import{B as j,j as U,P as $,u as x,p as E,r as O,c as y,a as n,w as m,b as i,t as g,g as e,d as b,n as D,o as u,F as h,h as z,e as C,i as P}from"./app-CYVHboi-.js";import{_ as M}from"./AdminLayout-dyjRnxvr.js";import{_ as N}from"./ActionMessage-c7Zw_lRY.js";import{_ as T}from"./FormSection-DWaXENBe.js";import{_ as F}from"./AutoComplete-Ao6jtcfm.js";import{_ as R}from"./LoadingButton-CH88QwYm.js";import{_ as w}from"./CheckBox-FJj299Iw.js";import{_}from"./Input-VvJHlcSh.js";import{_ as G}from"./TabMenus-DKUg6crU.js";import{_ as H}from"./Textarea-D40HahXW.js";import"./browser-BwNzv7vE.js";import"./Modal-oUJ1UwGv.js";import"./DropdownLink-DM9xS5m9.js";import"./Loading-C17YK6G3.js";import"./ApplicationLogo-DRGlNRtq.js";import"./SectionTitle-DAHP_o6O.js";import"./InputError-u5FIXCwc.js";import"./InputLabel-dHPaqRUC.js";import"./Keyboard-VWzCpVN-.js";import"./composable-DK3kcOvi.js";const I={class:"px-0 pt-6 pb-0 sm:px-6 sm:py-8 lg:px-8"},K={class:"col-span-full flex gap-x-8 gap-y-4"},L={class:"col-span-6 sm:col-span-3"},q={class:"col-span-6 sm:col-span-3"},J={key:0,class:"col-span-full flex flex-col gap-4 rounded-md bg-gray-100 p-4 dark:bg-gray-800"},Q={class:"col-span-full"},W={class:"col-span-full"},X={class:"col-span-full"},Y={class:"col-span-full"},Z={class:"col-span-full"},ee={class:"text-mute mt-1 text-xs"},ke=Object.assign({layout:M},{__name:"Payment",props:{current:Object,payment_methods:Array},setup(f){const{t:d}=j({}),a=f,k=U([{label:d("General Settings"),route:"settings.index",icon:"settings"},{label:d("Mail Settings"),route:"settings.mail",icon:"envelope"},{label:d("Payment Settings"),route:"settings.payment",icon:"dollar"},{label:d("Scale Barcode Settings"),route:"settings.barcode",icon:"scale"}]);$().has("settings.pos")&&k.value.push({label:d("POS Settings"),route:"settings.pos",icon:"pos"}),$().has("shop.settings")&&k.value.push({label:d("Shop Settings"),route:"shop.settings",icon:"shop",external:!0});const r=x({gateway:a.current?.gateway||null,default_currency:a.current?.default_currency||"USD",stripe_terminal:a.current?.stripe_terminal==1||!1,static_payment_methods:a.current?.static_payment_methods?a.current.static_payment_methods.join(`
`):"",services:{...a.current?.services,paypal:{enabled:a.current?.services?.paypal?.enabled||!1,client_id:a.current?.services?.paypal?.client_id||null,secret:a.current?.services?.paypal?.secret||null,fixed:a.current?.services?.paypal?.fixed||null,same_country:a.current?.services?.paypal?.same_country||null,other_countries:a.current?.services?.paypal?.other_countries||null},stripe:{key:a.current?.services?.stripe?.key||null,secret:a.current?.services?.stripe?.secret||null,fixed:a.current?.services?.stripe?.fixed||null,same_country:a.current?.services?.stripe?.same_country||null,other_countries:a.current?.services?.stripe?.other_countries||null},paymes:{public_key:a.current?.services?.paymes?.public_key||null,secret_key:a.current?.services?.paymes?.secret_key||null},authorize:{login:a.current?.services?.authorize?.login||null,transaction_key:a.current?.services?.authorize?.transaction_key||null}}});E(()=>{Object.keys(a.payment_methods).forEach(l=>{Object.keys(a.payment_methods[l].fields).map(t=>{V(r,a.payment_methods[l].fields[t].config,A(a.current,a.payment_methods[l].fields[t].config)||null)})})});function A(l,t){return t.split(".").reduce((p,s)=>p&&p[s]!=="undefined"?p[s]:void 0,l)}function V(l,t,p){const s=t.split(".");let c=l;for(let o=0;o<s.length-1;o++){const v=s[o];(!c[v]||typeof c[v]!="object")&&(c[v]={}),c=c[v]}c[s[s.length-1]]=p,l[t]=p}const S=U(r.static_payment_methods||"");function B(){r.transform(l=>({...l,static_payment_methods:S.value.split(`
`).map(t=>t.trim()).filter(Boolean)})).post($("settings.payment.store"))}return(l,t)=>{const p=O("Head");return u(),y(h,null,[n(p,null,{default:m(()=>[i("title",null,g(l.$t("Payment Settings")),1)]),_:1}),n(e(G),{links:k.value},null,8,["links"]),i("div",I,[n(e(T),{onSubmitted:B},{title:m(()=>[b(g(l.$t("Payment Settings")),1)]),description:m(()=>[b(g(l.$t("Please configure the payment settings.")),1)]),form:m(()=>[i("div",K,[n(e(w),{id:"paypal-enabled",label:l.$t("Enable PayPal Payments"),checked:e(r).services.paypal.enabled,"onUpdate:checked":t[0]||(t[0]=s=>e(r).services.paypal.enabled=s),error:e(r).errors.services?.paypal?.enabled},null,8,["label","checked","error"]),n(e(w),{id:"stripe-terminal",label:l.$t("Enable Stripe Terminal"),checked:e(r).stripe_terminal,"onUpdate:checked":t[1]||(t[1]=s=>e(r).stripe_terminal=s),error:e(r).errors.stripe_terminal},null,8,["label","checked","error"])]),i("div",L,[n(e(_),{modelValue:e(r).default_currency,"onUpdate:modelValue":t[2]||(t[2]=s=>e(r).default_currency=s),error:e(r).errors.default_currency,label:l.$t("Default Currency")},null,8,["modelValue","error","label"])]),i("div",q,[n(e(F),{json:!0,id:"gateway",searchable:!1,label:l.$t("Credit Card Gateway"),modelValue:e(r).gateway,"onUpdate:modelValue":t[3]||(t[3]=s=>e(r).gateway=s),error:e(r).errors.gateway,suggestions:[{value:"PayPal Rest",label:"PayPal Rest"},{value:"Stripe",label:"Stripe"},...Object.keys(f.payment_methods)?.map(s=>({value:s,label:f.payment_methods[s].name}))]},null,8,["label","modelValue","error","suggestions"])]),f.payment_methods[e(r).gateway]?(u(),y("div",J,[(u(!0),y(h,null,z(f.payment_methods[e(r).gateway].fields,(s,c)=>(u(),y("div",{key:c},[s.type=="checkbox"?(u(),C(e(w),{key:0,id:s.config,checked:e(r)[s.config]==1,"onUpdate:checked":o=>V(e(r),s.config,o?1:0),label:s.label||c.replace(/_/g," ").replace(/\b\w/g,o=>o.toUpperCase()),error:e(r).errors[s.config]?e(r).errors[s.config].replace("services.","").replaceAll("."," "):null},null,8,["id","checked","onUpdate:checked","label","error"])):(u(),C(e(_),{key:1,modelValue:e(r)[s.config],"onUpdate:modelValue":o=>e(r)[s.config]=o,onChange:o=>V(e(r),s.config,o.target.value),label:s.label||c.replace(/_/g," ").replace(/\b\w/g,o=>o.toUpperCase()),error:e(r).errors[s.config]?e(r).errors[s.config].replace("services.","").replaceAll("."," "):null},null,8,["modelValue","onUpdate:modelValue","onChange","label","error"]))]))),128))])):P("",!0),e(r).services.paypal.enabled||e(r).gateway=="PayPal Rest"?(u(),y(h,{key:1},[i("div",Q,[n(e(_),{label:l.$t("PayPal Client Id"),modelValue:e(r).services.paypal.client_id,"onUpdate:modelValue":t[4]||(t[4]=s=>e(r).services.paypal.client_id=s),error:e(r).errors["services.paypal.client_id"]?e(r).errors["services.paypal.client_id"].replace("services.","").replaceAll("."," "):null},null,8,["label","modelValue","error"])]),i("div",W,[n(e(_),{label:l.$t("PayPal Secret"),modelValue:e(r).services.paypal.secret,"onUpdate:modelValue":t[5]||(t[5]=s=>e(r).services.paypal.secret=s),error:e(r).errors["services.paypal.secret"]?e(r).errors["services.paypal.secret"].replace("services.","").replaceAll("."," "):null},null,8,["label","modelValue","error"])])],64)):P("",!0),e(r).stripe_terminal||e(r).gateway=="Stripe"?(u(),y(h,{key:2},[i("div",X,[n(e(_),{label:l.$t("Stripe Publishable Key"),modelValue:e(r).services.stripe.key,"onUpdate:modelValue":t[6]||(t[6]=s=>e(r).services.stripe.key=s),error:e(r).errors["services.stripe.key"]?e(r).errors["services.stripe.key"].replace("services.","").replaceAll("."," "):null},null,8,["label","modelValue","error"])]),i("div",Y,[n(e(_),{label:l.$t("Stripe Secret Key"),modelValue:e(r).services.stripe.secret,"onUpdate:modelValue":t[7]||(t[7]=s=>e(r).services.stripe.secret=s),error:e(r).errors["services.stripe.secret"]?e(r).errors["services.stripe.secret"].replace("services.","").replaceAll("."," "):null},null,8,["label","modelValue","error"])])],64)):P("",!0),i("div",Z,[n(e(H),{rows:"3",modelValue:S.value,"onUpdate:modelValue":t[8]||(t[8]=s=>S.value=s),label:l.$t("Payment Methods"),error:e(r).errors.static_payment_methods,placeholder:l.$t("Enter payment methods, one per line")},null,8,["modelValue","label","error","placeholder"]),i("p",ee,g(l.$t("Enter one method per line. These will appear in the payment method dropdown.")),1)])]),actions:m(()=>[n(e(N),{on:e(r).recentlySuccessful,class:"me-3"},{default:m(()=>[b(g(l.$t("Saved.")),1)]),_:1},8,["on"]),n(e(R),{class:D({"opacity-25":e(r).processing}),loading:e(r).processing},{default:m(()=>[b(g(l.$t("Save")),1)]),_:1},8,["class","loading"])]),_:1})])],64)}}});export{ke as default};
