import{E as e,N as t,O as n,Q as r,Rt as i,S as a,_t as o,b as s,dt as c,ft as l,kt as u,n as d,q as f,x as p,y as m}from"./vue-i18n-Bp4YYb-2.js";import{Br as h,C as g,F as _,Lt as v,ir as y,sr as b,va as x,ya as S,zi as C}from"./index-BOiiIZox.js";import{t as w}from"./multiselect-CmmgN80g.js";var T={class:`flex flex-col justify-between min-w-96 w-[40vw] min-h-max h-[40vh]`},E={class:`flex flex-col gap-y-4`},D={class:`my-2 text-center text-lg`},O={class:`font-bold`},k={class:`ml-3 font-light text-sm`},A={class:`flex flex-row justify-between mt-4`},j=n({__name:`ApplyToProfiles`,props:{functionUID:{}},emits:[`close`],setup(t,{emit:n}){let p=n,j=t,M=v(),N=y(),P=b(),F=S(),I=x(),{t:L}=d(),R=u([]),z=u([]),B=N.functions.find(e=>e.uid===j.functionUID)?.name??`unknown`;R.value=N.profiles.filter(e=>e.uid!==`0`&&e.p_type===C.Graph).map(e=>({profileUID:e.uid,profileName:e.name,functionUID:e.function_uid})),(()=>{for(let e of R.value)e.functionUID===j.functionUID&&z.value.push(e)})();let V=async()=>{for(let e of z.value)I.params!=null&&I.params.profileUID===e.profileUID&&await F.push({name:`startup-page`}),N.profiles.find(t=>t.uid===e.profileUID).function_uid=j.functionUID,await N.updateProfile(e.profileUID)?P.add({severity:`success`,summary:L(`common.success`),detail:L(`views.profiles.profileUpdated`),life:3e3}):P.add({severity:`error`,summary:L(`common.error`),detail:L(`views.profiles.profileUpdateError`),life:3e3});p(`close`)};return(t,n)=>{let u=r(`tooltip`);return f(),a(`div`,T,[m(`div`,E,[m(`p`,D,[m(`span`,O,o(i(B)),1)]),m(`small`,k,o(i(L)(`components.wizards.functionApply.profilesApply`)),1),l(e(i(w),{modelValue:z.value,"onUpdate:modelValue":n[0]||(n[0]=e=>z.value=e),options:R.value,class:`w-full h-11 bg-bg-one items-center`,filter:``,checkmark:``,"option-label":`profileName`,"filter-placeholder":i(L)(`common.search`),invalid:z.value.length===0,"scroll-height":`40rem`,"dropdown-icon":`pi pi-chart-line`,placeholder:i(L)(`components.wizards.functionApply.selectProfiles`)},null,8,[`modelValue`,`options`,`filter-placeholder`,`invalid`,`placeholder`]),[[u,{escape:!1,value:i(L)(`components.wizards.functionApply.profilesTooltip`)},void 0,{top:!0}]])]),m(`div`,A,[e(i(_),{class:`w-24 bg-bg-one`,label:i(L)(`common.cancel`),onClick:n[1]||(n[1]=e=>p(`close`))},null,8,[`label`]),l((f(),s(i(_),{class:`bg-accent/80 hover:!bg-accent w-32`,label:i(L)(`common.apply`),disabled:z.value.length===0,onClick:V},{default:c(()=>[e(i(g),{class:`outline-0`,type:`mdi`,path:i(h),size:i(M).getREMSize(1.5)},null,8,[`path`,`size`])]),_:1},8,[`label`,`disabled`])),[[u,i(L)(`views.speed.applySetting`),void 0,{top:!0}]])])])}}}),M=n({__name:`Wizard`,setup(e){let n=t(`dialogRef`),r=()=>{n.value.close()},a=n.value.data.functionUID,o=u(1);return(e,t)=>o.value===1?(f(),s(j,{key:0,"function-u-i-d":i(a),onClose:r},null,8,[`function-u-i-d`])):p(``,!0)}});export{M as default};