import{_ as x}from"./ButtonDefault-CzWpVlv6.js";import{m as T}from"./bootstrap-vue-next-C0pyDr3k.js";import{u as h}from"./index-Dax_IkAt.js";import{s as j}from"./multiselect-Bk-p1X5E.js";import{_ as N}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{r as v,g as D,l as O,v as U,o as w,c as g,t as m,i as A,a as s,f as $,b as f,w as V,B as M,N as F,A as R,D as W}from"./index-Bb2UEb_P.js";const J={key:0,class:"section-block_title"},K={class:"form-field form-field--basic"},q={class:"form-field-input__wrapper"},z={class:"multiselect-option"},G={__name:"BlockSelectProfile",props:["modelValue","title","items","domainOwner"],emits:["update:modelValue"],setup(i,{emit:I}){const d=i,b=I,o=h(),r=v(null),u=D(()=>{const n=Object.keys(o.profileList).map(a=>{const e=o.profileList[a].TemplateID;if(e==="Natural"||e==="Juridical"||e==="Individual"||e==="NaturalPartner")return{value:o.profileList[a].ID,name:o.profileList[a].Name,contractID:o.profileList[a].ContractID}}).filter(Boolean);return d.domainOwner?n.filter(a=>{const e=o.profileList[a.value].TemplateID;return e==="Natural"||e==="Juridical"}):n});function p(n){b("update:modelValue",n)}return O(()=>{o.profileList&&(r.value=Object.keys(o.profileList)?.[0])}),U(d,()=>{r.value=d.modelValue}),(n,a)=>(w(),g("section",null,[i.title?(w(),g("h2",J,m(i.title),1)):A("",!0),s("div",K,[a[1]||(a[1]=s("div",{class:"form-field__label"},[$(" Выбрать профиль "),s("span",null,"*")],-1)),s("div",q,[f(M(j),{modelValue:r.value,"onUpdate:modelValue":a[0]||(a[0]=e=>r.value=e),class:"multiselect--white",placeholder:"Выбрать профиль",label:"name",options:i.items||u.value,disabled:i.items?.length<=1&&u.value?.length<=1,onChange:p},{singlelabel:V(({value:e})=>[s("span",null,"# "+m(String(e.value).padStart(5,"0"))+" / "+m(e.name),1)]),option:V(({option:e})=>[s("div",z," # "+m(String(e.value).padStart(5,"0"))+" / "+m(e.name),1)]),_:1},8,["modelValue","options","disabled"])])])]))}},H=N(G,[["__scopeId","data-v-f2bdb84c"]]),Q={class:"modal__body"},X={class:"list-item__title"},Y={class:"modal__input-row"},Z={class:"modal__input-row"},ee={class:"modal__buttons-wrap"},te={__name:"ModalWindowDomainSelectOwner",props:["data"],emits:["modalClose"],setup(i,{emit:I}){const d=F(),b=h(),o=v(null),r=v(!1),u=v(!1),p=R("emitter"),n=i,a=I,e=D(()=>{const l=Object.values(d.domainsList);return n.data.OrderID!==void 0&&n.data.OrderID!==null?l.filter(t=>t.OrderID===n.data.OrderID):null}),_=D(()=>b?.profileList),P=D(()=>Object.keys(_?.value).map(l=>({value:_.value?.[l]?.ID,name:_.value?.[l]?.Name})));O(()=>{P?.value.length<1&&p.emit("open-modal",{component:"NewProfile"})});function E(){a("modalClose")}function B(){p.emit("open-modal",{component:"AcceptCreateProfile"})}function L(){u.value=!0;let l;e.value&&e.value!==void 0?l=e.value[0].ID:l=n.data.DomainOrderID;const t={DomainOrderID:l,OwnerTypeID:"Profile",ProfileID:_.value[o.value]?.ID,Agree:r.value?"yes":"no"};d.DomainSelectOwner(t).then(({result:S,resultData:y})=>{S==="SUCCESS"&&E(),u.value=!1})}const k=l=>{l.key==="Enter"&&L()};return O(()=>{document.addEventListener("keyup",k),d.fetchDomainOrders()}),W(()=>{document.removeEventListener("keyup",k)}),(l,t)=>{const S=H,y=T,C=x;return w(),g("div",Q,[s("div",X," Владелец домена "+m(i.data?.Domain?i.data?.Domain:e.value?.[0]?.Domain),1),s("div",Y,[f(S,{modelValue:o.value,"onUpdate:modelValue":t[0]||(t[0]=c=>o.value=c),title:"","domain-owner":!0},null,8,["modelValue"])]),s("div",Z,[f(y,{modelValue:r.value,"onUpdate:modelValue":t[1]||(t[1]=c=>r.value=c)},{default:V(()=>t[4]||(t[4]=[$(" Согласен на передачу моих персональных данных регистратору ",-1)])),_:1,__:[4]},8,["modelValue"])]),s("div",ee,[f(C,{class:"select-contract__button modal__button",label:"Создать новый профиль",onClick:t[2]||(t[2]=c=>B())}),f(C,{class:"modal__button",label:"Сохранить",disabled:!r.value||o.value===null,"is-loading":u.value,onClick:t[3]||(t[3]=c=>L())},null,8,["disabled","is-loading"])])])}}},re=N(te,[["__scopeId","data-v-7a72483e"]]);export{re as default};
