var k=Object.defineProperty,M=Object.defineProperties;var D=Object.getOwnPropertyDescriptors;var b=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable;var w=(a,r,l)=>r in a?k(a,r,{enumerable:!0,configurable:!0,writable:!0,value:l}):a[r]=l,j=(a,r)=>{for(var l in r||(r={}))A.call(r,l)&&w(a,l,r[l]);if(b)for(var l of b(r))E.call(r,l)&&w(a,l,r[l]);return a},y=(a,r)=>M(a,D(r));import{i as I,aq as O,u as N,r as W,I as f,as as L,j as e,_ as t,p as c,e as P,d as $,b3 as z,aK as R,O as T,aS as U,f as B,m as C}from"./main-343.js";import{t as F}from"./bf-974-82.js";import{u as q}from"./bf-437-78.js";import{C as d}from"./bf-649-79.js";const J=()=>{const[a,r]=I(z),l=O(R),g=N(T),_=N(U),[p,u]=W.useState({show:!1,msg:""}),{isLoading:x}=q(["bitforms_get_form_abandonment_config",g],{formID:g},{fetchCondition:f&&L(a),onSuccess:s=>r(s)}),o=(s,m)=>{if(!f)return!0;r(h=>B(h,n=>{if(C(n,s,m),s==="active"&&m&&!("saveFormDraft"in n)&&(n.saveFormDraft=!0,n.saveMode="always"),s==="showWarningMsg"&&m&&!("warningMsg"in n)&&(n.warningMsg="Please note that your information is saved on our server as you enter it."),s==="saveFormDraft"&&(m?n.saveMode="always":delete n.saveMode),s==="saveEmptyFromDraft"&&(m?n.saveEmptyFromDraft=!0:delete n.saveEmptyFromDraft),s==="repopulateForm"&&m&&_.enabled.submission){const S=t('In order to repopulate form fields, it is necessary to store the submitted data in the database. Please make sure to turn off the "disable storing form submission data" option in the form settings.');u({show:!0,msg:S}),delete n.repopulateForm}})),l(h=>y(j({},h),{unsaved:!0}))},v=()=>{u({show:!1})},i={};return a.active?(i.opacity=1,i.pointerEvents="auto",i.userSelect="auto"):(i.opacity=.6,i.pointerEvents="none",i.userSelect="none"),e.jsxs("div",{className:"pos-rel",children:[e.jsxs("div",{className:"flx mt-4",children:[e.jsx("h2",{className:"m-0",children:t("Form Abandonment")}),!x&&e.jsx(c,{name:"status",action:s=>o("active",s.target.checked),checked:a.active||!1,className:"ml-2 flx"})]}),e.jsxs("h5",{className:"mt-3",children:[t("How to setup Form Abandonment & save partial form progress:"),e.jsx("a",{href:F.formAbandonment.link,target:"_blank",rel:"noreferrer",className:"yt-txt ml-1 mr-1",children:t("YouTube")}),e.jsx("a",{href:F.formAbandonmentDoc.link,target:"_blank",rel:"noreferrer",className:"doc-txt",children:t("Documentation")})]}),!f&&e.jsx("div",{className:"pro-blur flx",style:{height:"111%",left:-53,width:"104%"},children:e.jsxs("div",{className:"pro",children:[t("Available On"),e.jsx("a",{href:"https://www.bitapps.pro/bit-form",target:"_blank",rel:"noreferrer",children:e.jsx("span",{className:"txt-pro",children:t("Premium")})})]})}),x?e.jsx(P,{style:{display:"flex",justifyContent:"center",alignItems:"center",height:70,transform:"scale(0.7)"}}):e.jsx("div",{className:"w-5",children:e.jsxs("div",{style:i,className:"mt-4",children:[e.jsxs("div",{className:"mt-2 mb-2 flx",children:[e.jsx(c,{name:"dflt_temp",action:s=>o("showWarningMsg",s.target.checked),checked:a.showWarningMsg||!1,className:"flx"}),e.jsx("label",{htmlFor:"dflt_temp",children:t("Show warning message below the form description")}),e.jsx(d,{className:"ml-1",icnSize:14,width:600,children:t("Places an admin-defined message below the form description, making your users aware that their field values are being saved before submission.")})]}),a.showWarningMsg&&e.jsx("div",{className:"flx",children:e.jsx("input",{onChange:s=>o("warningMsg",s.target.value),name:"warningMsg",value:a.warningMsg||"",className:"btcd-paper-inp mr-2 w-10",placeholder:"Set warning message",type:"text"})}),e.jsxs("div",{className:`flx ${a.showWarningMsg?"mt-2":"mt-3"}`,children:[e.jsx(c,{name:"disable_loggin_user",action:s=>o("onlyLoggedInUsers",s.target.checked),checked:a.onlyLoggedInUsers||!1,className:"flx"}),e.jsx("label",{htmlFor:"disable_loggin_user",children:t("Save draft only for logged in users")})]}),e.jsxs("div",{className:"mt-3 flx",children:[e.jsx(c,{name:"repopulate_fields",action:s=>o("repopulateForm",s.target.checked),checked:a.repopulateForm||!1,className:"flx"}),e.jsx("label",{htmlFor:"repopulate_fields",children:t("Repopulate form fields with previous partial entry")}),e.jsx(d,{className:"ml-1",icnSize:14,width:600,children:t(`If the user is logged in, the form will be repopulated with the previous partial entry from the database.
                    Otherwise, from the local storage of the browser.
                    `)})]}),e.jsxs("div",{className:"mt-3 flx",children:[e.jsx(c,{name:"save_from_draft",action:s=>o("saveFormDraft",s.target.checked),checked:a.saveFormDraft||!1,className:"flx"}),e.jsx("label",{htmlFor:"save_from_draft",children:t("Save draft when user leaves the form page")}),e.jsx(d,{className:"ml-1",icnSize:14,width:600,children:t(`
                    If turned off, the form will save draft when clicks on the save button or using conditional logic.
                    `)})]}),e.jsxs("div",{className:"mt-3 flx",children:[e.jsx(c,{name:"saveEmptyFromDraft",action:s=>o("saveEmptyFromDraft",s.target.checked),checked:a.saveEmptyFromDraft||!1,className:"flx"}),e.jsx("label",{htmlFor:"saveEmptyFromDraft",children:t("Allow empty form as Save draft")}),e.jsx(d,{className:"ml-1",icnSize:14,width:600,children:t(`
                    If turned on, the empty form save as draft when leave page.
                    `)})]}),!1]})}),e.jsx($,{className:"custom-conf-mdl",mainMdlCls:"o-v",btnClass:"red",btnTxt:"Close",show:p.show,close:v,action:v,title:"Sorry",children:e.jsx("div",{className:"txt-center",children:p.msg})})]})};export{J as default};
