1import{j as t,r as u,L as xe,aY as Se,p as Te}from"./vendor-react-0b52e17d.js";import{g as h,cx as P,hm as k,i as Q,b as ve,hn as F,d4 as Ee,ae as S,aS as W,bs as R,cj as b,eM as be,ba as J,d as _,M as Ae,a as je,v as M,ed as we,bc as Ne,cl as X,fN as ye,s as B,d5 as De,fO as Pe,aV as _e,Y as Ie,S as ke,_ as Oe,q as G,a0 as Re}from"./vendor-vy-3b44047f.js";import{t as Me,k as Le,aM as Ve,g as Fe,aQ as Be,H as Ue}from"./vendor-misc-60f9a457.js";import{V as Ye}from"./VyLayout-ff2cba0b.js";import{P as He}from"./page-frame-cbbf18ba.js";import{u as ee,bc as te,V as ae,a9 as z,w as Z,h as ne,Q as We,cp as Ge,q as ze,e as $e,p as qe,cq as $,B as se,c9 as Qe,aw as Ze,br as Ke,$ as Je,k as Xe}from"./app-core-d11f9ebf.js";import{u as et}from"./use-tab-param-d44c331c.js";import{a as tt}from"./use-customers-overviews-819766ea.js";import{C as at}from"./CreateContractDialog-39ab7186.js";import{S as I,B as re,T as O,I as nt,e as st,u as oe,aP as rt}from"./vendor-mui-238acd1e.js";import{u as ie}from"./use-debounce-c674a381.js";import{V as ot}from"./VyTable-d91a8cd0.js";import{V as H}from"./vy-table-toolbar-bf390e1c.js";import{g as it}from"./get-billing-interval-label-f9672b88.js";import{g as K}from"./get-plan-duration-values-ee4d381f.js";import{C as lt}from"./query-params-e9182ed8.js";import{u as ct,a as le,b as dt}from"./use-plans-overviews-7733c0ee.js";import{ao as ut,V as pt,av as U,a2 as ce,a3 as N,bd as mt,bR as ht,c0 as Ct,c4 as gt,bS as ft,c5 as xt,ar as St,c as y,a5 as de,am as ue,Q as pe,L as Tt,bI as vt,o as Et,a0 as bt,$ as At,ab as jt}from"./vendor-vy-ds-885d80cb.js";import{u as wt}from"./use-page-filters-persistence-ad5a25e8.js";import{u as me}from"./use-table-pagination-1f3af39e.js";import{u as he}from"./use-pagination-reset-handler-471a0e42.js";import{b as Nt,u as Ce,c as yt,d as Dt,e as Pt,f as _t,g as It,h as kt,l as Ot,m as Rt,j as Mt,k as Lt,n as Vt,o as Ft,p as Bt,a as T}from"./contracts-overview-columns-4e32274d.js";import{u as Ut}from"./use-entity-columns-with-custom-fields-0dff65fb.js";import{P as Yt,N as Ht,C as Wt}from"./PlanDotMenuModal-98db1026.js";import{u as ge}from"./use-table-sorting-e920e3c2.js";import{u as Gt}from"./use-table-columns-manager-b445f64d.js";import{S as zt}from"./status-types-c3fb59d3.js";import{u as $t}from"./use-search-with-search-params-c8e8c99a.js";import{u as qt}from"./use-page-param-f43ec8a2.js";import{u as Qt}from"./use-sync-query-param-to-state-184ff103.js";import{u as Zt}from"./use-billing-engine-estimation-4177f73c.js";import"./use-account-7dbbc7a8.js";import"./reference-data-query-options-consts-5095626a.js";import"./use-subsidiaries-9438a3e5.js";import"./use-descope-sdk-b1412f07.js";import"./breadcrumbs-context-d114e5ee.js";import"./breadcrumb-routes-3b4ebb59.js";import"./app-router-a49381be.js";import"./AiCopilotProvider-1e5fad19.js";import"./use-jobs-5c611126.js";import"./VyPageLayoutTabs-1805ce94.js";import"./use-state-params-0f9cef64.js";import"./withPrefetch-fe90ea99.js";import"./VyDatePicker-ffe76d24.js";import"./picker-value-utils-370a432f.js";import"./VyDateField-e8ded6f2.js";import"./VyTooltip-6bcb524b.js";import"./CustomerStatusSelect-3cb7eae2.js";import"./use-update-customer-ad2452ea.js";import"./ArrowIcon-0a7a632e.js";import"./use-vy-form-bea0b2b5.js";import"./vy-table-types-c38a34b9.js";import"./SearchInput-3f60f3bc.js";import"./use-page-size-param-e745239c.js";import"./use-effect-once-9ddca17d.js";import"./use-labels-4d4a7529.js";import"./index-cb475b22.js";import"./use-filters-param-e915f878.js";import"./ContractStatusPill-8add0ee2.js";import"./ContractStatusChip-196b750c.js";import"./use-menu-b2c157ac.js";import"./ContractPageHeaderMenu-00140a52.js";import"./contract-page-default-menu-414242e6.js";import"./use-contract-page-aac7fde5.js";import"./use-can-connect-net-suite-45916500.js";import"./use-net-suite-products-b58d8bcf.js";import"./use-net-suite-classes-76255a9e.js";import"./use-update-product-integration-entities-5bc890e9.js";import"./use-net-suite-customers-84d0dff8.js";import"./Price-1f7c2338.js";import"./VyTextFieldField-b4524273.js";import"./use-country-options-b4d34c7b.js";import"./VyNumberFieldField-8608cbd2.js";import"./VySwitchField-fe849c62.js";import"./use-toggle-b8bd28b6.js";import"./use-contract-4ee7a561.js";import"./use-validated-params-6dabfd0f.js";import"./EntityLabelsCell-8362b00c.js";import"./use-custom-field-definitions-c313253d.js";import"./CloseButton-31e3dea9.js";import"./DatePicker-9e79c901.js";import"./index-51d9f282.js";import"./VyRadioGroup-ba51f15f.js";import"./VyDescriptionTitle-f7aadd5a.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};e.SENTRY_RELEASE={id:"2cd2d3d210c4"};var a=new e.Error().stack;a&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[a]="b03dc98a-ea57-46dd-8be6-add45a97b955",e._sentryDebugIdIdentifier="sentry-dbid-b03dc98a-ea57-46dd-8be6-add45a97b955")}catch{}})();const Kt=()=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"19",height:"21",viewBox:"0 0 19 21",fill:"none",children:[t.jsx("path",{d:"M8.8755 6.5H4.89453",stroke:"#323232",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M10.866 9.5H4.89453",stroke:"#323232",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("ellipse",{cx:"6.38739",cy:"14",rx:"1.49286",ry:"1.5",stroke:"#323232",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.8331 7.0093V16.5C17.8331 18.1569 16.4964 19.5 14.8474 19.5H3.89978C2.25081 19.5 0.914062 18.1569 0.914062 16.5V4.5C0.914062 2.84315 2.25081 1.5 3.89978 1.5H12.35C13.1419 1.5 13.9013 1.81607 14.4613 2.37868L16.9586 4.888C17.5185 5.4506 17.8331 6.21366 17.8331 7.0093Z",stroke:"#323232",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M17.8332 7H14.3499C13.2505 7 12.3594 6.10457 12.3594 5V1.5",stroke:"#323232",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),Jt=()=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"27",viewBox:"0 0 24 27",fill:"none",children:[t.jsx("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M12.5542 14.4062V10.6875C12.5542 9.80775 11.8822 9.09375 11.0542 9.09375V9.09375C10.2262 9.09375 9.55419 9.80775 9.55419 10.6875V12.2812V17.5938L8.65319 16.6364C8.04619 15.9915 7.06219 15.9915 6.45519 16.6364V16.6364C5.93119 17.1932 5.85019 18.0655 6.26119 18.72L8.96019 23.0221C9.33119 23.6139 9.95619 23.9688 10.6252 23.9688H15.9132C16.9222 23.9688 17.7722 23.1708 17.8982 22.1073L18.4402 17.4992C18.5732 16.3655 17.8392 15.3221 16.7782 15.1383L12.5542 14.4062Z",stroke:"#323232","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),t.jsx("path",{d:"M18.179 19.7186H20C21.105 19.7186 22 18.7677 22 17.5936V4.87549C22 3.70143 21.105 2.75049 20 2.75049H4C2.895 2.75049 2 3.70143 2 4.87549V17.5936C2 18.7677 2.895 19.7186 4 19.7186H6.888",stroke:"#323232","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),t.jsx("path",{d:"M4.77734 5.39605C4.77434 5.39605 4.77234 5.39818 4.77234 5.40137C4.77234 5.40455 4.77434 5.40668 4.77734 5.40668C4.78034 5.40668 4.78234 5.40455 4.78234 5.40137C4.78234 5.39818 4.78034 5.39605 4.77734 5.39605",stroke:"#323232","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),t.jsx("path",{d:"M7.32031 5.39605C7.31731 5.39605 7.31531 5.39818 7.31531 5.40137C7.31531 5.40455 7.31731 5.40668 7.32031 5.40668C7.32331 5.40668 7.32531 5.40455 7.32531 5.40137C7.32531 5.39818 7.32331 5.39605 7.32031 5.39605",stroke:"#323232","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),t.jsx("path",{d:"M9.85938 5.39605C9.85637 5.39605 9.85438 5.39818 9.85438 5.40137C9.85438 5.40455 9.85637 5.40668 9.85938 5.40668C9.86238 5.40668 9.86437 5.40455 9.86437 5.40137C9.86437 5.39818 9.86238 5.39605 9.85938 5.39605",stroke:"#323232","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})]}),Xt=()=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"22",height:"21",viewBox:"0 0 22 21",fill:"none",children:[t.jsx("path",{d:"M10.5 14.5H7.5V11.5",stroke:"#323232","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}
1),t.jsx("path",{d:"M10.5 11.5L7.5 14.5",stroke:"#323232","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),t.jsx("path",{d:"M17 14.5H18.5C19.8807 14.5 21 13.3807 21 12V4C21 2.61929 19.8807 1.5 18.5 1.5L7.5 1.5C6.11929 1.5 5 2.61929 5 4V6.5",stroke:"#323232","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),t.jsx("rect",{x:"1",y:"6.5",width:"16",height:"13",rx:"2.5",stroke:"#323232","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})]}),ea=[{value:"new-contract",title:"Start a new contract",description:"Create a custom pricing plan for your customer",icon:t.jsx(Kt,{}),iconBackground:"#B0D2FF",disabled:!1},{value:"new-template",title:"Create a new template",description:"Build a reusable pricing plan, add products and fees",icon:t.jsx(Xt,{}),iconBackground:"#E2DBFE",disabled:!1},{value:"choose-template",title:"Choose a template",description:"Select an existing contract template to get started quickly",icon:t.jsx(Jt,{}),iconBackground:"#FFE0B0",disabled:!1}],ta=({option:e,selected:a,onSelect:n,selectorAttribute:r})=>{const o=()=>{e.disabled||n(e.value)};return t.jsxs(I,{spacing:2,role:"radio",tabIndex:1,sx:{flex:1,padding:3,border:`1px solid ${a?"#5083FF":"#E8EBF2"}`,borderRadius:"8px",alignItems:"center",cursor:e.disabled?"not-allowed":"pointer",backgroundColor:a?"#F5F6FA":"#fff",opacity:e.disabled?.4:1,pointerEvents:e.disabled?"none":"auto",transition:"all 0.2s ease-in-out",...!a&&!e.disabled&&{"&:hover":{borderColor:"#B0D2FF",backgroundColor:"#F5F6FA"}}},onClick:o,...r?h(r):{},children:[t.jsx(re,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:62,height:62,borderRadius:"50%",backgroundColor:e.iconBackground},children:e.icon}),t.jsxs(I,{spacing:.5,children:[t.jsx(O,{variant:"h6",sx:{fontWeight:600,fontSize:"14px",textAlign:"center"},children:e.title}),t.jsx(O,{variant:"body2",sx:{color:"text.secondary",fontSize:"14px",textAlign:"center",lineHeight:1.5},children:e.description})]})]})},aa=u.forwardRef(({status:e,className:a,...n},r)=>t.jsx("span",{className:Me(Le("mt-2 font-medium uppercase px-2.25 py-1.25 rounded-2lg w-fit",{"text-active bg-active":e===P.Active},{"text-error bg-error":e===P.Error},{"text-inactive bg-[#FFF7F7]":e===P.Inactive}),a),ref:r,...n,children:e})),na=[{field:"status",headerName:"Status",minWidth:120,renderCell:({row:e})=>t.jsx(aa,{status:e.status})},{field:"name",headerName:"Name",flex:1,headerAlign:"left",align:"left",renderCell:({row:e})=>t.jsx("span",{className:"font-sans text-black",children:e.name})},{field:"billingInterval",headerName:"Billing interval",flex:1,headerAlign:"left",align:"left",sortable:!1,renderCell:({row:e})=>t.jsx("span",{className:"font-sans text-black",children:it(e.billingInterval)})},{field:"planDuration",headerName:"Duration",flex:1,headerAlign:"center",align:"center",sortable:!1,renderCell:({row:e})=>t.jsx("span",{className:"font-sans text-black",children:K(e.planDuration)})},{field:"customersCount",headerName:"Customers",flex:1,headerAlign:"center",align:"center",sortable:!1}],sa=({message:e})=>t.jsx(I,{sx:{alignItems:"center",justifyContent:"center",height:"100%"},children:t.jsx(O,{variant:"body2",sx:{color:"text.secondary"},children:e})}),ra=({templates:e,itemsCount:a,isLoading:n,searchValue:r,onSearchChange:o,selectedPlanId:i,onSelectionChange:s,page:l,pageSize:c,onPageChange:d,onPageSizeChange:g})=>{const p=u.useMemo(()=>({type:"include",ids:new Set(i?[i]:[])}),[i]),C=Q(r)?"No templates match your search.":"No templates available",f=u.useMemo(()=>(function(){return t.jsx(sa,{message:C})}),[C]),A=v=>{const j=Array.from(v.ids).at(-1);s(j!==void 0?String(j):null)},m=v=>{s(i===v.id?null:String(v.id))};return t.jsxs(I,{spacing:1,sx:{minHeight:"200px",height:"600px"},children:[t.jsx(H,{sx:{padding:0},children:t.jsx(H.Queries,{children:t.jsx(H.SearchInput,{value:r,onChange:v=>o(v.target.value),placeholder:"Plan name",size:"medium",showLabel:!1,slotProps:{htmlInput:{"data-vy":k.searchInput}}})})}),t.jsx(re,{sx:{flex:1,minHeight:0},children:t.jsx(ot,{tableName:"select-plan-template",columns:na,items:e,itemsCount:a,loadingItems:n,checkboxSelection:!0,disableMultipleRowSelection:!0,rowSelectionModel:p,onRowSelectionModelChange:A,onRowClick:m,paginationMode:"server",page:l,pageSize:c,onPageChange:d,onPageSizeChange:g,emptyTableMessageSize:14,noRowsOverlay:f,slotProps:{row:{"data-vy":k.tableRow}},sx:{"& .MuiDataGrid-columnHeaderCheckbox .MuiCheckbox-root":{display:"none"}}})})]})};function oa(){const e=ee();return{goToCreatePlanWithClone:u.useCallback(n=>{e(`${te}?${lt.CLONE_FROM_PLAN_ID}=${n}`)},[])}}function ia({search:e,page:a,pageSize:n}){const r=e.trim(),{data:o,isFetching:i}=ct({page:a,pageSize:n,search:Q(r)?r:void 0});return{templates:(o==null?void 0:o.plansOverviews)??[],itemsCount:(o==null?void 0:o.countedFilteredPlansOverviews)??0,isLoading:i}}const la=({isOpen:e,onClose:a})=>{const[n,r]=u.useState(""),[o,i]=u.useState(null),[s,l]=u.useState(0),[c,d]=u.useState(10),g=ie(n),{templates:p,itemsCount:C,isLoading:f}=ia({search:g,page:s,pageSize:c}),{goToCreatePlanWithClone:A}=oa(),m=o===null,v=u.useCallback(Y=>{r(Y),i(null),l(0)},[]),j=u.useCallback(()=>{r(""),i(null),l(0),d(10),a()},[a]),w=u.useCallback(()=>{o!==null&&(A(o),j())},[o,A,j]);return t.jsx(ae,{open:e,onClose:j,label:"Select a plan template",labelDescription:"Choose a template to use as a base for your plan",ctaText:"Next",cancelButtonText:"Cancel",onSubmit:w,ctaDisabled:m,maxWidth:"lg",sx:{"& .MuiDialogContent-root":{paddingBottom:"0 !important"}},cancelButtonProps:{...h(k.cancelButton)},ctaButtonProps:{...h(k.nextButton)},...h(k.dialog),children:t.jsx(ra,{templates:p,itemsCount:C,isLoading:f,searchValue:n,onSearchChange:v,selectedPlanId:o,onSelectionChange:i,page:s,pageSize:c,onPageChange:l,onPageSizeChange:d})})},ca={"new-contract":F.optionCardNewContract,"new-template":F.optionCardNewTemplate,"choose-template":F.optionCardChooseTemplate},da=({isOpen:e,onClose:a})=>{const n=ee(),[r,o]=u.useState(null),{isDialogOpen:i,handleOpen:s,handleClose:l}=z(),{isDialogOpen:c,handleOpen:d,handleClose:g}=z(),p=u.useCallback(()=>{switch(r){case"new-contract":{a(),s();return}case"new-template":{a(),n(te);return}case"choose-template":{a(),d();return}default:return}},[r,a,s,n,d]),C=u.useCallback(()=>{o("new-template"),a()},[a]);return t.jsxs(t.Fragment,{children:[t.jsx(ae,{open:e,onClose:C,label:"Create a new pricing plan",labelDescription:"Select a method to get started",ctaText:"Next",cancelButtonText:"Cancel",onSubmit:p,maxWidth:"md",disableDividers:!0,ctaButtonProps:{disabled:ve(r),"data-vy":F.nextButton},children:t.jsx(I,{direction:"row",spacing:2,role:"radiogroup","aria-label":"Plan creation method",children:ea.map(f=>t.jsx(ta,{option:f,selected:r===f.value,onSelect:o,selectorAttribute:ca[f.value]},f.value))})}),t.jsx(at,{isOpen:i,onClose:l}),t.jsx(la,{isOpen:c,onClose:g})]})},ua=()=>{const{isDialogOpen:e,handleOpen:a,handleClose:n}=z();return t.jsxs(t.Fragment,{children:[t.jsx(ut,{variant:"cta",startIcon:t.jsx(pt,{icon:"PlusMedium",width:U,height:U}),onClick:a,...h("create-contract-btn"),children:"Create plan"}),t.jsx(da,{isOpen:e,onClose:n})]})};function pa(e){return Ut({entity:Ee.CONTRACT,baseColumns:Nt,items:e})}const ma=["contractFilters",Vt],E=20,ha=({apiRef:e})=>{const a=Ce(),{page:n,pageSize:r,onPageChange:o,onPageSizeChange:i}=me(),{data:s,isFetching:l}=yt(n,r),c=S(s==null?void 0:s.contracts,[]);he(S(s==null?void 0:s.countedFilteredContracts,0));const{activeExtractionTasks:d}=Dt(),g=d.map(Pt),p=[...g,...c],C=S(s==null?void 0:s.countedFilteredContracts,0),A=C===0&&W(d)?g.length:C;_t(d),It(),wt(ma);const m=kt(),v=pa(p),j=()=>{a.handleSearchInputChange({target:{value:""}})},w=u.useMemo(()=>({all:S(s==null?void 0:s.countedTotalContracts,0),active:S(s==null?void 0:s.countedActiveContracts,0),inReview:S(s==null?void 0:s.countedInReviewContracts,0),inactive:S(s==null?void 0:s.countedInactiveContracts,0),scheduled:S(s==null?void 0:s.countedScheduledContracts,0),renewals:S(s==null?void 0:s.countedUpcomingRenewalContracts,0)}),[s]),Y=W(a.filters);return t.jsxs(t.Fragment,{children:[t.jsxs(ce,{shape:"pill",value:a.selectedStatus,onChange:($a,fe)=>a.handleStatusTabChange(fe),children:[t.jsx(N,{value:Ot,label:"All",count:w.all,icon:t.jsx(mt,{width:E,height:E}),iconPosition:"start"}),t.jsx(N,{value:R.Active,label:"Active",count:w.active,icon:t.jsx(ht,{width:E,height:E}),iconPosition:"start"}),t.jsx(N,{value:R.InReview,label:"Pending review",count:w.inReview,icon:t.jsx(Ct,{width:E,height:E}),iconPosition:"start"}),t.jsx(N,{value:Rt,label:"Renewals",count:w.renewals,icon:t.jsx(gt,{width:E,height:E}),iconPosition:"start"}),t.jsx(N,{value:R.Inactive,label:"Inactive",count:w.inactive,icon:t.jsx(ft,{width:E,height:E}),iconPosition:"start"}),t.jsx(N,{value:R.Scheduled,label:"Scheduled",count:w.scheduled,icon:t.jsx(xt,{width:E,height:E}),iconPosition:"start"})]}),t.jsx(St,{}),t.jsxs(y,{direction:"row",sx:{gap:1,alignItems:"center"},children:[t.jsx(y,{sx:{width:300,flexShrink:0},children:t.jsx(de,{value:a.query??"",onChange:a.handleSearchInputChange,onClear:j,placeholder:"Search by Customer, Contract, etc..."})}),t.jsx(ue,{fields:m,onFiltersChange:a.handleFilterClick,defaultFilters:a.filters??[],slotProps:{button:h(b.filterButton),badge:Y?h(b.filterBadge):void 0,popover:h(b.filterPopover),fieldSelect:h(b.filterFieldSelect),operatorSelect:h(b.filterOperatorSelect),valueInput:h(b.filterValueSelect)}
1}),t.jsx(Mt,{apiRef:e,columns:v})]}),t.jsx(pe,{variant:"panel",sx:{flex:1,minHeight:0,padding:0,overflow:"hidden"},children:t.jsx(Lt,{apiRef:e,columns:v,items:p,itemsCount:A,loadingItems:l,page:n,pageSize:r,onPageChange:o,onPageSizeChange:i})})]})},Ca=Z(ha),ga=({plan:e,refetchFunction:a,apiGridRef:n,rowId:r})=>t.jsx("div",{onClick:o=>{o.preventDefault(),o.stopPropagation()},className:"flex justify-center",children:t.jsx(Yt,{refetchFunction:a,plan:e,apiGridRef:n,rowId:r,children:t.jsx(nt,{className:"aspect-square rounded-full",...h(be.dotsMenu),children:t.jsx("span",{className:"bg-icon text-label mx-2 mb-[3px] inline-block h-1 w-1 rounded-full shadow-[0_7px_0_#ADC2E2,0_-7px_0_#ADC2E2]"})})})}),fa={[P.Active]:"SUCCESS",[P.Error]:"ERROR",[P.Inactive]:"NEUTRAL"},L=Object.freeze({STATUS:"status",NAME:"name",REVENUE:"revenue",TYPE:"paymentTerm",CUSTOMERS:"customersCount",BILLING_INTERVAL:"billingInterval",PLAN_DURATION:"planDuration"}),xa=(e,a)=>[{field:L.STATUS,headerName:"Status",minWidth:140,headerClassName:"pl-7",cellClassName:"pl-6",renderCell:({row:n})=>t.jsx("div",{className:"flex items-center h-full font-sans font-medium uppercase",children:t.jsx(Tt,{status:zt[fa[n.status]],label:n.status})})},{field:L.NAME,headerName:"Name",flex:1,renderCell:({row:n})=>t.jsx(vt,{className:"font-sans text-black",children:n.name}),headerAlign:"left",align:"left"},{field:L.PLAN_DURATION,headerName:"Duration",flex:1,headerAlign:"center",align:"center",sortable:!1,renderCell:({row:n})=>t.jsx("span",{className:"font-sans text-black",children:K(n.planDuration)})},{field:L.CUSTOMERS,headerName:"Customers",flex:1,headerAlign:"center",align:"center",sortable:!1},{field:"actionMenu",headerName:"",width:30,sortable:!1,filterable:!1,headerClassName:"bg-white",cellClassName:"bg-white",renderCell:({row:n})=>t.jsx("span",{className:"flex items-center justify-center h-full",children:t.jsx(ga,{refetchFunction:e,plan:n,apiGridRef:a,rowId:n.id})})}],Sa=()=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"56",height:"42",viewBox:"0 0 56 42",fill:"none",children:[t.jsx("path",{opacity:"0.6",d:"M3.13186 27.689L1.25808 30.7842C0.661243 31.7835 1.07764 33.0744 2.14639 33.5324L20.4261 41.2357C21.6059 41.7354 22.9523 41.5133 23.91 40.6805L27.033 37.9601L30.5723 39.1954C31.9742 39.6673 33.5148 39.3758 34.653 38.432C37.8315 35.8087 44.3411 30.0624 48.519 23.8998C52.3359 18.2646 54.0431 14.628 54.7926 12.6987C55.5422 10.7694 54.6538 10.8388 53.7378 10.5751L38.5393 6.05029L3.13186 27.689Z",fill:"url(#paint0_linear_12972_199514)"}),t.jsx("path",{d:"M11.7088 28.2024C10.4735 27.7305 10.1959 26.1066 11.2092 25.2599C13.8741 23.0253 18.385 18.9029 22.3408 13.6564C26.366 8.31262 29.1003 4.07927 30.4883 1.81686C31.1406 0.761988 32.4176 0.262314 33.5974 0.60931L51.6967 5.80037C53.0291 6.18901 53.7231 7.66027 53.1541 8.92334C51.7383 12.0879 48.8791 17.9036 44.7845 23.7748C41.0508 29.1324 37.1228 32.533 34.6661 34.3512C32.2094 36.1695 31.3349 35.6837 29.6555 35.0452L11.7088 28.2024Z",fill:"white",stroke:"#00217B","stroke-miterlimit":"10","stroke-dasharray":"2 2"}),t.jsx("path",{d:"M44.0751 12.3793C42.5483 15.4884 39.4948 21.2208 35.2059 26.9393C32.7769 30.1733 30.3202 32.6578 28.1827 34.4899C26.8641 35.6142 25.6843 36.5025 24.7266 37.1687C23.2553 38.182 21.3538 38.3902 19.7021 37.6823L1.99141 30.2288C1.88038 30.1872 1.78322 30.1317 1.68606 30.0623C0.742228 29.4238 0.64507 28.008 1.5889 27.2724C4.33711 25.121 8.97298 21.1653 13.1092 16.0436C13.1231 16.0159 13.1508 15.9881 13.1647 15.9742C13.3451 15.766 13.5117 15.5439 13.6782 15.3357C17.5646 10.4639 20.2573 6.60532 21.6592 4.49558C22.3393 3.46847 23.6301 3.01044 24.8099 3.39907L28.6824 4.64826L36.6216 7.22991L42.7149 9.20085C44.0335 9.63112 44.6719 11.1301 44.0612 12.3793H44.0751Z",fill:"white",stroke:"#00217B","stroke-miterlimit":"10","stroke-dasharray":"2 2"}),t.jsx("defs",{children:t.jsxs("linearGradient",{id:"paint0_linear_12972_199514",x1:"0.980479",y1:"23.7887",x2:"54.8898",y2:"23.7887",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{"stop-color":"#258AE9"}),t.jsx("stop",{offset:"0.2","stop-color":"#228FE6"}),t.jsx("stop",{offset:"0.5","stop-color":"#1AA0E0"}),t.jsx("stop",{offset:"0.7","stop-color":"#0DBBD6"}),t.jsx("stop",{offset:"1","stop-color":"#00DACB"})]})})]}),Ta=e=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"9",height:"9",viewBox:"0 0 9 9",fill:"none",...e,children:[t.jsx("path",{d:"M8.5 4C8.77614 4 9 4.22386 9 4.5C9 4.77614 8.77614 5 8.5 5H0.5C0.223858 5 0 4.77614 0 4.5C0 4.22386 0.223858 4 0.5 4H8.5Z",fill:"#020F20"}),t.jsx("path",{d:"M4 8.5V0.5C4 0.223858 4.22386 0 4.5 0C4.77614 0 5 0.223858 5 0.5V8.5C5 8.77614 4.77614 9 4.5 9C4.22386 9 4 8.77614 4 8.5Z",fill:"#020F20"})]}),va=()=>t.jsxs(I,{sx:{width:"100%",alignItems:"center",justifyContent:"center",height:"100%"},children:[t.jsx(Sa,{}),t.jsx(O,{variant:"body2",sx:{fontWeight:600,marginBottom:.5},children:"No plan templates yet"}),t.jsx(O,{variant:"body2",sx:{textAlign:"center",maxWidth:"323px",marginBottom:2,color:"#7E8796"},children:"Youâll be able to view and manage them here once youâve created some."}),ne([J.PLAN_CREATE])&&t.jsx(xe,{to:"/plans/create",children:t.jsx(st,{variant:"contained",color:"primary",startIcon:t.jsx(Ta,{}),children:"Create plan template"})})]}),Ea=40,ba=({items:e,itemsCount:a,loadingItems:n,page:r,pageSize:o,onPageChange:i,onPageSizeChange:s})=>{const l=oe(),c=S(r,0),d=S(o,10),{refetch:g}=le({page:c,pageSize:d}),{handleSortModelChange:p}=ge(),C=u.useMemo(()=>xa(g,l),[g,l]),{processedColumns:f}=Gt({apiRef:l,columns:C,tableName:"plans-overview"});u.useEffect(()=>{if(_(l.current)){const m=l.current.getRowIdFromRowIndex(0);l.current.selectRow(m)}},[l]);const A=m=>{if(m.pageSize!==d){s==null||s(m.pageSize),i==null||i(0);return}m.page!==c&&(i==null||i(m.page))};return t.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:t.jsx("div",{style:{flex:1,minHeight:0}
1,children:t.jsx(Et,{apiRef:l,rows:e??[],columns:f,getRowId:m=>m.id,loading:n,rowHeight:Ea,pinnedColumns:{right:["actionMenu"]},isRowClickable:!0,sortingMode:"server",onSortModelChange:p,pagination:!0,paginationMode:"server",rowCount:a,paginationModel:{page:c,pageSize:d},onPaginationModelChange:A,pageSizeOptions:[10,25,50,100,500],slots:{noRowsOverlay:va,loadingOverlay:We,row:m=>t.jsx(Se,{to:`${m.rowId}`,children:t.jsx(rt,{...m})})}})})})},q="plansStatuses",Aa="plans-status",ja=[Ge(q,"Status",P)];function wa(){const[e,a]=$t(),[n,r]=u.useState(e??""),o=ie(n),[i,s]=dt(),[,l]=qt();u.useEffect(()=>{a(o)},[o]),Qt(e,r);const c=u.useMemo(()=>{const p=i??[];return p.length===0?[]:[{id:Aa,field:q,operator:Ae.IN,value:p}]},[i]);return{inputValue:n,handleSearchInputChange:p=>{r(p.target.value)},filterFields:ja,filters:c,handleFilterClick:p=>{const C=p.find(m=>m.field===q),f=C==null?void 0:C.value,A=Array.isArray(f)?f:[];s(A),l(0)}}}const Na=()=>{const{page:e,pageSize:a,onPageChange:n,onPageSizeChange:r}=me(),o=wa(),i=()=>{o.handleSearchInputChange({target:{value:""}})},{data:s,isFetching:l}=Da({page:e,pageSize:a});he((s==null?void 0:s.plansOverviews.length)??0);const c=Ve({resolver:Fe(Ht)}),d=c.watch("contract"),g=W(o.filters);return t.jsx(Be,{...c,children:t.jsxs(y,{component:"form",sx:{flex:1,minHeight:0,display:"flex",flexDirection:"column",gap:2},children:[t.jsxs(y,{direction:"row",sx:{gap:1,alignItems:"center"},children:[t.jsx(y,{sx:{width:300,flexShrink:0},children:t.jsx(de,{value:o.inputValue,onChange:o.handleSearchInputChange,onClear:i,placeholder:"Search plans..."})}),t.jsx(ue,{fields:o.filterFields,onFiltersChange:o.handleFilterClick,defaultFilters:o.filters,slotProps:{button:h(b.filterButton),badge:g?h(b.filterBadge):void 0,popover:h(b.filterPopover),fieldSelect:h(b.filterFieldSelect),operatorSelect:h(b.filterOperatorSelect),valueInput:h(b.filterValueSelect)}})]}),t.jsx(pe,{variant:"panel",sx:{flex:1,minHeight:0,padding:0,overflow:"hidden"},children:t.jsx(ba,{items:S(s==null?void 0:s.plansOverviews,[]),itemsCount:S(s==null?void 0:s.countedFilteredPlansOverviews,0),loadingItems:l,page:e,pageSize:a,onPageChange:n,onPageSizeChange:r})}),_(d)&&Q(d.planId)&&t.jsx(Wt,{title:"Assign customer",planId:d.planId})]})})},ya=Z(Na);function Da(e){const{data:a,...n}=le(e);return{...n,data:a}}const Pa=0,_a=1e3;function Ia(e){const{query:a,filters:n}=Ce(),{currentSortModel:r}=ge(),[o]=Ft(),[i]=Bt(),s={search:je(a)?void 0:a,contractFilters:n!=null&&n.length?M(n):void 0,page:Pa,pageSize:_a,sort:we(r,M),contractStatuses:o!=null&&o.length?M(o):void 0,additionalFilters:i!=null&&i.length?M(i):void 0};return Te({mutationKey:ze.contracts(...Object.values(s)),mutationFn:async()=>{const c=await $e().getContracts(s);return qe(Ne,c)},...e})}const x=Object.freeze({ID:"ID",STATUS:"Status",CUSTOMER:"Customer",CUSTOMER_ID:"Customer ID",CONTRACT:"Contract",START_DATE:"Start date",END_DATE:"End date",DAYS_TO_END:"Days to end",ESTIMATION:"Estimation",SIGNATURE_DATE:"Signature date",DURATION:"Duration",AUTO_RENEWAL:"Auto renewal",SYNC_STATUS:"SO Sync",CURRENCY:"Currency"}),ka=[{field:T.STATUS,header:x.STATUS,getValue:e=>e.status},{field:T.CUSTOMER_NAME,header:x.CUSTOMER,getValue:e=>$(e.customer.name)},{field:T.CUSTOMER_ID,header:x.CUSTOMER_ID,getValue:e=>e.customer.id},{field:T.PLAN_NAME,header:x.CONTRACT,getValue:e=>$(e.plan.name)},{field:T.START_DATE,header:x.START_DATE,getValue:e=>se(Va(e),"MM-DD-YYYY")},{field:T.END_DATE,header:x.END_DATE,getValue:e=>V(e.endDate)},{field:T.CREATED_AT,header:"Created at",getValue:e=>V(e.createdAt)},{field:"updatedAt",header:"Updated at",getValue:e=>V(e.updatedAt)},{field:"daysToEnd",header:x.DAYS_TO_END,getValue:e=>Fa(e)},{field:"contractEstimation",header:x.ESTIMATION,getValue:(e,a)=>Ba(e,a)},{field:T.SIGNATURE_DATE,header:x.SIGNATURE_DATE,getValue:e=>V(e.signatureDate)},{field:T.PLAN_DURATION,header:x.DURATION,getValue:e=>K(e.plan.billingData.duration)},{field:T.AUTO_RENEWAL,header:x.AUTO_RENEWAL,getValue:e=>e.plan.billingData.autoRenewal?"Yes":"No"},{field:T.SYNC_STATUS,header:x.SYNC_STATUS,getValue:e=>Ua(e)},{field:T.CURRENCY,header:x.CURRENCY,getValue:e=>{var a;return((a=e.customer.settings)==null?void 0:a.currency)??X}},{field:T.ID,header:x.ID,getValue:e=>e.id}];function Oa(e,a,n){const r=Ze(e.map(c=>c.customFieldValues)),o=[...ka,...Ya(r)],i=Ra(a,o),s=Ma(i,o),l=La(e,i,o,n);return`${s.join(",")} 2${l.join(` 3`)}`}function Ra(e,a){if(!_(e)||G(e))return a.map(r=>r.field);const n=a.filter(r=>e.includes(r.field)).map(r=>r.field);return G(n)?a.map(r=>r.field):n}function Ma(e,a){return a.filter(n=>e.includes(n.field)).map(n=>n.header)}function La(e,a,n,r){return e.map(o=>n.filter(s=>a.includes(s.field)).map(s=>s.getValue(o,r)).join(","))}function Va(e){return ye(e.initialStartDate,e.startDate,()=>_(e.revisedAt))}function V(e){return _(e)?se(B(e),"MM-DD-YYYY"):"-"}function Fa(e){if(!_(e.endDate))return"-";const a=B(),n=B(e.endDate);return String(n.diff(a,"days"))}function Ba(e,a){var l,c,d;const n=((l=e.customer.settings)==null?void 0:l.currency)??X,r=De({customerCurrency:n,contractCurrency:e.currencyOverride}
3),o=Pe(e.plan,{startDate:e.startDate,endDate:e.endDate,trialEndDate:e.trialEndDate}),i=Qe({isEngineEstimationEnabled:a,engineTotal:(c=e.estimation)==null?void 0:c.total,engineCurrency:(d=e.estimation)==null?void 0:d.currency,invoicesCurrency:r,clientEstimatedValue:o});return`"${_e(i??0,r)}"`}function Ua(e){const a=Ie(e.integrationEntities??[],ke.netSuite);return(a==null?void 0:a.syncStatus)??Oe.None}function Ya(e){return e.map(a=>({field:a,header:a,getValue:n=>Ha(n.customFieldValues,a)}))}function Ha(e,a){if(!e)return"-";const n=e.find(r=>r.fieldName===a);return!n||n.value===null||n.value===void 0?"-":$(String(n.value))}const Wa=({selectedContracts:e,apiRef:a})=>{const n=Ia(),r=Zt(),o=async()=>{const s=G(e),l=await i(s),c=_(a==null?void 0:a.current)?a.current.getVisibleColumns().map(C=>C.field):void 0,d=Oa(l??[],c,r),g=new Blob([d],{type:"text/csv;charset=utf-8"}),p=B().format("MMMM, DD, YYYY");Ke.saveAs(g,`${p}.csv`)},i=async s=>{if(!s)return e;const l=await Je(n,void 0,{pending:"Downloading all contracts...",success:"All contracts downloaded",error:"Failed to download all contracts"});return(l==null?void 0:l.contracts)??[]};return{handleExportSelectedContracts:o}},D={contracts:"contracts",plans:"plans"},Ga=()=>{tt();const[e,a]=et(D.contracts,za),n=S(e,D.contracts),r=oe(),{handleExportSelectedContracts:o}=Wa({selectedContracts:[],apiRef:r});return t.jsxs(t.Fragment,{children:[t.jsx(Ue,{children:t.jsx("title",{children:n===D.contracts?"Contracts":"Plans"})}),t.jsx(Ye,{sx:{display:"flex",flexDirection:"column",height:"100%",padding:0},children:t.jsxs(y,{sx:{height:"100%",gap:2,...He},children:[t.jsxs(y,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center",marginBottom:1},children:[t.jsx(bt,{children:"Plans & pricing"}),t.jsxs(y,{direction:"row",sx:{gap:1,alignItems:"center"},children:[t.jsx(At,{"aria-label":"Download CSV",color:"surface",onClick:o,children:t.jsx(jt,{width:U,height:U})}),ne([J.PLAN_CREATE])&&t.jsx(ua,{})]})]}),t.jsxs(ce,{value:n,onChange:(i,s)=>a(s),children:[t.jsx(N,{value:D.contracts,label:"Contracts"}),t.jsx(N,{value:D.plans,label:"Plans template"})]}),n===D.contracts?t.jsx(Ca,{apiRef:r}):t.jsx(ya,{})]})})]})},js=Z(Xe(Ga));function za(e){return Re(e,D),e}export{js as PlansPage};
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.