sidekick-client 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("react/jsx-runtime"),t=require("sonner"),a=require("react-router"),s=require("react"),r=require("clsx"),n=require("tailwind-merge"),i=require("lucide-react"),o=require("@radix-ui/react-label"),l=require("@radix-ui/react-select"),d=require("@radix-ui/react-dialog"),c=require("@radix-ui/react-switch"),u=require("@radix-ui/react-tooltip"),m=require("@radix-ui/react-separator"),x=require("@tiptap/react"),p=require("@tiptap/starter-kit"),h=require("@tiptap/extension-underline"),g=require("@tiptap/extension-link"),f=require("@tiptap/extension-placeholder"),b=require("@tiptap/extension-bubble-menu"),v=require("@tiptap/extension-floating-menu"),j=require("@radix-ui/react-dropdown-menu"),y=require("@radix-ui/react-tabs"),N=require("@marsidev/react-turnstile"),w=require("@radix-ui/react-collapsible"),_=require("@radix-ui/react-slot"),C=require("class-variance-authority"),k=require("@radix-ui/react-avatar"),S=require("@radix-ui/react-accordion"),P=require("input-otp"),z=require("motion/react"),T=require("@radix-ui/react-radio-group"),I=require("@radix-ui/react-toggle"),F=require("react-razorpay"),O=require("@tanstack/react-table"),D=require("axios");function A(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(a){if("default"!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,Object.freeze(t)}var E=A(s),L=A(o),R=A(l),M=A(d),$=A(c),U=A(u),B=A(m),q=A(j),V=A(y),H=A(w),Y=A(k),W=A(S),K=A(T),G=A(I);const X={navMain:[{title:"Your Work",items:[{title:"Sample",icon:i.SquarePen,url:"sample-documents"},{title:"Sample Saved",icon:i.Bookmark,url:"sample-saved-documents"}]},{title:"Settings",items:[{title:"Documentation",icon:i.BookOpen,items:[{title:"Sample Get Started",url:"sample-doc-get-started"},{title:"Sample Tutorials",url:"sample-tutorials"}]},{title:"Settings",icon:i.Settings2,items:[{title:"Sample General",url:"sample-general-settings"},{title:"Sample Active Plan",url:"sample-active-plan-setting"}]}]}],virtualChildOf:[]},J=(e,t,a)=>{e.forEach(e=>{const{items:s,...r}=e;r.parent=a,t.push(r),s&&J(s,t,r)})},Q={TEAM:"team",ORG:"org"},Z={appId:"gamma_tech",appName:"Gamma Tech",appDescription:"Gamma Tech is a software company that provides a range of services to help businesses grow and succeed.",logo:i.NotebookText,version:"2.0.1",account_type_txt:{singular:"Team",plural:"Teams",value:Q.TEAM},supportEmail:"support@gammatech.com",cloudFareKey:"",razorPayKey:"",themeColor:"#00c950",serverUrl:"http://192.168.31.71:6001"};function ee(...e){return n.twMerge(r.clsx(e))}const te=e=>{const t=new FormData(e);return Object.fromEntries(t.entries())},ae=e=>`${Z.appId}_${e}`,se=(e,t)=>{localStorage.setItem(ae(e),t)},re=e=>localStorage.getItem(ae(e)),ne=(e,t)=>{if(!e)return!1;if(t===e)return!0;return!!X.virtualChildOf.find(a=>a.id===e&&a.parentId===t)},ie=e=>{const t=(()=>{const e=[],t=X.navMain;return J(t,e,void 0),e})(),a=t.find(t=>t.url===e);if(a)return a;const s=X.virtualChildOf.find(t=>t.id===e);return s?t.find(e=>e.url===s.parentId):void 0},oe=e=>Array.from({length:e},(e,t)=>t),le={open:!1,type:"CONFIRM",text:""},de=e=>{const t=/[A-Z]/.test(e),a=/[a-z]/.test(e),s=/[0-9]/.test(e),r=/[!@#$%^&*(),.?":{}|<>]/.test(e);return e.length<8?{valid:!1,message:"Password must be at least 8 characters long."}:t?a?s?r?{valid:!0,message:"Password is valid."}:{valid:!1,message:"Password must contain at least one special character."}:{valid:!1,message:"Password must contain at least one number."}:{valid:!1,message:"Password must contain at least one lowercase letter."}:{valid:!1,message:"Password must contain at least one uppercase letter."}},ce=e=>{console.error(e)},ue=e=>{if(!e)return!1;const t=String(e).toLowerCase().match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);return Array.isArray(t)&&t.length>0},me=e=>{if(!e||"string"!=typeof e)return{validEmails:[],invalidEmails:[],totalProcessed:0};const t=e.replace(/\n/g,"").split(",").map(e=>e.trim()).filter(e=>e.length>0),a=[],s=[];return t.forEach(e=>{ue(e)?a.push(e):s.push(e)}),{validEmails:a,invalidEmails:s,totalProcessed:t.length}},xe=e=>new Date(e),pe=(e,t=!0)=>{if(!e)return"";const a=e instanceof Date?e:xe(e),s=String(a.getDate()).padStart(2,"0"),r=String(a.getMonth()+1).padStart(2,"0"),n=a.getFullYear();let i=a.getHours();const o=String(a.getMinutes()).padStart(2,"0");let l="";t&&(l=i>=12?"PM":"AM",i=i%12||12);const d=String(i).padStart(2,"0");return t?`${s}/${r}/${n}, ${d}:${o} ${l}`:`${s}/${r}/${n}, ${d}:${o}`},he=729444,ge=e=>e*he,fe=e=>Math.floor(e/he),be=(e,t)=>{const a=[];for(let s=0;s<e.length;s+=2){const r=e[s],n=e[s+1];a.push(t(r,n,s))}return a},ve=e=>"function"==typeof e,je=e=>1===e||"1"===e||!0===e,ye=Object.freeze({NOT_SAVED:10,INVITED:0,ACCEPTED:1,REJECTED:2,LEFT:3,text:{10:"Not Saved",0:"Invited",1:"Active (Accepted)",2:"Rejected",3:"Left"},getDisplay(e){return this.text[e]}}),Ne=e=>e&&0===Object.keys(e).length,we=e=>parseInt(e,10)>0,_e=e=>e.split("/")[2];const Ce="active-theme",ke=(e=(()=>re(Ce)||"system")())=>{const[t,a]=s.useState(e);return s.useEffect(()=>{const e=window.document.documentElement;e.classList.remove("light","dark");let a=t;"system"===t&&(a=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),e.classList.add(a),se(Ce,a)},[t]),{theme:t,setTheme:a}},Se=({...a})=>{const{theme:s="system"}=ke();return e.jsx(t.Toaster,{theme:s,position:"top-center",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},...a})},Pe=s.createContext({setAlertDlgOptions:()=>{},alertDlgOptions:le,orgs:[],setOrgs:()=>{},loggedInUser:null,setLoggedInUser:()=>{},activeOrg:void 0,setActiveOrg:()=>{},purchasePlans:[],setPurchasePlans:()=>{},activePlan:null,setActivePlan:()=>{},subscriptionConfig:{},setSubscriptionConfig:()=>{},featureFlags:{},setFeatureFlags:()=>{}}),ze=()=>e.jsx(i.Loader2Icon,{className:"animate-spin"}),Te=()=>e.jsxs("div",{className:"bg-muted flex min-h-svh flex-col items-center justify-center gap-6",children:[e.jsxs("h3",{className:"scroll-m-20 text-xl font-semibold tracking-tight text-primary inline-flex gap-2",children:[e.jsx("div",{className:"bg-sidebar-primary text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg",children:e.jsx(Z.logo,{className:"size-4"})}),e.jsx("div",{className:"grid flex-1 text-left leading-tight items-center text-foreground",children:Z.appName})]}),e.jsxs("div",{className:"inline-flex gap-1 ml-5",children:[e.jsx(ze,{}),"Loading application..."]})]}),Ie=({header:e="Success",description:a})=>{t.toast.success(e,{description:a})},Fe=({header:e="Error",description:a})=>{t.toast.error(e,{description:a})},Oe=({header:e="Warning",description:a})=>{t.toast.warning(e,{description:a})};let De=null;const Ae=()=>De||(De=D.create({baseURL:Z.serverUrl,headers:{api:re("apiKey")||"","Content-Type":"application/json"}}),De.interceptors.request.use(e=>(e.headers=e.headers||{},e.headers.api=re("apiKey")||"",e)),De.interceptors.response.use(e=>e.data?.response,e=>{if(!e.response)throw Fe({header:e.message||"Network error",description:"Unable to connect with server."}),e;const t=e.response.data;throw Fe({header:Le(t?.error?.errorMsg)||"Server error",description:Le(t.error.solution)||""}),t.error}),De),Ee={auth_users_tbl:{user_id:"User Id",user_email:"User Email",user_mobile_no:"User Mobile Number",user_fname:"User's First Name",user_lname:"User's Last Name",user_is_active:"User Is Active"},auth_organization_tbl:{org_id:Z.account_type_txt.singular+" Id",org_name:Z.account_type_txt.singular+" Name",org_address:Z.account_type_txt.singular+" Address",org_state:Z.account_type_txt.singular+" State",org_country:Z.account_type_txt.singular+" Country",org_external_id:Z.account_type_txt.singular+" External ID",org_gst_in:Z.account_type_txt.singular+" External ID",org_is_deleted:Z.account_type_txt.singular+" Deleted",org_created_by:Z.account_type_txt.singular+" Created By"},auth_organization_users_tbl:{org_user_id:Z.account_type_txt.singular+"User ID",org_id:Z.account_type_txt.singular+"ID",user_id:"User Id",org_user_role_id:Z.account_type_txt.singular+"User Role Id",org_user_is_active:Z.account_type_txt.singular+"User is active",user_opinion:"User Opinion"},auth_invited_users_tbl:{invited_users_id:"Invited Users Id",org_id:Z.account_type_txt.singular+"Id",email:"Email",invited_user_role_id:"Invited user role Id",invited_by_user_id:"Invited by user Id",is_deleted:"Deleted"}},Le=e=>{let t=e;const a=e.matchAll(/(\w+)\.(\w+)/g);for(const e of a){const a=e[0],s=e[1],r=e[2];if(Ee[s]?.[r]){const e=Ee[s][r];t=t.replace(a,e)}}return t=t.replaceAll("key","field"),t},Re=e=>"INR"===e?"₹":"USD"===e?"$":"EUR"===e?"€":"GBP"===e?"£":"AUD"===e||"CAD"===e?"$":"CHF"===e?"₣":"CNY"===e?"¥":"DKK"===e?"kr":"HKD"===e||"NZD"===e?"$":"SEK"===e?"kr":"SGD"===e?"$":"ZAR"===e?"R":"",Me=e=>!e||"starter"===e.plan_id,$e=(e,t,a,s,r)=>new Promise((n,i)=>{const o={key:Z.razorPayKey,amount:100*e,currency:t,order_id:a.orderId,name:Z.appName,description:Z.appDescription,handler:async function(e){try{if(!(await Ae().post("payment-gateway/verify-payment",{orderId:a.orderId,razorpayPaymentId:e.razorpay_payment_id,razorpaySignature:e.razorpay_signature})).success)return i("Payment verification failed.");n(!0)}catch(e){Fe({header:"Payment failed!",description:e?.message||"Payment verification failed."}),i(e)}},prefill:s,theme:{color:Z.themeColor},modal:{ondismiss:function(){i(new Error("Payment cancelled!"))}}},l=new r(o);l.on("payment.failed",function(e){Fe({header:"Payment Failed!",description:e.error.description||"Payment could not be processed."}),Ae().post("payment-gateway/log-failure",{orderId:a.orderId,errorCode:e.error.code,errorDescription:e.error.description,errorReason:e.error.reason,paymentId:e.metadata?.payment_id}).catch(()=>{})}),l.open()}),Ue=e=>("paid"!==e.status||(e.startAt=new Date(e.startAt),e.endAt=new Date(e.endAt),e.old_purchased_amount=Number(e.amount),e.updatedRecords&&e.updatedRecords.forEach(t=>{e.amount=Number(e.amount)+Number(t.amount)})),e),Be=()=>{const{setPurchasePlans:e,setActivePlan:t,featureFlags:a,activePlan:r,activeOrg:n}=s.useContext(Pe);return{loadPurchasedPlans:s.useCallback(async(s=!1)=>{if(!s&&!a.ff_enable_paid_subscription)return;const r=await Ae().get("/purchased-plans");r.purchasedPlans.forEach(Ue),e([...r.purchasedPlans||[]].reverse()),t(Ue(r.activePlan))},[e,t,a.ff_enable_paid_subscription]),isActiveOrgFreePlan:s.useCallback(()=>Me(n?.active_purchased_plan),[n]),isUserFreePlan:s.useCallback(()=>Me(r),[r])}},qe=({children:t})=>{const[r,n]=s.useState(!0),i=a.useLocation(),{orgs:o,setOrgs:l,loggedInUser:d,setLoggedInUser:c,setActiveOrg:u,subscriptionConfig:m,setSubscriptionConfig:x,featureFlags:p,setFeatureFlags:h}=s.useContext(Pe),{loadPurchasedPlans:g}=Be();return s.useEffect(()=>{(async()=>{try{await new Promise(e=>setTimeout(e,200));const e=await Ae().get("/feature-flags");h(e.featureFlags);const t=await Ae().get("/check-session"),a=!!t.sessionInfo?.id;if(c({email:t.user.user_email,id:t.sessionInfo?.id,fname:t.user.user_fname,lname:t.user.user_lname,mobNo:String(t.user.user_mobile_no)}),!0===a&&(e.featureFlags.ff_enable_paid_subscription&&await g(!0),e.featureFlags.ff_enable_teams)){const e=await Ae().get("organization"),t=e?.orgs||[];l(t);const a=re("activeOrgId");let s=t[0];a&&(s=t.find(e=>String(e.org_id)===a)||s),u(s)}if(e.featureFlags.ff_enable_paid_subscription&&"plans"in m==!1){const e=await Ae().get("/get-subscription-config");x(e)}}finally{n(!1)}})()},[]),r?e.jsx(Te,{}):d?.id?p.ff_enable_teams&&0===o.length&&!i.pathname.includes("infrastructure")?e.jsx(a.Navigate,{to:p.ff_enable_paid_subscription?"/infrastructure/manage-subscription":"/infrastructure",state:{from:i},replace:!0}):t:e.jsx(a.Navigate,{to:"/login",state:{from:i},replace:!0})},Ve=s.lazy(()=>Promise.resolve().then(function(){return Za})),He=s.lazy(()=>Promise.resolve().then(function(){return es})),Ye=s.lazy(()=>Promise.resolve().then(function(){return os})),We=s.lazy(()=>Promise.resolve().then(function(){return Xs})),Ke=s.lazy(()=>Promise.resolve().then(function(){return Js})),Ge=s.lazy(()=>Promise.resolve().then(function(){return Zs})),Xe=s.lazy(()=>Promise.resolve().then(function(){return er})),Je=s.lazy(()=>Promise.resolve().then(function(){return rr})),Qe=s.lazy(()=>Promise.resolve().then(function(){return nr})),Ze=s.lazy(()=>Promise.resolve().then(function(){return lr})),et=s.lazy(()=>Promise.resolve().then(function(){return dr})),tt=s.lazy(()=>Promise.resolve().then(function(){return Nr}).then(e=>({default:e.PricingTbl}))),at=s.lazy(()=>Promise.resolve().then(function(){return Fr})),st=s.lazy(()=>Promise.resolve().then(function(){return Lr})),rt=s.lazy(()=>Promise.resolve().then(function(){return Mr})),nt=s.lazy(()=>Promise.resolve().then(function(){return Ur}));function it({appRoutes:t,publicRoutes:r=[]}){const{featureFlags:n}=s.useContext(Pe),i=a.createBrowserRouter([{path:"/",element:e.jsx(qe,{children:e.jsx(We,{})}),children:[...t,{path:"app/general-settings",Component:nt},{path:"app/*",element:e.jsx(Ke,{canShowHeader:!1})}]},...!1===n.ff_enable_paid_subscription?[]:[{path:"plans",Component:tt}],...r,{path:"infrastructure",element:e.jsx(qe,{children:e.jsx(Ze,{})}),children:[...!1===n.ff_enable_teams?[]:[{index:!0,Component:Xe},{path:"create-new-org",Component:Je},{path:"edit-org/:orgId",Component:Je},{path:"user-invitations",Component:Qe},{path:"manage-infra",Component:et}],...!1===n.ff_enable_paid_subscription?[]:[{path:"manage-subscription",Component:at},{path:"checkout",Component:st},{path:"payment-history",Component:rt}]]},{Component:Ve,children:[{path:"login",Component:He},{path:"forgot-password",Component:Ge},{path:"register",Component:Ye}]},{path:"*",Component:Ke}]);return e.jsx(s.Suspense,{fallback:e.jsx(Te,{}),children:e.jsx(a.RouterProvider,{router:i})})}function ot({...t}){return e.jsx(M.Root,{"data-slot":"dialog",...t})}function lt({...t}){return e.jsx(M.Trigger,{"data-slot":"dialog-trigger",...t})}function dt({...t}){return e.jsx(M.Portal,{"data-slot":"dialog-portal",...t})}function ct({...t}){return e.jsx(M.Close,{"data-slot":"dialog-close",...t})}function ut({className:t,...a}){return e.jsx(M.Overlay,{"data-slot":"dialog-overlay",className:ee("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...a})}function mt({className:t,children:a,showCloseButton:s=!0,...r}){return e.jsxs(dt,{"data-slot":"dialog-portal",children:[e.jsx(ut,{}),e.jsxs(M.Content,{"data-slot":"dialog-content",className:ee("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",t),...r,children:[a,s&&e.jsxs(M.Close,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[e.jsx(i.XIcon,{}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function xt({className:t,...a}){return e.jsx("div",{"data-slot":"dialog-header",className:ee("flex flex-col gap-2 text-center sm:text-left",t),...a})}function pt({className:t,...a}){return e.jsx("div",{"data-slot":"dialog-footer",className:ee("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...a})}function ht({className:t,...a}){return e.jsx(M.Title,{"data-slot":"dialog-title",className:ee("text-lg leading-none font-semibold",t),...a})}function gt({className:t,...a}){return e.jsx(M.Description,{"data-slot":"dialog-description",className:ee("text-muted-foreground text-sm",t),...a})}const ft=C.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline",linkNoUnderline:"text-primary underline-offset-4"},size:{default:"h-8 px-4 py-2 has-[>svg]:px-3",sm:"h-7 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-9 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function bt({className:t,variant:a,size:s,asChild:r=!1,...n}){const i=r?_.Slot:"button";return e.jsx(i,{"data-slot":"button",className:ee(ft({variant:a,size:s,className:t}),"cursor-pointer"),...n})}function vt({loading:t=!1,children:a,...s}){return e.jsxs(bt,{...s,disabled:t||s.disabled,children:[t&&e.jsx(ze,{}),a]})}const jt=({open:t,setIsOpen:a,header:s,children:r,actionsJSX:n,disableOutsideClick:i=!1,dlgContentClsName:o})=>e.jsx(ot,{open:t,onOpenChange:e=>a(!0===e),children:e.jsxs(mt,{"aria-describedby":"dialog-content",onPointerDownOutside:e=>{i&&e.preventDefault()},className:o,children:[e.jsx(xt,{children:e.jsx(ht,{children:s})}),r,e.jsx(pt,{children:n})]})}),yt=()=>{const e=s.useContext(Pe),t=t=>{e.setAlertDlgOptions({...t,open:!0})};return{showAlertBox:t,closeAlertBox:()=>{e.setAlertDlgOptions({...e.alertDlgOptions,open:!1})},showAlertDlgPromise:async e=>new Promise((a,s)=>{t({...e,async onClose(e){"CONFIRM"===e?a(e):s(e)}})})}},Nt=({options:t})=>{const a=yt(),s=()=>{a.closeAlertBox(),t.onClose&&t.onClose("CANCEL")};return e.jsx(jt,{open:t.open,setIsOpen:s,header:"ALERT"===t.type?"Alert":"Confirmation",actionsJSX:e.jsxs(e.Fragment,{children:[e.jsx(vt,{onClick:s,variant:"ghost",children:"Cancel"}),"CONFIRM"===t.type&&e.jsx(vt,{onClick:()=>{a.closeAlertBox(),t.onClose&&t.onClose("CONFIRM")},children:"Confirm"})]}),children:e.jsx(gt,{className:"mt-3",children:t.text})})};const wt={READ:0,ADMIN:1,WRITE:2,Is_ADMIN:function(e){return e===this.ADMIN},CAN_WRITE:function(e){return e===this.WRITE||e===this.ADMIN},CAN_READ:function(e){return e===this.READ||e===this.WRITE||e===this.ADMIN},DISPLAY_TEXT:function(e){return{[this.READ]:"Read",[this.WRITE]:"Read / Write",[this.ADMIN]:Z.account_type_txt.singular+" Admin"}[e]||""},IS_VALID_ROLE_ID:function(e){return e===this.READ||e===this.ADMIN||e===this.WRITE},GET_LIST:function(){return[{id:this.READ.toString(),text:this.DISPLAY_TEXT(this.READ)},{id:this.WRITE.toString(),text:this.DISPLAY_TEXT(this.WRITE)},{id:this.ADMIN.toString(),text:this.DISPLAY_TEXT(this.ADMIN)}]}};function _t({className:t,...a}){return e.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto flex-1",children:e.jsx("table",{"data-slot":"table",className:ee("w-full caption-bottom text-sm",t),...a})})}function Ct({className:t,...a}){return e.jsx("thead",{"data-slot":"table-header",className:ee("[&_tr]:border-b",t),...a})}function kt({className:t,...a}){return e.jsx("tbody",{"data-slot":"table-body",className:ee("[&_tr:last-child]:border-0",t),...a})}function St({className:t,...a}){return e.jsx("tr",{"data-slot":"table-row",className:ee("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",t),...a})}function Pt({className:t,...a}){return e.jsx("th",{"data-slot":"table-head",className:ee("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...a})}function zt({className:t,...a}){return e.jsx("td",{"data-slot":"table-cell",className:ee("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...a})}function Tt({className:t,...a}){return e.jsx("caption",{"data-slot":"table-caption",className:ee("text-muted-foreground mt-4 text-sm",t),...a})}function It({className:t,...a}){return e.jsx("div",{"data-slot":"card",className:ee("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",t),...a})}function Ft({className:t,...a}){return e.jsx("div",{"data-slot":"card-header",className:ee("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",t),...a})}function Ot({className:t,...a}){return e.jsx("div",{"data-slot":"card-title",className:ee("leading-none font-semibold",t),...a})}function Dt({className:t,...a}){return e.jsx("div",{"data-slot":"card-description",className:ee("text-muted-foreground text-sm",t),...a})}function At({className:t,...a}){return e.jsx("div",{"data-slot":"card-content",className:ee("px-6",t),...a})}function Et({className:t,type:a,...s}){return e.jsx("input",{type:a,"data-slot":"input",className:ee("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",t),...s})}function Lt({className:t,...a}){return e.jsx(L.Root,{"data-slot":"label",className:ee("flex items-center gap-2 text-sm leading-none font-medium",t),...a})}function Rt({...t}){return e.jsx(R.Root,{"data-slot":"select",...t})}function Mt({...t}){return e.jsx(R.Value,{"data-slot":"select-value",...t})}function $t({className:t,size:a="default",children:s,...r}){return e.jsxs(R.Trigger,{"data-slot":"select-trigger","data-size":a,className:ee("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...r,children:[s,e.jsx(R.Icon,{asChild:!0,children:e.jsx(i.ChevronDownIcon,{className:"size-4 opacity-50"})})]})}function Ut({className:t,children:a,position:s="popper",...r}){return e.jsx(R.Portal,{children:e.jsxs(R.Content,{"data-slot":"select-content",className:ee("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md","popper"===s&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:s,...r,children:[e.jsx(qt,{}),e.jsx(R.Viewport,{className:ee("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:a}),e.jsx(Vt,{})]})})}function Bt({className:t,children:a,...s}){return e.jsxs(R.Item,{"data-slot":"select-item",className:ee("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",t),...s,children:[e.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:e.jsx(R.ItemIndicator,{children:e.jsx(i.CheckIcon,{className:"size-4"})})}),e.jsx(R.ItemText,{children:a})]})}function qt({className:t,...a}){return e.jsx(R.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:ee("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(i.ChevronUpIcon,{className:"size-4"})})}function Vt({className:t,...a}){return e.jsx(R.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:ee("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(i.ChevronDownIcon,{className:"size-4"})})}function Ht({...t}){return e.jsx(M.Root,{"data-slot":"sheet",...t})}function Yt({...t}){return e.jsx(M.Portal,{"data-slot":"sheet-portal",...t})}function Wt({className:t,...a}){return e.jsx(M.Overlay,{"data-slot":"sheet-overlay",className:ee("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...a})}function Kt({className:t,children:a,side:s="right",...r}){return e.jsxs(Yt,{children:[e.jsx(Wt,{}),e.jsxs(M.Content,{"data-slot":"sheet-content",className:ee("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500","right"===s&&"data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm","left"===s&&"data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm","top"===s&&"data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b","bottom"===s&&"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",t),...r,children:[a,e.jsxs(M.Close,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none",children:[e.jsx(i.XIcon,{className:"size-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Gt({className:t,...a}){return e.jsx("div",{"data-slot":"sheet-header",className:ee("flex flex-col gap-1.5 p-4",t),...a})}function Xt({className:t,...a}){return e.jsx(M.Title,{"data-slot":"sheet-title",className:ee("text-foreground font-semibold",t),...a})}function Jt({className:t,...a}){return e.jsx(M.Description,{"data-slot":"sheet-description",className:ee("text-muted-foreground text-sm",t),...a})}function Qt({className:t,...a}){return e.jsx($.Root,{"data-slot":"switch",className:ee("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...a,children:e.jsx($.Thumb,{"data-slot":"switch-thumb",className:ee("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}function Zt({delayDuration:t=0,...a}){return e.jsx(U.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...a})}function ea({delayDuration:t,...a}){return e.jsx(Zt,{delayDuration:t,children:e.jsx(U.Root,{"data-slot":"tooltip",...a})})}function ta({...t}){return e.jsx(U.Trigger,{"data-slot":"tooltip-trigger",...t})}function aa({className:t,sideOffset:a=0,children:s,...r}){return e.jsx(U.Portal,{children:e.jsxs(U.Content,{"data-slot":"tooltip-content",sideOffset:a,className:ee("bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",t),...r,children:[s,e.jsx(U.Arrow,{className:"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const sa=C.cva("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",success:"border-transparent bg-primary/10 text-primary [a&]:hover:bg-primary/20",failure:"border-transparent bg-destructive/10 text-destructive [a&]:hover:bg-destructive/20"}},defaultVariants:{variant:"default"}});function ra({className:t,variant:a,asChild:s=!1,...r}){const n=s?_.Slot:"span";return e.jsx(n,{"data-slot":"badge",className:ee(sa({variant:a}),t),...r})}function na({className:t,orientation:a="horizontal",decorative:s=!0,...r}){return e.jsx(B.Root,{"data-slot":"separator",decorative:s,orientation:a,className:ee("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",t),...r})}function ia({...t}){return e.jsx(q.Root,{"data-slot":"dropdown-menu",...t})}function oa({...t}){return e.jsx(q.Trigger,{"data-slot":"dropdown-menu-trigger",...t})}function la({className:t,sideOffset:a=4,...s}){return e.jsx(q.Portal,{children:e.jsx(q.Content,{"data-slot":"dropdown-menu-content",sideOffset:a,className:ee("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",t),...s})})}function da({...t}){return e.jsx(q.Group,{"data-slot":"dropdown-menu-group",...t})}function ca({className:t,inset:a,variant:s="default",...r}){return e.jsx(q.Item,{"data-slot":"dropdown-menu-item","data-inset":a,"data-variant":s,className:ee("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...r})}function ua({className:t,children:a,checked:s,...r}){return e.jsxs(q.CheckboxItem,{"data-slot":"dropdown-menu-checkbox-item",className:ee("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),checked:s,...r,children:[e.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:e.jsx(q.ItemIndicator,{children:e.jsx(i.CheckIcon,{className:"size-4"})})}),a]})}function ma({className:t,inset:a,...s}){return e.jsx(q.Label,{"data-slot":"dropdown-menu-label","data-inset":a,className:ee("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",t),...s})}function xa({className:t,...a}){return e.jsx(q.Separator,{"data-slot":"dropdown-menu-separator",className:ee("bg-border -mx-1 my-1 h-px",t),...a})}function pa({className:t,...a}){return e.jsx("textarea",{"data-slot":"textarea",className:ee("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),...a})}function ha({className:t,orientation:a="horizontal",...s}){return e.jsx(V.Root,{"data-slot":"tabs","data-orientation":a,orientation:a,className:ee("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",t),...s})}const ga=C.cva("rounded-lg p-[3px] group-data-[orientation=horizontal]/tabs:h-9 data-[variant=line]:rounded-none group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function fa({className:t,variant:a="default",...s}){return e.jsx(V.List,{"data-slot":"tabs-list","data-variant":a,className:ee(ga({variant:a}),t),...s})}function ba({className:t,...a}){return e.jsx(V.Trigger,{"data-slot":"tabs-trigger",className:ee("focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-foreground/60 hover:text-foreground dark:text-muted-foreground dark:hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","data-[state=active]:bg-background dark:data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 data-[state=active]:text-foreground","after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",t),...a})}const va=()=>e.jsxs("div",{className:"absolute inset-0 flex items-center justify-center",children:[e.jsx(ze,{}),"  Loading..."]}),ja=({className:t,layout:a="vertical",loading:s,doNotAppendFlex1:r=!1,responsive:n=!1,...i})=>{const o="horizontal"===a?!0===n?"sm:flex-row flex-col":"flex-row":"flex-col",l=r?"":"flex-1",d=a=>e.jsx("div",{className:`${l} flex ${o} items-stretch overflow-auto ${a||""} ${t}`,...i});if(!s)return d();const c=s?"pointer-events-none opacity-50":"";return e.jsxs("div",{className:"relative flex-1",children:[s&&e.jsx(va,{}),d(c)]})};function ya(){const[e,t]=E.useState(void 0);return E.useEffect(()=>{const e=window.matchMedia("(max-width: 767px)"),a=()=>{t(window.innerWidth<768)};return e.addEventListener("change",a),t(window.innerWidth<768),()=>e.removeEventListener("change",a)},[]),!!e}const Na=({leftItems:t=[],centerItems:a=[],rightItems:r=[],className:n="",style:o={}})=>{const l=ya(),[d,c]=s.useState(!1),u=[...t,...a,...r];return e.jsx("div",{className:`flex items-center w-full ${n}`,style:{minHeight:48,...o},children:l?e.jsxs("div",{className:"flex w-full justify-end items-center",children:[e.jsx(vt,{type:"button",onClick:()=>c(!0),children:e.jsx(i.Menu,{})}),e.jsx(jt,{open:d,setIsOpen:c,header:"Menu",actionsJSX:e.jsx(e.Fragment,{}),disableOutsideClick:!1,children:e.jsx("div",{className:"flex flex-col gap-5 mt-2",children:u.map((t,a)=>e.jsx("div",{children:t},a))})})]}):e.jsxs(e.Fragment,{children:[t.length>0&&e.jsx("div",{className:"flex flex-1 items-center gap-2 justify-start px-1",children:t}),a.length>0&&e.jsx("div",{className:"flex flex-1 items-center gap-2 justify-center px-1",children:a}),r.length>0&&e.jsx("div",{className:"flex flex-1 items-center gap-2 justify-end px-1",children:r})]})})};function wa({table:t,canShowSearchField:a=!0,searchFieldConfig:s={},canShowColumnsBtn:r=!1,additionalJSX:n,rawColumns:o,refreshBtn:l={canShow:!1,onClick:()=>{}}}){const d=e=>o.find(t=>t.id===e),c=ya();return e.jsx(ja,{className:"px-1 py-2 gap-2",layout:c?"vertical":"horizontal",doNotAppendFlex1:!0,children:e.jsx(Na,{leftItems:[a&&s.searchField?e.jsx(Et,{placeholder:s.placeholder,value:t.getColumn(s.searchField)?.getFilterValue()??"",onChange:e=>{const a=t.getColumn(s.searchField);a?.setFilterValue(e.target.value)},className:"max-w-sm"},"searchField"):e.jsx(e.Fragment,{}),l.canShow&&e.jsxs(vt,{variant:"ghost",onClick:l.onClick,children:[e.jsx(i.RefreshCcw,{})," Refresh"]},"refreshBtn")],rightItems:[r&&e.jsxs(ia,{children:[e.jsx(oa,{asChild:!0,children:e.jsxs(vt,{variant:"ghost",children:["Columns ",e.jsx(i.ChevronDown,{})]},"columnsBtn")}),e.jsx(la,{align:"end",children:t.getAllColumns().filter(e=>e.getCanHide()&&d(e.id)?.enableHiding).map(t=>e.jsx(ua,{checked:t.getIsVisible(),onCheckedChange:e=>t.toggleVisibility(!!e),children:d(t.id)?.headerText||""},t.id))})]},"columnsBtnDropDown"),...n]})})}function _a({className:t,...a}){return e.jsx("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:ee("mx-auto flex w-full justify-center",t),...a})}function Ca({className:t,...a}){return e.jsx("ul",{"data-slot":"pagination-content",className:ee("flex flex-row items-center gap-1",t),...a})}function ka({...t}){return e.jsx("li",{"data-slot":"pagination-item",...t})}function Sa({className:t,isActive:a,size:s="icon",...r}){return e.jsx("a",{"aria-current":a?"page":void 0,"data-slot":"pagination-link","data-active":a,className:ee(ft({variant:a?"outline":"ghost",size:s}),"cursor-pointer",t),...r})}function Pa({className:t,...a}){return e.jsxs(Sa,{"aria-label":"Go to previous page",size:"default",className:ee("gap-1 px-2.5 sm:pl-2.5",t),...a,children:[e.jsx(i.ChevronLeftIcon,{}),e.jsx("span",{className:"hidden sm:block",children:"Previous"})]})}function za({className:t,...a}){return e.jsxs(Sa,{"aria-label":"Go to next page",size:"default",className:ee("gap-1 px-2.5 sm:pr-2.5",t),...a,children:[e.jsx("span",{className:"hidden sm:block",children:"Next"}),e.jsx(i.ChevronRightIcon,{})]})}function Ta({className:t,...a}){return e.jsxs("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:ee("flex size-9 items-center justify-center",t),...a,children:[e.jsx(i.MoreHorizontalIcon,{className:"size-4"}),e.jsx("span",{className:"sr-only",children:"More pages"})]})}const Ia=({totalCount:t,activePage:a,pageSize:r,onPageChange:n})=>{const i=s.useMemo(()=>Math.ceil(t/r),[t,r]),o=e=>{e<0||e>=i||n(e)},l="opacity-50 cursor-not-allowed",d=oe(i).filter(e=>e<a+3&&e>a-3||0===e||e===i-1);return e.jsx(_a,{className:"text-secondary-foreground",children:e.jsxs(Ca,{children:[e.jsx(ka,{children:e.jsx(Pa,{className:0===a?l:"",onClick:()=>o(a-1)})}),d.map((t,r)=>{let n=null;return r>0&&t-d[r-1]!==1&&(n=e.jsx(ka,{children:e.jsx(Ta,{})})),e.jsxs(s.Fragment,{children:[n,e.jsx(ka,{className:a===t?"bg-primary text-primary-foreground rounded-2xl hover:bg-primary":"",children:e.jsx(Sa,{onClick:()=>o(t),children:t+1})})]},t)}),e.jsx(ka,{children:e.jsx(za,{className:a===i-1?l:"",onClick:()=>o(a+1)})})]})})},Fa=({pagination:t,totalCount:a,table:s})=>e.jsx("div",{className:"flex items-center justify-end space-x-2 pt-4",children:e.jsx(Ia,{totalCount:a,activePage:t.pageIndex,onPageChange:e=>{s.setPageIndex(e)},pageSize:t.pageSize})});var Oa=E.memo(function({data:t,columns:a,actions:s,toolbarConfig:r,loading:n=!1,canShowToolbar:o=!0,canShowPagination:l=!0}){const[d,c]=E.useState([]),[u,m]=E.useState([]),[x,p]=E.useState({}),[h,g]=E.useState({}),f=a.map(t=>({accessorKey:t.id,header:({column:a})=>t.enableSorting?e.jsxs(vt,{variant:"ghost",onClick:()=>a.toggleSorting("asc"===a.getIsSorted()),children:[t.headerText,e.jsx(i.ArrowUpDown,{})]}):e.jsx("span",{children:t.headerText}),cell:({row:a})=>{const s=a.getValue(t.id);if(ve(t.renderer))return t.renderer(a,s);let r;return r="boolean"===t.type?s?e.jsx(i.Check,{size:20}):e.jsx(i.X,{size:18}):"date"===t.type?pe(s):String(s),e.jsx("div",{children:r})}}));s&&s.length>0&&f.unshift({id:"actions",enableHiding:!1,cell:({row:t})=>{const a=t.original;return e.jsxs(ia,{children:[e.jsx(oa,{asChild:!0,children:e.jsxs(vt,{variant:"secondary",className:"h-5 w-8 p-0",children:[e.jsx("span",{className:"sr-only",children:"Open menu"}),e.jsx(i.MoreHorizontal,{})]})}),e.jsxs(la,{align:"start",children:[e.jsx(ma,{children:"Actions"}),s.map(t=>"SEPARATOR"===t.headerText?e.jsx(xa,{},t.id):e.jsx(ca,{onClick:()=>t.onClick&&t.onClick(a),children:t.headerText},t.id))]})]})}});const[b,v]=E.useState({pageIndex:0,pageSize:100}),j=O.useReactTable({data:t,columns:f,onSortingChange:c,onColumnFiltersChange:m,getCoreRowModel:O.getCoreRowModel(),getSortedRowModel:O.getSortedRowModel(),getFilteredRowModel:O.getFilteredRowModel(),onColumnVisibilityChange:p,onRowSelectionChange:g,...l&&{getPaginationRowModel:O.getPaginationRowModel(),onPaginationChange:v},state:{sorting:d,columnFilters:u,columnVisibility:x,rowSelection:h,pagination:b}}),y=n?"pointer-events-none opacity-50":"";return e.jsxs(ja,{className:"w-full",children:[o&&e.jsx(wa,{table:j,rawColumns:a,canShowSearchField:!0,canShowColumnsBtn:!0,...r,additionalJSX:r?.additionalJSX||[]}),n&&e.jsx(va,{}),e.jsx(ja,{className:`rounded-md border overflow-auto ${y}`,children:e.jsxs(_t,{children:[e.jsx(Ct,{className:"sticky top-0 bg-sidebar",children:j.getHeaderGroups().map(t=>e.jsx(St,{children:t.headers.map(t=>e.jsx(Pt,{children:t.isPlaceholder?null:O.flexRender(t.column.columnDef.header,t.getContext())},t.id))},t.id))}),e.jsx(kt,{className:"flex-1",children:j.getRowModel().rows?.length?j.getRowModel().rows.map(t=>e.jsx(St,{"data-state":t.getIsSelected()&&"selected",children:t.getVisibleCells().map(t=>e.jsx(zt,{children:O.flexRender(t.column.columnDef.cell,t.getContext())},t.id))},t.id)):e.jsx(St,{children:e.jsx(zt,{colSpan:s&&s.length>0?a.length+1:a.length,className:"h-24 text-center",children:"No results."})})})]})}),l&&e.jsx(Fa,{pagination:b,totalCount:t.length,table:j})]})});const Da=({child:t,className:a,rowCls:s,leftCls:r,rightCls:n})=>e.jsx("div",{className:`w-full ${a||""}`,children:be(t,(t,a,i)=>e.jsxs("div",{className:`flex w-full ${s||""}`,children:[e.jsx("div",{className:`flex-shrink-0 ${r||""}`,children:t}),e.jsx("div",{className:`flex-1 min-w-0 ${n||""}`,children:a})]},i+"tabularLayout"))});function Aa({className:t,...a}){return e.jsx("h4",{className:`scroll-m-20 text-xl font-semibold tracking-tight ${t||""}`,...a})}function Ea({...t}){return e.jsx("p",{className:"leading-7 [&:not(:first-child)]:mt-6",...t})}function La({...t}){return e.jsx(W.Root,{"data-slot":"accordion",...t})}function Ra({className:t,...a}){return e.jsx(W.Item,{"data-slot":"accordion-item",className:ee("border-b last:border-b-0",t),...a})}function Ma({className:t,children:a,...s}){return e.jsx(W.Header,{className:"flex",children:e.jsxs(W.Trigger,{"data-slot":"accordion-trigger",className:ee("focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",t),...s,children:[a,e.jsx(i.ChevronDownIcon,{className:"text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200"})]})})}function $a({className:t,children:a,...s}){return e.jsx(W.Content,{"data-slot":"accordion-content",className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm",...s,children:e.jsx("div",{className:ee("pt-0 pb-4",t),children:a})})}const Ua=({title:t,children:a})=>e.jsx(La,{type:"single",collapsible:!0,children:e.jsxs(Ra,{value:"item-1",children:[e.jsx(Ma,{children:t}),e.jsx($a,{children:a})]})}),Ba=({...t})=>e.jsx("span",{...t}),qa=({className:t,disabled:s,removeAllStyles:r=!1,...n})=>{const i=s?Ba:a.NavLink,o=s?"opacity-40 cursor-not-allowed":"cursor-pointer hover:underline";return e.jsx(i,{className:(t||"")+" "+(r?"":o),...n})},Va=({children:t,toPath:a,disabled:s,className:r,...n})=>e.jsx(qa,{to:a,disabled:s,className:"h-40 p-5 w-60 border-2 border-primary rounded-4xl font-semibold flex flex-col justify-center hover:bg-accent "+r,...n,children:t}),Ha=({children:t})=>e.jsx("h3",{className:"text-lg font-medium",children:t}),Ya=({children:t,side:a})=>e.jsxs(ea,{children:[e.jsx(ta,{asChild:!0,children:e.jsx("span",{className:"ml-2 align-middle cursor-pointer",children:e.jsx(vt,{variant:"link",className:"-ml-5",type:"button",tabIndex:-1,children:e.jsx(i.InfoIcon,{})})})}),e.jsx(aa,{side:a,children:t})]}),Wa=({title:t,description:a,control:s,labelCls:r="",className:n=""})=>e.jsxs("div",{className:`flex flex-row items-center justify-between rounded-lg border p-4 shadow-sm ${n}`,children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(Lt,{className:`cursor-pointer ${r}`,children:t}),e.jsx(Lt,{className:`font-normal text-gray-500 cursor-pointer ${r}`,children:a})]}),e.jsx("div",{children:s})]}),Ka=({children:t})=>e.jsxs("span",{className:`premium-icon-wrapper relative inline-flex items-center ${t?"gap-1":""} px-1.5 py-1.5 rounded-lg bg-gradient-to-br from-amber-400 via-amber-500 to-amber-600 bg-[length:200%_200%] text-xs font-semibold text-white transition-all duration-300 ease-in-out overflow-hidden hover:scale-105 hover:shadow-[0_0_20px_rgba(251,191,36,0.6),0_0_40px_rgba(251,191,36,0.3)] dark:from-amber-900 dark:via-amber-700 dark:to-amber-600 dark:bg-[length:200%_200%]`,children:[e.jsx(i.Crown,{size:14,className:"premium-crown relative z-10 flex-shrink-0 drop-shadow-[0_2px_4px_rgba(0,0,0,0.2)] text-white",strokeWidth:2.5}),e.jsx("span",{className:"relative z-10",children:t})]}),Ga=({placeholder:t,items:a,value:s,onValueChange:r,triggerClassName:n="w-[180px]",valueField:i="value",labelField:o="label",id:l,...d})=>e.jsxs(Rt,{value:s,onValueChange:e=>{r?.(e)},children:[e.jsx($t,{className:n,...d,id:l,children:e.jsx(Mt,{placeholder:t})}),e.jsx(Ut,{children:a.map(t=>e.jsx(Bt,{value:t[i],children:t[o]},t[i]))})]}),Xa=({content:t,side:a="bottom",rootProps:r,contentProps:n,triggerProps:i,children:o,canShowTooltip:l=!0,delayDuration:d=100,triggerOn:c="default"})=>{const[u,m]=s.useState(()=>"default"===c&&(!!l&&void 0)),x=s.useRef(null),p=e=>{"click"===c&&((e=>{const t=e?.target;return t&&x.current&&x.current?.contains(t)})(e)||m(!1))};return e.jsxs(ea,{open:u,delayDuration:d,...r,children:[e.jsx(ta,{"data-testid":"tooltip-trigger",asChild:!0,ref:x,onClick:()=>{"click"===c&&m(l&&!u)},...i,children:o}),e.jsx(aa,{side:a,"data-testid":"tooltip-content",onPointerDownOutside:p,onEscapeKeyDown:p,...n,children:t})]})},Ja=({onClick:t,icon:a,label:s,shortcut:r,className:n})=>e.jsxs("button",{onClick:e=>{e.preventDefault(),e.stopPropagation(),t()},className:ee("flex items-center justify-between w-full px-2 py-1.5 text-sm rounded-md transition-colors","hover:bg-accent hover:text-accent-foreground text-left",n),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex items-center justify-center w-6 h-6 rounded-md bg-muted/50",children:a}),e.jsx("span",{children:s})]}),r&&e.jsx("span",{className:"text-[10px] text-muted-foreground bg-muted px-1.5 py-0.5 rounded uppercase font-medium",children:r})]}),Qa=e=>{const[t,a]=s.useState(null),[r,n]=s.useState(!1);return s.useEffect(()=>{(async()=>{n(!0);try{const t=await Ae().get(e);a(t)}finally{n(!1)}})()},[e]),{loading:r,response:t}};var Za=Object.freeze({__proto__:null,default:function(){return e.jsx("div",{className:"bg-muted flex min-h-svh flex-col items-center justify-center gap-6 p-6 md:p-10",children:e.jsxs("div",{className:"flex w-full max-w-sm flex-col gap-6",children:[e.jsxs("span",{className:"flex items-center gap-2 self-center font-medium",children:[e.jsx("div",{className:"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md",children:e.jsx(Z.logo,{className:"size-4"})}),Z.appName]}),e.jsxs("div",{className:ee("flex flex-col gap-6"),children:[e.jsxs(It,{children:[e.jsxs(Ft,{className:"text-center",children:[e.jsx(Ot,{className:"text-xl",children:"Welcome"}),e.jsx(Dt,{children:"Please fill the below details to continue"})]}),e.jsx(At,{children:e.jsx(a.Outlet,{})})]}),e.jsxs("div",{className:"text-muted-foreground *:[a]:hover:text-primary text-center text-xs text-balance *:[a]:underline *:[a]:underline-offset-4",children:["By clicking continue, you agree to our ",e.jsx("a",{children:"Terms of Service"})," and ",e.jsx("a",{children:"Privacy Policy"}),"."]})]})]})})}});var es=Object.freeze({__proto__:null,default:function(){const t=s.useRef(null),r=a.useNavigate(),[n,i]=s.useTransition(),o=a.useLocation(),[l,d]=s.useState(""),c=s.useRef(null),u=o.state?.from,m=u?`${u.pathname}${u.search}${u.hash}`:"/",x="grid gap-1";return s.useEffect(()=>{t?.current?.focus()},[]),e.jsxs("div",{className:"grid gap-6",children:[e.jsx("div",{className:"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t",children:e.jsx("span",{className:"bg-card text-muted-foreground relative z-10 px-2",children:"Login"})}),e.jsxs("form",{onSubmit:async e=>{if(e.preventDefault(),!l)return void Fe({header:"Captcha not completed",description:"Please complete the captcha to proceed."});const t=te(e.currentTarget),a={username:t.email,password:t.password,turnstileToken:l};!1!==ue(a.username)?i(async()=>{try{const e=await Ae().post("/login",a),{api:t=""}=e;if(!t)return Fe({header:"Something went wrong!",description:"API Key not found."}),void ce("API key not found in login command.");Ie({header:"Welcome Back!",description:"Login Successful."}),se("apiKey",t),r(m)}catch(e){c.current?.reset(),d(""),ce(e)}}):Fe({header:"Email is not valid.",description:"Kindly recheck the email and try again."})},className:"grid gap-6",children:[e.jsxs("div",{className:x,children:[e.jsx(Lt,{htmlFor:"email",children:"Email *"}),e.jsx(Et,{id:"email",type:"email",placeholder:"mail@example.com",name:"email",ref:t,required:!0})]}),e.jsxs("div",{className:x,children:[e.jsx(Lt,{htmlFor:"password",children:"Password *"}),e.jsx(Et,{id:"password",type:"password",name:"password",placeholder:"**********",required:!0}),e.jsx(a.NavLink,{to:"/forgot-password",className:"ml-auto text-sm underline-offset-4 hover:underline cursor-pointer",children:"Forgot your password?"})]}),e.jsx("div",{className:"text-center",children:e.jsx(N.Turnstile,{ref:c,siteKey:Z.cloudFareKey,onSuccess:e=>d(e)})}),e.jsx(vt,{type:"submit",className:"w-full",size:"lg",loading:n,children:"Login"})]}),e.jsxs("div",{className:"text-center text-sm",children:["Don't have an account?"," ",e.jsx(a.NavLink,{to:"/register",children:e.jsx("span",{className:"underline underline-offset-4",children:"Register"})})]})]})}});const ts=()=>e.jsxs(Ya,{side:"right",children:[e.jsx("h5",{children:"Password Policy:"}),e.jsxs("ul",{children:[e.jsx("li",{children:"Password must be at least 8 characters long."}),e.jsx("li",{children:"Password must contain at least one uppercase letter."}),e.jsx("li",{children:"Password must contain at least one lowercase letter."}),e.jsx("li",{children:"Password must contain at least one number."}),e.jsx("li",{children:"Password must contain at least one special character."})]})]}),as=({handleOnOTPSent:t,ref:a,gridCls:r,hidden:n,path:i})=>{const o=s.useRef(null),[l,d]=s.useTransition();s.useImperativeHandle(a,()=>({focus(){o.current?.focus()}}),[]);return e.jsxs("form",{onSubmit:async e=>{e.preventDefault();const a={email:te(e.currentTarget).email||""};d(async()=>{try{await(async(e,t)=>{if(!1===ue(t.email))throw Fe({header:"Email is not valid.",description:"Kindly recheck the email and try again."});try{const a=await Ae().post("/send-otp/"+e,t);Ie({header:a.message||"OTP has been sent successfully",description:"Kindly enter below details to continue."})}catch(e){throw ce(e),e}})(i,a),t(a)}catch(e){ce(e)}})},className:`grid gap-5 ${n&&"hidden"}`,children:[e.jsxs("div",{className:r,children:[e.jsx(Lt,{htmlFor:"email",children:"Email *"}),e.jsx(Et,{id:"email",type:"email",name:"email",placeholder:"mail@example.com",ref:o,required:!0})]}),e.jsx(vt,{type:"submit",className:"w-full",loading:l,children:"Generate OTP"})]})};function ss({className:t,containerClassName:a,...s}){return e.jsx(P.OTPInput,{"data-slot":"input-otp",containerClassName:ee("flex items-center gap-2 has-disabled:opacity-50",a),className:ee("disabled:cursor-not-allowed",t),...s})}function rs({className:t,...a}){return e.jsx("div",{"data-slot":"input-otp-group",className:ee("flex items-center",t),...a})}function ns({index:t,className:a,...s}){const r=E.useContext(P.OTPInputContext),{char:n,hasFakeCaret:i,isActive:o}=r?.slots[t]??{};return e.jsxs("div",{"data-slot":"input-otp-slot","data-active":o,className:ee("data-[active=true]:border-ring data-[active=true]:ring-ring/50 data-[active=true]:aria-invalid:ring-destructive/20 dark:data-[active=true]:aria-invalid:ring-destructive/40 aria-invalid:border-destructive data-[active=true]:aria-invalid:border-destructive dark:bg-input/30 border-input relative flex h-9 w-9 items-center justify-center border-y border-r text-sm shadow-xs transition-all outline-none first:rounded-l-md first:border-l last:rounded-r-md data-[active=true]:z-10 data-[active=true]:ring-[3px]",a),...s,children:[n,i&&e.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"animate-caret-blink bg-foreground h-4 w-px duration-1000"})})]})}const is=({className:t,inputOTPField:a,otp:r,setOtp:n,onChangeEmailClick:i})=>{const o=function(e=30){const[t,a]=s.useState(e);return s.useEffect(()=>{if(t>0){const e=setTimeout(()=>a(t-1),1e3);return()=>clearTimeout(e)}},[t]),t}();return e.jsxs("div",{className:t,children:[e.jsx(Lt,{htmlFor:"otp",children:"Enter OTP *"}),e.jsx(ss,{maxLength:4,name:"otp",id:"otp",ref:a,value:r,onChange:n,children:e.jsxs(rs,{children:[e.jsx(ns,{index:0}),e.jsx(ns,{index:1}),e.jsx(ns,{index:2}),e.jsx(ns,{index:3})]})}),e.jsx("span",{className:"text-xs underline-offset-4 italic",children:o>0?e.jsxs("span",{className:"muted-foreground",children:["You can resend the OTP in ",o," seconds."]}):e.jsx("span",{className:"hover:underline cursor-pointer",onClick:()=>i(),children:"Didn't receive the OTP? Send again."})})]})};var os=Object.freeze({__proto__:null,default:function(){const t=s.useRef(null),r="grid gap-1",n=s.useRef(null),[i,o]=s.useState(!1),[l,d]=s.useState(""),[c,u]=s.useState(""),[m,x]=s.useTransition(),p=a.useNavigate();s.useEffect(()=>{i?n.current?.focus():t?.current?.focus()},[i]);const h=()=>{o(!1)};return e.jsxs("div",{className:"grid gap-5",children:[e.jsx("div",{className:"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t",children:e.jsx("span",{className:"bg-card text-muted-foreground relative z-10 px-2",children:"User Registration"})}),e.jsx(as,{ref:t,handleOnOTPSent:e=>{o(!0),u(e.email)},gridCls:r,hidden:i,path:"new-registration"}),i&&e.jsxs("form",{onSubmit:e=>{if(e.preventDefault(),!l)return Fe({header:"OTP Required!",description:"Please enter your OTP and try again."}),void n.current?.focus();const t=te(e.currentTarget);t.otp=l,t.user_email=c;const a=de(t.user_password);!1!==a.valid?x(async()=>{try{await Ae().post("user-registration",t),Ie({header:`Welcome to ${Z.appName}`,description:"Registration successful! Please log in to continue."}),p("/login")}catch(e){ce(e)}}):Fe({header:"Password Policy",description:a.message})},className:"grid gap-5",children:[e.jsxs("div",{className:r,children:[e.jsx(Lt,{htmlFor:"emailOTPGenerated",children:"Email *"}),e.jsx(Et,{id:"emailOTPGenerated",type:"email",name:"email",placeholder:"mail@example.com",value:c,disabled:!0,required:!0}),e.jsx("span",{className:"ml-auto text-xs underline-offset-4 hover:underline cursor-pointer italic",onClick:h,children:"Change Email"})]}),e.jsx(is,{className:r,inputOTPField:n,otp:l,setOtp:d,onChangeEmailClick:h}),e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("div",{className:r+" flex-1",children:[e.jsx(Lt,{htmlFor:"firstName",children:"First Name *"}),e.jsx(Et,{id:"firstName",name:"user_fname",type:"text",required:!0})]}),e.jsxs("div",{className:r+" flex-1",children:[e.jsx(Lt,{htmlFor:"lastName",children:"Last Name *"}),e.jsx(Et,{id:"lastName",name:"user_lname",type:"text",required:!0})]})]}),e.jsxs("div",{className:r,children:[e.jsx(Lt,{htmlFor:"mobile",children:"Mobile No"}),e.jsx(Et,{id:"mobile",type:"number",name:"user_mobile_no",placeholder:"98******88"})]}),e.jsxs("div",{className:r,children:[e.jsxs(Lt,{htmlFor:"password",children:["Set Password * ",e.jsx(ts,{})]}),e.jsx(Et,{id:"password",name:"user_password",type:"password",placeholder:"**********",required:!0})]}),e.jsx(vt,{type:"submit",className:"w-full",size:"lg",loading:m,children:"Create account"})]}),e.jsxs("div",{className:"text-center text-sm",children:["Already have an account?"," ",e.jsx(a.NavLink,{to:"/login",children:e.jsx("span",{className:"underline underline-offset-4",children:"Login"})})]})]})}});function ls({...t}){return e.jsx(H.Root,{"data-slot":"collapsible",...t})}function ds({isCollapsible:t,...a}){return t?e.jsx(H.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...a}):e.jsx(e.Fragment,{children:a.children})}function cs({...t}){return e.jsx(H.CollapsibleContent,{"data-slot":"collapsible-content",...t})}const us=E.createContext(null);function ms(){const e=E.useContext(us);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}function xs({defaultOpen:t=!0,open:a,onOpenChange:s,className:r,style:n,children:i,...o}){const l=ya(),[d,c]=E.useState(!1),[u,m]=E.useState(t),x=a??u,p=E.useCallback(e=>{const t="function"==typeof e?e(x):e;s?s(t):m(t),document.cookie=`sidebar_state=${t}; path=/; max-age=604800`},[s,x]),h=E.useCallback(()=>l?c(e=>!e):p(e=>!e),[l,p,c]);E.useEffect(()=>{const e=e=>{"l"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),h())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[h]);const g=x?"expanded":"collapsed",f=E.useMemo(()=>({state:g,open:x,setOpen:p,isMobile:l,openMobile:d,setOpenMobile:c,toggleSidebar:h}),[g,x,p,l,d,c,h]);return e.jsx(us.Provider,{value:f,children:e.jsx(Zt,{delayDuration:0,children:e.jsx("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":"16rem","--sidebar-width-icon":"3rem",...n},className:ee("group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full",r),...o,children:i})})})}function ps({side:t="left",variant:a="sidebar",collapsible:s="offcanvas",className:r,children:n,...i}){const{isMobile:o,state:l,openMobile:d,setOpenMobile:c}=ms();return"none"===s?e.jsx("div",{"data-slot":"sidebar",className:ee("bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col",r),...i,children:n}):o?e.jsx(Ht,{open:d,onOpenChange:c,...i,children:e.jsxs(Kt,{"data-sidebar":"sidebar","data-slot":"sidebar","data-mobile":"true",className:"bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden",style:{"--sidebar-width":"18rem"},side:t,children:[e.jsxs(Gt,{className:"sr-only",children:[e.jsx(Xt,{children:"Sidebar"}),e.jsx(Jt,{children:"Displays the mobile sidebar."})]}),e.jsx("div",{className:"flex h-full w-full flex-col",children:n})]})}):e.jsxs("div",{className:"group peer text-sidebar-foreground hidden md:block","data-state":l,"data-collapsible":"collapsed"===l?s:"","data-variant":a,"data-side":t,"data-slot":"sidebar",children:[e.jsx("div",{"data-slot":"sidebar-gap",className:ee("relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180","floating"===a||"inset"===a?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon)")}),e.jsx("div",{"data-slot":"sidebar-container",className:ee("fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex","left"===t?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]","floating"===a||"inset"===a?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...i,children:e.jsx("div",{"data-sidebar":"sidebar","data-slot":"sidebar-inner",className:"bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm",children:n})})]})}function hs({className:t,onClick:a,...s}){const{toggleSidebar:r}=ms();return e.jsxs(vt,{"data-sidebar":"trigger","data-slot":"sidebar-trigger",variant:"ghost",size:"icon",className:ee("size-7",t),onClick:e=>{a?.(e),r()},...s,children:[e.jsx(i.PanelLeftIcon,{}),e.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})}function gs({className:t,...a}){const{toggleSidebar:s}=ms();return e.jsx("button",{"data-sidebar":"rail","data-slot":"sidebar-rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:s,title:"Toggle Sidebar",className:ee("hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex","in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",t),...a})}function fs({className:t,...a}){return e.jsx("main",{"data-slot":"sidebar-inset",className:ee("bg-background relative flex w-full flex-1 flex-col","md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",t),...a})}function bs({className:t,...a}){return e.jsx("div",{"data-slot":"sidebar-header","data-sidebar":"header",className:ee("flex flex-col gap-2 p-2",t),...a})}function vs({className:t,...a}){return e.jsx("div",{"data-slot":"sidebar-footer","data-sidebar":"footer",className:ee("flex flex-col gap-2 p-2",t),...a})}function js({className:t,...a}){return e.jsx("div",{"data-slot":"sidebar-content","data-sidebar":"content",className:ee("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",t),...a})}function ys({className:t,...a}){return e.jsx("div",{"data-slot":"sidebar-group","data-sidebar":"group",className:ee("relative flex w-full min-w-0 flex-col p-2",t),...a})}function Ns({className:t,asChild:a=!1,...s}){const r=a?_.Slot:"div";return e.jsx(r,{"data-slot":"sidebar-group-label","data-sidebar":"group-label",className:ee("text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",t),...s})}function ws({className:t,...a}){return e.jsx("ul",{"data-slot":"sidebar-menu","data-sidebar":"menu",className:ee("flex w-full min-w-0 flex-col gap-1",t),...a})}function _s({className:t,...a}){return e.jsx("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:ee("group/menu-item relative",t),...a})}const Cs=C.cva("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-hidden ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-data-[sidebar=menu-action]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function ks({asChild:t=!1,isExpanded:a=!1,variant:s="default",size:r="default",tooltip:n,className:i,...o}){const l=t?_.Slot:"button",d=e.jsx(l,{"data-slot":"sidebar-menu-button","data-sidebar":"menu-button","data-size":r,"data-active":a,className:ee(Cs({variant:s,size:r}),i),...o});return n?("string"==typeof n&&(n={children:n}),e.jsxs(ea,{children:[e.jsx(ta,{asChild:!0,children:d}),e.jsx(aa,{side:"right",align:"center",...n})]})):d}function Ss({className:t,...a}){return e.jsx("ul",{"data-slot":"sidebar-menu-sub","data-sidebar":"menu-sub",className:ee("border-sidebar-border mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",t),...a})}function Ps({className:t,...a}){return e.jsx("li",{"data-slot":"sidebar-menu-sub-item","data-sidebar":"menu-sub-item",className:ee("group/menu-sub-item relative",t),...a})}function zs({asChild:t=!1,size:a="md",isExpanded:s=!1,className:r,...n}){const i=t?_.Slot:"a";return e.jsx(i,{"data-slot":"sidebar-menu-sub-button","data-sidebar":"menu-sub-button","data-size":a,"data-active":s,className:ee("text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 outline-hidden focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground","sm"===a&&"text-xs","md"===a&&"text-sm","group-data-[collapsible=icon]:hidden",r),...n})}function Ts({navItems:t}){const s=a.useLocation().pathname,r=_e(s),n=e=>`app/${e}`,o="bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground",l=t=>{const s=e.jsxs(ks,{tooltip:t.title,className:"cursor-pointer "+(ne(r,t.url||"")?o:""),children:[t.icon&&e.jsx(t.icon,{}),e.jsx("span",{children:t.title}),t.items&&e.jsx(i.ChevronRight,{className:"ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90"})]});return t.url?e.jsx(a.NavLink,{to:n(t.url),className:"w-full",children:s}):s};return e.jsx(e.Fragment,{children:t.map(t=>e.jsxs(ys,{children:[e.jsx(Ns,{children:t.title}),e.jsx(ws,{children:t.items.map(t=>{const s=t.items&&t.items.some(e=>ne(r,e.url));return e.jsx(ls,{asChild:!0,defaultOpen:s,className:"group/collapsible",children:e.jsxs(_s,{children:[e.jsx(ds,{isCollapsible:!!t.items,asChild:!0,children:l(t)}),e.jsx(cs,{children:e.jsx(Ss,{children:t.items?.map(t=>e.jsx(Ps,{children:e.jsx(zs,{asChild:!0,className:ne(r,t.url)?o:"",children:e.jsx(a.NavLink,{to:n(t.url),title:t.title,children:e.jsx("span",{children:t.title})})})},t.title))})})]})},t.title)})})]},t.title))})}function Is({className:t,...a}){return e.jsx(Y.Root,{"data-slot":"avatar",className:ee("relative flex size-8 shrink-0 overflow-hidden rounded-full",t),...a})}function Fs({className:t,...a}){return e.jsx(Y.Image,{"data-slot":"avatar-image",className:ee("aspect-square size-full",t),...a})}function Os({className:t,...a}){return e.jsx(Y.Fallback,{"data-slot":"avatar-fallback",className:ee("bg-muted flex size-full items-center justify-center rounded-full",t),...a})}const Ds=({isDialogOpen:t,setIsDialogOpen:a})=>{const{loggedInUser:r,setLoggedInUser:n}=s.useContext(Pe),[i,o]=s.useState(!1),[l,d]=s.useState(!1),[c,u]=s.useState(null),[m,x]=s.useState({});s.useEffect(()=>{t&&p()},[t]);const p=async()=>{o(!0);try{const e={user_id:r.id,user_email:r.email,user_mobile_no:r.mobNo?.toString()||"",user_fname:r.fname||"",user_lname:r.lname||"",user_is_active:!0,created_at:(new Date).toISOString(),updated_at:(new Date).toISOString()};u(e),x(e)}catch(e){console.error("Error fetching user data:",e)}finally{o(!1)}},h=(e,t)=>{x(a=>({...a,[e]:t}))};return e.jsx(jt,{open:t,setIsOpen:a,header:"Edit User Profile",disableOutsideClick:!0,actionsJSX:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(vt,{variant:"outline",onClick:()=>{x(c||{}),a(!1)},disabled:l,children:"Cancel"}),e.jsx(vt,{onClick:async()=>{d(!0);try{const e={user_mobile_no:m.user_mobile_no,user_fname:m.user_fname,user_lname:m.user_lname};await Ae().put(`/user-profile/${m.user_id}`,e),Ie({header:"Success",description:"User profile updated successfully"}),u(m),n({...r,mobNo:m.user_mobile_no,fname:m.user_fname,lname:m.user_lname}),a(!1)}catch(e){console.error("Error saving user data:",e)}finally{d(!1)}},loading:l,children:"Save Changes"})]}),children:i?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(ze,{}),"Loading user data..."]})}):e.jsxs("div",{className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Lt,{htmlFor:"user_id",children:"User ID"}),e.jsx(Et,{id:"user_id",value:m.user_id?ge(m.user_id):"",disabled:!0,className:"bg-muted"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Lt,{htmlFor:"user_email",children:"Email"}),e.jsx(Et,{id:"user_email",type:"email",value:m.user_email||"",placeholder:"Enter email address",disabled:!0,className:"bg-muted"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Lt,{htmlFor:"user_mobile_no",children:"Mobile Number"}),e.jsx(Et,{id:"user_mobile_no",type:"number",value:m.user_mobile_no||"",onChange:e=>h("user_mobile_no",e.target.value),placeholder:"Enter mobile number"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Lt,{htmlFor:"user_fname",children:"First Name"}),e.jsx(Et,{id:"user_fname",value:m.user_fname||"",onChange:e=>h("user_fname",e.target.value),placeholder:"Enter first name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Lt,{htmlFor:"user_lname",children:"Last Name"}),e.jsx(Et,{id:"user_lname",value:m.user_lname||"",onChange:e=>h("user_lname",e.target.value),placeholder:"Enter last name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Lt,{htmlFor:"created_at",children:"Joined On"}),e.jsx(Et,{id:"created_at",value:m.created_at?new Date(m.created_at).toLocaleString():"",disabled:!0,className:"bg-muted"})]})]})})};function As({fname:t,lname:r,email:n,avatar:o}){const l=a.useNavigate(),{isMobile:d}=ms(),{activePlan:c,featureFlags:u}=s.useContext(Pe),m=`${t} ${r}`,[x,p]=s.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(Ds,{isDialogOpen:x,setIsDialogOpen:p}),e.jsx(ws,{children:e.jsx(_s,{children:e.jsxs(ia,{children:[e.jsx(oa,{asChild:!0,children:e.jsxs(ks,{size:"lg",className:"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",children:[e.jsxs(Is,{className:"h-8 w-8 rounded-lg",children:[e.jsx(Fs,{src:o,alt:m}),e.jsxs(Os,{className:"rounded-lg",children:[t[0].toLocaleUpperCase(),r[0].toLocaleUpperCase()]})]}),e.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[e.jsx("span",{className:"truncate font-medium",children:m}),e.jsx("span",{className:"truncate text-xs",children:n})]}),e.jsx(i.ChevronsUpDown,{className:"ml-auto size-4"})]})}),e.jsxs(la,{className:"w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg",side:d?"bottom":"right",align:"end",sideOffset:4,children:[e.jsx(ma,{className:"p-0 font-normal",children:e.jsxs("div",{className:"flex items-center gap-2 px-1 py-1.5 text-left text-sm",children:[e.jsxs(Is,{className:"h-8 w-8 rounded-lg",children:[e.jsx(Fs,{src:o,alt:m}),e.jsxs(Os,{className:"rounded-lg",children:[t[0].toLocaleUpperCase(),r[0].toLocaleUpperCase()]})]}),e.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[e.jsx("span",{className:"truncate font-medium",children:m}),e.jsx("span",{className:"truncate text-xs",children:n})]})]})}),e.jsx(xa,{}),e.jsxs(ca,{onClick:()=>p(!0),children:[e.jsx(i.CircleUserRound,{}),"Your Profile"]}),u.ff_enable_paid_subscription?e.jsxs(e.Fragment,{children:[e.jsx(xa,{}),e.jsx(da,{children:e.jsxs(ca,{onClick:()=>{setTimeout(()=>{l("/plans")},d?500:0)},children:[e.jsx(i.Sparkle,{}),Me(c)?"Upgrade to premium":"View Plans"]})}),e.jsx(xa,{}),e.jsxs(da,{children:[e.jsxs(ca,{onClick:()=>{setTimeout(()=>{l("/infrastructure/manage-subscription")},d?500:0)},children:[e.jsx(i.BadgeCheck,{}),"Subscriptions"]}),e.jsxs(ca,{onClick:()=>{setTimeout(()=>{l("/infrastructure/payment-history")},d?500:0)},children:[e.jsx(i.CreditCard,{}),"Payment History"]})]})]}):null,e.jsx(xa,{}),e.jsxs(ca,{onClick:()=>{se("apiKey",""),l("/login")},children:[e.jsx(i.LogOut,{}),"Log out"]})]})]})})})]})}const Es=({purchasedPlan:t})=>{const{subscriptionConfig:a,featureFlags:r}=s.useContext(Pe);if(!r.ff_enable_paid_subscription)return null;const n=a.plans.find(e=>e.id===t.plan_id);if(!n)return null;const i=Me(t);return e.jsx(Xa,{delayDuration:20,content:e.jsxs(e.Fragment,{children:["This ",Z.account_type_txt.singular.toLocaleLowerCase(),' is on a "',n.title,'" plan.']}),side:"right",children:e.jsx("div",{children:e.jsx(ra,{variant:"success",children:i?"Free":"Premium"})})})};function Ls(){const{isMobile:t,setOpenMobile:r}=ms(),{orgs:n,activeOrg:o,setActiveOrg:l}=s.useContext(Pe),d=a.useNavigate();return e.jsx(ws,{children:e.jsx(_s,{children:e.jsxs(ia,{children:[e.jsx(oa,{asChild:!0,children:e.jsxs(ks,{size:"lg",className:"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",children:[e.jsx("div",{className:"flex aspect-square size-8 items-center justify-center rounded-lg",children:o?.logo?e.jsx(o.logo,{className:"size-4"}):e.jsx(i.Users2,{className:"size-4"})}),o?e.jsx(Xa,{content:o.org_name+" - "+o.org_external_id,side:"right",canShowTooltip:!0,children:e.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[e.jsx("span",{className:"truncate font-medium",children:o.org_name}),e.jsx("span",{className:"truncate text-xs",children:o.org_external_id})]})}):e.jsxs("div",{className:"truncate text-xs",children:["No Active ",Z.account_type_txt.singular,", select one."]}),o?.active_purchased_plan&&e.jsx("div",{className:"flex items-center justify-center rounded-md border",children:e.jsx(Es,{purchasedPlan:o.active_purchased_plan})}),e.jsx(i.ChevronsUpDown,{className:"ml-auto"})]})}),e.jsxs(la,{className:"w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg",align:"start",side:t?"bottom":"right",sideOffset:4,children:[e.jsx(ma,{className:"text-muted-foreground text-xs",children:Z.account_type_txt.plural}),n.map(t=>e.jsxs(ca,{onClick:()=>l(t),className:"gap-2 p-2",children:[t.logo?e.jsx("div",{className:"flex size-6 items-center justify-center rounded-md border",children:e.jsx(t.logo,{className:"size-3.5 shrink-0"})}):e.jsx(e.Fragment,{}),t.org_name,t.active_purchased_plan&&e.jsx("div",{className:"ml-auto flex items-center justify-center rounded-md border",children:e.jsx(Es,{purchasedPlan:t.active_purchased_plan})})]},t.org_id)),e.jsx(xa,{}),(()=>{const a=[];if(o&&we(o?.org_id||0)){const t=wt.Is_ADMIN(o?.role_id||NaN);a.push({text:e.jsx(e.Fragment,{children:"Invite team members"}),link:`/infrastructure/edit-org/${ge(o?.org_id||0)}`,disabled:!t,icon:e.jsx(i.UserRoundPlus,{className:"size-4"}),tooltip:t?`Invite peoples to "${o.org_name}" ${Z.account_type_txt.singular.toLocaleLowerCase()}`:`You are not an admin for "${o.org_name}" ${Z.account_type_txt.singular.toLocaleLowerCase()}, Only admins can invite peoples.`,key:"invite-peoples"},{text:e.jsxs(e.Fragment,{children:["Edit ",Z.account_type_txt.singular.toLocaleLowerCase()]}),link:`/infrastructure/edit-org/${ge(o?.org_id||0)}`,disabled:!t,icon:e.jsx(i.Pen,{className:"size-4"}),tooltip:t?`Edit "${o.org_name}" ${Z.account_type_txt.singular.toLocaleLowerCase()} details`:`You are not an admin for "${o.org_name}" ${Z.account_type_txt.singular.toLocaleLowerCase()}, Only admins can invite peoples.`,key:"edit-org"})}return a.push({addTopSeparator:!0,text:e.jsxs(e.Fragment,{children:["Create new ",Z.account_type_txt.singular.toLocaleLowerCase()]}),link:"/infrastructure/create-new-org",icon:e.jsx(i.Plus,{className:"size-4"}),key:"create-new-org"},{text:e.jsxs(e.Fragment,{children:["View all ",Z.account_type_txt.plural.toLocaleLowerCase()]}),link:"/infrastructure/manage-infra",icon:e.jsx(i.FolderKanban,{className:"size-4"}),key:"view-all-orgs"},{addTopSeparator:!0,text:e.jsx(e.Fragment,{children:"Check invites"}),link:"infrastructure/user-invitations",icon:e.jsx(i.UserRoundPlus,{className:"size-4"}),key:"check-invitations"}),e.jsx(e.Fragment,{children:a.map(a=>e.jsx(Xa,{content:e.jsx(e.Fragment,{children:a.tooltip}),side:"right",canShowTooltip:!!a.tooltip,children:e.jsxs("div",{children:[a.addTopSeparator?e.jsx(xa,{}):null,e.jsxs(ca,{className:"gap-2 p-2 cursor-pointer",onClick:()=>{r(!1),setTimeout(()=>{a.disabled?Fe({header:"Action not allowed!",description:a.tooltip||"You cannot access this option"}):d(a.link)},t?500:0)},children:[e.jsx("div",{className:"flex size-6 items-center justify-center rounded-md border bg-transparent",title:a.tooltip,children:a.icon}),e.jsx("div",{className:"text-muted-foreground font-medium",children:a.text})]},a.link)]},a.key)},a.key))})})()]})]})})})}function Rs(){return e.jsx(ws,{children:e.jsx(a.NavLink,{to:"/",children:e.jsx(_s,{children:e.jsxs(ks,{size:"lg",className:"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",children:[e.jsx("div",{className:"w-10 h-10 bg-sidebar-primary text-sidebar-primary-foreground rounded-lg flex items-center justify-center",children:e.jsx(Z.logo,{})}),e.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[e.jsx("span",{className:"truncate font-medium",children:Z.appName}),e.jsxs("span",{className:"truncate text-xs",children:["v",Z.version]})]})]})})})})}const Ms=X;function $s({...t}){const{loggedInUser:a,featureFlags:s}=E.useContext(Pe);return e.jsxs(ps,{collapsible:"icon",...t,children:[e.jsxs(bs,{children:[e.jsx(Rs,{}),s.ff_enable_teams&&e.jsx(Ls,{})]}),e.jsx(js,{children:e.jsx(Ts,{navItems:Ms.navMain})}),e.jsx(vs,{children:e.jsx(As,{email:a?.email||"",fname:a?.fname||"",lname:a?.lname||"",avatar:"/avatars/shadcn.jpg"})}),e.jsx(gs,{})]})}function Us({...t}){return e.jsx("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",...t})}function Bs({className:t,...a}){return e.jsx("ol",{"data-slot":"breadcrumb-list",className:ee("text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm break-words sm:gap-2.5",t),...a})}function qs({className:t,...a}){return e.jsx("li",{"data-slot":"breadcrumb-item",className:ee("inline-flex items-center gap-1.5",t),...a})}function Vs({asChild:t,className:a,...s}){const r=t?_.Slot:"a";return e.jsx(r,{"data-slot":"breadcrumb-link",className:ee("hover:text-foreground transition-colors",a),...s})}function Hs({className:t,...a}){return e.jsx("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:ee("text-foreground font-normal",t),...a})}function Ys({children:t,className:a,...s}){return e.jsx("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:ee("[&>svg]:size-3.5",a),...s,children:t??e.jsx(i.ChevronRight,{})})}const Ws=()=>{const t=(()=>{const e=a.useLocation().pathname;if(!e||"/"===e)return{title:"Dashboard"};const t=_e(e),s=ie(t);return s||{title:"Not Found",url:"notFound"}})(),r=(t,a)=>{let n=[];return n.push(e.jsxs(s.Fragment,{children:[e.jsx(qs,{children:a?e.jsx(Hs,{children:t.title}):e.jsx(Vs,{children:t.title})}),!a&&e.jsx(Ys,{})]},t.title)),t.parent&&(n=[r(t.parent,!1),...n].flat()),n};return e.jsx(Us,{children:e.jsx(Bs,{children:r(t,!0)})})},Ks=()=>{const t=a.useNavigate(),r=yt(),{activeOrg:n,loggedInUser:i}=s.useContext(Pe);return{editOrganization:a=>{wt.Is_ADMIN(a.role_id)?t("/infrastructure/edit-org/"+ge(a.org_id)):Oe({header:"Alert",description:e.jsxs(e.Fragment,{children:["You are not allowed to edit the ",e.jsx("b",{children:a.org_name})," ",Z.account_type_txt.singular.toLocaleLowerCase(),"."]})})},handleOnDeleteUnregisteredUser:(e,t)=>{const{id:a,email:s}=e;return new Promise((e,n)=>{r.showAlertBox({type:"CONFIRM",text:`Are you sure you want to remove "${s}" user from your ${Z.account_type_txt.singular}?`,async onClose(r){if("CONFIRM"!==r)return void n();const i={invited_users_id:a,org_id:t};try{const t=await Ae().delete("/org-member/unregistered-user-invitation",{data:i});Ie({description:`${s} has been successfully removed from the team.`}),e(t)}catch(e){n(e)}}})})},isActiveOrgCreatedByMe:()=>Number(n?.org_created_by)===Number(i.id)}},Gs=()=>{const{featureFlags:t}=s.useContext(Pe),{isMobile:r,setOpenMobile:n}=ms(),i=a.useNavigate(),{isActiveOrgFreePlan:o,isUserFreePlan:l}=Be(),{isActiveOrgCreatedByMe:d}=Ks();if(!1===t.ff_enable_paid_subscription)return null;const c=()=>{r&&n(!1),i("/plans")};return l()&&(!t.ff_enable_teams||o()&&d())?e.jsx("button",{onClick:c,children:e.jsx(Ka,{children:"Upgrade to premium"})}):null};var Xs=Object.freeze({__proto__:null,default:function(){const t=ya();return e.jsxs(xs,{children:[e.jsx($s,{}),e.jsxs(fs,{className:"h-screen",children:[e.jsxs("header",{className:"flex py-4 shrink-0 items-center gap-2 transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-12 bg-background",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4",children:[e.jsx(hs,{className:"-ml-1"}),e.jsx(na,{orientation:"vertical",className:"mr-2 data-[orientation=vertical]:h-4"}),e.jsx(Ws,{})]}),e.jsx("div",{className:"flex-1"}),e.jsx("div",{className:"flex items-center gap-2 px-4",children:t?e.jsx(e.Fragment,{}):e.jsx(Gs,{})})]}),e.jsx("div",{className:"flex items-stretch flex-col flex-1 overflow-auto",children:e.jsx(a.Outlet,{})})]})]})}});var Js=Object.freeze({__proto__:null,default:({canShowHeader:t=!0})=>e.jsxs("div",{className:"flex flex-col stretch justify-center gap-4 items-center flex-1 p-5",children:[t&&e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-3xl font-bold text-primary p-0",children:Z.appName}),e.jsx("p",{className:"text-sm",children:Z.appDescription})]}),e.jsxs("div",{className:"flex flex-col justify-center",children:[e.jsx("div",{className:"text-muted-foreground mb-4 text-sm",children:"404 Page Not Found"}),e.jsx(a.NavLink,{to:"/",className:"p-2 bg-primary text-primary-foreground rounded-md transition-colors text-sm",children:"Go to Homepage"})]})]})});const Qs=({ref:t,gridCls:r,onChangeEmailClick:n,email:i})=>{const[o,l]=s.useState(""),[d,c]=s.useTransition(),u=a.useNavigate(),m=s.useRef(null);return s.useImperativeHandle(t,()=>({focus(){m.current?.focus()}}),[]),e.jsxs("form",{onSubmit:async e=>{if(e.preventDefault(),!o)return Fe({header:"OTP Required!",description:"Please enter your OTP and try again."}),void m.current?.focus();const t=te(e.currentTarget);t.otp=o,t.user_email=i;const a=de(t.password);!1!==a.valid?t.password===t.user_password?c(async()=>{try{delete t.password,await Ae().put("/reset-password",t),Ie({header:"Your password has been reset successfully!",description:"Please log in using your new password."}),u("/login")}catch(e){ce(e)}}):Fe({header:"Password and Confirm Password fields contain different passwords.",description:""}):Fe({header:"Password Policy",description:a.message})},className:"grid gap-6",children:[e.jsxs("div",{className:r,children:[e.jsx(Lt,{htmlFor:"emailOTPGenerated",children:"Email *"}),e.jsx(Et,{id:"emailOTPGenerated",type:"email",name:"user_email",placeholder:"mail@example.com",value:i,disabled:!0,required:!0}),e.jsx("span",{className:"ml-auto text-xs underline-offset-4 hover:underline cursor-pointer italic",onClick:()=>n(),children:"Change Email"})]}),e.jsx(is,{className:r,inputOTPField:m,otp:o,setOtp:l,onChangeEmailClick:n}),e.jsxs("div",{className:r,children:[e.jsxs(Lt,{htmlFor:"password",children:["New Password * ",e.jsx(ts,{})]}),e.jsx(Et,{id:"password",type:"password",name:"password",placeholder:"**********",required:!0})]}),e.jsxs("div",{className:r,children:[e.jsx(Lt,{htmlFor:"cnf-password",children:"Confirm Password *"}),e.jsx(Et,{id:"cnf-password",type:"password",name:"user_password",placeholder:"**********",required:!0})]}),e.jsx(vt,{type:"submit",className:"w-full",size:"lg",loading:d,children:"Reset Password"})]})};var Zs=Object.freeze({__proto__:null,default:function(){const t=s.useRef(null),r=s.useRef(null),[n,i]=s.useState(!1),[o,l]=s.useState(""),d="grid gap-1";return s.useEffect(()=>{n?r.current?.focus():t?.current?.focus()},[n]),e.jsxs("div",{className:"grid gap-6",children:[e.jsx("div",{className:"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t",children:e.jsx("span",{className:"bg-card text-muted-foreground relative z-10 px-2",children:"Forgot Password"})}),e.jsx(as,{ref:t,handleOnOTPSent:e=>{i(!0),l(e.email)},gridCls:d,hidden:n,path:"forgot-password"}),n&&e.jsx(Qs,{ref:r,gridCls:d,onChangeEmailClick:()=>i(!1),email:o}),e.jsxs("div",{className:"text-center text-sm",children:["Already have an account?"," ",e.jsx(a.NavLink,{to:"/login",children:e.jsx("span",{className:"underline underline-offset-4",children:"Login"})})]})]})}});var er=Object.freeze({__proto__:null,default:()=>{const{orgs:t}=s.useContext(Pe);return e.jsxs("div",{className:"mt-5",children:[e.jsxs("div",{className:"flex flex-row justify-center gap-6",children:[e.jsxs(Va,{toPath:"create-new-org",className:"text-center",children:["Create new ",Z.account_type_txt.singular.toLocaleLowerCase()]}),e.jsx(Va,{toPath:"user-invitations",className:"text-center",children:"Accept/Reject Invitations"})]}),e.jsx("div",{className:"flex flex-row justify-center gap-6 mt-5",children:e.jsxs(Va,{toPath:"manage-infra",className:"text-center",disabled:t.length<=0,children:["Manage ",Z.account_type_txt.plural.toLocaleLowerCase()]})})]})}});const tr=({value:t,setValue:a,id:s})=>e.jsx(Ga,{valueField:"id",labelField:"text",placeholder:"Specify Role",items:wt.GET_LIST(),value:t,onValueChange:e=>{a(e)},triggerClassName:"w-[180px]",id:s}),ar=(e,t)=>-1===t||e?.user_opinion===ye.NOT_SAVED,sr=({teamMembers:t,setTeamMembers:a,inactiveUsers:r})=>{const[n,o]=s.useState(),[l,d]=s.useState(NaN),c=yt(),[u,m]=s.useState(),[x,p]=s.useState(!1),[h,g]=s.useState({email:"",role_id:wt.READ,user_opinion:ye.INVITED,id:""}),{loggedInUser:f}=s.useContext(Pe),b=e=>{const s={},r=[...t??[],...e];r.forEach(e=>{const t=e.email;s[t]=s[t]?s[t]++:1});const n=r.filter(e=>(s[e.email]--,0===s[e.email]));return a(n),r.length===n.length},v=e=>e&&e.email&&!1!==ue(e.email)?!!wt.IS_VALID_ROLE_ID(e.role_id)||(Fe({description:"Invalid role selected. Please select a valid role and try again."}),!1):(Fe({description:"Invalid email, please enter correct email and try again."}),!1);return s.useEffect(()=>{if(!u)return void g({email:"",role_id:NaN,user_opinion:ye.INVITED,id:""});if(-1===u)return;const e=t?.find(e=>e.id===u);e?g({email:e.email,role_id:e.role_id,user_opinion:e.user_opinion,id:e.id||e.email}):Fe({description:"Something went wrong, please reload and try again."})},[u]),e.jsxs(ja,{layout:"vertical",className:"gap-2",children:[x&&e.jsxs(jt,{open:!0,setIsOpen:p,header:"Bulk Add Users",actionsJSX:e.jsx(vt,{onClick:()=>{const{validEmails:e}=n||{};if(!e?.length||e?.length<=0)return Oe({description:"Please add comma separated emails, then press Continue button"});const t=e.map(e=>({email:e,role_id:l,id:e,user_opinion:ye.INVITED}));b(t),o(void 0),p(!1),Ie({description:`${e?.length} emails has been added.`})},children:"Add users"}),children:[e.jsxs(ja,{layout:"horizontal",className:"gap-2",children:[e.jsx(pa,{id:"includeUsers",placeholder:"Enter comma separated emailIds like mail1@temp.com, mail2@temp.com",className:"w-full min-h-[80px] max-h-[500px] mr-1",onChange:e=>o(me(e.target.value))}),e.jsx("span",{children:e.jsx(Ya,{side:"right",children:"Enter comma separated emailIds like mail1@temp.com, mail2@temp.com"})})]}),e.jsxs("span",{className:"mb-5",children:[e.jsxs("span",{className:"text-success",children:["Valid Emails: ",n?.validEmails.length||0]}),","," ",e.jsxs("span",{className:"text-failure",children:["Invalid Emails: ",n?.invalidEmails.length||0]})]}),e.jsxs("div",{className:"flex flex-row gap-2",children:[e.jsx(Lt,{htmlFor:"roles",children:"Role *"}),e.jsx(tr,{id:"bulk-roles",value:l?.toString()||"",setValue:e=>{d(Number(e))}})]})]}),u&&e.jsx(jt,{open:!0,setIsOpen:e=>{m(!1===e?void 0:u)},header:-1===u?"Add User":"Edit User",actionsJSX:e.jsx(vt,{type:"button",onClick:-1===u?()=>{if(!v(h))return;b([{...h,id:h.email,user_opinion:ye.NOT_SAVED}])?m(void 0):Fe({description:`This email is already exists in list: ${h.email}`})}:()=>{if(!v(h))return;const e=t?.find(e=>e.email===h.email&&e.id!==u);if(e)return void Oe({description:`This email is already exists in list: ${h.email}`});const s=[...t||[]],r=s.find(e=>e.id===u);r?(r.email=h.email,r.role_id=h.role_id,a(s),m(void 0)):Fe({description:"Record not found to update, something went wrong!"})},children:"Update"}),children:e.jsxs("div",{className:"flex flex-col p-5 gap-5",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Lt,{htmlFor:"email",children:"Email *"}),e.jsx(Et,{id:"email",type:"email",placeholder:"mail@example.com",value:h.email,disabled:!1===ar(h,u),onChange:e=>g(t=>({...t,email:e.target.value}))})]}),e.jsxs("div",{className:"flex flex-col gap-2 ",children:[e.jsx(Lt,{htmlFor:"roles",children:"Role *"}),e.jsx(tr,{id:"roles",value:h.role_id?.toString()||"",setValue:e=>{g(t=>({...t,role_id:Number(e)}))}})]})]})}),e.jsx(Oa,{canShowToolbar:!0,canShowPagination:!1,data:t||[],toolbarConfig:{canShowSearchField:!1,canShowColumnsBtn:!1,additionalJSX:[e.jsxs(vt,{variant:"secondary",type:"button",onClick:()=>{m(-1)},children:[e.jsx(i.Plus,{})," Add User"]}),e.jsxs(vt,{variant:"outline",type:"button",onClick:()=>{p(!0)},children:[e.jsx(i.Files,{})," Bulk Add"]})]},columns:[{id:"email",headerText:"Email",enableSorting:!1,enableHiding:!1,editable:!0},{id:"role_id",headerText:"Role",enableSorting:!1,enableHiding:!1,editable:!0,type:"string",renderer:(e,t)=>wt.DISPLAY_TEXT(t)},{id:"user_opinion",headerText:"Status",enableSorting:!1,enableHiding:!1,type:"boolean",editable:!1,renderer(e){const{user_opinion:t}=e.original;return ye.getDisplay(t)}},{id:"joinedOn",headerText:"Joined On",enableSorting:!1,enableHiding:!1,type:"date",editable:!0},{id:"actions",headerText:"Actions",enableSorting:!1,enableHiding:!1,renderer(s){const{id:r}=s?.original;return e.jsxs(e.Fragment,{children:[e.jsx(vt,{variant:"ghost",onClick:()=>{const e=t?.find(e=>e.id===r),a=e?.fname||e?.lname?`${e?.fname} ${e?.lname}`:e?.email;e?.email!==f?.email?(!1===ar(e,void 0)&&Oe({header:`Not allowed to edit email "${a}", however you can update its administrative privileges.`,description:"The invitation has been already sent. If you do not want this user as a team member, you can delete them and correct one."}),m(r)):Oe({header:`Not allowed to edit "${a}"`,description:`If you want to leave this ${Z.account_type_txt.singular.toLocaleLowerCase()}, go to "Manage ${Z.account_type_txt.singular}," open the actions menu (three dots), and click "Leave ${Z.account_type_txt.singular}."`})},type:"button",children:e.jsx(i.Pencil,{})}),e.jsx(vt,{variant:"ghost",onClick:()=>{const e=t?.find(e=>e.id===r),s=e?.fname||e?.lname?`${e?.fname} ${e?.lname}`:e?.email;e?.email!==f?.email?c.showAlertBox({type:"CONFIRM",text:`Are you sure you want to remove "${s}" user?`,async onClose(e){"CONFIRM"===e&&a(t?.filter(e=>e.id!==r))}}):Oe({header:`Not allowed to remove "${s}"`,description:`If you want to leave this ${Z.account_type_txt.singular}, go to "Manage ${Z.account_type_txt.singular}," open the actions menu (three dots), and click "Leave ${Z.account_type_txt.singular}."`})},type:"button",children:e.jsx(i.Trash,{})})]})}}]}),r.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ea,{className:"mt-5 leading-normal font-semibold",children:"Following users are inactive/deleted."}),e.jsx("ol",{children:r.map((t,a)=>e.jsxs("li",{children:[a+1,". ",t.email," ",wt.DISPLAY_TEXT(t.role_id)]},t.email))})]})]})};var rr=Object.freeze({__proto__:null,default:()=>{const t=a.useNavigate(),{orgId:r=""}=a.useParams(),[n,l]=s.useState(()=>r?fe(parseInt(r,10)):-1),[d,c]=s.useState(!1),[u,m]=s.useState([]),[x,p]=s.useState([]),[h,g]=s.useState([]),[f,b]=s.useState(!1),v=s.useRef([]),[j,y]=s.useState(),{orgs:N,setOrgs:w,loggedInUser:_}=s.useContext(Pe),C=n>-1?N.find(e=>e.org_id===n):null,k=n>-1||C,{handleOnDeleteUnregisteredUser:S}=Ks();s.useEffect(()=>{if(!k)return;const e=e=>e.map(e=>({id:e.user_id,email:e.user_email,role_id:e.role_id,user_opinion:e.user_opinion,fname:e.user_fname,lname:e.user_lname,joinedOn:e.joined_on}));(async()=>{b("Fetching Team Members");try{const t=await Ae().get(`org-member/${n}`),a=t.orgMembers.filter(e=>je(e.is_active)),s=e(a),r=t.unregisteredUsers.map(e=>({role_id:e.role_id,email:e.email,id:e.invited_users_id})),i=t.orgMembers.filter(e=>!je(e.is_active));m(s),c(!0),p(r),g(e(i)),v.current=structuredClone(s)}finally{b(!1)}})()},[k,n]);const P=k?C?.org_name:`${_?.fname}'s ${Z.account_type_txt.singular} ${N.length>=1?N.length+1:""}`;return e.jsx(ja,{className:"pb-5 sm:px-0 px-5 pt-5",children:e.jsxs(ja,{layout:"horizontal",children:[e.jsx("span",{className:"md:flex-1 flex-none"}),e.jsxs(ja,{className:"flex-4 max-w-4xl pr-5 sm:pl-0 pl-2 overflow-visible",children:[e.jsx(Aa,{className:"text-center pl-5 gap-1",children:e.jsxs("span",{className:"inline-flex items-center gap-2",children:[k?`Editing "${C?.org_name}" ${Z.account_type_txt.singular}`:`Create new ${Z.account_type_txt.singular}`,k&&C?.active_purchased_plan?e.jsx(Es,{purchasedPlan:C?.active_purchased_plan}):null]})}),e.jsx("form",{onSubmit:async e=>{e.preventDefault(),b("Saving...");try{let a=C?.org_id;const s=te(e.currentTarget);if(k)await(e=>{const t={},a=C;if(e.org_name!==a?.org_name&&e.org_name&&(t.org_name=e.org_name),e.org_address!==a?.org_address&&e.org_address&&(t.org_address=e.org_address),e.org_state!==a?.org_state&&e.org_state&&(t.org_state=e.org_state),e.org_country!==a?.org_country&&e.org_country&&(t.org_country=e.org_country),e.org_external_id!==a?.org_external_id&&e.org_external_id&&(t.org_external_id=e.org_external_id),!Ne(t))return Ae().put(`/organization/${C?.org_id}`,t)})(s);else{const e=await(async e=>{const t={org_name:e.org_name,org_address:e.org_address,org_state:e.org_state,org_country:e.org_country,org_external_id:e.org_external_id};return Ae().post("/organization",t)})(s);a=parseInt(e.insertedOrgId,10),!1===we(a)&&(Fe({description:`No response received from the ${Z.account_type_txt.singular.toLocaleLowerCase()} service. Returning to the Manage ${Z.account_type_txt.singular} page.`}),setTimeout(()=>{t("/infrastructure/manage-infra")},1e3))}const r=e=>{Ie({description:`${Z.account_type_txt.singular} has been ${k?"updated":"created"} successfully.${e?" Team members have also been updated successfully and sent invitation emails.":""}`}),t("/infrastructure/manage-infra")};if(!d)return r(!1);try{const e=v.current,t=e.filter(e=>!u.find(t=>e.email===t.email));if(t&&t.length>0){const e={org_id:a,users:t.map(e=>({user_id:e.id}))};await Ae().delete("/org-member",{data:e})}const s=u.filter(t=>{const a=e.find(e=>t.id===e.id);return!!a&&a.role_id!==t.role_id});if(s&&s.length>0){const e={org_id:a,users:s.map(e=>({user_id:e.id,role_id:e.role_id}))};await Ae().put("/org-member",e)}const n=u.filter(t=>!e.find(e=>e.email===t.email));if(n&&n.length>0){const e={org_id:a,included_users:n.map(e=>({email:e.email,role_id:e.role_id}))};await Ae().post("/org-member/by-emails",e)}r(!0)}finally{l(a||-1)}}finally{b(!1);const e=await Ae().get("organization");w(e?.orgs||[])}},children:e.jsx(Da,{className:"w-full pr-1 mt-2 text-sm",leftCls:"w-32 sm:w-36 md:w-40 w-full sm:w-40 text-left sm:text-right pr-0 sm:pr-2 pt-3 sm:pt-7",rightCls:"pt-1 sm:pt-5",rowCls:"flex-col sm:flex-row",child:[e.jsxs(o.Label,{htmlFor:"orgName",className:"font-medium",children:[Z.account_type_txt.singular," Name * :"]}),e.jsx(Et,{id:"orgName",name:"org_name",type:"text",required:!0,className:"w-full",defaultValue:C?.org_name??P,autoFocus:!0}),...Z.account_type_txt.value===Q.ORG?[e.jsx(o.Label,{htmlFor:"address",className:"font-medium",children:"Address * :"}),e.jsx(Et,{id:"address",name:"org_address",type:"text",required:!0,className:"w-full",defaultValue:C?.org_address??""}),e.jsx(o.Label,{htmlFor:"state",className:"font-medium",children:"State * :"}),e.jsx(Et,{id:"state",name:"org_state",type:"text",required:!0,className:"w-full",defaultValue:C?.org_state??""}),e.jsx(o.Label,{htmlFor:"country",className:"font-medium",children:"Country * :"}),e.jsx(Et,{id:"country",name:"org_country",type:"text",required:!0,className:"w-full",defaultValue:C?.org_country??""})]:[],e.jsx(o.Label,{htmlFor:"org_external_id",className:"font-medium",children:"External Id (optional) :"}),e.jsx(Et,{id:"org_external_id",name:"org_external_id",type:"text",className:"w-full",defaultValue:C?.org_external_id??""}),e.jsx(e.Fragment,{}),e.jsxs(ja,{layout:"horizontal",children:[e.jsx(Et,{id:"doIncludeUsers",type:"checkbox",className:"w-4",checked:d,onChange:e=>c(e.target.checked)}),e.jsxs(o.Label,{htmlFor:"doIncludeUsers",className:"font-medium mt-2 ml-1",children:["Would you like to invite your team members in this ",Z.account_type_txt.singular,"?"]})]}),...d?[e.jsx(o.Label,{htmlFor:"includeUsers",className:"font-medium",children:"Team Members:"}),e.jsx(sr,{teamMembers:u,setTeamMembers:m,inactiveUsers:h})]:[],e.jsx(e.Fragment,{}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(vt,{type:"submit",className:"flex-1 sm:flex-none",loading:!!f,children:f||"Save"}),e.jsx(vt,{type:"button",variant:"outline",className:"flex-1 sm:flex-none",onClick:()=>t(-1),children:"Cancel"})]}),e.jsx(e.Fragment,{}),e.jsx(e.Fragment,{}),e.jsx(e.Fragment,{}),e.jsx(e.Fragment,{children:x.length>0&&e.jsx(na,{})}),e.jsx(e.Fragment,{children:x.length>0&&"Unregistered Users:"}),e.jsx(e.Fragment,{children:x.length>0&&e.jsxs(ja,{loading:j,children:[e.jsxs(Ea,{className:"mt-2 leading-normal font-semibold",children:["Following users are unregistered. We have sent them invitation emails; once they accept, they will be part of this"," ",Z.account_type_txt.singular.toLocaleLowerCase(),"."]}),e.jsx("ol",{children:x.map((t,a)=>e.jsx("li",{className:"mt-1",children:e.jsxs("span",{className:"inline-flex group",children:[e.jsxs("span",{children:[a+1,". ",t.email,", (role:  ",wt.DISPLAY_TEXT(t.role_id),")"]}),e.jsx("span",{title:"Delete",children:e.jsx(i.Trash,{size:"15px",className:"opacity-40 group-hover:opacity-60 hover:opacity-100 ml-1 mt-0.5 cursor-pointer",onClick:async()=>{try{y(!0),await S(t,n);const e=[...x];e.splice(a,1),p(e)}finally{y(!1)}}})})]})},t.email))})]})})]})})]}),e.jsx("span",{className:"md:flex-1 flex-none"})]})})}});var nr=Object.freeze({__proto__:null,default:()=>{const{loading:t,response:a}=Qa("/invitation"),r=yt(),n=a?.invites.filter(e=>e.user_opinion!==ye.ACCEPTED),[o,l]=s.useState(-1),{setOrgs:d}=s.useContext(Pe),c=async(e,t)=>{if(t)try{const a=parseInt(t.org_id,10);l(a);const s={org_id:a,user_opinion:e};await Ae().put("/invitation",s);const r=await Ae().get("organization");d(r?.orgs||[]),t.user_opinion=ye.ACCEPTED,Ie({description:`Invitation for ${t.org_name} ${Z.account_type_txt.singular} has been ${e===ye.ACCEPTED?"accepted":"rejected"} successfully.`})}finally{l(-1)}};return e.jsxs(ja,{layout:"horizontal",children:[e.jsx("span",{className:"md:flex-1 flex-none"}),e.jsx(ja,{className:"flex-4 max-w-4xl mt-5",children:e.jsxs(ja,{children:[(()=>{if(t)return e.jsx("span",{children:e.jsx(ja,{layout:"horizontal",className:"text-center mt-5 justify-center items-center",children:e.jsx(ze,{})})});if(!n||n.length<=0)return e.jsxs(Ea,{className:"text-center mt-5",children:["You don't have any invitations from any ",Z.account_type_txt.singular.toLocaleLowerCase(),"."]});const a=n.filter(e=>je(e.org_user_is_active)).map(t=>[e.jsxs(Lt,{className:"font-normal",children:[e.jsxs("span",{className:"font-semibold",children:[t.org_name,","]}),"sent on  ",pe(t.sent_at)]}),e.jsxs(ja,{className:"gap-1 justify-end pr-3",layout:"horizontal",children:[e.jsxs(vt,{onClick:()=>c(ye.ACCEPTED,t),loading:o===parseInt(t.org_id,10),disabled:-1!==o,className:"bg-green-500 hover:bg-green-600",children:[e.jsx(i.Check,{})," Accept"]}),e.jsxs(vt,{variant:"destructive",loading:o===parseInt(t.org_id,10),disabled:-1!==o,onClick:()=>{r.showAlertBox({type:"CONFIRM",text:`Are you sure you want to reject this ${Z.account_type_txt.singular.toLocaleLowerCase()} request? You can't re-join until an administrator invites you again.`,async onClose(e){"CONFIRM"===e&&c(ye.REJECTED,t)}})},children:[e.jsx(i.X,{})," Reject"]})]})]);return e.jsx(Da,{className:"w-full mt-5 text-sm border-b-1",leftCls:"w-full sm:w-100 text-left sm:text-right pt-3",rightCls:"sm:pt-0 pt-2",rowCls:"flex-col sm:flex-row border-t-1 p-2 hover:bg-muted",child:a.flat()})})(),e.jsx("span",{className:"mt-5 text-center",children:e.jsx(vt,{className:"mt-5",variant:"link",children:e.jsxs(qa,{to:"/infrastructure/manage-infra",children:["View all ",Z.account_type_txt.plural.toLocaleLowerCase()]})})})]})}),e.jsx("span",{className:"md:flex-1 flex-none"})]})}});const ir=C.cva("flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}});function or({className:t,orientation:a,...s}){return e.jsx("div",{role:"group","data-slot":"button-group","data-orientation":a,className:ee(ir({orientation:a}),t),...s})}var lr=Object.freeze({__proto__:null,default:()=>{const{orgs:t,featureFlags:r}=s.useContext(Pe),n=r.ff_enable_teams&&0===t.length,o=a.useLocation(),l=a.useNavigate(),d=ya(),c=[...r.ff_enable_teams?[{title:Z.account_type_txt.plural,url:"/infrastructure/manage-infra"},{title:"Invitations",url:"/infrastructure/user-invitations"}]:[],...r.ff_enable_paid_subscription?[{title:"Subscriptions",url:"/infrastructure/manage-subscription"},{title:"Payment History",url:"/infrastructure/payment-history"}]:[]];return e.jsxs(ja,{className:"h-screen sm:pt-10 pt-5",children:[e.jsxs("div",{className:"scroll-m-20 text-xl inline-flex gap-2 px-5 pb-5",children:["/infrastructure"!==o.pathname&&e.jsxs(vt,{variant:"ghost",onClick:()=>l(-1),children:[e.jsx(i.ArrowLeft,{size:20})," Back"]}),e.jsx("span",{className:"flex-1"}),e.jsx("div",{className:"bg-sidebar-primary text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg",children:e.jsx(Z.logo,{className:"size-4"})}),e.jsx("div",{className:"grid text-left leading-tight items-center text-foreground font-semibold tracking-tight",children:Z.appName}),e.jsx("span",{className:"flex-1"}),n?e.jsx(a.NavLink,{to:"/login",children:e.jsxs(vt,{variant:"ghost",children:[e.jsx(i.LogOut,{}),"Log out"]})}):e.jsx(a.NavLink,{to:"/",children:e.jsx(vt,{variant:"ghost",title:"close",children:e.jsx(i.X,{size:20})})})]}),c.some(e=>e.url===o.pathname)&&e.jsx(ja,{doNotAppendFlex1:!0,className:"mx-auto mb-4",children:d?e.jsxs(ia,{children:[e.jsx(oa,{asChild:!0,children:e.jsxs(vt,{variant:"default",children:[e.jsx(i.Menu,{}),"Menu"]})}),e.jsx(la,{children:c.map(t=>e.jsx(ca,{onClick:()=>l(t.url),children:t.title},t.title))})]}):e.jsx(or,{children:c.map(t=>e.jsx(vt,{variant:o.pathname===t.url?"default":"outline",onClick:()=>l(t.url),children:t.title},t.title))})}),e.jsx(a.Outlet,{})]})}});var dr=Object.freeze({__proto__:null,default:()=>{const{orgs:t,setOrgs:r,featureFlags:n,loggedInUser:o,setActiveOrg:l}=s.useContext(Pe),d=yt(),[c,u]=s.useState(!1),m=a.useNavigate(),{editOrganization:x}=Ks(),p=async()=>{u(!0);try{const e=await Ae().get("organization");r(e?.orgs||[])}catch{r([])}finally{u(!1)}};return e.jsx(ja,{children:e.jsx("div",{className:"flex-1 flex p-5 sm:px-10 px-4 flex-col sm:w-300 m:w-full w-full mx-auto",children:e.jsx(Oa,{loading:c,toolbarConfig:{canShowSearchField:!0,searchFieldConfig:{placeholder:`Search by ${Z.account_type_txt.singular} Name...`,searchField:"org_name"},canShowColumnsBtn:!0,additionalJSX:[e.jsx(qa,{to:"/infrastructure/create-new-org",children:e.jsxs(vt,{variant:"default",children:[e.jsx(i.Plus,{})," Create new ",Z.account_type_txt.singular]})})],refreshBtn:{canShow:!0,onClick:p}},data:t,actions:[{id:"actionId1",headerText:"Edit",onClick:e=>{x(e)}},{id:"actionId2",headerText:"Delete",onClick:t=>{const a=t;wt.Is_ADMIN(a.role_id)?d.showAlertBox({type:"CONFIRM",text:`Are you sure you want to delete "${a.org_name}" ${Z.account_type_txt.singular.toLocaleLowerCase()}?`,async onClose(e){if("CONFIRM"===e){u(!0);try{const e=await Ae().delete("organization/"+a.org_id);Ie({header:`${Z.account_type_txt.singular} has been deleted successfully.`,description:e.message}),await p()}finally{u(!1)}}}}):Oe({header:"Alert",description:e.jsxs(e.Fragment,{children:["You are not allowed to delete the ",e.jsx("b",{children:a.org_name})," ",Z.account_type_txt.singular,"."]})})}},{id:"separate",headerText:"SEPARATOR"},{id:"actionId3",headerText:`Leave this ${Z.account_type_txt.singular.toLocaleLowerCase()}`,onClick:e=>{const t=e;d.showAlertBox({type:"CONFIRM",text:`Are you sure you want to leave this ${Z.account_type_txt.singular.toLocaleLowerCase()}? You can't re-join until an administrator invites you again.`,async onClose(e){if("CONFIRM"===e){u(!0);try{const e={org_id:t.org_id,user_opinion:ye.LEFT};await Ae().put("invitation",e),Ie({header:`You have successfully left this ${Z.account_type_txt.singular.toLocaleLowerCase()}.`,description:""}),await p()}finally{u(!1)}}}})}},{id:"separate2",headerText:"SEPARATOR"},{id:"actionId4",headerText:"Impersonate",onClick:e=>{l(e),m("/")}}],columns:[...!1===n.ff_enable_paid_subscription?[]:[{id:"active_purchased_plan",headerText:"",enableSorting:!1,enableHiding:!1,type:"string",renderer(t,a){const s=a;return e.jsx(Es,{purchasedPlan:s})}}],{id:"org_name",headerText:`${Z.account_type_txt.singular} Name`,enableSorting:!0,enableHiding:!0},...Z.account_type_txt.value===Q.ORG?[{id:"org_address",headerText:"Address",enableSorting:!0,enableHiding:!0},{id:"org_state",headerText:"State",enableSorting:!0,enableHiding:!0},{id:"org_country",headerText:"Country",enableSorting:!0,enableHiding:!0}]:[],{id:"role_id",headerText:"Role",enableSorting:!0,enableHiding:!0,type:"string",renderer:(e,t)=>wt.DISPLAY_TEXT(t)},{id:"org_created_by",headerText:"Created By Me?",enableSorting:!1,enableHiding:!0,renderer:(t,a)=>Number(a)===Number(o.id)?e.jsx(i.Check,{}):e.jsx(i.X,{})},{id:"updated_at",headerText:"Updated On",enableSorting:!0,enableHiding:!0,type:"date"},{id:"created_at",headerText:"Created On",enableSorting:!0,enableHiding:!0,type:"date"}]})})})}});function cr({className:t,...a}){return e.jsx(K.Root,{"data-slot":"radio-group",className:ee("grid gap-3",t),...a})}function ur({className:t,...a}){return e.jsx(K.Item,{"data-slot":"radio-group-item",className:ee("border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...a,children:e.jsx(K.Indicator,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:e.jsx(i.CircleIcon,{className:"fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})})})}const mr=C.cva("py-32 relative overflow-hidden",{variants:{size:{small:"py-12",medium:"py-20",large:"py-32"},theme:{minimal:"bg-background",classic:"bg-gradient-to-b from-background to-muted/20"}},defaultVariants:{size:"medium",theme:"minimal"}}),xr=C.cva("font-bold mb-4 text-foreground",{variants:{size:{small:"text-3xl lg:text-4xl",medium:"text-4xl lg:text-5xl",large:"text-4xl lg:text-6xl"},theme:{minimal:"",classic:"bg-gradient-to-r from-foreground to-muted-foreground bg-clip-text text-transparent"}},defaultVariants:{size:"medium",theme:"minimal"}}),pr=C.cva("text-muted-foreground max-w-3xl mx-auto mb-2",{variants:{size:{small:"text-base lg:text-lg",medium:"text-lg lg:text-xl",large:"lg:text-xl"},theme:{minimal:"",classic:""}},defaultVariants:{size:"medium",theme:"minimal"}}),hr=C.cva("relative h-full transition-all duration-300 rounded-lg border bg-card text-card-foreground",{variants:{size:{small:"p-4",medium:"p-5",large:"p-6"},theme:{minimal:"hover:bg-muted/30",classic:"hover:shadow-xl backdrop-blur-sm bg-card/50 border-border/50"},highlight:{true:"",false:""}},compoundVariants:[{theme:"classic",highlight:!0,className:"ring-2 ring-primary/20 border-primary/30 bg-gradient-to-b from-primary/5 to-transparent relative overflow-hidden shadow-xl"},{theme:"minimal",highlight:!0,className:"bg-muted/50 border-primary/20"}],defaultVariants:{size:"large",theme:"minimal",highlight:!1}}),gr=C.cva("flex h-11 w-fit shrink-0 items-center rounded-md p-1 text-lg",{variants:{theme:{minimal:"bg-muted",classic:"bg-muted/50 backdrop-blur-sm border border-border/50 shadow-lg"}},defaultVariants:{theme:"minimal"}}),fr=C.cva("font-medium",{variants:{size:{small:"text-2xl",medium:"text-3xl",large:"text-4xl"},theme:{minimal:"",classic:"font-extrabold bg-gradient-to-r from-foreground to-muted-foreground bg-clip-text text-transparent"}},defaultVariants:{size:"large",theme:"minimal"}}),br=C.cva("w-full transition-all duration-300 hover:cursor-pointer",{variants:{theme:{minimal:"shadow hover:bg-primary/90 h-9 py-2 group bg-primary text-primary-foreground ring-primary before:from-primary-foreground/20 after:from-primary-foreground/10 relative isolate inline-flex w-full items-center justify-center overflow-hidden rounded-md px-3 text-left text-sm font-medium ring-1 before:pointer-events-none before:absolute before:inset-0 before:-z-10 before:rounded-md before:bg-gradient-to-b before:opacity-80 before:transition-opacity before:duration-300 before:ease-[cubic-bezier(0.4,0.36,0,1)] after:pointer-events-none after:absolute after:inset-0 after:-z-10 after:rounded-md after:bg-gradient-to-b after:to-transparent after:mix-blend-overlay",classic:"relative overflow-hidden bg-gradient-to-r from-primary to-primary/80 text-primary-foreground font-semibold py-3 px-6 rounded-lg hover:shadow-xl active:scale-95 border border-primary/20"}},defaultVariants:{theme:"minimal"}}),vr=C.cva("flex-none h-[1lh]",{variants:{size:{small:"size-3",medium:"size-4",large:"size-4"},theme:{minimal:"text-primary",classic:"text-primary"}},defaultVariants:{size:"large",theme:"minimal"}}),jr={starter:e.jsx(i.Package,{className:"w-4 h-4"}),pro:e.jsx(i.Award,{className:"w-4 h-4"}),enterprise:e.jsx(i.Building2,{className:"w-4 h-4"})};function yr({plans:t,title:a="Choose Your Perfect Plan",description:r="Transform your project with our comprehensive pricing options designed for every need.",subtitle:n,onPlanSelect:o,className:l,size:d="medium",theme:c="minimal",showBillingToggle:u=!0,billingToggleLabels:m={monthly:"Monthly",yearly:"Yearly"}}){const[x,p]=s.useState(!1),h=s.useId();function g(e,t){const a=parseFloat(e),s=parseFloat(t);if("custom"===e.toLowerCase()||"custom"===t.toLowerCase()||isNaN(a)||isNaN(s)||0===a)return 0;const r=(12*a-s)/(12*a)*100;return Math.round(r)}const f=t.length?Math.max(...t.map(e=>g(e.monthlyPrice,e.yearlyPrice))):0;return e.jsxs("section",{className:ee(mr({size:d,theme:c}),l),children:["classic"===c&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute inset-0 bg-grid-pattern opacity-5"}),e.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-96 h-96 bg-primary/5 rounded-full blur-3xl"}),e.jsx("div",{className:"absolute top-1/4 right-1/4 w-64 h-64 bg-secondary/5 rounded-full blur-2xl"})]}),e.jsxs("div",{className:"container max-w-7xl mx-auto relative",children:[e.jsxs("div",{className:"text-center mb-12",children:[n&&e.jsx("p",{className:"text-sm font-medium text-primary mb-3 tracking-wide uppercase",children:n}),e.jsx("h2",{className:ee(xr({size:d,theme:c})),children:a}),e.jsx("p",{className:ee(pr({size:d,theme:c})),children:r}),u&&e.jsx("div",{className:ee("flex justify-center mt-8 mx-auto",gr({theme:c})),children:e.jsxs(cr,{defaultValue:"monthly",className:"h-full grid-cols-2",onValueChange:e=>{p("annually"===e)},children:[e.jsxs("div",{className:'has-[button[data-state="checked"]]:bg-background h-full rounded-md transition-all',children:[e.jsx(ur,{value:"monthly",id:`${h}-monthly`,className:"peer sr-only"}),e.jsx(Lt,{htmlFor:`${h}-monthly`,className:"text-muted-foreground peer-data-[state=checked]:text-primary flex h-full cursor-pointer items-center justify-center px-2 md:px-7 font-semibold transition-all hover:text-foreground",children:m.monthly})]}),e.jsxs("div",{className:'has-[button[data-state="checked"]]:bg-background h-full rounded-md transition-all',children:[e.jsx(ur,{value:"annually",id:`${h}-annually`,className:"peer sr-only"}),e.jsxs(Lt,{htmlFor:`${h}-annually`,className:"text-muted-foreground peer-data-[state=checked]:text-primary flex h-full cursor-pointer items-center justify-center gap-1 px-2 md:px-7 font-semibold transition-all hover:text-foreground",children:[m.yearly,f>0&&e.jsxs("span",{className:"ml-1 rounded bg-primary/10 px-2 py-0.5 text-xs text-primary border border-primary/20 font-medium",children:["Save ",f,"%"]})]})]})]})})]}),e.jsx("div",{className:ee("grid gap-6",1===t.length&&"grid-cols-1 max-w-md mx-auto",2===t.length&&"grid-cols-1 md:grid-cols-2 max-w-4xl mx-auto",3===t.length&&"grid-cols-1 md:grid-cols-3",t.length>=4&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4"),children:t.map((t,a)=>{return e.jsxs(z.motion.div,{className:"relative group h-full",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.4,delay:.1*a,ease:"easeOut"},children:[t.badge&&e.jsx(ra,{className:ee("absolute -top-3 left-1/2 transform -translate-x-1/2 z-20","classic"===c?"bg-gradient-to-r from-primary to-primary/80 text-primary-foreground border-primary/20 shadow-lg":"bg-primary text-primary-foreground"),children:t.badge}),"classic"===c&&t.highlight&&e.jsx("div",{className:"absolute -top-px left-1/2 -translate-x-1/2 w-32 h-px bg-gradient-to-r from-transparent via-primary to-transparent"}),e.jsx("div",{className:ee(hr({size:d,theme:c,highlight:t.highlight})),children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-start gap-4 mb-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:ee("text-xl font-bold mb-1","classic"===c?"text-lg":""),children:t.title}),e.jsx("p",{className:ee("text-sm text-muted-foreground","classic"===c&&"text-foreground/80"),children:t.description})]}),e.jsx("div",{className:ee("w-10 h-10 flex items-center rounded-lg justify-center flex-shrink-0","classic"===c?"bg-primary/10 text-primary border border-primary/20":"bg-muted text-foreground border border-border"),children:(s=t.id,jr[s]||e.jsx(i.Package,{className:"w-5 h-5"}))})]}),e.jsx("div",{className:"mb-6",children:e.jsx(z.AnimatePresence,{mode:"wait",children:e.jsx(z.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},children:x?e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsxs("span",{className:ee(fr({size:d,theme:c})),children:[parseFloat(t.yearlyPrice)>=0&&"custom"!==t.yearlyPrice.toLowerCase()&&e.jsx(e.Fragment,{children:t.currency}),t.yearlyPrice]}),e.jsx("span",{className:"text-muted-foreground text-sm",children:"/year"}),g(t.monthlyPrice,t.yearlyPrice)>0&&e.jsxs("span",{className:ee("text-xs ml-2","classic"===c?"text-emerald-500 font-semibold":"text-primary font-medium"),children:[g(t.monthlyPrice,t.yearlyPrice),"% off"]})]}):e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsxs("span",{className:ee(fr({size:d,theme:c})),children:[parseFloat(t.monthlyPrice)>=0&&"custom"!==t.monthlyPrice.toLowerCase()&&e.jsx(e.Fragment,{children:t.currency}),t.monthlyPrice]}),e.jsx("span",{className:"text-muted-foreground text-sm",children:"/month"})]})},x?"year":"month")})}),e.jsx("div",{className:"mb-6",children:e.jsxs(vt,{onClick:()=>(e=>{o?.(e,x)})(t.id),className:ee(br({theme:c}),!t.highlight&&"minimal"===c&&"bg-secondary hover:bg-secondary/80 text-secondary-foreground"),variant:t.highlight?"default":"secondary",children:[t.buttonText,"classic"===c&&t.highlight&&e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-white/0 via-white/10 to-white/0 translate-x-[-100%] hover:translate-x-[100%] transition-transform duration-700"})]})}),e.jsx("div",{className:"flex-1",children:e.jsx("ul",{className:"space-y-3",children:t.features.map((t,a)=>e.jsxs(z.motion.li,{className:"flex gap-3 items-start",initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{duration:.3,delay:.05*a},children:[e.jsx(i.Check,{className:ee(vr({size:d,theme:c}))}),e.jsx("span",{className:ee("text-sm","classic"===c?"text-foreground/90":"text-muted-foreground"),children:t.name})]},a))})})]})})]},t.id);var s})})]})]})}var Nr=Object.freeze({__proto__:null,PricingTbl:function(){const t=a.useNavigate(),{subscriptionConfig:r,setSubscriptionConfig:n}=s.useContext(Pe),{plans:i,faqs:o}=r;return s.useEffect(()=>{(async()=>{if("plans"in r==!1){const e=await Ae().get("/get-subscription-config");n(e)}})()},[n,r]),"plans"in r==!1?e.jsx(Te,{}):e.jsxs("div",{className:"px-5",children:[e.jsx(yr,{plans:i,title:"Choose Your Perfect Plan",theme:"classic",description:"Transform your project with our comprehensive pricing options designed for every need.",subtitle:Z.appName,onPlanSelect:(e,a)=>{t(`/infrastructure/checkout?plan=${e}&billing=${a?"yearly":"monthly"}`)},size:"small",className:"w-full",showBillingToggle:!0,billingToggleLabels:{monthly:"Monthly",yearly:"Yearly"}}),e.jsxs("div",{className:"m-8 mx-auto max-w-200",children:[e.jsx(Aa,{className:"mb-2",children:"Need a custom plan?"}),e.jsx("p",{className:"text-muted-foreground",children:"Contact our sales team for tailored solutions that fit your organization's unique needs."}),e.jsx(Aa,{className:"mb-2 mt-15 font-medium text-lg",children:"Frequently Asked Questions"}),e.jsx("div",{className:"mt-5",children:o.map((t,a)=>e.jsx("div",{className:"border-t",children:e.jsx(Ua,{title:e.jsx("h1",{className:"",children:t.question}),children:e.jsx("div",{className:"",children:t.answer})})},a))}),e.jsx(Aa,{className:"mb-2 mt-15 font-medium text-lg",children:"Still have questions?"}),e.jsxs("p",{className:"text-muted-foreground",children:["Reach out to our support team at"," ",e.jsx("a",{href:`mailto:${Z.supportEmail}`,className:"text-primary underline",children:Z.supportEmail})," ","for personalized assistance."]})]})]})}});function wr({title:t,description:a,plan:r,triggerButtonText:n,leftPanelImageUrl:o,warningTitle:l,warningText:d,keepButtonText:c,continueButtonText:u,finalTitle:m,finalSubtitle:x,finalWarningText:p,goBackButtonText:h,confirmButtonText:g,onCancel:f,onKeepSubscription:b,onDialogClose:v,className:j}){const[y,N]=s.useState(!1),[w,_]=s.useState(!1),[C,k]=s.useState(!1),[S,P]=s.useState(null),z=()=>{_(!1),N(!1),P(null),k(!1),v?.()};return s.useEffect(()=>{const e=e=>{w&&"Escape"===e.key&&(e.preventDefault(),z())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[w]),e.jsxs(ot,{open:w,onOpenChange:e=>{e?_(!0):z()},children:[e.jsx(lt,{asChild:!0,children:e.jsx(vt,{variant:"outline",children:n||"Cancel Subscription"})}),e.jsxs(mt,{className:ee("sm:max-w-[1000px] flex flex-col md:flex-row p-0 overflow-hidden text-foreground w-[95%] md:w-[100%]",o?"":"sm:max-w-[500px]",j),children:[e.jsx(ht,{className:"sr-only",children:t}),e.jsxs(ct,{className:"absolute right-4 top-4 z-10 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",onClick:z,children:[e.jsx(i.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]}),o&&e.jsxs("div",{className:"w-full md:w-1/2 min-h-[500px] relative hidden md:block overflow-hidden",children:[e.jsx("img",{src:o,alt:"Cancel Subscription",className:"absolute inset-0 w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-background/30 to-background/90 dark:block hidden"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-background/80 via-transparent to-background/20 dark:block hidden"})]}),e.jsxs("div",{className:ee("py-6 px-4 flex flex-col gap-4",o?"w-full md:w-1/2":"w-full"),children:[e.jsxs("div",{className:"flex flex-col gap-2 text-center md:text-left",children:[e.jsx("h2",{className:"md:text-2xl text-xl font-semibold",children:t}),e.jsx("p",{className:"md:text-sm text-xs text-muted-foreground",children:a}),S&&e.jsx("div",{className:"p-3 bg-destructive/10 border border-destructive/20 rounded-md",children:e.jsx("p",{className:"text-sm text-destructive",children:S})})]}),!y&&e.jsxs("div",{className:"flex flex-col gap-4 p-4 bg-muted/50 rounded-lg",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("span",{className:"font-semibold text-lg",children:[r.title," Plan"]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Current subscription"})]}),e.jsx(ra,{variant:"secondary",children:parseFloat(r.monthlyPrice)>=0?`${r.currency}${r.monthlyPrice}/monthly`:`${r.monthlyPrice}/monthly`})]}),e.jsx("div",{className:"flex flex-col gap-2",children:r.features.slice(0,4).map((t,a)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(i.Circle,{className:"w-2 h-2 fill-primary text-primary"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:t.name})]},a))})]}),!y&&(l||d)&&e.jsxs("div",{className:"p-4 bg-muted/30 border border-border rounded-lg",children:[l&&e.jsx("h3",{className:"font-semibold text-foreground mb-2",children:l}),d&&e.jsx("p",{className:"text-sm text-muted-foreground",children:d})]}),y?e.jsxs("div",{className:"flex flex-col gap-4 mt-auto",children:[e.jsxs("div",{className:"text-center p-4 bg-muted/50 rounded-lg",children:[e.jsx("h3",{className:"font-semibold mb-2 text-foreground",children:m||"Final Confirmation"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:x||"Are you sure you want to cancel your subscription?"}),e.jsx("p",{className:"text-sm text-destructive",children:p||"This action cannot be undone and you'll lose access to all premium features."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsx(vt,{variant:"outline",className:"flex-1",onClick:()=>{N(!1),P(null)},disabled:C,children:h||"Go Back"}),e.jsx(vt,{variant:"destructive",className:"flex-1",onClick:async()=>{try{k(!0),P(null),await f(r.id),z()}catch(e){P(e instanceof Error?e.message:"Failed to cancel subscription")}finally{k(!1)}},disabled:C,children:C?"Cancelling...":g||"Yes, Cancel Subscription"})]})]}):e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-auto",children:[e.jsx(vt,{className:"flex-1",onClick:async()=>{try{k(!0),P(null),b&&await b(r.id),z()}catch(e){P(e instanceof Error?e.message:"Failed to keep subscription")}finally{k(!1)}},disabled:C,children:C?"Processing...":c||"Keep My Subscription"}),e.jsx(vt,{variant:"destructive",className:"flex-1",onClick:()=>{N(!0),P(null)},disabled:C,children:u||"Continue Cancellation"})]})]})]})]})}const _r=C.cva("inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 px-2 min-w-9",sm:"h-8 px-1.5 min-w-8",lg:"h-10 px-2.5 min-w-10"}},defaultVariants:{variant:"default",size:"default"}});function Cr({className:t,variant:a,size:s,...r}){return e.jsx(G.Root,{"data-slot":"toggle",className:ee(_r({variant:a,size:s,className:t})),...r})}const kr=[.4,0,.2,1];function Sr({currentPlan:t,plans:a,onPlanChange:r,className:n,title:i,triggerText:o}){const[l,d]=s.useState(!1),[c,u]=s.useState(void 0),[m,x]=s.useState(!1),p=s.useCallback(e=>l?`${e.yearlyPrice}`:`${e.monthlyPrice}`,[l]),h=s.useCallback(e=>{u(t=>t===e?void 0:e)},[]),g=s.useCallback(e=>{x(e),e||u(void 0)},[]);return e.jsxs(ot,{open:m,onOpenChange:g,children:[e.jsx(lt,{asChild:!0,children:e.jsx(vt,{children:o||"Update Plan"})}),e.jsxs(mt,{className:ee("gap-3 sm:gap-4 max-h-[95vh] sm:max-h-[90vh] flex flex-col text-foreground","w-[calc(100vw-2rem)] sm:w-full max-w-2xl","p-4 sm:p-6",n),children:[e.jsxs(xt,{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 sm:gap-4 pb-2 sm:pb-0",children:[e.jsx(ht,{className:"text-lg sm:text-xl font-semibold",children:i||"Upgrade Plan"}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 text-sm",children:[e.jsx(Cr,{size:"sm",pressed:!l,onPressedChange:e=>d(!e),className:"px-3 sm:px-4 h-9 sm:h-10 text-xs sm:text-sm",children:"Monthly"}),e.jsx(Cr,{size:"sm",pressed:l,onPressedChange:e=>d(e),className:"px-3 sm:px-4 h-9 sm:h-10 text-xs sm:text-sm",children:"Yearly"})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto overflow-x-hidden -mx-4 sm:-mx-6 px-4 sm:px-6 [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-muted [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:border-2 [&::-webkit-scrollbar-thumb]:border-transparent hover:[&::-webkit-scrollbar-thumb]:bg-muted-foreground/20",style:{scrollbarWidth:"thin",scrollbarColor:"hsl(var(--muted)) transparent"},children:0===a.length?e.jsx("div",{className:"flex items-center justify-center py-12 text-center",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No plans available"})}):e.jsx(cr,{value:c,onValueChange:h,children:e.jsx("div",{className:"space-y-2.5 sm:space-y-3 pb-2 pr-0.5",children:a.map((a,s)=>e.jsxs(z.motion.div,{layout:!0,initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{layout:{duration:.3,ease:kr},opacity:{delay:.05*s,duration:.3,ease:kr},y:{delay:.05*s,duration:.3,ease:kr}},onClick:()=>h(a.id),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),h(a.id))},role:"button",tabIndex:0,"aria-pressed":c===a.id,className:ee("relative rounded-lg sm:rounded-xl border cursor-pointer overflow-hidden transition-all duration-200","touch-manipulation focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2",c===a.id?"border-primary bg-gradient-to-br from-muted/60 to-muted/30 shadow-sm":"border-border hover:border-primary/50"),children:[e.jsx(z.motion.div,{layout:"position",className:"p-3 sm:p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-2 sm:gap-3",children:[e.jsxs("div",{className:"flex gap-2 sm:gap-3 min-w-0 flex-1",children:[e.jsx(ur,{value:a.id,id:a.id,className:"flex-shrink-0 pointer-events-none mt-0.5 sm:mt-1"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 flex-wrap",children:[e.jsx(Lt,{htmlFor:a.id,className:"font-semibold sm:font-medium text-sm sm:text-base cursor-pointer leading-tight",children:a.title}),a.badge&&e.jsx(ra,{variant:"secondary",className:"flex-shrink-0 text-[10px] sm:text-xs px-1.5 sm:px-2 py-0 sm:py-0.5 h-5 sm:h-auto",children:a.badge})]}),e.jsx("p",{className:"text-[11px] sm:text-xs text-muted-foreground mt-1 leading-relaxed",children:a.description}),a.features.length>0&&e.jsx("div",{className:"pt-2 sm:pt-3",children:e.jsx("div",{className:"flex flex-wrap gap-1.5 sm:gap-2",children:a.features.map((t,a)=>e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 px-2 py-1 rounded-md sm:rounded-lg bg-muted/20 border border-border/30 flex-shrink-0",children:[e.jsx("div",{className:"w-1 h-1 sm:w-1.5 sm:h-1.5 rounded-full bg-primary flex-shrink-0"}),e.jsx("span",{className:"text-[10px] sm:text-xs text-muted-foreground whitespace-nowrap leading-none",children:t.name})]},a))})})]})]}),e.jsxs("div",{className:"text-right flex-shrink-0 min-w-[60px] sm:min-w-[80px]",children:[e.jsx("div",{className:"text-base sm:text-xl font-bold sm:font-semibold leading-tight",children:parseFloat(p(a))>=0?`${a.currency}${p(a)}`:p(a)}),e.jsxs("div",{className:"text-[10px] sm:text-xs text-muted-foreground mt-0.5",children:["/",l?"year":"month"]})]})]})}),e.jsx(z.AnimatePresence,{initial:!1,children:c===a.id&&e.jsx(z.motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1,transition:{height:{duration:.3,ease:kr},opacity:{duration:.25,delay:.05,ease:kr}}},exit:{height:0,opacity:0,transition:{height:{duration:.25,ease:kr},opacity:{duration:.15,ease:kr}}},className:"overflow-hidden",children:e.jsx(z.motion.div,{initial:{y:-8},animate:{y:0,transition:{duration:.25,delay:.05,ease:kr}},exit:{y:-8},className:"px-3 sm:px-4 pb-3 sm:pb-4",children:e.jsx(vt,{className:"w-full h-10 sm:h-11 text-sm sm:text-base font-medium touch-manipulation",disabled:c===t.id,onClick:e=>{e.stopPropagation(),r(a.id,l),g(!1)},children:c===t.id?"Current Plan":"Upgrade"})})})})]},a.id))})})})]})]})}function Pr({className:t,currentPlan:a,cancelSubscription:s,updatePlan:r,canShowUpdatePlanBtn:n,addMoreBtnProps:o,canShowCancelPlanBtn:l}){return e.jsx("div",{className:ee("text-left w-full",t),children:e.jsxs(It,{className:"",children:[e.jsxs(Ft,{className:"pb-4 sm:pb-6 px-4 sm:px-6",children:[e.jsxs(Ot,{className:"flex items-center gap-2 sm:gap-3 text-lg sm:text-xl",children:[e.jsx("div",{className:"p-1.5 sm:p-2 rounded-lg bg-primary/10 ring-1 ring-primary/20",children:e.jsx(i.CreditCard,{className:"h-4 w-4 sm:h-5 sm:w-5 text-primary"})}),"Current Subscription"]}),e.jsx(Dt,{className:"text-sm sm:text-base",children:"Manage your billing and subscription settings"})]}),e.jsxs(At,{className:"space-y-6 sm:space-y-8 px-4 sm:px-6",children:[e.jsx("div",{className:"relative p-3 sm:p-4 rounded-xl bg-gradient-to-r from-muted/30 via-muted/20 to-muted/30 border border-border/50 overflow-hidden",children:e.jsx("div",{className:"relative",children:e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 sm:gap-0",children:e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-3 mb-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("h3",{className:"text-lg sm:text-xl font-semibold",children:[a.plan.title," Plan"]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(ra,{variant:"active"===a.status?"default":"outline",className:"shadow-sm text-xs sm:text-sm bg-primary/90 hover:bg-primary border-0 font-medium",children:"monthly"===a.type?`${a.plan.currency}${a.plan.monthlyPrice}/month`:"yearly"===a.type?`${a.plan.currency}${a.plan.yearlyPrice}/year`:`${a.price}`}),e.jsx(ra,{variant:"outline",className:"shadow-sm text-xs sm:text-sm border-border/60 bg-background/50 backdrop-blur-sm",children:a.status})]})]}),e.jsx("div",{className:"relative",children:e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground relative z-10",children:a.plan.description})})]})})})}),e.jsx(na,{className:"my-4 sm:my-6 bg-gradient-to-r from-transparent via-border to-transparent"}),e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsxs("h4",{className:"font-medium flex items-center gap-2 text-base sm:text-lg",children:[e.jsx("div",{className:"p-1 sm:p-1.5 rounded-md bg-muted ring-1 ring-border/50",children:e.jsx(i.Calendar,{className:"h-3 w-3 sm:h-4 sm:w-4"})}),"Billing Information"]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 sm:gap-6",children:[e.jsxs("div",{className:"group p-2.5 sm:p-3 rounded-lg md:bg-gradient-to-tl bg-gradient-to-b from-muted to-background/10 border border-border/30 hover:border-border/60 transition-all duration-200",children:[e.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground block mb-1",children:"Start Date"}),e.jsx("div",{className:"font-medium text-sm sm:text-base group-hover:text-primary transition-colors duration-200",children:a.startDate})]}),e.jsxs("div",{className:"group p-2.5 sm:p-3 rounded-lg md:bg-gradient-to-tl bg-gradient-to-b from-muted to-background/10 border border-border/30 hover:border-border/60 transition-all duration-200",children:[e.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground block mb-1",children:"Plan Expiry Date"}),e.jsx("div",{className:"font-medium text-sm sm:text-base group-hover:text-primary transition-colors duration-200",children:a.expiryDate})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 sm:gap-6",children:[e.jsxs("div",{className:"group p-2.5 sm:p-3 rounded-lg md:bg-gradient-to-tl bg-gradient-to-b from-muted to-background/10 border border-border/30 hover:border-border/60 transition-all duration-200",children:[e.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground block mb-1",children:"Active Plan for"}),e.jsxs("div",{className:"font-medium text-sm sm:text-base group-hover:text-primary transition-colors duration-200",children:[a.activePlanFor," users"]})]}),e.jsxs("div",{className:"group p-2.5 sm:p-3 rounded-lg md:bg-gradient-to-tr bg-gradient-to-b from-muted to-background/10 border border-border/30 hover:border-border/60 transition-all duration-200",children:[e.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground block mb-1",children:"Total Paid Amount"}),e.jsx("div",{className:"font-medium text-sm sm:text-base group-hover:text-primary transition-colors duration-200",children:a.paidAmount})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 sm:gap-6",children:[e.jsxs("div",{className:"group p-2.5 sm:p-3 rounded-lg md:bg-gradient-to-tr bg-gradient-to-b from-muted to-background/10 border border-border/30 hover:border-border/60 transition-all duration-200",children:[e.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground block mb-1",children:"Payment method"}),e.jsx("div",{className:"font-medium text-sm sm:text-base group-hover:text-primary transition-colors duration-200",children:a.paymentMethod})]}),e.jsxs("div",{className:"group p-2.5 sm:p-3 rounded-lg md:bg-gradient-to-tr bg-gradient-to-b from-muted to-background/10 border border-border/30 hover:border-border/60 transition-all duration-200",children:[e.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground block mb-1",children:"Order Id"}),e.jsx("div",{className:"font-medium text-sm sm:text-base group-hover:text-primary transition-colors duration-200",children:a.transactionId||"N/A"})]})]})]}),e.jsx(na,{className:"my-4 sm:my-6 bg-gradient-to-r from-transparent via-border to-transparent"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[n&&e.jsx(Sr,{className:"mx-0 shadow-lg hover:shadow-xl transition-all duration-200",...r}),o&&o.canShow&&e.jsx(vt,{...o.buttonProps,children:o.text}),l&&e.jsx(wr,{className:"mx-0 shadow-lg hover:shadow-xl transition-all duration-200",...s}),e.jsx(qa,{to:"/plans",children:e.jsxs(vt,{variant:"outline",children:["Buy Upcoming Plan ",e.jsx(i.MoveUpRight,{})]})})]}),e.jsxs("div",{className:"pt-4 sm:pt-6",children:[e.jsx("h4",{className:"font-medium mb-3 sm:mb-4 text-base sm:text-lg",children:"Current Plan Features"}),e.jsx("div",{className:"flex flex-wrap gap-2 sm:gap-3",children:a.plan.features.map((t,a)=>e.jsxs("div",{className:"group flex items-center gap-2 p-2 sm:p-2 rounded-lg border border-border/80 hover:border-primary/30 hover:bg-primary/5 transition-all duration-200",children:[e.jsx("div",{className:"w-1 h-1 sm:w-1.5 sm:h-1.5 rounded-full bg-primary flex-shrink-0 group-hover:bg-primary group-hover:scale-125 transition-all duration-200"}),e.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground group-hover:text-foreground transition-colors duration-200",children:t.name})]},a))})]})]})]})})}const zr=({upcomingPlans:t,Icon:a,title:r,badgeText:n,isFreePlan:o=!1})=>{const{subscriptionConfig:l,orgs:d,featureFlags:c}=s.useContext(Pe),{plans:u}=l;return e.jsxs(It,{className:"mt-5",children:[e.jsx(Ft,{children:e.jsxs(Ot,{className:"flex items-center gap-2 sm:gap-3 text-lg sm:text-xl",children:[e.jsx("div",{className:"p-1.5 sm:p-2 rounded-lg bg-primary/10 ring-1 ring-primary/20",children:e.jsx(a,{className:"h-4 w-4 sm:h-5 sm:w-5 text-primary"})}),r]})}),e.jsx(At,{children:e.jsx("div",{className:"flex flex-wrap gap-2 sm:gap-3",children:t.length?t.map(t=>{const a=u.find(e=>e.id===t.plan_id);return e.jsx("div",{className:"w-full relative p-3 sm:p-4 rounded-xl bg-gradient-to-r from-muted/30 via-muted/20 to-muted/30 border border-border/50 overflow-hidden",children:e.jsx("div",{className:"relative",children:e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 sm:gap-0",children:e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-3 mb-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("h3",{className:"text-lg sm:text-xl font-semibold",children:[a?.title," Plan"]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(ra,{variant:"active"===t.status?"default":"outline",className:"shadow-sm text-xs sm:text-sm bg-primary/90 hover:bg-primary border-0 font-medium text-primary-foreground",children:[Re(t.z_currency),t.amount]}),e.jsx(ra,{variant:"outline",className:"shadow-sm text-xs sm:text-sm border-border/60 bg-background/50 backdrop-blur-sm",children:n})]})]}),o?e.jsx(e.Fragment,{children:e.jsxs("div",{className:"mt-5",children:[e.jsx(qa,{to:"/plans",children:e.jsx(Ka,{children:"Upgrade to premium"})}),c.ff_enable_teams&&0===d.length&&e.jsx(qa,{to:"/infrastructure/create-new-org",children:e.jsxs(vt,{className:"ml-2",variant:"outline",children:[e.jsx(i.LogIn,{})," Continue with Free Plan"]})})]})}):e.jsx("div",{className:"relative",children:e.jsxs("span",{className:"text-xs sm:text-sm text-muted-foreground relative z-10",children:[e.jsxs("p",{children:[t.for_no_users," Users for ",t.for_months," Months"]}),e.jsxs("p",{children:["Start Date: ",pe(t.startAt)]}),e.jsxs("p",{children:["End Date: ",pe(t.endAt)]}),e.jsxs("p",{children:["Order Id: ",t.z_order_id]})]})})]})})})},t.z_order_id)}):e.jsxs("p",{className:"text-center text-muted-foreground",children:["No ",n," Plans"]})})})]},"upcoming-plans")},Tr=s.forwardRef(function({title:t="Congratulations!",subtitle:a="Your payment was successful.",currencySymbol:r="$",price:n,productName:o,proceedButtonText:l="Proceed",backButtonText:d="Back",onProceed:c,onBack:u,className:m,open:x,onOpenChange:p},h){const g=void 0!==x,[f,b]=s.useState(!1),v=g?x:f,j=e=>{g?p?.(e):b(e)};s.useImperativeHandle(h,()=>({open:()=>j(!0),close:()=>j(!1)}),[g,p]);const[y,N]=s.useState(!1);s.useEffect(()=>{if(v){N(!0);const e=setTimeout(()=>N(!1),2200);return()=>clearTimeout(e)}N(!1)},[v]);const w=s.useMemo(()=>{const e=[],t=["--primary","--accent","--secondary"];for(let a=0;a<42;a++){const s=100*Math.random(),r=24*(Math.random()-.5);e.push({id:a,x:s,xEnd:Math.max(0,Math.min(100,s+r)),delay:.4*Math.random(),rotation:360*Math.random(),size:6+Math.round(6*Math.random()),colorVar:t[a%t.length]})}return e},[]);return e.jsx(ot,{open:v,onOpenChange:j,children:e.jsx(mt,{className:ee("w-[95%] sm:max-w-[560px] p-0 overflow-hidden text-foreground",m),children:e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"p-7 flex flex-col items-center text-center gap-5",children:[e.jsxs("div",{className:"relative",children:[e.jsx(z.motion.div,{className:"absolute inset-0 -z-10 mx-auto size-20 rounded-full blur-xl",style:{background:"var(--primary)",opacity:.12},initial:{scale:.9,opacity:0},animate:{scale:1,opacity:.12},transition:{duration:.5,ease:"easeOut"}}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"size-16 rounded-full bg-primary/10 flex items-center justify-center border border-primary/30 shadow-sm",children:e.jsx(i.CheckCircle2,{className:"size-10 text-primary"})}),e.jsx(z.motion.span,{className:"absolute inset-0 rounded-full border-2 border-primary/30",initial:{scale:.9,opacity:.5},animate:{scale:1.25,opacity:0},transition:{duration:1.2,repeat:1/0,ease:"easeOut"}}),e.jsx(z.motion.span,{className:"absolute inset-0 rounded-full border-2 border-accent/30",initial:{scale:.9,opacity:.5},animate:{scale:1.6,opacity:0},transition:{duration:1.6,repeat:1/0,ease:"easeOut",delay:.2}})]})]}),e.jsx(xt,{className:"text-center",children:e.jsx(ht,{className:"text-2xl font-semibold",children:t})}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-[38ch]",children:a}),e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsxs(z.motion.div,{className:"text-4xl font-semibold tracking-tight",initial:{y:6,opacity:0},animate:{y:0,opacity:1},transition:{type:"spring",stiffness:280,damping:22},children:[r,n]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Paid for ",o]})]}),e.jsxs(pt,{className:"w-full flex-col sm:flex-col gap-3 mt-1",children:[e.jsx(vt,{variant:"outline",className:"w-full",onClick:()=>{u?.(),j(!1)},children:d}),e.jsx(vt,{className:"w-full",onClick:()=>{c?.(),j(!1)},children:l})]})]}),e.jsx(z.AnimatePresence,{children:y&&e.jsx(z.motion.div,{className:"pointer-events-none absolute inset-0",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:w.map(t=>e.jsx(z.motion.span,{className:"absolute block rounded-[2px]",style:{left:`${t.x}%`,top:"-16px",width:t.size,height:.6*t.size,backgroundColor:`var(${t.colorVar})`},initial:{y:-20,rotate:t.rotation},animate:{y:360+80*Math.random(),x:`${t.xEnd}%`,rotate:t.rotation+720},transition:{duration:1.8+.8*Math.random(),delay:t.delay,ease:"easeOut"}},t.id))})})]})})})}),Ir=({isOpen:t,setIsOpen:r,purchasePlanId:n})=>{const{purchasePlans:i,subscriptionConfig:o,loggedInUser:l}=s.useContext(Pe),{plans:d,CURRENCY_SYMBOL:c,CURRENCY:u}=o,[m,x]=s.useState(1),[p,h]=s.useTransition(),{Razorpay:g}=F.useRazorpay(),{loadPurchasedPlans:f}=Be(),b=a.useNavigate(),[v,j]=s.useState(!1),y=s.useMemo(()=>i.find(e=>e.purchased_id===n),[i,n]),N=s.useMemo(()=>d.find(e=>e.id===y?.plan_id),[d,y]),w=s.useMemo(()=>{if(!y||!N)return 0;return(12===y.for_months?parseFloat(N.yearlyPrice):parseFloat(N.monthlyPrice))*m},[y,N,m]);return y&&N?e.jsxs(jt,{open:t,setIsOpen:r,disableOutsideClick:!0,header:`Add More Users in ${N.title}`,actionsJSX:e.jsxs(e.Fragment,{children:[e.jsx(vt,{variant:"outline",onClick:()=>{x(1),r(!1)},children:"Cancel"}),e.jsx(vt,{onClick:()=>{r(!1),h(async()=>{try{await new Promise(e=>setTimeout(e,200));const e=await Ae().post("payment-gateway/add-more-users-order",{purchased_id:n,currency:u,for_no_users:m});await $e(w,u,e,{name:`${l.fname} ${l.lname}`,email:l.email,contact:l.mobNo?.toString()||""},g),r(!0),j(!0)}catch(e){r(!0),Fe({header:"Failed to add users.",description:"Please try again later or contact support if the issue persists."})}finally{f()}})},disabled:m<1,loading:p,children:"Make Payment"})]}),children:[e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Order ID:"})," ",y.z_order_id]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Current Users:"})," ",y.for_no_users]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Plan Duration:"})," ",12===y.for_months?"Yearly":"Monthly"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Lt,{htmlFor:"numberOfUsers",children:"Number of Users to Add"}),e.jsx(Et,{id:"numberOfUsers",type:"number",min:"1",value:m,onChange:e=>x(Math.max(1,parseInt(e.target.value)||1)),placeholder:"Enter number of users"})]}),e.jsxs("div",{className:"rounded-lg bg-muted p-4 space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm font-medium",children:"Price per user:"}),e.jsxs("span",{className:"text-sm",children:[c,12===y.for_months?N.yearlyPrice:N.monthlyPrice]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm font-medium",children:"Number of users:"}),e.jsx("span",{className:"text-sm",children:m})]}),e.jsx("div",{className:"border-t pt-2 mt-2",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"font-semibold",children:"Total Amount:"}),e.jsxs("span",{className:"text-lg font-bold text-primary",children:[c,w.toFixed(2)]})]})})]})]}),e.jsx(Tr,{open:v,onOpenChange:e=>{j(e),e||b("/infrastructure/payment-history")},price:w.toFixed(2),currencySymbol:c,productName:N.title,proceedButtonText:"Go to Dashboard",backButtonText:"Go to Payment History",onProceed:()=>b("/"),onBack:()=>b("/infrastructure/payment-history")})]}):(Fe({header:"Failed to load plan details.",description:"Please try again later or contact support if the issue persists."}),null)};var Fr=Object.freeze({__proto__:null,default:()=>{const t=a.useNavigate(),{activePlan:r,purchasePlans:n,subscriptionConfig:o}=s.useContext(Pe),{plans:l,CURRENCY_SYMBOL:d}=o,[c,u]=s.useState(!1),m=l.find(e=>e.id===r?.plan_id)||l[0],x=s.useMemo(()=>n.filter(e=>"paid"===e.status&&new Date(e.startAt)>new Date).reverse(),[n]),p=s.useMemo(()=>n.filter(e=>"paid"===e.status&&new Date(e.endAt)<new Date),[n]),h=!r||Me(r);return e.jsx(ja,{children:e.jsxs("div",{className:"pb-5 sm:pl-20 px-2 w-200 mx-auto",children:[h?e.jsx(zr,{upcomingPlans:[r],Icon:i.CreditCard,title:"Current Subscription",badgeText:"Active",isFreePlan:!0}):e.jsxs(e.Fragment,{children:[e.jsx(Pr,{currentPlan:{plan:m,type:12===r.for_months?"yearly":"monthly",startDate:pe(r.startAt),expiryDate:pe(r.endAt),paymentMethod:(g=r.z_payment_method,"netbanking"===g?"Net Banking":"wallet"===g?"Wallet":"upi"===g?"UPI":"card"===g?"Card":g),activePlanFor:r.for_no_users,paidAmount:`${d}${r.amount}`,status:"active",transactionId:(()=>{const e=[r.z_order_id];return r.updatedRecords&&r.updatedRecords.forEach(t=>{"paid"===t.status&&e.push(t.z_order_id)}),e.join(", ")})()},canShowCancelPlanBtn:!1,cancelSubscription:{title:"Cancel Subscription",description:"Are you sure you want to cancel your subscription?",plan:m,onCancel:e=>console.log("Subscription cancelled for plan:",e),onKeepSubscription:e=>console.log("Subscription kept for plan:",e)},addMoreBtnProps:{text:"Add more users to your plan",buttonProps:{onClick:()=>u(!0)},canShow:r.for_no_users<m.maxUserRequired},canShowUpdatePlanBtn:!1,updatePlan:{currentPlan:m,plans:l,triggerText:"Change Plan",onPlanChange:(e,a)=>{t(`/infrastructure/checkout?plan=${e}&billing=${a?"yearly":"monthly"}`)}}}),e.jsx(Ir,{isOpen:c,setIsOpen:u,purchasePlanId:r.purchased_id})]}),e.jsx(zr,{upcomingPlans:x,Icon:i.GalleryVerticalEnd,title:"Upcoming Plans",badgeText:"Upcoming"}),e.jsx(zr,{upcomingPlans:p,Icon:i.History,title:"Expired Plans",badgeText:"Expired"})]})});var g}});const Or=C.cva("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"}},defaultVariants:{variant:"default"}});function Dr({className:t,variant:a,...s}){return e.jsx("div",{"data-slot":"alert",role:"alert",className:ee(Or({variant:a}),t),...s})}function Ar({className:t,...a}){return e.jsx("div",{"data-slot":"alert-title",className:ee("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",t),...a})}function Er({className:t,...a}){return e.jsx("div",{"data-slot":"alert-description",className:ee("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",t),...a})}var Lr=Object.freeze({__proto__:null,default:()=>{const{Razorpay:t}=F.useRazorpay(),{loggedInUser:r,subscriptionConfig:n,activePlan:o}=s.useContext(Pe),[l]=a.useSearchParams(),d=l.get("plan"),c=l.get("billing")||"yearly",u=(()=>{const[e,t]=s.useState([]);return s.useEffect(()=>{(async()=>{const e=re("countries");if(e)try{const a=JSON.parse(e);if(Array.isArray(a))return void t(a)}catch{}const a=(await Ae().get("get-countries")).countries??[];a.length>0&&se("countries",JSON.stringify(a)),t(a)})()},[]),e})(),m=a.useNavigate(),[x,p]=s.useState(!1),[h,g]=s.useState(!1),{plans:f,CURRENCY:b,CURRENCY_SYMBOL:v}=n,j=f.find(e=>e.id===d)||f[0],{minUserRequired:y,maxUserRequired:N}=j,[w,_]=s.useState(c),[C,k]=s.useState(y),S=C<=y?y:C,P="yearly"===w?j.yearlyPrice:j.monthlyPrice,z=S*parseFloat(P),T="yearly"===w?12:1,I=j.monthlyPrice,O=T*S*parseFloat(I),D=s.useRef({fullName:r?.fname+" "+r?.lname,country:"",address:"",email:r?.email,mobileNo:r?.mobNo?.toString()}),{loadPurchasedPlans:A}=Be();if("0"===j.monthlyPrice||"0"===j.yearlyPrice)return e.jsx(a.Navigate,{to:"/"});return e.jsxs(ja,{className:"pb-5",responsive:!0,children:[e.jsxs("div",{className:"sm:mx-auto mx-1 px-5",children:[e.jsxs(Aa,{className:"mb-4",children:['Checkout "',j.title,'" Plan'," ",e.jsx(qa,{className:"text-xs text-primary",to:"/plans",children:"Change Plan"})]}),Me(o)?null:e.jsxs(Dr,{variant:"default",className:"mb-5",children:[e.jsx(i.AlertCircleIcon,{}),e.jsx(Ar,{children:"You currently have an active paid plan."}),e.jsx(Er,{children:e.jsxs("p",{children:["Please be aware that this purchase is for an upcoming plan. Check your"," ",e.jsx(qa,{className:"text-primary",to:"/infrastructure/manage-subscription",children:"current subscription"}),"."]})})]}),e.jsxs(ja,{layout:"horizontal",className:"gap-5",responsive:!0,children:[e.jsxs(ja,{layout:"vertical",className:"sm:w-150 w-full gap-5",doNotAppendFlex1:!0,responsive:!0,children:[e.jsxs(It,{children:[e.jsxs(Ft,{children:[e.jsx(Ot,{children:"Specify billing period and team size"}),e.jsx(Dt,{children:"With yearly plans, you can save up to 17%."})]}),e.jsx(At,{children:e.jsxs("div",{className:"grid gap-6",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Lt,{children:"Billing period *"}),e.jsx(Ga,{triggerClassName:"w-full",placeholder:"Select billing period",items:[{value:"monthly",label:`Monthly - ${j.planDisplayCost?.monthly}`},{value:"yearly",label:`Yearly - ${j.planDisplayCost?.yearly}`}],value:w,onValueChange:e=>_(e)})]}),y>1?e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(Lt,{htmlFor:"teamSize",children:["Team Size (This should be ",y," or > ",y,") *"]}),e.jsx(Et,{type:"number",id:"teamSize",placeholder:"",min:y,max:N,value:C,onChange:e=>k(Math.max(y,parseInt(e.target.value)||y))})]}):e.jsx(e.Fragment,{})]})})]}),e.jsxs(It,{children:[e.jsxs(Ft,{children:[e.jsx(Ot,{children:"Billing Details"}),e.jsx(Dt,{children:"To finalize your subscription, kindly complete your details."})]}),e.jsx(At,{children:e.jsxs("div",{className:"grid gap-6",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Lt,{htmlFor:"fullName",children:"Full Name *"}),e.jsx(Et,{onChange:e=>D.current.fullName=e.currentTarget.value,id:"fullName",type:"text",placeholder:"",name:"fullName",defaultValue:r?.fname+" "+r?.lname})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Lt,{htmlFor:"country",children:"Country *"}),e.jsx(Ga,{valueField:"countryCode",labelField:"countryName",triggerClassName:"w-full",placeholder:"",items:u,onValueChange:e=>{D.current.country=e}})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Lt,{htmlFor:"address",children:"Address *"}),e.jsx(pa,{onChange:e=>D.current.address=e.target.value,id:"address",placeholder:""})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Lt,{htmlFor:"email",children:"Email *"}),e.jsx(Et,{defaultValue:r?.email,onChange:e=>D.current.email=e.target.value,id:"email",type:"email",placeholder:"",name:"email"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Lt,{htmlFor:"mobileNo",children:"Mobile No *"}),e.jsx(Et,{onChange:e=>D.current.mobileNo=e.target.value,id:"mobileNo",type:"number",placeholder:"",name:"mobileNo",defaultValue:r?.mobNo})]})]})})]})]}),e.jsxs(ja,{layout:"vertical",className:"sm:w-80 w-full",doNotAppendFlex1:!0,responsive:!0,children:[e.jsxs(It,{children:[e.jsx(Ft,{children:e.jsx(Ot,{children:"Summary"})}),e.jsx(At,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Subtotal"}),e.jsxs("span",{className:"tabular-nums",children:[v,O.toFixed(2)]})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Discount (Yearly)"}),e.jsxs("span",{className:"tabular-nums",children:["- ",v,(O-z).toFixed(2)]})]}),e.jsxs("div",{className:"flex items-center justify-between border-t pt-2",children:[e.jsx("span",{className:"font-medium",children:"Total"}),e.jsxs("span",{className:"text-xl font-semibold tabular-nums",children:[v,z.toFixed(2)]})]})]})})]}),e.jsxs(vt,{className:"mt-5",onClick:async()=>{const e=(()=>{const e={},t=D.current;return t.fullName.trim()||(e.fullName="Full Name is required."),t.country.trim()||(e.country="Country is required."),t.address.trim()?t.address.trim().length<5&&(e.address="Address must be at least 5 characters."):e.address="Address is required.",t.email.trim()?ue(t.email)||(e.email="Email is invalid."):e.email="Email is required.",t.mobileNo?.toString().trim()?(!/^\d+$/.test(t.mobileNo?.toString())||t.mobileNo?.toString().trim().length<10||t.mobileNo?.toString().trim().length>15)&&(e.mobileNo="Mobile Number is invalid (must be 10-15 digits)."):e.mobileNo="Mobile Number is required.",e})();if(Object.keys(e).length>0)Object.values(e).reverse().forEach(e=>Fe({header:"Invalid Billing Details",description:e}));else try{g(!0);const e=await Ae().post("payment-gateway/create-order",{planId:j.id,currency:b,billingPeriod:w||"yearly",for_no_users:S,billing_name:D.current.fullName,billing_email:D.current.email,billing_contact_no:D.current.mobileNo,billing_address:D.current.address,billing_country:D.current.country}),a=D.current;await $e(z,b,e,{name:a.fullName||`${r.fname} ${r.lname}`,email:a.email||r.email,contact:a.mobileNo?.toString()||r.mobNo?.toString()||""},t),p(!0)}catch(e){Fe({header:"Payment Failed!",description:e?.message})}finally{await A(),g(!1)}},loading:h,children:["Make Payment ",e.jsx(i.ArrowRight,{})]})]})]})]}),e.jsx(Tr,{open:x,onOpenChange:e=>{p(e),e||m("/infrastructure/payment-history")},price:z.toFixed(2),currencySymbol:v,productName:j.title,proceedButtonText:"Go to Dashboard",backButtonText:"Go to Payment History",onProceed:()=>m("/"),onBack:()=>m("/infrastructure/payment-history")})]})}});function Rr({className:t,title:a="Invoice History",description:s="Your past invoices and payment receipts.",invoices:r,onDownload:n}){if(!r)return null;const o=t=>{switch(t){case"paid":return e.jsx(ra,{className:"bg-emerald-600 text-emerald-50 border-emerald-700/40",children:"Paid"});case"refunded":return e.jsx(ra,{variant:"secondary",children:"Refunded"});case"idle":return e.jsx(ra,{variant:"outline",children:"Open"});case"verified":return e.jsx(ra,{variant:"outline",children:"Verified"});case"failed":return e.jsx(ra,{variant:"destructive",children:"Failed"})}};return e.jsxs(It,{className:ee("w-full",t),children:[(a||s)&&e.jsxs(Ft,{className:"space-y-1",children:[a&&e.jsxs(Ot,{className:"text-base font-medium leading-tight truncate flex items-center gap-2 sm:gap-3 text-lg sm:text-xl",children:[e.jsx(i.ReceiptText,{className:"h-4 w-4 text-primary"}),a]}),s&&e.jsx(Dt,{className:"text-sm text-muted-foreground",children:s})]}),e.jsx(At,{children:e.jsxs(_t,{children:[e.jsx(Tt,{className:"sr-only",children:"List of past invoices with dates, amounts, status and download actions"}),e.jsx(Ct,{children:e.jsxs(St,{children:[e.jsx(Pt,{className:"w-[120px]",children:"Date"}),e.jsx(Pt,{className:"text-left",children:"Order ID"}),e.jsx(Pt,{children:"Description"}),e.jsx(Pt,{className:"text-right",children:"Amount"}),e.jsx(Pt,{className:"text-right",children:"Status"}),e.jsx(Pt,{className:"text-right",children:"Action"})]})}),e.jsxs(kt,{children:[0===r.length&&e.jsx(St,{children:e.jsx(zt,{colSpan:6,className:"h-24 text-center text-muted-foreground",children:"No invoices yet"})}),r.map(t=>e.jsxs(St,{className:"group",children:[e.jsx(zt,{className:"text-muted-foreground",children:e.jsxs("div",{className:"inline-flex items-center gap-2",children:[e.jsx(i.CalendarDays,{className:"h-3.5 w-3.5"}),t.date]})}),e.jsx(zt,{className:"text-left",children:t.transactionId}),e.jsx(zt,{className:"max-w-[320px]",children:e.jsx("div",{className:"truncate",title:t.description||"Invoice",children:t.description||"Invoice"})}),e.jsx(zt,{className:"text-right font-medium",children:t.amount}),e.jsx(zt,{className:"text-right",children:o(t.status)}),e.jsx(zt,{className:"text-right",children:e.jsxs(vt,{variant:"outline",size:"sm",className:"h-8 text-xs",onClick:()=>t.invoiceUrl?window.open(t.invoiceUrl,"_blank","noopener,noreferrer"):n?.(t.id),"aria-label":`Download invoice ${t.id}`,children:[e.jsx(i.Download,{className:"h-3.5 w-3.5"}),"Download"]})})]},t.id))]})]})})]})}var Mr=Object.freeze({__proto__:null,default:()=>{const{purchasePlans:t,subscriptionConfig:a}=s.useContext(Pe),{plans:r}=a,n=[];return t.forEach(e=>{const t=r.find(t=>t.id===e.plan_id),a={id:e.z_order_id,date:pe(e.purchased_at),amount:`${Re(e.z_currency)}${e.old_purchased_amount||e.amount} (${e.z_currency})`,status:e.status,description:`${t?.title} — ${e.for_months} months, ${e.old_purchased_for_no_users||e.for_no_users} users`,transactionId:e.z_order_id};e.updatedRecords&&e.updatedRecords.forEach(t=>{n.push({id:t.z_order_id,date:pe(t.updated_at),amount:`${Re(t.z_currency)}${t.amount} (${t.z_currency})`,status:t.status,description:`Added ${t.for_no_users} more users, in ${e.z_order_id}`,transactionId:t.z_order_id})}),n.push(a)}),n.sort((e,t)=>new Date(e.date).getTime()-new Date(t.date).getTime()),e.jsx(ja,{children:e.jsx("div",{className:"w-full sm:max-w-250 mx-auto",children:e.jsx(Rr,{title:"Payment History",description:"Your past payment receipts.",className:"shadow-none border-none",invoices:n.reverse()})})})}});const $r=()=>{const{theme:t,setTheme:a}=ke();return e.jsxs(Rt,{value:t,onValueChange:e=>{a(e)},children:[e.jsx($t,{className:"w-[180px]",children:e.jsx(Mt,{placeholder:"Theme"})}),e.jsxs(Ut,{children:[e.jsx(Bt,{value:"light",children:"Light"}),e.jsx(Bt,{value:"dark",children:"Dark"}),e.jsx(Bt,{value:"system",children:"System"})]})]})};var Ur=Object.freeze({__proto__:null,default:()=>{const{featureFlags:t}=s.useContext(Pe);return e.jsxs(ja,{className:"pr-5 pl-5",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(Ha,{children:"Email Settings"}),e.jsx(Wa,{title:"Security emails",description:"Receive emails about your account security.",control:e.jsx(Qt,{checked:!0,disabled:!0})})]}),e.jsxs("div",{className:"space-y-3 mt-4",children:[e.jsx(Ha,{children:"Theme"}),e.jsx(Wa,{title:"Specify theme",description:"Choose your preferred theme to enhance your reading experience.",control:e.jsx($r,{})})]}),t?.ff_enable_teams&&e.jsxs("div",{className:"space-y-3 mt-4",children:[e.jsx(Ha,{children:e.jsxs(e.Fragment,{children:[Z.account_type_txt.plural," Settings"]})}),e.jsx(qa,{to:"/infrastructure/manage-infra",children:e.jsx(Wa,{title:`Manage ${Z.account_type_txt.plural}`,description:`Create and manage ${Z.account_type_txt.plural}, update ${Z.account_type_txt.singular} details, and invite members as needed.`,control:e.jsx(i.SquareArrowOutUpRight,{}),labelCls:"cursor-pointer"})}),e.jsx(qa,{to:"/infrastructure/user-invitations",children:e.jsx(Wa,{title:"Check Invitations",description:`View and respond to ${Z.account_type_txt.singular} invitations you have received.`,control:e.jsx(i.SquareArrowOutUpRight,{}),labelCls:"cursor-pointer",className:"mt-3"})})]})]})}});exports.AccordionWrapper=Ua,exports.AlertDialog=Nt,exports.Badge=ra,exports.BigSquare=Va,exports.Button=vt,exports.Card=It,exports.CardAction=function({className:t,...a}){return e.jsx("div",{"data-slot":"card-action",className:ee("col-start-2 row-span-2 row-start-1 self-start justify-self-end",t),...a})},exports.CardContent=At,exports.CardDescription=Dt,exports.CardFooter=function({className:t,...a}){return e.jsx("div",{"data-slot":"card-footer",className:ee("flex items-center px-6 [.border-t]:pt-6",t),...a})},exports.CardHeader=Ft,exports.CardTitle=Ot,exports.CenterAndMiddle=({className:t="",children:a})=>e.jsx("div",{className:`flex-1 flex items-center justify-center ${t}`,children:a}),exports.CopyTextField=({copyText:t})=>{const[a,r]=s.useState(!1);return e.jsxs("div",{className:"flex gap-2",children:[e.jsx(pa,{readOnly:!0,value:t}),e.jsx(vt,{variant:"outline",size:"icon",onClick:()=>(async e=>{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),2e3),Ie({description:"Copied to clipboard"})})(t),className:"shrink-0",children:e.jsx("span",{className:"flex items-center",children:a?e.jsx(i.Check,{size:16,className:"text-green-500"}):e.jsx(i.Copy,{size:16})})})]})},exports.DataTable=Oa,exports.DialogWrapper=jt,exports.DropdownBtn=({label:t,children:a,items:s,onItemSelect:r,disabled:n})=>e.jsxs(ia,{children:[e.jsx(oa,{asChild:!0,disabled:n,children:a||e.jsxs(vt,{className:"flex items-center gap-1",children:[t," ",e.jsx(i.ChevronDown,{size:15})]})}),e.jsx(la,{children:s.map(t=>e.jsx(ca,{onClick:()=>r?.(t),children:t.label},t.value))})]}),exports.DropdownLbl=({label:t,selectedRec:a,setSelectedRec:s,items:r})=>e.jsxs(ia,{children:[e.jsx(oa,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-2",children:[t&&e.jsx(Lt,{className:"whitespace-nowrap",children:t}),e.jsxs("span",{className:"whitespace-nowrap text-primary flex items-center gap-1 text-sm cursor-pointer",children:[a.label," ",e.jsx(i.ChevronDown,{size:15})]})]})}),e.jsx(la,{children:r.map(t=>e.jsx(ca,{onClick:()=>s(t),children:t.label},t.value))})]}),exports.DropdownMenu=ia,exports.DropdownMenuCheckboxItem=ua,exports.DropdownMenuContent=la,exports.DropdownMenuGroup=da,exports.DropdownMenuItem=ca,exports.DropdownMenuLabel=ma,exports.DropdownMenuPortal=function({...t}){return e.jsx(q.Portal,{"data-slot":"dropdown-menu-portal",...t})},exports.DropdownMenuRadioGroup=function({...t}){return e.jsx(q.RadioGroup,{"data-slot":"dropdown-menu-radio-group",...t})},exports.DropdownMenuRadioItem=function({className:t,children:a,...s}){return e.jsxs(q.RadioItem,{"data-slot":"dropdown-menu-radio-item",className:ee("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...s,children:[e.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:e.jsx(q.ItemIndicator,{children:e.jsx(i.CircleIcon,{className:"size-2 fill-current"})})}),a]})},exports.DropdownMenuSeparator=xa,exports.DropdownMenuShortcut=function({className:t,...a}){return e.jsx("span",{"data-slot":"dropdown-menu-shortcut",className:ee("text-muted-foreground ml-auto text-xs tracking-widest",t),...a})},exports.DropdownMenuSub=function({...t}){return e.jsx(q.Sub,{"data-slot":"dropdown-menu-sub",...t})},exports.DropdownMenuSubContent=function({className:t,...a}){return e.jsx(q.SubContent,{"data-slot":"dropdown-menu-sub-content",className:ee("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg",t),...a})},exports.DropdownMenuSubTrigger=function({className:t,inset:a,children:s,...r}){return e.jsxs(q.SubTrigger,{"data-slot":"dropdown-menu-sub-trigger","data-inset":a,className:ee("focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8",t),...r,children:[s,e.jsx(i.ChevronRightIcon,{className:"ml-auto size-4"})]})},exports.DropdownMenuTrigger=oa,exports.FlexColsLayout=ja,exports.FullPageLoading=Te,exports.HeaderText=Ha,exports.INVITATION_ENUMS=ye,exports.InfoButton=Ya,exports.Input=Et,exports.Label=Lt,exports.LinkWrapper=qa,exports.ListPanel=Wa,exports.LoadingCmp=ze,exports.LoadingMask=va,exports.PaginationWrapper=Ia,exports.PremiumHighlighter=Ka,exports.RichTextEditor=({value:t,onChange:a,onAICall:r,placeholder:n="Type / for commands or start writing...",className:o="",classNameEditor:l="",minHeight:d="unset",id:c="",enableSlashMenu:u=!1,canShowAIOptions:m=!1,readingMode:j=!1})=>{const y=e=>{if(!N)return;const t=`link-${Math.random().toString(36).slice(2,9)}`;N.chain().focus().insertContent(`<a href="${e}" data-marker="${t}">${e}</a>`).run(),Ae().get(`/link-metadata?url=${encodeURIComponent(e)}`).then(a=>{if(!a)return;const{title:s,image:r=`https://www.google.com/s2/favicons?domain=${e}`,description:n}=a,i=s||e;let o=-1,l=0;N.state.doc.descendants((e,a)=>{if(e.isText){if(e.marks.find(e=>"link"===e.type.name&&e.attrs["data-marker"]===t))return o=a,l=e.nodeSize,!1}return!0}),-1!==o&&N.chain().deleteRange({from:o,to:o+l}).insertContent(`<a href="${e}" data-image="${r||""}" data-description="${n||""}">${i}</a>`).run()}).catch(()=>{N.state.doc.descendants((a,s)=>{if(a.isText){if(a.marks.find(e=>"link"===e.type.name&&e.attrs["data-marker"]===t))return N.chain().deleteRange({from:s,to:s+a.nodeSize}).insertContent(`<a href="${e}">${e}</a>`).run(),!1}return!0})})},N=x.useEditor({editable:!j,extensions:[p.configure({heading:{levels:[1,2,3]}}),h,g.extend({inclusive:!1,addAttributes(){return{...this.parent?.(),"data-marker":{default:null,parseHTML:e=>e.getAttribute("data-marker"),renderHTML:e=>e["data-marker"]?{"data-marker":e["data-marker"]}:{}},"data-image":{default:null,parseHTML:e=>e.getAttribute("data-image"),renderHTML:e=>e["data-image"]?{"data-image":e["data-image"]}:{}},"data-description":{default:null,parseHTML:e=>e.getAttribute("data-description"),renderHTML:e=>e["data-description"]?{"data-description":e["data-description"]}:{}},style:{default:null,parseHTML:e=>e.getAttribute("style"),renderHTML:e=>e.style?{style:e.style}:{}}}},renderHTML({HTMLAttributes:e}){const{"data-image":t,"data-description":a,...s}=e,r=x.mergeAttributes(this.options.HTMLAttributes,s,{"data-image":t,"data-description":a,title:a||""});return t?["a",r,["img",{src:t,width:"16",height:"16"}],["span",0]]:["a",r,0]}}).configure({openOnClick:!1,autolink:!0,HTMLAttributes:{}}),f.configure({placeholder:n,emptyEditorClass:"is-editor-empty"}),...u?[b]:[],v],content:t,onUpdate:({editor:e})=>{a(e.getHTML())},editorProps:{attributes:{class:ee("prose dark:prose-invert max-w-none focus:outline-none min-h-full","selection:bg-primary/30"),id:c},handlePaste:(e,t)=>{const a=t.clipboardData?.getData("text/plain");return!(!a||!(e=>{try{const t=new URL(e);return"http:"===t.protocol||"https:"===t.protocol}catch{return!1}})(a))&&(y(a),!0)}}});if(s.useEffect(()=>{N&&t!==N.getHTML()&&N.commands.setContent(t)},[t,N]),s.useEffect(()=>{N&&N.setEditable(!j)},[N,j]),!N)return null;const[w,_]=s.useState(!1),[C,k]=s.useState(""),S=()=>{const{from:e,to:t}=N.state.selection,a=N.state.doc.textBetween(e,t," "),s=N.getText();r&&r(a,s)},P=()=>{if(""===C)N.chain().focus().extendMarkRange("link").unsetLink().run();else{let e=C;/^https?:\/\//i.test(e)||e.startsWith("/")||e.startsWith("#")||(e="https://"+e);const{empty:t}=N.state.selection;t?y(e):N.chain().focus().extendMarkRange("link").setLink({href:e}).run()}_(!1),k("")},z=()=>{const e=N.getAttributes("link").href;k(e||""),_(!0)};s.useEffect(()=>{const e=e=>{if((e.ctrlKey||e.metaKey)&&"k"===e.key){if(j)return;e.preventDefault(),z()}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[N]);const T=e=>ee("h-8 w-8 p-0 transition-all duration-200",e?"bg-primary text-primary-foreground hover:bg-primary/90":"hover:bg-accent hover:text-accent-foreground");return e.jsx("div",{className:ee("group relative w-full border rounded-md bg-transparent dark:bg-input/30 transition-[color,box-shadow] outline-none shadow-xs","border-input focus-within:border-ring focus-within:ring-ring/50 focus-within:ring-[3px] text-sm",o),style:{minHeight:d},children:e.jsxs("div",{className:ee("px-3 py-2 h-full",j?"cursor-default":"cursor-text",l),onClick:()=>!j&&N.chain().focus().run(),children:[!j&&e.jsx(x.BubbleMenu,{editor:N,tippyOptions:{duration:150,animation:"shift-away",onHidden:()=>_(!1)},className:"flex items-center gap-0.5 bg-popover/90 backdrop-blur-md border border-border rounded-lg shadow-xl p-1 overflow-hidden animate-in fade-in zoom-in duration-200",children:w?e.jsxs("div",{className:"flex items-center gap-1 px-1",onClick:e=>e.stopPropagation(),children:[e.jsx(Et,{type:"text",value:C,onChange:e=>k(e.target.value),placeholder:"Paste or type a link...",className:"h-7 w-48 text-xs border-none focus-visible:ring-0 bg-transparent",autoFocus:!0,onKeyDown:e=>{e.stopPropagation(),"Enter"===e.key&&(e.preventDefault(),P()),"Escape"===e.key&&_(!1)}}),e.jsx(vt,{type:"button",variant:"ghost",size:"sm",onClick:P,className:"h-7 w-7 p-0",children:e.jsx(i.Check,{className:"h-3.5 w-3.5"})}),e.jsx(vt,{type:"button",variant:"ghost",size:"sm",onClick:()=>_(!1),className:"h-7 w-7 p-0",children:e.jsx(i.X,{className:"h-3.5 w-3.5"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(vt,{type:"button",variant:"ghost",size:"sm",onClick:()=>N.chain().focus().toggleBold().run(),className:T(N.isActive("bold")),children:e.jsx(i.Bold,{className:"h-4 w-4"})}),e.jsx(vt,{type:"button",variant:"ghost",size:"sm",onClick:()=>N.chain().focus().toggleItalic().run(),className:T(N.isActive("italic")),children:e.jsx(i.Italic,{className:"h-4 w-4"})}),e.jsx(vt,{type:"button",variant:"ghost",size:"sm",onClick:()=>N.chain().focus().toggleUnderline().run(),className:T(N.isActive("underline")),children:e.jsx(i.Underline,{className:"h-4 w-4"})}),e.jsx(vt,{type:"button",variant:"ghost",size:"sm",onClick:z,className:T(N.isActive("link")),children:e.jsx(i.Link,{className:"h-4 w-4"})}),e.jsx(na,{orientation:"vertical",className:"h-4 mx-1"}),e.jsx(vt,{type:"button",variant:"ghost",size:"sm",onClick:()=>N.chain().focus().toggleBulletList().run(),className:T(N.isActive("bulletList")),children:e.jsx(i.List,{className:"h-4 w-4"})}),e.jsx(vt,{type:"button",variant:"ghost",size:"sm",onClick:()=>{N.chain().focus().deleteRange({from:N.state.selection.from-1,to:N.state.selection.from}).toggleBlockquote().run()},className:T(N.isActive("blockquote")),children:e.jsx(i.Quote,{className:"h-4 w-4"})}),m&&e.jsxs(e.Fragment,{children:[e.jsx(na,{orientation:"vertical",className:"h-4 mx-1"}),e.jsxs(vt,{type:"button",variant:"ghost",size:"sm",onClick:S,className:"h-8 px-2 flex items-center gap-1.5 text-primary hover:bg-primary/10 transition-colors",children:[e.jsx(i.Sparkles,{className:"h-4 w-4 fill-primary/20 animate-pulse"}),e.jsx("span",{className:"text-xs font-semibold",children:"AI Edit"})]})]})]})}),u&&!j&&e.jsxs(x.FloatingMenu,{editor:N,tippyOptions:{duration:150,placement:"bottom-start",offset:[0,8]},shouldShow:({state:e})=>{const{selection:t}=e,{$from:a}=t,s=a.nodeBefore?.text||"";return 1===a.parentOffset&&"/"===s},className:"flex flex-col min-w-[180px] bg-popover border border-border rounded-lg shadow-2xl p-1.5 animate-in slide-in-from-top-2 duration-200 z-50",children:[e.jsx("div",{className:"px-2 py-1.5 text-[10px] font-bold text-muted-foreground uppercase tracking-wider",children:"Quick Actions"}),e.jsx(Ja,{onClick:()=>{N.chain().focus().deleteRange({from:N.state.selection.from-1,to:N.state.selection.from}).toggleHeading({level:1}).run()},icon:e.jsx(i.Heading1,{className:"h-4 w-4"}),label:"Heading 1",shortcut:"H1"}),e.jsx(Ja,{onClick:()=>{N.chain().focus().deleteRange({from:N.state.selection.from-1,to:N.state.selection.from}).toggleHeading({level:2}).run()},icon:e.jsx(i.Heading2,{className:"h-4 w-4"}),label:"Heading 2",shortcut:"H2"}),e.jsx(Ja,{onClick:()=>{N.chain().focus().deleteRange({from:N.state.selection.from-1,to:N.state.selection.from}).toggleBulletList().run()},icon:e.jsx(i.List,{className:"h-4 w-4"}),label:"Bullet List",shortcut:"-"}),e.jsx(Ja,{onClick:()=>{N.chain().focus().deleteRange({from:N.state.selection.from-1,to:N.state.selection.from}).toggleOrderedList().run()},icon:e.jsx(i.ListOrdered,{className:"h-4 w-4"}),label:"Ordered List",shortcut:"1."}),e.jsx(Ja,{onClick:()=>{N.chain().focus().deleteRange({from:N.state.selection.from-1,to:N.state.selection.from}).toggleBlockquote().run()},icon:e.jsx(i.Quote,{className:"h-4 w-4"}),label:"Quote",shortcut:">"}),e.jsx(Ja,{onClick:()=>{N.chain().focus().deleteRange({from:N.state.selection.from-1,to:N.state.selection.from}).run(),z()},icon:e.jsx(i.Link,{className:"h-4 w-4"}),label:"Hyperlink",shortcut:"K"}),e.jsx(na,{className:"my-1"}),m&&e.jsx(Ja,{onClick:()=>{N.chain().focus().deleteRange({from:N.state.selection.from-1,to:N.state.selection.from}).run(),S()},icon:e.jsx(i.Sparkles,{className:"h-4 w-4 text-primary"}),label:"AI Assistant",className:"text-primary hover:bg-primary/10"})]}),e.jsx(x.EditorContent,{editor:N})]})})},exports.Select=Rt,exports.SelectContent=Ut,exports.SelectItem=Bt,exports.SelectLabel=function({className:t,...a}){return e.jsx(R.Label,{"data-slot":"select-label",className:ee("text-muted-foreground px-2 py-1.5 text-xs",t),...a})},exports.SelectListWrapper=Ga,exports.SelectSeparator=function({className:t,...a}){return e.jsx(R.Separator,{"data-slot":"select-separator",className:ee("bg-border pointer-events-none -mx-1 my-1 h-px",t),...a})},exports.SelectTrigger=$t,exports.SelectValue=Mt,exports.Separator=na,exports.Sheet=Ht,exports.SheetContent=Kt,exports.SheetDescription=Jt,exports.SheetHeader=Gt,exports.SheetTitle=Xt,exports.SheetTrigger=function({...t}){return e.jsx(M.Trigger,{"data-slot":"sheet-trigger",...t})},exports.SideKickClient=function({appRoutes:t,publicRoutes:a}){ke();const[r,n]=s.useState(le),[i,o]=s.useState([]),[l,d]=s.useState(),[c,u]=s.useState(),[m,x]=s.useState([]),[p,h]=s.useState(),[g,f]=s.useState({}),[b,v]=s.useState({}),j=s.useCallback(e=>{e&&(se("activeOrgId",String(e.org_id)),u(e))},[u]);return e.jsxs(Pe.Provider,{value:{alertDlgOptions:r,setAlertDlgOptions:n,orgs:i,setOrgs:o,loggedInUser:l||{},setLoggedInUser:d,activeOrg:c,setActiveOrg:j,purchasePlans:m,setPurchasePlans:x,activePlan:p,setActivePlan:h,subscriptionConfig:g,setSubscriptionConfig:f,featureFlags:b,setFeatureFlags:v},children:[e.jsx(it,{appRoutes:t,publicRoutes:a}),e.jsx(Se,{}),e.jsx(Nt,{options:r})]})},exports.SideKickContext=Pe,exports.Skeleton=function({className:t,...a}){return e.jsx("div",{"data-slot":"skeleton",className:ee("bg-accent animate-pulse rounded-md",t),...a})},exports.Switch=Qt,exports.Table=_t,exports.TableBody=kt,exports.TableCaption=Tt,exports.TableCell=zt,exports.TableFooter=function({className:t,...a}){return e.jsx("tfoot",{"data-slot":"table-footer",className:ee("bg-muted/50 border-t font-medium [&>tr]:last:border-b-0",t),...a})},exports.TableHead=Pt,exports.TableHeader=Ct,exports.TableRow=St,exports.Tabs=ha,exports.TabsContent=function({className:t,...a}){return e.jsx(V.Content,{"data-slot":"tabs-content",className:ee("flex-1 outline-none",t),...a})},exports.TabsList=fa,exports.TabsTrigger=ba,exports.TabsWrapper=({tabs:t,variant:a,defaultValue:s})=>e.jsxs(ha,{defaultValue:s,children:[e.jsx(fa,{variant:a,children:t.map(t=>e.jsx(ba,{value:t.value,children:t.title},t.value))}),t.map(t=>e.jsx(y.TabsContent,{value:t.value,children:t.content},t.value))]}),exports.TabularLayout=Da,exports.Textarea=pa,exports.Toolbar=Na,exports.Tooltip=ea,exports.TooltipContent=aa,exports.TooltipProvider=Zt,exports.TooltipTrigger=ta,exports.TooltipWrapper=Xa,exports.TypographyHeading=Aa,exports.TypographyP=Ea,exports.UrlChangesGuard=({isDirty:t,setDirty:r})=>{const n=a.useBlocker(t);return s.useEffect(()=>{const e=e=>{t&&(e.preventDefault(),e.returnValue="")};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[t]),"blocked"===n.state?e.jsx(Nt,{options:{open:!0,text:"Are you sure you want to leave this page?",type:"CONFIRM",onClose:e=>{"CONFIRM"===e?(n?.proceed(),r(!1)):n?.reset()}}}):null},exports.cn=ee,exports.convertServerDateToJS=xe,exports.createIndexedArray=oe,exports.debounce=function(e,t){let a;return function(...s){clearTimeout(a),a=setTimeout(()=>{e.apply(this,s)},t)}},exports.defaultAlertConfig=le,exports.errorLogger=ce,exports.findNavMenu=ie,exports.formatElapsedTime=e=>{const t=(new Date).getTime()-e.getTime(),a=t/36e5,s=t/864e5;return t<3e5?"Just now":a<1?`${Math.floor(t/6e4)} minutes ago`:a<24?`${Math.floor(a)} hours ago`:s<7?`${Math.floor(s)} days ago`:e.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})},exports.formatISODateWithTime24H=pe,exports.generatePublicId=ge,exports.generateRandom4Digits=()=>Math.floor(1e3+9e3*Math.random()).toString(),exports.getAxiosInstance=Ae,exports.getCurrencySymbol=Re,exports.getFormDataByFormEl=te,exports.getLocalStorage=re,exports.getModuleNameFromUrl=_e,exports.isEmailValid=ue,exports.isFunction=ve,exports.isObjectEmpty=Ne,exports.isSameNavItem=ne,exports.isTruthyValue=je,exports.isValidId=we,exports.mapIncrementBy2=be,exports.processEmailsWithValidation=me,exports.setAccountType=e=>{Object.assign(Q,e)},exports.setAppInfo=e=>{Object.assign(Z,e)},exports.setLocalStorage=se,exports.setNavigationItems=(e,t)=>{X.navMain=e,X.virtualChildOf=t||[]},exports.showErrorToast=Fe,exports.showSuccessToast=Ie,exports.showWarningToast=Oe,exports.undoPublicId=fe,exports.updateRolesEnum=e=>{Object.assign(wt,e)},exports.useAlertDialog=yt,exports.useFetchData=Qa,exports.useIsMobile=ya,exports.validatePassword=de,exports.waitTill=(e=3e3)=>new Promise(t=>setTimeout(t,e));
1
+ "use strict";var e=require("react/jsx-runtime"),t=require("sonner"),a=require("react-router"),s=require("react"),r=require("clsx"),n=require("tailwind-merge"),i=require("lucide-react"),o=require("@radix-ui/react-label"),l=require("@radix-ui/react-select"),d=require("@radix-ui/react-dialog"),c=require("@radix-ui/react-switch"),u=require("@radix-ui/react-tooltip"),m=require("@radix-ui/react-separator"),x=require("@tiptap/react"),p=require("@tiptap/starter-kit"),h=require("@tiptap/extension-underline"),g=require("@tiptap/extension-link"),f=require("@tiptap/extension-placeholder"),b=require("@tiptap/extension-bubble-menu"),v=require("@tiptap/extension-floating-menu"),j=require("@radix-ui/react-dropdown-menu"),y=require("@radix-ui/react-tabs"),N=require("@marsidev/react-turnstile"),w=require("@radix-ui/react-collapsible"),_=require("@radix-ui/react-slot"),C=require("class-variance-authority"),k=require("@radix-ui/react-avatar"),S=require("@radix-ui/react-accordion"),P=require("input-otp"),z=require("motion/react"),T=require("@radix-ui/react-radio-group"),I=require("@radix-ui/react-toggle"),F=require("react-razorpay"),O=require("@tanstack/react-table"),D=require("axios");function A(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(a){if("default"!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,Object.freeze(t)}var E=A(s),L=A(o),R=A(l),M=A(d),$=A(c),U=A(u),B=A(m),q=A(j),V=A(y),H=A(w),Y=A(k),W=A(S),K=A(T),G=A(I);const X={navMain:[{title:"Your Work",items:[{title:"Sample",icon:i.SquarePen,url:"sample-documents"},{title:"Sample Saved",icon:i.Bookmark,url:"sample-saved-documents"}]},{title:"Settings",items:[{title:"Documentation",icon:i.BookOpen,items:[{title:"Sample Get Started",url:"sample-doc-get-started"},{title:"Sample Tutorials",url:"sample-tutorials"}]},{title:"Settings",icon:i.Settings2,items:[{title:"Sample General",url:"sample-general-settings"},{title:"Sample Active Plan",url:"sample-active-plan-setting"}]}]}],virtualChildOf:[]},J=(e,t,a)=>{e.forEach(e=>{const{items:s,...r}=e;r.parent=a,t.push(r),s&&J(s,t,r)})},Q={TEAM:"team",ORG:"org"},Z={appId:"gamma_tech",appName:"Gamma Tech",appDescription:"Gamma Tech is a software company that provides a range of services to help businesses grow and succeed.",logo:i.NotebookText,version:"2.0.1",account_type_txt:{singular:"Team",plural:"Teams",value:Q.TEAM},supportEmail:"support@gammatech.com",cloudFareKey:"",razorPayKey:"",themeColor:"#00c950",serverUrl:"http://192.168.31.71:6001"};function ee(...e){return n.twMerge(r.clsx(e))}const te=e=>{const t=new FormData(e);return Object.fromEntries(t.entries())},ae=e=>`${Z.appId}_${e}`,se=(e,t)=>{localStorage.setItem(ae(e),t)},re=e=>localStorage.getItem(ae(e)),ne=(e,t)=>{if(!e)return!1;if(t===e)return!0;return!!X.virtualChildOf.find(a=>a.id===e&&a.parentId===t)},ie=e=>{const t=(()=>{const e=[],t=X.navMain;return J(t,e,void 0),e})(),a=t.find(t=>t.url===e);if(a)return a;const s=X.virtualChildOf.find(t=>t.id===e);return s?t.find(e=>e.url===s.parentId):void 0},oe=e=>Array.from({length:e},(e,t)=>t),le={open:!1,type:"CONFIRM",text:""},de=e=>{const t=/[A-Z]/.test(e),a=/[a-z]/.test(e),s=/[0-9]/.test(e),r=/[!@#$%^&*(),.?":{}|<>]/.test(e);return e.length<8?{valid:!1,message:"Password must be at least 8 characters long."}:t?a?s?r?{valid:!0,message:"Password is valid."}:{valid:!1,message:"Password must contain at least one special character."}:{valid:!1,message:"Password must contain at least one number."}:{valid:!1,message:"Password must contain at least one lowercase letter."}:{valid:!1,message:"Password must contain at least one uppercase letter."}},ce=e=>{console.error(e)},ue=e=>{if(!e)return!1;const t=String(e).toLowerCase().match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);return Array.isArray(t)&&t.length>0},me=e=>{if(!e||"string"!=typeof e)return{validEmails:[],invalidEmails:[],totalProcessed:0};const t=e.replace(/\n/g,"").split(",").map(e=>e.trim()).filter(e=>e.length>0),a=[],s=[];return t.forEach(e=>{ue(e)?a.push(e):s.push(e)}),{validEmails:a,invalidEmails:s,totalProcessed:t.length}},xe=e=>new Date(e),pe=(e,t=!0)=>{if(!e)return"";const a=e instanceof Date?e:xe(e),s=String(a.getDate()).padStart(2,"0"),r=String(a.getMonth()+1).padStart(2,"0"),n=a.getFullYear();let i=a.getHours();const o=String(a.getMinutes()).padStart(2,"0");let l="";t&&(l=i>=12?"PM":"AM",i=i%12||12);const d=String(i).padStart(2,"0");return t?`${s}/${r}/${n}, ${d}:${o} ${l}`:`${s}/${r}/${n}, ${d}:${o}`},he=729444,ge=e=>e*he,fe=e=>Math.floor(e/he),be=(e,t)=>{const a=[];for(let s=0;s<e.length;s+=2){const r=e[s],n=e[s+1];a.push(t(r,n,s))}return a},ve=e=>"function"==typeof e,je=e=>1===e||"1"===e||!0===e,ye=Object.freeze({NOT_SAVED:10,INVITED:0,ACCEPTED:1,REJECTED:2,LEFT:3,text:{10:"Not Saved",0:"Invited",1:"Active (Accepted)",2:"Rejected",3:"Left"},getDisplay(e){return this.text[e]}}),Ne=e=>e&&0===Object.keys(e).length,we=e=>parseInt(e,10)>0,_e=e=>e.split("/")[2];const Ce="active-theme",ke=(e=(()=>re(Ce)||"system")())=>{const[t,a]=s.useState(e);return s.useEffect(()=>{const e=window.document.documentElement;e.classList.remove("light","dark");let a=t;"system"===t&&(a=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),e.classList.add(a),se(Ce,a)},[t]),{theme:t,setTheme:a}},Se=({...a})=>{const{theme:s="system"}=ke();return e.jsx(t.Toaster,{theme:s,position:"top-center",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},...a})},Pe=s.createContext({setAlertDlgOptions:()=>{},alertDlgOptions:le,orgs:[],setOrgs:()=>{},loggedInUser:null,setLoggedInUser:()=>{},activeOrg:void 0,setActiveOrg:()=>{},purchasePlans:[],setPurchasePlans:()=>{},activePlan:null,setActivePlan:()=>{},subscriptionConfig:{},setSubscriptionConfig:()=>{},featureFlags:{},setFeatureFlags:()=>{}}),ze=()=>e.jsx(i.Loader2Icon,{className:"animate-spin"}),Te=()=>e.jsxs("div",{className:"bg-muted flex min-h-svh flex-col items-center justify-center gap-6",children:[e.jsxs("h3",{className:"scroll-m-20 text-xl font-semibold tracking-tight text-primary inline-flex gap-2",children:[e.jsx("div",{className:"bg-sidebar-primary text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg",children:e.jsx(Z.logo,{className:"size-4"})}),e.jsx("div",{className:"grid flex-1 text-left leading-tight items-center text-foreground",children:Z.appName})]}),e.jsxs("div",{className:"inline-flex gap-1 ml-5",children:[e.jsx(ze,{}),"Loading application..."]})]}),Ie=({header:e="Success",description:a})=>{t.toast.success(e,{description:a})},Fe=({header:e="Error",description:a})=>{t.toast.error(e,{description:a})},Oe=({header:e="Warning",description:a})=>{t.toast.warning(e,{description:a})};let De=null;const Ae=()=>De||(De=D.create({baseURL:Z.serverUrl,headers:{api:re("apiKey")||"","Content-Type":"application/json"}}),De.interceptors.request.use(e=>(e.headers=e.headers||{},e.headers.api=re("apiKey")||"",e)),De.interceptors.response.use(e=>e.data?.response,e=>{if(!e.response)throw Fe({header:e.message||"Network error",description:"Unable to connect with server."}),e;const t=e.response.data;throw Fe({header:Le(t?.error?.errorMsg)||"Server error",description:Le(t.error.solution)||""}),t.error}),De),Ee={auth_users_tbl:{user_id:"User Id",user_email:"User Email",user_mobile_no:"User Mobile Number",user_fname:"User's First Name",user_lname:"User's Last Name",user_is_active:"User Is Active"},auth_organization_tbl:{org_id:Z.account_type_txt.singular+" Id",org_name:Z.account_type_txt.singular+" Name",org_address:Z.account_type_txt.singular+" Address",org_state:Z.account_type_txt.singular+" State",org_country:Z.account_type_txt.singular+" Country",org_external_id:Z.account_type_txt.singular+" External ID",org_gst_in:Z.account_type_txt.singular+" External ID",org_is_deleted:Z.account_type_txt.singular+" Deleted",org_created_by:Z.account_type_txt.singular+" Created By"},auth_organization_users_tbl:{org_user_id:Z.account_type_txt.singular+"User ID",org_id:Z.account_type_txt.singular+"ID",user_id:"User Id",org_user_role_id:Z.account_type_txt.singular+"User Role Id",org_user_is_active:Z.account_type_txt.singular+"User is active",user_opinion:"User Opinion"},auth_invited_users_tbl:{invited_users_id:"Invited Users Id",org_id:Z.account_type_txt.singular+"Id",email:"Email",invited_user_role_id:"Invited user role Id",invited_by_user_id:"Invited by user Id",is_deleted:"Deleted"}},Le=e=>{let t=e;const a=e.matchAll(/(\w+)\.(\w+)/g);for(const e of a){const a=e[0],s=e[1],r=e[2];if(Ee[s]?.[r]){const e=Ee[s][r];t=t.replace(a,e)}}return t=t.replaceAll("key","field"),t},Re=e=>"INR"===e?"₹":"USD"===e?"$":"EUR"===e?"€":"GBP"===e?"£":"AUD"===e||"CAD"===e?"$":"CHF"===e?"₣":"CNY"===e?"¥":"DKK"===e?"kr":"HKD"===e||"NZD"===e?"$":"SEK"===e?"kr":"SGD"===e?"$":"ZAR"===e?"R":"",Me=e=>!e||"starter"===e.plan_id,$e=(e,t,a,s,r)=>new Promise((n,i)=>{const o={key:Z.razorPayKey,amount:100*e,currency:t,order_id:a.orderId,name:Z.appName,description:Z.appDescription,handler:async function(e){try{if(!(await Ae().post("payment-gateway/verify-payment",{orderId:a.orderId,razorpayPaymentId:e.razorpay_payment_id,razorpaySignature:e.razorpay_signature})).success)return i("Payment verification failed.");n(!0)}catch(e){Fe({header:"Payment failed!",description:e?.message||"Payment verification failed."}),i(e)}},prefill:s,theme:{color:Z.themeColor},modal:{ondismiss:function(){i(new Error("Payment cancelled!"))}}},l=new r(o);l.on("payment.failed",function(e){Fe({header:"Payment Failed!",description:e.error.description||"Payment could not be processed."}),Ae().post("payment-gateway/log-failure",{orderId:a.orderId,errorCode:e.error.code,errorDescription:e.error.description,errorReason:e.error.reason,paymentId:e.metadata?.payment_id}).catch(()=>{})}),l.open()}),Ue=e=>("paid"!==e.status||(e.startAt=new Date(e.startAt),e.endAt=new Date(e.endAt),e.old_purchased_amount=Number(e.amount),e.updatedRecords&&e.updatedRecords.forEach(t=>{e.amount=Number(e.amount)+Number(t.amount)})),e),Be=()=>{const{setPurchasePlans:e,setActivePlan:t,featureFlags:a,activePlan:r,activeOrg:n}=s.useContext(Pe);return{loadPurchasedPlans:s.useCallback(async(s=!1)=>{if(!s&&!a.ff_enable_paid_subscription)return;const r=await Ae().get("/purchased-plans");r.purchasedPlans.forEach(Ue),e([...r.purchasedPlans||[]].reverse()),t(Ue(r.activePlan))},[e,t,a.ff_enable_paid_subscription]),isActiveOrgFreePlan:s.useCallback(()=>Me(n?.active_purchased_plan),[n]),isUserFreePlan:s.useCallback(()=>Me(r),[r])}},qe=({children:t})=>{const[r,n]=s.useState(!0),i=a.useLocation(),{orgs:o,setOrgs:l,loggedInUser:d,setLoggedInUser:c,setActiveOrg:u,subscriptionConfig:m,setSubscriptionConfig:x,featureFlags:p,setFeatureFlags:h}=s.useContext(Pe),{loadPurchasedPlans:g}=Be();return s.useEffect(()=>{(async()=>{try{await new Promise(e=>setTimeout(e,200));const e=await Ae().get("/feature-flags");h(e.featureFlags);const t=await Ae().get("/check-session"),a=!!t.sessionInfo?.id;if(c({email:t.user.user_email,id:t.sessionInfo?.id,fname:t.user.user_fname,lname:t.user.user_lname,mobNo:String(t.user.user_mobile_no)}),!0===a&&(e.featureFlags.ff_enable_paid_subscription&&await g(!0),e.featureFlags.ff_enable_teams)){const e=await Ae().get("organization"),t=e?.orgs||[];l(t);const a=re("activeOrgId");let s=t[0];a&&(s=t.find(e=>String(e.org_id)===a)||s),u(s)}if(e.featureFlags.ff_enable_paid_subscription&&"plans"in m==!1){const e=await Ae().get("/get-subscription-config");x(e)}}finally{n(!1)}})()},[]),r?e.jsx(Te,{}):d?.id?p.ff_enable_teams&&0===o.length&&!i.pathname.includes("infrastructure")?e.jsx(a.Navigate,{to:p.ff_enable_paid_subscription?"/infrastructure/manage-subscription":"/infrastructure",state:{from:i},replace:!0}):t:e.jsx(a.Navigate,{to:"/login",state:{from:i},replace:!0})},Ve=s.lazy(()=>Promise.resolve().then(function(){return Za})),He=s.lazy(()=>Promise.resolve().then(function(){return es})),Ye=s.lazy(()=>Promise.resolve().then(function(){return os})),We=s.lazy(()=>Promise.resolve().then(function(){return Xs})),Ke=s.lazy(()=>Promise.resolve().then(function(){return Js})),Ge=s.lazy(()=>Promise.resolve().then(function(){return Zs})),Xe=s.lazy(()=>Promise.resolve().then(function(){return er})),Je=s.lazy(()=>Promise.resolve().then(function(){return rr})),Qe=s.lazy(()=>Promise.resolve().then(function(){return nr})),Ze=s.lazy(()=>Promise.resolve().then(function(){return lr})),et=s.lazy(()=>Promise.resolve().then(function(){return dr})),tt=s.lazy(()=>Promise.resolve().then(function(){return Nr}).then(e=>({default:e.PricingTbl}))),at=s.lazy(()=>Promise.resolve().then(function(){return Fr})),st=s.lazy(()=>Promise.resolve().then(function(){return Lr})),rt=s.lazy(()=>Promise.resolve().then(function(){return Mr})),nt=s.lazy(()=>Promise.resolve().then(function(){return Ur}));function it({appRoutes:t,publicRoutes:r=[]}){const{featureFlags:n}=s.useContext(Pe),i=a.createBrowserRouter([{path:"/",element:e.jsx(qe,{children:e.jsx(We,{})}),children:[...t,{path:"app/general-settings",Component:nt},{path:"app/*",element:e.jsx(Ke,{canShowHeader:!1})}]},...!1===n.ff_enable_paid_subscription?[]:[{path:"plans",Component:tt}],...r,{path:"infrastructure",element:e.jsx(qe,{children:e.jsx(Ze,{})}),children:[...!1===n.ff_enable_teams?[]:[{index:!0,Component:Xe},{path:"create-new-org",Component:Je},{path:"edit-org/:orgId",Component:Je},{path:"user-invitations",Component:Qe},{path:"manage-infra",Component:et}],...!1===n.ff_enable_paid_subscription?[]:[{path:"manage-subscription",Component:at},{path:"checkout",Component:st},{path:"payment-history",Component:rt}]]},{Component:Ve,children:[{path:"login",Component:He},{path:"forgot-password",Component:Ge},{path:"register",Component:Ye}]},{path:"*",Component:Ke}]);return e.jsx(s.Suspense,{fallback:e.jsx(Te,{}),children:e.jsx(a.RouterProvider,{router:i})})}function ot({...t}){return e.jsx(M.Root,{"data-slot":"dialog",...t})}function lt({...t}){return e.jsx(M.Trigger,{"data-slot":"dialog-trigger",...t})}function dt({...t}){return e.jsx(M.Portal,{"data-slot":"dialog-portal",...t})}function ct({...t}){return e.jsx(M.Close,{"data-slot":"dialog-close",...t})}function ut({className:t,...a}){return e.jsx(M.Overlay,{"data-slot":"dialog-overlay",className:ee("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...a})}function mt({className:t,children:a,showCloseButton:s=!0,...r}){return e.jsxs(dt,{"data-slot":"dialog-portal",children:[e.jsx(ut,{}),e.jsxs(M.Content,{"data-slot":"dialog-content",className:ee("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",t),...r,children:[a,s&&e.jsxs(M.Close,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[e.jsx(i.XIcon,{}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function xt({className:t,...a}){return e.jsx("div",{"data-slot":"dialog-header",className:ee("flex flex-col gap-2 text-center sm:text-left",t),...a})}function pt({className:t,...a}){return e.jsx("div",{"data-slot":"dialog-footer",className:ee("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...a})}function ht({className:t,...a}){return e.jsx(M.Title,{"data-slot":"dialog-title",className:ee("text-lg leading-none font-semibold",t),...a})}function gt({className:t,...a}){return e.jsx(M.Description,{"data-slot":"dialog-description",className:ee("text-muted-foreground text-sm",t),...a})}const ft=C.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline",linkNoUnderline:"text-primary underline-offset-4"},size:{default:"h-8 px-4 py-2 has-[>svg]:px-3",sm:"h-7 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-9 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function bt({className:t,variant:a,size:s,asChild:r=!1,...n}){const i=r?_.Slot:"button";return e.jsx(i,{"data-slot":"button",className:ee(ft({variant:a,size:s,className:t}),"cursor-pointer"),...n})}function vt({loading:t=!1,children:a,...s}){return e.jsxs(bt,{...s,disabled:t||s.disabled,children:[t&&e.jsx(ze,{}),a]})}const jt=({open:t,setIsOpen:a,header:s,children:r,actionsJSX:n,disableOutsideClick:i=!1,dlgContentClsName:o})=>e.jsx(ot,{open:t,onOpenChange:e=>a(!0===e),children:e.jsxs(mt,{"aria-describedby":"dialog-content",onPointerDownOutside:e=>{i&&e.preventDefault()},className:o,children:[e.jsx(xt,{children:e.jsx(ht,{children:s})}),r,e.jsx(pt,{children:n})]})}),yt=()=>{const e=s.useContext(Pe),t=t=>{e.setAlertDlgOptions({...t,open:!0})};return{showAlertBox:t,closeAlertBox:()=>{e.setAlertDlgOptions({...e.alertDlgOptions,open:!1})},showAlertDlgPromise:async e=>new Promise((a,s)=>{t({...e,async onClose(e){"CONFIRM"===e?a(e):s(e)}})})}},Nt=({options:t})=>{const a=yt(),s=()=>{a.closeAlertBox(),t.onClose&&t.onClose("CANCEL")};return e.jsx(jt,{open:t.open,setIsOpen:s,header:"ALERT"===t.type?"Alert":"Confirmation",actionsJSX:e.jsxs(e.Fragment,{children:[e.jsx(vt,{onClick:s,variant:"ghost",children:"Cancel"}),"CONFIRM"===t.type&&e.jsx(vt,{onClick:()=>{a.closeAlertBox(),t.onClose&&t.onClose("CONFIRM")},children:"Confirm"})]}),children:e.jsx(gt,{className:"mt-3",children:t.text})})};const wt={READ:0,ADMIN:1,WRITE:2,Is_ADMIN:function(e){return e===this.ADMIN},CAN_WRITE:function(e){return e===this.WRITE||e===this.ADMIN},CAN_READ:function(e){return e===this.READ||e===this.WRITE||e===this.ADMIN},DISPLAY_TEXT:function(e){return{[this.READ]:"Read",[this.WRITE]:"Read / Write",[this.ADMIN]:Z.account_type_txt.singular+" Admin"}[e]||""},IS_VALID_ROLE_ID:function(e){return e===this.READ||e===this.ADMIN||e===this.WRITE},GET_LIST:function(){return[{id:this.READ.toString(),text:this.DISPLAY_TEXT(this.READ)},{id:this.WRITE.toString(),text:this.DISPLAY_TEXT(this.WRITE)},{id:this.ADMIN.toString(),text:this.DISPLAY_TEXT(this.ADMIN)}]}};function _t({className:t,...a}){return e.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto flex-1",children:e.jsx("table",{"data-slot":"table",className:ee("w-full caption-bottom text-sm",t),...a})})}function Ct({className:t,...a}){return e.jsx("thead",{"data-slot":"table-header",className:ee("[&_tr]:border-b",t),...a})}function kt({className:t,...a}){return e.jsx("tbody",{"data-slot":"table-body",className:ee("[&_tr:last-child]:border-0",t),...a})}function St({className:t,...a}){return e.jsx("tr",{"data-slot":"table-row",className:ee("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",t),...a})}function Pt({className:t,...a}){return e.jsx("th",{"data-slot":"table-head",className:ee("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...a})}function zt({className:t,...a}){return e.jsx("td",{"data-slot":"table-cell",className:ee("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...a})}function Tt({className:t,...a}){return e.jsx("caption",{"data-slot":"table-caption",className:ee("text-muted-foreground mt-4 text-sm",t),...a})}function It({className:t,...a}){return e.jsx("div",{"data-slot":"card",className:ee("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",t),...a})}function Ft({className:t,...a}){return e.jsx("div",{"data-slot":"card-header",className:ee("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",t),...a})}function Ot({className:t,...a}){return e.jsx("div",{"data-slot":"card-title",className:ee("leading-none font-semibold",t),...a})}function Dt({className:t,...a}){return e.jsx("div",{"data-slot":"card-description",className:ee("text-muted-foreground text-sm",t),...a})}function At({className:t,...a}){return e.jsx("div",{"data-slot":"card-content",className:ee("px-6",t),...a})}function Et({className:t,type:a,...s}){return e.jsx("input",{type:a,"data-slot":"input",className:ee("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",t),...s})}function Lt({className:t,...a}){return e.jsx(L.Root,{"data-slot":"label",className:ee("flex items-center gap-2 text-sm leading-none font-medium",t),...a})}function Rt({...t}){return e.jsx(R.Root,{"data-slot":"select",...t})}function Mt({...t}){return e.jsx(R.Value,{"data-slot":"select-value",...t})}function $t({className:t,size:a="default",children:s,...r}){return e.jsxs(R.Trigger,{"data-slot":"select-trigger","data-size":a,className:ee("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...r,children:[s,e.jsx(R.Icon,{asChild:!0,children:e.jsx(i.ChevronDownIcon,{className:"size-4 opacity-50"})})]})}function Ut({className:t,children:a,position:s="popper",...r}){return e.jsx(R.Portal,{children:e.jsxs(R.Content,{"data-slot":"select-content",className:ee("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md","popper"===s&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:s,...r,children:[e.jsx(qt,{}),e.jsx(R.Viewport,{className:ee("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:a}),e.jsx(Vt,{})]})})}function Bt({className:t,children:a,...s}){return e.jsxs(R.Item,{"data-slot":"select-item",className:ee("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",t),...s,children:[e.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:e.jsx(R.ItemIndicator,{children:e.jsx(i.CheckIcon,{className:"size-4"})})}),e.jsx(R.ItemText,{children:a})]})}function qt({className:t,...a}){return e.jsx(R.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:ee("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(i.ChevronUpIcon,{className:"size-4"})})}function Vt({className:t,...a}){return e.jsx(R.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:ee("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(i.ChevronDownIcon,{className:"size-4"})})}function Ht({...t}){return e.jsx(M.Root,{"data-slot":"sheet",...t})}function Yt({...t}){return e.jsx(M.Portal,{"data-slot":"sheet-portal",...t})}function Wt({className:t,...a}){return e.jsx(M.Overlay,{"data-slot":"sheet-overlay",className:ee("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...a})}function Kt({className:t,children:a,side:s="right",...r}){return e.jsxs(Yt,{children:[e.jsx(Wt,{}),e.jsxs(M.Content,{"data-slot":"sheet-content",className:ee("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500","right"===s&&"data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm","left"===s&&"data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm","top"===s&&"data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b","bottom"===s&&"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",t),...r,children:[a,e.jsxs(M.Close,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none",children:[e.jsx(i.XIcon,{className:"size-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Gt({className:t,...a}){return e.jsx("div",{"data-slot":"sheet-header",className:ee("flex flex-col gap-1.5 p-4",t),...a})}function Xt({className:t,...a}){return e.jsx(M.Title,{"data-slot":"sheet-title",className:ee("text-foreground font-semibold",t),...a})}function Jt({className:t,...a}){return e.jsx(M.Description,{"data-slot":"sheet-description",className:ee("text-muted-foreground text-sm",t),...a})}function Qt({className:t,...a}){return e.jsx($.Root,{"data-slot":"switch",className:ee("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...a,children:e.jsx($.Thumb,{"data-slot":"switch-thumb",className:ee("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}function Zt({delayDuration:t=0,...a}){return e.jsx(U.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...a})}function ea({delayDuration:t,...a}){return e.jsx(Zt,{delayDuration:t,children:e.jsx(U.Root,{"data-slot":"tooltip",...a})})}function ta({...t}){return e.jsx(U.Trigger,{"data-slot":"tooltip-trigger",...t})}function aa({className:t,sideOffset:a=0,children:s,...r}){return e.jsx(U.Portal,{children:e.jsxs(U.Content,{"data-slot":"tooltip-content",sideOffset:a,className:ee("bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",t),...r,children:[s,e.jsx(U.Arrow,{className:"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const sa=C.cva("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",success:"border-transparent bg-primary/10 text-primary [a&]:hover:bg-primary/20",failure:"border-transparent bg-destructive/10 text-destructive [a&]:hover:bg-destructive/20"}},defaultVariants:{variant:"default"}});function ra({className:t,variant:a,asChild:s=!1,...r}){const n=s?_.Slot:"span";return e.jsx(n,{"data-slot":"badge",className:ee(sa({variant:a}),t),...r})}function na({className:t,orientation:a="horizontal",decorative:s=!0,...r}){return e.jsx(B.Root,{"data-slot":"separator",decorative:s,orientation:a,className:ee("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",t),...r})}function ia({...t}){return e.jsx(q.Root,{"data-slot":"dropdown-menu",...t})}function oa({...t}){return e.jsx(q.Trigger,{"data-slot":"dropdown-menu-trigger",...t})}function la({className:t,sideOffset:a=4,...s}){return e.jsx(q.Portal,{children:e.jsx(q.Content,{"data-slot":"dropdown-menu-content",sideOffset:a,className:ee("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",t),...s})})}function da({...t}){return e.jsx(q.Group,{"data-slot":"dropdown-menu-group",...t})}function ca({className:t,inset:a,variant:s="default",...r}){return e.jsx(q.Item,{"data-slot":"dropdown-menu-item","data-inset":a,"data-variant":s,className:ee("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...r})}function ua({className:t,children:a,checked:s,...r}){return e.jsxs(q.CheckboxItem,{"data-slot":"dropdown-menu-checkbox-item",className:ee("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),checked:s,...r,children:[e.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:e.jsx(q.ItemIndicator,{children:e.jsx(i.CheckIcon,{className:"size-4"})})}),a]})}function ma({className:t,inset:a,...s}){return e.jsx(q.Label,{"data-slot":"dropdown-menu-label","data-inset":a,className:ee("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",t),...s})}function xa({className:t,...a}){return e.jsx(q.Separator,{"data-slot":"dropdown-menu-separator",className:ee("bg-border -mx-1 my-1 h-px",t),...a})}function pa({className:t,...a}){return e.jsx("textarea",{"data-slot":"textarea",className:ee("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),...a})}function ha({className:t,orientation:a="horizontal",...s}){return e.jsx(V.Root,{"data-slot":"tabs","data-orientation":a,orientation:a,className:ee("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",t),...s})}const ga=C.cva("rounded-lg p-[3px] group-data-[orientation=horizontal]/tabs:h-9 data-[variant=line]:rounded-none group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function fa({className:t,variant:a="default",...s}){return e.jsx(V.List,{"data-slot":"tabs-list","data-variant":a,className:ee(ga({variant:a}),t),...s})}function ba({className:t,...a}){return e.jsx(V.Trigger,{"data-slot":"tabs-trigger",className:ee("focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-foreground/60 hover:text-foreground dark:text-muted-foreground dark:hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","data-[state=active]:bg-background dark:data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 data-[state=active]:text-foreground","after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",t),...a})}const va=()=>e.jsxs("div",{className:"absolute inset-0 flex items-center justify-center",children:[e.jsx(ze,{}),"  Loading..."]}),ja=({className:t,layout:a="vertical",loading:s,doNotAppendFlex1:r=!1,responsive:n=!1,...i})=>{const o="horizontal"===a?!0===n?"sm:flex-row flex-col":"flex-row":"flex-col",l=r?"":"flex-1",d=a=>e.jsx("div",{className:`${l} flex ${o} items-stretch overflow-auto ${a||""} ${t}`,...i});if(!s)return d();const c=s?"pointer-events-none opacity-50":"";return e.jsxs("div",{className:"relative flex-1",children:[s&&e.jsx(va,{}),d(c)]})};function ya(){const[e,t]=E.useState(void 0);return E.useEffect(()=>{const e=window.matchMedia("(max-width: 767px)"),a=()=>{t(window.innerWidth<768)};return e.addEventListener("change",a),t(window.innerWidth<768),()=>e.removeEventListener("change",a)},[]),!!e}const Na=({leftItems:t=[],centerItems:a=[],rightItems:r=[],className:n="",style:o={}})=>{const l=ya(),[d,c]=s.useState(!1),u=[...t,...a,...r];return e.jsx("div",{className:`flex items-center w-full ${n}`,style:{minHeight:48,...o},children:l?e.jsxs("div",{className:"flex w-full justify-end items-center",children:[e.jsx(vt,{type:"button",onClick:()=>c(!0),children:e.jsx(i.Menu,{})}),e.jsx(jt,{open:d,setIsOpen:c,header:"Menu",actionsJSX:e.jsx(e.Fragment,{}),disableOutsideClick:!1,children:e.jsx("div",{className:"flex flex-col gap-5 mt-2",children:u.map((t,a)=>e.jsx("div",{children:t},a))})})]}):e.jsxs(e.Fragment,{children:[t.length>0&&e.jsx("div",{className:"flex flex-1 items-center gap-2 justify-start px-1",children:t}),a.length>0&&e.jsx("div",{className:"flex flex-1 items-center gap-2 justify-center px-1",children:a}),r.length>0&&e.jsx("div",{className:"flex flex-1 items-center gap-2 justify-end px-1",children:r})]})})};function wa({table:t,canShowSearchField:a=!0,searchFieldConfig:s={},canShowColumnsBtn:r=!1,additionalJSX:n,rawColumns:o,refreshBtn:l={canShow:!1,onClick:()=>{}}}){const d=e=>o.find(t=>t.id===e),c=ya();return e.jsx(ja,{className:"px-1 py-2 gap-2",layout:c?"vertical":"horizontal",doNotAppendFlex1:!0,children:e.jsx(Na,{leftItems:[a&&s.searchField?e.jsx(Et,{placeholder:s.placeholder,value:t.getColumn(s.searchField)?.getFilterValue()??"",onChange:e=>{const a=t.getColumn(s.searchField);a?.setFilterValue(e.target.value)},className:"max-w-sm"},"searchField"):e.jsx(e.Fragment,{}),l.canShow&&e.jsxs(vt,{variant:"ghost",onClick:l.onClick,children:[e.jsx(i.RefreshCcw,{})," Refresh"]},"refreshBtn")],rightItems:[r&&e.jsxs(ia,{children:[e.jsx(oa,{asChild:!0,children:e.jsxs(vt,{variant:"ghost",children:["Columns ",e.jsx(i.ChevronDown,{})]},"columnsBtn")}),e.jsx(la,{align:"end",children:t.getAllColumns().filter(e=>e.getCanHide()&&d(e.id)?.enableHiding).map(t=>e.jsx(ua,{checked:t.getIsVisible(),onCheckedChange:e=>t.toggleVisibility(!!e),children:d(t.id)?.headerText||""},t.id))})]},"columnsBtnDropDown"),...n]})})}function _a({className:t,...a}){return e.jsx("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:ee("mx-auto flex w-full justify-center",t),...a})}function Ca({className:t,...a}){return e.jsx("ul",{"data-slot":"pagination-content",className:ee("flex flex-row items-center gap-1",t),...a})}function ka({...t}){return e.jsx("li",{"data-slot":"pagination-item",...t})}function Sa({className:t,isActive:a,size:s="icon",...r}){return e.jsx("a",{"aria-current":a?"page":void 0,"data-slot":"pagination-link","data-active":a,className:ee(ft({variant:a?"outline":"ghost",size:s}),"cursor-pointer",t),...r})}function Pa({className:t,...a}){return e.jsxs(Sa,{"aria-label":"Go to previous page",size:"default",className:ee("gap-1 px-2.5 sm:pl-2.5",t),...a,children:[e.jsx(i.ChevronLeftIcon,{}),e.jsx("span",{className:"hidden sm:block",children:"Previous"})]})}function za({className:t,...a}){return e.jsxs(Sa,{"aria-label":"Go to next page",size:"default",className:ee("gap-1 px-2.5 sm:pr-2.5",t),...a,children:[e.jsx("span",{className:"hidden sm:block",children:"Next"}),e.jsx(i.ChevronRightIcon,{})]})}function Ta({className:t,...a}){return e.jsxs("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:ee("flex size-9 items-center justify-center",t),...a,children:[e.jsx(i.MoreHorizontalIcon,{className:"size-4"}),e.jsx("span",{className:"sr-only",children:"More pages"})]})}const Ia=({totalCount:t,activePage:a,pageSize:r,onPageChange:n})=>{const i=s.useMemo(()=>Math.ceil(t/r),[t,r]),o=e=>{e<0||e>=i||n(e)},l="opacity-50 cursor-not-allowed",d=oe(i).filter(e=>e<a+3&&e>a-3||0===e||e===i-1);return e.jsx(_a,{className:"text-secondary-foreground",children:e.jsxs(Ca,{children:[e.jsx(ka,{children:e.jsx(Pa,{className:0===a?l:"",onClick:()=>o(a-1)})}),d.map((t,r)=>{let n=null;return r>0&&t-d[r-1]!==1&&(n=e.jsx(ka,{children:e.jsx(Ta,{})})),e.jsxs(s.Fragment,{children:[n,e.jsx(ka,{className:a===t?"bg-primary text-primary-foreground rounded-2xl hover:bg-primary":"",children:e.jsx(Sa,{onClick:()=>o(t),children:t+1})})]},t)}),e.jsx(ka,{children:e.jsx(za,{className:a===i-1?l:"",onClick:()=>o(a+1)})})]})})},Fa=({pagination:t,totalCount:a,table:s})=>e.jsx("div",{className:"flex items-center justify-end space-x-2 pt-4",children:e.jsx(Ia,{totalCount:a,activePage:t.pageIndex,onPageChange:e=>{s.setPageIndex(e)},pageSize:t.pageSize})});var Oa=E.memo(function({data:t,columns:a,actions:s,toolbarConfig:r,loading:n=!1,canShowToolbar:o=!0,canShowPagination:l=!0}){const[d,c]=E.useState([]),[u,m]=E.useState([]),[x,p]=E.useState({}),[h,g]=E.useState({}),f=a.map(t=>({accessorKey:t.id,header:({column:a})=>t.enableSorting?e.jsxs(vt,{variant:"ghost",onClick:()=>a.toggleSorting("asc"===a.getIsSorted()),children:[t.headerText,e.jsx(i.ArrowUpDown,{})]}):e.jsx("span",{children:t.headerText}),cell:({row:a})=>{const s=a.getValue(t.id);if(ve(t.renderer))return t.renderer(a,s);let r;return r="boolean"===t.type?s?e.jsx(i.Check,{size:20}):e.jsx(i.X,{size:18}):"date"===t.type?pe(s):String(s),e.jsx("div",{children:r})}}));s&&s.length>0&&f.unshift({id:"actions",enableHiding:!1,cell:({row:t})=>{const a=t.original;return e.jsxs(ia,{children:[e.jsx(oa,{asChild:!0,children:e.jsxs(vt,{variant:"secondary",className:"h-5 w-8 p-0",children:[e.jsx("span",{className:"sr-only",children:"Open menu"}),e.jsx(i.MoreHorizontal,{})]})}),e.jsxs(la,{align:"start",children:[e.jsx(ma,{children:"Actions"}),s.map(t=>"SEPARATOR"===t.headerText?e.jsx(xa,{},t.id):e.jsx(ca,{onClick:()=>t.onClick&&t.onClick(a),children:t.headerText},t.id))]})]})}});const[b,v]=E.useState({pageIndex:0,pageSize:100}),j=O.useReactTable({data:t,columns:f,onSortingChange:c,onColumnFiltersChange:m,getCoreRowModel:O.getCoreRowModel(),getSortedRowModel:O.getSortedRowModel(),getFilteredRowModel:O.getFilteredRowModel(),onColumnVisibilityChange:p,onRowSelectionChange:g,...l&&{getPaginationRowModel:O.getPaginationRowModel(),onPaginationChange:v},state:{sorting:d,columnFilters:u,columnVisibility:x,rowSelection:h,pagination:b}}),y=n?"pointer-events-none opacity-50":"";return e.jsxs(ja,{className:"w-full",children:[o&&e.jsx(wa,{table:j,rawColumns:a,canShowSearchField:!0,canShowColumnsBtn:!0,...r,additionalJSX:r?.additionalJSX||[]}),n&&e.jsx(va,{}),e.jsx(ja,{className:`rounded-md border overflow-auto ${y}`,children:e.jsxs(_t,{children:[e.jsx(Ct,{className:"sticky top-0 bg-sidebar",children:j.getHeaderGroups().map(t=>e.jsx(St,{children:t.headers.map(t=>e.jsx(Pt,{children:t.isPlaceholder?null:O.flexRender(t.column.columnDef.header,t.getContext())},t.id))},t.id))}),e.jsx(kt,{className:"flex-1",children:j.getRowModel().rows?.length?j.getRowModel().rows.map(t=>e.jsx(St,{"data-state":t.getIsSelected()&&"selected",children:t.getVisibleCells().map(t=>e.jsx(zt,{children:O.flexRender(t.column.columnDef.cell,t.getContext())},t.id))},t.id)):e.jsx(St,{children:e.jsx(zt,{colSpan:s&&s.length>0?a.length+1:a.length,className:"h-24 text-center",children:"No results."})})})]})}),l&&e.jsx(Fa,{pagination:b,totalCount:t.length,table:j})]})});const Da=({child:t,className:a,rowCls:s,leftCls:r,rightCls:n})=>e.jsx("div",{className:`w-full ${a||""}`,children:be(t,(t,a,i)=>e.jsxs("div",{className:`flex w-full ${s||""}`,children:[e.jsx("div",{className:`flex-shrink-0 ${r||""}`,children:t}),e.jsx("div",{className:`flex-1 min-w-0 ${n||""}`,children:a})]},i+"tabularLayout"))});function Aa({className:t,...a}){return e.jsx("h4",{className:`scroll-m-20 text-xl font-semibold tracking-tight ${t||""}`,...a})}function Ea({...t}){return e.jsx("p",{className:"leading-7 [&:not(:first-child)]:mt-6",...t})}function La({...t}){return e.jsx(W.Root,{"data-slot":"accordion",...t})}function Ra({className:t,...a}){return e.jsx(W.Item,{"data-slot":"accordion-item",className:ee("border-b last:border-b-0",t),...a})}function Ma({className:t,children:a,...s}){return e.jsx(W.Header,{className:"flex",children:e.jsxs(W.Trigger,{"data-slot":"accordion-trigger",className:ee("focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",t),...s,children:[a,e.jsx(i.ChevronDownIcon,{className:"text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200"})]})})}function $a({className:t,children:a,...s}){return e.jsx(W.Content,{"data-slot":"accordion-content",className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm",...s,children:e.jsx("div",{className:ee("pt-0 pb-4",t),children:a})})}const Ua=({title:t,children:a})=>e.jsx(La,{type:"single",collapsible:!0,children:e.jsxs(Ra,{value:"item-1",children:[e.jsx(Ma,{children:t}),e.jsx($a,{children:a})]})}),Ba=({...t})=>e.jsx("span",{...t}),qa=({className:t,disabled:s,removeAllStyles:r=!1,...n})=>{const i=s?Ba:a.NavLink,o=s?"opacity-40 cursor-not-allowed":"cursor-pointer hover:underline";return e.jsx(i,{className:(t||"")+" "+(r?"":o),...n})},Va=({children:t,toPath:a,disabled:s,className:r,...n})=>e.jsx(qa,{to:a,disabled:s,className:"h-40 p-5 w-60 border-2 border-primary rounded-4xl font-semibold flex flex-col justify-center hover:bg-accent "+r,...n,children:t}),Ha=({children:t})=>e.jsx("h3",{className:"text-lg font-medium",children:t}),Ya=({children:t,side:a})=>e.jsxs(ea,{children:[e.jsx(ta,{asChild:!0,children:e.jsx("span",{className:"ml-2 align-middle cursor-pointer",children:e.jsx(vt,{variant:"link",className:"-ml-5",type:"button",tabIndex:-1,children:e.jsx(i.InfoIcon,{})})})}),e.jsx(aa,{side:a,children:t})]}),Wa=({title:t,description:a,control:s,labelCls:r="",className:n=""})=>e.jsxs("div",{className:`flex flex-row items-center justify-between rounded-lg border p-4 shadow-sm ${n}`,children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(Lt,{className:`cursor-pointer ${r}`,children:t}),e.jsx(Lt,{className:`font-normal text-gray-500 cursor-pointer ${r}`,children:a})]}),e.jsx("div",{children:s})]}),Ka=({children:t})=>e.jsxs("span",{className:`premium-icon-wrapper relative inline-flex items-center ${t?"gap-1":""} px-1.5 py-1.5 rounded-lg bg-gradient-to-br from-amber-400 via-amber-500 to-amber-600 bg-[length:200%_200%] text-xs font-semibold text-white transition-all duration-300 ease-in-out overflow-hidden hover:scale-105 hover:shadow-[0_0_20px_rgba(251,191,36,0.6),0_0_40px_rgba(251,191,36,0.3)] dark:from-amber-900 dark:via-amber-700 dark:to-amber-600 dark:bg-[length:200%_200%]`,children:[e.jsx(i.Crown,{size:14,className:"premium-crown relative z-10 flex-shrink-0 drop-shadow-[0_2px_4px_rgba(0,0,0,0.2)] text-white",strokeWidth:2.5}),e.jsx("span",{className:"relative z-10",children:t})]}),Ga=({placeholder:t,items:a,value:s,onValueChange:r,triggerClassName:n="w-[180px]",valueField:i="value",labelField:o="label",id:l,...d})=>e.jsxs(Rt,{value:s,onValueChange:e=>{r?.(e)},children:[e.jsx($t,{className:n,...d,id:l,children:e.jsx(Mt,{placeholder:t})}),e.jsx(Ut,{children:a.map(t=>e.jsx(Bt,{value:t[i],children:t[o]},t[i]))})]}),Xa=({content:t,side:a="bottom",rootProps:r,contentProps:n,triggerProps:i,children:o,canShowTooltip:l=!0,delayDuration:d=100,triggerOn:c="default"})=>{const[u,m]=s.useState(()=>"default"===c&&(!!l&&void 0)),x=s.useRef(null),p=e=>{"click"===c&&((e=>{const t=e?.target;return t&&x.current&&x.current?.contains(t)})(e)||m(!1))};return e.jsxs(ea,{open:u,delayDuration:d,...r,children:[e.jsx(ta,{"data-testid":"tooltip-trigger",asChild:!0,ref:x,onClick:()=>{"click"===c&&m(l&&!u)},...i,children:o}),e.jsx(aa,{side:a,"data-testid":"tooltip-content",onPointerDownOutside:p,onEscapeKeyDown:p,...n,children:t})]})},Ja=({onClick:t,icon:a,label:s,shortcut:r,className:n})=>e.jsxs("button",{onClick:e=>{e.preventDefault(),e.stopPropagation(),t()},className:ee("flex items-center justify-between w-full px-2 py-1.5 text-sm rounded-md transition-colors","hover:bg-accent hover:text-accent-foreground text-left",n),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex items-center justify-center w-6 h-6 rounded-md bg-muted/50",children:a}),e.jsx("span",{children:s})]}),r&&e.jsx("span",{className:"text-[10px] text-muted-foreground bg-muted px-1.5 py-0.5 rounded uppercase font-medium",children:r})]}),Qa=e=>{const[t,a]=s.useState(null),[r,n]=s.useState(!1);return s.useEffect(()=>{(async()=>{n(!0);try{const t=await Ae().get(e);a(t)}finally{n(!1)}})()},[e]),{loading:r,response:t}};var Za=Object.freeze({__proto__:null,default:function(){return e.jsx("div",{className:"bg-muted flex min-h-svh flex-col items-center justify-center gap-6 p-6 md:p-10",children:e.jsxs("div",{className:"flex w-full max-w-sm flex-col gap-6",children:[e.jsxs("span",{className:"flex items-center gap-2 self-center font-medium",children:[e.jsx("div",{className:"bg-primary text-primary-foreground flex size-6 items-center justify-center rounded-md",children:e.jsx(Z.logo,{className:"size-4"})}),Z.appName]}),e.jsxs("div",{className:ee("flex flex-col gap-6"),children:[e.jsxs(It,{children:[e.jsxs(Ft,{className:"text-center",children:[e.jsx(Ot,{className:"text-xl",children:"Welcome"}),e.jsx(Dt,{children:"Please fill the below details to continue"})]}),e.jsx(At,{children:e.jsx(a.Outlet,{})})]}),e.jsxs("div",{className:"text-muted-foreground *:[a]:hover:text-primary text-center text-xs text-balance *:[a]:underline *:[a]:underline-offset-4",children:["By clicking continue, you agree to our ",e.jsx("a",{children:"Terms of Service"})," and ",e.jsx("a",{children:"Privacy Policy"}),"."]})]})]})})}});var es=Object.freeze({__proto__:null,default:function(){const t=s.useRef(null),r=a.useNavigate(),[n,i]=s.useTransition(),o=a.useLocation(),[l,d]=s.useState(""),c=s.useRef(null),u=o.state?.from,m=u?`${u.pathname}${u.search}${u.hash}`:"/",x="grid gap-1";return s.useEffect(()=>{t?.current?.focus()},[]),e.jsxs("div",{className:"grid gap-6",children:[e.jsx("div",{className:"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t",children:e.jsx("span",{className:"bg-card text-muted-foreground relative z-10 px-2",children:"Login"})}),e.jsxs("form",{onSubmit:async e=>{if(e.preventDefault(),!l)return void Fe({header:"Captcha not completed",description:"Please complete the captcha to proceed."});const t=te(e.currentTarget),a={username:t.email,password:t.password,turnstileToken:l};!1!==ue(a.username)?i(async()=>{try{const e=await Ae().post("/login",a),{api:t=""}=e;if(!t)return Fe({header:"Something went wrong!",description:"API Key not found."}),void ce("API key not found in login command.");Ie({header:"Welcome Back!",description:"Login Successful."}),se("apiKey",t),r(m)}catch(e){c.current?.reset(),d(""),ce(e)}}):Fe({header:"Email is not valid.",description:"Kindly recheck the email and try again."})},className:"grid gap-6",children:[e.jsxs("div",{className:x,children:[e.jsx(Lt,{htmlFor:"email",children:"Email *"}),e.jsx(Et,{id:"email",type:"email",placeholder:"mail@example.com",name:"email",ref:t,required:!0})]}),e.jsxs("div",{className:x,children:[e.jsx(Lt,{htmlFor:"password",children:"Password *"}),e.jsx(Et,{id:"password",type:"password",name:"password",placeholder:"**********",required:!0}),e.jsx(a.NavLink,{to:"/forgot-password",className:"ml-auto text-sm underline-offset-4 hover:underline cursor-pointer",children:"Forgot your password?"})]}),e.jsx("div",{className:"text-center",children:e.jsx(N.Turnstile,{ref:c,siteKey:Z.cloudFareKey,onSuccess:e=>d(e)})}),e.jsx(vt,{type:"submit",className:"w-full",size:"lg",loading:n,children:"Login"})]}),e.jsxs("div",{className:"text-center text-sm",children:["Don't have an account?"," ",e.jsx(a.NavLink,{to:"/register",children:e.jsx("span",{className:"underline underline-offset-4",children:"Register"})})]})]})}});const ts=()=>e.jsxs(Ya,{side:"right",children:[e.jsx("h5",{children:"Password Policy:"}),e.jsxs("ul",{children:[e.jsx("li",{children:"Password must be at least 8 characters long."}),e.jsx("li",{children:"Password must contain at least one uppercase letter."}),e.jsx("li",{children:"Password must contain at least one lowercase letter."}),e.jsx("li",{children:"Password must contain at least one number."}),e.jsx("li",{children:"Password must contain at least one special character."})]})]}),as=({handleOnOTPSent:t,ref:a,gridCls:r,hidden:n,path:i})=>{const o=s.useRef(null),[l,d]=s.useTransition();s.useImperativeHandle(a,()=>({focus(){o.current?.focus()}}),[]);return e.jsxs("form",{onSubmit:async e=>{e.preventDefault();const a={email:te(e.currentTarget).email||""};d(async()=>{try{await(async(e,t)=>{if(!1===ue(t.email))throw Fe({header:"Email is not valid.",description:"Kindly recheck the email and try again."});try{const a=await Ae().post("/send-otp/"+e,t);Ie({header:a.message||"OTP has been sent successfully",description:"Kindly enter below details to continue."})}catch(e){throw ce(e),e}})(i,a),t(a)}catch(e){ce(e)}})},className:`grid gap-5 ${n&&"hidden"}`,children:[e.jsxs("div",{className:r,children:[e.jsx(Lt,{htmlFor:"email",children:"Email *"}),e.jsx(Et,{id:"email",type:"email",name:"email",placeholder:"mail@example.com",ref:o,required:!0})]}),e.jsx(vt,{type:"submit",className:"w-full",loading:l,children:"Generate OTP"})]})};function ss({className:t,containerClassName:a,...s}){return e.jsx(P.OTPInput,{"data-slot":"input-otp",containerClassName:ee("flex items-center gap-2 has-disabled:opacity-50",a),className:ee("disabled:cursor-not-allowed",t),...s})}function rs({className:t,...a}){return e.jsx("div",{"data-slot":"input-otp-group",className:ee("flex items-center",t),...a})}function ns({index:t,className:a,...s}){const r=E.useContext(P.OTPInputContext),{char:n,hasFakeCaret:i,isActive:o}=r?.slots[t]??{};return e.jsxs("div",{"data-slot":"input-otp-slot","data-active":o,className:ee("data-[active=true]:border-ring data-[active=true]:ring-ring/50 data-[active=true]:aria-invalid:ring-destructive/20 dark:data-[active=true]:aria-invalid:ring-destructive/40 aria-invalid:border-destructive data-[active=true]:aria-invalid:border-destructive dark:bg-input/30 border-input relative flex h-9 w-9 items-center justify-center border-y border-r text-sm shadow-xs transition-all outline-none first:rounded-l-md first:border-l last:rounded-r-md data-[active=true]:z-10 data-[active=true]:ring-[3px]",a),...s,children:[n,i&&e.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"animate-caret-blink bg-foreground h-4 w-px duration-1000"})})]})}const is=({className:t,inputOTPField:a,otp:r,setOtp:n,onChangeEmailClick:i})=>{const o=function(e=30){const[t,a]=s.useState(e);return s.useEffect(()=>{if(t>0){const e=setTimeout(()=>a(t-1),1e3);return()=>clearTimeout(e)}},[t]),t}();return e.jsxs("div",{className:t,children:[e.jsx(Lt,{htmlFor:"otp",children:"Enter OTP *"}),e.jsx(ss,{maxLength:4,name:"otp",id:"otp",ref:a,value:r,onChange:n,children:e.jsxs(rs,{children:[e.jsx(ns,{index:0}),e.jsx(ns,{index:1}),e.jsx(ns,{index:2}),e.jsx(ns,{index:3})]})}),e.jsx("span",{className:"text-xs underline-offset-4 italic",children:o>0?e.jsxs("span",{className:"muted-foreground",children:["You can resend the OTP in ",o," seconds."]}):e.jsx("span",{className:"hover:underline cursor-pointer",onClick:()=>i(),children:"Didn't receive the OTP? Send again."})})]})};var os=Object.freeze({__proto__:null,default:function(){const t=s.useRef(null),r="grid gap-1",n=s.useRef(null),[i,o]=s.useState(!1),[l,d]=s.useState(""),[c,u]=s.useState(""),[m,x]=s.useTransition(),p=a.useNavigate();s.useEffect(()=>{i?n.current?.focus():t?.current?.focus()},[i]);const h=()=>{o(!1)};return e.jsxs("div",{className:"grid gap-5",children:[e.jsx("div",{className:"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t",children:e.jsx("span",{className:"bg-card text-muted-foreground relative z-10 px-2",children:"User Registration"})}),e.jsx(as,{ref:t,handleOnOTPSent:e=>{o(!0),u(e.email)},gridCls:r,hidden:i,path:"new-registration"}),i&&e.jsxs("form",{onSubmit:e=>{if(e.preventDefault(),!l)return Fe({header:"OTP Required!",description:"Please enter your OTP and try again."}),void n.current?.focus();const t=te(e.currentTarget);t.otp=l,t.user_email=c;const a=de(t.user_password);!1!==a.valid?x(async()=>{try{await Ae().post("user-registration",t),Ie({header:`Welcome to ${Z.appName}`,description:"Registration successful! Please log in to continue."}),p("/login")}catch(e){ce(e)}}):Fe({header:"Password Policy",description:a.message})},className:"grid gap-5",children:[e.jsxs("div",{className:r,children:[e.jsx(Lt,{htmlFor:"emailOTPGenerated",children:"Email *"}),e.jsx(Et,{id:"emailOTPGenerated",type:"email",name:"email",placeholder:"mail@example.com",value:c,disabled:!0,required:!0}),e.jsx("span",{className:"ml-auto text-xs underline-offset-4 hover:underline cursor-pointer italic",onClick:h,children:"Change Email"})]}),e.jsx(is,{className:r,inputOTPField:n,otp:l,setOtp:d,onChangeEmailClick:h}),e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("div",{className:r+" flex-1",children:[e.jsx(Lt,{htmlFor:"firstName",children:"First Name *"}),e.jsx(Et,{id:"firstName",name:"user_fname",type:"text",required:!0})]}),e.jsxs("div",{className:r+" flex-1",children:[e.jsx(Lt,{htmlFor:"lastName",children:"Last Name *"}),e.jsx(Et,{id:"lastName",name:"user_lname",type:"text",required:!0})]})]}),e.jsxs("div",{className:r,children:[e.jsx(Lt,{htmlFor:"mobile",children:"Mobile No"}),e.jsx(Et,{id:"mobile",type:"number",name:"user_mobile_no",placeholder:"98******88"})]}),e.jsxs("div",{className:r,children:[e.jsxs(Lt,{htmlFor:"password",children:["Set Password * ",e.jsx(ts,{})]}),e.jsx(Et,{id:"password",name:"user_password",type:"password",placeholder:"**********",required:!0})]}),e.jsx(vt,{type:"submit",className:"w-full",size:"lg",loading:m,children:"Create account"})]}),e.jsxs("div",{className:"text-center text-sm",children:["Already have an account?"," ",e.jsx(a.NavLink,{to:"/login",children:e.jsx("span",{className:"underline underline-offset-4",children:"Login"})})]})]})}});function ls({...t}){return e.jsx(H.Root,{"data-slot":"collapsible",...t})}function ds({isCollapsible:t,...a}){return t?e.jsx(H.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...a}):e.jsx(e.Fragment,{children:a.children})}function cs({...t}){return e.jsx(H.CollapsibleContent,{"data-slot":"collapsible-content",...t})}const us=E.createContext(null);function ms(){const e=E.useContext(us);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}function xs({defaultOpen:t=!0,open:a,onOpenChange:s,className:r,style:n,children:i,...o}){const l=ya(),[d,c]=E.useState(!1),[u,m]=E.useState(t),x=a??u,p=E.useCallback(e=>{const t="function"==typeof e?e(x):e;s?s(t):m(t),document.cookie=`sidebar_state=${t}; path=/; max-age=604800`},[s,x]),h=E.useCallback(()=>l?c(e=>!e):p(e=>!e),[l,p,c]);E.useEffect(()=>{const e=e=>{"l"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),h())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[h]);const g=x?"expanded":"collapsed",f=E.useMemo(()=>({state:g,open:x,setOpen:p,isMobile:l,openMobile:d,setOpenMobile:c,toggleSidebar:h}),[g,x,p,l,d,c,h]);return e.jsx(us.Provider,{value:f,children:e.jsx(Zt,{delayDuration:0,children:e.jsx("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":"16rem","--sidebar-width-icon":"3rem",...n},className:ee("group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full",r),...o,children:i})})})}function ps({side:t="left",variant:a="sidebar",collapsible:s="offcanvas",className:r,children:n,...i}){const{isMobile:o,state:l,openMobile:d,setOpenMobile:c}=ms();return"none"===s?e.jsx("div",{"data-slot":"sidebar",className:ee("bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col",r),...i,children:n}):o?e.jsx(Ht,{open:d,onOpenChange:c,...i,children:e.jsxs(Kt,{"data-sidebar":"sidebar","data-slot":"sidebar","data-mobile":"true",className:"bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden",style:{"--sidebar-width":"18rem"},side:t,children:[e.jsxs(Gt,{className:"sr-only",children:[e.jsx(Xt,{children:"Sidebar"}),e.jsx(Jt,{children:"Displays the mobile sidebar."})]}),e.jsx("div",{className:"flex h-full w-full flex-col",children:n})]})}):e.jsxs("div",{className:"group peer text-sidebar-foreground hidden md:block","data-state":l,"data-collapsible":"collapsed"===l?s:"","data-variant":a,"data-side":t,"data-slot":"sidebar",children:[e.jsx("div",{"data-slot":"sidebar-gap",className:ee("relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180","floating"===a||"inset"===a?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon)")}),e.jsx("div",{"data-slot":"sidebar-container",className:ee("fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex","left"===t?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]","floating"===a||"inset"===a?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...i,children:e.jsx("div",{"data-sidebar":"sidebar","data-slot":"sidebar-inner",className:"bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm",children:n})})]})}function hs({className:t,onClick:a,...s}){const{toggleSidebar:r}=ms();return e.jsxs(vt,{"data-sidebar":"trigger","data-slot":"sidebar-trigger",variant:"ghost",size:"icon",className:ee("size-7",t),onClick:e=>{a?.(e),r()},...s,children:[e.jsx(i.PanelLeftIcon,{}),e.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})}function gs({className:t,...a}){const{toggleSidebar:s}=ms();return e.jsx("button",{"data-sidebar":"rail","data-slot":"sidebar-rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:s,title:"Toggle Sidebar",className:ee("hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex","in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",t),...a})}function fs({className:t,...a}){return e.jsx("main",{"data-slot":"sidebar-inset",className:ee("bg-background relative flex w-full flex-1 flex-col","md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",t),...a})}function bs({className:t,...a}){return e.jsx("div",{"data-slot":"sidebar-header","data-sidebar":"header",className:ee("flex flex-col gap-2 p-2",t),...a})}function vs({className:t,...a}){return e.jsx("div",{"data-slot":"sidebar-footer","data-sidebar":"footer",className:ee("flex flex-col gap-2 p-2",t),...a})}function js({className:t,...a}){return e.jsx("div",{"data-slot":"sidebar-content","data-sidebar":"content",className:ee("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",t),...a})}function ys({className:t,...a}){return e.jsx("div",{"data-slot":"sidebar-group","data-sidebar":"group",className:ee("relative flex w-full min-w-0 flex-col p-2",t),...a})}function Ns({className:t,asChild:a=!1,...s}){const r=a?_.Slot:"div";return e.jsx(r,{"data-slot":"sidebar-group-label","data-sidebar":"group-label",className:ee("text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",t),...s})}function ws({className:t,...a}){return e.jsx("ul",{"data-slot":"sidebar-menu","data-sidebar":"menu",className:ee("flex w-full min-w-0 flex-col gap-1",t),...a})}function _s({className:t,...a}){return e.jsx("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:ee("group/menu-item relative",t),...a})}const Cs=C.cva("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-hidden ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-data-[sidebar=menu-action]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function ks({asChild:t=!1,isExpanded:a=!1,variant:s="default",size:r="default",tooltip:n,className:i,...o}){const l=t?_.Slot:"button",d=e.jsx(l,{"data-slot":"sidebar-menu-button","data-sidebar":"menu-button","data-size":r,"data-active":a,className:ee(Cs({variant:s,size:r}),i),...o});return n?("string"==typeof n&&(n={children:n}),e.jsxs(ea,{children:[e.jsx(ta,{asChild:!0,children:d}),e.jsx(aa,{side:"right",align:"center",...n})]})):d}function Ss({className:t,...a}){return e.jsx("ul",{"data-slot":"sidebar-menu-sub","data-sidebar":"menu-sub",className:ee("border-sidebar-border mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",t),...a})}function Ps({className:t,...a}){return e.jsx("li",{"data-slot":"sidebar-menu-sub-item","data-sidebar":"menu-sub-item",className:ee("group/menu-sub-item relative",t),...a})}function zs({asChild:t=!1,size:a="md",isExpanded:s=!1,className:r,...n}){const i=t?_.Slot:"a";return e.jsx(i,{"data-slot":"sidebar-menu-sub-button","data-sidebar":"menu-sub-button","data-size":a,"data-active":s,className:ee("text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 outline-hidden focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground","sm"===a&&"text-xs","md"===a&&"text-sm","group-data-[collapsible=icon]:hidden",r),...n})}function Ts({navItems:t}){const s=a.useLocation().pathname,r=_e(s),n=e=>`app/${e}`,o="bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground",l=t=>{const s=e.jsxs(ks,{tooltip:t.title,className:"cursor-pointer "+(ne(r,t.url||"")?o:""),children:[t.icon&&e.jsx(t.icon,{}),e.jsx("span",{children:t.title}),t.items&&e.jsx(i.ChevronRight,{className:"ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90"})]});return t.url?e.jsx(a.NavLink,{to:n(t.url),className:"w-full",children:s}):s};return e.jsx(e.Fragment,{children:t.map(t=>e.jsxs(ys,{children:[e.jsx(Ns,{children:t.title}),e.jsx(ws,{children:t.items.map(t=>{const s=t.items&&t.items.some(e=>ne(r,e.url));return e.jsx(ls,{asChild:!0,defaultOpen:s,className:"group/collapsible",children:e.jsxs(_s,{children:[e.jsx(ds,{isCollapsible:!!t.items,asChild:!0,children:l(t)}),e.jsx(cs,{children:e.jsx(Ss,{children:t.items?.map(t=>e.jsx(Ps,{children:e.jsx(zs,{asChild:!0,className:ne(r,t.url)?o:"",children:e.jsx(a.NavLink,{to:n(t.url),title:t.title,children:e.jsx("span",{children:t.title})})})},t.title))})})]})},t.title)})})]},t.title))})}function Is({className:t,...a}){return e.jsx(Y.Root,{"data-slot":"avatar",className:ee("relative flex size-8 shrink-0 overflow-hidden rounded-full",t),...a})}function Fs({className:t,...a}){return e.jsx(Y.Image,{"data-slot":"avatar-image",className:ee("aspect-square size-full",t),...a})}function Os({className:t,...a}){return e.jsx(Y.Fallback,{"data-slot":"avatar-fallback",className:ee("bg-muted flex size-full items-center justify-center rounded-full",t),...a})}const Ds=({isDialogOpen:t,setIsDialogOpen:a})=>{const{loggedInUser:r,setLoggedInUser:n}=s.useContext(Pe),[i,o]=s.useState(!1),[l,d]=s.useState(!1),[c,u]=s.useState(null),[m,x]=s.useState({});s.useEffect(()=>{t&&p()},[t]);const p=async()=>{o(!0);try{const e={user_id:r.id,user_email:r.email,user_mobile_no:r.mobNo?.toString()||"",user_fname:r.fname||"",user_lname:r.lname||"",user_is_active:!0,created_at:(new Date).toISOString(),updated_at:(new Date).toISOString()};u(e),x(e)}catch(e){console.error("Error fetching user data:",e)}finally{o(!1)}},h=(e,t)=>{x(a=>({...a,[e]:t}))};return e.jsx(jt,{open:t,setIsOpen:a,header:"Edit User Profile",disableOutsideClick:!0,actionsJSX:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(vt,{variant:"outline",onClick:()=>{x(c||{}),a(!1)},disabled:l,children:"Cancel"}),e.jsx(vt,{onClick:async()=>{d(!0);try{const e={user_mobile_no:m.user_mobile_no,user_fname:m.user_fname,user_lname:m.user_lname};await Ae().put(`/user-profile/${m.user_id}`,e),Ie({header:"Success",description:"User profile updated successfully"}),u(m),n({...r,mobNo:m.user_mobile_no,fname:m.user_fname,lname:m.user_lname}),a(!1)}catch(e){console.error("Error saving user data:",e)}finally{d(!1)}},loading:l,children:"Save Changes"})]}),children:i?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(ze,{}),"Loading user data..."]})}):e.jsxs("div",{className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Lt,{htmlFor:"user_id",children:"User ID"}),e.jsx(Et,{id:"user_id",value:m.user_id?ge(m.user_id):"",disabled:!0,className:"bg-muted"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Lt,{htmlFor:"user_email",children:"Email"}),e.jsx(Et,{id:"user_email",type:"email",value:m.user_email||"",placeholder:"Enter email address",disabled:!0,className:"bg-muted"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Lt,{htmlFor:"user_mobile_no",children:"Mobile Number"}),e.jsx(Et,{id:"user_mobile_no",type:"number",value:m.user_mobile_no||"",onChange:e=>h("user_mobile_no",e.target.value),placeholder:"Enter mobile number"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Lt,{htmlFor:"user_fname",children:"First Name"}),e.jsx(Et,{id:"user_fname",value:m.user_fname||"",onChange:e=>h("user_fname",e.target.value),placeholder:"Enter first name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Lt,{htmlFor:"user_lname",children:"Last Name"}),e.jsx(Et,{id:"user_lname",value:m.user_lname||"",onChange:e=>h("user_lname",e.target.value),placeholder:"Enter last name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Lt,{htmlFor:"created_at",children:"Joined On"}),e.jsx(Et,{id:"created_at",value:m.created_at?new Date(m.created_at).toLocaleString():"",disabled:!0,className:"bg-muted"})]})]})})};function As({fname:t,lname:r,email:n,avatar:o}){const l=a.useNavigate(),{isMobile:d}=ms(),{activePlan:c,featureFlags:u}=s.useContext(Pe),m=`${t} ${r}`,[x,p]=s.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(Ds,{isDialogOpen:x,setIsDialogOpen:p}),e.jsx(ws,{children:e.jsx(_s,{children:e.jsxs(ia,{children:[e.jsx(oa,{asChild:!0,children:e.jsxs(ks,{size:"lg",className:"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",children:[e.jsxs(Is,{className:"h-8 w-8 rounded-lg",children:[e.jsx(Fs,{src:o,alt:m}),e.jsxs(Os,{className:"rounded-lg",children:[t[0].toLocaleUpperCase(),r[0].toLocaleUpperCase()]})]}),e.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[e.jsx("span",{className:"truncate font-medium",children:m}),e.jsx("span",{className:"truncate text-xs",children:n})]}),e.jsx(i.ChevronsUpDown,{className:"ml-auto size-4"})]})}),e.jsxs(la,{className:"w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg",side:d?"bottom":"right",align:"end",sideOffset:4,children:[e.jsx(ma,{className:"p-0 font-normal",children:e.jsxs("div",{className:"flex items-center gap-2 px-1 py-1.5 text-left text-sm",children:[e.jsxs(Is,{className:"h-8 w-8 rounded-lg",children:[e.jsx(Fs,{src:o,alt:m}),e.jsxs(Os,{className:"rounded-lg",children:[t[0].toLocaleUpperCase(),r[0].toLocaleUpperCase()]})]}),e.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[e.jsx("span",{className:"truncate font-medium",children:m}),e.jsx("span",{className:"truncate text-xs",children:n})]})]})}),e.jsx(xa,{}),e.jsxs(ca,{onClick:()=>p(!0),children:[e.jsx(i.CircleUserRound,{}),"Your Profile"]}),u.ff_enable_paid_subscription?e.jsxs(e.Fragment,{children:[e.jsx(xa,{}),e.jsx(da,{children:e.jsxs(ca,{onClick:()=>{setTimeout(()=>{l("/plans")},d?500:0)},children:[e.jsx(i.Sparkle,{}),Me(c)?"Upgrade to premium":"View Plans"]})}),e.jsx(xa,{}),e.jsxs(da,{children:[e.jsxs(ca,{onClick:()=>{setTimeout(()=>{l("/infrastructure/manage-subscription")},d?500:0)},children:[e.jsx(i.BadgeCheck,{}),"Subscriptions"]}),e.jsxs(ca,{onClick:()=>{setTimeout(()=>{l("/infrastructure/payment-history")},d?500:0)},children:[e.jsx(i.CreditCard,{}),"Payment History"]})]})]}):null,e.jsx(xa,{}),e.jsxs(ca,{onClick:()=>{se("apiKey",""),l("/login")},children:[e.jsx(i.LogOut,{}),"Log out"]})]})]})})})]})}const Es=({purchasedPlan:t})=>{const{subscriptionConfig:a,featureFlags:r}=s.useContext(Pe);if(!r.ff_enable_paid_subscription)return null;const n=a.plans.find(e=>e.id===t.plan_id);if(!n)return null;const i=Me(t);return e.jsx(Xa,{delayDuration:20,content:e.jsxs(e.Fragment,{children:["This ",Z.account_type_txt.singular.toLocaleLowerCase(),' is on a "',n.title,'" plan.']}),side:"right",children:e.jsx("div",{children:e.jsx(ra,{variant:"success",children:i?"Free":"Premium"})})})};function Ls(){const{isMobile:t,setOpenMobile:r}=ms(),{orgs:n,activeOrg:o,setActiveOrg:l}=s.useContext(Pe),d=a.useNavigate();return e.jsx(ws,{children:e.jsx(_s,{children:e.jsxs(ia,{children:[e.jsx(oa,{asChild:!0,children:e.jsxs(ks,{size:"lg",className:"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",children:[e.jsx("div",{className:"flex aspect-square size-8 items-center justify-center rounded-lg",children:o?.logo?e.jsx(o.logo,{className:"size-4"}):e.jsx(i.Users2,{className:"size-4"})}),o?e.jsx(Xa,{content:o.org_name+" - "+o.org_external_id,side:"right",canShowTooltip:!0,children:e.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[e.jsx("span",{className:"truncate font-medium",children:o.org_name}),e.jsx("span",{className:"truncate text-xs",children:o.org_external_id})]})}):e.jsxs("div",{className:"truncate text-xs",children:["No Active ",Z.account_type_txt.singular,", select one."]}),o?.active_purchased_plan&&e.jsx("div",{className:"flex items-center justify-center rounded-md border",children:e.jsx(Es,{purchasedPlan:o.active_purchased_plan})}),e.jsx(i.ChevronsUpDown,{className:"ml-auto"})]})}),e.jsxs(la,{className:"w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg",align:"start",side:t?"bottom":"right",sideOffset:4,children:[e.jsx(ma,{className:"text-muted-foreground text-xs",children:Z.account_type_txt.plural}),n.map(t=>e.jsxs(ca,{onClick:()=>l(t),className:"gap-2 p-2",children:[t.logo?e.jsx("div",{className:"flex size-6 items-center justify-center rounded-md border",children:e.jsx(t.logo,{className:"size-3.5 shrink-0"})}):e.jsx(e.Fragment,{}),t.org_name,t.active_purchased_plan&&e.jsx("div",{className:"ml-auto flex items-center justify-center rounded-md border",children:e.jsx(Es,{purchasedPlan:t.active_purchased_plan})})]},t.org_id)),e.jsx(xa,{}),(()=>{const a=[];if(o&&we(o?.org_id||0)){const t=wt.Is_ADMIN(o?.role_id||NaN);a.push({text:e.jsx(e.Fragment,{children:"Invite team members"}),link:`/infrastructure/edit-org/${ge(o?.org_id||0)}`,disabled:!t,icon:e.jsx(i.UserRoundPlus,{className:"size-4"}),tooltip:t?`Invite peoples to "${o.org_name}" ${Z.account_type_txt.singular.toLocaleLowerCase()}`:`You are not an admin for "${o.org_name}" ${Z.account_type_txt.singular.toLocaleLowerCase()}, Only admins can invite peoples.`,key:"invite-peoples"},{text:e.jsxs(e.Fragment,{children:["Edit ",Z.account_type_txt.singular.toLocaleLowerCase()]}),link:`/infrastructure/edit-org/${ge(o?.org_id||0)}`,disabled:!t,icon:e.jsx(i.Pen,{className:"size-4"}),tooltip:t?`Edit "${o.org_name}" ${Z.account_type_txt.singular.toLocaleLowerCase()} details`:`You are not an admin for "${o.org_name}" ${Z.account_type_txt.singular.toLocaleLowerCase()}, Only admins can invite peoples.`,key:"edit-org"})}return a.push({addTopSeparator:!0,text:e.jsxs(e.Fragment,{children:["Create new ",Z.account_type_txt.singular.toLocaleLowerCase()]}),link:"/infrastructure/create-new-org",icon:e.jsx(i.Plus,{className:"size-4"}),key:"create-new-org"},{text:e.jsxs(e.Fragment,{children:["View all ",Z.account_type_txt.plural.toLocaleLowerCase()]}),link:"/infrastructure/manage-infra",icon:e.jsx(i.FolderKanban,{className:"size-4"}),key:"view-all-orgs"},{addTopSeparator:!0,text:e.jsx(e.Fragment,{children:"Check invites"}),link:"infrastructure/user-invitations",icon:e.jsx(i.UserRoundPlus,{className:"size-4"}),key:"check-invitations"}),e.jsx(e.Fragment,{children:a.map(a=>e.jsx(Xa,{content:e.jsx(e.Fragment,{children:a.tooltip}),side:"right",canShowTooltip:!!a.tooltip,children:e.jsxs("div",{children:[a.addTopSeparator?e.jsx(xa,{}):null,e.jsxs(ca,{className:"gap-2 p-2 cursor-pointer",onClick:()=>{r(!1),setTimeout(()=>{a.disabled?Fe({header:"Action not allowed!",description:a.tooltip||"You cannot access this option"}):d(a.link)},t?500:0)},children:[e.jsx("div",{className:"flex size-6 items-center justify-center rounded-md border bg-transparent",title:a.tooltip,children:a.icon}),e.jsx("div",{className:"text-muted-foreground font-medium",children:a.text})]},a.link)]},a.key)},a.key))})})()]})]})})})}function Rs(){return e.jsx(ws,{children:e.jsx(a.NavLink,{to:"/",children:e.jsx(_s,{children:e.jsxs(ks,{size:"lg",className:"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",children:[e.jsx("div",{className:"w-10 h-10 bg-sidebar-primary text-sidebar-primary-foreground rounded-lg flex items-center justify-center",children:e.jsx(Z.logo,{})}),e.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[e.jsx("span",{className:"truncate font-medium",children:Z.appName}),e.jsxs("span",{className:"truncate text-xs",children:["v",Z.version]})]})]})})})})}const Ms=X;function $s({...t}){const{loggedInUser:a,featureFlags:s}=E.useContext(Pe);return e.jsxs(ps,{collapsible:"icon",...t,children:[e.jsxs(bs,{children:[e.jsx(Rs,{}),s.ff_enable_teams&&e.jsx(Ls,{})]}),e.jsx(js,{children:e.jsx(Ts,{navItems:Ms.navMain})}),e.jsx(vs,{children:e.jsx(As,{email:a?.email||"",fname:a?.fname||"",lname:a?.lname||"",avatar:"/avatars/shadcn.jpg"})}),e.jsx(gs,{})]})}function Us({...t}){return e.jsx("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",...t})}function Bs({className:t,...a}){return e.jsx("ol",{"data-slot":"breadcrumb-list",className:ee("text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm break-words sm:gap-2.5",t),...a})}function qs({className:t,...a}){return e.jsx("li",{"data-slot":"breadcrumb-item",className:ee("inline-flex items-center gap-1.5",t),...a})}function Vs({asChild:t,className:a,...s}){const r=t?_.Slot:"a";return e.jsx(r,{"data-slot":"breadcrumb-link",className:ee("hover:text-foreground transition-colors",a),...s})}function Hs({className:t,...a}){return e.jsx("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:ee("text-foreground font-normal",t),...a})}function Ys({children:t,className:a,...s}){return e.jsx("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:ee("[&>svg]:size-3.5",a),...s,children:t??e.jsx(i.ChevronRight,{})})}const Ws=()=>{const t=(()=>{const e=a.useLocation().pathname;if(!e||"/"===e)return{title:"Dashboard"};const t=_e(e),s=ie(t);return s||{title:"Not Found",url:"notFound"}})(),r=(t,a)=>{let n=[];return n.push(e.jsxs(s.Fragment,{children:[e.jsx(qs,{children:a?e.jsx(Hs,{children:t.title}):e.jsx(Vs,{children:t.title})}),!a&&e.jsx(Ys,{})]},t.title)),t.parent&&(n=[r(t.parent,!1),...n].flat()),n};return e.jsx(Us,{children:e.jsx(Bs,{children:r(t,!0)})})},Ks=()=>{const t=a.useNavigate(),r=yt(),{activeOrg:n,loggedInUser:i}=s.useContext(Pe);return{editOrganization:a=>{wt.Is_ADMIN(a.role_id)?t("/infrastructure/edit-org/"+ge(a.org_id)):Oe({header:"Alert",description:e.jsxs(e.Fragment,{children:["You are not allowed to edit the ",e.jsx("b",{children:a.org_name})," ",Z.account_type_txt.singular.toLocaleLowerCase(),"."]})})},handleOnDeleteUnregisteredUser:(e,t)=>{const{id:a,email:s}=e;return new Promise((e,n)=>{r.showAlertBox({type:"CONFIRM",text:`Are you sure you want to remove "${s}" user from your ${Z.account_type_txt.singular}?`,async onClose(r){if("CONFIRM"!==r)return void n();const i={invited_users_id:a,org_id:t};try{const t=await Ae().delete("/org-member/unregistered-user-invitation",{data:i});Ie({description:`${s} has been successfully removed from the team.`}),e(t)}catch(e){n(e)}}})})},isActiveOrgCreatedByMe:()=>Number(n?.org_created_by)===Number(i.id)}},Gs=()=>{const{featureFlags:t}=s.useContext(Pe),{isMobile:r,setOpenMobile:n}=ms(),i=a.useNavigate(),{isActiveOrgFreePlan:o,isUserFreePlan:l}=Be(),{isActiveOrgCreatedByMe:d}=Ks();if(!1===t.ff_enable_paid_subscription)return null;const c=()=>{r&&n(!1),i("/plans")};return l()&&(!t.ff_enable_teams||o()&&d())?e.jsx("button",{onClick:c,children:e.jsx(Ka,{children:"Upgrade to premium"})}):null};var Xs=Object.freeze({__proto__:null,default:function(){const t=ya();return e.jsxs(xs,{children:[e.jsx($s,{}),e.jsxs(fs,{className:"h-screen",children:[e.jsxs("header",{className:"flex py-4 shrink-0 items-center gap-2 transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-12 bg-background",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4",children:[e.jsx(hs,{className:"-ml-1"}),e.jsx(na,{orientation:"vertical",className:"mr-2 data-[orientation=vertical]:h-4"}),e.jsx(Ws,{})]}),e.jsx("div",{className:"flex-1"}),e.jsx("div",{className:"flex items-center gap-2 px-4",children:t?e.jsx(e.Fragment,{}):e.jsx(Gs,{})})]}),e.jsx("div",{className:"flex items-stretch flex-col flex-1 overflow-auto",children:e.jsx(a.Outlet,{})})]})]})}});var Js=Object.freeze({__proto__:null,default:({canShowHeader:t=!0})=>e.jsxs("div",{className:"flex flex-col stretch justify-center gap-4 items-center flex-1 p-5",children:[t&&e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-3xl font-bold text-primary p-0",children:Z.appName}),e.jsx("p",{className:"text-sm",children:Z.appDescription})]}),e.jsxs("div",{className:"flex flex-col justify-center",children:[e.jsx("div",{className:"text-muted-foreground mb-4 text-sm",children:"404 Page Not Found"}),e.jsx(a.NavLink,{to:"/",className:"p-2 bg-primary text-primary-foreground rounded-md transition-colors text-sm",children:"Go to Homepage"})]})]})});const Qs=({ref:t,gridCls:r,onChangeEmailClick:n,email:i})=>{const[o,l]=s.useState(""),[d,c]=s.useTransition(),u=a.useNavigate(),m=s.useRef(null);return s.useImperativeHandle(t,()=>({focus(){m.current?.focus()}}),[]),e.jsxs("form",{onSubmit:async e=>{if(e.preventDefault(),!o)return Fe({header:"OTP Required!",description:"Please enter your OTP and try again."}),void m.current?.focus();const t=te(e.currentTarget);t.otp=o,t.user_email=i;const a=de(t.password);!1!==a.valid?t.password===t.user_password?c(async()=>{try{delete t.password,await Ae().put("/reset-password",t),Ie({header:"Your password has been reset successfully!",description:"Please log in using your new password."}),u("/login")}catch(e){ce(e)}}):Fe({header:"Password and Confirm Password fields contain different passwords.",description:""}):Fe({header:"Password Policy",description:a.message})},className:"grid gap-6",children:[e.jsxs("div",{className:r,children:[e.jsx(Lt,{htmlFor:"emailOTPGenerated",children:"Email *"}),e.jsx(Et,{id:"emailOTPGenerated",type:"email",name:"user_email",placeholder:"mail@example.com",value:i,disabled:!0,required:!0}),e.jsx("span",{className:"ml-auto text-xs underline-offset-4 hover:underline cursor-pointer italic",onClick:()=>n(),children:"Change Email"})]}),e.jsx(is,{className:r,inputOTPField:m,otp:o,setOtp:l,onChangeEmailClick:n}),e.jsxs("div",{className:r,children:[e.jsxs(Lt,{htmlFor:"password",children:["New Password * ",e.jsx(ts,{})]}),e.jsx(Et,{id:"password",type:"password",name:"password",placeholder:"**********",required:!0})]}),e.jsxs("div",{className:r,children:[e.jsx(Lt,{htmlFor:"cnf-password",children:"Confirm Password *"}),e.jsx(Et,{id:"cnf-password",type:"password",name:"user_password",placeholder:"**********",required:!0})]}),e.jsx(vt,{type:"submit",className:"w-full",size:"lg",loading:d,children:"Reset Password"})]})};var Zs=Object.freeze({__proto__:null,default:function(){const t=s.useRef(null),r=s.useRef(null),[n,i]=s.useState(!1),[o,l]=s.useState(""),d="grid gap-1";return s.useEffect(()=>{n?r.current?.focus():t?.current?.focus()},[n]),e.jsxs("div",{className:"grid gap-6",children:[e.jsx("div",{className:"after:border-border relative text-center text-sm after:absolute after:inset-0 after:top-1/2 after:z-0 after:flex after:items-center after:border-t",children:e.jsx("span",{className:"bg-card text-muted-foreground relative z-10 px-2",children:"Forgot Password"})}),e.jsx(as,{ref:t,handleOnOTPSent:e=>{i(!0),l(e.email)},gridCls:d,hidden:n,path:"forgot-password"}),n&&e.jsx(Qs,{ref:r,gridCls:d,onChangeEmailClick:()=>i(!1),email:o}),e.jsxs("div",{className:"text-center text-sm",children:["Already have an account?"," ",e.jsx(a.NavLink,{to:"/login",children:e.jsx("span",{className:"underline underline-offset-4",children:"Login"})})]})]})}});var er=Object.freeze({__proto__:null,default:()=>{const{orgs:t}=s.useContext(Pe);return e.jsxs("div",{className:"mt-5",children:[e.jsxs("div",{className:"flex flex-row justify-center gap-6",children:[e.jsxs(Va,{toPath:"create-new-org",className:"text-center",children:["Create new ",Z.account_type_txt.singular.toLocaleLowerCase()]}),e.jsx(Va,{toPath:"user-invitations",className:"text-center",children:"Accept/Reject Invitations"})]}),e.jsx("div",{className:"flex flex-row justify-center gap-6 mt-5",children:e.jsxs(Va,{toPath:"manage-infra",className:"text-center",disabled:t.length<=0,children:["Manage ",Z.account_type_txt.plural.toLocaleLowerCase()]})})]})}});const tr=({value:t,setValue:a,id:s})=>e.jsx(Ga,{valueField:"id",labelField:"text",placeholder:"Specify Role",items:wt.GET_LIST(),value:t,onValueChange:e=>{a(e)},triggerClassName:"w-[180px]",id:s}),ar=(e,t)=>-1===t||e?.user_opinion===ye.NOT_SAVED,sr=({teamMembers:t,setTeamMembers:a,inactiveUsers:r})=>{const[n,o]=s.useState(),[l,d]=s.useState(NaN),c=yt(),[u,m]=s.useState(),[x,p]=s.useState(!1),[h,g]=s.useState({email:"",role_id:wt.READ,user_opinion:ye.INVITED,id:""}),{loggedInUser:f}=s.useContext(Pe),b=e=>{const s={},r=[...t??[],...e];r.forEach(e=>{const t=e.email;s[t]=s[t]?s[t]++:1});const n=r.filter(e=>(s[e.email]--,0===s[e.email]));return a(n),r.length===n.length},v=e=>e&&e.email&&!1!==ue(e.email)?!!wt.IS_VALID_ROLE_ID(e.role_id)||(Fe({description:"Invalid role selected. Please select a valid role and try again."}),!1):(Fe({description:"Invalid email, please enter correct email and try again."}),!1);return s.useEffect(()=>{if(!u)return void g({email:"",role_id:NaN,user_opinion:ye.INVITED,id:""});if(-1===u)return;const e=t?.find(e=>e.id===u);e?g({email:e.email,role_id:e.role_id,user_opinion:e.user_opinion,id:e.id||e.email}):Fe({description:"Something went wrong, please reload and try again."})},[u]),e.jsxs(ja,{layout:"vertical",className:"gap-2",children:[x&&e.jsxs(jt,{open:!0,setIsOpen:p,header:"Bulk Add Users",actionsJSX:e.jsx(vt,{onClick:()=>{const{validEmails:e}=n||{};if(!e?.length||e?.length<=0)return Oe({description:"Please add comma separated emails, then press Continue button"});const t=e.map(e=>({email:e,role_id:l,id:e,user_opinion:ye.INVITED}));b(t),o(void 0),p(!1),Ie({description:`${e?.length} emails has been added.`})},children:"Add users"}),children:[e.jsxs(ja,{layout:"horizontal",className:"gap-2",children:[e.jsx(pa,{id:"includeUsers",placeholder:"Enter comma separated emailIds like mail1@temp.com, mail2@temp.com",className:"w-full min-h-[80px] max-h-[500px] mr-1",onChange:e=>o(me(e.target.value))}),e.jsx("span",{children:e.jsx(Ya,{side:"right",children:"Enter comma separated emailIds like mail1@temp.com, mail2@temp.com"})})]}),e.jsxs("span",{className:"mb-5",children:[e.jsxs("span",{className:"text-success",children:["Valid Emails: ",n?.validEmails.length||0]}),","," ",e.jsxs("span",{className:"text-failure",children:["Invalid Emails: ",n?.invalidEmails.length||0]})]}),e.jsxs("div",{className:"flex flex-row gap-2",children:[e.jsx(Lt,{htmlFor:"roles",children:"Role *"}),e.jsx(tr,{id:"bulk-roles",value:l?.toString()||"",setValue:e=>{d(Number(e))}})]})]}),u&&e.jsx(jt,{open:!0,setIsOpen:e=>{m(!1===e?void 0:u)},header:-1===u?"Add User":"Edit User",actionsJSX:e.jsx(vt,{type:"button",onClick:-1===u?()=>{if(!v(h))return;b([{...h,id:h.email,user_opinion:ye.NOT_SAVED}])?m(void 0):Fe({description:`This email is already exists in list: ${h.email}`})}:()=>{if(!v(h))return;const e=t?.find(e=>e.email===h.email&&e.id!==u);if(e)return void Oe({description:`This email is already exists in list: ${h.email}`});const s=[...t||[]],r=s.find(e=>e.id===u);r?(r.email=h.email,r.role_id=h.role_id,a(s),m(void 0)):Fe({description:"Record not found to update, something went wrong!"})},children:"Update"}),children:e.jsxs("div",{className:"flex flex-col p-5 gap-5",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Lt,{htmlFor:"email",children:"Email *"}),e.jsx(Et,{id:"email",type:"email",placeholder:"mail@example.com",value:h.email,disabled:!1===ar(h,u),onChange:e=>g(t=>({...t,email:e.target.value}))})]}),e.jsxs("div",{className:"flex flex-col gap-2 ",children:[e.jsx(Lt,{htmlFor:"roles",children:"Role *"}),e.jsx(tr,{id:"roles",value:h.role_id?.toString()||"",setValue:e=>{g(t=>({...t,role_id:Number(e)}))}})]})]})}),e.jsx(Oa,{canShowToolbar:!0,canShowPagination:!1,data:t||[],toolbarConfig:{canShowSearchField:!1,canShowColumnsBtn:!1,additionalJSX:[e.jsxs(vt,{variant:"secondary",type:"button",onClick:()=>{m(-1)},children:[e.jsx(i.Plus,{})," Add User"]}),e.jsxs(vt,{variant:"outline",type:"button",onClick:()=>{p(!0)},children:[e.jsx(i.Files,{})," Bulk Add"]})]},columns:[{id:"email",headerText:"Email",enableSorting:!1,enableHiding:!1,editable:!0},{id:"role_id",headerText:"Role",enableSorting:!1,enableHiding:!1,editable:!0,type:"string",renderer:(e,t)=>wt.DISPLAY_TEXT(t)},{id:"user_opinion",headerText:"Status",enableSorting:!1,enableHiding:!1,type:"boolean",editable:!1,renderer(e){const{user_opinion:t}=e.original;return ye.getDisplay(t)}},{id:"joinedOn",headerText:"Joined On",enableSorting:!1,enableHiding:!1,type:"date",editable:!0},{id:"actions",headerText:"Actions",enableSorting:!1,enableHiding:!1,renderer(s){const{id:r}=s?.original;return e.jsxs(e.Fragment,{children:[e.jsx(vt,{variant:"ghost",onClick:()=>{const e=t?.find(e=>e.id===r),a=e?.fname||e?.lname?`${e?.fname} ${e?.lname}`:e?.email;e?.email!==f?.email?(!1===ar(e,void 0)&&Oe({header:`Not allowed to edit email "${a}", however you can update its administrative privileges.`,description:"The invitation has been already sent. If you do not want this user as a team member, you can delete them and correct one."}),m(r)):Oe({header:`Not allowed to edit "${a}"`,description:`If you want to leave this ${Z.account_type_txt.singular.toLocaleLowerCase()}, go to "Manage ${Z.account_type_txt.singular}," open the actions menu (three dots), and click "Leave ${Z.account_type_txt.singular}."`})},type:"button",children:e.jsx(i.Pencil,{})}),e.jsx(vt,{variant:"ghost",onClick:()=>{const e=t?.find(e=>e.id===r),s=e?.fname||e?.lname?`${e?.fname} ${e?.lname}`:e?.email;e?.email!==f?.email?c.showAlertBox({type:"CONFIRM",text:`Are you sure you want to remove "${s}" user?`,async onClose(e){"CONFIRM"===e&&a(t?.filter(e=>e.id!==r))}}):Oe({header:`Not allowed to remove "${s}"`,description:`If you want to leave this ${Z.account_type_txt.singular}, go to "Manage ${Z.account_type_txt.singular}," open the actions menu (three dots), and click "Leave ${Z.account_type_txt.singular}."`})},type:"button",children:e.jsx(i.Trash,{})})]})}}]}),r.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ea,{className:"mt-5 leading-normal font-semibold",children:"Following users are inactive/deleted."}),e.jsx("ol",{children:r.map((t,a)=>e.jsxs("li",{children:[a+1,". ",t.email," ",wt.DISPLAY_TEXT(t.role_id)]},t.email))})]})]})};var rr=Object.freeze({__proto__:null,default:()=>{const t=a.useNavigate(),{orgId:r=""}=a.useParams(),[n,l]=s.useState(()=>r?fe(parseInt(r,10)):-1),[d,c]=s.useState(!1),[u,m]=s.useState([]),[x,p]=s.useState([]),[h,g]=s.useState([]),[f,b]=s.useState(!1),v=s.useRef([]),[j,y]=s.useState(),{orgs:N,setOrgs:w,loggedInUser:_}=s.useContext(Pe),C=n>-1?N.find(e=>e.org_id===n):null,k=n>-1||C,{handleOnDeleteUnregisteredUser:S}=Ks();s.useEffect(()=>{if(!k)return;const e=e=>e.map(e=>({id:e.user_id,email:e.user_email,role_id:e.role_id,user_opinion:e.user_opinion,fname:e.user_fname,lname:e.user_lname,joinedOn:e.joined_on}));(async()=>{b("Fetching Team Members");try{const t=await Ae().get(`org-member/${n}`),a=t.orgMembers.filter(e=>je(e.is_active)),s=e(a),r=t.unregisteredUsers.map(e=>({role_id:e.role_id,email:e.email,id:e.invited_users_id})),i=t.orgMembers.filter(e=>!je(e.is_active));m(s),c(!0),p(r),g(e(i)),v.current=structuredClone(s)}finally{b(!1)}})()},[k,n]);const P=k?C?.org_name:`${_?.fname}'s ${Z.account_type_txt.singular} ${N.length>=1?N.length+1:""}`;return e.jsx(ja,{className:"pb-5 sm:px-0 px-5 pt-5",children:e.jsxs(ja,{layout:"horizontal",children:[e.jsx("span",{className:"md:flex-1 flex-none"}),e.jsxs(ja,{className:"flex-4 max-w-4xl pr-5 sm:pl-0 pl-2 overflow-visible",children:[e.jsx(Aa,{className:"text-center pl-5 gap-1",children:e.jsxs("span",{className:"inline-flex items-center gap-2",children:[k?`Editing "${C?.org_name}" ${Z.account_type_txt.singular}`:`Create new ${Z.account_type_txt.singular}`,k&&C?.active_purchased_plan?e.jsx(Es,{purchasedPlan:C?.active_purchased_plan}):null]})}),e.jsx("form",{onSubmit:async e=>{e.preventDefault(),b("Saving...");try{let a=C?.org_id;const s=te(e.currentTarget);if(k)await(e=>{const t={},a=C;if(e.org_name!==a?.org_name&&e.org_name&&(t.org_name=e.org_name),e.org_address!==a?.org_address&&e.org_address&&(t.org_address=e.org_address),e.org_state!==a?.org_state&&e.org_state&&(t.org_state=e.org_state),e.org_country!==a?.org_country&&e.org_country&&(t.org_country=e.org_country),e.org_external_id!==a?.org_external_id&&e.org_external_id&&(t.org_external_id=e.org_external_id),!Ne(t))return Ae().put(`/organization/${C?.org_id}`,t)})(s);else{const e=await(async e=>{const t={org_name:e.org_name,org_address:e.org_address,org_state:e.org_state,org_country:e.org_country,org_external_id:e.org_external_id};return Ae().post("/organization",t)})(s);a=parseInt(e.insertedOrgId,10),!1===we(a)&&(Fe({description:`No response received from the ${Z.account_type_txt.singular.toLocaleLowerCase()} service. Returning to the Manage ${Z.account_type_txt.singular} page.`}),setTimeout(()=>{t("/infrastructure/manage-infra")},1e3))}const r=e=>{Ie({description:`${Z.account_type_txt.singular} has been ${k?"updated":"created"} successfully.${e?" Team members have also been updated successfully and sent invitation emails.":""}`}),t("/infrastructure/manage-infra")};if(!d)return r(!1);try{const e=v.current,t=e.filter(e=>!u.find(t=>e.email===t.email));if(t&&t.length>0){const e={org_id:a,users:t.map(e=>({user_id:e.id}))};await Ae().delete("/org-member",{data:e})}const s=u.filter(t=>{const a=e.find(e=>t.id===e.id);return!!a&&a.role_id!==t.role_id});if(s&&s.length>0){const e={org_id:a,users:s.map(e=>({user_id:e.id,role_id:e.role_id}))};await Ae().put("/org-member",e)}const n=u.filter(t=>!e.find(e=>e.email===t.email));if(n&&n.length>0){const e={org_id:a,included_users:n.map(e=>({email:e.email,role_id:e.role_id}))};await Ae().post("/org-member/by-emails",e)}r(!0)}finally{l(a||-1)}}finally{b(!1);const e=await Ae().get("organization");w(e?.orgs||[])}},children:e.jsx(Da,{className:"w-full pr-1 mt-2 text-sm",leftCls:"w-32 sm:w-36 md:w-40 w-full sm:w-40 text-left sm:text-right pr-0 sm:pr-2 pt-3 sm:pt-7",rightCls:"pt-1 sm:pt-5",rowCls:"flex-col sm:flex-row",child:[e.jsxs(o.Label,{htmlFor:"orgName",className:"font-medium",children:[Z.account_type_txt.singular," Name * :"]}),e.jsx(Et,{id:"orgName",name:"org_name",type:"text",required:!0,className:"w-full",defaultValue:C?.org_name??P,autoFocus:!0}),...Z.account_type_txt.value===Q.ORG?[e.jsx(o.Label,{htmlFor:"address",className:"font-medium",children:"Address * :"}),e.jsx(Et,{id:"address",name:"org_address",type:"text",required:!0,className:"w-full",defaultValue:C?.org_address??""}),e.jsx(o.Label,{htmlFor:"state",className:"font-medium",children:"State * :"}),e.jsx(Et,{id:"state",name:"org_state",type:"text",required:!0,className:"w-full",defaultValue:C?.org_state??""}),e.jsx(o.Label,{htmlFor:"country",className:"font-medium",children:"Country * :"}),e.jsx(Et,{id:"country",name:"org_country",type:"text",required:!0,className:"w-full",defaultValue:C?.org_country??""})]:[],e.jsx(o.Label,{htmlFor:"org_external_id",className:"font-medium",children:"External Id (optional) :"}),e.jsx(Et,{id:"org_external_id",name:"org_external_id",type:"text",className:"w-full",defaultValue:C?.org_external_id??""}),e.jsx(e.Fragment,{}),e.jsxs(ja,{layout:"horizontal",children:[e.jsx(Et,{id:"doIncludeUsers",type:"checkbox",className:"w-4",checked:d,onChange:e=>c(e.target.checked)}),e.jsxs(o.Label,{htmlFor:"doIncludeUsers",className:"font-medium mt-2 ml-1",children:["Would you like to invite your team-members in this ",Z.account_type_txt.singular,"?"]})]}),...d?[e.jsx(o.Label,{htmlFor:"includeUsers",className:"font-medium",children:"Team Members:"}),e.jsx(sr,{teamMembers:u,setTeamMembers:m,inactiveUsers:h})]:[],e.jsx(e.Fragment,{}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(vt,{type:"submit",className:"flex-1 sm:flex-none",loading:!!f,children:f||"Save"}),e.jsx(vt,{type:"button",variant:"outline",className:"flex-1 sm:flex-none",onClick:()=>t(-1),children:"Cancel"})]}),e.jsx(e.Fragment,{}),e.jsx(e.Fragment,{}),e.jsx(e.Fragment,{}),e.jsx(e.Fragment,{children:x.length>0&&e.jsx(na,{})}),e.jsx(e.Fragment,{children:x.length>0&&"Unregistered Users:"}),e.jsx(e.Fragment,{children:x.length>0&&e.jsxs(ja,{loading:j,children:[e.jsxs(Ea,{className:"mt-2 leading-normal font-semibold",children:["Following users are unregistered. We have sent them invitation emails; once they accept, they will be part of this"," ",Z.account_type_txt.singular.toLocaleLowerCase(),"."]}),e.jsx("ol",{children:x.map((t,a)=>e.jsx("li",{className:"mt-1",children:e.jsxs("span",{className:"inline-flex group",children:[e.jsxs("span",{children:[a+1,". ",t.email,", (role:  ",wt.DISPLAY_TEXT(t.role_id),")"]}),e.jsx("span",{title:"Delete",children:e.jsx(i.Trash,{size:"15px",className:"opacity-40 group-hover:opacity-60 hover:opacity-100 ml-1 mt-0.5 cursor-pointer",onClick:async()=>{try{y(!0),await S(t,n);const e=[...x];e.splice(a,1),p(e)}finally{y(!1)}}})})]})},t.email))})]})})]})})]}),e.jsx("span",{className:"md:flex-1 flex-none"})]})})}});var nr=Object.freeze({__proto__:null,default:()=>{const{loading:t,response:a}=Qa("/invitation"),r=yt(),n=a?.invites.filter(e=>e.user_opinion!==ye.ACCEPTED),[o,l]=s.useState(-1),{setOrgs:d}=s.useContext(Pe),c=async(e,t)=>{if(t)try{const a=parseInt(t.org_id,10);l(a);const s={org_id:a,user_opinion:e};await Ae().put("/invitation",s);const r=await Ae().get("organization");d(r?.orgs||[]),t.user_opinion=ye.ACCEPTED,Ie({description:`Invitation for ${t.org_name} ${Z.account_type_txt.singular} has been ${e===ye.ACCEPTED?"accepted":"rejected"} successfully.`})}finally{l(-1)}};return e.jsxs(ja,{layout:"horizontal",children:[e.jsx("span",{className:"md:flex-1 flex-none"}),e.jsx(ja,{className:"flex-4 max-w-4xl mt-5",children:e.jsxs(ja,{children:[(()=>{if(t)return e.jsx("span",{children:e.jsx(ja,{layout:"horizontal",className:"text-center mt-5 justify-center items-center",children:e.jsx(ze,{})})});if(!n||n.length<=0)return e.jsxs(Ea,{className:"text-center mt-5",children:["You don't have any invitations from any ",Z.account_type_txt.singular.toLocaleLowerCase(),"."]});const a=n.filter(e=>je(e.org_user_is_active)).map(t=>[e.jsxs(Lt,{className:"font-normal",children:[e.jsxs("span",{className:"font-semibold",children:[t.org_name,","]}),"sent on  ",pe(t.sent_at)]}),e.jsxs(ja,{className:"gap-1 justify-end pr-3",layout:"horizontal",children:[e.jsxs(vt,{onClick:()=>c(ye.ACCEPTED,t),loading:o===parseInt(t.org_id,10),disabled:-1!==o,className:"bg-green-500 hover:bg-green-600",children:[e.jsx(i.Check,{})," Accept"]}),e.jsxs(vt,{variant:"destructive",loading:o===parseInt(t.org_id,10),disabled:-1!==o,onClick:()=>{r.showAlertBox({type:"CONFIRM",text:`Are you sure you want to reject this ${Z.account_type_txt.singular.toLocaleLowerCase()} request? You can't re-join until an administrator invites you again.`,async onClose(e){"CONFIRM"===e&&c(ye.REJECTED,t)}})},children:[e.jsx(i.X,{})," Reject"]})]})]);return e.jsx(Da,{className:"w-full mt-5 text-sm border-b-1",leftCls:"w-full sm:w-100 text-left sm:text-right pt-3",rightCls:"sm:pt-0 pt-2",rowCls:"flex-col sm:flex-row border-t-1 p-2 hover:bg-muted",child:a.flat()})})(),e.jsx("span",{className:"mt-5 text-center",children:e.jsx(vt,{className:"mt-5",variant:"link",children:e.jsxs(qa,{to:"/infrastructure/manage-infra",children:["View all ",Z.account_type_txt.plural.toLocaleLowerCase()]})})})]})}),e.jsx("span",{className:"md:flex-1 flex-none"})]})}});const ir=C.cva("flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}});function or({className:t,orientation:a,...s}){return e.jsx("div",{role:"group","data-slot":"button-group","data-orientation":a,className:ee(ir({orientation:a}),t),...s})}var lr=Object.freeze({__proto__:null,default:()=>{const{orgs:t,featureFlags:r}=s.useContext(Pe),n=r.ff_enable_teams&&0===t.length,o=a.useLocation(),l=a.useNavigate(),d=ya(),c=[...r.ff_enable_teams?[{title:Z.account_type_txt.plural,url:"/infrastructure/manage-infra"},{title:"Invitations",url:"/infrastructure/user-invitations"}]:[],...r.ff_enable_paid_subscription?[{title:"Subscriptions",url:"/infrastructure/manage-subscription"},{title:"Payment History",url:"/infrastructure/payment-history"}]:[]];return e.jsxs(ja,{className:"h-screen sm:pt-10 pt-5",children:[e.jsxs("div",{className:"scroll-m-20 text-xl inline-flex gap-2 px-5 pb-5",children:["/infrastructure"!==o.pathname&&e.jsxs(vt,{variant:"ghost",onClick:()=>l(-1),children:[e.jsx(i.ArrowLeft,{size:20})," Back"]}),e.jsx("span",{className:"flex-1"}),e.jsx("div",{className:"bg-sidebar-primary text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg",children:e.jsx(Z.logo,{className:"size-4"})}),e.jsx("div",{className:"grid text-left leading-tight items-center text-foreground font-semibold tracking-tight",children:Z.appName}),e.jsx("span",{className:"flex-1"}),n?e.jsx(a.NavLink,{to:"/login",children:e.jsxs(vt,{variant:"ghost",children:[e.jsx(i.LogOut,{}),"Log out"]})}):e.jsx(a.NavLink,{to:"/",children:e.jsx(vt,{variant:"ghost",title:"close",children:e.jsx(i.X,{size:20})})})]}),c.some(e=>e.url===o.pathname)&&e.jsx(ja,{doNotAppendFlex1:!0,className:"mx-auto mb-4",children:d?e.jsxs(ia,{children:[e.jsx(oa,{asChild:!0,children:e.jsxs(vt,{variant:"default",children:[e.jsx(i.Menu,{}),"Menu"]})}),e.jsx(la,{children:c.map(t=>e.jsx(ca,{onClick:()=>l(t.url),children:t.title},t.title))})]}):e.jsx(or,{children:c.map(t=>e.jsx(vt,{variant:o.pathname===t.url?"default":"outline",onClick:()=>l(t.url),children:t.title},t.title))})}),e.jsx(a.Outlet,{})]})}});var dr=Object.freeze({__proto__:null,default:()=>{const{orgs:t,setOrgs:r,featureFlags:n,loggedInUser:o,setActiveOrg:l}=s.useContext(Pe),d=yt(),[c,u]=s.useState(!1),m=a.useNavigate(),{editOrganization:x}=Ks(),p=async()=>{u(!0);try{const e=await Ae().get("organization");r(e?.orgs||[])}catch{r([])}finally{u(!1)}};return e.jsx(ja,{children:e.jsx("div",{className:"flex-1 flex p-5 sm:px-10 px-4 flex-col sm:w-300 m:w-full w-full mx-auto",children:e.jsx(Oa,{loading:c,toolbarConfig:{canShowSearchField:!0,searchFieldConfig:{placeholder:`Search by ${Z.account_type_txt.singular} Name...`,searchField:"org_name"},canShowColumnsBtn:!0,additionalJSX:[e.jsx(qa,{to:"/infrastructure/create-new-org",children:e.jsxs(vt,{variant:"default",children:[e.jsx(i.Plus,{})," Create new ",Z.account_type_txt.singular]})})],refreshBtn:{canShow:!0,onClick:p}},data:t,actions:[{id:"actionId1",headerText:"Edit",onClick:e=>{x(e)}},{id:"actionId2",headerText:"Delete",onClick:t=>{const a=t;wt.Is_ADMIN(a.role_id)?d.showAlertBox({type:"CONFIRM",text:`Are you sure you want to delete "${a.org_name}" ${Z.account_type_txt.singular.toLocaleLowerCase()}?`,async onClose(e){if("CONFIRM"===e){u(!0);try{const e=await Ae().delete("organization/"+a.org_id);Ie({header:`${Z.account_type_txt.singular} has been deleted successfully.`,description:e.message}),await p()}finally{u(!1)}}}}):Oe({header:"Alert",description:e.jsxs(e.Fragment,{children:["You are not allowed to delete the ",e.jsx("b",{children:a.org_name})," ",Z.account_type_txt.singular,"."]})})}},{id:"separate",headerText:"SEPARATOR"},{id:"actionId3",headerText:`Leave this ${Z.account_type_txt.singular.toLocaleLowerCase()}`,onClick:e=>{const t=e;d.showAlertBox({type:"CONFIRM",text:`Are you sure you want to leave this ${Z.account_type_txt.singular.toLocaleLowerCase()}? You can't re-join until an administrator invites you again.`,async onClose(e){if("CONFIRM"===e){u(!0);try{const e={org_id:t.org_id,user_opinion:ye.LEFT};await Ae().put("invitation",e),Ie({header:`You have successfully left this ${Z.account_type_txt.singular.toLocaleLowerCase()}.`,description:""}),await p()}finally{u(!1)}}}})}},{id:"separate2",headerText:"SEPARATOR"},{id:"actionId4",headerText:"Impersonate",onClick:e=>{l(e),m("/")}}],columns:[...!1===n.ff_enable_paid_subscription?[]:[{id:"active_purchased_plan",headerText:"",enableSorting:!1,enableHiding:!1,type:"string",renderer(t,a){const s=a;return e.jsx(Es,{purchasedPlan:s})}}],{id:"org_name",headerText:`${Z.account_type_txt.singular} Name`,enableSorting:!0,enableHiding:!0},...Z.account_type_txt.value===Q.ORG?[{id:"org_address",headerText:"Address",enableSorting:!0,enableHiding:!0},{id:"org_state",headerText:"State",enableSorting:!0,enableHiding:!0},{id:"org_country",headerText:"Country",enableSorting:!0,enableHiding:!0}]:[],{id:"role_id",headerText:"Role",enableSorting:!0,enableHiding:!0,type:"string",renderer:(e,t)=>wt.DISPLAY_TEXT(t)},{id:"org_created_by",headerText:"Created By Me?",enableSorting:!1,enableHiding:!0,renderer:(t,a)=>Number(a)===Number(o.id)?e.jsx(i.Check,{}):e.jsx(i.X,{})},{id:"updated_at",headerText:"Updated On",enableSorting:!0,enableHiding:!0,type:"date"},{id:"created_at",headerText:"Created On",enableSorting:!0,enableHiding:!0,type:"date"}]})})})}});function cr({className:t,...a}){return e.jsx(K.Root,{"data-slot":"radio-group",className:ee("grid gap-3",t),...a})}function ur({className:t,...a}){return e.jsx(K.Item,{"data-slot":"radio-group-item",className:ee("border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...a,children:e.jsx(K.Indicator,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:e.jsx(i.CircleIcon,{className:"fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})})})}const mr=C.cva("py-32 relative overflow-hidden",{variants:{size:{small:"py-12",medium:"py-20",large:"py-32"},theme:{minimal:"bg-background",classic:"bg-gradient-to-b from-background to-muted/20"}},defaultVariants:{size:"medium",theme:"minimal"}}),xr=C.cva("font-bold mb-4 text-foreground",{variants:{size:{small:"text-3xl lg:text-4xl",medium:"text-4xl lg:text-5xl",large:"text-4xl lg:text-6xl"},theme:{minimal:"",classic:"bg-gradient-to-r from-foreground to-muted-foreground bg-clip-text text-transparent"}},defaultVariants:{size:"medium",theme:"minimal"}}),pr=C.cva("text-muted-foreground max-w-3xl mx-auto mb-2",{variants:{size:{small:"text-base lg:text-lg",medium:"text-lg lg:text-xl",large:"lg:text-xl"},theme:{minimal:"",classic:""}},defaultVariants:{size:"medium",theme:"minimal"}}),hr=C.cva("relative h-full transition-all duration-300 rounded-lg border bg-card text-card-foreground",{variants:{size:{small:"p-4",medium:"p-5",large:"p-6"},theme:{minimal:"hover:bg-muted/30",classic:"hover:shadow-xl backdrop-blur-sm bg-card/50 border-border/50"},highlight:{true:"",false:""}},compoundVariants:[{theme:"classic",highlight:!0,className:"ring-2 ring-primary/20 border-primary/30 bg-gradient-to-b from-primary/5 to-transparent relative overflow-hidden shadow-xl"},{theme:"minimal",highlight:!0,className:"bg-muted/50 border-primary/20"}],defaultVariants:{size:"large",theme:"minimal",highlight:!1}}),gr=C.cva("flex h-11 w-fit shrink-0 items-center rounded-md p-1 text-lg",{variants:{theme:{minimal:"bg-muted",classic:"bg-muted/50 backdrop-blur-sm border border-border/50 shadow-lg"}},defaultVariants:{theme:"minimal"}}),fr=C.cva("font-medium",{variants:{size:{small:"text-2xl",medium:"text-3xl",large:"text-4xl"},theme:{minimal:"",classic:"font-extrabold bg-gradient-to-r from-foreground to-muted-foreground bg-clip-text text-transparent"}},defaultVariants:{size:"large",theme:"minimal"}}),br=C.cva("w-full transition-all duration-300 hover:cursor-pointer",{variants:{theme:{minimal:"shadow hover:bg-primary/90 h-9 py-2 group bg-primary text-primary-foreground ring-primary before:from-primary-foreground/20 after:from-primary-foreground/10 relative isolate inline-flex w-full items-center justify-center overflow-hidden rounded-md px-3 text-left text-sm font-medium ring-1 before:pointer-events-none before:absolute before:inset-0 before:-z-10 before:rounded-md before:bg-gradient-to-b before:opacity-80 before:transition-opacity before:duration-300 before:ease-[cubic-bezier(0.4,0.36,0,1)] after:pointer-events-none after:absolute after:inset-0 after:-z-10 after:rounded-md after:bg-gradient-to-b after:to-transparent after:mix-blend-overlay",classic:"relative overflow-hidden bg-gradient-to-r from-primary to-primary/80 text-primary-foreground font-semibold py-3 px-6 rounded-lg hover:shadow-xl active:scale-95 border border-primary/20"}},defaultVariants:{theme:"minimal"}}),vr=C.cva("flex-none h-[1lh]",{variants:{size:{small:"size-3",medium:"size-4",large:"size-4"},theme:{minimal:"text-primary",classic:"text-primary"}},defaultVariants:{size:"large",theme:"minimal"}}),jr={starter:e.jsx(i.Package,{className:"w-4 h-4"}),pro:e.jsx(i.Award,{className:"w-4 h-4"}),enterprise:e.jsx(i.Building2,{className:"w-4 h-4"})};function yr({plans:t,title:a="Choose Your Perfect Plan",description:r="Transform your project with our comprehensive pricing options designed for every need.",subtitle:n,onPlanSelect:o,className:l,size:d="medium",theme:c="minimal",showBillingToggle:u=!0,billingToggleLabels:m={monthly:"Monthly",yearly:"Yearly"}}){const[x,p]=s.useState(!1),h=s.useId();function g(e,t){const a=parseFloat(e),s=parseFloat(t);if("custom"===e.toLowerCase()||"custom"===t.toLowerCase()||isNaN(a)||isNaN(s)||0===a)return 0;const r=(12*a-s)/(12*a)*100;return Math.round(r)}const f=t.length?Math.max(...t.map(e=>g(e.monthlyPrice,e.yearlyPrice))):0;return e.jsxs("section",{className:ee(mr({size:d,theme:c}),l),children:["classic"===c&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute inset-0 bg-grid-pattern opacity-5"}),e.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-96 h-96 bg-primary/5 rounded-full blur-3xl"}),e.jsx("div",{className:"absolute top-1/4 right-1/4 w-64 h-64 bg-secondary/5 rounded-full blur-2xl"})]}),e.jsxs("div",{className:"container max-w-7xl mx-auto relative",children:[e.jsxs("div",{className:"text-center mb-12",children:[n&&e.jsx("p",{className:"text-sm font-medium text-primary mb-3 tracking-wide uppercase",children:n}),e.jsx("h2",{className:ee(xr({size:d,theme:c})),children:a}),e.jsx("p",{className:ee(pr({size:d,theme:c})),children:r}),u&&e.jsx("div",{className:ee("flex justify-center mt-8 mx-auto",gr({theme:c})),children:e.jsxs(cr,{defaultValue:"monthly",className:"h-full grid-cols-2",onValueChange:e=>{p("annually"===e)},children:[e.jsxs("div",{className:'has-[button[data-state="checked"]]:bg-background h-full rounded-md transition-all',children:[e.jsx(ur,{value:"monthly",id:`${h}-monthly`,className:"peer sr-only"}),e.jsx(Lt,{htmlFor:`${h}-monthly`,className:"text-muted-foreground peer-data-[state=checked]:text-primary flex h-full cursor-pointer items-center justify-center px-2 md:px-7 font-semibold transition-all hover:text-foreground",children:m.monthly})]}),e.jsxs("div",{className:'has-[button[data-state="checked"]]:bg-background h-full rounded-md transition-all',children:[e.jsx(ur,{value:"annually",id:`${h}-annually`,className:"peer sr-only"}),e.jsxs(Lt,{htmlFor:`${h}-annually`,className:"text-muted-foreground peer-data-[state=checked]:text-primary flex h-full cursor-pointer items-center justify-center gap-1 px-2 md:px-7 font-semibold transition-all hover:text-foreground",children:[m.yearly,f>0&&e.jsxs("span",{className:"ml-1 rounded bg-primary/10 px-2 py-0.5 text-xs text-primary border border-primary/20 font-medium",children:["Save ",f,"%"]})]})]})]})})]}),e.jsx("div",{className:ee("grid gap-6",1===t.length&&"grid-cols-1 max-w-md mx-auto",2===t.length&&"grid-cols-1 md:grid-cols-2 max-w-4xl mx-auto",3===t.length&&"grid-cols-1 md:grid-cols-3",t.length>=4&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4"),children:t.map((t,a)=>{return e.jsxs(z.motion.div,{className:"relative group h-full",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.4,delay:.1*a,ease:"easeOut"},children:[t.badge&&e.jsx(ra,{className:ee("absolute -top-3 left-1/2 transform -translate-x-1/2 z-20","classic"===c?"bg-gradient-to-r from-primary to-primary/80 text-primary-foreground border-primary/20 shadow-lg":"bg-primary text-primary-foreground"),children:t.badge}),"classic"===c&&t.highlight&&e.jsx("div",{className:"absolute -top-px left-1/2 -translate-x-1/2 w-32 h-px bg-gradient-to-r from-transparent via-primary to-transparent"}),e.jsx("div",{className:ee(hr({size:d,theme:c,highlight:t.highlight})),children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-start gap-4 mb-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:ee("text-xl font-bold mb-1","classic"===c?"text-lg":""),children:t.title}),e.jsx("p",{className:ee("text-sm text-muted-foreground","classic"===c&&"text-foreground/80"),children:t.description})]}),e.jsx("div",{className:ee("w-10 h-10 flex items-center rounded-lg justify-center flex-shrink-0","classic"===c?"bg-primary/10 text-primary border border-primary/20":"bg-muted text-foreground border border-border"),children:(s=t.id,jr[s]||e.jsx(i.Package,{className:"w-5 h-5"}))})]}),e.jsx("div",{className:"mb-6",children:e.jsx(z.AnimatePresence,{mode:"wait",children:e.jsx(z.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},children:x?e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsxs("span",{className:ee(fr({size:d,theme:c})),children:[parseFloat(t.yearlyPrice)>=0&&"custom"!==t.yearlyPrice.toLowerCase()&&e.jsx(e.Fragment,{children:t.currency}),t.yearlyPrice]}),e.jsx("span",{className:"text-muted-foreground text-sm",children:"/year"}),g(t.monthlyPrice,t.yearlyPrice)>0&&e.jsxs("span",{className:ee("text-xs ml-2","classic"===c?"text-emerald-500 font-semibold":"text-primary font-medium"),children:[g(t.monthlyPrice,t.yearlyPrice),"% off"]})]}):e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsxs("span",{className:ee(fr({size:d,theme:c})),children:[parseFloat(t.monthlyPrice)>=0&&"custom"!==t.monthlyPrice.toLowerCase()&&e.jsx(e.Fragment,{children:t.currency}),t.monthlyPrice]}),e.jsx("span",{className:"text-muted-foreground text-sm",children:"/month"})]})},x?"year":"month")})}),e.jsx("div",{className:"mb-6",children:e.jsxs(vt,{onClick:()=>(e=>{o?.(e,x)})(t.id),className:ee(br({theme:c}),!t.highlight&&"minimal"===c&&"bg-secondary hover:bg-secondary/80 text-secondary-foreground"),variant:t.highlight?"default":"secondary",children:[t.buttonText,"classic"===c&&t.highlight&&e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-white/0 via-white/10 to-white/0 translate-x-[-100%] hover:translate-x-[100%] transition-transform duration-700"})]})}),e.jsx("div",{className:"flex-1",children:e.jsx("ul",{className:"space-y-3",children:t.features.map((t,a)=>e.jsxs(z.motion.li,{className:"flex gap-3 items-start",initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{duration:.3,delay:.05*a},children:[e.jsx(i.Check,{className:ee(vr({size:d,theme:c}))}),e.jsx("span",{className:ee("text-sm","classic"===c?"text-foreground/90":"text-muted-foreground"),children:t.name})]},a))})})]})})]},t.id);var s})})]})]})}var Nr=Object.freeze({__proto__:null,PricingTbl:function(){const t=a.useNavigate(),{subscriptionConfig:r,setSubscriptionConfig:n}=s.useContext(Pe),{plans:i,faqs:o}=r;return s.useEffect(()=>{(async()=>{if("plans"in r==!1){const e=await Ae().get("/get-subscription-config");n(e)}})()},[n,r]),"plans"in r==!1?e.jsx(Te,{}):e.jsxs("div",{className:"px-5",children:[e.jsx(yr,{plans:i,title:"Choose Your Perfect Plan",theme:"classic",description:"Transform your project with our comprehensive pricing options designed for every need.",subtitle:Z.appName,onPlanSelect:(e,a)=>{t(`/infrastructure/checkout?plan=${e}&billing=${a?"yearly":"monthly"}`)},size:"small",className:"w-full",showBillingToggle:!0,billingToggleLabels:{monthly:"Monthly",yearly:"Yearly"}}),e.jsxs("div",{className:"m-8 mx-auto max-w-200",children:[e.jsx(Aa,{className:"mb-2",children:"Need a custom plan?"}),e.jsx("p",{className:"text-muted-foreground",children:"Contact our sales team for tailored solutions that fit your organization's unique needs."}),e.jsx(Aa,{className:"mb-2 mt-15 font-medium text-lg",children:"Frequently Asked Questions"}),e.jsx("div",{className:"mt-5",children:o.map((t,a)=>e.jsx("div",{className:"border-t",children:e.jsx(Ua,{title:e.jsx("h1",{className:"",children:t.question}),children:e.jsx("div",{className:"",children:t.answer})})},a))}),e.jsx(Aa,{className:"mb-2 mt-15 font-medium text-lg",children:"Still have questions?"}),e.jsxs("p",{className:"text-muted-foreground",children:["Reach out to our support team at"," ",e.jsx("a",{href:`mailto:${Z.supportEmail}`,className:"text-primary underline",children:Z.supportEmail})," ","for personalized assistance."]})]})]})}});function wr({title:t,description:a,plan:r,triggerButtonText:n,leftPanelImageUrl:o,warningTitle:l,warningText:d,keepButtonText:c,continueButtonText:u,finalTitle:m,finalSubtitle:x,finalWarningText:p,goBackButtonText:h,confirmButtonText:g,onCancel:f,onKeepSubscription:b,onDialogClose:v,className:j}){const[y,N]=s.useState(!1),[w,_]=s.useState(!1),[C,k]=s.useState(!1),[S,P]=s.useState(null),z=()=>{_(!1),N(!1),P(null),k(!1),v?.()};return s.useEffect(()=>{const e=e=>{w&&"Escape"===e.key&&(e.preventDefault(),z())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[w]),e.jsxs(ot,{open:w,onOpenChange:e=>{e?_(!0):z()},children:[e.jsx(lt,{asChild:!0,children:e.jsx(vt,{variant:"outline",children:n||"Cancel Subscription"})}),e.jsxs(mt,{className:ee("sm:max-w-[1000px] flex flex-col md:flex-row p-0 overflow-hidden text-foreground w-[95%] md:w-[100%]",o?"":"sm:max-w-[500px]",j),children:[e.jsx(ht,{className:"sr-only",children:t}),e.jsxs(ct,{className:"absolute right-4 top-4 z-10 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",onClick:z,children:[e.jsx(i.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]}),o&&e.jsxs("div",{className:"w-full md:w-1/2 min-h-[500px] relative hidden md:block overflow-hidden",children:[e.jsx("img",{src:o,alt:"Cancel Subscription",className:"absolute inset-0 w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-background/30 to-background/90 dark:block hidden"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-background/80 via-transparent to-background/20 dark:block hidden"})]}),e.jsxs("div",{className:ee("py-6 px-4 flex flex-col gap-4",o?"w-full md:w-1/2":"w-full"),children:[e.jsxs("div",{className:"flex flex-col gap-2 text-center md:text-left",children:[e.jsx("h2",{className:"md:text-2xl text-xl font-semibold",children:t}),e.jsx("p",{className:"md:text-sm text-xs text-muted-foreground",children:a}),S&&e.jsx("div",{className:"p-3 bg-destructive/10 border border-destructive/20 rounded-md",children:e.jsx("p",{className:"text-sm text-destructive",children:S})})]}),!y&&e.jsxs("div",{className:"flex flex-col gap-4 p-4 bg-muted/50 rounded-lg",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("span",{className:"font-semibold text-lg",children:[r.title," Plan"]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Current subscription"})]}),e.jsx(ra,{variant:"secondary",children:parseFloat(r.monthlyPrice)>=0?`${r.currency}${r.monthlyPrice}/monthly`:`${r.monthlyPrice}/monthly`})]}),e.jsx("div",{className:"flex flex-col gap-2",children:r.features.slice(0,4).map((t,a)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(i.Circle,{className:"w-2 h-2 fill-primary text-primary"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:t.name})]},a))})]}),!y&&(l||d)&&e.jsxs("div",{className:"p-4 bg-muted/30 border border-border rounded-lg",children:[l&&e.jsx("h3",{className:"font-semibold text-foreground mb-2",children:l}),d&&e.jsx("p",{className:"text-sm text-muted-foreground",children:d})]}),y?e.jsxs("div",{className:"flex flex-col gap-4 mt-auto",children:[e.jsxs("div",{className:"text-center p-4 bg-muted/50 rounded-lg",children:[e.jsx("h3",{className:"font-semibold mb-2 text-foreground",children:m||"Final Confirmation"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:x||"Are you sure you want to cancel your subscription?"}),e.jsx("p",{className:"text-sm text-destructive",children:p||"This action cannot be undone and you'll lose access to all premium features."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsx(vt,{variant:"outline",className:"flex-1",onClick:()=>{N(!1),P(null)},disabled:C,children:h||"Go Back"}),e.jsx(vt,{variant:"destructive",className:"flex-1",onClick:async()=>{try{k(!0),P(null),await f(r.id),z()}catch(e){P(e instanceof Error?e.message:"Failed to cancel subscription")}finally{k(!1)}},disabled:C,children:C?"Cancelling...":g||"Yes, Cancel Subscription"})]})]}):e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-auto",children:[e.jsx(vt,{className:"flex-1",onClick:async()=>{try{k(!0),P(null),b&&await b(r.id),z()}catch(e){P(e instanceof Error?e.message:"Failed to keep subscription")}finally{k(!1)}},disabled:C,children:C?"Processing...":c||"Keep My Subscription"}),e.jsx(vt,{variant:"destructive",className:"flex-1",onClick:()=>{N(!0),P(null)},disabled:C,children:u||"Continue Cancellation"})]})]})]})]})}const _r=C.cva("inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 px-2 min-w-9",sm:"h-8 px-1.5 min-w-8",lg:"h-10 px-2.5 min-w-10"}},defaultVariants:{variant:"default",size:"default"}});function Cr({className:t,variant:a,size:s,...r}){return e.jsx(G.Root,{"data-slot":"toggle",className:ee(_r({variant:a,size:s,className:t})),...r})}const kr=[.4,0,.2,1];function Sr({currentPlan:t,plans:a,onPlanChange:r,className:n,title:i,triggerText:o}){const[l,d]=s.useState(!1),[c,u]=s.useState(void 0),[m,x]=s.useState(!1),p=s.useCallback(e=>l?`${e.yearlyPrice}`:`${e.monthlyPrice}`,[l]),h=s.useCallback(e=>{u(t=>t===e?void 0:e)},[]),g=s.useCallback(e=>{x(e),e||u(void 0)},[]);return e.jsxs(ot,{open:m,onOpenChange:g,children:[e.jsx(lt,{asChild:!0,children:e.jsx(vt,{children:o||"Update Plan"})}),e.jsxs(mt,{className:ee("gap-3 sm:gap-4 max-h-[95vh] sm:max-h-[90vh] flex flex-col text-foreground","w-[calc(100vw-2rem)] sm:w-full max-w-2xl","p-4 sm:p-6",n),children:[e.jsxs(xt,{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 sm:gap-4 pb-2 sm:pb-0",children:[e.jsx(ht,{className:"text-lg sm:text-xl font-semibold",children:i||"Upgrade Plan"}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 text-sm",children:[e.jsx(Cr,{size:"sm",pressed:!l,onPressedChange:e=>d(!e),className:"px-3 sm:px-4 h-9 sm:h-10 text-xs sm:text-sm",children:"Monthly"}),e.jsx(Cr,{size:"sm",pressed:l,onPressedChange:e=>d(e),className:"px-3 sm:px-4 h-9 sm:h-10 text-xs sm:text-sm",children:"Yearly"})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto overflow-x-hidden -mx-4 sm:-mx-6 px-4 sm:px-6 [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-muted [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:border-2 [&::-webkit-scrollbar-thumb]:border-transparent hover:[&::-webkit-scrollbar-thumb]:bg-muted-foreground/20",style:{scrollbarWidth:"thin",scrollbarColor:"hsl(var(--muted)) transparent"},children:0===a.length?e.jsx("div",{className:"flex items-center justify-center py-12 text-center",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No plans available"})}):e.jsx(cr,{value:c,onValueChange:h,children:e.jsx("div",{className:"space-y-2.5 sm:space-y-3 pb-2 pr-0.5",children:a.map((a,s)=>e.jsxs(z.motion.div,{layout:!0,initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{layout:{duration:.3,ease:kr},opacity:{delay:.05*s,duration:.3,ease:kr},y:{delay:.05*s,duration:.3,ease:kr}},onClick:()=>h(a.id),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),h(a.id))},role:"button",tabIndex:0,"aria-pressed":c===a.id,className:ee("relative rounded-lg sm:rounded-xl border cursor-pointer overflow-hidden transition-all duration-200","touch-manipulation focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2",c===a.id?"border-primary bg-gradient-to-br from-muted/60 to-muted/30 shadow-sm":"border-border hover:border-primary/50"),children:[e.jsx(z.motion.div,{layout:"position",className:"p-3 sm:p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-2 sm:gap-3",children:[e.jsxs("div",{className:"flex gap-2 sm:gap-3 min-w-0 flex-1",children:[e.jsx(ur,{value:a.id,id:a.id,className:"flex-shrink-0 pointer-events-none mt-0.5 sm:mt-1"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 flex-wrap",children:[e.jsx(Lt,{htmlFor:a.id,className:"font-semibold sm:font-medium text-sm sm:text-base cursor-pointer leading-tight",children:a.title}),a.badge&&e.jsx(ra,{variant:"secondary",className:"flex-shrink-0 text-[10px] sm:text-xs px-1.5 sm:px-2 py-0 sm:py-0.5 h-5 sm:h-auto",children:a.badge})]}),e.jsx("p",{className:"text-[11px] sm:text-xs text-muted-foreground mt-1 leading-relaxed",children:a.description}),a.features.length>0&&e.jsx("div",{className:"pt-2 sm:pt-3",children:e.jsx("div",{className:"flex flex-wrap gap-1.5 sm:gap-2",children:a.features.map((t,a)=>e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 px-2 py-1 rounded-md sm:rounded-lg bg-muted/20 border border-border/30 flex-shrink-0",children:[e.jsx("div",{className:"w-1 h-1 sm:w-1.5 sm:h-1.5 rounded-full bg-primary flex-shrink-0"}),e.jsx("span",{className:"text-[10px] sm:text-xs text-muted-foreground whitespace-nowrap leading-none",children:t.name})]},a))})})]})]}),e.jsxs("div",{className:"text-right flex-shrink-0 min-w-[60px] sm:min-w-[80px]",children:[e.jsx("div",{className:"text-base sm:text-xl font-bold sm:font-semibold leading-tight",children:parseFloat(p(a))>=0?`${a.currency}${p(a)}`:p(a)}),e.jsxs("div",{className:"text-[10px] sm:text-xs text-muted-foreground mt-0.5",children:["/",l?"year":"month"]})]})]})}),e.jsx(z.AnimatePresence,{initial:!1,children:c===a.id&&e.jsx(z.motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1,transition:{height:{duration:.3,ease:kr},opacity:{duration:.25,delay:.05,ease:kr}}},exit:{height:0,opacity:0,transition:{height:{duration:.25,ease:kr},opacity:{duration:.15,ease:kr}}},className:"overflow-hidden",children:e.jsx(z.motion.div,{initial:{y:-8},animate:{y:0,transition:{duration:.25,delay:.05,ease:kr}},exit:{y:-8},className:"px-3 sm:px-4 pb-3 sm:pb-4",children:e.jsx(vt,{className:"w-full h-10 sm:h-11 text-sm sm:text-base font-medium touch-manipulation",disabled:c===t.id,onClick:e=>{e.stopPropagation(),r(a.id,l),g(!1)},children:c===t.id?"Current Plan":"Upgrade"})})})})]},a.id))})})})]})]})}function Pr({className:t,currentPlan:a,cancelSubscription:s,updatePlan:r,canShowUpdatePlanBtn:n,addMoreBtnProps:o,canShowCancelPlanBtn:l}){return e.jsx("div",{className:ee("text-left w-full",t),children:e.jsxs(It,{className:"",children:[e.jsxs(Ft,{className:"pb-4 sm:pb-6 px-4 sm:px-6",children:[e.jsxs(Ot,{className:"flex items-center gap-2 sm:gap-3 text-lg sm:text-xl",children:[e.jsx("div",{className:"p-1.5 sm:p-2 rounded-lg bg-primary/10 ring-1 ring-primary/20",children:e.jsx(i.CreditCard,{className:"h-4 w-4 sm:h-5 sm:w-5 text-primary"})}),"Current Subscription"]}),e.jsx(Dt,{className:"text-sm sm:text-base",children:"Manage your billing and subscription settings"})]}),e.jsxs(At,{className:"space-y-6 sm:space-y-8 px-4 sm:px-6",children:[e.jsx("div",{className:"relative p-3 sm:p-4 rounded-xl bg-gradient-to-r from-muted/30 via-muted/20 to-muted/30 border border-border/50 overflow-hidden",children:e.jsx("div",{className:"relative",children:e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 sm:gap-0",children:e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-3 mb-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("h3",{className:"text-lg sm:text-xl font-semibold",children:[a.plan.title," Plan"]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(ra,{variant:"active"===a.status?"default":"outline",className:"shadow-sm text-xs sm:text-sm bg-primary/90 hover:bg-primary border-0 font-medium",children:"monthly"===a.type?`${a.plan.currency}${a.plan.monthlyPrice}/month`:"yearly"===a.type?`${a.plan.currency}${a.plan.yearlyPrice}/year`:`${a.price}`}),e.jsx(ra,{variant:"outline",className:"shadow-sm text-xs sm:text-sm border-border/60 bg-background/50 backdrop-blur-sm",children:a.status})]})]}),e.jsx("div",{className:"relative",children:e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground relative z-10",children:a.plan.description})})]})})})}),e.jsx(na,{className:"my-4 sm:my-6 bg-gradient-to-r from-transparent via-border to-transparent"}),e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsxs("h4",{className:"font-medium flex items-center gap-2 text-base sm:text-lg",children:[e.jsx("div",{className:"p-1 sm:p-1.5 rounded-md bg-muted ring-1 ring-border/50",children:e.jsx(i.Calendar,{className:"h-3 w-3 sm:h-4 sm:w-4"})}),"Billing Information"]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 sm:gap-6",children:[e.jsxs("div",{className:"group p-2.5 sm:p-3 rounded-lg md:bg-gradient-to-tl bg-gradient-to-b from-muted to-background/10 border border-border/30 hover:border-border/60 transition-all duration-200",children:[e.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground block mb-1",children:"Start Date"}),e.jsx("div",{className:"font-medium text-sm sm:text-base group-hover:text-primary transition-colors duration-200",children:a.startDate})]}),e.jsxs("div",{className:"group p-2.5 sm:p-3 rounded-lg md:bg-gradient-to-tl bg-gradient-to-b from-muted to-background/10 border border-border/30 hover:border-border/60 transition-all duration-200",children:[e.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground block mb-1",children:"Plan Expiry Date"}),e.jsx("div",{className:"font-medium text-sm sm:text-base group-hover:text-primary transition-colors duration-200",children:a.expiryDate})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 sm:gap-6",children:[e.jsxs("div",{className:"group p-2.5 sm:p-3 rounded-lg md:bg-gradient-to-tl bg-gradient-to-b from-muted to-background/10 border border-border/30 hover:border-border/60 transition-all duration-200",children:[e.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground block mb-1",children:"Active Plan for"}),e.jsxs("div",{className:"font-medium text-sm sm:text-base group-hover:text-primary transition-colors duration-200",children:[a.activePlanFor," users"]})]}),e.jsxs("div",{className:"group p-2.5 sm:p-3 rounded-lg md:bg-gradient-to-tr bg-gradient-to-b from-muted to-background/10 border border-border/30 hover:border-border/60 transition-all duration-200",children:[e.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground block mb-1",children:"Total Paid Amount"}),e.jsx("div",{className:"font-medium text-sm sm:text-base group-hover:text-primary transition-colors duration-200",children:a.paidAmount})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 sm:gap-6",children:[e.jsxs("div",{className:"group p-2.5 sm:p-3 rounded-lg md:bg-gradient-to-tr bg-gradient-to-b from-muted to-background/10 border border-border/30 hover:border-border/60 transition-all duration-200",children:[e.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground block mb-1",children:"Payment method"}),e.jsx("div",{className:"font-medium text-sm sm:text-base group-hover:text-primary transition-colors duration-200",children:a.paymentMethod})]}),e.jsxs("div",{className:"group p-2.5 sm:p-3 rounded-lg md:bg-gradient-to-tr bg-gradient-to-b from-muted to-background/10 border border-border/30 hover:border-border/60 transition-all duration-200",children:[e.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground block mb-1",children:"Order Id"}),e.jsx("div",{className:"font-medium text-sm sm:text-base group-hover:text-primary transition-colors duration-200",children:a.transactionId||"N/A"})]})]})]}),e.jsx(na,{className:"my-4 sm:my-6 bg-gradient-to-r from-transparent via-border to-transparent"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[n&&e.jsx(Sr,{className:"mx-0 shadow-lg hover:shadow-xl transition-all duration-200",...r}),o&&o.canShow&&e.jsx(vt,{...o.buttonProps,children:o.text}),l&&e.jsx(wr,{className:"mx-0 shadow-lg hover:shadow-xl transition-all duration-200",...s}),e.jsx(qa,{to:"/plans",children:e.jsxs(vt,{variant:"outline",children:["Buy Upcoming Plan ",e.jsx(i.MoveUpRight,{})]})})]}),e.jsxs("div",{className:"pt-4 sm:pt-6",children:[e.jsx("h4",{className:"font-medium mb-3 sm:mb-4 text-base sm:text-lg",children:"Current Plan Features"}),e.jsx("div",{className:"flex flex-wrap gap-2 sm:gap-3",children:a.plan.features.map((t,a)=>e.jsxs("div",{className:"group flex items-center gap-2 p-2 sm:p-2 rounded-lg border border-border/80 hover:border-primary/30 hover:bg-primary/5 transition-all duration-200",children:[e.jsx("div",{className:"w-1 h-1 sm:w-1.5 sm:h-1.5 rounded-full bg-primary flex-shrink-0 group-hover:bg-primary group-hover:scale-125 transition-all duration-200"}),e.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground group-hover:text-foreground transition-colors duration-200",children:t.name})]},a))})]})]})]})})}const zr=({upcomingPlans:t,Icon:a,title:r,badgeText:n,isFreePlan:o=!1})=>{const{subscriptionConfig:l,orgs:d,featureFlags:c}=s.useContext(Pe),{plans:u}=l;return e.jsxs(It,{className:"mt-5",children:[e.jsx(Ft,{children:e.jsxs(Ot,{className:"flex items-center gap-2 sm:gap-3 text-lg sm:text-xl",children:[e.jsx("div",{className:"p-1.5 sm:p-2 rounded-lg bg-primary/10 ring-1 ring-primary/20",children:e.jsx(a,{className:"h-4 w-4 sm:h-5 sm:w-5 text-primary"})}),r]})}),e.jsx(At,{children:e.jsx("div",{className:"flex flex-wrap gap-2 sm:gap-3",children:t.length?t.map(t=>{const a=u.find(e=>e.id===t.plan_id);return e.jsx("div",{className:"w-full relative p-3 sm:p-4 rounded-xl bg-gradient-to-r from-muted/30 via-muted/20 to-muted/30 border border-border/50 overflow-hidden",children:e.jsx("div",{className:"relative",children:e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 sm:gap-0",children:e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-3 mb-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("h3",{className:"text-lg sm:text-xl font-semibold",children:[a?.title," Plan"]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(ra,{variant:"active"===t.status?"default":"outline",className:"shadow-sm text-xs sm:text-sm bg-primary/90 hover:bg-primary border-0 font-medium text-primary-foreground",children:[Re(t.z_currency),t.amount]}),e.jsx(ra,{variant:"outline",className:"shadow-sm text-xs sm:text-sm border-border/60 bg-background/50 backdrop-blur-sm",children:n})]})]}),o?e.jsx(e.Fragment,{children:e.jsxs("div",{className:"mt-5",children:[e.jsx(qa,{to:"/plans",children:e.jsx(Ka,{children:"Upgrade to premium"})}),c.ff_enable_teams&&0===d.length&&e.jsx(qa,{to:"/infrastructure/create-new-org",children:e.jsxs(vt,{className:"ml-2",variant:"outline",children:[e.jsx(i.LogIn,{})," Continue with Free Plan"]})})]})}):e.jsx("div",{className:"relative",children:e.jsxs("span",{className:"text-xs sm:text-sm text-muted-foreground relative z-10",children:[e.jsxs("p",{children:[t.for_no_users," Users for ",t.for_months," Months"]}),e.jsxs("p",{children:["Start Date: ",pe(t.startAt)]}),e.jsxs("p",{children:["End Date: ",pe(t.endAt)]}),e.jsxs("p",{children:["Order Id: ",t.z_order_id]})]})})]})})})},t.z_order_id)}):e.jsxs("p",{className:"text-center text-muted-foreground",children:["No ",n," Plans"]})})})]},"upcoming-plans")},Tr=s.forwardRef(function({title:t="Congratulations!",subtitle:a="Your payment was successful.",currencySymbol:r="$",price:n,productName:o,proceedButtonText:l="Proceed",backButtonText:d="Back",onProceed:c,onBack:u,className:m,open:x,onOpenChange:p},h){const g=void 0!==x,[f,b]=s.useState(!1),v=g?x:f,j=e=>{g?p?.(e):b(e)};s.useImperativeHandle(h,()=>({open:()=>j(!0),close:()=>j(!1)}),[g,p]);const[y,N]=s.useState(!1);s.useEffect(()=>{if(v){N(!0);const e=setTimeout(()=>N(!1),2200);return()=>clearTimeout(e)}N(!1)},[v]);const w=s.useMemo(()=>{const e=[],t=["--primary","--accent","--secondary"];for(let a=0;a<42;a++){const s=100*Math.random(),r=24*(Math.random()-.5);e.push({id:a,x:s,xEnd:Math.max(0,Math.min(100,s+r)),delay:.4*Math.random(),rotation:360*Math.random(),size:6+Math.round(6*Math.random()),colorVar:t[a%t.length]})}return e},[]);return e.jsx(ot,{open:v,onOpenChange:j,children:e.jsx(mt,{className:ee("w-[95%] sm:max-w-[560px] p-0 overflow-hidden text-foreground",m),children:e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"p-7 flex flex-col items-center text-center gap-5",children:[e.jsxs("div",{className:"relative",children:[e.jsx(z.motion.div,{className:"absolute inset-0 -z-10 mx-auto size-20 rounded-full blur-xl",style:{background:"var(--primary)",opacity:.12},initial:{scale:.9,opacity:0},animate:{scale:1,opacity:.12},transition:{duration:.5,ease:"easeOut"}}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"size-16 rounded-full bg-primary/10 flex items-center justify-center border border-primary/30 shadow-sm",children:e.jsx(i.CheckCircle2,{className:"size-10 text-primary"})}),e.jsx(z.motion.span,{className:"absolute inset-0 rounded-full border-2 border-primary/30",initial:{scale:.9,opacity:.5},animate:{scale:1.25,opacity:0},transition:{duration:1.2,repeat:1/0,ease:"easeOut"}}),e.jsx(z.motion.span,{className:"absolute inset-0 rounded-full border-2 border-accent/30",initial:{scale:.9,opacity:.5},animate:{scale:1.6,opacity:0},transition:{duration:1.6,repeat:1/0,ease:"easeOut",delay:.2}})]})]}),e.jsx(xt,{className:"text-center",children:e.jsx(ht,{className:"text-2xl font-semibold",children:t})}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-[38ch]",children:a}),e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsxs(z.motion.div,{className:"text-4xl font-semibold tracking-tight",initial:{y:6,opacity:0},animate:{y:0,opacity:1},transition:{type:"spring",stiffness:280,damping:22},children:[r,n]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Paid for ",o]})]}),e.jsxs(pt,{className:"w-full flex-col sm:flex-col gap-3 mt-1",children:[e.jsx(vt,{variant:"outline",className:"w-full",onClick:()=>{u?.(),j(!1)},children:d}),e.jsx(vt,{className:"w-full",onClick:()=>{c?.(),j(!1)},children:l})]})]}),e.jsx(z.AnimatePresence,{children:y&&e.jsx(z.motion.div,{className:"pointer-events-none absolute inset-0",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:w.map(t=>e.jsx(z.motion.span,{className:"absolute block rounded-[2px]",style:{left:`${t.x}%`,top:"-16px",width:t.size,height:.6*t.size,backgroundColor:`var(${t.colorVar})`},initial:{y:-20,rotate:t.rotation},animate:{y:360+80*Math.random(),x:`${t.xEnd}%`,rotate:t.rotation+720},transition:{duration:1.8+.8*Math.random(),delay:t.delay,ease:"easeOut"}},t.id))})})]})})})}),Ir=({isOpen:t,setIsOpen:r,purchasePlanId:n})=>{const{purchasePlans:i,subscriptionConfig:o,loggedInUser:l}=s.useContext(Pe),{plans:d,CURRENCY_SYMBOL:c,CURRENCY:u}=o,[m,x]=s.useState(1),[p,h]=s.useTransition(),{Razorpay:g}=F.useRazorpay(),{loadPurchasedPlans:f}=Be(),b=a.useNavigate(),[v,j]=s.useState(!1),y=s.useMemo(()=>i.find(e=>e.purchased_id===n),[i,n]),N=s.useMemo(()=>d.find(e=>e.id===y?.plan_id),[d,y]),w=s.useMemo(()=>{if(!y||!N)return 0;return(12===y.for_months?parseFloat(N.yearlyPrice):parseFloat(N.monthlyPrice))*m},[y,N,m]);return y&&N?e.jsxs(jt,{open:t,setIsOpen:r,disableOutsideClick:!0,header:`Add More Users in ${N.title}`,actionsJSX:e.jsxs(e.Fragment,{children:[e.jsx(vt,{variant:"outline",onClick:()=>{x(1),r(!1)},children:"Cancel"}),e.jsx(vt,{onClick:()=>{r(!1),h(async()=>{try{await new Promise(e=>setTimeout(e,200));const e=await Ae().post("payment-gateway/add-more-users-order",{purchased_id:n,currency:u,for_no_users:m});await $e(w,u,e,{name:`${l.fname} ${l.lname}`,email:l.email,contact:l.mobNo?.toString()||""},g),r(!0),j(!0)}catch(e){r(!0),Fe({header:"Failed to add users.",description:"Please try again later or contact support if the issue persists."})}finally{f()}})},disabled:m<1,loading:p,children:"Make Payment"})]}),children:[e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Order ID:"})," ",y.z_order_id]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Current Users:"})," ",y.for_no_users]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Plan Duration:"})," ",12===y.for_months?"Yearly":"Monthly"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Lt,{htmlFor:"numberOfUsers",children:"Number of Users to Add"}),e.jsx(Et,{id:"numberOfUsers",type:"number",min:"1",value:m,onChange:e=>x(Math.max(1,parseInt(e.target.value)||1)),placeholder:"Enter number of users"})]}),e.jsxs("div",{className:"rounded-lg bg-muted p-4 space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm font-medium",children:"Price per user:"}),e.jsxs("span",{className:"text-sm",children:[c,12===y.for_months?N.yearlyPrice:N.monthlyPrice]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm font-medium",children:"Number of users:"}),e.jsx("span",{className:"text-sm",children:m})]}),e.jsx("div",{className:"border-t pt-2 mt-2",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"font-semibold",children:"Total Amount:"}),e.jsxs("span",{className:"text-lg font-bold text-primary",children:[c,w.toFixed(2)]})]})})]})]}),e.jsx(Tr,{open:v,onOpenChange:e=>{j(e),e||b("/infrastructure/payment-history")},price:w.toFixed(2),currencySymbol:c,productName:N.title,proceedButtonText:"Go to Dashboard",backButtonText:"Go to Payment History",onProceed:()=>b("/"),onBack:()=>b("/infrastructure/payment-history")})]}):(Fe({header:"Failed to load plan details.",description:"Please try again later or contact support if the issue persists."}),null)};var Fr=Object.freeze({__proto__:null,default:()=>{const t=a.useNavigate(),{activePlan:r,purchasePlans:n,subscriptionConfig:o}=s.useContext(Pe),{plans:l,CURRENCY_SYMBOL:d}=o,[c,u]=s.useState(!1),m=l.find(e=>e.id===r?.plan_id)||l[0],x=s.useMemo(()=>n.filter(e=>"paid"===e.status&&new Date(e.startAt)>new Date).reverse(),[n]),p=s.useMemo(()=>n.filter(e=>"paid"===e.status&&new Date(e.endAt)<new Date),[n]),h=!r||Me(r);return e.jsx(ja,{children:e.jsxs("div",{className:"pb-5 sm:pl-20 px-2 w-200 mx-auto",children:[h?e.jsx(zr,{upcomingPlans:[r],Icon:i.CreditCard,title:"Current Subscription",badgeText:"Active",isFreePlan:!0}):e.jsxs(e.Fragment,{children:[e.jsx(Pr,{currentPlan:{plan:m,type:12===r.for_months?"yearly":"monthly",startDate:pe(r.startAt),expiryDate:pe(r.endAt),paymentMethod:(g=r.z_payment_method,"netbanking"===g?"Net Banking":"wallet"===g?"Wallet":"upi"===g?"UPI":"card"===g?"Card":g),activePlanFor:r.for_no_users,paidAmount:`${d}${r.amount}`,status:"active",transactionId:(()=>{const e=[r.z_order_id];return r.updatedRecords&&r.updatedRecords.forEach(t=>{"paid"===t.status&&e.push(t.z_order_id)}),e.join(", ")})()},canShowCancelPlanBtn:!1,cancelSubscription:{title:"Cancel Subscription",description:"Are you sure you want to cancel your subscription?",plan:m,onCancel:e=>console.log("Subscription cancelled for plan:",e),onKeepSubscription:e=>console.log("Subscription kept for plan:",e)},addMoreBtnProps:{text:"Add more users to your plan",buttonProps:{onClick:()=>u(!0)},canShow:r.for_no_users<m.maxUserRequired},canShowUpdatePlanBtn:!1,updatePlan:{currentPlan:m,plans:l,triggerText:"Change Plan",onPlanChange:(e,a)=>{t(`/infrastructure/checkout?plan=${e}&billing=${a?"yearly":"monthly"}`)}}}),e.jsx(Ir,{isOpen:c,setIsOpen:u,purchasePlanId:r.purchased_id})]}),e.jsx(zr,{upcomingPlans:x,Icon:i.GalleryVerticalEnd,title:"Upcoming Plans",badgeText:"Upcoming"}),e.jsx(zr,{upcomingPlans:p,Icon:i.History,title:"Expired Plans",badgeText:"Expired"})]})});var g}});const Or=C.cva("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"}},defaultVariants:{variant:"default"}});function Dr({className:t,variant:a,...s}){return e.jsx("div",{"data-slot":"alert",role:"alert",className:ee(Or({variant:a}),t),...s})}function Ar({className:t,...a}){return e.jsx("div",{"data-slot":"alert-title",className:ee("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",t),...a})}function Er({className:t,...a}){return e.jsx("div",{"data-slot":"alert-description",className:ee("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",t),...a})}var Lr=Object.freeze({__proto__:null,default:()=>{const{Razorpay:t}=F.useRazorpay(),{loggedInUser:r,subscriptionConfig:n,activePlan:o}=s.useContext(Pe),[l]=a.useSearchParams(),d=l.get("plan"),c=l.get("billing")||"yearly",u=(()=>{const[e,t]=s.useState([]);return s.useEffect(()=>{(async()=>{const e=re("countries");if(e)try{const a=JSON.parse(e);if(Array.isArray(a))return void t(a)}catch{}const a=(await Ae().get("get-countries")).countries??[];a.length>0&&se("countries",JSON.stringify(a)),t(a)})()},[]),e})(),m=a.useNavigate(),[x,p]=s.useState(!1),[h,g]=s.useState(!1),{plans:f,CURRENCY:b,CURRENCY_SYMBOL:v}=n,j=f.find(e=>e.id===d)||f[0],{minUserRequired:y,maxUserRequired:N}=j,[w,_]=s.useState(c),[C,k]=s.useState(y),S=C<=y?y:C,P="yearly"===w?j.yearlyPrice:j.monthlyPrice,z=S*parseFloat(P),T="yearly"===w?12:1,I=j.monthlyPrice,O=T*S*parseFloat(I),D=s.useRef({fullName:r?.fname+" "+r?.lname,country:"",address:"",email:r?.email,mobileNo:r?.mobNo?.toString()}),{loadPurchasedPlans:A}=Be();if("0"===j.monthlyPrice||"0"===j.yearlyPrice)return e.jsx(a.Navigate,{to:"/"});return e.jsxs(ja,{className:"pb-5",responsive:!0,children:[e.jsxs("div",{className:"sm:mx-auto mx-1 px-5",children:[e.jsxs(Aa,{className:"mb-4",children:['Checkout "',j.title,'" Plan'," ",e.jsx(qa,{className:"text-xs text-primary",to:"/plans",children:"Change Plan"})]}),Me(o)?null:e.jsxs(Dr,{variant:"default",className:"mb-5",children:[e.jsx(i.AlertCircleIcon,{}),e.jsx(Ar,{children:"You currently have an active paid plan."}),e.jsx(Er,{children:e.jsxs("p",{children:["Please be aware that this purchase is for an upcoming plan. Check your"," ",e.jsx(qa,{className:"text-primary",to:"/infrastructure/manage-subscription",children:"current subscription"}),"."]})})]}),e.jsxs(ja,{layout:"horizontal",className:"gap-5",responsive:!0,children:[e.jsxs(ja,{layout:"vertical",className:"sm:w-150 w-full gap-5",doNotAppendFlex1:!0,responsive:!0,children:[e.jsxs(It,{children:[e.jsxs(Ft,{children:[e.jsx(Ot,{children:"Specify billing period and team size"}),e.jsx(Dt,{children:"With yearly plans, you can save up to 17%."})]}),e.jsx(At,{children:e.jsxs("div",{className:"grid gap-6",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Lt,{children:"Billing period *"}),e.jsx(Ga,{triggerClassName:"w-full",placeholder:"Select billing period",items:[{value:"monthly",label:`Monthly - ${j.planDisplayCost?.monthly}`},{value:"yearly",label:`Yearly - ${j.planDisplayCost?.yearly}`}],value:w,onValueChange:e=>_(e)})]}),y>1?e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(Lt,{htmlFor:"teamSize",children:["Team Size (This should be ",y," or > ",y,") *"]}),e.jsx(Et,{type:"number",id:"teamSize",placeholder:"",min:y,max:N,value:C,onChange:e=>k(Math.max(y,parseInt(e.target.value)||y))})]}):e.jsx(e.Fragment,{})]})})]}),e.jsxs(It,{children:[e.jsxs(Ft,{children:[e.jsx(Ot,{children:"Billing Details"}),e.jsx(Dt,{children:"To finalize your subscription, kindly complete your details."})]}),e.jsx(At,{children:e.jsxs("div",{className:"grid gap-6",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Lt,{htmlFor:"fullName",children:"Full Name *"}),e.jsx(Et,{onChange:e=>D.current.fullName=e.currentTarget.value,id:"fullName",type:"text",placeholder:"",name:"fullName",defaultValue:r?.fname+" "+r?.lname})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Lt,{htmlFor:"country",children:"Country *"}),e.jsx(Ga,{valueField:"countryCode",labelField:"countryName",triggerClassName:"w-full",placeholder:"",items:u,onValueChange:e=>{D.current.country=e}})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Lt,{htmlFor:"address",children:"Address *"}),e.jsx(pa,{onChange:e=>D.current.address=e.target.value,id:"address",placeholder:""})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Lt,{htmlFor:"email",children:"Email *"}),e.jsx(Et,{defaultValue:r?.email,onChange:e=>D.current.email=e.target.value,id:"email",type:"email",placeholder:"",name:"email"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Lt,{htmlFor:"mobileNo",children:"Mobile No *"}),e.jsx(Et,{onChange:e=>D.current.mobileNo=e.target.value,id:"mobileNo",type:"number",placeholder:"",name:"mobileNo",defaultValue:r?.mobNo})]})]})})]})]}),e.jsxs(ja,{layout:"vertical",className:"sm:w-80 w-full",doNotAppendFlex1:!0,responsive:!0,children:[e.jsxs(It,{children:[e.jsx(Ft,{children:e.jsx(Ot,{children:"Summary"})}),e.jsx(At,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Subtotal"}),e.jsxs("span",{className:"tabular-nums",children:[v,O.toFixed(2)]})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Discount (Yearly)"}),e.jsxs("span",{className:"tabular-nums",children:["- ",v,(O-z).toFixed(2)]})]}),e.jsxs("div",{className:"flex items-center justify-between border-t pt-2",children:[e.jsx("span",{className:"font-medium",children:"Total"}),e.jsxs("span",{className:"text-xl font-semibold tabular-nums",children:[v,z.toFixed(2)]})]})]})})]}),e.jsxs(vt,{className:"mt-5",onClick:async()=>{const e=(()=>{const e={},t=D.current;return t.fullName.trim()||(e.fullName="Full Name is required."),t.country.trim()||(e.country="Country is required."),t.address.trim()?t.address.trim().length<5&&(e.address="Address must be at least 5 characters."):e.address="Address is required.",t.email.trim()?ue(t.email)||(e.email="Email is invalid."):e.email="Email is required.",t.mobileNo?.toString().trim()?(!/^\d+$/.test(t.mobileNo?.toString())||t.mobileNo?.toString().trim().length<10||t.mobileNo?.toString().trim().length>15)&&(e.mobileNo="Mobile Number is invalid (must be 10-15 digits)."):e.mobileNo="Mobile Number is required.",e})();if(Object.keys(e).length>0)Object.values(e).reverse().forEach(e=>Fe({header:"Invalid Billing Details",description:e}));else try{g(!0);const e=await Ae().post("payment-gateway/create-order",{planId:j.id,currency:b,billingPeriod:w||"yearly",for_no_users:S,billing_name:D.current.fullName,billing_email:D.current.email,billing_contact_no:D.current.mobileNo,billing_address:D.current.address,billing_country:D.current.country}),a=D.current;await $e(z,b,e,{name:a.fullName||`${r.fname} ${r.lname}`,email:a.email||r.email,contact:a.mobileNo?.toString()||r.mobNo?.toString()||""},t),p(!0)}catch(e){Fe({header:"Payment Failed!",description:e?.message})}finally{await A(),g(!1)}},loading:h,children:["Make Payment ",e.jsx(i.ArrowRight,{})]})]})]})]}),e.jsx(Tr,{open:x,onOpenChange:e=>{p(e),e||m("/infrastructure/payment-history")},price:z.toFixed(2),currencySymbol:v,productName:j.title,proceedButtonText:"Go to Dashboard",backButtonText:"Go to Payment History",onProceed:()=>m("/"),onBack:()=>m("/infrastructure/payment-history")})]})}});function Rr({className:t,title:a="Invoice History",description:s="Your past invoices and payment receipts.",invoices:r,onDownload:n}){if(!r)return null;const o=t=>{switch(t){case"paid":return e.jsx(ra,{className:"bg-emerald-600 text-emerald-50 border-emerald-700/40",children:"Paid"});case"refunded":return e.jsx(ra,{variant:"secondary",children:"Refunded"});case"idle":return e.jsx(ra,{variant:"outline",children:"Open"});case"verified":return e.jsx(ra,{variant:"outline",children:"Verified"});case"failed":return e.jsx(ra,{variant:"destructive",children:"Failed"})}};return e.jsxs(It,{className:ee("w-full",t),children:[(a||s)&&e.jsxs(Ft,{className:"space-y-1",children:[a&&e.jsxs(Ot,{className:"text-base font-medium leading-tight truncate flex items-center gap-2 sm:gap-3 text-lg sm:text-xl",children:[e.jsx(i.ReceiptText,{className:"h-4 w-4 text-primary"}),a]}),s&&e.jsx(Dt,{className:"text-sm text-muted-foreground",children:s})]}),e.jsx(At,{children:e.jsxs(_t,{children:[e.jsx(Tt,{className:"sr-only",children:"List of past invoices with dates, amounts, status and download actions"}),e.jsx(Ct,{children:e.jsxs(St,{children:[e.jsx(Pt,{className:"w-[120px]",children:"Date"}),e.jsx(Pt,{className:"text-left",children:"Order ID"}),e.jsx(Pt,{children:"Description"}),e.jsx(Pt,{className:"text-right",children:"Amount"}),e.jsx(Pt,{className:"text-right",children:"Status"}),e.jsx(Pt,{className:"text-right",children:"Action"})]})}),e.jsxs(kt,{children:[0===r.length&&e.jsx(St,{children:e.jsx(zt,{colSpan:6,className:"h-24 text-center text-muted-foreground",children:"No invoices yet"})}),r.map(t=>e.jsxs(St,{className:"group",children:[e.jsx(zt,{className:"text-muted-foreground",children:e.jsxs("div",{className:"inline-flex items-center gap-2",children:[e.jsx(i.CalendarDays,{className:"h-3.5 w-3.5"}),t.date]})}),e.jsx(zt,{className:"text-left",children:t.transactionId}),e.jsx(zt,{className:"max-w-[320px]",children:e.jsx("div",{className:"truncate",title:t.description||"Invoice",children:t.description||"Invoice"})}),e.jsx(zt,{className:"text-right font-medium",children:t.amount}),e.jsx(zt,{className:"text-right",children:o(t.status)}),e.jsx(zt,{className:"text-right",children:e.jsxs(vt,{variant:"outline",size:"sm",className:"h-8 text-xs",onClick:()=>t.invoiceUrl?window.open(t.invoiceUrl,"_blank","noopener,noreferrer"):n?.(t.id),"aria-label":`Download invoice ${t.id}`,children:[e.jsx(i.Download,{className:"h-3.5 w-3.5"}),"Download"]})})]},t.id))]})]})})]})}var Mr=Object.freeze({__proto__:null,default:()=>{const{purchasePlans:t,subscriptionConfig:a}=s.useContext(Pe),{plans:r}=a,n=[];return t.forEach(e=>{const t=r.find(t=>t.id===e.plan_id),a={id:e.z_order_id,date:pe(e.purchased_at),amount:`${Re(e.z_currency)}${e.old_purchased_amount||e.amount} (${e.z_currency})`,status:e.status,description:`${t?.title} — ${e.for_months} months, ${e.old_purchased_for_no_users||e.for_no_users} users`,transactionId:e.z_order_id};e.updatedRecords&&e.updatedRecords.forEach(t=>{n.push({id:t.z_order_id,date:pe(t.updated_at),amount:`${Re(t.z_currency)}${t.amount} (${t.z_currency})`,status:t.status,description:`Added ${t.for_no_users} more users, in ${e.z_order_id}`,transactionId:t.z_order_id})}),n.push(a)}),n.sort((e,t)=>new Date(e.date).getTime()-new Date(t.date).getTime()),e.jsx(ja,{children:e.jsx("div",{className:"w-full sm:max-w-250 mx-auto",children:e.jsx(Rr,{title:"Payment History",description:"Your past payment receipts.",className:"shadow-none border-none",invoices:n.reverse()})})})}});const $r=()=>{const{theme:t,setTheme:a}=ke();return e.jsxs(Rt,{value:t,onValueChange:e=>{a(e)},children:[e.jsx($t,{className:"w-[180px]",children:e.jsx(Mt,{placeholder:"Theme"})}),e.jsxs(Ut,{children:[e.jsx(Bt,{value:"light",children:"Light"}),e.jsx(Bt,{value:"dark",children:"Dark"}),e.jsx(Bt,{value:"system",children:"System"})]})]})};var Ur=Object.freeze({__proto__:null,default:()=>{const{featureFlags:t}=s.useContext(Pe);return e.jsxs(ja,{className:"pr-5 pl-5",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(Ha,{children:"Email Settings"}),e.jsx(Wa,{title:"Security emails",description:"Receive emails about your account security.",control:e.jsx(Qt,{checked:!0,disabled:!0})})]}),e.jsxs("div",{className:"space-y-3 mt-4",children:[e.jsx(Ha,{children:"Theme"}),e.jsx(Wa,{title:"Specify theme",description:"Choose your preferred theme to enhance your reading experience.",control:e.jsx($r,{})})]}),t?.ff_enable_teams&&e.jsxs("div",{className:"space-y-3 mt-4",children:[e.jsx(Ha,{children:e.jsxs(e.Fragment,{children:[Z.account_type_txt.plural," Settings"]})}),e.jsx(qa,{to:"/infrastructure/manage-infra",children:e.jsx(Wa,{title:`Manage ${Z.account_type_txt.plural}`,description:`Create and manage ${Z.account_type_txt.plural}, update ${Z.account_type_txt.singular} details, and invite members as needed.`,control:e.jsx(i.SquareArrowOutUpRight,{}),labelCls:"cursor-pointer"})}),e.jsx(qa,{to:"/infrastructure/user-invitations",children:e.jsx(Wa,{title:"Check Invitations",description:`View and respond to ${Z.account_type_txt.singular} invitations you have received.`,control:e.jsx(i.SquareArrowOutUpRight,{}),labelCls:"cursor-pointer",className:"mt-3"})})]})]})}});exports.AccordionWrapper=Ua,exports.AlertDialog=Nt,exports.Badge=ra,exports.BigSquare=Va,exports.Button=vt,exports.Card=It,exports.CardAction=function({className:t,...a}){return e.jsx("div",{"data-slot":"card-action",className:ee("col-start-2 row-span-2 row-start-1 self-start justify-self-end",t),...a})},exports.CardContent=At,exports.CardDescription=Dt,exports.CardFooter=function({className:t,...a}){return e.jsx("div",{"data-slot":"card-footer",className:ee("flex items-center px-6 [.border-t]:pt-6",t),...a})},exports.CardHeader=Ft,exports.CardTitle=Ot,exports.CenterAndMiddle=({className:t="",children:a})=>e.jsx("div",{className:`flex-1 flex items-center justify-center ${t}`,children:a}),exports.CopyTextField=({copyText:t})=>{const[a,r]=s.useState(!1);return e.jsxs("div",{className:"flex gap-2",children:[e.jsx(pa,{readOnly:!0,value:t}),e.jsx(vt,{variant:"outline",size:"icon",onClick:()=>(async e=>{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),2e3),Ie({description:"Copied to clipboard"})})(t),className:"shrink-0",children:e.jsx("span",{className:"flex items-center",children:a?e.jsx(i.Check,{size:16,className:"text-green-500"}):e.jsx(i.Copy,{size:16})})})]})},exports.DataTable=Oa,exports.DialogWrapper=jt,exports.DropdownBtn=({label:t,children:a,items:s,onItemSelect:r,disabled:n})=>e.jsxs(ia,{children:[e.jsx(oa,{asChild:!0,disabled:n,children:a||e.jsxs(vt,{className:"flex items-center gap-1",children:[t," ",e.jsx(i.ChevronDown,{size:15})]})}),e.jsx(la,{children:s.map(t=>e.jsx(ca,{onClick:()=>r?.(t),children:t.label},t.value))})]}),exports.DropdownLbl=({label:t,selectedRec:a,setSelectedRec:s,items:r})=>e.jsxs(ia,{children:[e.jsx(oa,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-2",children:[t&&e.jsx(Lt,{className:"whitespace-nowrap",children:t}),e.jsxs("span",{className:"whitespace-nowrap text-primary flex items-center gap-1 text-sm cursor-pointer",children:[a.label," ",e.jsx(i.ChevronDown,{size:15})]})]})}),e.jsx(la,{children:r.map(t=>e.jsx(ca,{onClick:()=>s(t),children:t.label},t.value))})]}),exports.DropdownMenu=ia,exports.DropdownMenuCheckboxItem=ua,exports.DropdownMenuContent=la,exports.DropdownMenuGroup=da,exports.DropdownMenuItem=ca,exports.DropdownMenuLabel=ma,exports.DropdownMenuPortal=function({...t}){return e.jsx(q.Portal,{"data-slot":"dropdown-menu-portal",...t})},exports.DropdownMenuRadioGroup=function({...t}){return e.jsx(q.RadioGroup,{"data-slot":"dropdown-menu-radio-group",...t})},exports.DropdownMenuRadioItem=function({className:t,children:a,...s}){return e.jsxs(q.RadioItem,{"data-slot":"dropdown-menu-radio-item",className:ee("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...s,children:[e.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:e.jsx(q.ItemIndicator,{children:e.jsx(i.CircleIcon,{className:"size-2 fill-current"})})}),a]})},exports.DropdownMenuSeparator=xa,exports.DropdownMenuShortcut=function({className:t,...a}){return e.jsx("span",{"data-slot":"dropdown-menu-shortcut",className:ee("text-muted-foreground ml-auto text-xs tracking-widest",t),...a})},exports.DropdownMenuSub=function({...t}){return e.jsx(q.Sub,{"data-slot":"dropdown-menu-sub",...t})},exports.DropdownMenuSubContent=function({className:t,...a}){return e.jsx(q.SubContent,{"data-slot":"dropdown-menu-sub-content",className:ee("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg",t),...a})},exports.DropdownMenuSubTrigger=function({className:t,inset:a,children:s,...r}){return e.jsxs(q.SubTrigger,{"data-slot":"dropdown-menu-sub-trigger","data-inset":a,className:ee("focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8",t),...r,children:[s,e.jsx(i.ChevronRightIcon,{className:"ml-auto size-4"})]})},exports.DropdownMenuTrigger=oa,exports.FlexColsLayout=ja,exports.FullPageLoading=Te,exports.HeaderText=Ha,exports.INVITATION_ENUMS=ye,exports.InfoButton=Ya,exports.Input=Et,exports.Label=Lt,exports.LinkWrapper=qa,exports.ListPanel=Wa,exports.LoadingCmp=ze,exports.LoadingMask=va,exports.PaginationWrapper=Ia,exports.PremiumHighlighter=Ka,exports.RichTextEditor=({value:t,onChange:a,onAICall:r,placeholder:n="Type / for commands or start writing...",className:o="",classNameEditor:l="",minHeight:d="unset",id:c="",enableSlashMenu:u=!1,canShowAIOptions:m=!1,readingMode:j=!1})=>{const y=e=>{if(!N)return;const t=`link-${Math.random().toString(36).slice(2,9)}`;N.chain().focus().insertContent(`<a href="${e}" data-marker="${t}">${e}</a>`).run(),Ae().get(`/link-metadata?url=${encodeURIComponent(e)}`).then(a=>{if(!a)return;const{title:s,image:r=`https://www.google.com/s2/favicons?domain=${e}`,description:n}=a,i=s||e;let o=-1,l=0;N.state.doc.descendants((e,a)=>{if(e.isText){if(e.marks.find(e=>"link"===e.type.name&&e.attrs["data-marker"]===t))return o=a,l=e.nodeSize,!1}return!0}),-1!==o&&N.chain().deleteRange({from:o,to:o+l}).insertContent(`<a href="${e}" data-image="${r||""}" data-description="${n||""}">${i}</a>`).run()}).catch(()=>{N.state.doc.descendants((a,s)=>{if(a.isText){if(a.marks.find(e=>"link"===e.type.name&&e.attrs["data-marker"]===t))return N.chain().deleteRange({from:s,to:s+a.nodeSize}).insertContent(`<a href="${e}">${e}</a>`).run(),!1}return!0})})},N=x.useEditor({editable:!j,extensions:[p.configure({heading:{levels:[1,2,3]}}),h,g.extend({inclusive:!1,addAttributes(){return{...this.parent?.(),"data-marker":{default:null,parseHTML:e=>e.getAttribute("data-marker"),renderHTML:e=>e["data-marker"]?{"data-marker":e["data-marker"]}:{}},"data-image":{default:null,parseHTML:e=>e.getAttribute("data-image"),renderHTML:e=>e["data-image"]?{"data-image":e["data-image"]}:{}},"data-description":{default:null,parseHTML:e=>e.getAttribute("data-description"),renderHTML:e=>e["data-description"]?{"data-description":e["data-description"]}:{}},style:{default:null,parseHTML:e=>e.getAttribute("style"),renderHTML:e=>e.style?{style:e.style}:{}}}},renderHTML({HTMLAttributes:e}){const{"data-image":t,"data-description":a,...s}=e,r=x.mergeAttributes(this.options.HTMLAttributes,s,{"data-image":t,"data-description":a,title:a||""});return t?["a",r,["img",{src:t,width:"16",height:"16"}],["span",0]]:["a",r,0]}}).configure({openOnClick:!1,autolink:!0,HTMLAttributes:{}}),f.configure({placeholder:n,emptyEditorClass:"is-editor-empty"}),...u?[b]:[],v],content:t,onUpdate:({editor:e})=>{a(e.getHTML())},editorProps:{attributes:{class:ee("prose dark:prose-invert max-w-none focus:outline-none min-h-full","selection:bg-primary/30"),id:c},handlePaste:(e,t)=>{const a=t.clipboardData?.getData("text/plain");return!(!a||!(e=>{try{const t=new URL(e);return"http:"===t.protocol||"https:"===t.protocol}catch{return!1}})(a))&&(y(a),!0)}}});if(s.useEffect(()=>{N&&t!==N.getHTML()&&N.commands.setContent(t)},[t,N]),s.useEffect(()=>{N&&N.setEditable(!j)},[N,j]),!N)return null;const[w,_]=s.useState(!1),[C,k]=s.useState(""),S=()=>{const{from:e,to:t}=N.state.selection,a=N.state.doc.textBetween(e,t," "),s=N.getText();r&&r(a,s)},P=()=>{if(""===C)N.chain().focus().extendMarkRange("link").unsetLink().run();else{let e=C;/^https?:\/\//i.test(e)||e.startsWith("/")||e.startsWith("#")||(e="https://"+e);const{empty:t}=N.state.selection;t?y(e):N.chain().focus().extendMarkRange("link").setLink({href:e}).run()}_(!1),k("")},z=()=>{const e=N.getAttributes("link").href;k(e||""),_(!0)};s.useEffect(()=>{const e=e=>{if((e.ctrlKey||e.metaKey)&&"k"===e.key){if(j)return;e.preventDefault(),z()}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[N]);const T=e=>ee("h-8 w-8 p-0 transition-all duration-200",e?"bg-primary text-primary-foreground hover:bg-primary/90":"hover:bg-accent hover:text-accent-foreground");return e.jsx("div",{className:ee("group relative w-full border rounded-md bg-transparent dark:bg-input/30 transition-[color,box-shadow] outline-none shadow-xs","border-input focus-within:border-ring focus-within:ring-ring/50 focus-within:ring-[3px] text-sm",o),style:{minHeight:d},children:e.jsxs("div",{className:ee("px-3 py-2 h-full",j?"cursor-default":"cursor-text",l),onClick:()=>!j&&N.chain().focus().run(),children:[!j&&e.jsx(x.BubbleMenu,{editor:N,tippyOptions:{duration:150,animation:"shift-away",onHidden:()=>_(!1)},className:"flex items-center gap-0.5 bg-popover/90 backdrop-blur-md border border-border rounded-lg shadow-xl p-1 overflow-hidden animate-in fade-in zoom-in duration-200",children:w?e.jsxs("div",{className:"flex items-center gap-1 px-1",onClick:e=>e.stopPropagation(),children:[e.jsx(Et,{type:"text",value:C,onChange:e=>k(e.target.value),placeholder:"Paste or type a link...",className:"h-7 w-48 text-xs border-none focus-visible:ring-0 bg-transparent",autoFocus:!0,onKeyDown:e=>{e.stopPropagation(),"Enter"===e.key&&(e.preventDefault(),P()),"Escape"===e.key&&_(!1)}}),e.jsx(vt,{type:"button",variant:"ghost",size:"sm",onClick:P,className:"h-7 w-7 p-0",children:e.jsx(i.Check,{className:"h-3.5 w-3.5"})}),e.jsx(vt,{type:"button",variant:"ghost",size:"sm",onClick:()=>_(!1),className:"h-7 w-7 p-0",children:e.jsx(i.X,{className:"h-3.5 w-3.5"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(vt,{type:"button",variant:"ghost",size:"sm",onClick:()=>N.chain().focus().toggleBold().run(),className:T(N.isActive("bold")),children:e.jsx(i.Bold,{className:"h-4 w-4"})}),e.jsx(vt,{type:"button",variant:"ghost",size:"sm",onClick:()=>N.chain().focus().toggleItalic().run(),className:T(N.isActive("italic")),children:e.jsx(i.Italic,{className:"h-4 w-4"})}),e.jsx(vt,{type:"button",variant:"ghost",size:"sm",onClick:()=>N.chain().focus().toggleUnderline().run(),className:T(N.isActive("underline")),children:e.jsx(i.Underline,{className:"h-4 w-4"})}),e.jsx(vt,{type:"button",variant:"ghost",size:"sm",onClick:z,className:T(N.isActive("link")),children:e.jsx(i.Link,{className:"h-4 w-4"})}),e.jsx(na,{orientation:"vertical",className:"h-4 mx-1"}),e.jsx(vt,{type:"button",variant:"ghost",size:"sm",onClick:()=>N.chain().focus().toggleBulletList().run(),className:T(N.isActive("bulletList")),children:e.jsx(i.List,{className:"h-4 w-4"})}),e.jsx(vt,{type:"button",variant:"ghost",size:"sm",onClick:()=>{N.chain().focus().deleteRange({from:N.state.selection.from-1,to:N.state.selection.from}).toggleBlockquote().run()},className:T(N.isActive("blockquote")),children:e.jsx(i.Quote,{className:"h-4 w-4"})}),m&&e.jsxs(e.Fragment,{children:[e.jsx(na,{orientation:"vertical",className:"h-4 mx-1"}),e.jsxs(vt,{type:"button",variant:"ghost",size:"sm",onClick:S,className:"h-8 px-2 flex items-center gap-1.5 text-primary hover:bg-primary/10 transition-colors",children:[e.jsx(i.Sparkles,{className:"h-4 w-4 fill-primary/20 animate-pulse"}),e.jsx("span",{className:"text-xs font-semibold",children:"AI Edit"})]})]})]})}),u&&!j&&e.jsxs(x.FloatingMenu,{editor:N,tippyOptions:{duration:150,placement:"bottom-start",offset:[0,8]},shouldShow:({state:e})=>{const{selection:t}=e,{$from:a}=t,s=a.nodeBefore?.text||"";return 1===a.parentOffset&&"/"===s},className:"flex flex-col min-w-[180px] bg-popover border border-border rounded-lg shadow-2xl p-1.5 animate-in slide-in-from-top-2 duration-200 z-50",children:[e.jsx("div",{className:"px-2 py-1.5 text-[10px] font-bold text-muted-foreground uppercase tracking-wider",children:"Quick Actions"}),e.jsx(Ja,{onClick:()=>{N.chain().focus().deleteRange({from:N.state.selection.from-1,to:N.state.selection.from}).toggleHeading({level:1}).run()},icon:e.jsx(i.Heading1,{className:"h-4 w-4"}),label:"Heading 1",shortcut:"H1"}),e.jsx(Ja,{onClick:()=>{N.chain().focus().deleteRange({from:N.state.selection.from-1,to:N.state.selection.from}).toggleHeading({level:2}).run()},icon:e.jsx(i.Heading2,{className:"h-4 w-4"}),label:"Heading 2",shortcut:"H2"}),e.jsx(Ja,{onClick:()=>{N.chain().focus().deleteRange({from:N.state.selection.from-1,to:N.state.selection.from}).toggleBulletList().run()},icon:e.jsx(i.List,{className:"h-4 w-4"}),label:"Bullet List",shortcut:"-"}),e.jsx(Ja,{onClick:()=>{N.chain().focus().deleteRange({from:N.state.selection.from-1,to:N.state.selection.from}).toggleOrderedList().run()},icon:e.jsx(i.ListOrdered,{className:"h-4 w-4"}),label:"Ordered List",shortcut:"1."}),e.jsx(Ja,{onClick:()=>{N.chain().focus().deleteRange({from:N.state.selection.from-1,to:N.state.selection.from}).toggleBlockquote().run()},icon:e.jsx(i.Quote,{className:"h-4 w-4"}),label:"Quote",shortcut:">"}),e.jsx(Ja,{onClick:()=>{N.chain().focus().deleteRange({from:N.state.selection.from-1,to:N.state.selection.from}).run(),z()},icon:e.jsx(i.Link,{className:"h-4 w-4"}),label:"Hyperlink",shortcut:"K"}),e.jsx(na,{className:"my-1"}),m&&e.jsx(Ja,{onClick:()=>{N.chain().focus().deleteRange({from:N.state.selection.from-1,to:N.state.selection.from}).run(),S()},icon:e.jsx(i.Sparkles,{className:"h-4 w-4 text-primary"}),label:"AI Assistant",className:"text-primary hover:bg-primary/10"})]}),e.jsx(x.EditorContent,{editor:N})]})})},exports.Select=Rt,exports.SelectContent=Ut,exports.SelectItem=Bt,exports.SelectLabel=function({className:t,...a}){return e.jsx(R.Label,{"data-slot":"select-label",className:ee("text-muted-foreground px-2 py-1.5 text-xs",t),...a})},exports.SelectListWrapper=Ga,exports.SelectSeparator=function({className:t,...a}){return e.jsx(R.Separator,{"data-slot":"select-separator",className:ee("bg-border pointer-events-none -mx-1 my-1 h-px",t),...a})},exports.SelectTrigger=$t,exports.SelectValue=Mt,exports.Separator=na,exports.Sheet=Ht,exports.SheetContent=Kt,exports.SheetDescription=Jt,exports.SheetHeader=Gt,exports.SheetTitle=Xt,exports.SheetTrigger=function({...t}){return e.jsx(M.Trigger,{"data-slot":"sheet-trigger",...t})},exports.SideKickClient=function({appRoutes:t,publicRoutes:a}){ke();const[r,n]=s.useState(le),[i,o]=s.useState([]),[l,d]=s.useState(),[c,u]=s.useState(),[m,x]=s.useState([]),[p,h]=s.useState(),[g,f]=s.useState({}),[b,v]=s.useState({}),j=s.useCallback(e=>{e&&(se("activeOrgId",String(e.org_id)),u(e))},[u]);return e.jsxs(Pe.Provider,{value:{alertDlgOptions:r,setAlertDlgOptions:n,orgs:i,setOrgs:o,loggedInUser:l||{},setLoggedInUser:d,activeOrg:c,setActiveOrg:j,purchasePlans:m,setPurchasePlans:x,activePlan:p,setActivePlan:h,subscriptionConfig:g,setSubscriptionConfig:f,featureFlags:b,setFeatureFlags:v},children:[e.jsx(it,{appRoutes:t,publicRoutes:a}),e.jsx(Se,{}),e.jsx(Nt,{options:r})]})},exports.SideKickContext=Pe,exports.Skeleton=function({className:t,...a}){return e.jsx("div",{"data-slot":"skeleton",className:ee("bg-accent animate-pulse rounded-md",t),...a})},exports.Switch=Qt,exports.Table=_t,exports.TableBody=kt,exports.TableCaption=Tt,exports.TableCell=zt,exports.TableFooter=function({className:t,...a}){return e.jsx("tfoot",{"data-slot":"table-footer",className:ee("bg-muted/50 border-t font-medium [&>tr]:last:border-b-0",t),...a})},exports.TableHead=Pt,exports.TableHeader=Ct,exports.TableRow=St,exports.Tabs=ha,exports.TabsContent=function({className:t,...a}){return e.jsx(V.Content,{"data-slot":"tabs-content",className:ee("flex-1 outline-none",t),...a})},exports.TabsList=fa,exports.TabsTrigger=ba,exports.TabsWrapper=({tabs:t,variant:a,defaultValue:s})=>e.jsxs(ha,{defaultValue:s,children:[e.jsx(fa,{variant:a,children:t.map(t=>e.jsx(ba,{value:t.value,children:t.title},t.value))}),t.map(t=>e.jsx(y.TabsContent,{value:t.value,children:t.content},t.value))]}),exports.TabularLayout=Da,exports.Textarea=pa,exports.Toolbar=Na,exports.Tooltip=ea,exports.TooltipContent=aa,exports.TooltipProvider=Zt,exports.TooltipTrigger=ta,exports.TooltipWrapper=Xa,exports.TypographyHeading=Aa,exports.TypographyP=Ea,exports.UrlChangesGuard=({isDirty:t,setDirty:r})=>{const n=a.useBlocker(t);return s.useEffect(()=>{const e=e=>{t&&(e.preventDefault(),e.returnValue="")};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[t]),"blocked"===n.state?e.jsx(Nt,{options:{open:!0,text:"Are you sure you want to leave this page?",type:"CONFIRM",onClose:e=>{"CONFIRM"===e?(n?.proceed(),r(!1)):n?.reset()}}}):null},exports.cn=ee,exports.convertServerDateToJS=xe,exports.createIndexedArray=oe,exports.debounce=function(e,t){let a;return function(...s){clearTimeout(a),a=setTimeout(()=>{e.apply(this,s)},t)}},exports.defaultAlertConfig=le,exports.errorLogger=ce,exports.findNavMenu=ie,exports.formatElapsedTime=e=>{const t=(new Date).getTime()-e.getTime(),a=t/36e5,s=t/864e5;return t<3e5?"Just now":a<1?`${Math.floor(t/6e4)} minutes ago`:a<24?`${Math.floor(a)} hours ago`:s<7?`${Math.floor(s)} days ago`:e.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})},exports.formatISODateWithTime24H=pe,exports.generatePublicId=ge,exports.generateRandom4Digits=()=>Math.floor(1e3+9e3*Math.random()).toString(),exports.getAxiosInstance=Ae,exports.getCurrencySymbol=Re,exports.getFormDataByFormEl=te,exports.getLocalStorage=re,exports.getModuleNameFromUrl=_e,exports.isEmailValid=ue,exports.isFunction=ve,exports.isObjectEmpty=Ne,exports.isSameNavItem=ne,exports.isTruthyValue=je,exports.isValidId=we,exports.mapIncrementBy2=be,exports.processEmailsWithValidation=me,exports.setAccountType=e=>{Object.assign(Q,e)},exports.setAppInfo=e=>{Object.assign(Z,e)},exports.setLocalStorage=se,exports.setNavigationItems=(e,t)=>{X.navMain=e,X.virtualChildOf=t||[]},exports.showErrorToast=Fe,exports.showSuccessToast=Ie,exports.showWarningToast=Oe,exports.undoPublicId=fe,exports.updateRolesEnum=e=>{Object.assign(wt,e)},exports.useAlertDialog=yt,exports.useFetchData=Qa,exports.useIsMobile=ya,exports.validatePassword=de,exports.waitTill=(e=3e3)=>new Promise(t=>setTimeout(t,e));
2
2
  //# sourceMappingURL=index.cjs.js.map