import{r as o,u as q,h4 as D,j as l,aP as L,gd as O,h5 as R,aQ as G,h6 as J,h7 as U,a6 as j,g as V,au as Q,i as Y,ct as z}from"./index-CXyQ5sGC.js";import{l as Z}from"./lodash-CQGrF3PQ.js";const S=500,m=5,oe=(e,n)=>({...e>S?{max:{value:S,message:"maximum_max_day_deposit_error"}}:{max:{value:n,message:"Daily limit should not exceed the weekly limit."}}}),re=(e,n,t,h,r)=>({...r?n>=e?n>=m?{min:{value:e,message:"Weekly limit should not exceed the monthly limit."}}:{min:{value:m,message:"min_week_deposit_limit_error"}}:n>=m?{min:{value:S,message:"Weekly limit should not be lower than the daily limit."}}:{min:{value:m,message:"min_week_deposit_limit_error"}}:{min:{value:e,message:"min_week_deposit_limit_error"}},...r&&e>S&&n=1500&&n>1500&&{min:{value:1500,message:"max_week_deposit_limit_error"}},...r?n>1500?{max:{value:1500,message:"max_week_deposit_limit_error"}}:n>t?{max:{value:t,message:"Weekly limit should not exceed the monthly limit."}}:n({...r?t>=m?tt&&t>2400&&{min:{value:2400,message:"max_month_deposit_limit_error"}},...!r&&{max:{value:e*h,message:"max_month_deposit_limit_error"}}}),ue=e=>({min:{value:m,message:"The minimum deposit limit should be £5 or more."},max:{value:e,message:"Daily limit should not exceed the weekly limit."}}),me=(e,n,t)=>({...n>=m?{min:{value:e,message:"Weekly limit should not be lower than the daily limit."}}:{min:{value:m,message:"The minimum deposit limit should be £5 or more."}},max:{value:t,message:"Weekly limit should not exceed the monthly limit."}}),ce=(e,n,t)=>({...t>=m?t{const I=q(),N=o.useRef(c),[w,W]=o.useState(""),[K,B]=o.useState(!1),[_,P]=o.useState({phoneCode:!1,phoneNumber:!1}),v={phoneCode:[],phoneNumber:[]},{phoneCode:A,phoneNumber:y}=o.useMemo(()=>{const{phoneCode:s,phoneNumber:u}=i;return{phoneCode:s||"",phoneNumber:u||""}},[i]);v.phoneCode.push(_.phoneCode?"focused":""),v.phoneNumber.push(_.phoneNumber?"focused":""),A.length>0&&v.phoneCode.push("filled"),y.length>0&&v.phoneNumber.push("filled"),n&&(v.phoneCode.push(e?"invalid":"valid"),v.phoneNumber.push(e?"invalid":"valid"));const g=s=>{const{type:u,target:p}=s;if(!b&&p.value&&!U.test(p.value))return!1;const X={phoneCode:A,phoneNumber:y,countryCode:N.current,[p.name]:p.value};E(u,f,X),u===j.FOCUS?P({..._,[p.name]:!0}):u===j.BLUR&&(P({..._,[p.name]:!1}),X.phoneNumber=V(y))},F=s=>{W(""),g(s)},$=()=>{W(ee)};o.useEffect(()=>{N.current=i.countryCode},[c,i.countryCode]);const[H]=o.useMemo(()=>{const s=Object.entries(O);return s.find(([u,{code:p}])=>p===i.phoneCode&&(!N.current||u===N.current||u===i.countryCode))||s[0]},[i.countryCode,i.phoneCode]),M=D().find(s=>s.value===i.countryCode);return l.jsxs("div",{className:"form-controls-group-bc telephone",children:[l.jsxs("div",{className:"form-controls-field-content",children:[x&&l.jsx("div",{className:`form-controls-field-bc country-code ${K?"is-expanded-field":""}`,children:l.jsx(L,{inputValue:String(H),onChange:s=>{N.current=s,g({type:"change",target:{name:"phoneCode",value:O[s].code}})},setIsExpanded:B,title:I("Code"),readOnly:r!=null&&r.isCountryCodeEditable?!1:D().length===1,filterType:"number",icon:`ftr-lang-bar-flag-bc flag-bc ${M==null?void 0:M.iconClassName}`,searchable:!0,regExp:R,children:D().map(s=>{var u;return l.jsx(G,{value:s.value,label:s.code,className:`ftr-lang-bar-flag-bc flag-bc ${(u=O[s.value])==null?void 0:u.iconClassName}`},s.value)})})}),l.jsx("div",{className:"form-controls-field-bc",children:l.jsx("div",{className:`form-control-bc default ${v.phoneNumber.join(" ")}`,children:l.jsxs("label",{className:"form-control-label-bc inputs",children:[b?l.jsx(J,{mask:String(b),maskPlaceholder:w,type:"tel",name:"phoneNumber",className:"form-control-input-bc",onChange:g,onBlur:g,onFocus:g,onBlurCapture:F,onFocusCapture:$,value:y,...k}):l.jsx("input",{type:"tel",name:"phoneNumber",className:"form-control-input-bc",onChange:g,onBlur:g,onFocus:g,value:y,...k}),l.jsx("i",{className:"form-control-input-stroke-bc"}),l.jsx("span",{className:"form-control-title-bc ellipsis",children:I(h)})]})})})]}),n&&e?l.jsx("div",{className:"form-control-message-holder-bc",children:l.jsx("span",{className:"form-control-message-bc",children:I(e)})}):null]})},he=o.memo(ne),le=()=>l.jsx("div",{className:"form-control-bc",children:l.jsx("label",{className:"form-control-label-bc inputs",children:l.jsx("div",{className:"skeleton-loader-full-banner"})})}),se=({options:e,readOnly:n=!1,country_code:t,setRules:h,manuallyChanged:r,...a})=>{const E=Q(),C=o.useRef({rules:a.rules,onChange:a.onChange}),[{loading:T,data:f},i]=o.useState({loading:!0,data:[]}),b=n?f.length===0?JSON.stringify({}):null:JSON.stringify({country_code:t});return o.useEffect(()=>{C.current.rules=a.rules,C.current.onChange=a.onChange},[a.onChange,a.rules]),o.useEffect(function(){b&&(i({loading:!0,data:[]}),Y.get(JSON.parse(b),"get_partner_banks").then(({result:d,details:c})=>{if(d===0)return c;throw new Error}).then(d=>Z("Order",d).map(c=>({value:c.Id,label:c.Name}))).then(d=>{E.current&&i({loading:!1,data:d})}).catch(()=>{E.current&&i({loading:!1,data:[]})}))},[E,b]),o.useEffect(function(){var d;if(!T){if(f.length)a.value||C.current.onChange(j.CHANGE,a.name,String(f[0].value));else if((d=C.current.rules)!=null&&d.required){const c={...C.current.rules};return h(a.name,{...c,required:null}),()=>{h(a.name,c)}}}},[T,f,a.name,a.value,h]),l.jsx("div",{children:T?l.jsx(le,{}):l.jsx(z,{options:f,readOnly:f.length===0||n,...a})})},de=o.memo(se);export{he as I,le as a,re as b,ie as c,de as d,ue as e,me as f,ce as g,oe as m};