import{d as M,G as j,c as C,s as k,v as F,a as u,o as s,w as d,g as n,u as i,i as H,j as l,e as $,f as _,l as w,h as v,b as g,F as V,p as P,k as I,W as c}from"./app-Cb9hmj6k.js";import{a as U}from"./AppLayout.vue_vue_type_script_setup_true_lang-CteAxl0C.js";import{_ as W,a as D}from"./Layout.vue_vue_type_script_setup_true_lang-BUO1b7TX.js";import{_ as T}from"./Input.vue_vue_type_script_setup_true_lang-t_rUv_4v.js";import{_ as f}from"./AppLogoIcon.vue_vue_type_script_setup_true_lang-DKWl2XLX.js";import{t as h}from"./index-bRFR14ax.js";import{P as G,T as q}from"./trash-Cw7Sd6FH.js";import"./index-hboZUdbT.js";import"./RovingFocusGroup-CP1IPgEn.js";import"./Separator.vue_vue_type_script_setup_true_lang-BOE17VcD.js";const A={class:"space-y-6"},J={class:"flex gap-2"},O={class:"border rounded-xl overflow-hidden"},Q={class:"flex-1"},R={key:0,class:"text-sm"},X={class:"flex items-center gap-3"},Y=["onClick"],Z={key:0,class:"text-center text-sm text-muted-foreground py-6"},ee={class:"flex gap-2 flex-wrap"},pe=M({__name:"Priorities",setup(te){const K=[{title:"Приоритеты",href:"/settings/priorities"}],y=j(),x=C(()=>y.props.priorities),N=C(()=>y.props.editingPriority),m=k(""),a=k(""),o=k(null);F(N,t=>{t&&(o.value=t.id,a.value=t.name)},{immediate:!0});function S(){m.value.trim()&&c.post("/settings/priorities",{name:m.value},{preserveScroll:!0,onSuccess:()=>{m.value="",h.success("Приоритет успешно добавлен")}})}function z(t){c.get(`/settings/priorities/${t.id}/edit`,{},{preserveScroll:!0,preserveState:!0})}function b(){!o.value||!a.value.trim()||c.put(`/settings/priorities/${o.value}`,{name:a.value},{preserveScroll:!0,onSuccess:()=>{o.value=null,a.value="",h.success("Приоритет успешно обновлён")}})}function B(){o.value=null,a.value="",c.get("/settings/priorities",{},{preserveScroll:!0,preserveState:!0})}function E(t){confirm("Вы уверены, что хотите удалить этот приоритет?")&&c.delete(`/settings/priorities/${t}`,{preserveScroll:!0,onSuccess:()=>{h.success("Приоритет успешно удалён")}})}function L(t){t&&c.visit(t,{preserveScroll:!0,preserveState:!0})}return(t,r)=>(s(),u(U,{breadcrumbs:K},{default:d(()=>[n(i(H),{title:"Приоритеты"}),n(W,null,{default:d(()=>[l("div",A,[n(D,{title:"Приоритеты",description:"Управление приоритетами заявок"}),l("div",J,[n(i(T),{modelValue:m.value,"onUpdate:modelValue":r[0]||(r[0]=e=>m.value=e),placeholder:"Название приоритета",onKeydown:$(_(S,["prevent"]),["enter"])},null,8,["modelValue","onKeydown"]),n(i(f),{onClick:S},{default:d(()=>r[2]||(r[2]=[w("Добавить")])),_:1,__:[2]})]),l("div",O,[(s(!0),v(V,null,P(x.value.data,e=>(s(),v("div",{key:e.id,class:"flex items-center justify-between px-4 py-2 hover:bg-muted transition"},[l("div",Q,[o.value!==e.id?(s(),v("span",R,I(e.name),1)):(s(),u(i(T),{key:1,modelValue:a.value,"onUpdate:modelValue":r[1]||(r[1]=p=>a.value=p),class:"max-w-xs",onKeydown:$(_(b,["prevent"]),["enter"])},null,8,["modelValue","onKeydown"]))]),l("div",X,[o.value!==e.id?(s(),u(i(f),{key:0,size:"sm",variant:"outline",onClick:_(p=>z(e),["stop"]),class:"border-none shadow-none cursor-pointer"},{default:d(()=>[n(i(G),{class:"w-4 h-4"})]),_:2},1032,["onClick"])):g("",!0),o.value===e.id?(s(),u(i(f),{key:1,size:"sm",onClick:b,class:"cursor-pointer"},{default:d(()=>r[3]||(r[3]=[w(" Сохранить ")])),_:1,__:[3]})):g("",!0),o.value===e.id?(s(),u(i(f),{key:2,size:"sm",variant:"ghost",onClick:B,class:"cursor-pointer"},{default:d(()=>r[4]||(r[4]=[w(" Отмена ")])),_:1,__:[4]})):g("",!0),l("span",{class:"text-xs text-red-500 cursor-pointer hover:underline",onClick:_(p=>E(e.id),["stop"])},[n(i(q),{class:"w-5 h-5"})],8,Y)])]))),128)),x.value.data.length?g("",!0):(s(),v("div",Z," Нет приоритетов "))]),l("div",ee,[(s(!0),v(V,null,P(x.value.links,(e,p)=>(s(),u(i(f),{key:p,size:"sm",variant:"outline",disabled:!e.url,onClick:se=>L(e.url),class:"cursor-pointer",innerHTML:e.label},null,8,["disabled","onClick","innerHTML"]))),128))])])]),_:1})]),_:1}))}});export{pe as default};
