import{g as w,i as L,aH as O,a as B,j as e,h as t,_ as p,f as y,bG as F}from"./main-634.js";import{j as C}from"./bf-25-81.js";import{F as x}from"./bf-767-388.js";import{l as D,f as H}from"./bf-717-463.js";import{F as b}from"./bf-457-387.js";import{C as u}from"./bf-297-103.js";import{S as $}from"./bf-26-460.js";import"./bf-534-247.js";import"./bf-299-245.js";function J({className:A=""}){var N;const{fieldKey:i}=w(),[r,g]=L(O),{css:a}=B();if(!i)return null;const l=r[i],m=(l==null?void 0:l.shippingType)==="dynamic",h=(l==null?void 0:l.taxType)==="dynamic",j=(N=l==null?void 0:l.lbl)!=null?N:"",v=()=>Object.entries(r).filter(n=>n[1].typ.match(/^(radio|number|currency)/)).map(n=>e.jsx("option",{value:n[0],children:n[1].adminLbl||n[1].lbl},n[0])),o=(s,d)=>{const n=y(r,c=>{if(d){if(c[i][s]=d,s==="locale"){const S=d.split(" - ");c[i].locale=S[S.length-1],c[i].language=d}}else delete c[i][s]});g(n),F({event:`${s} changed to ${d}: ${j||i}`,type:`${s}_changed`,state:{fields:n,fldKey:i}})},f=s=>{const{value:d}=s.target,n=y(r,c=>{d?c[i].shippingType=d:delete c[i].shippingType,delete c[i].shipping,delete c[i].shippingFld});g(n),F({event:`Shipping Type changed to "${d}": ${j||i}`,type:"set_shipping_type",state:{fields:n,fldKey:i}})},T=s=>{const{value:d}=s.target,n=y(r,c=>{d?c[i].taxType=d:delete c[i].taxType,delete c[i].tax,delete c[i].taxFld});g(n),F({event:`Tax type changed to "${d}": ${j||i}`,type:"set_tax_type",state:{fields:n,fldKey:i}})},_=()=>D.map(s=>({label:e.jsxs("div",{className:"flx flx-between",children:[e.jsx("span",{className:"btcd-ttl-ellipsis",children:s.region}),e.jsx("code",{className:"btcd-code",children:s.code})]}),title:`${s.region} - ${s.code}`,value:`${s.region} - ${s.code}`})),k=()=>H.map(s=>({label:s.label,value:s.value}));return e.jsxs("div",{className:A,children:[e.jsxs("div",{className:a(t.ml2,t.mr2,t.p1),children:[e.jsx("b",{children:p("Language")}),e.jsx(C,{className:"w-10 btcd-paper-drpdwn mt-1",options:_(),onChange:s=>o("locale",s),defaultValue:l.language||"",largeData:!0,singleSelect:!0})]}),e.jsx(b,{}),e.jsxs("div",{className:a(t.ml2,t.mr2,t.p1),children:[e.jsx("b",{children:p("Disable Card")}),e.jsx(C,{className:"w-10 btcd-paper-drpdwn mt-1 btcd-ttc",options:k(),onChange:s=>o("disableFunding",s),defaultValue:l.disableFunding||""})]}),e.jsx(b,{}),e.jsxs("div",{className:a(t.ml2,t.mr2,t.p1),children:[e.jsx("b",{children:p("Shipping Amount")}),e.jsx("br",{}),e.jsx(u,{id:"shpng-amnt-fxd",onChange:f,radio:!0,checked:!m,title:p("Fixed")}),e.jsx(u,{id:"shpng-amnt-dynmc",onChange:f,radio:!0,checked:m,title:p("Dynamic"),value:"dynamic"})]}),!m&&e.jsx("div",{className:a(t.ml2,t.mr2,t.p1),children:e.jsx($,{id:"spng-cst",cls:a(x.input),inpType:"number",title:p("Shipping Cost"),value:l.shipping||"",action:s=>o("shipping",s.target.value),className:a({mt:0})})}),m&&e.jsxs("div",{className:a(t.ml2,t.mr2,t.p1),children:[e.jsx("label",{htmlFor:"shippingFld",children:p("Select Shipping Amount Field")}),e.jsxs("select",{"data-testid":"slct-shpng-amnt",onChange:s=>o("shippingFld",s.target.value),name:"shippingFld",className:a(x.input),value:l.shippingFld||"",children:[e.jsx("option",{value:"",children:p("Select Field")}),v()]})]}),e.jsx(b,{}),e.jsxs("div",{className:a(t.ml2,t.mr2,t.p1),children:[e.jsx("b",{children:p("Tax Amount Type")}),e.jsx("br",{}),e.jsx(u,{id:"tx-amnt-fxd",onChange:T,radio:!0,checked:!h,title:p("Fixed")}),e.jsx(u,{id:"tx-amnt-dynmc",onChange:T,radio:!0,checked:h,title:p("Dynamic"),value:"dynamic"})]}),!h&&e.jsx("div",{className:a(t.ml2,t.mr2,t.p1),children:e.jsx($,{id:"tax",cls:a(x.input),inpType:"number",title:p("Tax (%)"),value:l.tax||"",action:s=>o("tax",s.target.value),className:a({mt:0})})}),h&&e.jsxs("div",{className:a(t.ml2,t.mr2,t.p1),children:[e.jsx("label",{htmlFor:"taxFld",children:p("Select Amount Field")}),e.jsxs("select",{"data-testid":"slct-amnt-fld",onChange:s=>o("taxFld",s.target.value),name:"taxFld",className:a(x.input),value:l.taxFld||"",children:[e.jsx("option",{value:"",children:p("Select Field")}),v()]})]})]})}export{J as default};
