import{X as N,s as c,y as z,z as y,A,o as p,c as x,a as s,u as i,w as a,F as C,Z as B,b as n,d as e,P as D,t as h,V as F,n as I}from"./app-I4K73wff.js";import{_ as L}from"./AuthenticatedLayout-if5JcM-v.js";import{_ as S}from"./PrimaryLink-q8FflJbM.js";import{a as T,_ as k}from"./Modal-2XNj_mQu.js";import{_ as $}from"./SecondaryButton-KuZEOqaa.js";import{_ as K}from"./InputError-H3v_qTU0.js";import{_ as M}from"./InputLabel-kIOW7zCm.js";import{_ as O}from"./TextInput-QqzhSxrA.js";import"./index-9SbmYGxV.js";import"./index--wbxBylr.js";import"./index-dsvEKYml.js";import"./primeicons-LH9OCmKu.js";import"./_plugin-vue_export-helper-x3n3nnut.js";const X={class:"flex justify-center w-full"},Z={class:"lg:w-2/4 md:w-full sm:w-full"},G={class:"overflow-x-scroll md:overflow-x-auto"},H={class:"text-right p-4"},J={class:"overflow-x-scroll md:overflow-x-auto rounded-lg shadow"},Q={class:"w-full whitespace-no-wrap overflow-x-auto"},W=e("thead",null,[e("tr",{class:"border-b bg-gray-50 text-left text-xs font-semibold uppercase tracking-wide text-gray-500"},[e("th",{class:"border-b-2 border-gray-200 bg-gray-100 sm:px-5 sm:py-3 p-2 text-center text-xs font-semibold uppercase tracking-wider text-gray-600"}," Nombre "),e("th",{class:"border-b-2 border-gray-200 bg-gray-100 sm:px-5 sm:py-3 p-2 text-center text-xs font-semibold uppercase tracking-wider text-gray-600"}," Acciones ")])],-1),Y={class:"border-b border-gray-200 bg-white sm:px-5 sm:py-5 p-2 sm:text-sm text-xs text-center"},ee={class:"text-gray-900 whitespace-no-wrap"},se={class:"inline-flex w-full justify-center border-b border-gray-200 bg-white sm:px-5 sm:py-5 p-2 sm:text-sm text-xs"},te={class:"flex items-center border-b bg-gray-50 px-5 py-2 xs:flex-row justify-between text-gray-500 text-xs font-semibold"},oe=["disabled"],ae=e("i",{class:"fa-solid fa-arrow-left"},null,-1),re=[ae],le=["disabled"],ie=e("i",{class:"fa-solid fa-arrow-right"},null,-1),ne=[ie],ce={class:"p-6"},de=e("h2",{class:"text-lg font-medium text-gray-900"}," ¿Estás seguro de que quieres eliminar un rol de usuario? ",-1),ue=e("p",{class:"mt-1 text-sm text-gray-600"}," Una vez que se elimine el rol, todos los permisos se eliminaran permanentemente de los usuarios. Por favor ingrese su contraseña para confirmar que desea eliminar. ",-1),me={class:"mt-6"},_e={class:"mt-6 flex justify-end"},Ee={__name:"Index",props:{roles:Object},setup(P){const g=P,E=N("$swal"),m=c(!1),v=c(),o=z({password:""}),_=()=>{m.value=!1,o.reset()},V=r=>{m.value=!0,v.value=r},w=()=>{o.delete(route("roles.destroy",v.value),{preserveScroll:!0,onSuccess:()=>{_(),E({title:"Registro Eliminado",text:"El rol se ha eliminado exitosamente",icon:"success"})},onError:()=>passwordInput.value.focus(),onFinish:()=>o.reset()})},d=c(8),t=c(0),f=y(()=>Math.ceil(g.roles.length/d.value)),j=()=>{t.value>0&&t.value--},R=()=>{t.value<f.value-1&&t.value++};A(d,()=>{t.value=0});const U=c(""),q=y(()=>{const r=t.value*d.value,u=r+d.value;return g.roles.filter(b=>b.name.toLowerCase().includes(U.value.toLowerCase())).slice(r,u)});return(r,u)=>(p(),x(C,null,[s(i(B),{title:"Roles del sistema"}),s(L,null,{header:a(()=>[n(" Roles del sistema ")]),default:a(()=>[e("div",X,[e("div",Z,[e("div",G,[e("div",H,[s(S,{href:r.route("roles.create")},{default:a(()=>[n(" Agregar ")]),_:1},8,["href"])])]),e("div",J,[e("table",Q,[W,e("tbody",null,[(p(!0),x(C,null,D(q.value,l=>(p(),x("tr",{key:l.id,class:"text-gray-700"},[e("td",Y,[e("p",ee,h(l.name),1)]),e("td",se,[s($,{href:r.route("roles.edit",l.id),class:"mr-2"},{default:a(()=>[n(" Editar ")]),_:2},1032,["href"]),s(k,{onClick:b=>V(l.id)},{default:a(()=>[n("Eliminar")]),_:2},1032,["onClick"])])]))),128))])]),e("div",te,[e("button",{class:"hover:scale-125 transition duration-500 cursor-pointer",onClick:j,disabled:t.value===0},re,8,oe),e("p",null,"Pagina "+h(t.value+1)+" de "+h(f.value),1),e("button",{class:"hover:scale-125 transition duration-500 cursor-pointer",onClick:R,disabled:t.value===f.value-1},ne,8,le)])])])]),s(T,{show:m.value,onClose:_},{default:a(()=>[e("div",ce,[de,ue,e("div",me,[s(M,{for:"password",value:"Contraseña",class:"sr-only"}),s(O,{id:"password",ref:"passwordInput",modelValue:i(o).password,"onUpdate:modelValue":u[0]||(u[0]=l=>i(o).password=l),type:"password",class:"mt-1 block w-3/4",placeholder:"Contraseña",onKeyup:F(w,["enter"])},null,8,["modelValue"]),s(K,{message:i(o).errors.password,class:"mt-2"},null,8,["message"])]),e("div",_e,[s($,{onClick:_},{default:a(()=>[n(" Cancelar ")]),_:1}),s(k,{class:I(["ms-3",{"opacity-25":i(o).processing}]),disabled:i(o).processing,onClick:w},{default:a(()=>[n(" Eliminar rol ")]),_:1},8,["class","disabled"])])])]),_:1},8,["show"])]),_:1})],64))}};export{Ee as default};
