import{u as g}from"./index-Dax_IkAt.js";import{s as h}from"./multiselect-Bk-p1X5E.js";import{_ as S}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{H as C,r as B,g as N,l as V,o as d,c,t as l,i as w,a as s,f as D,b as I,w as m,B as y,I as f}from"./index-Bb2UEb_P.js";const x={key:0,class:"tw-mb-2"},T={class:"form-field form-field--basic"},L={class:"form-field-input__wrapper"},P={class:"tw-mr-2"},E={class:"tw-text-right"},k={__name:"BlockSelectContract",props:f({title:{type:String,default:""},hasBalance:{type:Boolean,default:!1},allowPartner:{type:Boolean,default:!1}},{modelValue:{type:Number},modelModifiers:{}}),emits:f(["update"],["update:modelValue"]),setup(r,{emit:p}){const n=r,_=C(r,"modelValue"),v=p,i=g(),u=B(null),o=N(()=>{const a=["Natural","Juridical","Default","Public","Individual","NaturalPartner"];return Object.values(i.contractsList).filter(e=>!(!a.includes(e.TypeID)||e.IsHidden||!n.allowPartner&&e.TypeID==="NaturalPartner"||n.hasBalance&&Number(e.Balance)<=0)).map(e=>({value:Number(e.ID),name:e.Customer,balance:e.Balance}))});function b(a){_.value=a,v("update")}return V(()=>{if(o.value?.length&&i.contractsList){const a=o.value[0].value;i.contractsList[a]?u.value=a:console.error("Договор не найден:",a)}}),(a,e)=>(d(),c("div",null,[r.title?(d(),c("h2",x,l(n.title),1)):w("",!0),s("div",T,[e[1]||(e[1]=s("div",{class:"form-field__label"},[D(" Выбрать договор "),s("span",null,"*")],-1)),s("div",L,[I(y(h),{modelValue:u.value,"onUpdate:modelValue":e[0]||(e[0]=t=>u.value=t),class:"multiselect--white tw-h-[44px]",placeholder:"Выбрать договор",label:"name",options:o.value,disabled:o.value?.length<=1,onChange:b},{singlelabel:m(({value:t})=>[s("div",P," # "+l(t.value?t.value.toString().padStart(5,"0"):String(t).padStart(5,"0"))+" / "+l(t.name)+" / "+l(t.balance+" руб"),1)]),option:m(({option:t})=>[s("div",E," # "+l(t.value.toString().padStart(5,"0"))+" / "+l(t.name)+" / "+l(t.balance+" руб"),1)]),_:1},8,["modelValue","options","disabled"])])])]))}},R=S(k,[["__scopeId","data-v-59fef4f8"]]);export{R as _};
