import{I as e,U as t,_ as n,bt as r,d as i,dt as a,lt as o,nt as s,p as c,qt as l,u,v as d,z as f}from"./runtime-core.esm-bundler.v79eHMSw.js";import{t as p}from"./notification.Fq1yjFBe.js";import{t as m}from"./i18n.DdD8a55v.js";import{t as h}from"./_plugin-vue_export-helper.BDNMzG2s.js";import{t as g}from"./Api.Bn9e8nm9.js";import{t as _}from"./PageSkeleton.D9UH8cao.js";var v={class:`smb2b-settings-page`},y={class:`smb2b-settings-page__head`},b={class:`smb2b-muted`},x={class:`smb2b-muted smb2b-small`},S={class:`smb2b-muted smb2b-small`},C=h({__name:`DataUninstall`,setup(h){let C=a(!0),w=a(!1),T=o({remove_data_on_uninstall:!1,remove_financial_data:!1}),E=(e,t=`success`)=>p({type:t,message:e}),D=async()=>{C.value=!0;try{let e=await g.get(`/settings`);Object.assign(T,e?.data?.settings||{})}catch(e){E(e.message,`error`)}finally{C.value=!1}},O=async()=>{w.value=!0;try{let e=await g.post(`/settings`,{settings:{...T}});Object.assign(T,e?.data?.settings||{}),E(e?.message||m(`Settings saved.`))}catch(e){E(e.message,`error`)}finally{w.value=!1}};return e(D),(e,a)=>{let o=t(`el-button`),p=t(`el-checkbox`),h=t(`el-form-item`),g=t(`el-form`),E=t(`el-card`);return f(),c(`div`,v,[u(`div`,y,[u(`div`,null,[u(`h1`,null,l(r(m)(`Data & uninstall`)),1),u(`p`,b,l(r(m)(`What happens to your data if the plugin is ever removed.`)),1)]),d(o,{type:`primary`,loading:w.value,disabled:C.value,onClick:O},{default:s(()=>[n(l(r(m)(`Save changes`)),1)]),_:1},8,[`loading`,`disabled`])]),C.value?(f(),i(_,{key:0,variant:`form`})):(f(),i(E,{key:1,shadow:`never`},{header:s(()=>[u(`strong`,null,l(r(m)(`When you uninstall`)),1)]),default:s(()=>[d(g,{"label-position":`top`},{default:s(()=>[d(h,null,{default:s(()=>[d(p,{modelValue:T.remove_data_on_uninstall,"onUpdate:modelValue":a[0]||=e=>T.remove_data_on_uninstall=e},{default:s(()=>[n(l(r(m)(`Delete B2B settings, groups and pricing when the plugin is deleted`)),1)]),_:1},8,[`modelValue`]),u(`div`,x,l(r(m)(`Off by default, so deleting the plugin by accident doesn’t lose your setup. Credit and invoice records are always kept unless you also tick the box below.`)),1)]),_:1}),d(h,null,{default:s(()=>[d(p,{modelValue:T.remove_financial_data,"onUpdate:modelValue":a[1]||=e=>T.remove_financial_data=e,disabled:!T.remove_data_on_uninstall},{default:s(()=>[n(l(r(m)(`Also delete credit ledgers and financial records`)),1)]),_:1},8,[`modelValue`,`disabled`]),u(`div`,S,l(r(m)(`Only tick this if you’re sure. You may be legally required to keep accounting records — export them first if in doubt.`)),1)]),_:1})]),_:1})]),_:1}))])}}},[[`__scopeId`,`data-v-3bb29616`]]);export{C as default};