1import{u as V,r as o,j as t,L as W,B as b,$ as c,S as i,a5 as G}from"./app-B52dr9Z4.js";import{t as J,a as y}from"./gtm-CNimFiNN.js";import{F as Q}from"./filters-toolbar-Df9A3BAA.js";import{B as g}from"./badge-BvQoBsz0.js";import{H as U}from"./html-content-DUWN6dgg.js";import{D as X,a as Y,b as Z,c as p,e as ee}from"./dropdown-menu-B44w2sc-.js";import{P as te,a as ae}from"./page-CmjTIkIE.js";import{A as re}from"./service-badges-CTLsZEly.js";import{A as se}from"./app-layout-D-S07WEp.js";import{u as ie}from"./useTranslations-i04ZGdU9.js";import{D as oe}from"./data-table-C-LENwKa.js";import{B as de}from"./bulk-actions-bar-DarcCgnk.js";import{E as ne}from"./empty-state-Bi8xD4GK.js";import D from"./plus-B-lvnMuG.js";import P from"./puzzle-CD0WbofF.js";import B from"./toggle-right-Cl9jOqBh.js";import T from"./toggle-left-6sy1wquA.js";import z from"./trash-2-BEPiZNU-.js";import le from"./ellipsis-BPpaJ7_g.js";import ce from"./eye-B-fMjr7w.js";import pe from"./square-pen-CvjAmtvR.js";import me from"./copy-BAEob28Y.js";/* empty css */import"./popover-CKXulyAZ.js";import"./index-t4LHgfoc.js";import"./index-CHtzdPVW.js";import"./index-BAzmGsHK.js";import"./separator-fSsrDt21.js";import"./checkbox-CabXFd8o.js";import"./index-pqbWUrFk.js";import"./index-D52OTMAh.js";import"./check-Dkg1l1kj.js";import"./search-DrhBYSUp.js";import"./circle-plus-CkSWnAcD.js";import"./index-DVkNJKuA.js";import"./chevron-right-C5JGOTvn.js";import"./page-header-slot-9wF9SEHn.js";import"./use-mobile-DfVMgrrG.js";import"./index-B5Df9cCr.js";import"./arrow-left-BeFRqDBE.js";import"./app-sidebar-header-BL3HNvLX.js";import"./app-shell-DV32o7Te.js";import"./star-CdNTN9gm.js";import"./avatar-Q9_zke_9.js";import"./settings-Ch2tFJAb.js";import"./message-circle-Cc1b5lIO.js";import"./calendar-C2fAY7cK.js";import"./user-D4aoCIcS.js";import"./credit-card-By7R9445.js";import"./clipboard-list-kr81UB2O.js";import"./message-square-BxdKuZ7C.js";import"./external-link-C6S42OOY.js";import"./dialog-CkZdIX0v.js";import"./rocket-BQ_JeDhc.js";import"./circle-CRKXs4-N.js";import"./powered-by-footer-L2H-sKEz.js";import"./file-text-bmIjoN1R.js";import"./arrow-right-C3t4zTEM.js";import"./grid-3x3-DKKQUXvl.js";import"./play-5gdiVMo6.js";import"./globe-DpLTLMc2.js";import"./index-D05D7-PE.js";import"./chart-column-C_-PLaMo.js";import"./clock-DExexYRX.js";import"./gauge-COYLukSc.js";import"./trending-up-BMTt3tYh.js";import"./users-CybtftJu.js";import"./package-Cf3B7llU.js";import"./percent-C9JYnWN1.js";import"./briefcase-Ddide-SI.js";import"./ticket-BBIVt4fy.js";import"./user-plus-Df5nIE0-.js";import"./file-check-C7P8Nlnh.js";import"./file-pen-line-BR6r4i1A.js";import"./scroll-text-Bsuv6swU.js";import"./bot-DunatdlK.js";import"./coins-D83a7E6n.js";import"./sparkles-BYOkPKvs.js";import"./alert-e1DeHu6Z.js";import"./index-DzHyjDkQ.js";import"./building-2-C_2e5VDY.js";import"./book-open-BBYq3Djb.js";import"./layout-grid-CU4pOG0B.js";import"./google-tag-manager-DcQYvIGa.js";import"./circle-alert-CTH4t-G2.js";import"./table-B9ssSTZP.js";import"./pagination-DWaaSVeR.js";import"./chevron-left-CYLkMADM.js";import"./select-DUM4Pa6s.js";import"./chevron-down-CNRg1fMK.js";import"./chevron-up-e5chpv2P.js";import"./sliders-horizontal-Bs-in_Co.js";import"./arrow-up-C8yT-Riu.js";import"./arrow-down-B_KJIEDz.js";function Zt({addons:d,filters:r,services:A,fieldTypes:f,billingTypes:S}){const{t:a}=ie(),{formatDate:E}=V(),[v,k]=o.useState(r.search||""),[m,N]=o.useState(r.field_type===""||!r.field_type?"all":r.field_type),[j,L]=o.useState(Number(r==null?void 0:r.per_page)||(d==null?void 0:d.per_page)||15),[u,w]=o.useState(r.billing_type===""||!r.billing_type?"all":r.billing_type),[_,C]=o.useState(r.status===""||!r.status?"all":r.status),[x,F]=o.useState(r.service_id===""||!r.service_id?"all":r.service_id),[n,l]=o.useState([]);o.useEffect(()=>{J("/team/addons",a("addons.title"))},[a]);const M=[{title:a("addons.title"),href:"/addons"}],h=(e={})=>{const s={per_page:j};return v&&(s.search=v),m&&m!=="all"&&(s.field_type=m),u&&u!=="all"&&(s.billing_type=u),_&&_!=="all"&&(s.status=_),x&&x!=="all"&&(s.service_id=x),r!=null&&r.sort_field&&(s.sort_field=r==null?void 0:r.sort_field),r!=null&&r.sort_direction&&(s.sort_direction=r==null?void 0:r.sort_direction),{...s,...e}},I=e=>{y("addon_status_changed",{addon_id:e.id,addon_title:e.title,new_status:e.is_active?"inactive":"active"}),i.patch(route("addons.toggle-status",e.id),{},{preserveScroll:!0})},K=e=>{y("addon_duplicated",{original_addon_id:e.id,addon_title:e.title,field_type:e.field_type}),i.post(route("addons.duplicate",e.id))},R=async e=>{await G({title:a("addons.delete_title","Delete add-on?"),description:a("addons.delete_confirm"),confirmText:a("common.delete"),variant:"destructive"})&&(y("addon_deleted",{addon_id:e.id,addon_title:e.title,field_type:e.field_type}),i.delete(route("addons.destroy",e.id)))},$=e=>t.jsx(re,{active:e.is_active}),H=e=>t.jsx(g,{variant:"outline",children:a(`addons.field_types.${e}`,f[e]||e)}),O=e=>t.jsx(g,{variant:e==="recurring"?"primary":"secondary",children:a(`addons.billing_types.${e}`,S[e]||e)});return t.jsxs(se,{breadcrumbs:M,children:[t.jsx(W,{title:a("addons.title")}),t.jsxs(te,{children:[t.jsx(ae,{title:a("addons.title"),description:a("addons.manage_description"),actions:t.jsx(b,{asChild:!0,children:t.jsxs(c,{href:route("addons.
1create"),children:[t.jsx(D,{}),a("addons.create")]})})}),t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx(Q,{search:v,onSearchChange:k,onSearchSubmit:()=>i.get(route("addons.index"),h(),{preserveState:!0,replace:!0}),searchPlaceholder:a("addons.search_placeholder"),persistKey:"team.addons.filters.toolbar",items:[{key:"field_type",label:a("addons.field_type_field"),value:m,options:[{value:"all",label:a("addons.all_field_types")},...Object.entries(f).map(([e,s])=>({value:e,label:s}))]},{key:"billing_type",label:a("addons.billing_type_field"),value:u,options:[{value:"all",label:a("addons.all_billing_types")},...Object.entries(S).map(([e,s])=>({value:e,label:s}))]},{key:"status",label:a("common.status"),value:_,options:[{value:"all",label:a("addons.all_status")},{value:"active",label:a("common.active")},{value:"inactive",label:a("common.inactive")}]},{key:"service_id",label:a("addons.services_field"),value:x,options:[{value:"all",label:a("addons.all_services")},...A.map(e=>({value:String(e.id),label:e.name}))]}],onChange:(e,s)=>{e==="field_type"&&N(s),e==="billing_type"&&w(s),e==="status"&&C(s),e==="service_id"&&F(s);const q=s==="all"?void 0:s;i.get(route("addons.index"),h({[e]:q,page:1}),{preserveState:!0,replace:!0})},onReset:()=>{k(""),N("all"),w("all"),C("all"),F("all"),i.get(route("addons.index"),{per_page:j},{preserveState:!0,replace:!0})}}),d.data.length===0?t.jsx(ne,{icon:t.jsx(P,{}),title:a("addons.no_addons"),description:a("addons.no_addons_description"),actions:t.jsx(b,{asChild:!0,children:t.jsxs(c,{href:route("addons.create"),children:[t.jsx(D,{}),a("addons.create")]})})}):t.jsxs(t.Fragment,{children:[t.jsx(de,{variant:"toolbar",selectedIds:n,onClear:()=>l([]),actions:[{key:"activate",label:a("addons.activate_selected"),icon:t.jsx(B,{className:"size-4"}),onAction:async()=>i.post(route("addons.bulk"),{action:"activate",ids:n},{preserveScroll:!0,onSuccess:()=>l([])})},{key:"deactivate",label:a("addons.deactivate_selected"),icon:t.jsx(T,{className:"size-4"}),onAction:async()=>i.post(route("addons.bulk"),{action:"deactivate",ids:n},{preserveScroll:!0,onSuccess:()=>l([])})},{key:"delete",label:a("addons.delete_selected"),icon:t.jsx(z,{className:"size-4"}),intent:"destructive",onAction:async()=>i.post(route("addons.bulk"),{action:"delete",ids:n},{preserveScroll:!0,onSuccess:()=>l([])}),confirm:e=>a("addons.bulk_delete_confirm",{count:e})}]}),t.jsx(oe,{columns:[{key:"title",header:a("addons.table_title"),sortable:!0,render:e=>t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("div",{className:"text-muted-foreground flex size-9 shrink-0 items-center justify-center rounded-md border",children:t.jsx(P,{className:"size-4"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx(c,{href:route("addons.show",e.id),className:"text-foreground hover:text-primary truncate font-medium",children:e.title}),e.description&&t.jsx("div",{className:"max-w-xs",children:t.jsx(U,{content:e.description,className:"text-muted-foreground text-xs",maxLines:1})})]})]})},{key:"field_type",header:a("addons.table_field_type"),sortable:!0,render:e=>H(e.field_type)},{key:"price",header:a("addons.table_price"),sortable:!0,render:e=>t.jsx("span",{className:"font-medium tabular-nums",children:e.field_type==="multiple"?e.price_description:e.formatted_price})},{key:"billing_type",header:a("addons.table_billing_type"),sortable:!0,render:e=>O(e.billing_type)},{key:"services",header:a("addons.table_services"),render:e=>t.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.services.length>0?e.services.slice(0,2).map(s=>t.jsx(g,{variant:"outline",children:s.name},s.id)):t.jsx("span",{className:"text-muted-foreground text-sm",children:a("addons.no_services_assigned")}),e.services.length>2&&t.jsx(g,{variant:"muted",children:a("addons.more_services",{count:e.services.length-2})})]})},{key:"status",header:a("addons.table_status"),render:e=>$(e)},{key:"created_at",header:a("addons.table_created"),sortable:!0,render:e=>t.jsx("span",{className:"text-muted-foreground",children:E(e.created_at)})},{key:"actions",header:t.jsx("span",{className:"sr-only",children:a("addons.table_actions")}),className:"w-12 text-right",render:e=>t.jsxs(X,{children:[t.jsx(Y,{asChild:!0,children:t.jsx(b,{variant:"ghost",size:"icon",className:"size-8","aria-label":a("addons.table_actions"),children:t.jsx(le,{})})}),t.jsxs(Z,{align:"end",children:[t.jsx(p,{asChild:!0,children:t.jsxs(c,{href:route("addons.show",e.id),children:[t.jsx(ce,{}),a("addons.view")]})}),t.jsx(p,{asChild:!0,children:t.jsxs(c,{href:route("addons.edit",e.id),children:[t.jsx(pe,{}),a("common.edit")]})}),t.jsxs(p,{onClick:()=>K(e),children:[t.jsx(me,{}),a("addons.duplicate")]}),t.jsx(p,{onClick:()=>I(e),children:e.is_active?t.jsxs(t.Fragment,{children:[t.jsx(T,{}),a("addons.deactivate")]}):t.jsxs(t.Fragment,{children:[t.jsx(B,{}),a("addons.activate")]})}),t.jsx(ee,{}),t.jsxs(p,{onClick:()=>R(e),className:"text-destructive focus:text-destructive",children:[t.jsx(z,{className:"text-destructive"}),a("common.delete")]})]})]})}],data:d.data,rowKey:e=>e.id,onRowClick:e=>i.visit(route("addons.show",e.id)),paginator:d,perPage:j,sortField:r==null?void 0:r.sort_field,sortDirection:r==null?void 0:r.sort_direction,onSortChange:(e,s)=>{i.get(route("addons.index"),h({sort_field:e,sort_direction:s,page:1}),{preserveState:!0,replace:!0})},onPerPageChange:e=>{L(e),i.get(route("addons.index"),h({per_page:e,page:1}),{preserveState:!0,preserveScroll:!0})},selectable:!0,selectedKeys:n,onSelectedKeysChange:e=>l(e)})]})]})]})]})}export{Zt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.