import{r as V,c as o,a as r,u as c,Z as N,w as n,b as t,d as g,o as a,F as p,e as m,t as d,v as _,i as f,f as b,N as $}from"./app-z_grtNg1.js";import{_ as P}from"./AdminLayout-D8-5CkB9.js";import{_ as j}from"./AppCard-C2KBW1s0.js";import{_ as D}from"./AppTable-7n8nNCI3.js";import{_ as F}from"./StatusBadge-DAu0ZF3H.js";import"./ToastStack-xenoaUxd.js";const B={class:"flex items-center justify-between gap-4"},M={class:"mx-auto max-w-7xl space-y-6 px-4 py-6 sm:px-6 lg:px-8"},U={class:"grid gap-3 sm:grid-cols-4"},E=["value"],I=["value"],O=["value"],q={class:"divide-y divide-gray-100 text-sm"},G={class:"px-4 py-3"},H={class:"font-medium text-gray-900"},L={class:"text-xs text-gray-500"},R={class:"px-4 py-3"},T={class:"px-4 py-3"},Z={class:"px-4 py-3"},z={class:"px-4 py-3"},J={class:"px-4 py-3"},K={class:"flex flex-wrap gap-2 justify-end"},Q=["onClick"],W=["onClick"],X=["onClick"],rt={__name:"Index",props:{plans:Object,filters:Object,networks:Array,categories:Array,statuses:Array},setup(l){var v,k,w;const x=l,i=V({network_id:((v=x.filters)==null?void 0:v.network_id)||"",category_id:((k=x.filters)==null?void 0:k.category_id)||"",status:((w=x.filters)==null?void 0:w.status)||""}),S=()=>{$.get(route("admin.plans.index"),i,{preserveState:!0,replace:!0})},y=(u,s)=>{$.patch(route("admin.plans.toggle-status",u),{status:s},{preserveScroll:!0})};return(u,s)=>(a(),o(p,null,[r(c(N),{title:"Plans"}),r(P,null,{header:n(()=>[t("div",B,[s[4]||(s[4]=t("div",null,[t("h2",{class:"text-xl font-semibold text-gray-800"},"Plans"),t("p",{class:"mt-1 text-sm text-gray-500"},"Manage non-airtime plans (data/cable/electricity/epin) with tier pricing and vendor plan IDs.")],-1)),r(c(f),{href:u.route("admin.plans.create"),class:"rounded-md bg-gray-900 px-3 py-2 text-sm font-medium text-white"},{default:n(()=>[...s[3]||(s[3]=[b(" Create Plan ",-1)])]),_:1},8,["href"])])]),default:n(()=>[t("div",M,[r(j,{title:"Filters"},{default:n(()=>[t("div",U,[g(t("select",{"onUpdate:modelValue":s[0]||(s[0]=e=>i.network_id=e),class:"rounded-md border-gray-300 text-sm shadow-sm"},[s[5]||(s[5]=t("option",{value:""},"All networks",-1)),(a(!0),o(p,null,m(l.networks,e=>(a(),o("option",{key:e.id,value:e.id},d(e.name),9,E))),128))],512),[[_,i.network_id]]),g(t("select",{"onUpdate:modelValue":s[1]||(s[1]=e=>i.category_id=e),class:"rounded-md border-gray-300 text-sm shadow-sm"},[s[6]||(s[6]=t("option",{value:""},"All categories",-1)),(a(!0),o(p,null,m(l.categories,e=>(a(),o("option",{key:e.id,value:e.id},d(e.name),9,I))),128))],512),[[_,i.category_id]]),g(t("select",{"onUpdate:modelValue":s[2]||(s[2]=e=>i.status=e),class:"rounded-md border-gray-300 text-sm shadow-sm"},[s[7]||(s[7]=t("option",{value:""},"All statuses",-1)),(a(!0),o(p,null,m(l.statuses,e=>(a(),o("option",{key:e,value:e},d(e),9,O))),128))],512),[[_,i.status]]),t("button",{type:"button",class:"rounded-md border border-gray-300 px-3 py-2 text-sm",onClick:S},"Apply")])]),_:1}),r(D,null,{default:n(()=>[s[10]||(s[10]=t("thead",{class:"bg-gray-50"},[t("tr",{class:"text-left text-xs font-semibold uppercase tracking-wide text-gray-500"},[t("th",{class:"px-4 py-3"},"Plan"),t("th",{class:"px-4 py-3"},"Category"),t("th",{class:"px-4 py-3"},"Network"),t("th",{class:"px-4 py-3"},"Subscriber Price"),t("th",{class:"px-4 py-3"},"Status"),t("th",{class:"px-4 py-3"},"Actions")])],-1)),t("tbody",q,[(a(!0),o(p,null,m(l.plans.data,e=>{var h,C;return a(),o("tr",{key:e.id},[t("td",G,[t("div",H,d(e.name),1),t("div",L,d(e.duration_label?`Duration: ${e.duration_label}`:e.value||"Variable"),1)]),t("td",R,d((h=e.category)==null?void 0:h.name),1),t("td",T,d(((C=e.network)==null?void 0:C.name)||"General"),1),t("td",Z,d(e.selling_price),1),t("td",z,[r(F,{status:e.status},null,8,["status"])]),t("td",J,[t("div",K,[r(c(f),{href:u.route("admin.plans.edit",e.id),class:"rounded border px-2 py-1 text-xs"},{default:n(()=>[...s[8]||(s[8]=[b("Edit",-1)])]),_:1},8,["href"]),r(c(f),{href:u.route("admin.mappings.index",{category_id:e.category_id,network_id:e.network_id||""}),class:"rounded border px-2 py-1 text-xs"},{default:n(()=>[...s[9]||(s[9]=[b(" Routing ",-1)])]),_:1},8,["href"]),t("button",{type:"button",class:"rounded border px-2 py-1 text-xs",onClick:A=>y(e.id,"available")},"Avail",8,Q),t("button",{type:"button",class:"rounded border px-2 py-1 text-xs",onClick:A=>y(e.id,"hidden")},"Hide",8,W),t("button",{type:"button",class:"rounded border px-2 py-1 text-xs",onClick:A=>y(e.id,"maintenance")},"Maint",8,X)])])])}),128))])]),_:1})])]),_:1})],64))}};export{rt as default};
