import{q as g,r as A,S as L,j as e,J as M,f as N}from"./app-Bup04Qnx.js";import{A as R,C as S,X as B}from"./AuthenticatedLayout-BdDF4YYO.js";import{T as z}from"./Table-B-yOTLCP.js";import{D as O,R as V}from"./RestoreModal-DxRPbH67.js";import{W as H,M as v}from"./WithModal-CbKxT3eW.js";import{c as h,u as Y,n as q}from"./format-CisCU4Rs.js";import{D as E,a as k}from"./DetailModalContent-BPB3mCJa.js";import{u as I,s as J}from"./index-Dy_g3AZ5.js";import{R as K}from"./RejectedModal-pIH7niEQ.js";import{u as W,a as X,b as Z}from"./Select-Cs0aMrtU.js";import{E as G}from"./eye-COhjizRe.js";import{c as u}from"./index-DdNKWgRS.js";import"./clsx-B-dksMZM.js";import"./index-CtjruoRR.js";import"./floating-ui.dom-CwWDmSD9.js";import"./BaseForm-wkPKZ5Eg.js";import"./table-2-B1MKhBGJ.js";import"./DetailModalItem-BOaAAJ7m.js";import"./TextArea-DiAj0IR8.js";import"./useFormChange-D35moWjQ.js";/**
 * @license lucide-react v0.546.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Q=[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M6 12h.01M18 12h.01",key:"113zkx"}]],U=u("banknote",Q);/**
 * @license lucide-react v0.546.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ee=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],se=u("credit-card",ee);/**
 * @license lucide-react v0.546.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const le=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],te=u("file-text",le);/**
 * @license lucide-react v0.546.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ae=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],ne=u("history",ae);/**
 * @license lucide-react v0.546.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ie=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],ce=u("pencil",ie);/**
 * @license lucide-react v0.546.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const re=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],de=u("rotate-ccw",re);/**
 * @license lucide-react v0.546.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const me=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],oe=u("send",me);/**
 * @license lucide-react v0.546.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ue=[["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}],["path",{d:"M3.103 6.034h17.794",key:"awc11p"}],["path",{d:"M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z",key:"o988cm"}]],xe=u("shopping-bag",ue);/**
 * @license lucide-react v0.546.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const he=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],pe=u("trash-2",he),be=n=>{const{id:i,data:l=null,isLabel:p=!0,content:t=null,handleClick:c}=n,r=`approved_${i}`,{page:d}=g().props,m=A.useRef(),{put:b,processing:x}=L({approved:"1"}),j=s=>{s.preventDefault(),b(`${d.url}/${i}`,{onSuccess:()=>{var o;(o=m.current)==null||o.click()}})};return e.jsx(H,{type:r,backdrop:!0,onClick:c,children:e.jsxs("form",{action:"",children:[e.jsx("h1",{className:"text-lg font-bold",children:"Konfirmasi"}),p?e.jsxs("p",{children:["Apakah anda yakin ingin setujui ",d.label," ini?"]}):null,e.jsx("div",{className:"",children:!!l&&!!t&&typeof t=="function"&&t(l)}),e.jsxs("div",{className:"modal-action",children:[e.jsx("label",{ref:m,onClick:c,htmlFor:`modal_${r}`,className:"btn btn-sm btn-neutral btn-outline",children:"Batal"}),e.jsxs("button",{onClick:j,className:"btn btn-sm btn-success bg-green-600 text-white ",disabled:x,children:[e.jsx("span",{className:`${x&&"loading"}`}),e.jsxs("span",{children:["Setujui ",d.label]})]})]})]})})},je=n=>{const{id:i,data:l=null,isLabel:p=!0,content:t=null,handleClick:c}=n,r=`submit_${i}`,{page:d}=g().props,m=A.useRef(),{put:b,processing:x}=L({submit:"1"}),j=s=>{s.preventDefault(),b(`${d.url}/${i}`,{onSuccess:()=>{var o;(o=m.current)==null||o.click()}})};return e.jsx(H,{type:r,backdrop:!0,onClick:c,children:e.jsxs("form",{action:"",children:[e.jsx("h1",{className:"text-lg font-bold",children:"Konfirmasi"}),p?e.jsxs("p",{children:["Apakah anda yakin ingin ajukan ",d.label," ini?"]}):null,e.jsx("div",{className:"",children:!!l&&!!t&&typeof t=="function"&&t(l)}),e.jsxs("div",{className:"modal-action",children:[e.jsx("label",{ref:m,onClick:c,htmlFor:`modal_${r}`,className:"btn btn-sm btn-neutral btn-outline",children:"Batal"}),e.jsxs("button",{onClick:j,className:"btn btn-sm btn-success bg-green-600 text-white ",disabled:x,children:[e.jsx("span",{className:`${x&&"loading"}`}),e.jsxs("span",{children:["Ajukan ",d.label]})]})]})]})})};function w(n){return e.jsx(R,{title:n==null?void 0:n.title,children:e.jsx(T,{})})}const T=n=>{var d,m,b,x,j;let{tableHeader:i=null}=n;const{props:l}=g();i||(i=F());const p=P(),[t,c]=I(J),r=s=>{c(s)};return e.jsxs(e.Fragment,{children:[e.jsx(z,{addButton:["user"].includes((m=(d=l==null?void 0:l.auth)==null?void 0:d.user)==null?void 0:m.role),search:!0,filter:!0,filterOptions:p,tableHeader:i,tableBody:((x=l==null?void 0:l[(b=l==null?void 0:l.page)==null?void 0:b.name])==null?void 0:x.data)??[],tablePage:l==null?void 0:l[(j=l==null?void 0:l.page)==null?void 0:j.name],tableAction:s=>{var y,a,D,C;const{user:o}=l.auth;let _=![s.approval_level].includes(o.role)||!["review"].includes(s.status),$=![s.approval_level].includes(o.role)||!["revision"].includes(s.status),f=!["approved"].includes(s.status)||parseInt((s==null?void 0:s.paid_percentage)??0)>=100;return e.jsxs(e.Fragment,{children:[e.jsx("li",{className:"mb-1",children:e.jsxs(v,{id:`detail_${s==null?void 0:s.id}`,onClick:()=>r(s),className:"menu-item-action",children:[e.jsx(G,{className:"w-4 h-4 text-blue-500"}),e.jsx("span",{children:"Lihat Selengkapnya"})]})}),e.jsx("li",{className:"mb-1",children:e.jsxs(M,{href:`${(y=l==null?void 0:l.page)==null?void 0:y.url}/${s.id}/budget_details`,className:"menu-item-action",children:[e.jsx(te,{className:"w-4 h-4 text-green-500"}),e.jsx("span",{children:"Lihat Anggaran Detail"})]})}),e.jsx("li",{className:"mb-1",children:e.jsxs(M,{href:`${(a=l==null?void 0:l.page)==null?void 0:a.url}/${s.id}/approval_logs`,className:"menu-item-action",children:[e.jsx(ne,{className:"w-4 h-4 text-orange-500"}),e.jsx("span",{children:"Lihat Approval Log"})]})}),e.jsx("li",{className:"mb-1",children:e.jsxs("button",{className:"menu-item-action",onClick:()=>N.get(`/admin/budgets/${s==null?void 0:s.id}/payment_details`),children:[e.jsx(se,{className:"w-4 h-4 text-purple-500"}),e.jsx("span",{children:"Detail Pembayaran"})]})}),l.isAdmin?e.jsxs(e.Fragment,{children:[e.jsx("li",{className:"mb-1",children:e.jsxs("button",{disabled:_,id:`approved_${s==null?void 0:s.id}`,className:"menu-item-action",onClick:()=>N.get(`/admin/budgets/${s==null?void 0:s.id}/budget_approvals`),children:[e.jsx(S,{className:"w-4 h-4 text-green-600"}),e.jsxs("span",{className:"text-green-700",children:["Setujui ",(D=l==null?void 0:l.page)==null?void 0:D.label]})]})}),e.jsx("li",{className:"mb-1",children:e.jsxs(v,{disabled:_,id:`rejected_${s==null?void 0:s.id}`,onClick:()=>r(s),className:"menu-item-action",children:[e.jsx(B,{className:"w-4 h-4 text-red-600"}),e.jsxs("span",{className:"text-red-700",children:["Tolak ",(C=l==null?void 0:l.page)==null?void 0:C.label]})]})})]}):e.jsxs(e.Fragment,{children:[["user"].includes(o.role)&&e.jsxs(e.Fragment,{children:[e.jsx("li",{className:"mb-1",children:e.jsxs(v,{disabled:!["draft"].includes(s.status),id:`submit_${s==null?void 0:s.id}`,onClick:()=>r(s),className:"menu-item-action",children:[e.jsx(oe,{className:"w-4 h-4 text-blue-600"}),e.jsx("span",{className:"text-blue-700",children:"Ajukan Persetujuan Anggaran"})]})}),["cash_advance"].includes(s.type)?e.jsx("li",{className:"mb-1",children:e.jsxs("button",{disabled:f,className:"menu-item-action",onClick:()=>N.get(`/admin/budgets/${s==null?void 0:s.id}/payment_requests`),children:[e.jsx(U,{className:"w-4 h-4 text-emerald-600"}),e.jsx("span",{className:"text-blue-700",children:"Ajukan Pencairan Dana"})]})}):null,["purchase_order"].includes(s.type)?e.jsx("li",{className:"mb-1",children:e.jsxs("button",{disabled:f,className:"menu-item-action",onClick:()=>N.get(`/admin/budgets/${s==null?void 0:s.id}/purchase_orders`),children:[e.jsx(xe,{className:"w-4 h-4 text-indigo-600"}),e.jsx("span",{className:"text-blue-700",children:"Ajukan Pembayaran PO"})]})}):null]}),e.jsx("li",{className:"mb-1",children:e.jsxs("button",{disabled:!["draft"].includes(s.status),className:"menu-item-action",onClick:()=>N.get(`/admin/budgets/${s==null?void 0:s.id}/edit`),children:[e.jsx(ce,{className:"w-4 h-4 text-amber-500"}),e.jsx("span",{children:"Edit Draft"})]})})]}),["user","manager"].includes(o.role)&&e.jsx("li",{className:"mb-1",children:e.jsxs("button",{disabled:$,className:"menu-item-action",onClick:()=>N.get(`/admin/budgets/${s==null?void 0:s.id}/budget_revisions`),children:[e.jsx(de,{className:"w-4 h-4 text-purple-700"}),e.jsx("span",{className:"text-purple-700",children:"Revisi Anggaran"})]})}),e.jsx("li",{className:"mb-1",children:e.jsxs(v,{disabled:!["draft"].includes(s==null?void 0:s.status),id:`delete_${s==null?void 0:s.id}`,onClick:()=>r(s),className:"menu-item-action",children:[e.jsx(pe,{className:"w-4 h-4 text-red-600"}),e.jsx("span",{className:"text-red-700",children:"Hapus Draft"})]})})]})},tableFooter:s=>{const{tableBody:o,tableHeader:_,defaultClassName:{tdBodyClassName:$,trBodyClassName:f},isTable:y=!0}=s,a=(l==null?void 0:l.budgetSum)??{};return y?e.jsxs("tr",{className:`${f} bg-white w-full`,children:[e.jsx("td",{colSpan:l.isAdmin?5:4,className:`${$}`,children:e.jsx("div",{className:"flex items-center justify-between w-full py-3",children:e.jsx("span",{className:"font-semibold",children:"Total"})})}),e.jsx("td",{children:e.jsx("span",{className:"font-semibold",children:h((a==null?void 0:a.debit_amount)??0)})}),e.jsx("td",{children:e.jsx("span",{className:"font-semibold",children:h((a==null?void 0:a.credit_amount)??0)})}),e.jsx("td",{children:e.jsx("span",{className:"font-semibold",children:h((a==null?void 0:a.remaining_amount)??0)})}),e.jsx("td",{children:e.jsx("span",{className:"font-semibold",children:h((a==null?void 0:a.paid_amount)??0)})}),e.jsx("td",{colSpan:(l.isAdmin,4)})]}):e.jsx("div",{className:"card bg-white dark:bg-gray-800 shadow-sm border border-gray-200 dark:border-gray-700 p-4 mt-4 w-full",children:e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-center gap-4",children:[e.jsx("span",{className:"font-semibold text-lg text-gray-900 dark:text-gray-100",children:"Total"}),e.jsxs("div",{className:"flex flex-wrap gap-4 justify-center sm:justify-end text-sm",children:[e.jsxs("div",{className:"flex flex-col items-center sm:items-end",children:[e.jsx("span",{className:"text-gray-500 text-xs",children:"Debit"}),e.jsx("span",{className:"font-semibold",children:h((a==null?void 0:a.debit_amount)??0)})]}),e.jsxs("div",{className:"flex flex-col items-center sm:items-end",children:[e.jsx("span",{className:"text-gray-500 text-xs",children:"Kredit"}),e.jsx("span",{className:"font-semibold",children:h((a==null?void 0:a.credit_amount)??0)})]}),e.jsxs("div",{className:"flex flex-col items-center sm:items-end",children:[e.jsx("span",{className:"text-gray-500 text-xs",children:"Anggaran Tersedia"}),e.jsx("span",{className:"font-semibold",children:h((a==null?void 0:a.remaining_amount)??0)})]}),e.jsxs("div",{className:"flex flex-col items-center sm:items-end",children:[e.jsx("span",{className:"text-gray-500 text-xs",children:"Jumlah Terbayar"}),e.jsx("span",{className:"font-semibold",children:h((a==null?void 0:a.paid_amount)??0)})]})]})]})})},...n}),t?e.jsxs(e.Fragment,{children:[e.jsx(O,{id:t==null?void 0:t.id,label:t.name,isForceDelete:t.deleted_at!=null,handleClick:()=>r(null)}),e.jsx(V,{id:t==null?void 0:t.id,label:t.name,handleClick:()=>r(null)}),e.jsx(E,{id:t==null?void 0:t.id,tableHeader:i,data:t,handleClick:()=>r(null),content:s=>k(s,i),size:"max-w-2xl"}),e.jsx(be,{id:t==null?void 0:t.id,isLabel:!0,data:t,handleClick:()=>r(null),content:s=>k(s,i)}),e.jsx(K,{id:t==null?void 0:t.id,isLabel:!0,data:t,handleClick:()=>r(null),content:s=>k(s,i)}),e.jsx(je,{id:t==null?void 0:t.id,isLabel:!0,data:t,handleClick:()=>r(null),content:s=>k(s,i)})]}):null]})},F=()=>{const{page:n,isAdmin:i,location:l}=g().props,{params:p}=Y(l);return[{label:"#",value:"id",type:"numbering"},{value:"code",label:"Kode",isSearchable:!0,className:"text-[13px] w-[10%] md:w-[100px] !whitespace-pre"},{value:"date",label:"Tanggal",dateFormat:"DD MMM YYYY",type:"date",className:"text-[13px] w-[10%] md:w-[80px] !whitespace-pre",isSearchable:!0},{label:"Disubmit",value:"user.name",className:"text-[13px] w-[10%] md:w-[100px]",isSearchable:!0,isDetail:!1,isHidden:!i},{value:"name",label:"Nama Anggaran",isSearchable:!0,isDefaultLabel:!0,custom:({data:c,key:r})=>e.jsx("td",{className:"text-[13px] min-w-[200px] whitespace-normal",children:e.jsx(M,{href:`${n==null?void 0:n.url}/${c.id}/budget_details`,className:"link-hover",children:c.name})},r)},{value:"type",label:"Jenis",type:"status",prefix:"budget.type",className:"[&_div]:text-[13px] w-[10%]"},{label:"Debit",value:"debit_amount",className:"text-[13px] w-[10%] md:w-[120px]",type:"currency",defaultValue:"-"},{label:"Kredit",value:"credit_amount",className:"text-[13px] w-[10%] md:w-[120px]",type:"currency",defaultValue:"-"},{label:"Anggaran Tersedia",value:"remaining_amount",className:"text-[13px] w-[10%] md:w-[120px]",type:"currency",defaultValue:"-",isSortable:!1},{label:"Jumlah Terbayar",value:"paid_amount",className:"text-[13px] w-[10%] md:w-[120px]",type:"currency",defaultValue:"-",isSortable:!1},{label:"Persentase Terbayar",value:"paid_percentage",className:"text-[13px] w-[10%] md:w-[120px]",defaultValue:"-",valueLabel:({value:c})=>`${q(c,"id-ID",2)}%`,isSortable:!1},{label:"Status",value:"status",type:"status",className:"[&_div]:text-[13px] w-[10%]",prefix:"budget.status",isDefaultLabel:!0,wrapperClassName:"flex flex-wrap justify-between",custom:({data:c,key:r,header:d,defaultClassName:m})=>e.jsx("td",{className:`${m==null?void 0:m.tdBodyClassName} ${(d==null?void 0:d.className)??""}`,children:e.jsxs("div",{className:`capitalize badge badge-xs py-2 ${Z(`${(d==null?void 0:d.prefix)??""}.${c==null?void 0:c.status}`)}`,children:[W(`${(d==null?void 0:d.prefix)??""}.${c==null?void 0:c.status}`),["review","revision"].includes(c.status)?` ${X(c.approval_level)}`:""]})},r)},{value:"status_message",label:"Catatan Penolakan",isDetail:!0,isHidden:"not null"},{label:"Ditambahkan",value:"created_at",type:"date",isDetail:!0,className:"text-[13px] w-[10%] md:w-[100px] !whitespace-pre"},{label:"Diperbarui",value:"updated_at",type:"date",isDetail:!0,className:"text-[13px] w-[10%] md:w-[100px] !whitespace-pre"},{label:"Dihapus",value:"deleted_at",type:"date",className:"text-[13px] w-[10%] md:w-[100px] !whitespace-pre",isHidden:p.get("deleted_at")!="show"},{label:"Aksi",value:"id",type:"action"},{label:"Di Submit Oleh",value:"user.name",className:"text-[13px] w-[10%] md:w-[100px]",isDetail:!0,isHidden:!i},{label:"Di Review Oleh",value:"reviewer.name",className:"text-[13px] w-[10%] md:w-[100px]",isDetail:!0,isHidden:"not null"},{label:"Tanggal Review",value:"review_at",type:"date",isHidden:"not null",isDetail:!0,className:"text-[13px] w-[10%] md:w-[100px]",dateFormat:"DD MMM YYYY hh:mm"}]},P=()=>{const{props:n}=g();return[{name:"status",data:(n==null?void 0:n.status)??[],label:"Filter Status",prefix:"budget.status"},{name:"type",data:(n==null?void 0:n.types)??[],label:"Filter Jenis",prefix:"budget.type"}]},Ne=({children:n})=>{const i=F();return n(i)},ge=({children:n})=>{const i=P();return n(i)};w.Table=T;w.HeaderProvider=Ne;w.FilterProvider=ge;const Oe=w;export{Oe as default};
