var k=Object.defineProperty;var u=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var j=(s,n,c)=>n in s?k(s,n,{enumerable:!0,configurable:!0,writable:!0,value:c}):s[n]=c,r=(s,n)=>{for(var c in n||(n={}))A.call(n,c)&&j(s,c,n[c]);if(u)for(var c of u(n))O.call(n,c)&&j(s,c,n[c]);return s};import{d as o,_ as a,z as m,j as e}from"./main.2.8.1.js";import{d as b}from"./react-router-dom.9mCuUg3q.js";import{r as p}from"./index.wO-AxluA.js";import{S as x}from"./SingleToggle2.DZ0IpcUz.js";import{S as F}from"./SnackMsg.S8DrwLlT.js";function z(){const[s,n]=b.useState({}),[c,f]=b.useState([]),[N,v]=b.useState({show:!1});b.useEffect(()=>{const i=o({},"analytics/check","","GET").then(t=>{f(t.data)}),l=o({},"get/config",null,"GET").then(t=>("success"in t&&t.success&&n(t.data),t!=null&&t.success?a("Successfully fetched","bit-integrations"):"Error"));Promise.all([i,l]).catch(t=>{console.error(t)}),m.promise(l,{success:t=>t,error:a("Error Occurred","bit-integrations"),loading:a("Fetching...")})},[]);const y=i=>{const l=r({},s),t=o({data:l},"app/config").then(d=>{if("success"in d&&d.success)return a("Save successfully done","bit-integrations");delete l[i],n(r({},l))}).catch(()=>a("Failed to save","bit-integrations"));m.promise(t,{success:d=>d,error:a("Error Occurred","bit-integrations"),loading:a("Updating...")})},w=i=>{o({isChecked:i},"analytics/optIn").then(l=>{m.success(a("Opt-in status updated","bit-integrations"))}).catch(()=>{m.error(a("Failed to save","bit-integrations"))})},g=p.useAsyncDebounce(y,500),_=p.useAsyncDebounce(w,500),h=({target:{name:i,checked:l}})=>{const t=r({},s);l?t[i]=!0:delete t[i],n(t),g(i)},S=({target:{name:i,value:l}})=>{const t=r({},s);l?t[i]=l:delete t[i],n(t),g(i)},E=()=>{const i=!c;f(i),_(i)};return e.jsxs("div",{className:"btcd-f-settings",children:[e.jsx(F,{snack:N,setSnackbar:v}),e.jsxs("div",{id:"btcd-settings-wrp",className:"btcd-s-wrp",children:[e.jsxs("div",{className:"w-6 mt-3",children:[e.jsxs("div",{className:"flx flx-between sh-sm br-10 btcd-setting-opt",children:[e.jsx("div",{children:e.jsxs("b",{children:[e.jsx("span",{className:"btcd-icn  icn-trash-fill mr-2"}),a("Erase all data of this plugin in deletion","bit-integrations")]})}),e.jsx(x,{action:h,name:"erase_db",checked:s==null?void 0:s.erase_db,className:"flx"})]}),e.jsx("br",{})]}),e.jsxs("div",{className:"w-6 mt-3",children:[e.jsxs("div",{className:"flx flx-between sh-sm br-10 btcd-setting-opt",children:[e.jsxs("div",{className:"flx flx-start",children:[e.jsx("span",{className:"btcd-icn icn-information-outline mr-2"}),e.jsxs("div",{children:[e.jsx("b",{children:a("Opt In Telemetry Data","bit-integrations")}),e.jsx("br",{}),e.jsx("small",{children:a("If you turn off, Bit Integrations will no longer collect any telemetry data","bit-integrations")})]})]}),e.jsx(x,{action:E,name:"erase_db",checked:c,className:"flx"})]}),e.jsx("br",{})]}),e.jsxs("div",{className:"w-6 mt-3",children:[e.jsxs("div",{className:"flx flx-between sh-sm br-10 btcd-setting-opt",children:[e.jsx("div",{className:"",children:e.jsxs("b",{children:[e.jsx("span",{className:"btcd-icn icn-trash-fill mr-2"}),a("Specify after how many days  old log will be deleted","bit-integrations")]})}),e.jsxs("div",{className:"flx",children:[e.jsx("input",{onChange:S,name:"day",value:s==null?void 0:s.day,disabled:!s.enable_log_del,className:"btcd-paper-inp mr-2 wdt-100",placeholder:"Day",type:"number",min:"1"}),e.jsx(x,{action:h,name:"enable_log_del",checked:s==null?void 0:s.enable_log_del,className:"flx"})]})]}),e.jsx("br",{})]}),e.jsx("div",{className:"w-6 mt-3",children:e.jsxs("div",{className:"flx flx-between sh-sm br-10 btcd-setting-opt",children:[e.jsxs("div",{className:"flx flx-start",children:[e.jsx("span",{className:"btcd-icn icn-email mr-2"}),e.jsxs("div",{children:[e.jsx("b",{children:a("Enable Email Notifications for Failed Integrations","bit-integrations")}),e.jsx("br",{}),e.jsx("small",{children:a("When enabled, you will receive an email notification to the admin email whenever an integration execution fails","bit-integrations")})]})]}),e.jsx(x,{action:h,name:"enable_failure_email",checked:s==null?void 0:s.enable_failure_email,className:"flx"})]})}),e.jsx("div",{className:"mb-50"})]})]})}export{z as default};
