randmarcomps 1.634.0 → 1.637.0
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/randmarcomps.js +27 -4
- package/dist/randmarcomps.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/randmarcomps.js
CHANGED
|
@@ -54560,7 +54560,7 @@ function ResellerOverview({
|
|
|
54560
54560
|
...ft,
|
|
54561
54561
|
[yt]: It
|
|
54562
54562
|
} : ft);
|
|
54563
|
-
}, []), { NavigationGuardDialog: lt } = useRouterNavigationGuard(at), ut = te ?? t, ct = A && !ut, dt = rt && !ut, pt = !n || !!ut?.Statement && (ut.Statement.Total ?? 0)
|
|
54563
|
+
}, []), { NavigationGuardDialog: lt } = useRouterNavigationGuard(at), ut = te ?? t, ct = A && !ut, dt = rt && !ut, pt = !n || !!ut?.Statement && (ut.Statement.Total ?? 0) !== 0, mt = ut?.QualifiedManufacturers ?? [], Ct = ut?.Qualifications ?? [];
|
|
54564
54564
|
return /* @__PURE__ */ jsxs("div", { className: "@container", children: [
|
|
54565
54565
|
dt ? /* @__PURE__ */ jsx(Card, { className: "p-6", children: /* @__PURE__ */ jsxs(Alert, { variant: "destructive", children: [
|
|
54566
54566
|
/* @__PURE__ */ jsx(CircleAlert, { className: "h-4 w-4" }),
|
|
@@ -62064,6 +62064,7 @@ const AlertDialogCancel = React.forwardRef(({ className: e, ...t }, n) => /* @__
|
|
|
62064
62064
|
}
|
|
62065
62065
|
));
|
|
62066
62066
|
AlertDialogCancel.displayName = Cancel.displayName;
|
|
62067
|
+
const MOBILE_ASSISTANT_URL = "https://assistant.randmar.io";
|
|
62067
62068
|
function parseDate(e) {
|
|
62068
62069
|
if (e == null) return null;
|
|
62069
62070
|
const t = e instanceof Date ? e : new Date(e);
|
|
@@ -62111,8 +62112,8 @@ function RefreshCluster({
|
|
|
62111
62112
|
}
|
|
62112
62113
|
}
|
|
62113
62114
|
}, [A, d, rt, n, t]);
|
|
62114
|
-
return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-wrap items-center justify-
|
|
62115
|
-
/* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground sm:text-sm", children: [
|
|
62115
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("flex w-full flex-wrap items-center justify-start gap-2 lg:w-auto lg:justify-end", c), children: [
|
|
62116
|
+
/* @__PURE__ */ jsxs("p", { className: "w-full text-xs text-muted-foreground sm:text-sm lg:w-auto", children: [
|
|
62116
62117
|
"Last refresh:",
|
|
62117
62118
|
" ",
|
|
62118
62119
|
/* @__PURE__ */ jsx("span", { className: "font-medium text-foreground", children: formatLastRefresh(ot) })
|
|
@@ -62131,12 +62132,34 @@ function RefreshCluster({
|
|
|
62131
62132
|
]
|
|
62132
62133
|
}
|
|
62133
62134
|
),
|
|
62135
|
+
/* @__PURE__ */ jsx(
|
|
62136
|
+
Button$1,
|
|
62137
|
+
{
|
|
62138
|
+
asChild: !0,
|
|
62139
|
+
variant: "default",
|
|
62140
|
+
className: cn("min-h-11 lg:hidden", d && "pointer-events-none opacity-50"),
|
|
62141
|
+
children: /* @__PURE__ */ jsxs(
|
|
62142
|
+
"a",
|
|
62143
|
+
{
|
|
62144
|
+
href: MOBILE_ASSISTANT_URL,
|
|
62145
|
+
target: "_blank",
|
|
62146
|
+
rel: "noopener noreferrer",
|
|
62147
|
+
"aria-disabled": d || void 0,
|
|
62148
|
+
onClick: d ? (at) => at.preventDefault() : void 0,
|
|
62149
|
+
children: [
|
|
62150
|
+
/* @__PURE__ */ jsx(Bot, { className: "h-4 w-4", "aria-hidden": "true" }),
|
|
62151
|
+
/* @__PURE__ */ jsx("span", { children: l })
|
|
62152
|
+
]
|
|
62153
|
+
}
|
|
62154
|
+
)
|
|
62155
|
+
}
|
|
62156
|
+
),
|
|
62134
62157
|
/* @__PURE__ */ jsxs(
|
|
62135
62158
|
Button$1,
|
|
62136
62159
|
{
|
|
62137
62160
|
type: "button",
|
|
62138
62161
|
variant: "default",
|
|
62139
|
-
className: "min-h-11",
|
|
62162
|
+
className: "hidden min-h-11 lg:inline-flex",
|
|
62140
62163
|
disabled: d,
|
|
62141
62164
|
onClick: o,
|
|
62142
62165
|
children: [
|
|
@@ -484,7 +484,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let a="<p>An error
|
|
|
484
484
|
|
|
485
485
|
Defaulting to \`null\`.`}var Root$2=Progress$1,Indicator=ProgressIndicator;const Progress=React__namespace.forwardRef(({className:e,value:t,...n},s)=>jsxRuntime.jsx(Root$2,{ref:s,className:cn("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...n,children:jsxRuntime.jsx(Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));Progress.displayName=Root$2.displayName;function ManufacturerInventoryFinanceCard({manufacturer:e,isLoading:t}){const{data:n=[],isLoading:s,isFetching:a}=useGetV4ManufacturerByRouteManufacturerIdInventoryValueQuery({routeManufacturerId:e?.ManufacturerId??""},{skip:!e?.ManufacturerId}),o=e?.DefaultMaxInventoryValue??0,l=n.reduce((f,R)=>f+(R.InventoryValue||0),0),c=o-l,d=o>0?Math.round(l/o*100):0;return t||s||a?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/2 mt-2"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-2 w-full"})]})]})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsxs(CardTitle,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(DollarSign,{className:"h-5 w-5 text-muted-foreground"}),"Inventory Finance"]}),jsxRuntime.jsx(CardDescription,{children:"Current inventory financial status"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[o!==0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Max Allowance"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(o)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Current value"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(l)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Available"}),jsxRuntime.jsx("span",{className:`font-bold ${c>=0?"text-success":"text-destructive"}`,children:formatMoney(c)})]})]}),o!==0&&jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Budget Usage"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsxs("span",{className:"text-sm font-medium",children:[d,"%"]}),d>80&&jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4 text-warning"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:d>80?"High usage alert":"Budget usage"})})]})})]}),jsxRuntime.jsx(Progress,{value:d,className:"h-2"})]})]})]})}function ManufacturerCreditFinanceCard({manufacturer:e,isLoading:t}){const n=e?.CreditLimit??0,s=e?.OutstandingBalance??0,a=n-s,o=Math.round(s/n*100);return t?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/2 mt-2"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-2 w-full"})]})]})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsxs(CardTitle,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(CreditCard,{className:"h-5 w-5 text-muted-foreground"}),"Credit Finance"]}),jsxRuntime.jsx(CardDescription,{children:"Current credit financial status"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Credit Limit"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(n)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Outstanding Balance"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(s)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Available Credit"}),jsxRuntime.jsx("span",{className:`font-bold ${a>=0?"text-success":"text-destructive"}`,children:formatMoney(a)})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Credit Usage"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsxs("span",{className:"text-sm font-medium",children:[o,"%"]}),o>80&&jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4 text-warning"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:o>80?"High credit usage alert":"Credit usage"})})]})})]}),jsxRuntime.jsx(Progress,{value:o,className:"h-2"})]})]})]})}function SalesChartCard({statistics:e,loading:t=!1,mode:n="month",chartHeight:s=300,className:a,size:o="default"}){return t?jsxRuntime.jsxs(Card,{className:cn("w-full",a),children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-48 rounded-md"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx("div",{style:{height:s},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}),o==="default"&&n==="month"&&jsxRuntime.jsxs("div",{className:"mt-4 flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-10 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40 rounded-md"})]})]})]}):jsxRuntime.jsxs(Card,{className:cn("w-full",a),children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:n==="week"?"Weekly Sales Performance":"Monthly Sales Performance"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(SalesChart,{statistics:e,mode:n,chartHeight:s,size:o})})]})}function ManufacturerOverviewPage({applicationId:e,readonly:t,withReports:n,manufacturer:s,userEmail:a}){const{data:o,isLoading:l,isError:c}=useGetV4PartnerByApplicationIdAccountManufacturerQuery({applicationId:e,withSpecification:!0},{skip:!!s}),[d,f]=React.useState({publicInfo:{hasUnsavedChanges:!1},qualifications:{hasUnsavedChanges:!1},billingInfo:{hasUnsavedChanges:!1}}),R=React.useCallback(()=>t?!1:d.publicInfo.hasUnsavedChanges||d.qualifications.hasUnsavedChanges||d.billingInfo.hasUnsavedChanges,[t,d]),S=React.useCallback((rt,st)=>{f(it=>it[rt]?.hasUnsavedChanges!==st.hasUnsavedChanges?(console.log(`Updating form state for ${rt}:`,st.hasUnsavedChanges),{...it,[rt]:st}):it)},[]),{NavigationGuardDialog:te}=useRouterNavigationGuard(R),A=s??o;return jsxRuntime.jsxs("div",{className:"@container",children:[c?jsxRuntime.jsx(Card,{className:"p-6",children:jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Error"}),jsxRuntime.jsx(AlertDescription,{children:"There was an error loading your manufacturer information. Please try again later."})]})}):jsxRuntime.jsxs("div",{className:"space-y-6 mb-6",children:[jsxRuntime.jsx(SalesSummary,{fiscalYearMonthStart:A?.FiscalYearMonthStart,salesData:A?.SalesData,isLoading:l}),jsxRuntime.jsxs("div",{className:"grid @2xl:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:A?.SalesStatistics??[],loading:l}),jsxRuntime.jsx(ManufacturerResellerOrdersSection,{manufacturerId:A?.ManufacturerId??"",activeOrders:A?.ActiveOrderDetails??void 0,isLoading:l}),n&&jsxRuntime.jsx(ManufacturerInventoryFinanceCard,{manufacturer:A,isLoading:l}),n&&jsxRuntime.jsx(ManufacturerCreditFinanceCard,{manufacturer:A,isLoading:l}),n&&jsxRuntime.jsx(ManufacturerReorderingCard,{manufacturer:A??{},onSave:()=>{},loading:l,readonly:t}),n&&jsxRuntime.jsx(ManufacturerPublicInfoSection,{manufacturer:A,readonly:t,isLoading:l,onUnsavedChanges:rt=>S("publicInfo",{hasUnsavedChanges:rt})}),n&&jsxRuntime.jsx(OpenToWorkSection,{manufacturer:A,readonly:t,isLoading:l}),n&&jsxRuntime.jsx(ManufacturerBillingInfoSection,{manufacturer:A,readonly:t,isLoading:l,onUnsavedChanges:rt=>S("billingInfo",{hasUnsavedChanges:rt})}),n&&jsxRuntime.jsx(ManufacturerQualificationsSection,{manufacturer:A,readonly:t,isLoading:l,onUnsavedChanges:rt=>S("qualifications",{hasUnsavedChanges:rt})})]}),n&&jsxRuntime.jsx(ManufacturerReportsSection,{manufacturerId:A?.ManufacturerId??"",userEmail:a,isLoading:l})]}),jsxRuntime.jsx(te,{})]})}function ManufacturerCategories({categories:e,activeCategory:t,onSelectCategory:n}){return jsxRuntime.jsx("div",{className:"grid",children:jsxRuntime.jsx("div",{className:"flex overflow-x-auto small-scrollbar pb-4",children:jsxRuntime.jsxs("div",{className:"flex gap-2 items-baseline",children:[jsxRuntime.jsx("p",{children:"Category filter:"}),e.map(s=>jsxRuntime.jsxs(Button$1,{onClick:()=>n(s.CategoryCode??""),variant:t===s.CategoryCode?"default":"outline",size:"sm",className:"px-3 py-1.5 text-xs whitespace-nowrap rounded-full",children:[s.CategoryName??"Undefined",s.QualificationRequired&&jsxRuntime.jsx(ShieldCheck,{className:`ml-1 w-5 h-5 ${t!==s.CategoryCode?"text-destructive":""}`})]},s.CategoryCode))]})})})}function CategoryStats(e){const{data:t,isLoading:n,isFetching:s}=useGetV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeQuery({routeResellerId:e.appID,manufacturerId:e.manufID,categoryCode:e.categoryCode});return jsxRuntime.jsx(Card,{className:"w-full",children:jsxRuntime.jsx(CardContent,{className:"p-4 space-y-1",children:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:e.categoryName}),jsxRuntime.jsx(SalesChart,{statistics:t?.SalesStatistics??[],loading:n||s,chartHeight:300})]})})})}function ManufacturerCategoriesStats(e){return(e.categories??[]).filter(n=>n.CategoryName).map(n=>jsxRuntime.jsx(CategoryStats,{appID:e.appID,manufID:e.manufID,categoryCode:n.CategoryCode,categoryName:n.CategoryName},`${e.manufID}-${n.CategoryCode}`))}const badgeVariants=cva("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground border border-border hover:bg-accent hover:text-accent-foreground",success:"bg-success text-success-foreground hover:bg-success/90",warning:"bg-warning text-warning-foreground hover:bg-warning/90",info:"bg-info text-info-foreground hover:bg-info/90",ghost:"bg-background hover:bg-accent hover:text-accent-foreground",randmarRed:"bg-primary text-primary-foreground hover:bg-primary/80",randmarBlue:"bg-primary text-primary-foreground hover:bg-primary/80",randmarPurple:"bg-primary text-primary-foreground hover:bg-primary/80",randmarGreen:"bg-primary text-primary-foreground hover:bg-primary/80",randmarBlack:"bg-foreground text-background hover:bg-foreground/90",randmarYellow:"bg-primary text-primary-foreground hover:bg-primary/80"},size:{default:"h-6",sm:"h-5 text-[10px]",lg:"h-7 px-3"}},defaultVariants:{variant:"default",size:"default"}}),Badge=React__namespace.forwardRef(({className:e,variant:t,size:n,icon:s,children:a,...o},l)=>jsxRuntime.jsxs("div",{ref:l,className:cn(badgeVariants({variant:t,size:n}),e),...o,children:[s&&jsxRuntime.jsx("span",{className:"mr-1",children:s}),a]}));Badge.displayName="Badge";function ManufacturerCategorySummary({name:e="N/A",niche:t="N/A",productsNumber:n=0,autoreorder:s=!1,starred:a=!1,isLoading:o=!1,children:l}){return o?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-4",children:jsxRuntime.jsxs("div",{className:"flex items-start justify-between",children:[jsxRuntime.jsx("div",{className:"space-y-1 flex-1",children:jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-28 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-5 w-48 bg-muted rounded-md animate-pulse"})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-12 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-5 w-5 bg-muted rounded-md animate-pulse"})]})]})}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-8 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-4 w-32 bg-muted rounded-md animate-pulse"})]}),jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1 flex-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-16 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-4 w-4 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-4 w-6 bg-muted rounded-md animate-pulse"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-1 flex-1 flex flex-col items-end",children:[jsxRuntime.jsx("div",{className:"h-3 w-20 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-4 w-4 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-6 w-16 bg-muted rounded-md animate-pulse"})]})]})]})]})]}):jsxRuntime.jsx(Card,{children:jsxRuntime.jsxs(CardContent,{className:"grid grid-cols-[1fr_auto] items-start gap-4 pt-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-start gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Category Name"}),jsxRuntime.jsx("h3",{className:"text-lg font-semibold leading-none tracking-tight",children:e})]}),jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Niche"}),jsxRuntime.jsx("p",{className:"text-sm font-medium",children:t})]}),jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Products"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Package,{className:"h-4 w-4 text-muted-foreground"}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:n})]})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end justify-between gap-4 h-full",children:[l,jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Starred"}),a?jsxRuntime.jsx(Star,{className:"h-5 w-5 fill-warning text-warning"}):jsxRuntime.jsx(Star,{className:"h-5 w-5 text-muted-foreground"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 flex flex-col items-end",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Auto-reorder"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[s?jsxRuntime.jsx(RefreshCw,{className:"size-4 text-success"}):jsxRuntime.jsx(RefreshCwOff,{className:"size-4 text-warning"}),jsxRuntime.jsx(Badge,{variant:s?"success":"warning",className:"text-xs",children:s?"Enabled":"Disabled"})]})]})]})]})})}function createSlot$1(e){const t=createSlotClone$1(e),n=React__namespace.forwardRef((s,a)=>{const{children:o,...l}=s,c=React__namespace.Children.toArray(o),d=c.find(isSlottable$1);if(d){const f=d.props.children,R=c.map(S=>S===d?React__namespace.Children.count(f)>1?React__namespace.Children.only(null):React__namespace.isValidElement(f)?f.props.children:null:S);return jsxRuntime.jsx(t,{...l,ref:a,children:React__namespace.isValidElement(f)?React__namespace.cloneElement(f,void 0,R):null})}return jsxRuntime.jsx(t,{...l,ref:a,children:o})});return n.displayName=`${e}.Slot`,n}function createSlotClone$1(e){const t=React__namespace.forwardRef((n,s)=>{const{children:a,...o}=n;if(React__namespace.isValidElement(a)){const l=getElementRef$1(a),c=mergeProps$1(o,a.props);return a.type!==React__namespace.Fragment&&(c.ref=s?composeRefs(s,l):l),React__namespace.cloneElement(a,c)}return React__namespace.Children.count(a)>1?React__namespace.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var SLOTTABLE_IDENTIFIER$2=Symbol("radix.slottable");function isSlottable$1(e){return React__namespace.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===SLOTTABLE_IDENTIFIER$2}function mergeProps$1(e,t){const n={...t};for(const s in t){const a=e[s],o=t[s];/^on[A-Z]/.test(s)?a&&o?n[s]=(...c)=>{const d=o(...c);return a(...c),d}:a&&(n[s]=a):s==="style"?n[s]={...a,...o}:s==="className"&&(n[s]=[a,o].filter(Boolean).join(" "))}return{...e,...n}}function getElementRef$1(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var OPEN_KEYS=[" ","Enter","ArrowUp","ArrowDown"],SELECTION_KEYS=[" ","Enter"],SELECT_NAME="Select",[Collection$1,useCollection$1,createCollectionScope$1]=createCollection(SELECT_NAME),[createSelectContext]=createContextScope$2(SELECT_NAME,[createCollectionScope$1,createPopperScope]),usePopperScope$1=createPopperScope(),[SelectProvider,useSelectContext]=createSelectContext(SELECT_NAME),[SelectNativeOptionsProvider,useSelectNativeOptionsContext]=createSelectContext(SELECT_NAME),Select$2=e=>{const{__scopeSelect:t,children:n,open:s,defaultOpen:a,onOpenChange:o,value:l,defaultValue:c,onValueChange:d,dir:f,name:R,autoComplete:S,disabled:te,required:A,form:rt}=e,st=usePopperScope$1(t),[it,at]=React__namespace.useState(null),[ot,lt]=React__namespace.useState(null),[ut,ct]=React__namespace.useState(!1),dt=useDirection(f),[pt,mt]=useControllableState({prop:s,defaultProp:a??!1,onChange:o,caller:SELECT_NAME}),[Rt,yt]=useControllableState({prop:l,defaultProp:c,onChange:d,caller:SELECT_NAME}),It=React__namespace.useRef(null),ft=it?rt||!!it.closest("form"):!0,[Ct,Mt]=React__namespace.useState(new Set),Dt=Array.from(Ct).map(Vt=>Vt.props.value).join(";");return jsxRuntime.jsx(Root2$7,{...st,children:jsxRuntime.jsxs(SelectProvider,{required:A,scope:t,trigger:it,onTriggerChange:at,valueNode:ot,onValueNodeChange:lt,valueNodeHasChildren:ut,onValueNodeHasChildrenChange:ct,contentId:useId$1(),value:Rt,onValueChange:yt,open:pt,onOpenChange:mt,dir:dt,triggerPointerDownPosRef:It,disabled:te,children:[jsxRuntime.jsx(Collection$1.Provider,{scope:t,children:jsxRuntime.jsx(SelectNativeOptionsProvider,{scope:e.__scopeSelect,onNativeOptionAdd:React__namespace.useCallback(Vt=>{Mt(Wt=>new Set(Wt).add(Vt))},[]),onNativeOptionRemove:React__namespace.useCallback(Vt=>{Mt(Wt=>{const $t=new Set(Wt);return $t.delete(Vt),$t})},[]),children:n})}),ft?jsxRuntime.jsxs(SelectBubbleInput,{"aria-hidden":!0,required:A,tabIndex:-1,name:R,autoComplete:S,value:Rt,onChange:Vt=>yt(Vt.target.value),disabled:te,form:rt,children:[Rt===void 0?jsxRuntime.jsx("option",{value:""}):null,Array.from(Ct)]},Dt):null]})})};Select$2.displayName=SELECT_NAME;var TRIGGER_NAME$5="SelectTrigger",SelectTrigger$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:s=!1,...a}=e,o=usePopperScope$1(n),l=useSelectContext(TRIGGER_NAME$5,n),c=l.disabled||s,d=useComposedRefs(t,l.onTriggerChange),f=useCollection$1(n),R=React__namespace.useRef("touch"),[S,te,A]=useTypeaheadSearch(st=>{const it=f().filter(lt=>!lt.disabled),at=it.find(lt=>lt.value===l.value),ot=findNextItem(it,st,at);ot!==void 0&&l.onValueChange(ot.value)}),rt=st=>{c||(l.onOpenChange(!0),A()),st&&(l.triggerPointerDownPosRef.current={x:Math.round(st.pageX),y:Math.round(st.pageY)})};return jsxRuntime.jsx(Anchor,{asChild:!0,...o,children:jsxRuntime.jsx(Primitive$4.button,{type:"button",role:"combobox","aria-controls":l.contentId,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":shouldShowPlaceholder(l.value)?"":void 0,...a,ref:d,onClick:composeEventHandlers(a.onClick,st=>{st.currentTarget.focus(),R.current!=="mouse"&&rt(st)}),onPointerDown:composeEventHandlers(a.onPointerDown,st=>{R.current=st.pointerType;const it=st.target;it.hasPointerCapture(st.pointerId)&&it.releasePointerCapture(st.pointerId),st.button===0&&st.ctrlKey===!1&&st.pointerType==="mouse"&&(rt(st),st.preventDefault())}),onKeyDown:composeEventHandlers(a.onKeyDown,st=>{const it=S.current!=="";!(st.ctrlKey||st.altKey||st.metaKey)&&st.key.length===1&&te(st.key),!(it&&st.key===" ")&&OPEN_KEYS.includes(st.key)&&(rt(),st.preventDefault())})})})});SelectTrigger$1.displayName=TRIGGER_NAME$5;var VALUE_NAME="SelectValue",SelectValue$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:a,children:o,placeholder:l="",...c}=e,d=useSelectContext(VALUE_NAME,n),{onValueNodeHasChildrenChange:f}=d,R=o!==void 0,S=useComposedRefs(t,d.onValueNodeChange);return useLayoutEffect2(()=>{f(R)},[f,R]),jsxRuntime.jsx(Primitive$4.span,{...c,ref:S,style:{pointerEvents:"none"},children:shouldShowPlaceholder(d.value)?jsxRuntime.jsx(jsxRuntime.Fragment,{children:l}):o})});SelectValue$1.displayName=VALUE_NAME;var ICON_NAME="SelectIcon",SelectIcon=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,...a}=e;return jsxRuntime.jsx(Primitive$4.span,{"aria-hidden":!0,...a,ref:t,children:s||"▼"})});SelectIcon.displayName=ICON_NAME;var PORTAL_NAME$2="SelectPortal",SelectPortal=e=>jsxRuntime.jsx(Portal$5,{asChild:!0,...e});SelectPortal.displayName=PORTAL_NAME$2;var CONTENT_NAME$4="SelectContent",SelectContent$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContext(CONTENT_NAME$4,e.__scopeSelect),[s,a]=React__namespace.useState();if(useLayoutEffect2(()=>{a(new DocumentFragment)},[]),!n.open){const o=s;return o?ReactDOM__namespace.createPortal(jsxRuntime.jsx(SelectContentProvider,{scope:e.__scopeSelect,children:jsxRuntime.jsx(Collection$1.Slot,{scope:e.__scopeSelect,children:jsxRuntime.jsx("div",{children:e.children})})}),o):null}return jsxRuntime.jsx(SelectContentImpl,{...e,ref:t})});SelectContent$1.displayName=CONTENT_NAME$4;var CONTENT_MARGIN=10,[SelectContentProvider,useSelectContentContext]=createSelectContext(CONTENT_NAME$4),CONTENT_IMPL_NAME="SelectContentImpl",Slot$1=createSlot$1("SelectContent.RemoveScroll"),SelectContentImpl=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,position:s="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:l,side:c,sideOffset:d,align:f,alignOffset:R,arrowPadding:S,collisionBoundary:te,collisionPadding:A,sticky:rt,hideWhenDetached:st,avoidCollisions:it,...at}=e,ot=useSelectContext(CONTENT_NAME$4,n),[lt,ut]=React__namespace.useState(null),[ct,dt]=React__namespace.useState(null),pt=useComposedRefs(t,Ut=>ut(Ut)),[mt,Rt]=React__namespace.useState(null),[yt,It]=React__namespace.useState(null),ft=useCollection$1(n),[Ct,Mt]=React__namespace.useState(!1),Dt=React__namespace.useRef(!1);React__namespace.useEffect(()=>{if(lt)return hideOthers(lt)},[lt]),useFocusGuards();const Vt=React__namespace.useCallback(Ut=>{const[rr,...qt]=ft().map(Kt=>Kt.ref.current),[Qt]=qt.slice(-1),dr=document.activeElement;for(const Kt of Ut)if(Kt===dr||(Kt?.scrollIntoView({block:"nearest"}),Kt===rr&&ct&&(ct.scrollTop=0),Kt===Qt&&ct&&(ct.scrollTop=ct.scrollHeight),Kt?.focus(),document.activeElement!==dr))return},[ft,ct]),Wt=React__namespace.useCallback(()=>Vt([mt,lt]),[Vt,mt,lt]);React__namespace.useEffect(()=>{Ct&&Wt()},[Ct,Wt]);const{onOpenChange:$t,triggerPointerDownPosRef:Ft}=ot;React__namespace.useEffect(()=>{if(lt){let Ut={x:0,y:0};const rr=Qt=>{Ut={x:Math.abs(Math.round(Qt.pageX)-(Ft.current?.x??0)),y:Math.abs(Math.round(Qt.pageY)-(Ft.current?.y??0))}},qt=Qt=>{Ut.x<=10&&Ut.y<=10?Qt.preventDefault():lt.contains(Qt.target)||$t(!1),document.removeEventListener("pointermove",rr),Ft.current=null};return Ft.current!==null&&(document.addEventListener("pointermove",rr),document.addEventListener("pointerup",qt,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",rr),document.removeEventListener("pointerup",qt,{capture:!0})}}},[lt,$t,Ft]),React__namespace.useEffect(()=>{const Ut=()=>$t(!1);return window.addEventListener("blur",Ut),window.addEventListener("resize",Ut),()=>{window.removeEventListener("blur",Ut),window.removeEventListener("resize",Ut)}},[$t]);const[Ht,nr]=useTypeaheadSearch(Ut=>{const rr=ft().filter(dr=>!dr.disabled),qt=rr.find(dr=>dr.ref.current===document.activeElement),Qt=findNextItem(rr,Ut,qt);Qt&&setTimeout(()=>Qt.ref.current.focus())}),Jt=React__namespace.useCallback((Ut,rr,qt)=>{const Qt=!Dt.current&&!qt;(ot.value!==void 0&&ot.value===rr||Qt)&&(Rt(Ut),Qt&&(Dt.current=!0))},[ot.value]),ar=React__namespace.useCallback(()=>lt?.focus(),[lt]),cr=React__namespace.useCallback((Ut,rr,qt)=>{const Qt=!Dt.current&&!qt;(ot.value!==void 0&&ot.value===rr||Qt)&&It(Ut)},[ot.value]),Zt=s==="popper"?SelectPopperPosition:SelectItemAlignedPosition,lr=Zt===SelectPopperPosition?{side:c,sideOffset:d,align:f,alignOffset:R,arrowPadding:S,collisionBoundary:te,collisionPadding:A,sticky:rt,hideWhenDetached:st,avoidCollisions:it}:{};return jsxRuntime.jsx(SelectContentProvider,{scope:n,content:lt,viewport:ct,onViewportChange:dt,itemRefCallback:Jt,selectedItem:mt,onItemLeave:ar,itemTextRefCallback:cr,focusSelectedItem:Wt,selectedItemText:yt,position:s,isPositioned:Ct,searchRef:Ht,children:jsxRuntime.jsx(ReactRemoveScroll,{as:Slot$1,allowPinchZoom:!0,children:jsxRuntime.jsx(FocusScope,{asChild:!0,trapped:ot.open,onMountAutoFocus:Ut=>{Ut.preventDefault()},onUnmountAutoFocus:composeEventHandlers(a,Ut=>{ot.trigger?.focus({preventScroll:!0}),Ut.preventDefault()}),children:jsxRuntime.jsx(DismissableLayer,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:Ut=>Ut.preventDefault(),onDismiss:()=>ot.onOpenChange(!1),children:jsxRuntime.jsx(Zt,{role:"listbox",id:ot.contentId,"data-state":ot.open?"open":"closed",dir:ot.dir,onContextMenu:Ut=>Ut.preventDefault(),...at,...lr,onPlaced:()=>Mt(!0),ref:pt,style:{display:"flex",flexDirection:"column",outline:"none",...at.style},onKeyDown:composeEventHandlers(at.onKeyDown,Ut=>{const rr=Ut.ctrlKey||Ut.altKey||Ut.metaKey;if(Ut.key==="Tab"&&Ut.preventDefault(),!rr&&Ut.key.length===1&&nr(Ut.key),["ArrowUp","ArrowDown","Home","End"].includes(Ut.key)){let Qt=ft().filter(dr=>!dr.disabled).map(dr=>dr.ref.current);if(["ArrowUp","End"].includes(Ut.key)&&(Qt=Qt.slice().reverse()),["ArrowUp","ArrowDown"].includes(Ut.key)){const dr=Ut.target,Kt=Qt.indexOf(dr);Qt=Qt.slice(Kt+1)}setTimeout(()=>Vt(Qt)),Ut.preventDefault()}})})})})})})});SelectContentImpl.displayName=CONTENT_IMPL_NAME;var ITEM_ALIGNED_POSITION_NAME="SelectItemAlignedPosition",SelectItemAlignedPosition=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:s,...a}=e,o=useSelectContext(CONTENT_NAME$4,n),l=useSelectContentContext(CONTENT_NAME$4,n),[c,d]=React__namespace.useState(null),[f,R]=React__namespace.useState(null),S=useComposedRefs(t,pt=>R(pt)),te=useCollection$1(n),A=React__namespace.useRef(!1),rt=React__namespace.useRef(!0),{viewport:st,selectedItem:it,selectedItemText:at,focusSelectedItem:ot}=l,lt=React__namespace.useCallback(()=>{if(o.trigger&&o.valueNode&&c&&f&&st&&it&&at){const pt=o.trigger.getBoundingClientRect(),mt=f.getBoundingClientRect(),Rt=o.valueNode.getBoundingClientRect(),yt=at.getBoundingClientRect();if(o.dir!=="rtl"){const dr=yt.left-mt.left,Kt=Rt.left-dr,gr=pt.left-Kt,sr=pt.width+gr,or=Math.max(sr,mt.width),xr=window.innerWidth-CONTENT_MARGIN,Rr=clamp(Kt,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,xr-or)]);c.style.minWidth=sr+"px",c.style.left=Rr+"px"}else{const dr=mt.right-yt.right,Kt=window.innerWidth-Rt.right-dr,gr=window.innerWidth-pt.right-Kt,sr=pt.width+gr,or=Math.max(sr,mt.width),xr=window.innerWidth-CONTENT_MARGIN,Rr=clamp(Kt,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,xr-or)]);c.style.minWidth=sr+"px",c.style.right=Rr+"px"}const It=te(),ft=window.innerHeight-CONTENT_MARGIN*2,Ct=st.scrollHeight,Mt=window.getComputedStyle(f),Dt=parseInt(Mt.borderTopWidth,10),Vt=parseInt(Mt.paddingTop,10),Wt=parseInt(Mt.borderBottomWidth,10),$t=parseInt(Mt.paddingBottom,10),Ft=Dt+Vt+Ct+$t+Wt,Ht=Math.min(it.offsetHeight*5,Ft),nr=window.getComputedStyle(st),Jt=parseInt(nr.paddingTop,10),ar=parseInt(nr.paddingBottom,10),cr=pt.top+pt.height/2-CONTENT_MARGIN,Zt=ft-cr,lr=it.offsetHeight/2,Ut=it.offsetTop+lr,rr=Dt+Vt+Ut,qt=Ft-rr;if(rr<=cr){const dr=It.length>0&&it===It[It.length-1].ref.current;c.style.bottom="0px";const Kt=f.clientHeight-st.offsetTop-st.offsetHeight,gr=Math.max(Zt,lr+(dr?ar:0)+Kt+Wt),sr=rr+gr;c.style.height=sr+"px"}else{const dr=It.length>0&&it===It[0].ref.current;c.style.top="0px";const gr=Math.max(cr,Dt+st.offsetTop+(dr?Jt:0)+lr)+qt;c.style.height=gr+"px",st.scrollTop=rr-cr+st.offsetTop}c.style.margin=`${CONTENT_MARGIN}px 0`,c.style.minHeight=Ht+"px",c.style.maxHeight=ft+"px",s?.(),requestAnimationFrame(()=>A.current=!0)}},[te,o.trigger,o.valueNode,c,f,st,it,at,o.dir,s]);useLayoutEffect2(()=>lt(),[lt]);const[ut,ct]=React__namespace.useState();useLayoutEffect2(()=>{f&&ct(window.getComputedStyle(f).zIndex)},[f]);const dt=React__namespace.useCallback(pt=>{pt&&rt.current===!0&&(lt(),ot?.(),rt.current=!1)},[lt,ot]);return jsxRuntime.jsx(SelectViewportProvider,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:A,onScrollButtonChange:dt,children:jsxRuntime.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:ut},children:jsxRuntime.jsx(Primitive$4.div,{...a,ref:S,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});SelectItemAlignedPosition.displayName=ITEM_ALIGNED_POSITION_NAME;var POPPER_POSITION_NAME="SelectPopperPosition",SelectPopperPosition=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,align:s="start",collisionPadding:a=CONTENT_MARGIN,...o}=e,l=usePopperScope$1(n);return jsxRuntime.jsx(Content$2,{...l,...o,ref:t,align:s,collisionPadding:a,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});SelectPopperPosition.displayName=POPPER_POSITION_NAME;var[SelectViewportProvider,useSelectViewportContext]=createSelectContext(CONTENT_NAME$4,{}),VIEWPORT_NAME="SelectViewport",SelectViewport=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:s,...a}=e,o=useSelectContentContext(VIEWPORT_NAME,n),l=useSelectViewportContext(VIEWPORT_NAME,n),c=useComposedRefs(t,o.onViewportChange),d=React__namespace.useRef(0);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),jsxRuntime.jsx(Collection$1.Slot,{scope:n,children:jsxRuntime.jsx(Primitive$4.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:composeEventHandlers(a.onScroll,f=>{const R=f.currentTarget,{contentWrapper:S,shouldExpandOnScrollRef:te}=l;if(te?.current&&S){const A=Math.abs(d.current-R.scrollTop);if(A>0){const rt=window.innerHeight-CONTENT_MARGIN*2,st=parseFloat(S.style.minHeight),it=parseFloat(S.style.height),at=Math.max(st,it);if(at<rt){const ot=at+A,lt=Math.min(rt,ot),ut=ot-lt;S.style.height=lt+"px",S.style.bottom==="0px"&&(R.scrollTop=ut>0?ut:0,S.style.justifyContent="flex-end")}}}d.current=R.scrollTop})})})]})});SelectViewport.displayName=VIEWPORT_NAME;var GROUP_NAME="SelectGroup",[SelectGroupContextProvider,useSelectGroupContext]=createSelectContext(GROUP_NAME),SelectGroup$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=useId$1();return jsxRuntime.jsx(SelectGroupContextProvider,{scope:n,id:a,children:jsxRuntime.jsx(Primitive$4.div,{role:"group","aria-labelledby":a,...s,ref:t})})});SelectGroup$1.displayName=GROUP_NAME;var LABEL_NAME="SelectLabel",SelectLabel$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=useSelectGroupContext(LABEL_NAME,n);return jsxRuntime.jsx(Primitive$4.div,{id:a.id,...s,ref:t})});SelectLabel$1.displayName=LABEL_NAME;var ITEM_NAME$1="SelectItem",[SelectItemContextProvider,useSelectItemContext]=createSelectContext(ITEM_NAME$1),SelectItem$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,value:s,disabled:a=!1,textValue:o,...l}=e,c=useSelectContext(ITEM_NAME$1,n),d=useSelectContentContext(ITEM_NAME$1,n),f=c.value===s,[R,S]=React__namespace.useState(o??""),[te,A]=React__namespace.useState(!1),rt=useComposedRefs(t,ot=>d.itemRefCallback?.(ot,s,a)),st=useId$1(),it=React__namespace.useRef("touch"),at=()=>{a||(c.onValueChange(s),c.onOpenChange(!1))};if(s==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return jsxRuntime.jsx(SelectItemContextProvider,{scope:n,value:s,disabled:a,textId:st,isSelected:f,onItemTextChange:React__namespace.useCallback(ot=>{S(lt=>lt||(ot?.textContent??"").trim())},[]),children:jsxRuntime.jsx(Collection$1.ItemSlot,{scope:n,value:s,disabled:a,textValue:R,children:jsxRuntime.jsx(Primitive$4.div,{role:"option","aria-labelledby":st,"data-highlighted":te?"":void 0,"aria-selected":f&&te,"data-state":f?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...l,ref:rt,onFocus:composeEventHandlers(l.onFocus,()=>A(!0)),onBlur:composeEventHandlers(l.onBlur,()=>A(!1)),onClick:composeEventHandlers(l.onClick,()=>{it.current!=="mouse"&&at()}),onPointerUp:composeEventHandlers(l.onPointerUp,()=>{it.current==="mouse"&&at()}),onPointerDown:composeEventHandlers(l.onPointerDown,ot=>{it.current=ot.pointerType}),onPointerMove:composeEventHandlers(l.onPointerMove,ot=>{it.current=ot.pointerType,a?d.onItemLeave?.():it.current==="mouse"&&ot.currentTarget.focus({preventScroll:!0})}),onPointerLeave:composeEventHandlers(l.onPointerLeave,ot=>{ot.currentTarget===document.activeElement&&d.onItemLeave?.()}),onKeyDown:composeEventHandlers(l.onKeyDown,ot=>{d.searchRef?.current!==""&&ot.key===" "||(SELECTION_KEYS.includes(ot.key)&&at(),ot.key===" "&&ot.preventDefault())})})})})});SelectItem$1.displayName=ITEM_NAME$1;var ITEM_TEXT_NAME="SelectItemText",SelectItemText=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:a,...o}=e,l=useSelectContext(ITEM_TEXT_NAME,n),c=useSelectContentContext(ITEM_TEXT_NAME,n),d=useSelectItemContext(ITEM_TEXT_NAME,n),f=useSelectNativeOptionsContext(ITEM_TEXT_NAME,n),[R,S]=React__namespace.useState(null),te=useComposedRefs(t,at=>S(at),d.onItemTextChange,at=>c.itemTextRefCallback?.(at,d.value,d.disabled)),A=R?.textContent,rt=React__namespace.useMemo(()=>jsxRuntime.jsx("option",{value:d.value,disabled:d.disabled,children:A},d.value),[d.disabled,d.value,A]),{onNativeOptionAdd:st,onNativeOptionRemove:it}=f;return useLayoutEffect2(()=>(st(rt),()=>it(rt)),[st,it,rt]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Primitive$4.span,{id:d.textId,...o,ref:te}),d.isSelected&&l.valueNode&&!l.valueNodeHasChildren?ReactDOM__namespace.createPortal(o.children,l.valueNode):null]})});SelectItemText.displayName=ITEM_TEXT_NAME;var ITEM_INDICATOR_NAME="SelectItemIndicator",SelectItemIndicator=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return useSelectItemContext(ITEM_INDICATOR_NAME,n).isSelected?jsxRuntime.jsx(Primitive$4.span,{"aria-hidden":!0,...s,ref:t}):null});SelectItemIndicator.displayName=ITEM_INDICATOR_NAME;var SCROLL_UP_BUTTON_NAME="SelectScrollUpButton",SelectScrollUpButton$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContentContext(SCROLL_UP_BUTTON_NAME,e.__scopeSelect),s=useSelectViewportContext(SCROLL_UP_BUTTON_NAME,e.__scopeSelect),[a,o]=React__namespace.useState(!1),l=useComposedRefs(t,s.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let c=function(){const f=d.scrollTop>0;o(f)};const d=n.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),a?jsxRuntime.jsx(SelectScrollButtonImpl,{...e,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop-d.offsetHeight)}}):null});SelectScrollUpButton$1.displayName=SCROLL_UP_BUTTON_NAME;var SCROLL_DOWN_BUTTON_NAME="SelectScrollDownButton",SelectScrollDownButton$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContentContext(SCROLL_DOWN_BUTTON_NAME,e.__scopeSelect),s=useSelectViewportContext(SCROLL_DOWN_BUTTON_NAME,e.__scopeSelect),[a,o]=React__namespace.useState(!1),l=useComposedRefs(t,s.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let c=function(){const f=d.scrollHeight-d.clientHeight,R=Math.ceil(d.scrollTop)<f;o(R)};const d=n.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),a?jsxRuntime.jsx(SelectScrollButtonImpl,{...e,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop+d.offsetHeight)}}):null});SelectScrollDownButton$1.displayName=SCROLL_DOWN_BUTTON_NAME;var SelectScrollButtonImpl=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:s,...a}=e,o=useSelectContentContext("SelectScrollButton",n),l=React__namespace.useRef(null),c=useCollection$1(n),d=React__namespace.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return React__namespace.useEffect(()=>()=>d(),[d]),useLayoutEffect2(()=>{c().find(R=>R.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[c]),jsxRuntime.jsx(Primitive$4.div,{"aria-hidden":!0,...a,ref:t,style:{flexShrink:0,...a.style},onPointerDown:composeEventHandlers(a.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(s,50))}),onPointerMove:composeEventHandlers(a.onPointerMove,()=>{o.onItemLeave?.(),l.current===null&&(l.current=window.setInterval(s,50))}),onPointerLeave:composeEventHandlers(a.onPointerLeave,()=>{d()})})}),SEPARATOR_NAME="SelectSeparator",SelectSeparator$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return jsxRuntime.jsx(Primitive$4.div,{"aria-hidden":!0,...s,ref:t})});SelectSeparator$1.displayName=SEPARATOR_NAME;var ARROW_NAME$1="SelectArrow",SelectArrow=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=usePopperScope$1(n),o=useSelectContext(ARROW_NAME$1,n),l=useSelectContentContext(ARROW_NAME$1,n);return o.open&&l.position==="popper"?jsxRuntime.jsx(Arrow,{...a,...s,ref:t}):null});SelectArrow.displayName=ARROW_NAME$1;var BUBBLE_INPUT_NAME$1="SelectBubbleInput",SelectBubbleInput=React__namespace.forwardRef(({__scopeSelect:e,value:t,...n},s)=>{const a=React__namespace.useRef(null),o=useComposedRefs(s,a),l=usePrevious(t);return React__namespace.useEffect(()=>{const c=a.current;if(!c)return;const d=window.HTMLSelectElement.prototype,R=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==t&&R){const S=new Event("change",{bubbles:!0});R.call(c,t),c.dispatchEvent(S)}},[l,t]),jsxRuntime.jsx(Primitive$4.select,{...n,style:{...VISUALLY_HIDDEN_STYLES,...n.style},ref:o,defaultValue:t})});SelectBubbleInput.displayName=BUBBLE_INPUT_NAME$1;function shouldShowPlaceholder(e){return e===""||e===void 0}function useTypeaheadSearch(e){const t=useCallbackRef$1(e),n=React__namespace.useRef(""),s=React__namespace.useRef(0),a=React__namespace.useCallback(l=>{const c=n.current+l;t(c),(function d(f){n.current=f,window.clearTimeout(s.current),f!==""&&(s.current=window.setTimeout(()=>d(""),1e3))})(c)},[t]),o=React__namespace.useCallback(()=>{n.current="",window.clearTimeout(s.current)},[]);return React__namespace.useEffect(()=>()=>window.clearTimeout(s.current),[]),[n,a,o]}function findNextItem(e,t,n){const a=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let l=wrapArray(e,Math.max(o,0));a.length===1&&(l=l.filter(f=>f!==n));const d=l.find(f=>f.textValue.toLowerCase().startsWith(a.toLowerCase()));return d!==n?d:void 0}function wrapArray(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Root2$3=Select$2,Trigger$2=SelectTrigger$1,Value=SelectValue$1,Icon=SelectIcon,Portal$1=SelectPortal,Content2$3=SelectContent$1,Viewport=SelectViewport,Group=SelectGroup$1,Label=SelectLabel$1,Item$2=SelectItem$1,ItemText=SelectItemText,ItemIndicator=SelectItemIndicator,ScrollUpButton=SelectScrollUpButton$1,ScrollDownButton=SelectScrollDownButton$1,Separator=SelectSeparator$1;const Select$1=Root2$3,SelectGroup=Group,SelectValue=Value,SelectTrigger=React__namespace.forwardRef(({className:e,children:t,...n},s)=>jsxRuntime.jsxs(Trigger$2,{ref:s,className:cn("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,jsxRuntime.jsx(Icon,{asChild:!0,children:jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));SelectTrigger.displayName=Trigger$2.displayName;const SelectScrollUpButton=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(ScrollUpButton,{ref:n,className:cn("flex cursor-default items-center justify-center py-1",e),...t,children:jsxRuntime.jsx(ChevronUp,{className:"h-4 w-4"})}));SelectScrollUpButton.displayName=ScrollUpButton.displayName;const SelectScrollDownButton=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(ScrollDownButton,{ref:n,className:cn("flex cursor-default items-center justify-center py-1",e),...t,children:jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4"})}));SelectScrollDownButton.displayName=ScrollDownButton.displayName;const SelectContent=React__namespace.forwardRef(({className:e,children:t,position:n="popper",...s},a)=>jsxRuntime.jsx(Portal$1,{children:jsxRuntime.jsxs(Content2$3,{ref:a,className:cn("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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 origin-[--radix-select-content-transform-origin]",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...s,children:[jsxRuntime.jsx(SelectScrollUpButton,{}),jsxRuntime.jsx(Viewport,{className:cn("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),jsxRuntime.jsx(SelectScrollDownButton,{})]})}));SelectContent.displayName=Content2$3.displayName;const SelectLabel=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Label,{ref:n,className:cn("px-2 py-1.5 text-sm font-semibold",e),...t}));SelectLabel.displayName=Label.displayName;const SelectItem=React__namespace.forwardRef(({className:e,children:t,...n},s)=>jsxRuntime.jsxs(Item$2,{ref:s,className:cn("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[jsxRuntime.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:jsxRuntime.jsx(ItemIndicator,{children:jsxRuntime.jsx(Check,{className:"h-4 w-4"})})}),jsxRuntime.jsx(ItemText,{children:t})]}));SelectItem.displayName=Item$2.displayName;const SelectSeparator=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Separator,{ref:n,className:cn("-mx-1 my-1 h-px bg-muted",e),...t}));SelectSeparator.displayName=Separator.displayName;function ManufacturerProducts({applicationId:e,manufacturer:t,shopifyHostName:n}){const[s]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeShopifyMutation(),[a,o]=React.useState(()=>{const dt=t.Categories?.[0]?.CategoryCode??"";if(typeof window>"u")return dt;const pt=new URLSearchParams(window.location.search).get("category")?.trim();return pt&&t.Categories?.some(Rt=>Rt.CategoryCode===pt)?pt:dt}),[l,c]=React.useState(!1),[d,f]=React.useState(!1),[R,S]=React.useState("percentile"),[te,A]=React.useState(!1),{toast:rt}=useToast(),{data:st,isLoading:it,isFetching:at}=useGetV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeQuery({routeResellerId:e,manufacturerId:t.ManufacturerId,categoryCode:a??""},{skip:!t.ManufacturerId||!a}),ot=async()=>{try{c(!0),f(!1),await s({routeResellerId:e,manufacturerId:t.ManufacturerId??"",categoryCode:a,shopifyHostName:n}).unwrap()&&rt({title:"Success",description:"Category synced to Shopify successfully",variant:"success"})}catch(dt){console.error("Error syncing to Shopify:",dt),rt({title:"Error",description:"Error syncing category to Shopify.",variant:"destructive"})}finally{c(!1)}},lt=()=>t.Categories?.find(dt=>dt.CategoryCode===a)?.CategoryName||a,ut=React.useMemo(()=>st?.Products?[...st.Products].sort((dt,pt)=>R==="price-asc"?(dt.MAP??0)-(pt.MAP??0):R==="price-desc"?(pt.MAP??0)-(dt.MAP??0):R==="name"?(dt.Title??"").localeCompare(pt.Title??""):R==="percentile"?(pt.OverallPercentileRank??0)-(dt.OverallPercentileRank??0):0):[],[st?.Products,R]),ct=React.useMemo(()=>te?ut.filter(dt=>{const pt=dt.Distribution?.Inventory;return!Array.isArray(pt)||pt.length===0?!1:pt.reduce((Rt,yt)=>Rt+(yt?.AvailableQuantity??0),0)>0}):ut,[te,ut]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx(ManufacturerCategories,{categories:t.Categories||[],activeCategory:a,onSelectCategory:o}),jsxRuntime.jsx("div",{className:"mb-4 w-full",children:jsxRuntime.jsx(ManufacturerCategorySummary,{name:lt(),niche:st?.Niche||"",productsNumber:st?.Products?.length||0,autoreorder:st?.AutoReorder||!1,starred:st?.Starred||!1,isLoading:it||at,children:n&&t.Categories?.findIndex(dt=>dt.AvailableToBuy)!==-1&&jsxRuntime.jsx(Button$1,{className:"bg-success text-success-foreground hover:bg-success/90",disabled:l,onClick:()=>f(!0),children:l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2 h-4 w-4"}),"Sync Category to Shopify"]})})})}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsx(ManufacturerCategoriesStats,{categories:[t.Categories?.find(dt=>dt.CategoryCode===a)].filter(Boolean),manufID:t.ManufacturerId,appID:e}),jsxRuntime.jsx(ActiveOrdersCard,{orders:st?.ActiveOrderDetails??void 0,loading:it||at})]})]}),jsxRuntime.jsx(ManufacturerCategories,{categories:t.Categories||[],activeCategory:a,onSelectCategory:o}),jsxRuntime.jsxs("div",{className:"flex justify-between items-center mt-7 mb-4",children:[jsxRuntime.jsx("h4",{className:"text-xl md:text-2xl text-foreground font-bold",children:"Products"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-4 ms-auto",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:"Sort by:"}),jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:jsxRuntime.jsxs(Select$1,{value:R,onValueChange:S,children:[jsxRuntime.jsx(SelectTrigger,{className:"w-[220px]",children:jsxRuntime.jsx(SelectValue,{})}),jsxRuntime.jsxs(SelectContent,{children:[jsxRuntime.jsx(SelectItem,{value:"price-asc",children:"MAP: Low to High"}),jsxRuntime.jsx(SelectItem,{value:"price-desc",children:"MAP: High to Low"}),jsxRuntime.jsx(SelectItem,{value:"name",children:"Name"}),jsxRuntime.jsx(SelectItem,{value:"percentile",children:"Best Selling"})]})]})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Checkbox,{id:"in-stock-filter",checked:te,onCheckedChange:dt=>A(dt===!0)}),jsxRuntime.jsx(Label$2,{htmlFor:"in-stock-filter",className:"text-muted-foreground whitespace-nowrap",children:"In Stock"})]})]})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4 mb-4",children:it||at?Array.from({length:4}).map((dt,pt)=>jsxRuntime.jsx(ProductCard,{},pt)):ct.length>0?ct.map(dt=>jsxRuntime.jsx(ProductCard,{applicationId:e,product:dt,viewProductLink:`/${e}/Product/${dt.RandmarSKU}`,shopifyHostname:n},dt.RandmarSKU)):jsxRuntime.jsxs(Alert,{variant:"warning",className:"col-span-1 @md:col-span-2",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Warning"}),jsxRuntime.jsx(AlertDescription,{children:te&&ut.length>0?"No in-stock products found in this category. Try turning off the In Stock filter.":"No products found for this manufacturer category."})]})}),jsxRuntime.jsx(Dialog,{open:d,onOpenChange:f,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Confirm Sync to Shopify"}),jsxRuntime.jsxs(DialogDescription,{children:['Are you sure you want to sync the category "',lt(),'" to Shopify? This will add all products in this category to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>f(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{className:"bg-success text-success-foreground hover:bg-success/90",onClick:ot,disabled:l,children:l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})})]})}function PartnerRelationshipPage({applicationId:e,partnerId:t,userEmail:n,shopifyHostName:s,isSuperAdmin:a}){const{data:o}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:e}),{data:l,isLoading:c,isFetching:d}=useGetV4PartnerByRouteApplicationIdPartnerAndPartnerIdQuery({routeApplicationId:e,partnerId:t,withSpecification:!0}),{toast:f}=useToast(),[R]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdShopifyMutation(),[S,te]=React.useState(!1),[A,rt]=React.useState(!1),st=async()=>{try{te(!0),rt(!1),await R({routeResellerId:e??"",manufacturerId:t??"",shopifyHostName:s}).unwrap()&&f({title:"Success",description:"Manufacturer synced to Shopify successfully",variant:"success"})}catch(ut){console.error("Error syncing to Shopify:",ut),f({title:"Error",description:"Error syncing manufacturer to Shopify.",variant:"destructive"})}finally{te(!1)}},it=()=>l?.Manufacturer?"products":l?.Reseller?"reseller-overview":"",at=()=>typeof window>"u"?null:new URLSearchParams(window.location.search).get("tab"),ot=()=>{const ut=at();return ut==="assistant"?"assistant":ut==="reseller-overview"&&l?.Reseller?"reseller-overview":ut==="manufacturer-overview"&&l?.Manufacturer?"manufacturer-overview":ut==="products"&&l?.Manufacturer?"products":it()||"assistant"},lt=usePartnershipAssistantPrompt(o,l);return jsxRuntime.jsxs("div",{className:"@container",children:[jsxRuntime.jsxs("div",{className:"grid gap-4 @2xl:grid-cols-2",children:[jsxRuntime.jsx(PartnerCard,{account:l,loading:c||d,withAbout:!0,action:" "}),jsxRuntime.jsxs("div",{className:"grid gap-4",children:[(l?.Manufacturer||c||d)&&jsxRuntime.jsx(ManufacturerCard,{manufacturer:l?.Manufacturer,loading:c||d,mainAction:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[l?.Manufacturer&&jsxRuntime.jsx(ManufacturerGetStartedButton,{applicationId:e,manufacturer:l?.Manufacturer}),s&&l?.Manufacturer?.Categories?.findIndex(ut=>ut.AvailableToBuy)!==-1&&jsxRuntime.jsxs(Dialog,{open:A,onOpenChange:rt,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{className:"ml-2 bg-success text-success-foreground hover:bg-success/90",disabled:S,children:S?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2 h-4 w-4"}),"Sync Manufacturer to Shopify"]})})}),jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Confirm Sync to Shopify"}),jsxRuntime.jsxs(DialogDescription,{children:['Are you sure you want to sync the manufacturer "',l?.Manufacturer?.PublicName,'" to Shopify? This will add all products from this manufacturer to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>rt(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{className:"bg-success text-success-foreground hover:bg-success/90",onClick:st,disabled:S,children:S?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})]})]})}),l?.Reseller&&jsxRuntime.jsx(ResellerCard,{reseller:l?.Reseller,loading:c||d})]})]}),(l?.Reseller||l?.Manufacturer)&&!c&&!d&&jsxRuntime.jsx("div",{className:"w-full p-4 sm:p-6",children:jsxRuntime.jsxs(Tabs,{defaultValue:ot(),className:"w-full",children:[jsxRuntime.jsxs(TabsList,{className:"inline-flex h-auto items-center justify-center rounded-none border-b bg-transparent p-0",children:[l?.Reseller&&jsxRuntime.jsx(TabsTrigger,{value:"reseller-overview",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Reseller Overview"}),l?.Manufacturer&&jsxRuntime.jsx(TabsTrigger,{value:"manufacturer-overview",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Manufacturer Overview"}),l?.Manufacturer&&jsxRuntime.jsx(TabsTrigger,{value:"products",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Products"}),jsxRuntime.jsxs(TabsTrigger,{value:"assistant",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:[jsxRuntime.jsx(Bot,{className:"mr-2 w-4 h-4"}),"Assistant"]})]}),l?.Reseller&&jsxRuntime.jsx(TabsContent,{value:"reseller-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ResellerOverview,{readonly:!0,appID:l.ApplicationId||"",reseller:l?.Reseller,userEmail:n,isSuperAdmin:a,withoutReports:!0})})}),l?.Manufacturer&&jsxRuntime.jsx(TabsContent,{value:"manufacturer-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerOverviewPage,{readonly:!0,manufacturer:l?.Manufacturer,applicationId:e,userEmail:n})})}),l?.Manufacturer&&jsxRuntime.jsx(TabsContent,{value:"products",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerProducts,{applicationId:e,manufacturer:l.Manufacturer,shopifyHostName:s})})}),jsxRuntime.jsx(TabsContent,{value:"assistant",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(AssistantInsight,{applicationId:e,prompt:lt,thinkingPlaceholderText:"Thinking about the relationship..."})})})]})}),(c||d)&&jsxRuntime.jsx("div",{className:"mt-4 flex h-32 w-full items-center justify-center p-4 sm:p-6",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-primary"})})]})}const PublicInfo=({reseller:e,appID:t,isLoading:n,readonly:s,onUnsavedChanges:a})=>{const{toast:o}=useToast(),[l]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),[c,d]=React.useState({}),f=React.useMemo(()=>({publicEmail:e.PublicEmail??"",contactName:e.ContactName??"",phone:e.Phone??"",website:e.Website??""}),[e]),{register:R,handleSubmit:S,reset:te,watch:A,formState:{errors:rt,isSubmitting:st}}=useForm({defaultValues:f}),it=A(),at=React.useCallback(()=>c?JSON.stringify(it)!==JSON.stringify(c):!1,[it,c]);React.useEffect(()=>{a&&a(at())},[at,a]),React.useEffect(()=>{e&&Object.keys(e).length>0&&(te(f),d(f))},[e,te,f]);const ot=async ut=>{let ct=!0,dt=!1;const pt=Object.keys(ut).map(mt=>({key:mt,keyApi:mt.charAt(0).toUpperCase()+mt.slice(1)}));for(const mt of pt){const Rt=ut[mt.key],yt=e[mt.keyApi];if(Rt!==yt&&Rt!==void 0){dt=!0;try{await l({applicationId:t,fieldName:mt.keyApi,newValue:String(Rt)}).unwrap()||(ct=!1)}catch(It){console.error(`Error updating ${mt.keyApi}:`,It),ct=!1}}}ct&&dt?(o({title:"Public info",description:"Information updated successfully",variant:"success"}),d({...ut}),a&&a(!1)):ct||o({title:"Updation error",description:"Failed to update",variant:"destructive"})},lt=ut=>!ut||ut.trim()==="";return n?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Public Information"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-28"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"})})]})})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsxs(CardTitle,{className:"text-1xl font-bold",children:["Public Information ",s?"(read only)":""]})}),jsxRuntime.jsxs(CardContent,{children:[(lt(A("contactName"))||lt(A("publicEmail"))||lt(A("website"))||lt(A("phone")))&&jsxRuntime.jsxs(Alert,{variant:"destructive",className:"mb-6",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Missing information"}),jsxRuntime.jsx(AlertDescription,{children:"All fields are required to get started at working with Manufacturers."})]}),jsxRuntime.jsxs("form",{onSubmit:S(ot),className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"contactName",children:"Main Representative *"}),jsxRuntime.jsx(Input,{id:"contactName",placeholder:"John Doe",readOnly:s,...R("contactName",{}),className:rt.contactName||lt(A("contactName"))?"input-error-indicator":""}),rt.contactName&&jsxRuntime.jsx("p",{className:"text-destructive text-sm",children:rt.contactName.message})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"publicEmail",children:"Public Email *"}),jsxRuntime.jsx(Input,{id:"publicEmail",placeholder:"contact@company.com",readOnly:s,...R("publicEmail",{pattern:{value:/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,message:"Invalid email address"}}),className:rt.publicEmail||lt(A("publicEmail"))?"input-error-indicator":""}),rt.publicEmail&&jsxRuntime.jsx("p",{className:"text-destructive text-sm",children:rt.publicEmail.message})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"website",children:"Website *"}),jsxRuntime.jsx(Input,{id:"website",placeholder:"https://company.com",readOnly:s,...R("website",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:rt.website||lt(A("website"))?"input-error-indicator":""}),rt.website&&jsxRuntime.jsx("p",{className:"text-destructive text-sm",children:rt.website.message})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"phone",children:"Phone Number *"}),jsxRuntime.jsx(Input,{id:"phone",placeholder:"+1 (555) 123-4567",readOnly:s,...R("phone",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:rt.phone||lt(A("phone"))?"input-error-indicator":""}),rt.phone&&jsxRuntime.jsx("p",{className:"text-destructive text-sm",children:rt.phone.message})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Button$1,{type:"submit",disabled:st||s,className:s?"hidden":"",children:st?"Saving...":"Save"})})]})]})]})};function BillingCard({appID:e,reseller:t,isLoading:n,withoutReports:s,userEmail:a,isSuperAdmin:o}){const{toast:l}=useToast(),{Statement:c,CreditLimit:d}=t,[f,R]=React.useState(!1),[S,te]=React.useState(!1),[A,rt]=React.useState(!1),[st,it]=React.useState(!1),[at,ot]=React.useState(a||""),[lt,ut]=React.useState(!1),[ct,dt]=React.useState(d?.toString()||""),[pt,{isLoading:mt}]=usePostV4PartnerByApplicationIdAccountResellerCreditLimitMutation(),Rt=[{label:"0 - 30 Days",value:jsxRuntime.jsx(FormattedNumber,{value:c?.Over0||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:Calendar$1},{label:"31 - 45 Days",value:jsxRuntime.jsx(FormattedNumber,{value:c?.Over30||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarDays},{label:"45+ Days",value:jsxRuntime.jsx(FormattedNumber,{value:c?.Over45||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarRange},{label:"Total",value:jsxRuntime.jsx(FormattedNumber,{value:c?.Total||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:DollarSign},{label:"Credit Limit",value:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(FormattedNumber,{value:d||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),o&&jsxRuntime.jsx(Button$1,{size:"icon",variant:"outline",className:"ml-2",onClick:()=>{ut(!0),dt(d?.toString()||"")},children:jsxRuntime.jsx(SquarePen,{})})]}),icon:CreditCard}],[yt]=useLazyGetV4ResellerByRouteResellerIdDocumentAndDocumentNumberPdfQuery(),It=async Dt=>{Dt?R(!0):te(!0);try{const Wt=(await yt({routeResellerId:e,documentNumber:`ST${e}`})).data;if(!Wt)throw new Error("No data received for download.");if(Dt)window.open(Wt);else{const $t=document.createElement("a");$t.href=Wt,$t.download=`ST${e}.pdf`,document.body.appendChild($t),$t.click(),$t.remove()}l({title:"Success",description:"Statement downloaded successfully.",variant:"success"})}catch(Vt){console.error("Download Error:",Vt),l({title:"Error",description:"An error occurred while downloading the statement. Please try again.",variant:"destructive"})}finally{Dt?R(!1):te(!1)}},[ft]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),Ct=async()=>{if(!at||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(at)){l({title:"Invalid Email",description:"Please enter a valid email address.",variant:"destructive"});return}rt(!0);try{await ft({routeResellerId:e,emailAddress:at}).unwrap(),l({title:"Success",description:`Statement sent to ${at} successfully.`,variant:"success"}),it(!1)}catch(Vt){console.error("Send Email Error:",Vt),l({title:"Error",description:"An error occurred while sending the statement. Please try again.",variant:"destructive"})}finally{rt(!1)}};if(n)return jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"border-b p-6 md:p-5",children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-36"})}),jsxRuntime.jsxs(CardContent,{className:"p-6 md:p-5",children:[jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-2 sm:divide-x divide-border",children:[jsxRuntime.jsx("div",{className:"space-y-6 sm:pe-4",children:[1,2,3].map(Dt=>jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 ms-auto"})]},Dt))}),jsxRuntime.jsx("div",{className:"space-y-6 sm:ps-4 pt-6 sm:pt-0 mt-6 sm:mt-0 border-t sm:border-t-0 border-border",children:[1,2].map(Dt=>jsxRuntime.jsx("div",{className:Dt===2?"pt-6 mt-6 border-t border-border":"",children:jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 ms-auto"})]})},Dt))})]}),jsxRuntime.jsxs("div",{className:"flex justify-end mt-6 gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-28"})]})]})]});const Mt=!s;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"border-b p-6 md:p-5",children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Billing Overview"})}),jsxRuntime.jsxs(CardContent,{className:"p-6 md:p-5",children:[jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-2 sm:divide-x divide-border",children:[jsxRuntime.jsx("div",{className:"space-y-6 sm:pe-4",children:Rt.slice(0,3).map((Dt,Vt)=>jsxRuntime.jsx(BillingItem,{icon:Dt.icon,label:Dt.label,value:Dt.value},Vt))}),jsxRuntime.jsx("div",{className:"space-y-6 sm:ps-4 pt-6 sm:pt-0 mt-6 sm:mt-0 border-t sm:border-t-0 border-border",children:Rt.slice(3).map((Dt,Vt)=>jsxRuntime.jsx("div",{className:Vt===1?"pt-6 mt-6 border-t border-border":"",children:jsxRuntime.jsx(BillingItem,{icon:Dt.icon,label:Dt.label,value:Dt.value})},Vt))})]}),Mt&&jsxRuntime.jsxs("div",{className:"flex justify-end mt-6 gap-2",children:[jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"outline",size:"icon",onClick:()=>It(!0),disabled:f,children:f?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Printer,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Print Statement"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"outline",size:"icon",onClick:()=>It(!1),disabled:S,children:S?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Download Statement"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"outline",size:"icon",onClick:()=>it(!0),disabled:A,children:A?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Mail,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Email Statement"})})]})}),jsxRuntime.jsx(reactRouterDom.Link,{to:`${window.location.hostname==="dashboard.randmar.io"?"":"https://dashboard.randmar.io"}/${e}/PayInvoice`,target:window.location.hostname==="dashboard.randmar.io"?"_self":"_blank",children:jsxRuntime.jsxs(Button$1,{children:[jsxRuntime.jsx(CreditCard,{className:"mr-2 h-4 w-4"}),"Pay Invoices"]})})]})]})]}),jsxRuntime.jsx(Dialog,{open:st,onOpenChange:it,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Send Statement by Email"}),jsxRuntime.jsx(DialogDescription,{children:"Enter the recipient's email address below. The statement will be sent as a PDF attachment."})]}),jsxRuntime.jsx("div",{className:"grid gap-4 py-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",className:"text-right",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",type:"email",value:at,onChange:Dt=>ot(Dt.target.value),className:"col-span-3",placeholder:"recipient@example.com"})]})}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button$1,{type:"submit",onClick:Ct,disabled:A||!at,children:A?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Send,{className:"mr-2 h-4 w-4"}),"Send"]})})})]})}),jsxRuntime.jsx(Dialog,{open:lt,onOpenChange:ut,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Edit Credit Limit"}),jsxRuntime.jsx(DialogDescription,{children:"Enter the new credit limit for this reseller."})]}),jsxRuntime.jsx("div",{className:"grid gap-4 py-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"creditLimit",className:"text-right",children:"Amount"}),jsxRuntime.jsx(Input,{id:"creditLimit",type:"number",value:ct,onChange:Dt=>dt(Dt.target.value),className:"col-span-3",placeholder:"0.00"})]})}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button$1,{type:"submit",onClick:async()=>{const Dt=Number(ct);if(isNaN(Dt)){l({title:"Invalid Amount",description:"Please enter a valid number for credit limit.",variant:"destructive"});return}try{await pt({applicationId:e,newValue:Dt}).unwrap(),ut(!1),l({title:"Success",description:"Credit limit updated successfully.",variant:"success"})}catch(Vt){console.error("Update Credit Limit Error:",Vt),l({title:"Error",description:"Failed to update credit limit. Please try again.",variant:"destructive"})}},disabled:mt,children:mt?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})})]})})]})}function BillingItem({icon:e,label:t,value:n}){return jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(e,{className:"size-4 text-muted-foreground"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:t})]}),jsxRuntime.jsx("span",{className:"text-base font-semibold ms-auto",children:n})]})}function ChangePricingTierModal({open:e,setOpen:t,tier:n,onTierChange:s,isLoading:a}){const o=()=>{t(!1)};return jsxRuntime.jsx(Dialog,{open:e,onOpenChange:t,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Change Pricing Tier"})}),jsxRuntime.jsxs("div",{className:"grid gap-1.5 py-2",children:[jsxRuntime.jsxs("p",{className:"text-lg text-muted-foreground",children:["Requested Pricing Tier: ",jsxRuntime.jsx("span",{className:"font-bold",children:n})]}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"If your account qualifies, your pricing will update immediately."}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"If not, we'll review your request and notify you of the decision."})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:o,disabled:a,children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:s,disabled:a,children:a?"Loading...":`Apply for ${n}`})]})]})})}const getPricingText=e=>e===1?"The Best":e===2?"Fixed 12.5% GP on all items":e===3?"Advantageous":e===4?"Buying Group":e===5?"Cost":e,getShippingText=e=>e==="A"?"Free or Custom":e==="B"?"Fixed $10 anywhere":e==="C"?`Free shipping on $150+ orders to your location,
|
|
486
486
|
$15 for drop shipped orders under $1,500,
|
|
487
|
-
$10 with opportunities under $1,000`:e==="D"?"$15 under $1,500":e==="E"?"Full shipping charges":e,getTermsText=e=>e==="STRIPE"?"Credit card payment":e==="NET30"?"Net 30 days":e,AccountTier=({isSuperAdmin:e,readonly:t,reseller:n,appID:s,isLoading:a})=>{const{toast:o}=useToast(),[l,c]=React.useState(!1),[d,f]=React.useState(""),[R,{isLoading:S}]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),te=Dt=>Dt&&{Starter:"starter","E-Commerce":"ecommerce",Commercial:"commercial",Basics:"cws",Novexco:"novexco",COOPSCO:"coopsco","Jean Coutu":"jeancoutu",Exclusive:"exclusive"}[Dt]||"",A=Dt=>Dt&&{A:"free",B:"fixed",C:"dropshipped",D:"under1500",E:"fullcharges"}[Dt]||"",rt=Dt=>Dt&&{1:"exclusive",2:"ecommerce",3:"commercial",4:"buyinggroup",5:"cost"}[Dt]||"",[st,it]=React.useState(te(n?.Priority??"")),[at,ot]=React.useState(A(n?.ShippingProfile??"")),[lt,ut]=React.useState(rt(n?.PriceProfile)),ct=Dt=>({starter:"Starter",ecommerce:"E-Commerce",commercial:"Commercial",cws:"Basics",novexco:"Novexco",coopsco:"COOPSCO",jeancoutu:"Jean Coutu",exclusive:"Exclusive"})[Dt]||Dt,dt=Dt=>({free:"A",fixed:"B",dropshipped:"C",under1500:"D",fullcharges:"E"})[Dt]||Dt,pt=Dt=>({exclusive:"1",ecommerce:"2",commercial:"3",buyinggroup:"4",cost:"5"})[Dt]||Dt;React.useEffect(()=>{it(te(n?.Priority??"")),ot(A(n?.ShippingProfile??"")),ut(rt(n?.PriceProfile))},[n]);const mt=async(Dt,Vt,Wt,$t)=>{try{(await R({applicationId:s,fieldName:Dt,newValue:Vt})).error?o({title:"Error",description:$t,variant:"destructive"}):o({title:"Success",description:Wt,variant:"success"})}catch{o({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}},Rt=async Dt=>{it(Dt);const Vt=ct(Dt);mt("Priority",Vt,`Priority updated to ${Vt}`,"Failed to update priority")},yt=async Dt=>{ot(Dt);const Vt=dt(Dt);mt("ShippingProfile",Vt,`Shipping profile updated to ${Vt}`,"Failed to update shipping profile")},It=async Dt=>{ut(Dt);const Vt=pt(Dt);mt("PriceProfile",Vt,`Pricing profile updated to ${Vt}`,"Failed to update pricing profile")},ft=async()=>{try{const Dt=await R({applicationId:s,fieldName:"Tier",newValue:d});Dt.error?o({title:"Error",description:"Failed to update reseller",variant:"destructive"}):Dt.data?o({title:"Success",description:`Pricing Tier changed to ${d}`,variant:"success"}):o({title:"Considered",description:"Request being considered",variant:"success"})}catch{o({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}finally{c(!1),f("")}},Ct=[{name:"Terms",enabled:n.Priority==="Starter"},{name:"E-Commerce",enabled:n.Priority==="Commercial"},{name:"Commercial",enabled:n.Priority==="E-Commerce"},{name:"Exclusive",enabled:e}],Mt=Dt=>{f(Dt),c(!0)};return a?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"pb-2",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-28"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-16 rounded-full"})]})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-56"})]}),jsxRuntime.jsx("div",{className:"grid gap-3",children:[1,2,3].map(Dt=>jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"})]})]},Dt))}),jsxRuntime.jsxs("div",{className:"flex gap-2 mt-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{className:"pb-2 pt-4 px-4 flex flex-row items-center justify-between",children:[jsxRuntime.jsx(CardTitle,{className:"text-base font-medium text-foreground",children:"Account Tier"}),jsxRuntime.jsx(Badge,{variant:"success",className:"text-xs",children:"Active"})]}),jsxRuntime.jsxs(CardContent,{className:"pt-2 px-4 pb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-3 bg-primary/5 p-4 rounded-lg",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("h3",{className:"text-lg font-bold text-primary",children:[n?.Priority||""," Tier"]}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Optimized for online retail"})]}),jsxRuntime.jsx(CircleCheck,{className:"h-6 w-6 text-success"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-2 mb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Package2,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Pricing"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground truncate",children:getPricingText(n.PriceProfile||0)})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Truck,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Shipping"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getShippingText(n.ShippingProfile||"").split(".")[0]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Calendar$1,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Payment terms"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getTermsText(n?.Terms||"")})]})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[!t&&jsxRuntime.jsx(Button$1,{variant:"outline",className:"flex-1",asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:"https://randmar.io/pricing",target:"_blank",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4 mr-1"}),"Pricing Tiers"]})}),jsxRuntime.jsxs(Popover,{children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{disabled:t,className:t?"hidden":"flex-1",children:["Upgrade Tier ",jsxRuntime.jsx(ChevronRight,{className:"h-3 w-3 ml-1"})]})}),jsxRuntime.jsx(PopoverContent,{className:"w-56 p-2",children:jsxRuntime.jsxs("div",{className:"grid gap-1",children:[jsxRuntime.jsx("h4",{className:"font-medium text-xs mb-1",children:"Select a tier"}),Ct.map(Dt=>jsxRuntime.jsx(Button$1,{variant:"ghost",size:"sm",className:"w-full justify-start h-8",disabled:!Dt.enabled,onClick:()=>Mt(Dt.name),children:Dt.name},Dt.name))]})})]})]})]})]}),jsxRuntime.jsx(ChangePricingTierModal,{isLoading:S,open:l,setOpen:c,tier:d,onTierChange:ft}),e&&!t&&jsxRuntime.jsxs(Card,{className:"mt-4",children:[jsxRuntime.jsx(CardHeader,{className:"pb-2 pt-3 px-4",children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Admin Configuration"})}),jsxRuntime.jsx(CardContent,{className:"pt-2 px-4 pb-4",children:jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Priority"}),jsxRuntime.jsx(RadioGroup$1,{value:st,onValueChange:Rt,className:"grid grid-cols-2 @sm:grid-cols-3 @md:grid-cols-4 gap-1",children:[{value:"starter",label:"Starter"},{value:"ecommerce",label:"E-Commerce"},{value:"commercial",label:"Commercial"},{value:"cws",label:"CWS (Basics)"},{value:"novexco",label:"Novexco"},{value:"coopsco",label:"COOPSCO"},{value:"jeancoutu",label:"Jean Coutu"},{value:"exclusive",label:"Exclusive"}].map(Dt=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Dt.value,id:`priority-${Dt.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`priority-${Dt.value}`,className:"cursor-pointer text-xs",children:Dt.label})]},Dt.value))})]}),jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Shipping Profile"}),jsxRuntime.jsx(RadioGroup$1,{value:at,onValueChange:yt,className:"grid grid-cols-1 @md:grid-cols-2 gap-1",children:[{value:"free",label:"Free (A)"},{value:"fixed",label:"Fixed $10 Shipping (B)"},{value:"dropshipped",label:"$15 for drop shipped (C)"},{value:"under1500",label:"15$ under 1,500 (D)"},{value:"fullcharges",label:"Full shipping charges (E)"}].map(Dt=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Dt.value,id:`shipping-${Dt.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`shipping-${Dt.value}`,className:"cursor-pointer text-xs",children:Dt.label})]},Dt.value))})]}),jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Pricing Profile"}),jsxRuntime.jsx(RadioGroup$1,{value:lt,onValueChange:It,className:"grid grid-cols-2 @sm:grid-cols-3 gap-1",children:[{value:"exclusive",label:"Exclusive (1)"},{value:"ecommerce",label:"E-Commerce (2)"},{value:"commercial",label:"Commercial (3)"},{value:"buyinggroup",label:"Buying Group (4)"},{value:"cost",label:"Cost (5)"}].map(Dt=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Dt.value,id:`pricing-${Dt.value}`,className:"h-6 w-6 scale-50 antialiased"}),jsxRuntime.jsx(Label$2,{htmlFor:`pricing-${Dt.value}`,className:"cursor-pointer text-xs",children:Dt.label})]},Dt.value))})]})]})})]})]})};function OrderCategories({openOrders:e=[],isLoading:t=!1}){const n=e?.filter(st=>st.DocumentType==="Order")||[],s=e?.filter(st=>st.DocumentType==="Shipment")||[],a=n.filter(st=>st.WarehouseCode!=="3PLE"),o=a.reduce((st,it)=>st+(it.Quantity??0),0),l=a.reduce((st,it)=>st+(it.ExtendedPrice??0),0),c=n.filter(st=>st.WarehouseCode==="3PLE"),d=c.reduce((st,it)=>st+(it.Quantity??0),0),f=c.reduce((st,it)=>st+(it.ExtendedPrice??0),0),R=s.reduce((st,it)=>st+(it.Quantity??0),0),S=s.reduce((st,it)=>st+(it.ExtendedPrice??0),0),te=o+d+R,A=l+f+S,rt=[{name:"All",icon:Package,stripeClass:"bg-info/60",iconBgClass:"bg-info/90",iconTextClass:"text-info-foreground",orders:te,amount:A},{name:"Processing",icon:RefreshCcw,stripeClass:"bg-warning/60",iconBgClass:"bg-warning/90",iconTextClass:"text-warning-foreground",orders:o,amount:l},{name:"Shipped",icon:Truck,stripeClass:"bg-success/60",iconBgClass:"bg-success/90",iconTextClass:"text-success-foreground",orders:R,amount:S},{name:"Delayed",icon:CircleAlert,stripeClass:"bg-destructive/60",iconBgClass:"bg-destructive/90",iconTextClass:"text-destructive-foreground",orders:d,amount:f}];return t?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-40"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:[1,2,3,4].map(st=>jsxRuntime.jsx(Card,{className:"overflow-hidden rounded-md rounded-b-lg border-0 shadow-md",children:jsxRuntime.jsxs(CardContent,{className:"p-0",children:[jsxRuntime.jsx("div",{className:"bg-border h-[3px]"}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-12"})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]})]})]})},st))})})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-base font-medium text-foreground",children:"Order Categories"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:rt.map(st=>jsxRuntime.jsx(Card,{className:"overflow-hidden rounded-md rounded-b-lg border-0 shadow-md",children:jsxRuntime.jsxs(CardContent,{className:"p-0",children:[jsxRuntime.jsx("div",{className:`${st.stripeClass} h-[3px]`}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-base",children:st.name}),jsxRuntime.jsx("div",{className:`${st.iconBgClass} p-2 rounded-full`,children:jsxRuntime.jsx(st.icon,{className:`size-4 shrink-0 ${st.iconTextClass}`})})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Orders"}),jsxRuntime.jsx("p",{className:"text-xl font-bold",children:st.orders})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Amount"}),jsxRuntime.jsx("p",{className:"text-base font-semibold",children:jsxRuntime.jsx(FormattedNumber,{value:st.amount,style:"currency",currency:"CAD",currencyDisplay:"symbol"})})]})]})]})]})},st.name))})})]})}function ReportsSection({isLoading:e,userEmail:t,appID:n}){const{toast:s}=useToast(),[a,{isLoading:o}]=usePostV4ResellerByRouteResellerIdReportWalmartTrackingFileEmailMutation(),[l,{isLoading:c}]=usePostV4ResellerByRouteResellerIdReportAmazonTrackingFileEmailMutation(),[d,{isLoading:f}]=usePostV4ResellerByRouteResellerIdReportOpenOrdersEmailMutation(),[R,{isLoading:S}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[te,{isLoading:A}]=usePostV4ResellerByRouteResellerIdReportInvoicesEmailMutation(),[rt,{isLoading:st}]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),[it,at]=React.useState(null),[ot,lt]=React.useState(t),[ut,ct]=React.useState(!1),[dt,pt]=React.useState("all"),{data:mt,isLoading:Rt}=useGetV4PartnerByRouteApplicationIdManufacturersQuery({routeApplicationId:n,withSpecification:!1}),yt=[{name:"Products",reports:[{id:"Products",title:"Universal Product List",description:"A comprehensive overview of your product list with detailed specifications and pricing information.",icon:Package}]},{name:"Operation Details",reports:[{id:"OpenOrders",title:"Order Details",description:"A detailed report of all your orders and shipments, including status, tracking information, and delivery estimates.",icon:ShoppingCart},{id:"Invoices",title:"Invoices and Credits Report",description:"Detailed overview of your invoices and credits within a specific date range. It also contains reports about additional charges, serial numbers, and other relevant information.",icon:ScrollText},{id:"Statement",title:"Statement and RMAs Report",description:"A detailed report of all unpaid invoices and active RMAs.",icon:Banknote}]},{name:"Tracking Files",reports:[{id:"AmazonTrackingFile",title:"Amazon Tracking File",description:"Track products sold on Amazon marketplace with detailed sales and inventory information.",icon:ChartNoAxesColumnIncreasing},{id:"WalmartTrackingFile",title:"Walmart Tracking File",description:"Track products sold on Walmart marketplace with detailed sales and inventory information.",icon:ChartNoAxesColumnIncreasing}]}],It=async Mt=>{at(Mt),Mt.id==="Products"&&pt("all"),ct(!0)},ft=async()=>{if(!(!it||!n))try{switch(it.id){case"Products":{const Mt={routeResellerId:n,emailAddress:ot};dt&&dt!=="all"&&(Mt.manufacturerId=dt),await R(Mt).unwrap();break}case"AmazonTrackingFile":await l({routeResellerId:n,emailAddress:ot}).unwrap();break;case"WalmartTrackingFile":await a({routeResellerId:n,emailAddress:ot}).unwrap();break;case"OpenOrders":await d({routeResellerId:n,emailAddress:ot}).unwrap();break;case"Invoices":await te({routeResellerId:n,emailAddress:ot}).unwrap();break;case"Statement":await rt({routeResellerId:n,emailAddress:ot}).unwrap();break;default:throw new Error("invalid report id")}s({title:"Report requested",description:`The ${it.title} will be sent to ${ot} shortly.`,variant:"success"}),ct(!1)}catch(Mt){console.error("Error requesting report:",Mt),s({title:"Error",description:"Failed to request report. Please try again.",variant:"destructive"})}},Ct=f||S||c||o||st||A;return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Reports"}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Download essential business reports, from your Product List to your Order Details."})]}),jsxRuntime.jsx(CardContent,{className:"space-y-6",children:e?jsxRuntime.jsx(jsxRuntime.Fragment,{children:[1,2,3].map(Mt=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-48"}),[1,2].map(Dt=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"})]}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"})]},Dt))]},Mt))}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:yt.map(Mt=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:Mt.name}),Mt.reports.map(Dt=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg hover:bg-muted transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-2 rounded-full",children:jsxRuntime.jsx(Dt.icon,{className:"h-5 w-5 text-primary"})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("h4",{className:"font-semibold text-sm",children:Dt.title}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:Dt.description})]}),jsxRuntime.jsxs(Button$1,{variant:"outline",size:"sm",className:"flex items-center gap-1",onClick:()=>It(Dt),children:[jsxRuntime.jsx(Download,{className:"h-4 w-4"}),"Request"]})]},Dt.id))]},Mt.name))})}),jsxRuntime.jsx(Dialog,{open:ut,onOpenChange:ct,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsxs(DialogTitle,{children:["Request ",it?.title]}),jsxRuntime.jsx(DialogDescription,{children:"Enter the email address where you would like to receive the report."})]}),jsxRuntime.jsxs("div",{className:"py-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",value:ot,onChange:Mt=>lt(Mt.target.value),placeholder:"your@email.com",className:"mt-2"})]}),it?.id==="Products"&&jsxRuntime.jsxs("div",{className:"py-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"manufacturer",children:"Manufacturer"}),jsxRuntime.jsxs("select",{id:"manufacturer",className:"mt-2 block w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:dt,onChange:Mt=>pt(Mt.target.value),disabled:Rt,children:[jsxRuntime.jsx("option",{value:"all",children:"All manufacturers"}),!Rt&&Array.isArray(mt)&&mt.slice().sort((Mt,Dt)=>(Mt.PublicName||Mt.Name||"").localeCompare(Dt.PublicName||Dt.Name||"")).map(Mt=>Mt?.ManufacturerId?jsxRuntime.jsx("option",{value:Mt.ManufacturerId,children:(Mt.PublicName||Mt.Name||Mt.ManufacturerId)+(Mt.OpenToWork?" (Open to Work)":"")},Mt.ManufacturerId):null)]})]}),jsxRuntime.jsx(DialogDescription,{children:"The report will take around 5 minutes to generate."}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>ct(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:ft,disabled:!ot||Ct,children:Ct?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}function QualificationBadge({qualification:e}){return!e.QualificationId||e.QualificationId==="Suspended"?null:e.QualificationId==="Do Not Sell"?jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs(Badge,{variant:"destructive",children:[jsxRuntime.jsx(X$2,{className:"h-3 w-3 mr-1"}),"Do Not Sell"]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})}):jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs(Badge,{variant:"info",className:e.DefaultOpportunityNumber?"pr-1":"",children:[jsxRuntime.jsx(BadgeCheck,{className:"h-3 w-3 mr-1"}),e.QualificationId,e.DefaultOpportunityNumber&&jsxRuntime.jsx(Badge,{variant:"secondary",size:"sm",className:"ml-1",children:e.DefaultOpportunityNumber})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})})}function SalesChart({statistics:e,mode:t="month",chartHeight:n,loading:s=!1,size:a="default"}){const[o,l]=React.useState([]),[c,d]=React.useState(!1),f=[{name:"dollarVolume",label:"Dollar Volume",color:"var(--primary)",dotClassName:"bg-primary",yAxisId:"left",format:"money"},{name:"unitsSold",label:"Units Sold",color:"var(--chart-2)",dotClassName:"bg-chart-2",units:" units",yAxisId:"right",format:"integer"}];return React.useEffect(()=>{if(s||!e){l([]);return}let R=[];if(t==="week"){const S=new Map;e.forEach(te=>{const A=te.Day?.toString()||"";if(A.length===8){const rt=parseInt(A.substring(0,4),10),st=parseInt(A.substring(4,6),10)-1,it=parseInt(A.substring(6,8),10),at=new Date(rt,st,it),ot=new Date(at);ot.setDate(at.getDate()-at.getDay());const lt=`${ot.getFullYear()}-${String(ot.getMonth()+1).padStart(2,"0")}-${String(ot.getDate()).padStart(2,"0")}`,ut=S.get(lt)||{price:0,quantity:0};ut.price+=te.ExtendedPrice||0,ut.quantity+=te.Quantity||0,S.set(lt,ut)}}),R=Array.from(S).sort(([te],[A])=>te.localeCompare(A)).map(([te,A])=>({date:`${te.substring(5,7)}/${te.substring(8,10)}`,dollarVolume:A.price,unitsSold:A.quantity}))}else{const S=new Date,te=S.getFullYear(),A=S.getMonth(),rt=S.getDate(),st=`${te}-${(A+1).toString().padStart(2,"0")}`,it=Array.from({length:12},(ot,lt)=>{const ut=new Date(te,A-(11-lt),1);return`${ut.getFullYear()}-${(ut.getMonth()+1).toString().padStart(2,"0")}`}),at=Object.fromEntries(it.map(ot=>[ot,{price:0,quantity:0}]));if(e.forEach(ot=>{const lt=String(ot.Day??0);if(lt.length!==8)return;const ut=`${lt.substring(0,4)}-${lt.substring(4,6)}`;at[ut]&&(at[ut].price+=ot.ExtendedPrice??0,at[ut].quantity+=ot.Quantity??0)}),R=it.map(ot=>{const lt=at[ot],[ut,ct]=ot.split("-").map(Number);return{date:new Date(ut,ct-1).toLocaleString("default",{month:"short",year:"numeric"}),dollarVolume:lt.price,unitsSold:lt.quantity}}),c){const ot=at[st];if(ot&&ot.price>0&&rt>0){const lt=new Date(te,A+1,0).getDate();if(rt<lt){const ut=ot.price/rt,ct=ot.quantity/rt,dt=ut*lt,pt=ct*lt,mt=R[R.length-1];mt&&(mt.dollarVolume=dt,mt.unitsSold=pt)}}}}l(R)},[e,t,c,s]),s?jsxRuntime.jsx("div",{style:{height:n},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}):o.length===0?jsxRuntime.jsx("div",{style:{height:n},className:"flex items-center justify-center text-muted-foreground",children:"No sales data available."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(AreaChart,{data:o,series:f,height:n,size:a}),a==="default"&&t==="month"&&jsxRuntime.jsxs("div",{className:"mt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{checked:c,onCheckedChange:d,id:"extrapolate-switch"}),jsxRuntime.jsx(Label$2,{htmlFor:"extrapolate-switch",children:"Extrapolate Current Month"})]}),c&&jsxRuntime.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["* Values for ",new Date().toLocaleString("default",{month:"long"})," are projected estimates."]})]})]})}function PartnerCardHeader({type:e,applicationId:t,publicName:n,name:s,location:a,link:o,linkNewTab:l=!0,children:c}){const[d,f]=React.useState(!1),R=te=>{te.preventDefault(),te.stopPropagation(),navigator.clipboard.writeText(t),f(!0),setTimeout(()=>f(!1),2e3)},S=jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx(PartnerLogo,{id:t,width:48,height:48},`partner_logo_${t}`)}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:e}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{delayDuration:300,children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex cursor-pointer items-center gap-1",onClick:R,children:[jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:t}),d?jsxRuntime.jsx(Check,{className:"h-3 w-3 text-success"}):jsxRuntime.jsx(Copy,{className:"h-3 w-3 text-muted-foreground"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:d?"Copied!":"Copy ID"})})]})})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:n||"N/A"}),s&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:s}),a&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:a})]})]}),c&&jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:c})]});return o?jsxRuntime.jsx(reactRouterDom.Link,{to:o,target:l?"_blank":"_self",children:S}):S}function ManufacturerCard({manufacturer:e,link:t,linkNewTab:n=!0,actions:s,mainAction:a,loading:o=!1,appID:l}){const{toast:c}=useToast(),[d,{isLoading:f}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[R,S]=React.useState(!1),[te,A]=React.useState(""),{data:rt}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:l||""},{skip:!l}),st=rt?.IsReseller;if(o||!e)return jsxRuntime.jsxs(Card,{className:"flex flex-col h-full",children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-24 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"})]})]}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-24"})]}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex flex-col space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-14 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-36"})]})]})]})}),jsxRuntime.jsxs(CardFooter,{className:"flex justify-between pt-2 gap-2 mt-auto",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-40"})]})]});const it=[e.City,e.Province,e.Country].filter(Boolean),at=it.length>0?it.join(", "):"",ot=e.Tags?.split(",").map(ut=>ut.trim()).filter(Boolean)||[],lt=async()=>{if(!(!e?.ManufacturerId||!l||!te))try{await d({routeResellerId:l,emailAddress:te,manufacturerId:e.ManufacturerId}).unwrap(),c({title:"Report requested",description:`The Universal Product List for this manufacturer will be sent to ${te} shortly.`,variant:"success"}),S(!1)}catch(ut){console.error("Error requesting product list:",ut),c({title:"Error",description:"Failed to request product list. Please try again.",variant:"destructive"})}};return jsxRuntime.jsxs(Card,{className:"flex flex-col h-full",children:[jsxRuntime.jsx(PartnerCardHeader,{type:"Manufacturer",applicationId:e.ManufacturerId,publicName:e.PublicName,name:e.Name,location:at,link:t,linkNewTab:n,children:jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:e.SalesStatistics&&e.SalesStatistics.length>0&&jsxRuntime.jsx("div",{className:"h-16 w-24",children:jsxRuntime.jsx(SalesChart,{statistics:e.SalesStatistics,size:"mini"})})})}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex",children:[jsxRuntime.jsxs("div",{className:"flex flex-col flex-1 space-y-2",children:[(!!e.Qualification?.QualificationId&&e.Qualification?.QualificationId!=="Suspended"||!!e.OpenToWork||!!e.OnHold&&e.OnHold!==0||ot.length>0)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(QualificationBadge,{qualification:e.Qualification??{}}),!!e.OpenToWork&&jsxRuntime.jsxs(Badge,{variant:"success",children:[jsxRuntime.jsx(HardHat,{className:"h-3 w-3 mr-1"}),"Open To Work"]}),!!e.OnHold&&e.OnHold!==0&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"}),ot.map((ut,ct)=>jsxRuntime.jsx(Badge,{variant:"outline",children:ut},ct))]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[e.Phone&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`tel:${e.Phone}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Phone,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Phone})]}),e.PublicEmail&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`mailto:${e.PublicEmail}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.PublicEmail})]}),e.Website&&jsxRuntime.jsxs(reactRouterDom.Link,{to:e.Website,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Globe,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Website})]}),e.CurrencyCode&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(DollarSign,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.CurrencyCode})]})]})]}),e.SalesData&&jsxRuntime.jsxs("div",{className:"border-l pl-2 ml-2 flex flex-col text-sm",children:[jsxRuntime.jsx("strong",{className:"",children:"YTD"}),jsxRuntime.jsx("p",{children:e.SalesData.SalesYearToDay?formatMoney(e.SalesData.SalesYearToDay):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"3 mo."}),jsxRuntime.jsx("p",{children:e.SalesData.SalesLast3Months?formatMoney(e.SalesData.SalesLast3Months):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"30 days"}),jsxRuntime.jsx("p",{children:e.SalesData.SalesLast30Days?formatMoney(e.SalesData.SalesLast30Days):"—"})]})]})}),(s||a||e.PublicResourcesLink||st&&l&&e.ManufacturerId||t)&&jsxRuntime.jsxs(CardFooter,{className:"flex pt-2 gap-2 justify-between mt-auto",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[s&&s,st&&l&&e.ManufacturerId&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{size:"icon",onClick:()=>S(!0),disabled:f,children:f?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Email Product List"})})]})}),e.PublicResourcesLink&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:e.PublicResourcesLink,target:"_blank",children:jsxRuntime.jsx(Button$1,{size:"icon",children:jsxRuntime.jsx(BookOpen,{className:"h-4 w-4"})})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Public Resources Link"})})]})})]}),a&&jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:jsxRuntime.jsx("div",{children:a})})]}),jsxRuntime.jsx(Dialog,{open:R,onOpenChange:S,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Request Universal Product List"}),jsxRuntime.jsx(DialogDescription,{children:"Enter the email address where you would like to receive the report."})]}),jsxRuntime.jsxs("div",{className:"py-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",value:te,onChange:ut=>A(ut.target.value),placeholder:"your@email.com",className:"mt-2"})]}),jsxRuntime.jsx(DialogDescription,{children:"The report will take around 5 minutes to generate."}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>S(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:lt,disabled:!te||f,children:f?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}function ProductInventoryButton({applicationId:e,randmarSku:t,inventory:n,buttonSize:s="default",buttonClassName:a}){const o=React.useRef(null),l=useIntersectionObserver({elementRef:o,threshold:.1,rootMargin:"100px",freezeOnceVisible:!0}),{toast:c}=useToast(),[d,f]=React.useState(!1),[R,S]=React.useState(!1),[te,A]=React.useState(!1),{data:rt,isLoading:st,isFetching:it}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:e},{skip:!e||!l}),{data:at,isLoading:ot,isFetching:lt}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:e,randmarSku:t,withSpecification:!1},{skip:!!n||!l}),[ut]=usePutV4ResellerByRouteResellerIdProductAndRandmarSkuRequisitionMutation(),ct=n??at?.Distribution?.Inventory;React.useEffect(()=>{f(!1)},[t]);const{inventoryQuantity:dt,totalIncomingQuantity:pt}=React.useMemo(()=>{if(!ct||ct.length===0)return{inventoryQuantity:0,totalIncomingQuantity:0};const It=ct.reduce((Ct,Mt)=>Ct+(Mt.AvailableQuantity||0),0),ft=ct.reduce((Ct,Mt)=>Ct+(Mt.PurchaseOrderQuantity||0),0);return{inventoryQuantity:It,totalIncomingQuantity:ft}},[ct]);if(st||it||ot||lt)return jsxRuntime.jsx("div",{ref:o,children:jsxRuntime.jsx(Skeleton,{className:cn("h-10 w-36 rounded-md",a)})});const Rt=()=>{te||!rt?.IsReseller||(A(!0),ut({routeResellerId:e??"",randmarSku:t??""}).then(It=>{It.error||It.data===!1?c({title:"Warning",description:"Reorder is pending or requires manual approval. Contact the Randmar team for details.",variant:"warning"}):c({title:"Success",description:"Qualification successfully submitted.",variant:"success"}),S(!1)}).catch(It=>{console.error(It),c({title:"Error",description:"Error submitting your qualification.",variant:"destructive"})}).finally(()=>{A(!1)}))};if(!ct)return jsxRuntime.jsx("div",{ref:o,children:jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("span",{tabIndex:0,children:jsxRuntime.jsxs(Button$1,{disabled:!0,size:s,variant:"outline",className:cn("text-sm",a),children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),"No data"]})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"No inventory data could be found for this product."})})]})})});if(rt?.IsReseller&&dt<=0&&pt<=0)return jsxRuntime.jsx("div",{ref:o,children:jsxRuntime.jsxs(Dialog,{open:R,onOpenChange:S,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:s,className:cn("text-sm text-primary",a),children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),"Request to stock"]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-md",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Request to stock"})}),jsxRuntime.jsx("p",{className:"py-4",children:"Are you sure you want to request this product to be stocked?"}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>S(!1),disabled:te,children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:Rt,disabled:te,children:te?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin mr-2"}),"Requesting..."]}):"Confirm"})]})]})]})});const yt=dt<=0&&pt>0;return jsxRuntime.jsx("div",{ref:o,children:jsxRuntime.jsxs(Dialog,{open:d,onOpenChange:f,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:s,className:cn("text-sm",yt?"text-info":dt>0?"text-success":"text-destructive",a),children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),yt?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(pt)," Incoming"]}):dt>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(dt)," in stock"]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Out of stock"})]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-4xl",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsxs(DialogTitle,{className:"flex items-center",children:[jsxRuntime.jsx(Warehouse,{className:"mr-2",size:18}),"Inventory Information"]})}),jsxRuntime.jsx(ProductInventoryGrid,{inventory:ct})]})]})})}function OrdersCard({applicationId:e,orders:t=null,loading:n=!1,title:s="Order Details"}){const a=React.useMemo(()=>[{accessorKey:"OrderNumber",header:"Order Number",cell:({row:c})=>c.original.OrderNumber?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/GeneralDocument/${c.original.OrderNumber}`,className:"font-medium text-primary hover:underline",children:c.original.OrderNumber})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for order ",c.original.OrderNumber]})})]})}):"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentNumber",header:"Document Number",cell:({row:c})=>c.original.DocumentNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentDate",header:"Document Date",cell:({row:c})=>formatYYYYMMDDIntToDateString(c.original.DocumentDate),enableSorting:!0,enableFiltering:!1},{accessorKey:"PONumber",header:"PO Number",cell:({row:c})=>c.original.PONumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseCode",header:"Warehouse",cell:({row:c})=>c.original.WarehouseCode??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"MPN",header:"MPN",cell:({row:c})=>c.original.MPN?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Product/${c.original.MPN}`,className:"font-medium text-primary hover:underline",children:c.original.MPN})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for MPN ",c.original.MPN]})})]})}):"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:c})=>c.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!1},{accessorKey:"ShipToName",header:"Name",cell:({row:c})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:c.original.ShipToName??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:c})=>c.original.UnitPrice?formatMoney(c.original.UnitPrice):"N/A",enableSorting:!0,enableFiltering:!1},{id:"actions",header:"Actions",cell:({row:c})=>jsxRuntime.jsx("div",{className:"flex space-x-2",children:jsxRuntime.jsx(ProductInventoryButton,{applicationId:e,randmarSku:c.original.RandmarSKU??"",buttonSize:"sm"})})}],[e]),o=React.useMemo(()=>{const c={};if(t){const d=Array.from(new Set(t.map(rt=>rt.WarehouseCode).filter(rt=>rt!=null)));c.WarehouseCode=d;const f=Array.from(new Set(t.map(rt=>rt.ShipToName).filter(rt=>rt!=null)));c.ShipToName=f;const R=Array.from(new Set(t.map(rt=>rt.DocumentNumber).filter(rt=>rt!=null)));c.DocumentNumber=R;const S=Array.from(new Set(t.map(rt=>rt.OrderNumber).filter(rt=>rt!=null)));c.OrderNumber=S;const te=Array.from(new Set(t.map(rt=>rt.PONumber).filter(rt=>rt!=null)));c.PONumber=te;const A=Array.from(new Set(t.map(rt=>rt.MPN).filter(rt=>rt!=null)));c.MPN=A}return c},[t]),l=t||[];return n?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:s})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:a,data:l,uniqueValues:o})})]})}function ResellerOverview({appID:e,reseller:t,readonly:n,userEmail:s,isSuperAdmin:a,withoutReports:o=!1,loadFullAfterSummary:l=!1}){const c=`${e}|${l?1:0}`,d=React.useRef(c),[f,R]=React.useState(()=>l?!!t:!1);React.useEffect(()=>{d.current!==c&&(d.current=c,R(!1))},[c]),React.useEffect(()=>{l&&t&&R(!0)},[l,t]);const S=l?f:!t,{data:te,isLoading:A,isError:rt}=useGetV4PartnerByApplicationIdAccountResellerQuery({applicationId:e??"",withSpecification:!0},{skip:!e||!S}),[st,it]=React.useState({publicInfo:{hasUnsavedChanges:!1}}),at=React.useCallback(()=>n?!1:st.publicInfo.hasUnsavedChanges,[n,st]),ot=React.useCallback((yt,It)=>{it(ft=>ft[yt]?.hasUnsavedChanges!==It.hasUnsavedChanges?{...ft,[yt]:It}:ft)},[]),{NavigationGuardDialog:lt}=useRouterNavigationGuard(at),ut=te??t,ct=A&&!ut,dt=rt&&!ut,pt=!n||!!ut?.Statement&&(ut.Statement.Total??0)>0,mt=ut?.QualifiedManufacturers??[],Rt=ut?.Qualifications??[];return jsxRuntime.jsxs("div",{className:"@container",children:[dt?jsxRuntime.jsx(Card,{className:"p-6",children:jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Error"}),jsxRuntime.jsx(AlertDescription,{children:"There was an error loading your reseller information. Please try again later."})]})}):jsxRuntime.jsxs("div",{className:"space-y-6 mb-6",children:[jsxRuntime.jsx(SalesSummary,{fiscalYearMonthStart:ut?.FiscalYearMonthStart||1,salesData:ut?.SalesData,isLoading:ct}),jsxRuntime.jsxs("div",{className:"grid @lg:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:ut?.SalesStatistics??[],loading:ct}),jsxRuntime.jsx(OrderCategories,{openOrders:ut?.ActiveOrderDetails??[],isLoading:ct}),pt&&jsxRuntime.jsx(BillingCard,{appID:e,reseller:ut||{},withoutReports:o,isLoading:ct,userEmail:s,isSuperAdmin:a}),jsxRuntime.jsx(PublicInfo,{reseller:ut||{},appID:e??"",isLoading:ct,readonly:n,onUnsavedChanges:yt=>ot("publicInfo",{hasUnsavedChanges:yt})}),jsxRuntime.jsx(AccountTier,{isSuperAdmin:a,readonly:n,reseller:ut||{},appID:e??"",isLoading:ct})]}),ct||mt.length>0?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Manufacturers you are qualified for"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid @lg:grid-cols-2 gap-4",children:ct?Array.from({length:2}).map((yt,It)=>jsxRuntime.jsx(ManufacturerCard,{loading:!0},It)):mt.map(yt=>jsxRuntime.jsx(ManufacturerCard,{manufacturer:yt,link:`https://dashboard.randmar.io/${e}/Partner/${yt.ManufacturerId}`},yt.ManufacturerId))})})]}):Rt.length>0&&jsxRuntime.jsx(ResellerQualificationsCard,{qualifications:Rt}),(ut?.Opportunities?.length??0)>0&&jsxRuntime.jsx(OpportunitiesTable,{applicationId:e,opportunities:ut?.Opportunities,loading:ct}),(ut?.ActiveOrderDetails?.length??0)>0&&jsxRuntime.jsx(OrdersCard,{applicationId:e,title:"Active Orders",orders:ut?.ActiveOrderDetails,loading:ct}),(ut?.CompletedOrderDetails?.length??0)>0&&jsxRuntime.jsx(OrdersCard,{applicationId:e,title:"Completed Orders",orders:ut?.CompletedOrderDetails,loading:ct}),(ut?.Returns?.length??0)>0&&jsxRuntime.jsx(ReturnsTable,{applicationId:e,returns:ut?.Returns,loading:ct}),!o&&jsxRuntime.jsx(ReportsSection,{appID:e,userEmail:s,isLoading:ct})]}),jsxRuntime.jsx(lt,{})]})}const alertVariants=cva("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 bg-destructive/10 text-foreground [&>svg]:text-destructive",success:"border-success/50 bg-success/10 text-foreground [&>svg]:text-success",warning:"border-warning/50 bg-warning/10 text-foreground [&>svg]:text-warning",info:"border-info/50 bg-info/10 text-foreground [&>svg]:text-info"}},defaultVariants:{variant:"default"}}),Alert=React__namespace.forwardRef(({className:e,variant:t,...n},s)=>jsxRuntime.jsx("div",{ref:s,role:"alert",className:cn(alertVariants({variant:t}),e),...n}));Alert.displayName="Alert";const AlertTitle=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("h5",{ref:n,className:cn("mb-1 font-medium leading-none tracking-tight",e),...t}));AlertTitle.displayName="AlertTitle";const AlertDescription=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("text-sm [&_p]:leading-relaxed",e),...t}));AlertDescription.displayName="AlertDescription";function functionalUpdate(e,t){return typeof e=="function"?e(t):e}function makeStateUpdater(e,t){return n=>{t.setState(s=>({...s,[e]:functionalUpdate(n,s[e])}))}}function isFunction$2(e){return e instanceof Function}function isNumberArray(e){return Array.isArray(e)&&e.every(t=>typeof t=="number")}function flattenBy(e,t){const n=[],s=a=>{a.forEach(o=>{n.push(o);const l=t(o);l!=null&&l.length&&s(l)})};return s(e),n}function memo(e,t,n){let s=[],a;return o=>{let l;n.key&&n.debug&&(l=Date.now());const c=e(o);if(!(c.length!==s.length||c.some((R,S)=>s[S]!==R)))return a;s=c;let f;if(n.key&&n.debug&&(f=Date.now()),a=t(...c),n==null||n.onChange==null||n.onChange(a),n.key&&n.debug&&n!=null&&n.debug()){const R=Math.round((Date.now()-l)*100)/100,S=Math.round((Date.now()-f)*100)/100,te=S/16,A=(rt,st)=>{for(rt=String(rt);rt.length<st;)rt=" "+rt;return rt};console.info(`%c⏱ ${A(S,5)} /${A(R,5)} ms`,`
|
|
487
|
+
$10 with opportunities under $1,000`:e==="D"?"$15 under $1,500":e==="E"?"Full shipping charges":e,getTermsText=e=>e==="STRIPE"?"Credit card payment":e==="NET30"?"Net 30 days":e,AccountTier=({isSuperAdmin:e,readonly:t,reseller:n,appID:s,isLoading:a})=>{const{toast:o}=useToast(),[l,c]=React.useState(!1),[d,f]=React.useState(""),[R,{isLoading:S}]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),te=Dt=>Dt&&{Starter:"starter","E-Commerce":"ecommerce",Commercial:"commercial",Basics:"cws",Novexco:"novexco",COOPSCO:"coopsco","Jean Coutu":"jeancoutu",Exclusive:"exclusive"}[Dt]||"",A=Dt=>Dt&&{A:"free",B:"fixed",C:"dropshipped",D:"under1500",E:"fullcharges"}[Dt]||"",rt=Dt=>Dt&&{1:"exclusive",2:"ecommerce",3:"commercial",4:"buyinggroup",5:"cost"}[Dt]||"",[st,it]=React.useState(te(n?.Priority??"")),[at,ot]=React.useState(A(n?.ShippingProfile??"")),[lt,ut]=React.useState(rt(n?.PriceProfile)),ct=Dt=>({starter:"Starter",ecommerce:"E-Commerce",commercial:"Commercial",cws:"Basics",novexco:"Novexco",coopsco:"COOPSCO",jeancoutu:"Jean Coutu",exclusive:"Exclusive"})[Dt]||Dt,dt=Dt=>({free:"A",fixed:"B",dropshipped:"C",under1500:"D",fullcharges:"E"})[Dt]||Dt,pt=Dt=>({exclusive:"1",ecommerce:"2",commercial:"3",buyinggroup:"4",cost:"5"})[Dt]||Dt;React.useEffect(()=>{it(te(n?.Priority??"")),ot(A(n?.ShippingProfile??"")),ut(rt(n?.PriceProfile))},[n]);const mt=async(Dt,Vt,Wt,$t)=>{try{(await R({applicationId:s,fieldName:Dt,newValue:Vt})).error?o({title:"Error",description:$t,variant:"destructive"}):o({title:"Success",description:Wt,variant:"success"})}catch{o({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}},Rt=async Dt=>{it(Dt);const Vt=ct(Dt);mt("Priority",Vt,`Priority updated to ${Vt}`,"Failed to update priority")},yt=async Dt=>{ot(Dt);const Vt=dt(Dt);mt("ShippingProfile",Vt,`Shipping profile updated to ${Vt}`,"Failed to update shipping profile")},It=async Dt=>{ut(Dt);const Vt=pt(Dt);mt("PriceProfile",Vt,`Pricing profile updated to ${Vt}`,"Failed to update pricing profile")},ft=async()=>{try{const Dt=await R({applicationId:s,fieldName:"Tier",newValue:d});Dt.error?o({title:"Error",description:"Failed to update reseller",variant:"destructive"}):Dt.data?o({title:"Success",description:`Pricing Tier changed to ${d}`,variant:"success"}):o({title:"Considered",description:"Request being considered",variant:"success"})}catch{o({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}finally{c(!1),f("")}},Ct=[{name:"Terms",enabled:n.Priority==="Starter"},{name:"E-Commerce",enabled:n.Priority==="Commercial"},{name:"Commercial",enabled:n.Priority==="E-Commerce"},{name:"Exclusive",enabled:e}],Mt=Dt=>{f(Dt),c(!0)};return a?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"pb-2",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-28"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-16 rounded-full"})]})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-56"})]}),jsxRuntime.jsx("div",{className:"grid gap-3",children:[1,2,3].map(Dt=>jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"})]})]},Dt))}),jsxRuntime.jsxs("div",{className:"flex gap-2 mt-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{className:"pb-2 pt-4 px-4 flex flex-row items-center justify-between",children:[jsxRuntime.jsx(CardTitle,{className:"text-base font-medium text-foreground",children:"Account Tier"}),jsxRuntime.jsx(Badge,{variant:"success",className:"text-xs",children:"Active"})]}),jsxRuntime.jsxs(CardContent,{className:"pt-2 px-4 pb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-3 bg-primary/5 p-4 rounded-lg",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("h3",{className:"text-lg font-bold text-primary",children:[n?.Priority||""," Tier"]}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Optimized for online retail"})]}),jsxRuntime.jsx(CircleCheck,{className:"h-6 w-6 text-success"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-2 mb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Package2,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Pricing"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground truncate",children:getPricingText(n.PriceProfile||0)})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Truck,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Shipping"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getShippingText(n.ShippingProfile||"").split(".")[0]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Calendar$1,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Payment terms"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getTermsText(n?.Terms||"")})]})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[!t&&jsxRuntime.jsx(Button$1,{variant:"outline",className:"flex-1",asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:"https://randmar.io/pricing",target:"_blank",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4 mr-1"}),"Pricing Tiers"]})}),jsxRuntime.jsxs(Popover,{children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{disabled:t,className:t?"hidden":"flex-1",children:["Upgrade Tier ",jsxRuntime.jsx(ChevronRight,{className:"h-3 w-3 ml-1"})]})}),jsxRuntime.jsx(PopoverContent,{className:"w-56 p-2",children:jsxRuntime.jsxs("div",{className:"grid gap-1",children:[jsxRuntime.jsx("h4",{className:"font-medium text-xs mb-1",children:"Select a tier"}),Ct.map(Dt=>jsxRuntime.jsx(Button$1,{variant:"ghost",size:"sm",className:"w-full justify-start h-8",disabled:!Dt.enabled,onClick:()=>Mt(Dt.name),children:Dt.name},Dt.name))]})})]})]})]})]}),jsxRuntime.jsx(ChangePricingTierModal,{isLoading:S,open:l,setOpen:c,tier:d,onTierChange:ft}),e&&!t&&jsxRuntime.jsxs(Card,{className:"mt-4",children:[jsxRuntime.jsx(CardHeader,{className:"pb-2 pt-3 px-4",children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Admin Configuration"})}),jsxRuntime.jsx(CardContent,{className:"pt-2 px-4 pb-4",children:jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Priority"}),jsxRuntime.jsx(RadioGroup$1,{value:st,onValueChange:Rt,className:"grid grid-cols-2 @sm:grid-cols-3 @md:grid-cols-4 gap-1",children:[{value:"starter",label:"Starter"},{value:"ecommerce",label:"E-Commerce"},{value:"commercial",label:"Commercial"},{value:"cws",label:"CWS (Basics)"},{value:"novexco",label:"Novexco"},{value:"coopsco",label:"COOPSCO"},{value:"jeancoutu",label:"Jean Coutu"},{value:"exclusive",label:"Exclusive"}].map(Dt=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Dt.value,id:`priority-${Dt.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`priority-${Dt.value}`,className:"cursor-pointer text-xs",children:Dt.label})]},Dt.value))})]}),jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Shipping Profile"}),jsxRuntime.jsx(RadioGroup$1,{value:at,onValueChange:yt,className:"grid grid-cols-1 @md:grid-cols-2 gap-1",children:[{value:"free",label:"Free (A)"},{value:"fixed",label:"Fixed $10 Shipping (B)"},{value:"dropshipped",label:"$15 for drop shipped (C)"},{value:"under1500",label:"15$ under 1,500 (D)"},{value:"fullcharges",label:"Full shipping charges (E)"}].map(Dt=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Dt.value,id:`shipping-${Dt.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`shipping-${Dt.value}`,className:"cursor-pointer text-xs",children:Dt.label})]},Dt.value))})]}),jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Pricing Profile"}),jsxRuntime.jsx(RadioGroup$1,{value:lt,onValueChange:It,className:"grid grid-cols-2 @sm:grid-cols-3 gap-1",children:[{value:"exclusive",label:"Exclusive (1)"},{value:"ecommerce",label:"E-Commerce (2)"},{value:"commercial",label:"Commercial (3)"},{value:"buyinggroup",label:"Buying Group (4)"},{value:"cost",label:"Cost (5)"}].map(Dt=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Dt.value,id:`pricing-${Dt.value}`,className:"h-6 w-6 scale-50 antialiased"}),jsxRuntime.jsx(Label$2,{htmlFor:`pricing-${Dt.value}`,className:"cursor-pointer text-xs",children:Dt.label})]},Dt.value))})]})]})})]})]})};function OrderCategories({openOrders:e=[],isLoading:t=!1}){const n=e?.filter(st=>st.DocumentType==="Order")||[],s=e?.filter(st=>st.DocumentType==="Shipment")||[],a=n.filter(st=>st.WarehouseCode!=="3PLE"),o=a.reduce((st,it)=>st+(it.Quantity??0),0),l=a.reduce((st,it)=>st+(it.ExtendedPrice??0),0),c=n.filter(st=>st.WarehouseCode==="3PLE"),d=c.reduce((st,it)=>st+(it.Quantity??0),0),f=c.reduce((st,it)=>st+(it.ExtendedPrice??0),0),R=s.reduce((st,it)=>st+(it.Quantity??0),0),S=s.reduce((st,it)=>st+(it.ExtendedPrice??0),0),te=o+d+R,A=l+f+S,rt=[{name:"All",icon:Package,stripeClass:"bg-info/60",iconBgClass:"bg-info/90",iconTextClass:"text-info-foreground",orders:te,amount:A},{name:"Processing",icon:RefreshCcw,stripeClass:"bg-warning/60",iconBgClass:"bg-warning/90",iconTextClass:"text-warning-foreground",orders:o,amount:l},{name:"Shipped",icon:Truck,stripeClass:"bg-success/60",iconBgClass:"bg-success/90",iconTextClass:"text-success-foreground",orders:R,amount:S},{name:"Delayed",icon:CircleAlert,stripeClass:"bg-destructive/60",iconBgClass:"bg-destructive/90",iconTextClass:"text-destructive-foreground",orders:d,amount:f}];return t?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-40"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:[1,2,3,4].map(st=>jsxRuntime.jsx(Card,{className:"overflow-hidden rounded-md rounded-b-lg border-0 shadow-md",children:jsxRuntime.jsxs(CardContent,{className:"p-0",children:[jsxRuntime.jsx("div",{className:"bg-border h-[3px]"}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-12"})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]})]})]})},st))})})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-base font-medium text-foreground",children:"Order Categories"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:rt.map(st=>jsxRuntime.jsx(Card,{className:"overflow-hidden rounded-md rounded-b-lg border-0 shadow-md",children:jsxRuntime.jsxs(CardContent,{className:"p-0",children:[jsxRuntime.jsx("div",{className:`${st.stripeClass} h-[3px]`}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-base",children:st.name}),jsxRuntime.jsx("div",{className:`${st.iconBgClass} p-2 rounded-full`,children:jsxRuntime.jsx(st.icon,{className:`size-4 shrink-0 ${st.iconTextClass}`})})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Orders"}),jsxRuntime.jsx("p",{className:"text-xl font-bold",children:st.orders})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Amount"}),jsxRuntime.jsx("p",{className:"text-base font-semibold",children:jsxRuntime.jsx(FormattedNumber,{value:st.amount,style:"currency",currency:"CAD",currencyDisplay:"symbol"})})]})]})]})]})},st.name))})})]})}function ReportsSection({isLoading:e,userEmail:t,appID:n}){const{toast:s}=useToast(),[a,{isLoading:o}]=usePostV4ResellerByRouteResellerIdReportWalmartTrackingFileEmailMutation(),[l,{isLoading:c}]=usePostV4ResellerByRouteResellerIdReportAmazonTrackingFileEmailMutation(),[d,{isLoading:f}]=usePostV4ResellerByRouteResellerIdReportOpenOrdersEmailMutation(),[R,{isLoading:S}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[te,{isLoading:A}]=usePostV4ResellerByRouteResellerIdReportInvoicesEmailMutation(),[rt,{isLoading:st}]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),[it,at]=React.useState(null),[ot,lt]=React.useState(t),[ut,ct]=React.useState(!1),[dt,pt]=React.useState("all"),{data:mt,isLoading:Rt}=useGetV4PartnerByRouteApplicationIdManufacturersQuery({routeApplicationId:n,withSpecification:!1}),yt=[{name:"Products",reports:[{id:"Products",title:"Universal Product List",description:"A comprehensive overview of your product list with detailed specifications and pricing information.",icon:Package}]},{name:"Operation Details",reports:[{id:"OpenOrders",title:"Order Details",description:"A detailed report of all your orders and shipments, including status, tracking information, and delivery estimates.",icon:ShoppingCart},{id:"Invoices",title:"Invoices and Credits Report",description:"Detailed overview of your invoices and credits within a specific date range. It also contains reports about additional charges, serial numbers, and other relevant information.",icon:ScrollText},{id:"Statement",title:"Statement and RMAs Report",description:"A detailed report of all unpaid invoices and active RMAs.",icon:Banknote}]},{name:"Tracking Files",reports:[{id:"AmazonTrackingFile",title:"Amazon Tracking File",description:"Track products sold on Amazon marketplace with detailed sales and inventory information.",icon:ChartNoAxesColumnIncreasing},{id:"WalmartTrackingFile",title:"Walmart Tracking File",description:"Track products sold on Walmart marketplace with detailed sales and inventory information.",icon:ChartNoAxesColumnIncreasing}]}],It=async Mt=>{at(Mt),Mt.id==="Products"&&pt("all"),ct(!0)},ft=async()=>{if(!(!it||!n))try{switch(it.id){case"Products":{const Mt={routeResellerId:n,emailAddress:ot};dt&&dt!=="all"&&(Mt.manufacturerId=dt),await R(Mt).unwrap();break}case"AmazonTrackingFile":await l({routeResellerId:n,emailAddress:ot}).unwrap();break;case"WalmartTrackingFile":await a({routeResellerId:n,emailAddress:ot}).unwrap();break;case"OpenOrders":await d({routeResellerId:n,emailAddress:ot}).unwrap();break;case"Invoices":await te({routeResellerId:n,emailAddress:ot}).unwrap();break;case"Statement":await rt({routeResellerId:n,emailAddress:ot}).unwrap();break;default:throw new Error("invalid report id")}s({title:"Report requested",description:`The ${it.title} will be sent to ${ot} shortly.`,variant:"success"}),ct(!1)}catch(Mt){console.error("Error requesting report:",Mt),s({title:"Error",description:"Failed to request report. Please try again.",variant:"destructive"})}},Ct=f||S||c||o||st||A;return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Reports"}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Download essential business reports, from your Product List to your Order Details."})]}),jsxRuntime.jsx(CardContent,{className:"space-y-6",children:e?jsxRuntime.jsx(jsxRuntime.Fragment,{children:[1,2,3].map(Mt=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-48"}),[1,2].map(Dt=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"})]}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"})]},Dt))]},Mt))}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:yt.map(Mt=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:Mt.name}),Mt.reports.map(Dt=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg hover:bg-muted transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-2 rounded-full",children:jsxRuntime.jsx(Dt.icon,{className:"h-5 w-5 text-primary"})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("h4",{className:"font-semibold text-sm",children:Dt.title}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:Dt.description})]}),jsxRuntime.jsxs(Button$1,{variant:"outline",size:"sm",className:"flex items-center gap-1",onClick:()=>It(Dt),children:[jsxRuntime.jsx(Download,{className:"h-4 w-4"}),"Request"]})]},Dt.id))]},Mt.name))})}),jsxRuntime.jsx(Dialog,{open:ut,onOpenChange:ct,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsxs(DialogTitle,{children:["Request ",it?.title]}),jsxRuntime.jsx(DialogDescription,{children:"Enter the email address where you would like to receive the report."})]}),jsxRuntime.jsxs("div",{className:"py-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",value:ot,onChange:Mt=>lt(Mt.target.value),placeholder:"your@email.com",className:"mt-2"})]}),it?.id==="Products"&&jsxRuntime.jsxs("div",{className:"py-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"manufacturer",children:"Manufacturer"}),jsxRuntime.jsxs("select",{id:"manufacturer",className:"mt-2 block w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:dt,onChange:Mt=>pt(Mt.target.value),disabled:Rt,children:[jsxRuntime.jsx("option",{value:"all",children:"All manufacturers"}),!Rt&&Array.isArray(mt)&&mt.slice().sort((Mt,Dt)=>(Mt.PublicName||Mt.Name||"").localeCompare(Dt.PublicName||Dt.Name||"")).map(Mt=>Mt?.ManufacturerId?jsxRuntime.jsx("option",{value:Mt.ManufacturerId,children:(Mt.PublicName||Mt.Name||Mt.ManufacturerId)+(Mt.OpenToWork?" (Open to Work)":"")},Mt.ManufacturerId):null)]})]}),jsxRuntime.jsx(DialogDescription,{children:"The report will take around 5 minutes to generate."}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>ct(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:ft,disabled:!ot||Ct,children:Ct?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}function QualificationBadge({qualification:e}){return!e.QualificationId||e.QualificationId==="Suspended"?null:e.QualificationId==="Do Not Sell"?jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs(Badge,{variant:"destructive",children:[jsxRuntime.jsx(X$2,{className:"h-3 w-3 mr-1"}),"Do Not Sell"]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})}):jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs(Badge,{variant:"info",className:e.DefaultOpportunityNumber?"pr-1":"",children:[jsxRuntime.jsx(BadgeCheck,{className:"h-3 w-3 mr-1"}),e.QualificationId,e.DefaultOpportunityNumber&&jsxRuntime.jsx(Badge,{variant:"secondary",size:"sm",className:"ml-1",children:e.DefaultOpportunityNumber})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})})}function SalesChart({statistics:e,mode:t="month",chartHeight:n,loading:s=!1,size:a="default"}){const[o,l]=React.useState([]),[c,d]=React.useState(!1),f=[{name:"dollarVolume",label:"Dollar Volume",color:"var(--primary)",dotClassName:"bg-primary",yAxisId:"left",format:"money"},{name:"unitsSold",label:"Units Sold",color:"var(--chart-2)",dotClassName:"bg-chart-2",units:" units",yAxisId:"right",format:"integer"}];return React.useEffect(()=>{if(s||!e){l([]);return}let R=[];if(t==="week"){const S=new Map;e.forEach(te=>{const A=te.Day?.toString()||"";if(A.length===8){const rt=parseInt(A.substring(0,4),10),st=parseInt(A.substring(4,6),10)-1,it=parseInt(A.substring(6,8),10),at=new Date(rt,st,it),ot=new Date(at);ot.setDate(at.getDate()-at.getDay());const lt=`${ot.getFullYear()}-${String(ot.getMonth()+1).padStart(2,"0")}-${String(ot.getDate()).padStart(2,"0")}`,ut=S.get(lt)||{price:0,quantity:0};ut.price+=te.ExtendedPrice||0,ut.quantity+=te.Quantity||0,S.set(lt,ut)}}),R=Array.from(S).sort(([te],[A])=>te.localeCompare(A)).map(([te,A])=>({date:`${te.substring(5,7)}/${te.substring(8,10)}`,dollarVolume:A.price,unitsSold:A.quantity}))}else{const S=new Date,te=S.getFullYear(),A=S.getMonth(),rt=S.getDate(),st=`${te}-${(A+1).toString().padStart(2,"0")}`,it=Array.from({length:12},(ot,lt)=>{const ut=new Date(te,A-(11-lt),1);return`${ut.getFullYear()}-${(ut.getMonth()+1).toString().padStart(2,"0")}`}),at=Object.fromEntries(it.map(ot=>[ot,{price:0,quantity:0}]));if(e.forEach(ot=>{const lt=String(ot.Day??0);if(lt.length!==8)return;const ut=`${lt.substring(0,4)}-${lt.substring(4,6)}`;at[ut]&&(at[ut].price+=ot.ExtendedPrice??0,at[ut].quantity+=ot.Quantity??0)}),R=it.map(ot=>{const lt=at[ot],[ut,ct]=ot.split("-").map(Number);return{date:new Date(ut,ct-1).toLocaleString("default",{month:"short",year:"numeric"}),dollarVolume:lt.price,unitsSold:lt.quantity}}),c){const ot=at[st];if(ot&&ot.price>0&&rt>0){const lt=new Date(te,A+1,0).getDate();if(rt<lt){const ut=ot.price/rt,ct=ot.quantity/rt,dt=ut*lt,pt=ct*lt,mt=R[R.length-1];mt&&(mt.dollarVolume=dt,mt.unitsSold=pt)}}}}l(R)},[e,t,c,s]),s?jsxRuntime.jsx("div",{style:{height:n},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}):o.length===0?jsxRuntime.jsx("div",{style:{height:n},className:"flex items-center justify-center text-muted-foreground",children:"No sales data available."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(AreaChart,{data:o,series:f,height:n,size:a}),a==="default"&&t==="month"&&jsxRuntime.jsxs("div",{className:"mt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{checked:c,onCheckedChange:d,id:"extrapolate-switch"}),jsxRuntime.jsx(Label$2,{htmlFor:"extrapolate-switch",children:"Extrapolate Current Month"})]}),c&&jsxRuntime.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["* Values for ",new Date().toLocaleString("default",{month:"long"})," are projected estimates."]})]})]})}function PartnerCardHeader({type:e,applicationId:t,publicName:n,name:s,location:a,link:o,linkNewTab:l=!0,children:c}){const[d,f]=React.useState(!1),R=te=>{te.preventDefault(),te.stopPropagation(),navigator.clipboard.writeText(t),f(!0),setTimeout(()=>f(!1),2e3)},S=jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx(PartnerLogo,{id:t,width:48,height:48},`partner_logo_${t}`)}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:e}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{delayDuration:300,children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex cursor-pointer items-center gap-1",onClick:R,children:[jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:t}),d?jsxRuntime.jsx(Check,{className:"h-3 w-3 text-success"}):jsxRuntime.jsx(Copy,{className:"h-3 w-3 text-muted-foreground"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:d?"Copied!":"Copy ID"})})]})})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:n||"N/A"}),s&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:s}),a&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:a})]})]}),c&&jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:c})]});return o?jsxRuntime.jsx(reactRouterDom.Link,{to:o,target:l?"_blank":"_self",children:S}):S}function ManufacturerCard({manufacturer:e,link:t,linkNewTab:n=!0,actions:s,mainAction:a,loading:o=!1,appID:l}){const{toast:c}=useToast(),[d,{isLoading:f}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[R,S]=React.useState(!1),[te,A]=React.useState(""),{data:rt}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:l||""},{skip:!l}),st=rt?.IsReseller;if(o||!e)return jsxRuntime.jsxs(Card,{className:"flex flex-col h-full",children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-24 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"})]})]}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-24"})]}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex flex-col space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-14 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-36"})]})]})]})}),jsxRuntime.jsxs(CardFooter,{className:"flex justify-between pt-2 gap-2 mt-auto",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-40"})]})]});const it=[e.City,e.Province,e.Country].filter(Boolean),at=it.length>0?it.join(", "):"",ot=e.Tags?.split(",").map(ut=>ut.trim()).filter(Boolean)||[],lt=async()=>{if(!(!e?.ManufacturerId||!l||!te))try{await d({routeResellerId:l,emailAddress:te,manufacturerId:e.ManufacturerId}).unwrap(),c({title:"Report requested",description:`The Universal Product List for this manufacturer will be sent to ${te} shortly.`,variant:"success"}),S(!1)}catch(ut){console.error("Error requesting product list:",ut),c({title:"Error",description:"Failed to request product list. Please try again.",variant:"destructive"})}};return jsxRuntime.jsxs(Card,{className:"flex flex-col h-full",children:[jsxRuntime.jsx(PartnerCardHeader,{type:"Manufacturer",applicationId:e.ManufacturerId,publicName:e.PublicName,name:e.Name,location:at,link:t,linkNewTab:n,children:jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:e.SalesStatistics&&e.SalesStatistics.length>0&&jsxRuntime.jsx("div",{className:"h-16 w-24",children:jsxRuntime.jsx(SalesChart,{statistics:e.SalesStatistics,size:"mini"})})})}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex",children:[jsxRuntime.jsxs("div",{className:"flex flex-col flex-1 space-y-2",children:[(!!e.Qualification?.QualificationId&&e.Qualification?.QualificationId!=="Suspended"||!!e.OpenToWork||!!e.OnHold&&e.OnHold!==0||ot.length>0)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(QualificationBadge,{qualification:e.Qualification??{}}),!!e.OpenToWork&&jsxRuntime.jsxs(Badge,{variant:"success",children:[jsxRuntime.jsx(HardHat,{className:"h-3 w-3 mr-1"}),"Open To Work"]}),!!e.OnHold&&e.OnHold!==0&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"}),ot.map((ut,ct)=>jsxRuntime.jsx(Badge,{variant:"outline",children:ut},ct))]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[e.Phone&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`tel:${e.Phone}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Phone,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Phone})]}),e.PublicEmail&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`mailto:${e.PublicEmail}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.PublicEmail})]}),e.Website&&jsxRuntime.jsxs(reactRouterDom.Link,{to:e.Website,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Globe,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Website})]}),e.CurrencyCode&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(DollarSign,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.CurrencyCode})]})]})]}),e.SalesData&&jsxRuntime.jsxs("div",{className:"border-l pl-2 ml-2 flex flex-col text-sm",children:[jsxRuntime.jsx("strong",{className:"",children:"YTD"}),jsxRuntime.jsx("p",{children:e.SalesData.SalesYearToDay?formatMoney(e.SalesData.SalesYearToDay):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"3 mo."}),jsxRuntime.jsx("p",{children:e.SalesData.SalesLast3Months?formatMoney(e.SalesData.SalesLast3Months):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"30 days"}),jsxRuntime.jsx("p",{children:e.SalesData.SalesLast30Days?formatMoney(e.SalesData.SalesLast30Days):"—"})]})]})}),(s||a||e.PublicResourcesLink||st&&l&&e.ManufacturerId||t)&&jsxRuntime.jsxs(CardFooter,{className:"flex pt-2 gap-2 justify-between mt-auto",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[s&&s,st&&l&&e.ManufacturerId&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{size:"icon",onClick:()=>S(!0),disabled:f,children:f?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Email Product List"})})]})}),e.PublicResourcesLink&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:e.PublicResourcesLink,target:"_blank",children:jsxRuntime.jsx(Button$1,{size:"icon",children:jsxRuntime.jsx(BookOpen,{className:"h-4 w-4"})})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Public Resources Link"})})]})})]}),a&&jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:jsxRuntime.jsx("div",{children:a})})]}),jsxRuntime.jsx(Dialog,{open:R,onOpenChange:S,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Request Universal Product List"}),jsxRuntime.jsx(DialogDescription,{children:"Enter the email address where you would like to receive the report."})]}),jsxRuntime.jsxs("div",{className:"py-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",value:te,onChange:ut=>A(ut.target.value),placeholder:"your@email.com",className:"mt-2"})]}),jsxRuntime.jsx(DialogDescription,{children:"The report will take around 5 minutes to generate."}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>S(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:lt,disabled:!te||f,children:f?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}function ProductInventoryButton({applicationId:e,randmarSku:t,inventory:n,buttonSize:s="default",buttonClassName:a}){const o=React.useRef(null),l=useIntersectionObserver({elementRef:o,threshold:.1,rootMargin:"100px",freezeOnceVisible:!0}),{toast:c}=useToast(),[d,f]=React.useState(!1),[R,S]=React.useState(!1),[te,A]=React.useState(!1),{data:rt,isLoading:st,isFetching:it}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:e},{skip:!e||!l}),{data:at,isLoading:ot,isFetching:lt}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:e,randmarSku:t,withSpecification:!1},{skip:!!n||!l}),[ut]=usePutV4ResellerByRouteResellerIdProductAndRandmarSkuRequisitionMutation(),ct=n??at?.Distribution?.Inventory;React.useEffect(()=>{f(!1)},[t]);const{inventoryQuantity:dt,totalIncomingQuantity:pt}=React.useMemo(()=>{if(!ct||ct.length===0)return{inventoryQuantity:0,totalIncomingQuantity:0};const It=ct.reduce((Ct,Mt)=>Ct+(Mt.AvailableQuantity||0),0),ft=ct.reduce((Ct,Mt)=>Ct+(Mt.PurchaseOrderQuantity||0),0);return{inventoryQuantity:It,totalIncomingQuantity:ft}},[ct]);if(st||it||ot||lt)return jsxRuntime.jsx("div",{ref:o,children:jsxRuntime.jsx(Skeleton,{className:cn("h-10 w-36 rounded-md",a)})});const Rt=()=>{te||!rt?.IsReseller||(A(!0),ut({routeResellerId:e??"",randmarSku:t??""}).then(It=>{It.error||It.data===!1?c({title:"Warning",description:"Reorder is pending or requires manual approval. Contact the Randmar team for details.",variant:"warning"}):c({title:"Success",description:"Qualification successfully submitted.",variant:"success"}),S(!1)}).catch(It=>{console.error(It),c({title:"Error",description:"Error submitting your qualification.",variant:"destructive"})}).finally(()=>{A(!1)}))};if(!ct)return jsxRuntime.jsx("div",{ref:o,children:jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("span",{tabIndex:0,children:jsxRuntime.jsxs(Button$1,{disabled:!0,size:s,variant:"outline",className:cn("text-sm",a),children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),"No data"]})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"No inventory data could be found for this product."})})]})})});if(rt?.IsReseller&&dt<=0&&pt<=0)return jsxRuntime.jsx("div",{ref:o,children:jsxRuntime.jsxs(Dialog,{open:R,onOpenChange:S,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:s,className:cn("text-sm text-primary",a),children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),"Request to stock"]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-md",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Request to stock"})}),jsxRuntime.jsx("p",{className:"py-4",children:"Are you sure you want to request this product to be stocked?"}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>S(!1),disabled:te,children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:Rt,disabled:te,children:te?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin mr-2"}),"Requesting..."]}):"Confirm"})]})]})]})});const yt=dt<=0&&pt>0;return jsxRuntime.jsx("div",{ref:o,children:jsxRuntime.jsxs(Dialog,{open:d,onOpenChange:f,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:s,className:cn("text-sm",yt?"text-info":dt>0?"text-success":"text-destructive",a),children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),yt?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(pt)," Incoming"]}):dt>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(dt)," in stock"]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Out of stock"})]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-4xl",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsxs(DialogTitle,{className:"flex items-center",children:[jsxRuntime.jsx(Warehouse,{className:"mr-2",size:18}),"Inventory Information"]})}),jsxRuntime.jsx(ProductInventoryGrid,{inventory:ct})]})]})})}function OrdersCard({applicationId:e,orders:t=null,loading:n=!1,title:s="Order Details"}){const a=React.useMemo(()=>[{accessorKey:"OrderNumber",header:"Order Number",cell:({row:c})=>c.original.OrderNumber?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/GeneralDocument/${c.original.OrderNumber}`,className:"font-medium text-primary hover:underline",children:c.original.OrderNumber})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for order ",c.original.OrderNumber]})})]})}):"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentNumber",header:"Document Number",cell:({row:c})=>c.original.DocumentNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentDate",header:"Document Date",cell:({row:c})=>formatYYYYMMDDIntToDateString(c.original.DocumentDate),enableSorting:!0,enableFiltering:!1},{accessorKey:"PONumber",header:"PO Number",cell:({row:c})=>c.original.PONumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseCode",header:"Warehouse",cell:({row:c})=>c.original.WarehouseCode??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"MPN",header:"MPN",cell:({row:c})=>c.original.MPN?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Product/${c.original.MPN}`,className:"font-medium text-primary hover:underline",children:c.original.MPN})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for MPN ",c.original.MPN]})})]})}):"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:c})=>c.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!1},{accessorKey:"ShipToName",header:"Name",cell:({row:c})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:c.original.ShipToName??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:c})=>c.original.UnitPrice?formatMoney(c.original.UnitPrice):"N/A",enableSorting:!0,enableFiltering:!1},{id:"actions",header:"Actions",cell:({row:c})=>jsxRuntime.jsx("div",{className:"flex space-x-2",children:jsxRuntime.jsx(ProductInventoryButton,{applicationId:e,randmarSku:c.original.RandmarSKU??"",buttonSize:"sm"})})}],[e]),o=React.useMemo(()=>{const c={};if(t){const d=Array.from(new Set(t.map(rt=>rt.WarehouseCode).filter(rt=>rt!=null)));c.WarehouseCode=d;const f=Array.from(new Set(t.map(rt=>rt.ShipToName).filter(rt=>rt!=null)));c.ShipToName=f;const R=Array.from(new Set(t.map(rt=>rt.DocumentNumber).filter(rt=>rt!=null)));c.DocumentNumber=R;const S=Array.from(new Set(t.map(rt=>rt.OrderNumber).filter(rt=>rt!=null)));c.OrderNumber=S;const te=Array.from(new Set(t.map(rt=>rt.PONumber).filter(rt=>rt!=null)));c.PONumber=te;const A=Array.from(new Set(t.map(rt=>rt.MPN).filter(rt=>rt!=null)));c.MPN=A}return c},[t]),l=t||[];return n?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:s})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:a,data:l,uniqueValues:o})})]})}function ResellerOverview({appID:e,reseller:t,readonly:n,userEmail:s,isSuperAdmin:a,withoutReports:o=!1,loadFullAfterSummary:l=!1}){const c=`${e}|${l?1:0}`,d=React.useRef(c),[f,R]=React.useState(()=>l?!!t:!1);React.useEffect(()=>{d.current!==c&&(d.current=c,R(!1))},[c]),React.useEffect(()=>{l&&t&&R(!0)},[l,t]);const S=l?f:!t,{data:te,isLoading:A,isError:rt}=useGetV4PartnerByApplicationIdAccountResellerQuery({applicationId:e??"",withSpecification:!0},{skip:!e||!S}),[st,it]=React.useState({publicInfo:{hasUnsavedChanges:!1}}),at=React.useCallback(()=>n?!1:st.publicInfo.hasUnsavedChanges,[n,st]),ot=React.useCallback((yt,It)=>{it(ft=>ft[yt]?.hasUnsavedChanges!==It.hasUnsavedChanges?{...ft,[yt]:It}:ft)},[]),{NavigationGuardDialog:lt}=useRouterNavigationGuard(at),ut=te??t,ct=A&&!ut,dt=rt&&!ut,pt=!n||!!ut?.Statement&&(ut.Statement.Total??0)!==0,mt=ut?.QualifiedManufacturers??[],Rt=ut?.Qualifications??[];return jsxRuntime.jsxs("div",{className:"@container",children:[dt?jsxRuntime.jsx(Card,{className:"p-6",children:jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Error"}),jsxRuntime.jsx(AlertDescription,{children:"There was an error loading your reseller information. Please try again later."})]})}):jsxRuntime.jsxs("div",{className:"space-y-6 mb-6",children:[jsxRuntime.jsx(SalesSummary,{fiscalYearMonthStart:ut?.FiscalYearMonthStart||1,salesData:ut?.SalesData,isLoading:ct}),jsxRuntime.jsxs("div",{className:"grid @lg:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:ut?.SalesStatistics??[],loading:ct}),jsxRuntime.jsx(OrderCategories,{openOrders:ut?.ActiveOrderDetails??[],isLoading:ct}),pt&&jsxRuntime.jsx(BillingCard,{appID:e,reseller:ut||{},withoutReports:o,isLoading:ct,userEmail:s,isSuperAdmin:a}),jsxRuntime.jsx(PublicInfo,{reseller:ut||{},appID:e??"",isLoading:ct,readonly:n,onUnsavedChanges:yt=>ot("publicInfo",{hasUnsavedChanges:yt})}),jsxRuntime.jsx(AccountTier,{isSuperAdmin:a,readonly:n,reseller:ut||{},appID:e??"",isLoading:ct})]}),ct||mt.length>0?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Manufacturers you are qualified for"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid @lg:grid-cols-2 gap-4",children:ct?Array.from({length:2}).map((yt,It)=>jsxRuntime.jsx(ManufacturerCard,{loading:!0},It)):mt.map(yt=>jsxRuntime.jsx(ManufacturerCard,{manufacturer:yt,link:`https://dashboard.randmar.io/${e}/Partner/${yt.ManufacturerId}`},yt.ManufacturerId))})})]}):Rt.length>0&&jsxRuntime.jsx(ResellerQualificationsCard,{qualifications:Rt}),(ut?.Opportunities?.length??0)>0&&jsxRuntime.jsx(OpportunitiesTable,{applicationId:e,opportunities:ut?.Opportunities,loading:ct}),(ut?.ActiveOrderDetails?.length??0)>0&&jsxRuntime.jsx(OrdersCard,{applicationId:e,title:"Active Orders",orders:ut?.ActiveOrderDetails,loading:ct}),(ut?.CompletedOrderDetails?.length??0)>0&&jsxRuntime.jsx(OrdersCard,{applicationId:e,title:"Completed Orders",orders:ut?.CompletedOrderDetails,loading:ct}),(ut?.Returns?.length??0)>0&&jsxRuntime.jsx(ReturnsTable,{applicationId:e,returns:ut?.Returns,loading:ct}),!o&&jsxRuntime.jsx(ReportsSection,{appID:e,userEmail:s,isLoading:ct})]}),jsxRuntime.jsx(lt,{})]})}const alertVariants=cva("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 bg-destructive/10 text-foreground [&>svg]:text-destructive",success:"border-success/50 bg-success/10 text-foreground [&>svg]:text-success",warning:"border-warning/50 bg-warning/10 text-foreground [&>svg]:text-warning",info:"border-info/50 bg-info/10 text-foreground [&>svg]:text-info"}},defaultVariants:{variant:"default"}}),Alert=React__namespace.forwardRef(({className:e,variant:t,...n},s)=>jsxRuntime.jsx("div",{ref:s,role:"alert",className:cn(alertVariants({variant:t}),e),...n}));Alert.displayName="Alert";const AlertTitle=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("h5",{ref:n,className:cn("mb-1 font-medium leading-none tracking-tight",e),...t}));AlertTitle.displayName="AlertTitle";const AlertDescription=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("text-sm [&_p]:leading-relaxed",e),...t}));AlertDescription.displayName="AlertDescription";function functionalUpdate(e,t){return typeof e=="function"?e(t):e}function makeStateUpdater(e,t){return n=>{t.setState(s=>({...s,[e]:functionalUpdate(n,s[e])}))}}function isFunction$2(e){return e instanceof Function}function isNumberArray(e){return Array.isArray(e)&&e.every(t=>typeof t=="number")}function flattenBy(e,t){const n=[],s=a=>{a.forEach(o=>{n.push(o);const l=t(o);l!=null&&l.length&&s(l)})};return s(e),n}function memo(e,t,n){let s=[],a;return o=>{let l;n.key&&n.debug&&(l=Date.now());const c=e(o);if(!(c.length!==s.length||c.some((R,S)=>s[S]!==R)))return a;s=c;let f;if(n.key&&n.debug&&(f=Date.now()),a=t(...c),n==null||n.onChange==null||n.onChange(a),n.key&&n.debug&&n!=null&&n.debug()){const R=Math.round((Date.now()-l)*100)/100,S=Math.round((Date.now()-f)*100)/100,te=S/16,A=(rt,st)=>{for(rt=String(rt);rt.length<st;)rt=" "+rt;return rt};console.info(`%c⏱ ${A(S,5)} /${A(R,5)} ms`,`
|
|
488
488
|
font-size: .6rem;
|
|
489
489
|
font-weight: bold;
|
|
490
490
|
color: hsl(${Math.max(0,Math.min(120-120*te,120))}deg 100% 31%);`,n?.key)}return a}}function getMemoOptions(e,t,n,s){return{debug:()=>{var a;return(a=e?.debugAll)!=null?a:e[t]},key:process.env.NODE_ENV==="development"&&n,onChange:s}}function createCell(e,t,n,s){const a=()=>{var l;return(l=o.getValue())!=null?l:e.options.renderFallbackValue},o={id:`${t.id}_${n.id}`,row:t,column:n,getValue:()=>t.getValue(s),renderValue:a,getContext:memo(()=>[e,n,t,o],(l,c,d,f)=>({table:l,column:c,row:d,cell:f,getValue:f.getValue,renderValue:f.renderValue}),getMemoOptions(e.options,"debugCells","cell.getContext"))};return e._features.forEach(l=>{l.createCell==null||l.createCell(o,n,t,e)},{}),o}function createColumn(e,t,n,s){var a,o;const c={...e._getDefaultColumnDef(),...t},d=c.accessorKey;let f=(a=(o=c.id)!=null?o:d?typeof String.prototype.replaceAll=="function"?d.replaceAll(".","_"):d.replace(/\./g,"_"):void 0)!=null?a:typeof c.header=="string"?c.header:void 0,R;if(c.accessorFn?R=c.accessorFn:d&&(d.includes(".")?R=te=>{let A=te;for(const st of d.split(".")){var rt;A=(rt=A)==null?void 0:rt[st],process.env.NODE_ENV!=="production"&&A===void 0&&console.warn(`"${st}" in deeply nested key "${d}" returned undefined.`)}return A}:R=te=>te[c.accessorKey]),!f)throw process.env.NODE_ENV!=="production"?new Error(c.accessorFn?"Columns require an id when using an accessorFn":"Columns require an id when using a non-string header"):new Error;let S={id:`${String(f)}`,accessorFn:R,parent:s,depth:n,columnDef:c,columns:[],getFlatColumns:memo(()=>[!0],()=>{var te;return[S,...(te=S.columns)==null?void 0:te.flatMap(A=>A.getFlatColumns())]},getMemoOptions(e.options,"debugColumns","column.getFlatColumns")),getLeafColumns:memo(()=>[e._getOrderColumnsFn()],te=>{var A;if((A=S.columns)!=null&&A.length){let rt=S.columns.flatMap(st=>st.getLeafColumns());return te(rt)}return[S]},getMemoOptions(e.options,"debugColumns","column.getLeafColumns"))};for(const te of e._features)te.createColumn==null||te.createColumn(S,e);return S}const debug="debugHeaders";function createHeader(e,t,n){var s;let o={id:(s=n.id)!=null?s:t.id,column:t,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{const l=[],c=d=>{d.subHeaders&&d.subHeaders.length&&d.subHeaders.map(c),l.push(d)};return c(o),l},getContext:()=>({table:e,header:o,column:t})};return e._features.forEach(l=>{l.createHeader==null||l.createHeader(o,e)}),o}const Headers$1={createTable:e=>{e.getHeaderGroups=memo(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,s,a)=>{var o,l;const c=(o=s?.map(S=>n.find(te=>te.id===S)).filter(Boolean))!=null?o:[],d=(l=a?.map(S=>n.find(te=>te.id===S)).filter(Boolean))!=null?l:[],f=n.filter(S=>!(s!=null&&s.includes(S.id))&&!(a!=null&&a.includes(S.id)));return buildHeaderGroups(t,[...c,...f,...d],e)},getMemoOptions(e.options,debug,"getHeaderGroups")),e.getCenterHeaderGroups=memo(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,s,a)=>(n=n.filter(o=>!(s!=null&&s.includes(o.id))&&!(a!=null&&a.includes(o.id))),buildHeaderGroups(t,n,e,"center")),getMemoOptions(e.options,debug,"getCenterHeaderGroups")),e.getLeftHeaderGroups=memo(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,n,s)=>{var a;const o=(a=s?.map(l=>n.find(c=>c.id===l)).filter(Boolean))!=null?a:[];return buildHeaderGroups(t,o,e,"left")},getMemoOptions(e.options,debug,"getLeftHeaderGroups")),e.getRightHeaderGroups=memo(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,n,s)=>{var a;const o=(a=s?.map(l=>n.find(c=>c.id===l)).filter(Boolean))!=null?a:[];return buildHeaderGroups(t,o,e,"right")},getMemoOptions(e.options,debug,"getRightHeaderGroups")),e.getFooterGroups=memo(()=>[e.getHeaderGroups()],t=>[...t].reverse(),getMemoOptions(e.options,debug,"getFooterGroups")),e.getLeftFooterGroups=memo(()=>[e.getLeftHeaderGroups()],t=>[...t].reverse(),getMemoOptions(e.options,debug,"getLeftFooterGroups")),e.getCenterFooterGroups=memo(()=>[e.getCenterHeaderGroups()],t=>[...t].reverse(),getMemoOptions(e.options,debug,"getCenterFooterGroups")),e.getRightFooterGroups=memo(()=>[e.getRightHeaderGroups()],t=>[...t].reverse(),getMemoOptions(e.options,debug,"getRightFooterGroups")),e.getFlatHeaders=memo(()=>[e.getHeaderGroups()],t=>t.map(n=>n.headers).flat(),getMemoOptions(e.options,debug,"getFlatHeaders")),e.getLeftFlatHeaders=memo(()=>[e.getLeftHeaderGroups()],t=>t.map(n=>n.headers).flat(),getMemoOptions(e.options,debug,"getLeftFlatHeaders")),e.getCenterFlatHeaders=memo(()=>[e.getCenterHeaderGroups()],t=>t.map(n=>n.headers).flat(),getMemoOptions(e.options,debug,"getCenterFlatHeaders")),e.getRightFlatHeaders=memo(()=>[e.getRightHeaderGroups()],t=>t.map(n=>n.headers).flat(),getMemoOptions(e.options,debug,"getRightFlatHeaders")),e.getCenterLeafHeaders=memo(()=>[e.getCenterFlatHeaders()],t=>t.filter(n=>{var s;return!((s=n.subHeaders)!=null&&s.length)}),getMemoOptions(e.options,debug,"getCenterLeafHeaders")),e.getLeftLeafHeaders=memo(()=>[e.getLeftFlatHeaders()],t=>t.filter(n=>{var s;return!((s=n.subHeaders)!=null&&s.length)}),getMemoOptions(e.options,debug,"getLeftLeafHeaders")),e.getRightLeafHeaders=memo(()=>[e.getRightFlatHeaders()],t=>t.filter(n=>{var s;return!((s=n.subHeaders)!=null&&s.length)}),getMemoOptions(e.options,debug,"getRightLeafHeaders")),e.getLeafHeaders=memo(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(t,n,s)=>{var a,o,l,c,d,f;return[...(a=(o=t[0])==null?void 0:o.headers)!=null?a:[],...(l=(c=n[0])==null?void 0:c.headers)!=null?l:[],...(d=(f=s[0])==null?void 0:f.headers)!=null?d:[]].map(R=>R.getLeafHeaders()).flat()},getMemoOptions(e.options,debug,"getLeafHeaders"))}};function buildHeaderGroups(e,t,n,s){var a,o;let l=0;const c=function(te,A){A===void 0&&(A=1),l=Math.max(l,A),te.filter(rt=>rt.getIsVisible()).forEach(rt=>{var st;(st=rt.columns)!=null&&st.length&&c(rt.columns,A+1)},0)};c(e);let d=[];const f=(te,A)=>{const rt={depth:A,id:[s,`${A}`].filter(Boolean).join("_"),headers:[]},st=[];te.forEach(it=>{const at=[...st].reverse()[0],ot=it.column.depth===rt.depth;let lt,ut=!1;if(ot&&it.column.parent?lt=it.column.parent:(lt=it.column,ut=!0),at&&at?.column===lt)at.subHeaders.push(it);else{const ct=createHeader(n,lt,{id:[s,A,lt.id,it?.id].filter(Boolean).join("_"),isPlaceholder:ut,placeholderId:ut?`${st.filter(dt=>dt.column===lt).length}`:void 0,depth:A,index:st.length});ct.subHeaders.push(it),st.push(ct)}rt.headers.push(it),it.headerGroup=rt}),d.push(rt),A>0&&f(st,A-1)},R=t.map((te,A)=>createHeader(n,te,{depth:l,index:A}));f(R,l-1),d.reverse();const S=te=>te.filter(rt=>rt.column.getIsVisible()).map(rt=>{let st=0,it=0,at=[0];rt.subHeaders&&rt.subHeaders.length?(at=[],S(rt.subHeaders).forEach(lt=>{let{colSpan:ut,rowSpan:ct}=lt;st+=ut,at.push(ct)})):st=1;const ot=Math.min(...at);return it=it+ot,rt.colSpan=st,rt.rowSpan=it,{colSpan:st,rowSpan:it}});return S((a=(o=d[0])==null?void 0:o.headers)!=null?a:[]),d}const createRow=(e,t,n,s,a,o,l)=>{let c={id:t,index:s,original:n,depth:a,parentId:l,_valuesCache:{},_uniqueValuesCache:{},getValue:d=>{if(c._valuesCache.hasOwnProperty(d))return c._valuesCache[d];const f=e.getColumn(d);if(f!=null&&f.accessorFn)return c._valuesCache[d]=f.accessorFn(c.original,s),c._valuesCache[d]},getUniqueValues:d=>{if(c._uniqueValuesCache.hasOwnProperty(d))return c._uniqueValuesCache[d];const f=e.getColumn(d);if(f!=null&&f.accessorFn)return f.columnDef.getUniqueValues?(c._uniqueValuesCache[d]=f.columnDef.getUniqueValues(c.original,s),c._uniqueValuesCache[d]):(c._uniqueValuesCache[d]=[c.getValue(d)],c._uniqueValuesCache[d])},renderValue:d=>{var f;return(f=c.getValue(d))!=null?f:e.options.renderFallbackValue},subRows:[],getLeafRows:()=>flattenBy(c.subRows,d=>d.subRows),getParentRow:()=>c.parentId?e.getRow(c.parentId,!0):void 0,getParentRows:()=>{let d=[],f=c;for(;;){const R=f.getParentRow();if(!R)break;d.push(R),f=R}return d.reverse()},getAllCells:memo(()=>[e.getAllLeafColumns()],d=>d.map(f=>createCell(e,c,f,f.id)),getMemoOptions(e.options,"debugRows","getAllCells")),_getAllCellsByColumnId:memo(()=>[c.getAllCells()],d=>d.reduce((f,R)=>(f[R.column.id]=R,f),{}),getMemoOptions(e.options,"debugRows","getAllCellsByColumnId"))};for(let d=0;d<e._features.length;d++){const f=e._features[d];f==null||f.createRow==null||f.createRow(c,e)}return c},ColumnFaceting={createColumn:(e,t)=>{e._getFacetedRowModel=t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,e.id),e.getFacetedRowModel=()=>e._getFacetedRowModel?e._getFacetedRowModel():t.getPreFilteredRowModel(),e._getFacetedUniqueValues=t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,e.id),e.getFacetedUniqueValues=()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,e._getFacetedMinMaxValues=t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,e.id),e.getFacetedMinMaxValues=()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}}},includesString=(e,t,n)=>{var s,a;const o=n==null||(s=n.toString())==null?void 0:s.toLowerCase();return!!(!((a=e.getValue(t))==null||(a=a.toString())==null||(a=a.toLowerCase())==null)&&a.includes(o))};includesString.autoRemove=e=>testFalsey(e);const includesStringSensitive=(e,t,n)=>{var s;return!!(!((s=e.getValue(t))==null||(s=s.toString())==null)&&s.includes(n))};includesStringSensitive.autoRemove=e=>testFalsey(e);const equalsString=(e,t,n)=>{var s;return((s=e.getValue(t))==null||(s=s.toString())==null?void 0:s.toLowerCase())===n?.toLowerCase()};equalsString.autoRemove=e=>testFalsey(e);const arrIncludes=(e,t,n)=>{var s;return(s=e.getValue(t))==null?void 0:s.includes(n)};arrIncludes.autoRemove=e=>testFalsey(e);const arrIncludesAll=(e,t,n)=>!n.some(s=>{var a;return!((a=e.getValue(t))!=null&&a.includes(s))});arrIncludesAll.autoRemove=e=>testFalsey(e)||!(e!=null&&e.length);const arrIncludesSome=(e,t,n)=>n.some(s=>{var a;return(a=e.getValue(t))==null?void 0:a.includes(s)});arrIncludesSome.autoRemove=e=>testFalsey(e)||!(e!=null&&e.length);const equals=(e,t,n)=>e.getValue(t)===n;equals.autoRemove=e=>testFalsey(e);const weakEquals=(e,t,n)=>e.getValue(t)==n;weakEquals.autoRemove=e=>testFalsey(e);const inNumberRange=(e,t,n)=>{let[s,a]=n;const o=e.getValue(t);return o>=s&&o<=a};inNumberRange.resolveFilterValue=e=>{let[t,n]=e,s=typeof t!="number"?parseFloat(t):t,a=typeof n!="number"?parseFloat(n):n,o=t===null||Number.isNaN(s)?-1/0:s,l=n===null||Number.isNaN(a)?1/0:a;if(o>l){const c=o;o=l,l=c}return[o,l]},inNumberRange.autoRemove=e=>testFalsey(e)||testFalsey(e[0])&&testFalsey(e[1]);const filterFns={includesString,includesStringSensitive,equalsString,arrIncludes,arrIncludesAll,arrIncludesSome,equals,weakEquals,inNumberRange};function testFalsey(e){return e==null||e===""}const ColumnFiltering={getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:e=>({columnFilters:[],...e}),getDefaultOptions:e=>({onColumnFiltersChange:makeStateUpdater("columnFilters",e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(e,t)=>{e.getAutoFilterFn=()=>{const n=t.getCoreRowModel().flatRows[0],s=n?.getValue(e.id);return typeof s=="string"?filterFns.includesString:typeof s=="number"?filterFns.inNumberRange:typeof s=="boolean"||s!==null&&typeof s=="object"?filterFns.equals:Array.isArray(s)?filterFns.arrIncludes:filterFns.weakEquals},e.getFilterFn=()=>{var n,s;return isFunction$2(e.columnDef.filterFn)?e.columnDef.filterFn:e.columnDef.filterFn==="auto"?e.getAutoFilterFn():(n=(s=t.options.filterFns)==null?void 0:s[e.columnDef.filterFn])!=null?n:filterFns[e.columnDef.filterFn]},e.getCanFilter=()=>{var n,s,a;return((n=e.columnDef.enableColumnFilter)!=null?n:!0)&&((s=t.options.enableColumnFilters)!=null?s:!0)&&((a=t.options.enableFilters)!=null?a:!0)&&!!e.accessorFn},e.getIsFiltered=()=>e.getFilterIndex()>-1,e.getFilterValue=()=>{var n;return(n=t.getState().columnFilters)==null||(n=n.find(s=>s.id===e.id))==null?void 0:n.value},e.getFilterIndex=()=>{var n,s;return(n=(s=t.getState().columnFilters)==null?void 0:s.findIndex(a=>a.id===e.id))!=null?n:-1},e.setFilterValue=n=>{t.setColumnFilters(s=>{const a=e.getFilterFn(),o=s?.find(R=>R.id===e.id),l=functionalUpdate(n,o?o.value:void 0);if(shouldAutoRemoveFilter(a,l,e)){var c;return(c=s?.filter(R=>R.id!==e.id))!=null?c:[]}const d={id:e.id,value:l};if(o){var f;return(f=s?.map(R=>R.id===e.id?d:R))!=null?f:[]}return s!=null&&s.length?[...s,d]:[d]})}},createRow:(e,t)=>{e.columnFilters={},e.columnFiltersMeta={}},createTable:e=>{e.setColumnFilters=t=>{const n=e.getAllLeafColumns(),s=a=>{var o;return(o=functionalUpdate(t,a))==null?void 0:o.filter(l=>{const c=n.find(d=>d.id===l.id);if(c){const d=c.getFilterFn();if(shouldAutoRemoveFilter(d,l.value,c))return!1}return!0})};e.options.onColumnFiltersChange==null||e.options.onColumnFiltersChange(s)},e.resetColumnFilters=t=>{var n,s;e.setColumnFilters(t?[]:(n=(s=e.initialState)==null?void 0:s.columnFilters)!=null?n:[])},e.getPreFilteredRowModel=()=>e.getCoreRowModel(),e.getFilteredRowModel=()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel?e.getPreFilteredRowModel():e._getFilteredRowModel())}};function shouldAutoRemoveFilter(e,t,n){return(e&&e.autoRemove?e.autoRemove(t,n):!1)||typeof t>"u"||typeof t=="string"&&!t}const sum=(e,t,n)=>n.reduce((s,a)=>{const o=a.getValue(e);return s+(typeof o=="number"?o:0)},0),min=(e,t,n)=>{let s;return n.forEach(a=>{const o=a.getValue(e);o!=null&&(s>o||s===void 0&&o>=o)&&(s=o)}),s},max=(e,t,n)=>{let s;return n.forEach(a=>{const o=a.getValue(e);o!=null&&(s<o||s===void 0&&o>=o)&&(s=o)}),s},extent=(e,t,n)=>{let s,a;return n.forEach(o=>{const l=o.getValue(e);l!=null&&(s===void 0?l>=l&&(s=a=l):(s>l&&(s=l),a<l&&(a=l)))}),[s,a]},mean=(e,t)=>{let n=0,s=0;if(t.forEach(a=>{let o=a.getValue(e);o!=null&&(o=+o)>=o&&(++n,s+=o)}),n)return s/n},median=(e,t)=>{if(!t.length)return;const n=t.map(o=>o.getValue(e));if(!isNumberArray(n))return;if(n.length===1)return n[0];const s=Math.floor(n.length/2),a=n.sort((o,l)=>o-l);return n.length%2!==0?a[s]:(a[s-1]+a[s])/2},unique=(e,t)=>Array.from(new Set(t.map(n=>n.getValue(e))).values()),uniqueCount=(e,t)=>new Set(t.map(n=>n.getValue(e))).size,count=(e,t)=>t.length,aggregationFns={sum,min,max,extent,mean,median,unique,uniqueCount,count},ColumnGrouping={getDefaultColumnDef:()=>({aggregatedCell:e=>{var t,n;return(t=(n=e.getValue())==null||n.toString==null?void 0:n.toString())!=null?t:null},aggregationFn:"auto"}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:makeStateUpdater("grouping",e),groupedColumnMode:"reorder"}),createColumn:(e,t)=>{e.toggleGrouping=()=>{t.setGrouping(n=>n!=null&&n.includes(e.id)?n.filter(s=>s!==e.id):[...n??[],e.id])},e.getCanGroup=()=>{var n,s;return((n=e.columnDef.enableGrouping)!=null?n:!0)&&((s=t.options.enableGrouping)!=null?s:!0)&&(!!e.accessorFn||!!e.columnDef.getGroupingValue)},e.getIsGrouped=()=>{var n;return(n=t.getState().grouping)==null?void 0:n.includes(e.id)},e.getGroupedIndex=()=>{var n;return(n=t.getState().grouping)==null?void 0:n.indexOf(e.id)},e.getToggleGroupingHandler=()=>{const n=e.getCanGroup();return()=>{n&&e.toggleGrouping()}},e.getAutoAggregationFn=()=>{const n=t.getCoreRowModel().flatRows[0],s=n?.getValue(e.id);if(typeof s=="number")return aggregationFns.sum;if(Object.prototype.toString.call(s)==="[object Date]")return aggregationFns.extent},e.getAggregationFn=()=>{var n,s;if(!e)throw new Error;return isFunction$2(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:e.columnDef.aggregationFn==="auto"?e.getAutoAggregationFn():(n=(s=t.options.aggregationFns)==null?void 0:s[e.columnDef.aggregationFn])!=null?n:aggregationFns[e.columnDef.aggregationFn]}},createTable:e=>{e.setGrouping=t=>e.options.onGroupingChange==null?void 0:e.options.onGroupingChange(t),e.resetGrouping=t=>{var n,s;e.setGrouping(t?[]:(n=(s=e.initialState)==null?void 0:s.grouping)!=null?n:[])},e.getPreGroupedRowModel=()=>e.getFilteredRowModel(),e.getGroupedRowModel=()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel?e.getPreGroupedRowModel():e._getGroupedRowModel())},createRow:(e,t)=>{e.getIsGrouped=()=>!!e.groupingColumnId,e.getGroupingValue=n=>{if(e._groupingValuesCache.hasOwnProperty(n))return e._groupingValuesCache[n];const s=t.getColumn(n);return s!=null&&s.columnDef.getGroupingValue?(e._groupingValuesCache[n]=s.columnDef.getGroupingValue(e.original),e._groupingValuesCache[n]):e.getValue(n)},e._groupingValuesCache={}},createCell:(e,t,n,s)=>{e.getIsGrouped=()=>t.getIsGrouped()&&t.id===n.groupingColumnId,e.getIsPlaceholder=()=>!e.getIsGrouped()&&t.getIsGrouped(),e.getIsAggregated=()=>{var a;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!((a=n.subRows)!=null&&a.length)}}};function orderColumns(e,t,n){if(!(t!=null&&t.length)||!n)return e;const s=e.filter(o=>!t.includes(o.id));return n==="remove"?s:[...t.map(o=>e.find(l=>l.id===o)).filter(Boolean),...s]}const ColumnOrdering={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:makeStateUpdater("columnOrder",e)}),createColumn:(e,t)=>{e.getIndex=memo(n=>[_getVisibleLeafColumns(t,n)],n=>n.findIndex(s=>s.id===e.id),getMemoOptions(t.options,"debugColumns","getIndex")),e.getIsFirstColumn=n=>{var s;return((s=_getVisibleLeafColumns(t,n)[0])==null?void 0:s.id)===e.id},e.getIsLastColumn=n=>{var s;const a=_getVisibleLeafColumns(t,n);return((s=a[a.length-1])==null?void 0:s.id)===e.id}},createTable:e=>{e.setColumnOrder=t=>e.options.onColumnOrderChange==null?void 0:e.options.onColumnOrderChange(t),e.resetColumnOrder=t=>{var n;e.setColumnOrder(t?[]:(n=e.initialState.columnOrder)!=null?n:[])},e._getOrderColumnsFn=memo(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(t,n,s)=>a=>{let o=[];if(!(t!=null&&t.length))o=a;else{const l=[...t],c=[...a];for(;c.length&&l.length;){const d=l.shift(),f=c.findIndex(R=>R.id===d);f>-1&&o.push(c.splice(f,1)[0])}o=[...o,...c]}return orderColumns(o,n,s)},getMemoOptions(e.options,"debugTable","_getOrderColumnsFn"))}},getDefaultColumnPinningState=()=>({left:[],right:[]}),ColumnPinning={getInitialState:e=>({columnPinning:getDefaultColumnPinningState(),...e}),getDefaultOptions:e=>({onColumnPinningChange:makeStateUpdater("columnPinning",e)}),createColumn:(e,t)=>{e.pin=n=>{const s=e.getLeafColumns().map(a=>a.id).filter(Boolean);t.setColumnPinning(a=>{var o,l;if(n==="right"){var c,d;return{left:((c=a?.left)!=null?c:[]).filter(S=>!(s!=null&&s.includes(S))),right:[...((d=a?.right)!=null?d:[]).filter(S=>!(s!=null&&s.includes(S))),...s]}}if(n==="left"){var f,R;return{left:[...((f=a?.left)!=null?f:[]).filter(S=>!(s!=null&&s.includes(S))),...s],right:((R=a?.right)!=null?R:[]).filter(S=>!(s!=null&&s.includes(S)))}}return{left:((o=a?.left)!=null?o:[]).filter(S=>!(s!=null&&s.includes(S))),right:((l=a?.right)!=null?l:[]).filter(S=>!(s!=null&&s.includes(S)))}})},e.getCanPin=()=>e.getLeafColumns().some(s=>{var a,o,l;return((a=s.columnDef.enablePinning)!=null?a:!0)&&((o=(l=t.options.enableColumnPinning)!=null?l:t.options.enablePinning)!=null?o:!0)}),e.getIsPinned=()=>{const n=e.getLeafColumns().map(c=>c.id),{left:s,right:a}=t.getState().columnPinning,o=n.some(c=>s?.includes(c)),l=n.some(c=>a?.includes(c));return o?"left":l?"right":!1},e.getPinnedIndex=()=>{var n,s;const a=e.getIsPinned();return a?(n=(s=t.getState().columnPinning)==null||(s=s[a])==null?void 0:s.indexOf(e.id))!=null?n:-1:0}},createRow:(e,t)=>{e.getCenterVisibleCells=memo(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left,t.getState().columnPinning.right],(n,s,a)=>{const o=[...s??[],...a??[]];return n.filter(l=>!o.includes(l.column.id))},getMemoOptions(t.options,"debugRows","getCenterVisibleCells")),e.getLeftVisibleCells=memo(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left],(n,s)=>(s??[]).map(o=>n.find(l=>l.column.id===o)).filter(Boolean).map(o=>({...o,position:"left"})),getMemoOptions(t.options,"debugRows","getLeftVisibleCells")),e.getRightVisibleCells=memo(()=>[e._getAllVisibleCells(),t.getState().columnPinning.right],(n,s)=>(s??[]).map(o=>n.find(l=>l.column.id===o)).filter(Boolean).map(o=>({...o,position:"right"})),getMemoOptions(t.options,"debugRows","getRightVisibleCells"))},createTable:e=>{e.setColumnPinning=t=>e.options.onColumnPinningChange==null?void 0:e.options.onColumnPinningChange(t),e.resetColumnPinning=t=>{var n,s;return e.setColumnPinning(t?getDefaultColumnPinningState():(n=(s=e.initialState)==null?void 0:s.columnPinning)!=null?n:getDefaultColumnPinningState())},e.getIsSomeColumnsPinned=t=>{var n;const s=e.getState().columnPinning;if(!t){var a,o;return!!((a=s.left)!=null&&a.length||(o=s.right)!=null&&o.length)}return!!((n=s[t])!=null&&n.length)},e.getLeftLeafColumns=memo(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(t,n)=>(n??[]).map(s=>t.find(a=>a.id===s)).filter(Boolean),getMemoOptions(e.options,"debugColumns","getLeftLeafColumns")),e.getRightLeafColumns=memo(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(t,n)=>(n??[]).map(s=>t.find(a=>a.id===s)).filter(Boolean),getMemoOptions(e.options,"debugColumns","getRightLeafColumns")),e.getCenterLeafColumns=memo(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,s)=>{const a=[...n??[],...s??[]];return t.filter(o=>!a.includes(o.id))},getMemoOptions(e.options,"debugColumns","getCenterLeafColumns"))}};function safelyAccessDocument(e){return e||(typeof document<"u"?document:null)}const defaultColumnSizing={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},getDefaultColumnSizingInfoState=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),ColumnSizing={getDefaultColumnDef:()=>defaultColumnSizing,getInitialState:e=>({columnSizing:{},columnSizingInfo:getDefaultColumnSizingInfoState(),...e}),getDefaultOptions:e=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:makeStateUpdater("columnSizing",e),onColumnSizingInfoChange:makeStateUpdater("columnSizingInfo",e)}),createColumn:(e,t)=>{e.getSize=()=>{var n,s,a;const o=t.getState().columnSizing[e.id];return Math.min(Math.max((n=e.columnDef.minSize)!=null?n:defaultColumnSizing.minSize,(s=o??e.columnDef.size)!=null?s:defaultColumnSizing.size),(a=e.columnDef.maxSize)!=null?a:defaultColumnSizing.maxSize)},e.getStart=memo(n=>[n,_getVisibleLeafColumns(t,n),t.getState().columnSizing],(n,s)=>s.slice(0,e.getIndex(n)).reduce((a,o)=>a+o.getSize(),0),getMemoOptions(t.options,"debugColumns","getStart")),e.getAfter=memo(n=>[n,_getVisibleLeafColumns(t,n),t.getState().columnSizing],(n,s)=>s.slice(e.getIndex(n)+1).reduce((a,o)=>a+o.getSize(),0),getMemoOptions(t.options,"debugColumns","getAfter")),e.resetSize=()=>{t.setColumnSizing(n=>{let{[e.id]:s,...a}=n;return a})},e.getCanResize=()=>{var n,s;return((n=e.columnDef.enableResizing)!=null?n:!0)&&((s=t.options.enableColumnResizing)!=null?s:!0)},e.getIsResizing=()=>t.getState().columnSizingInfo.isResizingColumn===e.id},createHeader:(e,t)=>{e.getSize=()=>{let n=0;const s=a=>{if(a.subHeaders.length)a.subHeaders.forEach(s);else{var o;n+=(o=a.column.getSize())!=null?o:0}};return s(e),n},e.getStart=()=>{if(e.index>0){const n=e.headerGroup.headers[e.index-1];return n.getStart()+n.getSize()}return 0},e.getResizeHandler=n=>{const s=t.getColumn(e.column.id),a=s?.getCanResize();return o=>{if(!s||!a||(o.persist==null||o.persist(),isTouchStartEvent(o)&&o.touches&&o.touches.length>1))return;const l=e.getSize(),c=e?e.getLeafHeaders().map(at=>[at.column.id,at.column.getSize()]):[[s.id,s.getSize()]],d=isTouchStartEvent(o)?Math.round(o.touches[0].clientX):o.clientX,f={},R=(at,ot)=>{typeof ot=="number"&&(t.setColumnSizingInfo(lt=>{var ut,ct;const dt=t.options.columnResizeDirection==="rtl"?-1:1,pt=(ot-((ut=lt?.startOffset)!=null?ut:0))*dt,mt=Math.max(pt/((ct=lt?.startSize)!=null?ct:0),-.999999);return lt.columnSizingStart.forEach(Rt=>{let[yt,It]=Rt;f[yt]=Math.round(Math.max(It+It*mt,0)*100)/100}),{...lt,deltaOffset:pt,deltaPercentage:mt}}),(t.options.columnResizeMode==="onChange"||at==="end")&&t.setColumnSizing(lt=>({...lt,...f})))},S=at=>R("move",at),te=at=>{R("end",at),t.setColumnSizingInfo(ot=>({...ot,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},A=safelyAccessDocument(n),rt={moveHandler:at=>S(at.clientX),upHandler:at=>{A?.removeEventListener("mousemove",rt.moveHandler),A?.removeEventListener("mouseup",rt.upHandler),te(at.clientX)}},st={moveHandler:at=>(at.cancelable&&(at.preventDefault(),at.stopPropagation()),S(at.touches[0].clientX),!1),upHandler:at=>{var ot;A?.removeEventListener("touchmove",st.moveHandler),A?.removeEventListener("touchend",st.upHandler),at.cancelable&&(at.preventDefault(),at.stopPropagation()),te((ot=at.touches[0])==null?void 0:ot.clientX)}},it=passiveEventSupported()?{passive:!1}:!1;isTouchStartEvent(o)?(A?.addEventListener("touchmove",st.moveHandler,it),A?.addEventListener("touchend",st.upHandler,it)):(A?.addEventListener("mousemove",rt.moveHandler,it),A?.addEventListener("mouseup",rt.upHandler,it)),t.setColumnSizingInfo(at=>({...at,startOffset:d,startSize:l,deltaOffset:0,deltaPercentage:0,columnSizingStart:c,isResizingColumn:s.id}))}}},createTable:e=>{e.setColumnSizing=t=>e.options.onColumnSizingChange==null?void 0:e.options.onColumnSizingChange(t),e.setColumnSizingInfo=t=>e.options.onColumnSizingInfoChange==null?void 0:e.options.onColumnSizingInfoChange(t),e.resetColumnSizing=t=>{var n;e.setColumnSizing(t?{}:(n=e.initialState.columnSizing)!=null?n:{})},e.resetHeaderSizeInfo=t=>{var n;e.setColumnSizingInfo(t?getDefaultColumnSizingInfoState():(n=e.initialState.columnSizingInfo)!=null?n:getDefaultColumnSizingInfoState())},e.getTotalSize=()=>{var t,n;return(t=(n=e.getHeaderGroups()[0])==null?void 0:n.headers.reduce((s,a)=>s+a.getSize(),0))!=null?t:0},e.getLeftTotalSize=()=>{var t,n;return(t=(n=e.getLeftHeaderGroups()[0])==null?void 0:n.headers.reduce((s,a)=>s+a.getSize(),0))!=null?t:0},e.getCenterTotalSize=()=>{var t,n;return(t=(n=e.getCenterHeaderGroups()[0])==null?void 0:n.headers.reduce((s,a)=>s+a.getSize(),0))!=null?t:0},e.getRightTotalSize=()=>{var t,n;return(t=(n=e.getRightHeaderGroups()[0])==null?void 0:n.headers.reduce((s,a)=>s+a.getSize(),0))!=null?t:0}}};let passiveSupported=null;function passiveEventSupported(){if(typeof passiveSupported=="boolean")return passiveSupported;let e=!1;try{const t={get passive(){return e=!0,!1}},n=()=>{};window.addEventListener("test",n,t),window.removeEventListener("test",n)}catch{e=!1}return passiveSupported=e,passiveSupported}function isTouchStartEvent(e){return e.type==="touchstart"}const ColumnVisibility={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:makeStateUpdater("columnVisibility",e)}),createColumn:(e,t)=>{e.toggleVisibility=n=>{e.getCanHide()&&t.setColumnVisibility(s=>({...s,[e.id]:n??!e.getIsVisible()}))},e.getIsVisible=()=>{var n,s;const a=e.columns;return(n=a.length?a.some(o=>o.getIsVisible()):(s=t.getState().columnVisibility)==null?void 0:s[e.id])!=null?n:!0},e.getCanHide=()=>{var n,s;return((n=e.columnDef.enableHiding)!=null?n:!0)&&((s=t.options.enableHiding)!=null?s:!0)},e.getToggleVisibilityHandler=()=>n=>{e.toggleVisibility==null||e.toggleVisibility(n.target.checked)}},createRow:(e,t)=>{e._getAllVisibleCells=memo(()=>[e.getAllCells(),t.getState().columnVisibility],n=>n.filter(s=>s.column.getIsVisible()),getMemoOptions(t.options,"debugRows","_getAllVisibleCells")),e.getVisibleCells=memo(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(n,s,a)=>[...n,...s,...a],getMemoOptions(t.options,"debugRows","getVisibleCells"))},createTable:e=>{const t=(n,s)=>memo(()=>[s(),s().filter(a=>a.getIsVisible()).map(a=>a.id).join("_")],a=>a.filter(o=>o.getIsVisible==null?void 0:o.getIsVisible()),getMemoOptions(e.options,"debugColumns",n));e.getVisibleFlatColumns=t("getVisibleFlatColumns",()=>e.getAllFlatColumns()),e.getVisibleLeafColumns=t("getVisibleLeafColumns",()=>e.getAllLeafColumns()),e.getLeftVisibleLeafColumns=t("getLeftVisibleLeafColumns",()=>e.getLeftLeafColumns()),e.getRightVisibleLeafColumns=t("getRightVisibleLeafColumns",()=>e.getRightLeafColumns()),e.getCenterVisibleLeafColumns=t("getCenterVisibleLeafColumns",()=>e.getCenterLeafColumns()),e.setColumnVisibility=n=>e.options.onColumnVisibilityChange==null?void 0:e.options.onColumnVisibilityChange(n),e.resetColumnVisibility=n=>{var s;e.setColumnVisibility(n?{}:(s=e.initialState.columnVisibility)!=null?s:{})},e.toggleAllColumnsVisible=n=>{var s;n=(s=n)!=null?s:!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((a,o)=>({...a,[o.id]:n||!(o.getCanHide!=null&&o.getCanHide())}),{}))},e.getIsAllColumnsVisible=()=>!e.getAllLeafColumns().some(n=>!(n.getIsVisible!=null&&n.getIsVisible())),e.getIsSomeColumnsVisible=()=>e.getAllLeafColumns().some(n=>n.getIsVisible==null?void 0:n.getIsVisible()),e.getToggleAllColumnsVisibilityHandler=()=>n=>{var s;e.toggleAllColumnsVisible((s=n.target)==null?void 0:s.checked)}}};function _getVisibleLeafColumns(e,t){return t?t==="center"?e.getCenterVisibleLeafColumns():t==="left"?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}const GlobalFaceting={createTable:e=>{e._getGlobalFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,"__global__"),e.getGlobalFacetedRowModel=()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),e._getGlobalFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,"__global__"),e.getGlobalFacetedUniqueValues=()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,e._getGlobalFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,"__global__"),e.getGlobalFacetedMinMaxValues=()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}}},GlobalFiltering={getInitialState:e=>({globalFilter:void 0,...e}),getDefaultOptions:e=>({onGlobalFilterChange:makeStateUpdater("globalFilter",e),globalFilterFn:"auto",getColumnCanGlobalFilter:t=>{var n;const s=(n=e.getCoreRowModel().flatRows[0])==null||(n=n._getAllCellsByColumnId()[t.id])==null?void 0:n.getValue();return typeof s=="string"||typeof s=="number"}}),createColumn:(e,t)=>{e.getCanGlobalFilter=()=>{var n,s,a,o;return((n=e.columnDef.enableGlobalFilter)!=null?n:!0)&&((s=t.options.enableGlobalFilter)!=null?s:!0)&&((a=t.options.enableFilters)!=null?a:!0)&&((o=t.options.getColumnCanGlobalFilter==null?void 0:t.options.getColumnCanGlobalFilter(e))!=null?o:!0)&&!!e.accessorFn}},createTable:e=>{e.getGlobalAutoFilterFn=()=>filterFns.includesString,e.getGlobalFilterFn=()=>{var t,n;const{globalFilterFn:s}=e.options;return isFunction$2(s)?s:s==="auto"?e.getGlobalAutoFilterFn():(t=(n=e.options.filterFns)==null?void 0:n[s])!=null?t:filterFns[s]},e.setGlobalFilter=t=>{e.options.onGlobalFilterChange==null||e.options.onGlobalFilterChange(t)},e.resetGlobalFilter=t=>{e.setGlobalFilter(t?void 0:e.initialState.globalFilter)}}},RowExpanding={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:makeStateUpdater("expanded",e),paginateExpandedRows:!0}),createTable:e=>{let t=!1,n=!1;e._autoResetExpanded=()=>{var s,a;if(!t){e._queue(()=>{t=!0});return}if((s=(a=e.options.autoResetAll)!=null?a:e.options.autoResetExpanded)!=null?s:!e.options.manualExpanding){if(n)return;n=!0,e._queue(()=>{e.resetExpanded(),n=!1})}},e.setExpanded=s=>e.options.onExpandedChange==null?void 0:e.options.onExpandedChange(s),e.toggleAllRowsExpanded=s=>{s??!e.getIsAllRowsExpanded()?e.setExpanded(!0):e.setExpanded({})},e.resetExpanded=s=>{var a,o;e.setExpanded(s?{}:(a=(o=e.initialState)==null?void 0:o.expanded)!=null?a:{})},e.getCanSomeRowsExpand=()=>e.getPrePaginationRowModel().flatRows.some(s=>s.getCanExpand()),e.getToggleAllRowsExpandedHandler=()=>s=>{s.persist==null||s.persist(),e.toggleAllRowsExpanded()},e.getIsSomeRowsExpanded=()=>{const s=e.getState().expanded;return s===!0||Object.values(s).some(Boolean)},e.getIsAllRowsExpanded=()=>{const s=e.getState().expanded;return typeof s=="boolean"?s===!0:!(!Object.keys(s).length||e.getRowModel().flatRows.some(a=>!a.getIsExpanded()))},e.getExpandedDepth=()=>{let s=0;return(e.getState().expanded===!0?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(o=>{const l=o.split(".");s=Math.max(s,l.length)}),s},e.getPreExpandedRowModel=()=>e.getSortedRowModel(),e.getExpandedRowModel=()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel?e.getPreExpandedRowModel():e._getExpandedRowModel())},createRow:(e,t)=>{e.toggleExpanded=n=>{t.setExpanded(s=>{var a;const o=s===!0?!0:!!(s!=null&&s[e.id]);let l={};if(s===!0?Object.keys(t.getRowModel().rowsById).forEach(c=>{l[c]=!0}):l=s,n=(a=n)!=null?a:!o,!o&&n)return{...l,[e.id]:!0};if(o&&!n){const{[e.id]:c,...d}=l;return d}return s})},e.getIsExpanded=()=>{var n;const s=t.getState().expanded;return!!((n=t.options.getIsRowExpanded==null?void 0:t.options.getIsRowExpanded(e))!=null?n:s===!0||s?.[e.id])},e.getCanExpand=()=>{var n,s,a;return(n=t.options.getRowCanExpand==null?void 0:t.options.getRowCanExpand(e))!=null?n:((s=t.options.enableExpanding)!=null?s:!0)&&!!((a=e.subRows)!=null&&a.length)},e.getIsAllParentsExpanded=()=>{let n=!0,s=e;for(;n&&s.parentId;)s=t.getRow(s.parentId,!0),n=s.getIsExpanded();return n},e.getToggleExpandedHandler=()=>{const n=e.getCanExpand();return()=>{n&&e.toggleExpanded()}}}},defaultPageIndex=0,defaultPageSize=10,getDefaultPaginationState=()=>({pageIndex:defaultPageIndex,pageSize:defaultPageSize}),RowPagination={getInitialState:e=>({...e,pagination:{...getDefaultPaginationState(),...e?.pagination}}),getDefaultOptions:e=>({onPaginationChange:makeStateUpdater("pagination",e)}),createTable:e=>{let t=!1,n=!1;e._autoResetPageIndex=()=>{var s,a;if(!t){e._queue(()=>{t=!0});return}if((s=(a=e.options.autoResetAll)!=null?a:e.options.autoResetPageIndex)!=null?s:!e.options.manualPagination){if(n)return;n=!0,e._queue(()=>{e.resetPageIndex(),n=!1})}},e.setPagination=s=>{const a=o=>functionalUpdate(s,o);return e.options.onPaginationChange==null?void 0:e.options.onPaginationChange(a)},e.resetPagination=s=>{var a;e.setPagination(s?getDefaultPaginationState():(a=e.initialState.pagination)!=null?a:getDefaultPaginationState())},e.setPageIndex=s=>{e.setPagination(a=>{let o=functionalUpdate(s,a.pageIndex);const l=typeof e.options.pageCount>"u"||e.options.pageCount===-1?Number.MAX_SAFE_INTEGER:e.options.pageCount-1;return o=Math.max(0,Math.min(o,l)),{...a,pageIndex:o}})},e.resetPageIndex=s=>{var a,o;e.setPageIndex(s?defaultPageIndex:(a=(o=e.initialState)==null||(o=o.pagination)==null?void 0:o.pageIndex)!=null?a:defaultPageIndex)},e.resetPageSize=s=>{var a,o;e.setPageSize(s?defaultPageSize:(a=(o=e.initialState)==null||(o=o.pagination)==null?void 0:o.pageSize)!=null?a:defaultPageSize)},e.setPageSize=s=>{e.setPagination(a=>{const o=Math.max(1,functionalUpdate(s,a.pageSize)),l=a.pageSize*a.pageIndex,c=Math.floor(l/o);return{...a,pageIndex:c,pageSize:o}})},e.setPageCount=s=>e.setPagination(a=>{var o;let l=functionalUpdate(s,(o=e.options.pageCount)!=null?o:-1);return typeof l=="number"&&(l=Math.max(-1,l)),{...a,pageCount:l}}),e.getPageOptions=memo(()=>[e.getPageCount()],s=>{let a=[];return s&&s>0&&(a=[...new Array(s)].fill(null).map((o,l)=>l)),a},getMemoOptions(e.options,"debugTable","getPageOptions")),e.getCanPreviousPage=()=>e.getState().pagination.pageIndex>0,e.getCanNextPage=()=>{const{pageIndex:s}=e.getState().pagination,a=e.getPageCount();return a===-1?!0:a===0?!1:s<a-1},e.previousPage=()=>e.setPageIndex(s=>s-1),e.nextPage=()=>e.setPageIndex(s=>s+1),e.firstPage=()=>e.setPageIndex(0),e.lastPage=()=>e.setPageIndex(e.getPageCount()-1),e.getPrePaginationRowModel=()=>e.getExpandedRowModel(),e.getPaginationRowModel=()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel?e.getPrePaginationRowModel():e._getPaginationRowModel()),e.getPageCount=()=>{var s;return(s=e.options.pageCount)!=null?s:Math.ceil(e.getRowCount()/e.getState().pagination.pageSize)},e.getRowCount=()=>{var s;return(s=e.options.rowCount)!=null?s:e.getPrePaginationRowModel().rows.length}}},getDefaultRowPinningState=()=>({top:[],bottom:[]}),RowPinning={getInitialState:e=>({rowPinning:getDefaultRowPinningState(),...e}),getDefaultOptions:e=>({onRowPinningChange:makeStateUpdater("rowPinning",e)}),createRow:(e,t)=>{e.pin=(n,s,a)=>{const o=s?e.getLeafRows().map(d=>{let{id:f}=d;return f}):[],l=a?e.getParentRows().map(d=>{let{id:f}=d;return f}):[],c=new Set([...l,e.id,...o]);t.setRowPinning(d=>{var f,R;if(n==="bottom"){var S,te;return{top:((S=d?.top)!=null?S:[]).filter(st=>!(c!=null&&c.has(st))),bottom:[...((te=d?.bottom)!=null?te:[]).filter(st=>!(c!=null&&c.has(st))),...Array.from(c)]}}if(n==="top"){var A,rt;return{top:[...((A=d?.top)!=null?A:[]).filter(st=>!(c!=null&&c.has(st))),...Array.from(c)],bottom:((rt=d?.bottom)!=null?rt:[]).filter(st=>!(c!=null&&c.has(st)))}}return{top:((f=d?.top)!=null?f:[]).filter(st=>!(c!=null&&c.has(st))),bottom:((R=d?.bottom)!=null?R:[]).filter(st=>!(c!=null&&c.has(st)))}})},e.getCanPin=()=>{var n;const{enableRowPinning:s,enablePinning:a}=t.options;return typeof s=="function"?s(e):(n=s??a)!=null?n:!0},e.getIsPinned=()=>{const n=[e.id],{top:s,bottom:a}=t.getState().rowPinning,o=n.some(c=>s?.includes(c)),l=n.some(c=>a?.includes(c));return o?"top":l?"bottom":!1},e.getPinnedIndex=()=>{var n,s;const a=e.getIsPinned();if(!a)return-1;const o=(n=a==="top"?t.getTopRows():t.getBottomRows())==null?void 0:n.map(l=>{let{id:c}=l;return c});return(s=o?.indexOf(e.id))!=null?s:-1}},createTable:e=>{e.setRowPinning=t=>e.options.onRowPinningChange==null?void 0:e.options.onRowPinningChange(t),e.resetRowPinning=t=>{var n,s;return e.setRowPinning(t?getDefaultRowPinningState():(n=(s=e.initialState)==null?void 0:s.rowPinning)!=null?n:getDefaultRowPinningState())},e.getIsSomeRowsPinned=t=>{var n;const s=e.getState().rowPinning;if(!t){var a,o;return!!((a=s.top)!=null&&a.length||(o=s.bottom)!=null&&o.length)}return!!((n=s[t])!=null&&n.length)},e._getPinnedRows=(t,n,s)=>{var a;return((a=e.options.keepPinnedRows)==null||a?(n??[]).map(l=>{const c=e.getRow(l,!0);return c.getIsAllParentsExpanded()?c:null}):(n??[]).map(l=>t.find(c=>c.id===l))).filter(Boolean).map(l=>({...l,position:s}))},e.getTopRows=memo(()=>[e.getRowModel().rows,e.getState().rowPinning.top],(t,n)=>e._getPinnedRows(t,n,"top"),getMemoOptions(e.options,"debugRows","getTopRows")),e.getBottomRows=memo(()=>[e.getRowModel().rows,e.getState().rowPinning.bottom],(t,n)=>e._getPinnedRows(t,n,"bottom"),getMemoOptions(e.options,"debugRows","getBottomRows")),e.getCenterRows=memo(()=>[e.getRowModel().rows,e.getState().rowPinning.top,e.getState().rowPinning.bottom],(t,n,s)=>{const a=new Set([...n??[],...s??[]]);return t.filter(o=>!a.has(o.id))},getMemoOptions(e.options,"debugRows","getCenterRows"))}},RowSelection={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:makeStateUpdater("rowSelection",e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>{e.setRowSelection=t=>e.options.onRowSelectionChange==null?void 0:e.options.onRowSelectionChange(t),e.resetRowSelection=t=>{var n;return e.setRowSelection(t?{}:(n=e.initialState.rowSelection)!=null?n:{})},e.toggleAllRowsSelected=t=>{e.setRowSelection(n=>{t=typeof t<"u"?t:!e.getIsAllRowsSelected();const s={...n},a=e.getPreGroupedRowModel().flatRows;return t?a.forEach(o=>{o.getCanSelect()&&(s[o.id]=!0)}):a.forEach(o=>{delete s[o.id]}),s})},e.toggleAllPageRowsSelected=t=>e.setRowSelection(n=>{const s=typeof t<"u"?t:!e.getIsAllPageRowsSelected(),a={...n};return e.getRowModel().rows.forEach(o=>{mutateRowIsSelected(a,o.id,s,!0,e)}),a}),e.getPreSelectedRowModel=()=>e.getCoreRowModel(),e.getSelectedRowModel=memo(()=>[e.getState().rowSelection,e.getCoreRowModel()],(t,n)=>Object.keys(t).length?selectRowsFn(e,n):{rows:[],flatRows:[],rowsById:{}},getMemoOptions(e.options,"debugTable","getSelectedRowModel")),e.getFilteredSelectedRowModel=memo(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(t,n)=>Object.keys(t).length?selectRowsFn(e,n):{rows:[],flatRows:[],rowsById:{}},getMemoOptions(e.options,"debugTable","getFilteredSelectedRowModel")),e.getGroupedSelectedRowModel=memo(()=>[e.getState().rowSelection,e.getSortedRowModel()],(t,n)=>Object.keys(t).length?selectRowsFn(e,n):{rows:[],flatRows:[],rowsById:{}},getMemoOptions(e.options,"debugTable","getGroupedSelectedRowModel")),e.getIsAllRowsSelected=()=>{const t=e.getFilteredRowModel().flatRows,{rowSelection:n}=e.getState();let s=!!(t.length&&Object.keys(n).length);return s&&t.some(a=>a.getCanSelect()&&!n[a.id])&&(s=!1),s},e.getIsAllPageRowsSelected=()=>{const t=e.getPaginationRowModel().flatRows.filter(a=>a.getCanSelect()),{rowSelection:n}=e.getState();let s=!!t.length;return s&&t.some(a=>!n[a.id])&&(s=!1),s},e.getIsSomeRowsSelected=()=>{var t;const n=Object.keys((t=e.getState().rowSelection)!=null?t:{}).length;return n>0&&n<e.getFilteredRowModel().flatRows.length},e.getIsSomePageRowsSelected=()=>{const t=e.getPaginationRowModel().flatRows;return e.getIsAllPageRowsSelected()?!1:t.filter(n=>n.getCanSelect()).some(n=>n.getIsSelected()||n.getIsSomeSelected())},e.getToggleAllRowsSelectedHandler=()=>t=>{e.toggleAllRowsSelected(t.target.checked)},e.getToggleAllPageRowsSelectedHandler=()=>t=>{e.toggleAllPageRowsSelected(t.target.checked)}},createRow:(e,t)=>{e.toggleSelected=(n,s)=>{const a=e.getIsSelected();t.setRowSelection(o=>{var l;if(n=typeof n<"u"?n:!a,e.getCanSelect()&&a===n)return o;const c={...o};return mutateRowIsSelected(c,e.id,n,(l=s?.selectChildren)!=null?l:!0,t),c})},e.getIsSelected=()=>{const{rowSelection:n}=t.getState();return isRowSelected(e,n)},e.getIsSomeSelected=()=>{const{rowSelection:n}=t.getState();return isSubRowSelected(e,n)==="some"},e.getIsAllSubRowsSelected=()=>{const{rowSelection:n}=t.getState();return isSubRowSelected(e,n)==="all"},e.getCanSelect=()=>{var n;return typeof t.options.enableRowSelection=="function"?t.options.enableRowSelection(e):(n=t.options.enableRowSelection)!=null?n:!0},e.getCanSelectSubRows=()=>{var n;return typeof t.options.enableSubRowSelection=="function"?t.options.enableSubRowSelection(e):(n=t.options.enableSubRowSelection)!=null?n:!0},e.getCanMultiSelect=()=>{var n;return typeof t.options.enableMultiRowSelection=="function"?t.options.enableMultiRowSelection(e):(n=t.options.enableMultiRowSelection)!=null?n:!0},e.getToggleSelectedHandler=()=>{const n=e.getCanSelect();return s=>{var a;n&&e.toggleSelected((a=s.target)==null?void 0:a.checked)}}}},mutateRowIsSelected=(e,t,n,s,a)=>{var o;const l=a.getRow(t,!0);n?(l.getCanMultiSelect()||Object.keys(e).forEach(c=>delete e[c]),l.getCanSelect()&&(e[t]=!0)):delete e[t],s&&(o=l.subRows)!=null&&o.length&&l.getCanSelectSubRows()&&l.subRows.forEach(c=>mutateRowIsSelected(e,c.id,n,s,a))};function selectRowsFn(e,t){const n=e.getState().rowSelection,s=[],a={},o=function(l,c){return l.map(d=>{var f;const R=isRowSelected(d,n);if(R&&(s.push(d),a[d.id]=d),(f=d.subRows)!=null&&f.length&&(d={...d,subRows:o(d.subRows)}),R)return d}).filter(Boolean)};return{rows:o(t.rows),flatRows:s,rowsById:a}}function isRowSelected(e,t){var n;return(n=t[e.id])!=null?n:!1}function isSubRowSelected(e,t,n){var s;if(!((s=e.subRows)!=null&&s.length))return!1;let a=!0,o=!1;return e.subRows.forEach(l=>{if(!(o&&!a)&&(l.getCanSelect()&&(isRowSelected(l,t)?o=!0:a=!1),l.subRows&&l.subRows.length)){const c=isSubRowSelected(l,t);c==="all"?o=!0:(c==="some"&&(o=!0),a=!1)}}),a?"all":o?"some":!1}const reSplitAlphaNumeric=/([0-9]+)/gm,alphanumeric$1=(e,t,n)=>compareAlphanumeric(toString$1(e.getValue(n)).toLowerCase(),toString$1(t.getValue(n)).toLowerCase()),alphanumericCaseSensitive=(e,t,n)=>compareAlphanumeric(toString$1(e.getValue(n)),toString$1(t.getValue(n))),text=(e,t,n)=>compareBasic(toString$1(e.getValue(n)).toLowerCase(),toString$1(t.getValue(n)).toLowerCase()),textCaseSensitive=(e,t,n)=>compareBasic(toString$1(e.getValue(n)),toString$1(t.getValue(n))),datetime=(e,t,n)=>{const s=e.getValue(n),a=t.getValue(n);return s>a?1:s<a?-1:0},basic=(e,t,n)=>compareBasic(e.getValue(n),t.getValue(n));function compareBasic(e,t){return e===t?0:e>t?1:-1}function toString$1(e){return typeof e=="number"?isNaN(e)||e===1/0||e===-1/0?"":String(e):typeof e=="string"?e:""}function compareAlphanumeric(e,t){const n=e.split(reSplitAlphaNumeric).filter(Boolean),s=t.split(reSplitAlphaNumeric).filter(Boolean);for(;n.length&&s.length;){const a=n.shift(),o=s.shift(),l=parseInt(a,10),c=parseInt(o,10),d=[l,c].sort();if(isNaN(d[0])){if(a>o)return 1;if(o>a)return-1;continue}if(isNaN(d[1]))return isNaN(l)?-1:1;if(l>c)return 1;if(c>l)return-1}return n.length-s.length}const sortingFns={alphanumeric:alphanumeric$1,alphanumericCaseSensitive,text,textCaseSensitive,datetime,basic},RowSorting={getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:makeStateUpdater("sorting",e),isMultiSortEvent:t=>t.shiftKey}),createColumn:(e,t)=>{e.getAutoSortingFn=()=>{const n=t.getFilteredRowModel().flatRows.slice(10);let s=!1;for(const a of n){const o=a?.getValue(e.id);if(Object.prototype.toString.call(o)==="[object Date]")return sortingFns.datetime;if(typeof o=="string"&&(s=!0,o.split(reSplitAlphaNumeric).length>1))return sortingFns.alphanumeric}return s?sortingFns.text:sortingFns.basic},e.getAutoSortDir=()=>{const n=t.getFilteredRowModel().flatRows[0];return typeof n?.getValue(e.id)=="string"?"asc":"desc"},e.getSortingFn=()=>{var n,s;if(!e)throw new Error;return isFunction$2(e.columnDef.sortingFn)?e.columnDef.sortingFn:e.columnDef.sortingFn==="auto"?e.getAutoSortingFn():(n=(s=t.options.sortingFns)==null?void 0:s[e.columnDef.sortingFn])!=null?n:sortingFns[e.columnDef.sortingFn]},e.toggleSorting=(n,s)=>{const a=e.getNextSortingOrder(),o=typeof n<"u"&&n!==null;t.setSorting(l=>{const c=l?.find(A=>A.id===e.id),d=l?.findIndex(A=>A.id===e.id);let f=[],R,S=o?n:a==="desc";if(l!=null&&l.length&&e.getCanMultiSort()&&s?c?R="toggle":R="add":l!=null&&l.length&&d!==l.length-1?R="replace":c?R="toggle":R="replace",R==="toggle"&&(o||a||(R="remove")),R==="add"){var te;f=[...l,{id:e.id,desc:S}],f.splice(0,f.length-((te=t.options.maxMultiSortColCount)!=null?te:Number.MAX_SAFE_INTEGER))}else R==="toggle"?f=l.map(A=>A.id===e.id?{...A,desc:S}:A):R==="remove"?f=l.filter(A=>A.id!==e.id):f=[{id:e.id,desc:S}];return f})},e.getFirstSortDir=()=>{var n,s;return((n=(s=e.columnDef.sortDescFirst)!=null?s:t.options.sortDescFirst)!=null?n:e.getAutoSortDir()==="desc")?"desc":"asc"},e.getNextSortingOrder=n=>{var s,a;const o=e.getFirstSortDir(),l=e.getIsSorted();return l?l!==o&&((s=t.options.enableSortingRemoval)==null||s)&&(!(n&&(a=t.options.enableMultiRemove)!=null)||a)?!1:l==="desc"?"asc":"desc":o},e.getCanSort=()=>{var n,s;return((n=e.columnDef.enableSorting)!=null?n:!0)&&((s=t.options.enableSorting)!=null?s:!0)&&!!e.accessorFn},e.getCanMultiSort=()=>{var n,s;return(n=(s=e.columnDef.enableMultiSort)!=null?s:t.options.enableMultiSort)!=null?n:!!e.accessorFn},e.getIsSorted=()=>{var n;const s=(n=t.getState().sorting)==null?void 0:n.find(a=>a.id===e.id);return s?s.desc?"desc":"asc":!1},e.getSortIndex=()=>{var n,s;return(n=(s=t.getState().sorting)==null?void 0:s.findIndex(a=>a.id===e.id))!=null?n:-1},e.clearSorting=()=>{t.setSorting(n=>n!=null&&n.length?n.filter(s=>s.id!==e.id):[])},e.getToggleSortingHandler=()=>{const n=e.getCanSort();return s=>{n&&(s.persist==null||s.persist(),e.toggleSorting==null||e.toggleSorting(void 0,e.getCanMultiSort()?t.options.isMultiSortEvent==null?void 0:t.options.isMultiSortEvent(s):!1))}}},createTable:e=>{e.setSorting=t=>e.options.onSortingChange==null?void 0:e.options.onSortingChange(t),e.resetSorting=t=>{var n,s;e.setSorting(t?[]:(n=(s=e.initialState)==null?void 0:s.sorting)!=null?n:[])},e.getPreSortedRowModel=()=>e.getGroupedRowModel(),e.getSortedRowModel=()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel?e.getPreSortedRowModel():e._getSortedRowModel())}},builtInFeatures=[Headers$1,ColumnVisibility,ColumnOrdering,ColumnPinning,ColumnFaceting,ColumnFiltering,GlobalFaceting,GlobalFiltering,RowSorting,ColumnGrouping,RowExpanding,RowPagination,RowPinning,RowSelection,ColumnSizing];function createTable(e){var t,n;process.env.NODE_ENV!=="production"&&(e.debugAll||e.debugTable)&&console.info("Creating Table Instance...");const s=[...builtInFeatures,...(t=e._features)!=null?t:[]];let a={_features:s};const o=a._features.reduce((te,A)=>Object.assign(te,A.getDefaultOptions==null?void 0:A.getDefaultOptions(a)),{}),l=te=>a.options.mergeOptions?a.options.mergeOptions(o,te):{...o,...te};let d={...{},...(n=e.initialState)!=null?n:{}};a._features.forEach(te=>{var A;d=(A=te.getInitialState==null?void 0:te.getInitialState(d))!=null?A:d});const f=[];let R=!1;const S={_features:s,options:{...o,...e},initialState:d,_queue:te=>{f.push(te),R||(R=!0,Promise.resolve().then(()=>{for(;f.length;)f.shift()();R=!1}).catch(A=>setTimeout(()=>{throw A})))},reset:()=>{a.setState(a.initialState)},setOptions:te=>{const A=functionalUpdate(te,a.options);a.options=l(A)},getState:()=>a.options.state,setState:te=>{a.options.onStateChange==null||a.options.onStateChange(te)},_getRowId:(te,A,rt)=>{var st;return(st=a.options.getRowId==null?void 0:a.options.getRowId(te,A,rt))!=null?st:`${rt?[rt.id,A].join("."):A}`},getCoreRowModel:()=>(a._getCoreRowModel||(a._getCoreRowModel=a.options.getCoreRowModel(a)),a._getCoreRowModel()),getRowModel:()=>a.getPaginationRowModel(),getRow:(te,A)=>{let rt=(A?a.getPrePaginationRowModel():a.getRowModel()).rowsById[te];if(!rt&&(rt=a.getCoreRowModel().rowsById[te],!rt))throw process.env.NODE_ENV!=="production"?new Error(`getRow could not find row with ID: ${te}`):new Error;return rt},_getDefaultColumnDef:memo(()=>[a.options.defaultColumn],te=>{var A;return te=(A=te)!=null?A:{},{header:rt=>{const st=rt.header.column.columnDef;return st.accessorKey?st.accessorKey:st.accessorFn?st.id:null},cell:rt=>{var st,it;return(st=(it=rt.renderValue())==null||it.toString==null?void 0:it.toString())!=null?st:null},...a._features.reduce((rt,st)=>Object.assign(rt,st.getDefaultColumnDef==null?void 0:st.getDefaultColumnDef()),{}),...te}},getMemoOptions(e,"debugColumns","_getDefaultColumnDef")),_getColumnDefs:()=>a.options.columns,getAllColumns:memo(()=>[a._getColumnDefs()],te=>{const A=function(rt,st,it){return it===void 0&&(it=0),rt.map(at=>{const ot=createColumn(a,at,it,st),lt=at;return ot.columns=lt.columns?A(lt.columns,ot,it+1):[],ot})};return A(te)},getMemoOptions(e,"debugColumns","getAllColumns")),getAllFlatColumns:memo(()=>[a.getAllColumns()],te=>te.flatMap(A=>A.getFlatColumns()),getMemoOptions(e,"debugColumns","getAllFlatColumns")),_getAllFlatColumnsById:memo(()=>[a.getAllFlatColumns()],te=>te.reduce((A,rt)=>(A[rt.id]=rt,A),{}),getMemoOptions(e,"debugColumns","getAllFlatColumnsById")),getAllLeafColumns:memo(()=>[a.getAllColumns(),a._getOrderColumnsFn()],(te,A)=>{let rt=te.flatMap(st=>st.getLeafColumns());return A(rt)},getMemoOptions(e,"debugColumns","getAllLeafColumns")),getColumn:te=>{const A=a._getAllFlatColumnsById()[te];return process.env.NODE_ENV!=="production"&&!A&&console.error(`[Table] Column with id '${te}' does not exist.`),A}};Object.assign(a,S);for(let te=0;te<a._features.length;te++){const A=a._features[te];A==null||A.createTable==null||A.createTable(a)}return a}function getCoreRowModel(){return e=>memo(()=>[e.options.data],t=>{const n={rows:[],flatRows:[],rowsById:{}},s=function(a,o,l){o===void 0&&(o=0);const c=[];for(let f=0;f<a.length;f++){const R=createRow(e,e._getRowId(a[f],f,l),a[f],f,o,void 0,l?.id);if(n.flatRows.push(R),n.rowsById[R.id]=R,c.push(R),e.options.getSubRows){var d;R.originalSubRows=e.options.getSubRows(a[f],f),(d=R.originalSubRows)!=null&&d.length&&(R.subRows=s(R.originalSubRows,o+1,R))}}return c};return n.rows=s(t),n},getMemoOptions(e.options,"debugTable","getRowModel",()=>e._autoResetPageIndex()))}function expandRows(e){const t=[],n=s=>{var a;t.push(s),(a=s.subRows)!=null&&a.length&&s.getIsExpanded()&&s.subRows.forEach(n)};return e.rows.forEach(n),{rows:t,flatRows:e.flatRows,rowsById:e.rowsById}}function filterRows(e,t,n){return n.options.filterFromLeafRows?filterRowModelFromLeafs(e,t,n):filterRowModelFromRoot(e,t,n)}function filterRowModelFromLeafs(e,t,n){var s;const a=[],o={},l=(s=n.options.maxLeafRowFilterDepth)!=null?s:100,c=function(d,f){f===void 0&&(f=0);const R=[];for(let te=0;te<d.length;te++){var S;let A=d[te];const rt=createRow(n,A.id,A.original,A.index,A.depth,void 0,A.parentId);if(rt.columnFilters=A.columnFilters,(S=A.subRows)!=null&&S.length&&f<l){if(rt.subRows=c(A.subRows,f+1),A=rt,t(A)&&!rt.subRows.length){R.push(A),o[A.id]=A,a.push(A);continue}if(t(A)||rt.subRows.length){R.push(A),o[A.id]=A,a.push(A);continue}}else A=rt,t(A)&&(R.push(A),o[A.id]=A,a.push(A))}return R};return{rows:c(e),flatRows:a,rowsById:o}}function filterRowModelFromRoot(e,t,n){var s;const a=[],o={},l=(s=n.options.maxLeafRowFilterDepth)!=null?s:100,c=function(d,f){f===void 0&&(f=0);const R=[];for(let te=0;te<d.length;te++){let A=d[te];if(t(A)){var S;if((S=A.subRows)!=null&&S.length&&f<l){const st=createRow(n,A.id,A.original,A.index,A.depth,void 0,A.parentId);st.subRows=c(A.subRows,f+1),A=st}R.push(A),a.push(A),o[A.id]=A}}return R};return{rows:c(e),flatRows:a,rowsById:o}}function getFilteredRowModel(){return e=>memo(()=>[e.getPreFilteredRowModel(),e.getState().columnFilters,e.getState().globalFilter],(t,n,s)=>{if(!t.rows.length||!(n!=null&&n.length)&&!s){for(let te=0;te<t.flatRows.length;te++)t.flatRows[te].columnFilters={},t.flatRows[te].columnFiltersMeta={};return t}const a=[],o=[];(n??[]).forEach(te=>{var A;const rt=e.getColumn(te.id);if(!rt)return;const st=rt.getFilterFn();if(!st){process.env.NODE_ENV!=="production"&&console.warn(`Could not find a valid 'column.filterFn' for column with the ID: ${rt.id}.`);return}a.push({id:te.id,filterFn:st,resolvedValue:(A=st.resolveFilterValue==null?void 0:st.resolveFilterValue(te.value))!=null?A:te.value})});const l=(n??[]).map(te=>te.id),c=e.getGlobalFilterFn(),d=e.getAllLeafColumns().filter(te=>te.getCanGlobalFilter());s&&c&&d.length&&(l.push("__global__"),d.forEach(te=>{var A;o.push({id:te.id,filterFn:c,resolvedValue:(A=c.resolveFilterValue==null?void 0:c.resolveFilterValue(s))!=null?A:s})}));let f,R;for(let te=0;te<t.flatRows.length;te++){const A=t.flatRows[te];if(A.columnFilters={},a.length)for(let rt=0;rt<a.length;rt++){f=a[rt];const st=f.id;A.columnFilters[st]=f.filterFn(A,st,f.resolvedValue,it=>{A.columnFiltersMeta[st]=it})}if(o.length){for(let rt=0;rt<o.length;rt++){R=o[rt];const st=R.id;if(R.filterFn(A,st,R.resolvedValue,it=>{A.columnFiltersMeta[st]=it})){A.columnFilters.__global__=!0;break}}A.columnFilters.__global__!==!0&&(A.columnFilters.__global__=!1)}}const S=te=>{for(let A=0;A<l.length;A++)if(te.columnFilters[l[A]]===!1)return!1;return!0};return filterRows(t.rows,S,e)},getMemoOptions(e.options,"debugTable","getFilteredRowModel",()=>e._autoResetPageIndex()))}function getPaginationRowModel(e){return t=>memo(()=>[t.getState().pagination,t.getPrePaginationRowModel(),t.options.paginateExpandedRows?void 0:t.getState().expanded],(n,s)=>{if(!s.rows.length)return s;const{pageSize:a,pageIndex:o}=n;let{rows:l,flatRows:c,rowsById:d}=s;const f=a*o,R=f+a;l=l.slice(f,R);let S;t.options.paginateExpandedRows?S={rows:l,flatRows:c,rowsById:d}:S=expandRows({rows:l,flatRows:c,rowsById:d}),S.flatRows=[];const te=A=>{S.flatRows.push(A),A.subRows.length&&A.subRows.forEach(te)};return S.rows.forEach(te),S},getMemoOptions(t.options,"debugTable","getPaginationRowModel"))}function getSortedRowModel(){return e=>memo(()=>[e.getState().sorting,e.getPreSortedRowModel()],(t,n)=>{if(!n.rows.length||!(t!=null&&t.length))return n;const s=e.getState().sorting,a=[],o=s.filter(d=>{var f;return(f=e.getColumn(d.id))==null?void 0:f.getCanSort()}),l={};o.forEach(d=>{const f=e.getColumn(d.id);f&&(l[d.id]={sortUndefined:f.columnDef.sortUndefined,invertSorting:f.columnDef.invertSorting,sortingFn:f.getSortingFn()})});const c=d=>{const f=d.map(R=>({...R}));return f.sort((R,S)=>{for(let A=0;A<o.length;A+=1){var te;const rt=o[A],st=l[rt.id],it=st.sortUndefined,at=(te=rt?.desc)!=null?te:!1;let ot=0;if(it){const lt=R.getValue(rt.id),ut=S.getValue(rt.id),ct=lt===void 0,dt=ut===void 0;if(ct||dt){if(it==="first")return ct?-1:1;if(it==="last")return ct?1:-1;ot=ct&&dt?0:ct?it:-it}}if(ot===0&&(ot=st.sortingFn(R,S,rt.id)),ot!==0)return at&&(ot*=-1),st.invertSorting&&(ot*=-1),ot}return R.index-S.index}),f.forEach(R=>{var S;a.push(R),(S=R.subRows)!=null&&S.length&&(R.subRows=c(R.subRows))}),f};return{rows:c(n.rows),flatRows:a,rowsById:n.rowsById}},getMemoOptions(e.options,"debugTable","getSortedRowModel",()=>e._autoResetPageIndex()))}function flexRender(e,t){return e?isReactComponent(e)?React__namespace.createElement(e,t):e:null}function isReactComponent(e){return isClassComponent(e)||typeof e=="function"||isExoticComponent(e)}function isClassComponent(e){return typeof e=="function"&&(()=>{const t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function isExoticComponent(e){return typeof e=="object"&&typeof e.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(e.$$typeof.description)}function useReactTable(e){const t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[n]=React__namespace.useState(()=>({current:createTable(t)})),[s,a]=React__namespace.useState(()=>n.current.initialState);return n.current.setOptions(o=>({...o,...e,state:{...s,...e.state},onStateChange:l=>{a(l),e.onStateChange==null||e.onStateChange(l)}})),n.current}function DataTable({columns:e,data:t,uniqueValues:n,tableClass:s,loading:a,initialSort:o}){const[l,c]=React.useState(o??[]),[d,f]=React.useState([]),[R,S]=React.useState({pageIndex:0,pageSize:10}),[te,A]=React.useState(null),rt=useReactTable({data:a?[]:t,columns:e,getCoreRowModel:getCoreRowModel(),onSortingChange:c,getSortedRowModel:getSortedRowModel(),onColumnFiltersChange:f,getFilteredRowModel:getFilteredRowModel(),getPaginationRowModel:getPaginationRowModel(),onPaginationChange:S,state:{sorting:l,columnFilters:d,pagination:R},manualPagination:a,manualSorting:a,manualFiltering:a}),st=(it,at)=>{it.toggleSorting(at),A(null)};return a?jsxRuntime.jsxs("div",{className:"@container space-y-4",children:[jsxRuntime.jsx("div",{className:`rounded-md border ${s??""}`,children:jsxRuntime.jsxs(Table,{children:[jsxRuntime.jsx(TableHeader,{children:jsxRuntime.jsx(TableRow,{children:e.map((it,at)=>jsxRuntime.jsx(TableHead,{children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-full"})},`skeleton-header-${at}`))})}),jsxRuntime.jsx(TableBody,{children:Array.from({length:R.pageSize}).map((it,at)=>jsxRuntime.jsx(TableRow,{children:e.map((ot,lt)=>jsxRuntime.jsx(TableCell,{children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-full"})},`skeleton-cell-${at}-${lt}`))},`skeleton-row-${at}`))})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center gap-4 @[35rem]:flex-row @[35rem]:justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-[110px]"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-[70px]"})]}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"hidden h-8 w-8 lg:flex"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-12"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-8"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-8"})]}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8"}),jsxRuntime.jsx(Skeleton,{className:"hidden h-8 w-8 lg:flex"})]})]})]}):jsxRuntime.jsxs("div",{className:"@container space-y-4",children:[jsxRuntime.jsxs(ScrollArea,{className:`rounded-md border ${s??""}`,children:[jsxRuntime.jsxs(Table,{children:[jsxRuntime.jsx(TableHeader,{children:rt.getHeaderGroups().map(it=>jsxRuntime.jsx(TableRow,{children:it.headers.map(at=>jsxRuntime.jsx(TableHead,{children:at.isPlaceholder?null:at.column.getCanSort()||at.column.getCanFilter()?jsxRuntime.jsxs(Popover,{open:te===at.id,onOpenChange:ot=>A(ot?at.id:null),children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"ghost",className:"pl-0",children:[flexRender(at.column.columnDef.header,at.getContext()),at.column.getIsFiltered()?jsxRuntime.jsx(Funnel,{className:"ml-2 h-4 w-4"}):at.column.getIsSorted()==="asc"?jsxRuntime.jsx(ArrowUp,{className:"ml-2 h-4 w-4"}):at.column.getIsSorted()==="desc"?jsxRuntime.jsx(ArrowDown,{className:"ml-2 h-4 w-4"}):jsxRuntime.jsx(ArrowUpDown,{className:"ml-2 h-4 w-4"})]})}),jsxRuntime.jsx(PopoverContent,{className:"w-56",children:jsxRuntime.jsxs("div",{className:"space-y-2",children:[at.column.getCanSort()&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button$1,{variant:"ghost",className:"w-full justify-start",onClick:()=>st(at.column,!1),children:[jsxRuntime.jsx(ArrowUp,{className:"mr-2 h-4 w-4"}),"Sort Ascending"]}),jsxRuntime.jsxs(Button$1,{variant:"ghost",className:"w-full justify-start",onClick:()=>st(at.column,!0),children:[jsxRuntime.jsx(ArrowDown,{className:"mr-2 h-4 w-4"}),"Sort Descending"]})]}),at.column.getCanFilter()&&jsxRuntime.jsx("div",{className:"px-2 py-1",children:n[at.column.id]?jsxRuntime.jsxs(Select$1,{onValueChange:ot=>at.column.setFilterValue(ot==="all"?void 0:[ot]),children:[jsxRuntime.jsx(SelectTrigger,{children:jsxRuntime.jsx(SelectValue,{placeholder:`Filter ${at.column.columnDef.header}...`})}),jsxRuntime.jsxs(SelectContent,{children:[jsxRuntime.jsx(SelectItem,{value:"all",children:"All"}),n[at.column.id]?.map(ot=>jsxRuntime.jsx(SelectItem,{value:ot||"empty",children:ot||"(Empty)"},ot))]})]}):jsxRuntime.jsx(Input,{placeholder:`Filter ${at.column.columnDef.header}...`,value:at.column.getFilterValue()??"",onChange:ot=>at.column.setFilterValue(ot.target.value),className:"w-full"})})]})})]}):jsxRuntime.jsx("div",{className:"py-2 px-4",children:flexRender(at.column.columnDef.header,at.getContext())})},at.id))},it.id))}),jsxRuntime.jsx(TableBody,{children:rt.getRowModel().rows?.length?rt.getRowModel().rows.map(it=>jsxRuntime.jsx(TableRow,{"data-state":it.getIsSelected()&&"selected",children:it.getVisibleCells().map(at=>jsxRuntime.jsx(TableCell,{children:flexRender(at.column.columnDef.cell,at.getContext())},at.id))},it.id)):jsxRuntime.jsx(TableRow,{children:jsxRuntime.jsx(TableCell,{colSpan:e.length,className:"h-24 text-center",children:"No results."})})})]}),jsxRuntime.jsx(ScrollBar,{orientation:"horizontal"})]}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center gap-4 @[35rem]:flex-row @[35rem]:justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("p",{className:"text-sm font-medium",children:"Rows per page"}),jsxRuntime.jsxs(Select$1,{value:`${rt.getState().pagination.pageSize}`,onValueChange:it=>{rt.setPageSize(Number(it))},children:[jsxRuntime.jsx(SelectTrigger,{className:"h-8 w-[70px]",children:jsxRuntime.jsx(SelectValue,{asChild:!0,children:jsxRuntime.jsx("span",{children:rt.getState().pagination.pageSize})})}),jsxRuntime.jsx(SelectContent,{side:"top",children:[10,20,30,40,50].map(it=>jsxRuntime.jsx(SelectItem,{value:`${it}`,children:jsxRuntime.jsx("span",{children:it})},it))})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsxs(Button$1,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>rt.setPageIndex(0),disabled:!rt.getCanPreviousPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to first page"}),jsxRuntime.jsx(ChevronsLeft,{className:"h-4 w-4"})]}),jsxRuntime.jsxs(Button$1,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>rt.previousPage(),disabled:!rt.getCanPreviousPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to previous page"}),jsxRuntime.jsx(ChevronLeft,{className:"h-4 w-4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("p",{className:"text-sm font-medium",children:"Page"}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:rt.getState().pagination.pageIndex+1}),jsxRuntime.jsx("p",{className:"text-sm font-medium",children:"of"}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:rt.getPageCount()})]}),jsxRuntime.jsxs(Button$1,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>rt.nextPage(),disabled:!rt.getCanNextPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to next page"}),jsxRuntime.jsx(ChevronRight,{className:"h-4 w-4"})]}),jsxRuntime.jsxs(Button$1,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>rt.setPageIndex(rt.getPageCount()-1),disabled:!rt.getCanNextPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to last page"}),jsxRuntime.jsx(ChevronsRight,{className:"h-4 w-4"})]})]})]})]})}function PartnerCard({account:e,action:t,loading:n=!1,className:s,withAbout:a=!1}){return n||!e?jsxRuntime.jsxs(Card,{className:`flex flex-col h-full ${s}`,children:[jsxRuntime.jsx(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-16"}),jsxRuntime.jsx(Skeleton,{className:"h-3 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-48 mt-1"})]})]})}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"})]}),a&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-full"})]})]})}),jsxRuntime.jsxs(CardFooter,{className:"px-6 py-4 flex justify-between gap-2 mt-auto",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-48"})]})]}):jsxRuntime.jsxs(Card,{className:`flex flex-col h-full ${s}`,children:[jsxRuntime.jsx(PartnerCardHeader,{type:"Partner",applicationId:e.ApplicationId,publicName:e.PublicName}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[(e.IsManufacturer||e.IsReseller||e.IsSalesAgency||e.HasShopifyStore||e.IsVendor)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.IsManufacturer&&jsxRuntime.jsx(Badge,{variant:"info",children:"Manufacturer"}),e.IsReseller&&jsxRuntime.jsx(Badge,{variant:"success",children:"Reseller"}),e.IsSalesAgency&&jsxRuntime.jsx(Badge,{variant:"outline",children:"Agency"}),e.HasShopifyStore&&jsxRuntime.jsx(Badge,{variant:"secondary",children:"Shopify"}),e.IsVendor&&jsxRuntime.jsx(Badge,{variant:"outline",children:"Vendor"})]}),a&&e.About&&jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:e.About??""}})]})}),jsxRuntime.jsx(CardFooter,{className:"px-6 py-4 flex justify-end gap-2 mt-auto",children:t||jsxRuntime.jsxs(Button$1,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4"}),"Go to Partner Dashboard"]})})]})}function ResellerCard({reseller:e,link:t,linkNewTab:n=!0,actions:s,mainAction:a,loading:o=!1}){if(o||!e)return jsxRuntime.jsxs(Card,{className:"flex flex-col h-full",children:[jsxRuntime.jsx(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-24 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"})]})]})}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsx("div",{className:"flex",children:jsxRuntime.jsxs("div",{className:"flex flex-col flex-1 space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-14 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-36"})]})]})]})})}),jsxRuntime.jsxs(CardFooter,{className:"flex justify-between pt-2 gap-2 mt-auto",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-40"})]})]});const l=[e.City,e.Province,e.Country].filter(Boolean),c=l.length>0?l.join(", "):"Location not provided",d=e.Priority?.trim(),f=!!e.Qualification?.QualificationId&&e.Qualification?.QualificationId!=="Suspended",R=!!e.OnHold&&e.OnHold!==0,S=!!d,te=A=>{const rt=A.toLowerCase();return rt.includes("starter")||rt.includes("basic")?"secondary":rt.includes("exclusive")||rt.includes("jean coutu")||rt.includes("novexco")||rt.includes("coopsco")?"success":"info"};return jsxRuntime.jsxs(Card,{className:"flex flex-col h-full",children:[jsxRuntime.jsx(PartnerCardHeader,{type:"Reseller",applicationId:e.ResellerId,publicName:e.PublicName,name:e.Name,location:c,link:t,linkNewTab:n,children:jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:e.SalesStatistics&&e.SalesStatistics.length>0&&jsxRuntime.jsx("div",{className:"h-16 w-24",children:jsxRuntime.jsx(SalesChart,{statistics:e.SalesStatistics,size:"mini"})})})}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex",children:[jsxRuntime.jsxs("div",{className:"flex flex-col flex-1 space-y-2",children:[(f||R||S)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[f&&jsxRuntime.jsx(QualificationBadge,{qualification:e.Qualification??{}}),R&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"}),S&&jsxRuntime.jsx(Badge,{variant:te(d),children:d})]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[e.Phone&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`tel:${e.Phone}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Phone,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Phone})]}),e.PublicEmail&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`mailto:${e.PublicEmail}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.PublicEmail})]}),e.Website&&jsxRuntime.jsxs(reactRouterDom.Link,{to:e.Website,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Globe,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Website})]}),e.CurrencyCode&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(DollarSign,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.CurrencyCode})]})]})]}),e?.SalesData&&jsxRuntime.jsxs("div",{className:"border-l pl-2 ml-2 flex flex-col text-sm",children:[jsxRuntime.jsx("strong",{className:"",children:"YTD"}),jsxRuntime.jsx("p",{children:e?.SalesData.SalesYearToDay?formatMoney(e?.SalesData.SalesYearToDay):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"3 mo."}),jsxRuntime.jsx("p",{children:e?.SalesData.SalesLast3Months?formatMoney(e?.SalesData.SalesLast3Months):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"30 days"}),jsxRuntime.jsx("p",{children:e?.SalesData.SalesLast30Days?formatMoney(e?.SalesData.SalesLast30Days):"—"})]})]})}),(s||a)&&jsxRuntime.jsxs(CardFooter,{className:"flex pt-2 gap-2 justify-between mt-auto",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:s&&s}),a&&jsxRuntime.jsx("div",{children:a})]})]})}const Table=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{className:"relative w-full overflow-auto",children:jsxRuntime.jsx("table",{ref:n,className:cn("w-full caption-bottom text-sm",e),...t})}));Table.displayName="Table";const TableHeader=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("thead",{ref:n,className:cn("[&_tr]:border-b",e),...t}));TableHeader.displayName="TableHeader";const TableBody=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("tbody",{ref:n,className:cn("[&_tr:last-child]:border-0",e),...t}));TableBody.displayName="TableBody";const TableFooter=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("tfoot",{ref:n,className:cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));TableFooter.displayName="TableFooter";const TableRow=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("tr",{ref:n,className:cn("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...t}));TableRow.displayName="TableRow";const TableHead=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("th",{ref:n,className:cn("h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t,children:React__namespace.isValidElement(t.children)&&t.children.type==="span"?t.children:jsxRuntime.jsx("span",{children:t.children})}));TableHead.displayName="TableHead";const TableCell=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("td",{ref:n,className:cn("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t,children:React__namespace.isValidElement(t.children)&&t.children.type==="span"?t.children:jsxRuntime.jsx("span",{children:t.children})}));TableCell.displayName="TableCell";const TableCaption=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("caption",{ref:n,className:cn("mt-4 text-sm text-muted-foreground",e),...t}));TableCaption.displayName="TableCaption";const APP_SHELL_HEADER_HEIGHT_TOKEN_CLASS="[--rm-shell-header-height:3.5rem]",APP_SHELL_HEADER_HEIGHT_CLASS="h-[var(--rm-shell-header-height)]",APP_SHELL_HEADER_OFFSET_CLASS="pt-[var(--rm-shell-header-height)]",Topbar=React.forwardRef(({onSignOut:e,handleValidSearch:t,rightMenu:n,searchPlaceholder:s},a)=>{const[o,l]=React.useState(""),c=reactRouterDom.useLocation(),{toast:d}=useToast();React.useEffect(()=>{const te=new URLSearchParams(c.search).get("q");te&&l(te)},[c.search]);const f=()=>{const S=o.trim();if(!S||S.length<2){d({title:"Enter more characters to search",description:"At least 2 characters are needed to search products.",variant:"destructive",duration:5e3});return}t(S)},R=S=>{S.key==="Enter"&&f()};return jsxRuntime.jsxs("header",{className:`fixed top-0 right-0 left-0 z-50 flex ${APP_SHELL_HEADER_HEIGHT_TOKEN_CLASS} ${APP_SHELL_HEADER_HEIGHT_CLASS} items-center gap-3 border-b border-primary/20 bg-primary px-4 text-primary-foreground transition-[left] duration-200 ease-linear lg:px-6 peer-data-[state=expanded]:lg:left-(--sidebar-width) peer-data-[collapsible=offcanvas]:lg:left-0 peer-data-[collapsible=icon]:lg:left-(--sidebar-width-icon)`,children:[jsxRuntime.jsx(SidebarTrigger,{className:"h-10 w-10 text-primary-foreground hover:bg-primary-foreground/15 hover:text-primary-foreground focus-visible:ring-primary-foreground focus-visible:ring-offset-primary lg:hidden",children:jsxRuntime.jsx(Menu$1,{className:"h-5 w-5"})}),jsxRuntime.jsx("div",{className:"flex flex-1 items-center gap-4",children:jsxRuntime.jsx("div",{className:"relative w-full max-w-sm",children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("button",{type:"button",className:"absolute left-1 top-1/2 inline-flex h-8 w-8 -translate-y-1/2 items-center justify-center rounded-md text-primary-foreground/90 transition-colors hover:bg-primary-foreground/15 hover:text-primary-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-foreground focus-visible:ring-offset-2 focus-visible:ring-offset-primary",onClick:f,"aria-label":"Search",children:jsxRuntime.jsx(Search,{className:"h-4 w-4"})}),jsxRuntime.jsx(Input,{placeholder:s??"Search...","aria-label":s??"Search",className:"h-10 w-full border-primary-foreground/35 bg-primary-foreground/12 pl-10 text-primary-foreground placeholder:text-primary-foreground/70 focus-visible:ring-primary-foreground focus-visible:ring-offset-primary",value:o,onChange:S=>l(S.target.value),onKeyDown:R,ref:a},"topbar-search")]})})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 text-primary-foreground [&_svg]:text-primary-foreground",children:[n,e&&jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs(Button$1,{variant:"ghost",size:"icon",className:"h-10 w-10 text-primary-foreground hover:bg-primary-foreground/15 hover:text-primary-foreground focus-visible:ring-primary-foreground focus-visible:ring-offset-primary",onClick:e,children:[jsxRuntime.jsx(LogOut,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{className:"sr-only",children:"Sign out"})]})})]})]})});Topbar.displayName="Topbar";function ActiveOrdersCard({orders:e,loading:t=!1}){const n=React.useMemo(()=>{if(!e||e.length===0)return{all:{orders:0,amount:0},processing:{orders:0,amount:0},shipped:{orders:0,amount:0},delayed:{orders:0,amount:0}};const a=e.filter(it=>it.DocumentType==="Order"),o=e.filter(it=>it.DocumentType==="Shipment"),l=a.filter(it=>it.WarehouseCode!=="3PLE"),c=l.reduce((it,at)=>it+(at.Quantity||0),0),d=l.reduce((it,at)=>it+(at.ExtendedPrice||0),0),f=a.filter(it=>it.WarehouseCode==="3PLE"),R=f.reduce((it,at)=>it+(at.Quantity||0),0),S=f.reduce((it,at)=>it+(at.ExtendedPrice||0),0),te=o.length,A=o.reduce((it,at)=>it+(at.ExtendedPrice||0),0),rt=c+R+te,st=d+S+A;return{all:{orders:rt,amount:st},processing:{orders:c,amount:d},shipped:{orders:te,amount:A},delayed:{orders:R,amount:S}}},[e]),s=[{name:"All",icon:Package,stripeClass:"bg-info/60",iconBgClass:"bg-info/90",iconTextClass:"text-info-foreground",orders:n.all.orders,amount:n.all.amount},{name:"Processing",icon:RefreshCcw,stripeClass:"bg-warning/60",iconBgClass:"bg-warning/90",iconTextClass:"text-warning-foreground",orders:n.processing.orders,amount:n.processing.amount},{name:"Shipped",icon:Truck,stripeClass:"bg-success/60",iconBgClass:"bg-success/90",iconTextClass:"text-success-foreground",orders:n.shipped.orders,amount:n.shipped.amount},{name:"Delayed",icon:CircleAlert,stripeClass:"bg-destructive/60",iconBgClass:"bg-destructive/90",iconTextClass:"text-destructive-foreground",orders:n.delayed.orders,amount:n.delayed.amount}];return t?jsxRuntime.jsxs(Card,{className:"@container",children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-base font-medium text-foreground",children:"Active Orders"})}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-4 p-4",children:[1,2,3,4].map(a=>jsxRuntime.jsxs("div",{className:"overflow-hidden rounded-md border",children:[jsxRuntime.jsx("div",{className:"bg-border h-[3px]"}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-16 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-7 w-12"})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-16 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]})]})]},a))})]}):jsxRuntime.jsxs(Card,{className:"@container",children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-base font-medium text-foreground",children:"Active Orders"})}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-4 p-4",children:s.map(a=>jsxRuntime.jsxs("div",{className:"overflow-hidden rounded-md border",children:[jsxRuntime.jsx("div",{className:`${a.stripeClass} h-[3px]`}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-base",children:a.name}),jsxRuntime.jsx("div",{className:`${a.iconBgClass} p-2 rounded-full`,children:jsxRuntime.jsx(a.icon,{className:`size-4 shrink-0 ${a.iconTextClass}`})})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Orders"}),jsxRuntime.jsx("p",{className:"text-xl font-bold",children:a.orders})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Amount"}),jsxRuntime.jsx("p",{className:"text-base font-semibold",children:formatMoney(a.amount)})]})]})]})]},a.name))})]})}var CHECKBOX_NAME="Checkbox",[createCheckboxContext]=createContextScope$2(CHECKBOX_NAME),[CheckboxProviderImpl,useCheckboxContext]=createCheckboxContext(CHECKBOX_NAME);function CheckboxProvider(e){const{__scopeCheckbox:t,checked:n,children:s,defaultChecked:a,disabled:o,form:l,name:c,onCheckedChange:d,required:f,value:R="on",internal_do_not_use_render:S}=e,[te,A]=useControllableState({prop:n,defaultProp:a??!1,onChange:d,caller:CHECKBOX_NAME}),[rt,st]=React__namespace.useState(null),[it,at]=React__namespace.useState(null),ot=React__namespace.useRef(!1),lt=rt?!!l||!!rt.closest("form"):!0,ut={checked:te,disabled:o,setChecked:A,control:rt,setControl:st,name:c,form:l,value:R,hasConsumerStoppedPropagationRef:ot,required:f,defaultChecked:isIndeterminate(a)?!1:a,isFormControl:lt,bubbleInput:it,setBubbleInput:at};return jsxRuntime.jsx(CheckboxProviderImpl,{scope:t,...ut,children:isFunction$1(S)?S(ut):s})}var TRIGGER_NAME$4="CheckboxTrigger",CheckboxTrigger=React__namespace.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...s},a)=>{const{control:o,value:l,disabled:c,checked:d,required:f,setControl:R,setChecked:S,hasConsumerStoppedPropagationRef:te,isFormControl:A,bubbleInput:rt}=useCheckboxContext(TRIGGER_NAME$4,e),st=useComposedRefs(a,R),it=React__namespace.useRef(d);return React__namespace.useEffect(()=>{const at=o?.form;if(at){const ot=()=>S(it.current);return at.addEventListener("reset",ot),()=>at.removeEventListener("reset",ot)}},[o,S]),jsxRuntime.jsx(Primitive$4.button,{type:"button",role:"checkbox","aria-checked":isIndeterminate(d)?"mixed":d,"aria-required":f,"data-state":getState$3(d),"data-disabled":c?"":void 0,disabled:c,value:l,...s,ref:st,onKeyDown:composeEventHandlers(t,at=>{at.key==="Enter"&&at.preventDefault()}),onClick:composeEventHandlers(n,at=>{S(ot=>isIndeterminate(ot)?!0:!ot),rt&&A&&(te.current=at.isPropagationStopped(),te.current||at.stopPropagation())})})});CheckboxTrigger.displayName=TRIGGER_NAME$4;var Checkbox$1=React__namespace.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:s,checked:a,defaultChecked:o,required:l,disabled:c,value:d,onCheckedChange:f,form:R,...S}=e;return jsxRuntime.jsx(CheckboxProvider,{__scopeCheckbox:n,checked:a,defaultChecked:o,disabled:c,required:l,onCheckedChange:f,name:s,form:R,value:d,internal_do_not_use_render:({isFormControl:te})=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(CheckboxTrigger,{...S,ref:t,__scopeCheckbox:n}),te&&jsxRuntime.jsx(CheckboxBubbleInput,{__scopeCheckbox:n})]})})});Checkbox$1.displayName=CHECKBOX_NAME;var INDICATOR_NAME="CheckboxIndicator",CheckboxIndicator=React__namespace.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:s,...a}=e,o=useCheckboxContext(INDICATOR_NAME,n);return jsxRuntime.jsx(Presence,{present:s||isIndeterminate(o.checked)||o.checked===!0,children:jsxRuntime.jsx(Primitive$4.span,{"data-state":getState$3(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:t,style:{pointerEvents:"none",...e.style}})})});CheckboxIndicator.displayName=INDICATOR_NAME;var BUBBLE_INPUT_NAME="CheckboxBubbleInput",CheckboxBubbleInput=React__namespace.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:s,hasConsumerStoppedPropagationRef:a,checked:o,defaultChecked:l,required:c,disabled:d,name:f,value:R,form:S,bubbleInput:te,setBubbleInput:A}=useCheckboxContext(BUBBLE_INPUT_NAME,e),rt=useComposedRefs(n,A),st=usePrevious(o),it=useSize(s);React__namespace.useEffect(()=>{const ot=te;if(!ot)return;const lt=window.HTMLInputElement.prototype,ct=Object.getOwnPropertyDescriptor(lt,"checked").set,dt=!a.current;if(st!==o&&ct){const pt=new Event("click",{bubbles:dt});ot.indeterminate=isIndeterminate(o),ct.call(ot,isIndeterminate(o)?!1:o),ot.dispatchEvent(pt)}},[te,st,o,a]);const at=React__namespace.useRef(isIndeterminate(o)?!1:o);return jsxRuntime.jsx(Primitive$4.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??at.current,required:c,disabled:d,name:f,value:R,form:S,...t,tabIndex:-1,ref:rt,style:{...t.style,...it,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});CheckboxBubbleInput.displayName=BUBBLE_INPUT_NAME;function isFunction$1(e){return typeof e=="function"}function isIndeterminate(e){return e==="indeterminate"}function getState$3(e){return isIndeterminate(e)?"indeterminate":e?"checked":"unchecked"}const Checkbox=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Checkbox$1,{ref:n,className:cn("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:jsxRuntime.jsx(CheckboxIndicator,{className:cn("flex items-center justify-center text-current"),children:jsxRuntime.jsx(Check,{className:"h-4 w-4"})})}));Checkbox.displayName=Checkbox$1.displayName;function CheckboxCardList({items:e,selectedIds:t,onSelectedIdsChange:n,disabled:s=!1,loading:a=!1,selectionMode:o="multiple",layout:l="stack",gridColumns:c=2,emptyState:d,loadingState:f,getItemAriaLabel:R,renderItem:S,className:te,...A}){const rt=React__namespace.useId(),st=React__namespace.useMemo(()=>new Set(t),[t]),it=l==="grid"?cn("grid gap-3",c===2&&"grid-cols-1 sm:grid-cols-2"):"space-y-3",at=React__namespace.useCallback(ot=>{if(s||a||ot.disabled)return;const lt=st.has(ot.id);if(o==="single"){n(lt?[]:[ot.id]);return}if(lt){n(t.filter(ut=>ut!==ot.id));return}n([...t,ot.id])},[s,a,n,st,t,o]);return a?jsxRuntime.jsx("div",{className:cn(it,te),role:"status","aria-live":"polite",...A,children:f??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Loading options"}),Array.from({length:l==="grid"?4:3}).map((ot,lt)=>jsxRuntime.jsxs("div",{className:"rounded-xl border border-border bg-card p-4 shadow-sm","aria-hidden":"true",children:[jsxRuntime.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded bg-muted"}),jsxRuntime.jsx("div",{className:"mt-2 h-3 w-1/2 animate-pulse rounded bg-muted"})]},`loading-${lt}`))]})}):e.length===0?jsxRuntime.jsx("div",{className:cn(it,te),...A,children:d??jsxRuntime.jsx("div",{className:"rounded-xl border border-dashed border-border bg-muted/30 p-4 text-sm text-muted-foreground",children:"No options are available."})}):jsxRuntime.jsx("div",{className:cn(it,te),role:"group","aria-disabled":s||void 0,...A,children:e.map((ot,lt)=>{const ut=st.has(ot.id),ct=s||ot.disabled===!0,dt=`${rt}-${lt}-label`,pt=`${rt}-${lt}-description`;return jsxRuntime.jsxs("button",{type:"button",role:"checkbox","aria-checked":ut,"aria-disabled":ct,"aria-label":R?.(ot)??ot.label,"aria-labelledby":S?void 0:dt,"aria-describedby":!S&&ot.description?pt:void 0,disabled:ct,onClick:()=>at(ot),className:cn("flex w-full items-start gap-3 rounded-xl border bg-card p-4 text-left shadow-sm transition-colors transition-shadow","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","hover:bg-muted/30 hover:shadow",ut?"border-primary bg-primary/5 ring-2 ring-primary/20":"border-border",ct&&"cursor-not-allowed opacity-60 hover:bg-card hover:shadow-sm"),children:[jsxRuntime.jsx("span",{"aria-hidden":"true",className:cn("mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-sm border border-primary shadow-sm",ut?"bg-primary text-primary-foreground":"bg-background text-transparent"),children:jsxRuntime.jsx(Check,{className:"h-3.5 w-3.5"})}),jsxRuntime.jsx("div",{className:"min-w-0 flex-1",children:S?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"sr-only",children:ot.label}),S(ot,{checked:ut,disabled:ct,index:lt})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[(ot.prefix||ot.emphasis)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap items-baseline gap-1 text-xs",children:[ot.prefix&&jsxRuntime.jsx("span",{className:"font-semibold uppercase tracking-wide text-muted-foreground",children:ot.prefix}),ot.emphasis&&jsxRuntime.jsx("span",{className:"font-semibold text-foreground",children:ot.emphasis})]}),jsxRuntime.jsx("span",{id:dt,className:cn("block text-sm font-medium text-foreground",(ot.prefix||ot.emphasis)&&"mt-1"),children:ot.label}),ot.description&&jsxRuntime.jsx("span",{id:pt,className:"mt-1 block text-sm text-muted-foreground",children:ot.description})]})})]},ot.id)})})}var U=1,Y$1=.9,H=.8,J=.17,p=.1,u=.999,$=.9999,k$1=.99,m=/[\\\/_+.#"@\[\(\{&]/,B$1=/[\\\/_+.#"@\[\(\{&]/g,K$1=/[\s-]/,X=/[\s-]/g;function G(e,t,n,s,a,o,l){if(o===t.length)return a===e.length?U:k$1;var c=`${a},${o}`;if(l[c]!==void 0)return l[c];for(var d=s.charAt(o),f=n.indexOf(d,a),R=0,S,te,A,rt;f>=0;)S=G(e,t,n,s,f+1,o+1,l),S>R&&(f===a?S*=U:m.test(e.charAt(f-1))?(S*=H,A=e.slice(a,f-1).match(B$1),A&&a>0&&(S*=Math.pow(u,A.length))):K$1.test(e.charAt(f-1))?(S*=Y$1,rt=e.slice(a,f-1).match(X),rt&&a>0&&(S*=Math.pow(u,rt.length))):(S*=J,a>0&&(S*=Math.pow(u,f-a))),e.charAt(f)!==t.charAt(o)&&(S*=$)),(S<p&&n.charAt(f-1)===s.charAt(o+1)||s.charAt(o+1)===s.charAt(o)&&n.charAt(f-1)!==s.charAt(o))&&(te=G(e,t,n,s,f+1,o+2,l),te*p>S&&(S=te*p)),S>R&&(R=S),f=n.indexOf(d,f+1);return l[c]=R,R}function D(e){return e.toLowerCase().replace(X," ")}function W(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,G(e,t,D(e),D(t),0,0,{})}var N='[cmdk-group=""]',Y='[cmdk-group-items=""]',be='[cmdk-group-heading=""]',le='[cmdk-item=""]',ce=`${le}:not([aria-disabled="true"])`,Z="cmdk-item-select",T="data-value",Re=(e,t,n)=>W(e,t,n),ue=React__namespace.createContext(void 0),K=()=>React__namespace.useContext(ue),de=React__namespace.createContext(void 0),ee=()=>React__namespace.useContext(de),fe=React__namespace.createContext(void 0),me=React__namespace.forwardRef((e,t)=>{let n=L(()=>{var Jt,ar;return{search:"",value:(ar=(Jt=e.value)!=null?Jt:e.defaultValue)!=null?ar:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),s=L(()=>new Set),a=L(()=>new Map),o=L(()=>new Map),l=L(()=>new Set),c=pe(e),{label:d,children:f,value:R,onValueChange:S,filter:te,shouldFilter:A,loop:rt,disablePointerSelection:st=!1,vimBindings:it=!0,...at}=e,ot=useId$1(),lt=useId$1(),ut=useId$1(),ct=React__namespace.useRef(null),dt=ke();k(()=>{if(R!==void 0){let Jt=R.trim();n.current.value=Jt,pt.emit()}},[R]),k(()=>{dt(6,Ct)},[]);let pt=React__namespace.useMemo(()=>({subscribe:Jt=>(l.current.add(Jt),()=>l.current.delete(Jt)),snapshot:()=>n.current,setState:(Jt,ar,cr)=>{var Zt,lr,Ut,rr;if(!Object.is(n.current[Jt],ar)){if(n.current[Jt]=ar,Jt==="search")ft(),yt(),dt(1,It);else if(Jt==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let qt=document.getElementById(ut);qt?qt.focus():(Zt=document.getElementById(ot))==null||Zt.focus()}if(dt(7,()=>{var qt;n.current.selectedItemId=(qt=Mt())==null?void 0:qt.id,pt.emit()}),cr||dt(5,Ct),((lr=c.current)==null?void 0:lr.value)!==void 0){let qt=ar??"";(rr=(Ut=c.current).onValueChange)==null||rr.call(Ut,qt);return}}pt.emit()}},emit:()=>{l.current.forEach(Jt=>Jt())}}),[]),mt=React__namespace.useMemo(()=>({value:(Jt,ar,cr)=>{var Zt;ar!==((Zt=o.current.get(Jt))==null?void 0:Zt.value)&&(o.current.set(Jt,{value:ar,keywords:cr}),n.current.filtered.items.set(Jt,Rt(ar,cr)),dt(2,()=>{yt(),pt.emit()}))},item:(Jt,ar)=>(s.current.add(Jt),ar&&(a.current.has(ar)?a.current.get(ar).add(Jt):a.current.set(ar,new Set([Jt]))),dt(3,()=>{ft(),yt(),n.current.value||It(),pt.emit()}),()=>{o.current.delete(Jt),s.current.delete(Jt),n.current.filtered.items.delete(Jt);let cr=Mt();dt(4,()=>{ft(),cr?.getAttribute("id")===Jt&&It(),pt.emit()})}),group:Jt=>(a.current.has(Jt)||a.current.set(Jt,new Set),()=>{o.current.delete(Jt),a.current.delete(Jt)}),filter:()=>c.current.shouldFilter,label:d||e["aria-label"],getDisablePointerSelection:()=>c.current.disablePointerSelection,listId:ot,inputId:ut,labelId:lt,listInnerRef:ct}),[]);function Rt(Jt,ar){var cr,Zt;let lr=(Zt=(cr=c.current)==null?void 0:cr.filter)!=null?Zt:Re;return Jt?lr(Jt,n.current.search,ar):0}function yt(){if(!n.current.search||c.current.shouldFilter===!1)return;let Jt=n.current.filtered.items,ar=[];n.current.filtered.groups.forEach(Zt=>{let lr=a.current.get(Zt),Ut=0;lr.forEach(rr=>{let qt=Jt.get(rr);Ut=Math.max(qt,Ut)}),ar.push([Zt,Ut])});let cr=ct.current;Dt().sort((Zt,lr)=>{var Ut,rr;let qt=Zt.getAttribute("id"),Qt=lr.getAttribute("id");return((Ut=Jt.get(Qt))!=null?Ut:0)-((rr=Jt.get(qt))!=null?rr:0)}).forEach(Zt=>{let lr=Zt.closest(Y);lr?lr.appendChild(Zt.parentElement===lr?Zt:Zt.closest(`${Y} > *`)):cr.appendChild(Zt.parentElement===cr?Zt:Zt.closest(`${Y} > *`))}),ar.sort((Zt,lr)=>lr[1]-Zt[1]).forEach(Zt=>{var lr;let Ut=(lr=ct.current)==null?void 0:lr.querySelector(`${N}[${T}="${encodeURIComponent(Zt[0])}"]`);Ut?.parentElement.appendChild(Ut)})}function It(){let Jt=Dt().find(cr=>cr.getAttribute("aria-disabled")!=="true"),ar=Jt?.getAttribute(T);pt.setState("value",ar||void 0)}function ft(){var Jt,ar,cr,Zt;if(!n.current.search||c.current.shouldFilter===!1){n.current.filtered.count=s.current.size;return}n.current.filtered.groups=new Set;let lr=0;for(let Ut of s.current){let rr=(ar=(Jt=o.current.get(Ut))==null?void 0:Jt.value)!=null?ar:"",qt=(Zt=(cr=o.current.get(Ut))==null?void 0:cr.keywords)!=null?Zt:[],Qt=Rt(rr,qt);n.current.filtered.items.set(Ut,Qt),Qt>0&&lr++}for(let[Ut,rr]of a.current)for(let qt of rr)if(n.current.filtered.items.get(qt)>0){n.current.filtered.groups.add(Ut);break}n.current.filtered.count=lr}function Ct(){var Jt,ar,cr;let Zt=Mt();Zt&&(((Jt=Zt.parentElement)==null?void 0:Jt.firstChild)===Zt&&((cr=(ar=Zt.closest(N))==null?void 0:ar.querySelector(be))==null||cr.scrollIntoView({block:"nearest"})),Zt.scrollIntoView({block:"nearest"}))}function Mt(){var Jt;return(Jt=ct.current)==null?void 0:Jt.querySelector(`${le}[aria-selected="true"]`)}function Dt(){var Jt;return Array.from(((Jt=ct.current)==null?void 0:Jt.querySelectorAll(ce))||[])}function Vt(Jt){let ar=Dt()[Jt];ar&&pt.setState("value",ar.getAttribute(T))}function Wt(Jt){var ar;let cr=Mt(),Zt=Dt(),lr=Zt.findIndex(rr=>rr===cr),Ut=Zt[lr+Jt];(ar=c.current)!=null&&ar.loop&&(Ut=lr+Jt<0?Zt[Zt.length-1]:lr+Jt===Zt.length?Zt[0]:Zt[lr+Jt]),Ut&&pt.setState("value",Ut.getAttribute(T))}function $t(Jt){let ar=Mt(),cr=ar?.closest(N),Zt;for(;cr&&!Zt;)cr=Jt>0?we(cr,N):De(cr,N),Zt=cr?.querySelector(ce);Zt?pt.setState("value",Zt.getAttribute(T)):Wt(Jt)}let Ft=()=>Vt(Dt().length-1),Ht=Jt=>{Jt.preventDefault(),Jt.metaKey?Ft():Jt.altKey?$t(1):Wt(1)},nr=Jt=>{Jt.preventDefault(),Jt.metaKey?Vt(0):Jt.altKey?$t(-1):Wt(-1)};return React__namespace.createElement(Primitive$4.div,{ref:t,tabIndex:-1,...at,"cmdk-root":"",onKeyDown:Jt=>{var ar;(ar=at.onKeyDown)==null||ar.call(at,Jt);let cr=Jt.nativeEvent.isComposing||Jt.keyCode===229;if(!(Jt.defaultPrevented||cr))switch(Jt.key){case"n":case"j":{it&&Jt.ctrlKey&&Ht(Jt);break}case"ArrowDown":{Ht(Jt);break}case"p":case"k":{it&&Jt.ctrlKey&&nr(Jt);break}case"ArrowUp":{nr(Jt);break}case"Home":{Jt.preventDefault(),Vt(0);break}case"End":{Jt.preventDefault(),Ft();break}case"Enter":{Jt.preventDefault();let Zt=Mt();if(Zt){let lr=new Event(Z);Zt.dispatchEvent(lr)}}}}},React__namespace.createElement("label",{"cmdk-label":"",htmlFor:mt.inputId,id:mt.labelId,style:Te},d),B(e,Jt=>React__namespace.createElement(de.Provider,{value:pt},React__namespace.createElement(ue.Provider,{value:mt},Jt))))}),he=React__namespace.forwardRef((e,t)=>{var n,s;let a=useId$1(),o=React__namespace.useRef(null),l=React__namespace.useContext(fe),c=K(),d=pe(e),f=(s=(n=d.current)==null?void 0:n.forceMount)!=null?s:l?.forceMount;k(()=>{if(!f)return c.item(a,l?.id)},[f]);let R=ve(a,o,[e.value,e.children,o],e.keywords),S=ee(),te=P(dt=>dt.value&&dt.value===R.current),A=P(dt=>f||c.filter()===!1?!0:dt.search?dt.filtered.items.get(a)>0:!0);React__namespace.useEffect(()=>{let dt=o.current;if(!(!dt||e.disabled))return dt.addEventListener(Z,rt),()=>dt.removeEventListener(Z,rt)},[A,e.onSelect,e.disabled]);function rt(){var dt,pt;st(),(pt=(dt=d.current).onSelect)==null||pt.call(dt,R.current)}function st(){S.setState("value",R.current,!0)}if(!A)return null;let{disabled:it,value:at,onSelect:ot,forceMount:lt,keywords:ut,...ct}=e;return React__namespace.createElement(Primitive$4.div,{ref:composeRefs(o,t),...ct,id:a,"cmdk-item":"",role:"option","aria-disabled":!!it,"aria-selected":!!te,"data-disabled":!!it,"data-selected":!!te,onPointerMove:it||c.getDisablePointerSelection()?void 0:st,onClick:it?void 0:rt},e.children)}),Ee=React__namespace.forwardRef((e,t)=>{let{heading:n,children:s,forceMount:a,...o}=e,l=useId$1(),c=React__namespace.useRef(null),d=React__namespace.useRef(null),f=useId$1(),R=K(),S=P(A=>a||R.filter()===!1?!0:A.search?A.filtered.groups.has(l):!0);k(()=>R.group(l),[]),ve(l,c,[e.value,e.heading,d]);let te=React__namespace.useMemo(()=>({id:l,forceMount:a}),[a]);return React__namespace.createElement(Primitive$4.div,{ref:composeRefs(c,t),...o,"cmdk-group":"",role:"presentation",hidden:S?void 0:!0},n&&React__namespace.createElement("div",{ref:d,"cmdk-group-heading":"","aria-hidden":!0,id:f},n),B(e,A=>React__namespace.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?f:void 0},React__namespace.createElement(fe.Provider,{value:te},A))))}),ye=React__namespace.forwardRef((e,t)=>{let{alwaysRender:n,...s}=e,a=React__namespace.useRef(null),o=P(l=>!l.search);return!n&&!o?null:React__namespace.createElement(Primitive$4.div,{ref:composeRefs(a,t),...s,"cmdk-separator":"",role:"separator"})}),Se=React__namespace.forwardRef((e,t)=>{let{onValueChange:n,...s}=e,a=e.value!=null,o=ee(),l=P(f=>f.search),c=P(f=>f.selectedItemId),d=K();return React__namespace.useEffect(()=>{e.value!=null&&o.setState("search",e.value)},[e.value]),React__namespace.createElement(Primitive$4.input,{ref:t,...s,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":d.listId,"aria-labelledby":d.labelId,"aria-activedescendant":c,id:d.inputId,type:"text",value:a?e.value:l,onChange:f=>{a||o.setState("search",f.target.value),n?.(f.target.value)}})}),Ce=React__namespace.forwardRef((e,t)=>{let{children:n,label:s="Suggestions",...a}=e,o=React__namespace.useRef(null),l=React__namespace.useRef(null),c=P(f=>f.selectedItemId),d=K();return React__namespace.useEffect(()=>{if(l.current&&o.current){let f=l.current,R=o.current,S,te=new ResizeObserver(()=>{S=requestAnimationFrame(()=>{let A=f.offsetHeight;R.style.setProperty("--cmdk-list-height",A.toFixed(1)+"px")})});return te.observe(f),()=>{cancelAnimationFrame(S),te.unobserve(f)}}},[]),React__namespace.createElement(Primitive$4.div,{ref:composeRefs(o,t),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":c,"aria-label":s,id:d.listId},B(e,f=>React__namespace.createElement("div",{ref:composeRefs(l,d.listInnerRef),"cmdk-list-sizer":""},f)))}),xe=React__namespace.forwardRef((e,t)=>{let{open:n,onOpenChange:s,overlayClassName:a,contentClassName:o,container:l,...c}=e;return React__namespace.createElement(Root$a,{open:n,onOpenChange:s},React__namespace.createElement(Portal$4,{container:l},React__namespace.createElement(Overlay,{"cmdk-overlay":"",className:a}),React__namespace.createElement(Content$3,{"aria-label":e.label,"cmdk-dialog":"",className:o},React__namespace.createElement(me,{ref:t,...c}))))}),Ie=React__namespace.forwardRef((e,t)=>P(n=>n.filtered.count===0)?React__namespace.createElement(Primitive$4.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Pe=React__namespace.forwardRef((e,t)=>{let{progress:n,children:s,label:a="Loading...",...o}=e;return React__namespace.createElement(Primitive$4.div,{ref:t,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},B(e,l=>React__namespace.createElement("div",{"aria-hidden":!0},l)))}),_e=Object.assign(me,{List:Ce,Item:he,Input:Se,Group:Ee,Separator:ye,Dialog:xe,Empty:Ie,Loading:Pe});function we(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function De(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function pe(e){let t=React__namespace.useRef(e);return k(()=>{t.current=e}),t}var k=typeof window>"u"?React__namespace.useEffect:React__namespace.useLayoutEffect;function L(e){let t=React__namespace.useRef();return t.current===void 0&&(t.current=e()),t}function P(e){let t=ee(),n=()=>e(t.snapshot());return React__namespace.useSyncExternalStore(t.subscribe,n,n)}function ve(e,t,n,s=[]){let a=React__namespace.useRef(),o=K();return k(()=>{var l;let c=(()=>{var f;for(let R of n){if(typeof R=="string")return R.trim();if(typeof R=="object"&&"current"in R)return R.current?(f=R.current.textContent)==null?void 0:f.trim():a.current}})(),d=s.map(f=>f.trim());o.value(e,c,d),(l=t.current)==null||l.setAttribute(T,c),a.current=c}),a}var ke=()=>{let[e,t]=React__namespace.useState(),n=L(()=>new Map);return k(()=>{n.current.forEach(s=>s()),n.current=new Map},[e]),(s,a)=>{n.current.set(s,a),t({})}};function Me(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function B({asChild:e,children:t},n){return e&&React__namespace.isValidElement(t)?React__namespace.cloneElement(Me(t),{ref:t.ref},n(t.props.children)):n(t)}var Te={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Command=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(_e,{ref:n,className:cn("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Command.displayName=_e.displayName;const CommandDialog=({children:e,...t})=>jsxRuntime.jsx(Dialog,{...t,children:jsxRuntime.jsx(DialogContent,{className:"overflow-hidden p-0",children:jsxRuntime.jsx(Command,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:e})})}),CommandInput=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[jsxRuntime.jsx(Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),jsxRuntime.jsx(_e.Input,{ref:n,className:cn("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));CommandInput.displayName=_e.Input.displayName;const CommandList=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(_e.List,{ref:n,className:cn("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));CommandList.displayName=_e.List.displayName;const CommandEmpty=React__namespace.forwardRef((e,t)=>jsxRuntime.jsx(_e.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));CommandEmpty.displayName=_e.Empty.displayName;const CommandGroup=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(_e.Group,{ref:n,className:cn("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));CommandGroup.displayName=_e.Group.displayName;const CommandSeparator=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(_e.Separator,{ref:n,className:cn("-mx-1 h-px bg-border",e),...t}));CommandSeparator.displayName=_e.Separator.displayName;const CommandItem=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(_e.Item,{ref:n,className:cn("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",e),...t}));CommandItem.displayName=_e.Item.displayName;const CommandShortcut=({className:e,...t})=>jsxRuntime.jsx("span",{className:cn("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});CommandShortcut.displayName="CommandShortcut";const CountryFlag=({countryCode:e,className:t=""})=>{const[n,s]=React.useState(!1),a=e.trim().toUpperCase();React.useEffect(()=>{s(!1)},[a]);const o=React.useMemo(()=>a?`https://purecatamphetamine.github.io/country-flag-icons/3x2/${encodeURIComponent(a)}.svg`:"",[a]);return!a||n?jsxRuntime.jsx("span",{className:t,children:e}):jsxRuntime.jsx("img",{src:o,alt:`${a} flag`,className:`inline-block h-auto w-6 ${t}`,loading:"lazy",onError:()=>s(!0)})};function GeneralDocumentCard({document:e,loading:t=!1}){return t?jsxRuntime.jsx("div",{children:"loading..."}):jsxRuntime.jsxs("div",{children:["GENERAL DOCUMENT CARD - ",e?.OrderNumber," for P.O. ",e?.PONumber]})}function ApiImage({path:e,origin:t,...n}){const s=useApiOrigin(),a=React__namespace.useMemo(()=>buildApiUrl(e,t??s),[s,t,e]);return jsxRuntime.jsx("img",{...n,src:a})}var md5={exports:{}};const __viteBrowserExternal={},__viteBrowserExternal$1=Object.freeze(Object.defineProperty({__proto__:null,default:__viteBrowserExternal},Symbol.toStringTag,{value:"Module"})),require$$1=getAugmentedNamespace(__viteBrowserExternal$1);var hasRequiredMd5;function requireMd5(){return hasRequiredMd5||(hasRequiredMd5=1,(function(e){(function(){var t="input is invalid type",n="finalize already called",s=typeof window=="object",a=s?window:{};a.JS_MD5_NO_WINDOW&&(s=!1);var o=!s&&typeof self=="object",l=!a.JS_MD5_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;l?a=commonjsGlobal:o&&(a=self);var c=!a.JS_MD5_NO_COMMON_JS&&!0&&e.exports,d=!a.JS_MD5_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",f="0123456789abcdef".split(""),R=[128,32768,8388608,-2147483648],S=[0,8,16,24],te=["hex","array","digest","buffer","arrayBuffer","base64"],A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),rt=[],st;if(d){var it=new ArrayBuffer(68);st=new Uint8Array(it),rt=new Uint32Array(it)}var at=Array.isArray;(a.JS_MD5_NO_NODE_JS||!at)&&(at=function(ft){return Object.prototype.toString.call(ft)==="[object Array]"});var ot=ArrayBuffer.isView;d&&(a.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW||!ot)&&(ot=function(ft){return typeof ft=="object"&&ft.buffer&&ft.buffer.constructor===ArrayBuffer});var lt=function(ft){var Ct=typeof ft;if(Ct==="string")return[ft,!0];if(Ct!=="object"||ft===null)throw new Error(t);if(d&&ft.constructor===ArrayBuffer)return[new Uint8Array(ft),!1];if(!at(ft)&&!ot(ft))throw new Error(t);return[ft,!1]},ut=function(ft){return function(Ct){return new Rt(!0).update(Ct)[ft]()}},ct=function(){var ft=ut("hex");l&&(ft=dt(ft)),ft.create=function(){return new Rt},ft.update=function(Dt){return ft.create().update(Dt)};for(var Ct=0;Ct<te.length;++Ct){var Mt=te[Ct];ft[Mt]=ut(Mt)}return ft},dt=function(ft){var Ct=require$$1,Mt=require$$1.Buffer,Dt;Mt.from&&!a.JS_MD5_NO_BUFFER_FROM?Dt=Mt.from:Dt=function(Wt){return new Mt(Wt)};var Vt=function(Wt){if(typeof Wt=="string")return Ct.createHash("md5").update(Wt,"utf8").digest("hex");if(Wt==null)throw new Error(t);return Wt.constructor===ArrayBuffer&&(Wt=new Uint8Array(Wt)),at(Wt)||ot(Wt)||Wt.constructor===Mt?Ct.createHash("md5").update(Dt(Wt)).digest("hex"):ft(Wt)};return Vt},pt=function(ft){return function(Ct,Mt){return new yt(Ct,!0).update(Mt)[ft]()}},mt=function(){var ft=pt("hex");ft.create=function(Dt){return new yt(Dt)},ft.update=function(Dt,Vt){return ft.create(Dt).update(Vt)};for(var Ct=0;Ct<te.length;++Ct){var Mt=te[Ct];ft[Mt]=pt(Mt)}return ft};function Rt(ft){if(ft)rt[0]=rt[16]=rt[1]=rt[2]=rt[3]=rt[4]=rt[5]=rt[6]=rt[7]=rt[8]=rt[9]=rt[10]=rt[11]=rt[12]=rt[13]=rt[14]=rt[15]=0,this.blocks=rt,this.buffer8=st;else if(d){var Ct=new ArrayBuffer(68);this.buffer8=new Uint8Array(Ct),this.blocks=new Uint32Array(Ct)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}Rt.prototype.update=function(ft){if(this.finalized)throw new Error(n);var Ct=lt(ft);ft=Ct[0];for(var Mt=Ct[1],Dt,Vt=0,Wt,$t=ft.length,Ft=this.blocks,Ht=this.buffer8;Vt<$t;){if(this.hashed&&(this.hashed=!1,Ft[0]=Ft[16],Ft[16]=Ft[1]=Ft[2]=Ft[3]=Ft[4]=Ft[5]=Ft[6]=Ft[7]=Ft[8]=Ft[9]=Ft[10]=Ft[11]=Ft[12]=Ft[13]=Ft[14]=Ft[15]=0),Mt)if(d)for(Wt=this.start;Vt<$t&&Wt<64;++Vt)Dt=ft.charCodeAt(Vt),Dt<128?Ht[Wt++]=Dt:Dt<2048?(Ht[Wt++]=192|Dt>>>6,Ht[Wt++]=128|Dt&63):Dt<55296||Dt>=57344?(Ht[Wt++]=224|Dt>>>12,Ht[Wt++]=128|Dt>>>6&63,Ht[Wt++]=128|Dt&63):(Dt=65536+((Dt&1023)<<10|ft.charCodeAt(++Vt)&1023),Ht[Wt++]=240|Dt>>>18,Ht[Wt++]=128|Dt>>>12&63,Ht[Wt++]=128|Dt>>>6&63,Ht[Wt++]=128|Dt&63);else for(Wt=this.start;Vt<$t&&Wt<64;++Vt)Dt=ft.charCodeAt(Vt),Dt<128?Ft[Wt>>>2]|=Dt<<S[Wt++&3]:Dt<2048?(Ft[Wt>>>2]|=(192|Dt>>>6)<<S[Wt++&3],Ft[Wt>>>2]|=(128|Dt&63)<<S[Wt++&3]):Dt<55296||Dt>=57344?(Ft[Wt>>>2]|=(224|Dt>>>12)<<S[Wt++&3],Ft[Wt>>>2]|=(128|Dt>>>6&63)<<S[Wt++&3],Ft[Wt>>>2]|=(128|Dt&63)<<S[Wt++&3]):(Dt=65536+((Dt&1023)<<10|ft.charCodeAt(++Vt)&1023),Ft[Wt>>>2]|=(240|Dt>>>18)<<S[Wt++&3],Ft[Wt>>>2]|=(128|Dt>>>12&63)<<S[Wt++&3],Ft[Wt>>>2]|=(128|Dt>>>6&63)<<S[Wt++&3],Ft[Wt>>>2]|=(128|Dt&63)<<S[Wt++&3]);else if(d)for(Wt=this.start;Vt<$t&&Wt<64;++Vt)Ht[Wt++]=ft[Vt];else for(Wt=this.start;Vt<$t&&Wt<64;++Vt)Ft[Wt>>>2]|=ft[Vt]<<S[Wt++&3];this.lastByteIndex=Wt,this.bytes+=Wt-this.start,Wt>=64?(this.start=Wt-64,this.hash(),this.hashed=!0):this.start=Wt}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this},Rt.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var ft=this.blocks,Ct=this.lastByteIndex;ft[Ct>>>2]|=R[Ct&3],Ct>=56&&(this.hashed||this.hash(),ft[0]=ft[16],ft[16]=ft[1]=ft[2]=ft[3]=ft[4]=ft[5]=ft[6]=ft[7]=ft[8]=ft[9]=ft[10]=ft[11]=ft[12]=ft[13]=ft[14]=ft[15]=0),ft[14]=this.bytes<<3,ft[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},Rt.prototype.hash=function(){var ft,Ct,Mt,Dt,Vt,Wt,$t=this.blocks;this.first?(ft=$t[0]-680876937,ft=(ft<<7|ft>>>25)-271733879<<0,Dt=(-1732584194^ft&2004318071)+$t[1]-117830708,Dt=(Dt<<12|Dt>>>20)+ft<<0,Mt=(-271733879^Dt&(ft^-271733879))+$t[2]-1126478375,Mt=(Mt<<17|Mt>>>15)+Dt<<0,Ct=(ft^Mt&(Dt^ft))+$t[3]-1316259209,Ct=(Ct<<22|Ct>>>10)+Mt<<0):(ft=this.h0,Ct=this.h1,Mt=this.h2,Dt=this.h3,ft+=(Dt^Ct&(Mt^Dt))+$t[0]-680876936,ft=(ft<<7|ft>>>25)+Ct<<0,Dt+=(Mt^ft&(Ct^Mt))+$t[1]-389564586,Dt=(Dt<<12|Dt>>>20)+ft<<0,Mt+=(Ct^Dt&(ft^Ct))+$t[2]+606105819,Mt=(Mt<<17|Mt>>>15)+Dt<<0,Ct+=(ft^Mt&(Dt^ft))+$t[3]-1044525330,Ct=(Ct<<22|Ct>>>10)+Mt<<0),ft+=(Dt^Ct&(Mt^Dt))+$t[4]-176418897,ft=(ft<<7|ft>>>25)+Ct<<0,Dt+=(Mt^ft&(Ct^Mt))+$t[5]+1200080426,Dt=(Dt<<12|Dt>>>20)+ft<<0,Mt+=(Ct^Dt&(ft^Ct))+$t[6]-1473231341,Mt=(Mt<<17|Mt>>>15)+Dt<<0,Ct+=(ft^Mt&(Dt^ft))+$t[7]-45705983,Ct=(Ct<<22|Ct>>>10)+Mt<<0,ft+=(Dt^Ct&(Mt^Dt))+$t[8]+1770035416,ft=(ft<<7|ft>>>25)+Ct<<0,Dt+=(Mt^ft&(Ct^Mt))+$t[9]-1958414417,Dt=(Dt<<12|Dt>>>20)+ft<<0,Mt+=(Ct^Dt&(ft^Ct))+$t[10]-42063,Mt=(Mt<<17|Mt>>>15)+Dt<<0,Ct+=(ft^Mt&(Dt^ft))+$t[11]-1990404162,Ct=(Ct<<22|Ct>>>10)+Mt<<0,ft+=(Dt^Ct&(Mt^Dt))+$t[12]+1804603682,ft=(ft<<7|ft>>>25)+Ct<<0,Dt+=(Mt^ft&(Ct^Mt))+$t[13]-40341101,Dt=(Dt<<12|Dt>>>20)+ft<<0,Mt+=(Ct^Dt&(ft^Ct))+$t[14]-1502002290,Mt=(Mt<<17|Mt>>>15)+Dt<<0,Ct+=(ft^Mt&(Dt^ft))+$t[15]+1236535329,Ct=(Ct<<22|Ct>>>10)+Mt<<0,ft+=(Mt^Dt&(Ct^Mt))+$t[1]-165796510,ft=(ft<<5|ft>>>27)+Ct<<0,Dt+=(Ct^Mt&(ft^Ct))+$t[6]-1069501632,Dt=(Dt<<9|Dt>>>23)+ft<<0,Mt+=(ft^Ct&(Dt^ft))+$t[11]+643717713,Mt=(Mt<<14|Mt>>>18)+Dt<<0,Ct+=(Dt^ft&(Mt^Dt))+$t[0]-373897302,Ct=(Ct<<20|Ct>>>12)+Mt<<0,ft+=(Mt^Dt&(Ct^Mt))+$t[5]-701558691,ft=(ft<<5|ft>>>27)+Ct<<0,Dt+=(Ct^Mt&(ft^Ct))+$t[10]+38016083,Dt=(Dt<<9|Dt>>>23)+ft<<0,Mt+=(ft^Ct&(Dt^ft))+$t[15]-660478335,Mt=(Mt<<14|Mt>>>18)+Dt<<0,Ct+=(Dt^ft&(Mt^Dt))+$t[4]-405537848,Ct=(Ct<<20|Ct>>>12)+Mt<<0,ft+=(Mt^Dt&(Ct^Mt))+$t[9]+568446438,ft=(ft<<5|ft>>>27)+Ct<<0,Dt+=(Ct^Mt&(ft^Ct))+$t[14]-1019803690,Dt=(Dt<<9|Dt>>>23)+ft<<0,Mt+=(ft^Ct&(Dt^ft))+$t[3]-187363961,Mt=(Mt<<14|Mt>>>18)+Dt<<0,Ct+=(Dt^ft&(Mt^Dt))+$t[8]+1163531501,Ct=(Ct<<20|Ct>>>12)+Mt<<0,ft+=(Mt^Dt&(Ct^Mt))+$t[13]-1444681467,ft=(ft<<5|ft>>>27)+Ct<<0,Dt+=(Ct^Mt&(ft^Ct))+$t[2]-51403784,Dt=(Dt<<9|Dt>>>23)+ft<<0,Mt+=(ft^Ct&(Dt^ft))+$t[7]+1735328473,Mt=(Mt<<14|Mt>>>18)+Dt<<0,Ct+=(Dt^ft&(Mt^Dt))+$t[12]-1926607734,Ct=(Ct<<20|Ct>>>12)+Mt<<0,Vt=Ct^Mt,ft+=(Vt^Dt)+$t[5]-378558,ft=(ft<<4|ft>>>28)+Ct<<0,Dt+=(Vt^ft)+$t[8]-2022574463,Dt=(Dt<<11|Dt>>>21)+ft<<0,Wt=Dt^ft,Mt+=(Wt^Ct)+$t[11]+1839030562,Mt=(Mt<<16|Mt>>>16)+Dt<<0,Ct+=(Wt^Mt)+$t[14]-35309556,Ct=(Ct<<23|Ct>>>9)+Mt<<0,Vt=Ct^Mt,ft+=(Vt^Dt)+$t[1]-1530992060,ft=(ft<<4|ft>>>28)+Ct<<0,Dt+=(Vt^ft)+$t[4]+1272893353,Dt=(Dt<<11|Dt>>>21)+ft<<0,Wt=Dt^ft,Mt+=(Wt^Ct)+$t[7]-155497632,Mt=(Mt<<16|Mt>>>16)+Dt<<0,Ct+=(Wt^Mt)+$t[10]-1094730640,Ct=(Ct<<23|Ct>>>9)+Mt<<0,Vt=Ct^Mt,ft+=(Vt^Dt)+$t[13]+681279174,ft=(ft<<4|ft>>>28)+Ct<<0,Dt+=(Vt^ft)+$t[0]-358537222,Dt=(Dt<<11|Dt>>>21)+ft<<0,Wt=Dt^ft,Mt+=(Wt^Ct)+$t[3]-722521979,Mt=(Mt<<16|Mt>>>16)+Dt<<0,Ct+=(Wt^Mt)+$t[6]+76029189,Ct=(Ct<<23|Ct>>>9)+Mt<<0,Vt=Ct^Mt,ft+=(Vt^Dt)+$t[9]-640364487,ft=(ft<<4|ft>>>28)+Ct<<0,Dt+=(Vt^ft)+$t[12]-421815835,Dt=(Dt<<11|Dt>>>21)+ft<<0,Wt=Dt^ft,Mt+=(Wt^Ct)+$t[15]+530742520,Mt=(Mt<<16|Mt>>>16)+Dt<<0,Ct+=(Wt^Mt)+$t[2]-995338651,Ct=(Ct<<23|Ct>>>9)+Mt<<0,ft+=(Mt^(Ct|~Dt))+$t[0]-198630844,ft=(ft<<6|ft>>>26)+Ct<<0,Dt+=(Ct^(ft|~Mt))+$t[7]+1126891415,Dt=(Dt<<10|Dt>>>22)+ft<<0,Mt+=(ft^(Dt|~Ct))+$t[14]-1416354905,Mt=(Mt<<15|Mt>>>17)+Dt<<0,Ct+=(Dt^(Mt|~ft))+$t[5]-57434055,Ct=(Ct<<21|Ct>>>11)+Mt<<0,ft+=(Mt^(Ct|~Dt))+$t[12]+1700485571,ft=(ft<<6|ft>>>26)+Ct<<0,Dt+=(Ct^(ft|~Mt))+$t[3]-1894986606,Dt=(Dt<<10|Dt>>>22)+ft<<0,Mt+=(ft^(Dt|~Ct))+$t[10]-1051523,Mt=(Mt<<15|Mt>>>17)+Dt<<0,Ct+=(Dt^(Mt|~ft))+$t[1]-2054922799,Ct=(Ct<<21|Ct>>>11)+Mt<<0,ft+=(Mt^(Ct|~Dt))+$t[8]+1873313359,ft=(ft<<6|ft>>>26)+Ct<<0,Dt+=(Ct^(ft|~Mt))+$t[15]-30611744,Dt=(Dt<<10|Dt>>>22)+ft<<0,Mt+=(ft^(Dt|~Ct))+$t[6]-1560198380,Mt=(Mt<<15|Mt>>>17)+Dt<<0,Ct+=(Dt^(Mt|~ft))+$t[13]+1309151649,Ct=(Ct<<21|Ct>>>11)+Mt<<0,ft+=(Mt^(Ct|~Dt))+$t[4]-145523070,ft=(ft<<6|ft>>>26)+Ct<<0,Dt+=(Ct^(ft|~Mt))+$t[11]-1120210379,Dt=(Dt<<10|Dt>>>22)+ft<<0,Mt+=(ft^(Dt|~Ct))+$t[2]+718787259,Mt=(Mt<<15|Mt>>>17)+Dt<<0,Ct+=(Dt^(Mt|~ft))+$t[9]-343485551,Ct=(Ct<<21|Ct>>>11)+Mt<<0,this.first?(this.h0=ft+1732584193<<0,this.h1=Ct-271733879<<0,this.h2=Mt-1732584194<<0,this.h3=Dt+271733878<<0,this.first=!1):(this.h0=this.h0+ft<<0,this.h1=this.h1+Ct<<0,this.h2=this.h2+Mt<<0,this.h3=this.h3+Dt<<0)},Rt.prototype.hex=function(){this.finalize();var ft=this.h0,Ct=this.h1,Mt=this.h2,Dt=this.h3;return f[ft>>>4&15]+f[ft&15]+f[ft>>>12&15]+f[ft>>>8&15]+f[ft>>>20&15]+f[ft>>>16&15]+f[ft>>>28&15]+f[ft>>>24&15]+f[Ct>>>4&15]+f[Ct&15]+f[Ct>>>12&15]+f[Ct>>>8&15]+f[Ct>>>20&15]+f[Ct>>>16&15]+f[Ct>>>28&15]+f[Ct>>>24&15]+f[Mt>>>4&15]+f[Mt&15]+f[Mt>>>12&15]+f[Mt>>>8&15]+f[Mt>>>20&15]+f[Mt>>>16&15]+f[Mt>>>28&15]+f[Mt>>>24&15]+f[Dt>>>4&15]+f[Dt&15]+f[Dt>>>12&15]+f[Dt>>>8&15]+f[Dt>>>20&15]+f[Dt>>>16&15]+f[Dt>>>28&15]+f[Dt>>>24&15]},Rt.prototype.toString=Rt.prototype.hex,Rt.prototype.digest=function(){this.finalize();var ft=this.h0,Ct=this.h1,Mt=this.h2,Dt=this.h3;return[ft&255,ft>>>8&255,ft>>>16&255,ft>>>24&255,Ct&255,Ct>>>8&255,Ct>>>16&255,Ct>>>24&255,Mt&255,Mt>>>8&255,Mt>>>16&255,Mt>>>24&255,Dt&255,Dt>>>8&255,Dt>>>16&255,Dt>>>24&255]},Rt.prototype.array=Rt.prototype.digest,Rt.prototype.arrayBuffer=function(){this.finalize();var ft=new ArrayBuffer(16),Ct=new Uint32Array(ft);return Ct[0]=this.h0,Ct[1]=this.h1,Ct[2]=this.h2,Ct[3]=this.h3,ft},Rt.prototype.buffer=Rt.prototype.arrayBuffer,Rt.prototype.base64=function(){for(var ft,Ct,Mt,Dt="",Vt=this.array(),Wt=0;Wt<15;)ft=Vt[Wt++],Ct=Vt[Wt++],Mt=Vt[Wt++],Dt+=A[ft>>>2]+A[(ft<<4|Ct>>>4)&63]+A[(Ct<<2|Mt>>>6)&63]+A[Mt&63];return ft=Vt[Wt],Dt+=A[ft>>>2]+A[ft<<4&63]+"==",Dt};function yt(ft,Ct){var Mt,Dt=lt(ft);if(ft=Dt[0],Dt[1]){var Vt=[],Wt=ft.length,$t=0,Ft;for(Mt=0;Mt<Wt;++Mt)Ft=ft.charCodeAt(Mt),Ft<128?Vt[$t++]=Ft:Ft<2048?(Vt[$t++]=192|Ft>>>6,Vt[$t++]=128|Ft&63):Ft<55296||Ft>=57344?(Vt[$t++]=224|Ft>>>12,Vt[$t++]=128|Ft>>>6&63,Vt[$t++]=128|Ft&63):(Ft=65536+((Ft&1023)<<10|ft.charCodeAt(++Mt)&1023),Vt[$t++]=240|Ft>>>18,Vt[$t++]=128|Ft>>>12&63,Vt[$t++]=128|Ft>>>6&63,Vt[$t++]=128|Ft&63);ft=Vt}ft.length>64&&(ft=new Rt(!0).update(ft).array());var Ht=[],nr=[];for(Mt=0;Mt<64;++Mt){var Jt=ft[Mt]||0;Ht[Mt]=92^Jt,nr[Mt]=54^Jt}Rt.call(this,Ct),this.update(nr),this.oKeyPad=Ht,this.inner=!0,this.sharedMemory=Ct}yt.prototype=new Rt,yt.prototype.finalize=function(){if(Rt.prototype.finalize.call(this),this.inner){this.inner=!1;var ft=this.array();Rt.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(ft),Rt.prototype.finalize.call(this)}};var It=ct();It.md5=It,It.md5.hmac=mt(),c?e.exports=It:a.md5=It})()})(md5)),md5.exports}var md5Exports=requireMd5(),Type=(e=>(e.STRING="string",e.NUMBER="number",e.BOOLEAN="boolean",e.OBJECT="object",e))(Type||{});const bodyKey="TheRequestBody",defaultSchemaDescription="Request body content";function getHash(e){return md5Exports.md5(e).substring(0,16)}function deduplicateApiFunctions(e){const t=new Map;return e.map(n=>{const s=n.declaration.name,a=t.get(s)||0;let o=s;return a>0&&(o=`${s}_${a}`),t.set(s,a+1),{...n,declaration:{...n.declaration,name:o}}})}function isSchemaReference(e){return!!e&&"$ref"in e}function isSchemaObject(e){return!!e&&!("$ref"in e)}function getRequestBodySchema(e){if(!e?.content)return;const t=["application/json","application/json-patch+json","multipart/form-data","text/plain"];for(const s of t){const a=e.content[s]?.schema;if(a)return a}return Object.values(e.content).find(s=>s?.schema)?.schema}async function fetchApiFunctions(e){const t=e?.swaggerJsonUrl??DEFAULT_SWAGGER_JSON_URL,n=resolveApiOrigin(t)??resolveApiOrigin(DEFAULT_SWAGGER_JSON_URL),s=buildApiUrl(t,n);try{const a=await fetch(s);if(!a.ok)throw new Error("Failed to fetch Swagger spec");const o=await a.json(),l=[];for(const[c,d]of Object.entries(o.paths)){const f=["get","post","put","delete"];for(const R of f){const S=d[R];if(!S||S["x-allowed-for-chatbots"]!==!0)continue;const te=c.split("/").filter(Boolean);let A;te.length>0&&te[0].toLowerCase()==="v4"?A=te.length>1?te[1]:"api":A=te.length>0?te[0]:"api",A=A.replace(/[{}]/g,"");const rt=getHash(c),st=`${R}-${A.toLowerCase()}-${rt}`,it={},at=[];S.parameters?.forEach(Rt=>{const yt=Rt.schema?.type,It=yt==="integer"||yt==="number"?"number":yt==="boolean"?"boolean":"string";it[Rt.name]={type:It,description:Rt.description||`The ${Rt.name} parameter`},Rt.required&&at.push(Rt.name)});const ot=S.parameters?.filter(Rt=>Rt.in==="path").map(Rt=>Rt.name)||[];if((R==="post"||R==="put")&&S.requestBody){const Rt=getRequestBodySchema(S.requestBody),yt=S.requestBody.description||defaultSchemaDescription;if(Rt&&isSchemaReference(Rt)&&Rt.$ref.startsWith("#/components/schemas/")){const It=Rt.$ref.substring(21),ft=o.components.schemas[It],Ct=isSchemaObject(ft)?ft.properties:void 0,Mt=Ct?JSON.stringify(Ct):"Refer to API schema for details.";it[bodyKey]={type:"string",description:`${yt}. Must be a JSON string with these properties: ${Mt}`}}else it[bodyKey]={type:"string",description:yt};at.push(bodyKey)}const lt={name:st,description:S.description?`${S.summary}
|
|
@@ -520,7 +520,7 @@ You can add a description to the \`${CONTENT_NAME$2}\` by passing a \`${DESCRIPT
|
|
|
520
520
|
|
|
521
521
|
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${CONTENT_NAME$2}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
|
|
522
522
|
|
|
523
|
-
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return React__namespace.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},Root2$1=AlertDialog$1,Trigger2$1=AlertDialogTrigger$1,Portal2=AlertDialogPortal$1,Overlay2=AlertDialogOverlay$1,Content2$1=AlertDialogContent$1,Action=AlertDialogAction$1,Cancel=AlertDialogCancel$1,Title2=AlertDialogTitle$1,Description2=AlertDialogDescription$1;const AlertDialog=Root2$1,AlertDialogTrigger=Trigger2$1,AlertDialogPortal=Portal2,AlertDialogOverlay=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Overlay2,{className:cn("fixed inset-0 z-50 bg-foreground/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));AlertDialogOverlay.displayName=Overlay2.displayName;const AlertDialogContent=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsxs(AlertDialogPortal,{children:[jsxRuntime.jsx(AlertDialogOverlay,{}),jsxRuntime.jsx(Content2$1,{ref:n,className:cn("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]}));AlertDialogContent.displayName=Content2$1.displayName;const AlertDialogHeader=({className:e,...t})=>jsxRuntime.jsx("div",{className:cn("flex flex-col space-y-2 text-center sm:text-left",e),...t});AlertDialogHeader.displayName="AlertDialogHeader";const AlertDialogFooter=({className:e,...t})=>jsxRuntime.jsx("div",{className:cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});AlertDialogFooter.displayName="AlertDialogFooter";const AlertDialogTitle=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Title2,{ref:n,className:cn("text-lg font-semibold",e),...t}));AlertDialogTitle.displayName=Title2.displayName;const AlertDialogDescription=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Description2,{ref:n,className:cn("text-sm text-muted-foreground",e),...t}));AlertDialogDescription.displayName=Description2.displayName;const AlertDialogAction=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Action,{ref:n,className:cn(buttonVariants(),e),...t}));AlertDialogAction.displayName=Action.displayName;const AlertDialogCancel=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Cancel,{ref:n,className:cn(buttonVariants({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));AlertDialogCancel.displayName=Cancel.displayName;function parseDate(e){if(e==null)return null;const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?null:t}function formatLastRefresh(e){const t=parseDate(e);if(!t)return"Never";const n=new Date;return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate()?`Today at ${new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit",timeZoneName:"short"}).format(t)}`:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}).format(t)}function RefreshCluster({lastRefreshAt:e,onRefresh:t,onProgressiveRefresh:n,onAssistantClick:s,isRefreshing:a=!1,refreshLabel:o="Refresh",assistantLabel:l="Assistant",className:c,disabled:d=!1}){const[f,R]=React__namespace.useState(!1),[S,te]=React__namespace.useState(e);React__namespace.useEffect(()=>{te(e)},[e]);const A=!!(t||n),rt=a||f,st=e??S,it=React__namespace.useCallback(async()=>{if(!(!A||d||rt)){R(!0);try{n?(await n(!1),await n(!0)):await t?.(),te(new Date)}finally{R(!1)}}},[A,d,rt,n,t]);return jsxRuntime.jsxs("div",{className:cn("flex flex-wrap items-center justify-end gap-2",c),children:[jsxRuntime.jsxs("p",{className:"text-xs text-muted-foreground sm:text-sm",children:["Last refresh:"," ",jsxRuntime.jsx("span",{className:"font-medium text-foreground",children:formatLastRefresh(st)})]}),jsxRuntime.jsxs(Button$1,{type:"button",variant:"outline",className:"min-h-11",disabled:d||rt||!A,onClick:it,children:[rt?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}):jsxRuntime.jsx(RefreshCw,{className:"h-4 w-4","aria-hidden":"true"}),jsxRuntime.jsx("span",{children:o})]}),jsxRuntime.jsxs(Button$1,{type:"button",variant:"default",className:"min-h-11",disabled:d,onClick:s,children:[jsxRuntime.jsx(Bot,{className:"h-4 w-4","aria-hidden":"true"}),jsxRuntime.jsx("span",{children:l})]})]})}function DataRefreshAssistantCluster({onAssistantClick:e,assistantPromptOptions:t,onAssistantUnavailable:n,...s}){const a=useOptionalChat(),o=React__namespace.useCallback(()=>{if(e){e();return}if(t){if(!a){n?.();return}a.sendMessageWithClear(t.prompt,t.hiddenPrompt,t.sopID)||n?.();return}n?.()},[t,a,e,n]);return jsxRuntime.jsx(RefreshCluster,{...s,onAssistantClick:o})}const fullBleedClassName="w-full max-w-none w-[100cqw] ml-[calc(50%-50cqw)] mr-[calc(50%-50cqw)]",rowInlinePaddingClassName="px-4 lg:px-6",primaryRowPaddingClassName=`${rowInlinePaddingClassName} py-4`,secondaryRowPaddingClassName=`${rowInlinePaddingClassName} py-3`;function RmPageHeaderBreadcrumbLink({item:e,isCurrent:t}){return!t&&e.href?jsxRuntime.jsx("a",{href:e.href,className:"text-xs font-medium text-muted-foreground underline-offset-4 transition-colors hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:e.label}):!t&&e.onClick?jsxRuntime.jsx("button",{type:"button",className:"text-xs font-medium text-muted-foreground underline-offset-4 transition-colors hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",onClick:e.onClick,children:e.label}):jsxRuntime.jsx("span",{"aria-current":t?"page":void 0,className:cn("text-xs font-medium",t?"text-foreground":"text-muted-foreground"),children:e.label})}function RmPageHeaderBreadcrumbs({items:e}){return e.length===0?null:jsxRuntime.jsx("nav",{"aria-label":"Breadcrumb",className:"w-full",children:jsxRuntime.jsx("ol",{className:"flex flex-wrap items-center gap-1.5",children:e.map((t,n)=>{const s=n===e.length-1,a=t.key??`${String(t.label)}-${n}`;return jsxRuntime.jsxs("li",{className:"inline-flex items-center gap-1.5",children:[jsxRuntime.jsx(RmPageHeaderBreadcrumbLink,{item:t,isCurrent:!!t.current||s}),s?null:jsxRuntime.jsx("span",{"aria-hidden":"true",className:"text-xs text-muted-foreground",children:"/"})]},a)})})})}function RmPageHeader({title:e,subtitle:t,breadcrumbs:n,rightTopActions:s,rightBottomActions:a,secondaryRow:o,sticky:l=!1,stickyClassName:c,className:d,cardClassName:f,contentClassName:R}){const S=!!(s||a),te=jsxRuntime.jsxs("header",{className:cn("w-full border-b border-border bg-background",d),children:[jsxRuntime.jsx("div",{className:cn(primaryRowPaddingClassName,f),children:jsxRuntime.jsxs("div",{className:cn("flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",R),children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[n?.length?jsxRuntime.jsx(RmPageHeaderBreadcrumbs,{items:n}):null,jsxRuntime.jsx("h1",{className:"text-2xl font-semibold leading-tight tracking-tight text-foreground",children:e}),t?jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:t}):null]}),S?jsxRuntime.jsxs("div",{className:"flex w-full flex-col items-start gap-2 lg:w-auto lg:min-w-[16rem] lg:items-end",children:[s?jsxRuntime.jsx("div",{className:"flex w-full flex-wrap items-center justify-start gap-2 lg:justify-end",children:s}):null,a?jsxRuntime.jsx("div",{className:"flex w-full flex-wrap items-center justify-start gap-2 lg:justify-end",children:a}):null]}):null]})}),o?jsxRuntime.jsx("div",{className:"border-t border-border bg-primary/5",children:jsxRuntime.jsx("div",{className:secondaryRowPaddingClassName,children:o})}):null]});return l?jsxRuntime.jsx("div",{className:fullBleedClassName,children:jsxRuntime.jsx("div",{className:cn("sticky top-0 z-20",c),children:te})}):jsxRuntime.jsx("div",{className:fullBleedClassName,children:te})}function PageHeader({title:e,children:t,className:n}){return jsxRuntime.jsx(RmPageHeader,{title:e,rightBottomActions:t?jsxRuntime.jsx("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:t}):void 0,cardClassName:n})}const PARTNER_PAGE_SHELL_STACK_CLASS_NAME="space-y-8",PARTNER_PAGE_SHELL_CONTENT_CLASS_NAME="px-4 py-4 sm:px-6 sm:py-6";function PartnerPageShell({header:e,children:t,className:n,contentClassName:s,contentProps:a,...o}){return jsxRuntime.jsxs("section",{className:cn(PARTNER_PAGE_SHELL_STACK_CLASS_NAME,n),...o,children:[e,jsxRuntime.jsx("div",{className:cn(PARTNER_PAGE_SHELL_CONTENT_CLASS_NAME,s),...a,children:t})]})}function RmBodyZone({className:e,children:t,...n}){return jsxRuntime.jsx("section",{className:cn("px-4 py-4 sm:px-6 sm:py-6",e),...n,children:t})}function OrderedMap(e){this.content=e}OrderedMap.prototype={constructor:OrderedMap,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var s=n&&n!=e?this.remove(n):this,a=s.find(e),o=s.content.slice();return a==-1?o.push(n||e,t):(o[a+1]=t,n&&(o[a]=n)),new OrderedMap(o)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new OrderedMap(n)},addToStart:function(e,t){return new OrderedMap([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new OrderedMap(n)},addBefore:function(e,t,n){var s=this.remove(t),a=s.content.slice(),o=s.find(e);return a.splice(o==-1?a.length:o,0,t,n),new OrderedMap(a)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=OrderedMap.from(e),e.size?new OrderedMap(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=OrderedMap.from(e),e.size?new OrderedMap(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=OrderedMap.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},OrderedMap.from=function(e){if(e instanceof OrderedMap)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new OrderedMap(t)};function findDiffStart(e,t,n){for(let s=0;;s++){if(s==e.childCount||s==t.childCount)return e.childCount==t.childCount?null:n;let a=e.child(s),o=t.child(s);if(a==o){n+=a.nodeSize;continue}if(!a.sameMarkup(o))return n;if(a.isText&&a.text!=o.text){for(let l=0;a.text[l]==o.text[l];l++)n++;return n}if(a.content.size||o.content.size){let l=findDiffStart(a.content,o.content,n+1);if(l!=null)return l}n+=a.nodeSize}}function findDiffEnd(e,t,n,s){for(let a=e.childCount,o=t.childCount;;){if(a==0||o==0)return a==o?null:{a:n,b:s};let l=e.child(--a),c=t.child(--o),d=l.nodeSize;if(l==c){n-=d,s-=d;continue}if(!l.sameMarkup(c))return{a:n,b:s};if(l.isText&&l.text!=c.text){let f=0,R=Math.min(l.text.length,c.text.length);for(;f<R&&l.text[l.text.length-f-1]==c.text[c.text.length-f-1];)f++,n--,s--;return{a:n,b:s}}if(l.content.size||c.content.size){let f=findDiffEnd(l.content,c.content,n-1,s-1);if(f)return f}n-=d,s-=d}}class Fragment{constructor(t,n){if(this.content=t,this.size=n||0,n==null)for(let s=0;s<t.length;s++)this.size+=t[s].nodeSize}nodesBetween(t,n,s,a=0,o){for(let l=0,c=0;c<n;l++){let d=this.content[l],f=c+d.nodeSize;if(f>t&&s(d,a+c,o||null,l)!==!1&&d.content.size){let R=c+1;d.nodesBetween(Math.max(0,t-R),Math.min(d.content.size,n-R),s,a+R)}c=f}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,n,s,a){let o="",l=!0;return this.nodesBetween(t,n,(c,d)=>{let f=c.isText?c.text.slice(Math.max(t,d)-d,n-d):c.isLeaf?a?typeof a=="function"?a(c):a:c.type.spec.leafText?c.type.spec.leafText(c):"":"";c.isBlock&&(c.isLeaf&&f||c.isTextblock)&&s&&(l?l=!1:o+=s),o+=f},0),o}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,s=t.firstChild,a=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(s)&&(a[a.length-1]=n.withText(n.text+s.text),o=1);o<t.content.length;o++)a.push(t.content[o]);return new Fragment(a,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let s=[],a=0;if(n>t)for(let o=0,l=0;l<n;o++){let c=this.content[o],d=l+c.nodeSize;d>t&&((l<t||d>n)&&(c.isText?c=c.cut(Math.max(0,t-l),Math.min(c.text.length,n-l)):c=c.cut(Math.max(0,t-l-1),Math.min(c.content.size,n-l-1))),s.push(c),a+=c.nodeSize),l=d}return new Fragment(s,a)}cutByIndex(t,n){return t==n?Fragment.empty:t==0&&n==this.content.length?this:new Fragment(this.content.slice(t,n))}replaceChild(t,n){let s=this.content[t];if(s==n)return this;let a=this.content.slice(),o=this.size+n.nodeSize-s.nodeSize;return a[t]=n,new Fragment(a,o)}addToStart(t){return new Fragment([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new Fragment(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(t.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let n=this.content[t];if(!n)throw new RangeError("Index "+t+" out of range for "+this);return n}maybeChild(t){return this.content[t]||null}forEach(t){for(let n=0,s=0;n<this.content.length;n++){let a=this.content[n];t(a,s,n),s+=a.nodeSize}}findDiffStart(t,n=0){return findDiffStart(this,t,n)}findDiffEnd(t,n=this.size,s=t.size){return findDiffEnd(this,t,n,s)}findIndex(t){if(t==0)return retIndex(0,t);if(t==this.size)return retIndex(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,s=0;;n++){let a=this.child(n),o=s+a.nodeSize;if(o>=t)return o==t?retIndex(n+1,o):retIndex(n,s);s=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,n){if(!n)return Fragment.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Fragment(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return Fragment.empty;let n,s=0;for(let a=0;a<t.length;a++){let o=t[a];s+=o.nodeSize,a&&o.isText&&t[a-1].sameMarkup(o)?(n||(n=t.slice(0,a)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new Fragment(n||t,s)}static from(t){if(!t)return Fragment.empty;if(t instanceof Fragment)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new Fragment([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Fragment.empty=new Fragment([],0);const found={index:0,offset:0};function retIndex(e,t){return found.index=e,found.offset=t,found}function compareDeep(e,t){if(e===t)return!0;if(!(e&&typeof e=="object")||!(t&&typeof t=="object"))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let s=0;s<e.length;s++)if(!compareDeep(e[s],t[s]))return!1}else{for(let s in e)if(!(s in t)||!compareDeep(e[s],t[s]))return!1;for(let s in t)if(!(s in e))return!1}return!0}let Mark$1=class Vn{constructor(t,n){this.type=t,this.attrs=n}addToSet(t){let n,s=!1;for(let a=0;a<t.length;a++){let o=t[a];if(this.eq(o))return t;if(this.type.excludes(o.type))n||(n=t.slice(0,a));else{if(o.type.excludes(this.type))return t;!s&&o.type.rank>this.type.rank&&(n||(n=t.slice(0,a)),n.push(this),s=!0),n&&n.push(o)}}return n||(n=t.slice()),s||n.push(this),n}removeFromSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return t.slice(0,n).concat(t.slice(n+1));return t}isInSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return!0;return!1}eq(t){return this==t||this.type==t.type&&compareDeep(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let s=t.marks[n.type];if(!s)throw new RangeError(`There is no mark type ${n.type} in this schema`);let a=s.create(n.attrs);return s.checkAttrs(a.attrs),a}static sameSet(t,n){if(t==n)return!0;if(t.length!=n.length)return!1;for(let s=0;s<t.length;s++)if(!t[s].eq(n[s]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return Vn.none;if(t instanceof Vn)return[t];let n=t.slice();return n.sort((s,a)=>s.type.rank-a.type.rank),n}};Mark$1.none=[];class ReplaceError extends Error{}class Slice{constructor(t,n,s){this.content=t,this.openStart=n,this.openEnd=s}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let s=insertInto(this.content,t+this.openStart,n);return s&&new Slice(s,this.openStart,this.openEnd)}removeBetween(t,n){return new Slice(removeRange(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,n){if(!n)return Slice.empty;let s=n.openStart||0,a=n.openEnd||0;if(typeof s!="number"||typeof a!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Slice(Fragment.fromJSON(t,n.content),s,a)}static maxOpen(t,n=!0){let s=0,a=0;for(let o=t.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)s++;for(let o=t.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)a++;return new Slice(t,s,a)}}Slice.empty=new Slice(Fragment.empty,0,0);function removeRange(e,t,n){let{index:s,offset:a}=e.findIndex(t),o=e.maybeChild(s),{index:l,offset:c}=e.findIndex(n);if(a==t||o.isText){if(c!=n&&!e.child(l).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(s!=l)throw new RangeError("Removing non-flat range");return e.replaceChild(s,o.copy(removeRange(o.content,t-a-1,n-a-1)))}function insertInto(e,t,n,s){let{index:a,offset:o}=e.findIndex(t),l=e.maybeChild(a);if(o==t||l.isText)return s&&!s.canReplace(a,a,n)?null:e.cut(0,t).append(n).append(e.cut(t));let c=insertInto(l.content,t-o-1,n,l);return c&&e.replaceChild(a,l.copy(c))}function replace(e,t,n){if(n.openStart>e.depth)throw new ReplaceError("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new ReplaceError("Inconsistent open depths");return replaceOuter(e,t,n,0)}function replaceOuter(e,t,n,s){let a=e.index(s),o=e.node(s);if(a==t.index(s)&&s<e.depth-n.openStart){let l=replaceOuter(e,t,n,s+1);return o.copy(o.content.replaceChild(a,l))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&e.depth==s&&t.depth==s){let l=e.parent,c=l.content;return close(l,c.cut(0,e.parentOffset).append(n.content).append(c.cut(t.parentOffset)))}else{let{start:l,end:c}=prepareSliceForReplace(n,e);return close(o,replaceThreeWay(e,l,c,t,s))}else return close(o,replaceTwoWay(e,t,s))}function checkJoin(e,t){if(!t.type.compatibleContent(e.type))throw new ReplaceError("Cannot join "+t.type.name+" onto "+e.type.name)}function joinable$1(e,t,n){let s=e.node(n);return checkJoin(s,t.node(n)),s}function addNode(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function addRange(e,t,n,s){let a=(t||e).node(n),o=0,l=t?t.index(n):a.childCount;e&&(o=e.index(n),e.depth>n?o++:e.textOffset&&(addNode(e.nodeAfter,s),o++));for(let c=o;c<l;c++)addNode(a.child(c),s);t&&t.depth==n&&t.textOffset&&addNode(t.nodeBefore,s)}function close(e,t){return e.type.checkContent(t),e.copy(t)}function replaceThreeWay(e,t,n,s,a){let o=e.depth>a&&joinable$1(e,t,a+1),l=s.depth>a&&joinable$1(n,s,a+1),c=[];return addRange(null,e,a,c),o&&l&&t.index(a)==n.index(a)?(checkJoin(o,l),addNode(close(o,replaceThreeWay(e,t,n,s,a+1)),c)):(o&&addNode(close(o,replaceTwoWay(e,t,a+1)),c),addRange(t,n,a,c),l&&addNode(close(l,replaceTwoWay(n,s,a+1)),c)),addRange(s,null,a,c),new Fragment(c)}function replaceTwoWay(e,t,n){let s=[];if(addRange(null,e,n,s),e.depth>n){let a=joinable$1(e,t,n+1);addNode(close(a,replaceTwoWay(e,t,n+1)),s)}return addRange(t,null,n,s),new Fragment(s)}function prepareSliceForReplace(e,t){let n=t.depth-e.openStart,a=t.node(n).copy(e.content);for(let o=n-1;o>=0;o--)a=t.node(o).copy(Fragment.from(a));return{start:a.resolveNoCache(e.openStart+n),end:a.resolveNoCache(a.content.size-e.openEnd-n)}}class ResolvedPos{constructor(t,n,s){this.pos=t,this.path=n,this.parentOffset=s,this.depth=n.length/3-1}resolveDepth(t){return t==null?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){return t=this.resolveDepth(t),t==0?0:this.path[t*3-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,n=this.index(this.depth);if(n==t.childCount)return null;let s=this.pos-this.path[this.path.length-1],a=t.child(n);return s?t.child(n).cut(s):a}get nodeBefore(){let t=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(t).cut(0,n):t==0?null:this.parent.child(t-1)}posAtIndex(t,n){n=this.resolveDepth(n);let s=this.path[n*3],a=n==0?0:this.path[n*3-1]+1;for(let o=0;o<t;o++)a+=s.child(o).nodeSize;return a}marks(){let t=this.parent,n=this.index();if(t.content.size==0)return Mark$1.none;if(this.textOffset)return t.child(n).marks;let s=t.maybeChild(n-1),a=t.maybeChild(n);if(!s){let c=s;s=a,a=c}let o=s.marks;for(var l=0;l<o.length;l++)o[l].type.spec.inclusive===!1&&(!a||!o[l].isInSet(a.marks))&&(o=o[l--].removeFromSet(o));return o}marksAcross(t){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let s=n.marks,a=t.parent.maybeChild(t.index());for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!a||!s[o].isInSet(a.marks))&&(s=s[o--].removeFromSet(s));return s}sharedDepth(t){for(let n=this.depth;n>0;n--)if(this.start(n)<=t&&this.end(n)>=t)return n;return 0}blockRange(t=this,n){if(t.pos<this.pos)return t.blockRange(this);for(let s=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);s>=0;s--)if(t.pos<=this.end(s)&&(!n||n(this.node(s))))return new NodeRange(this,t,s);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let n=1;n<=this.depth;n++)t+=(t?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return t+":"+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw new RangeError("Position "+n+" out of range");let s=[],a=0,o=n;for(let l=t;;){let{index:c,offset:d}=l.content.findIndex(o),f=o-d;if(s.push(l,c,a+d),!f||(l=l.child(c),l.isText))break;o=f-1,a+=d+1}return new ResolvedPos(n,s,o)}static resolveCached(t,n){let s=resolveCache.get(t);if(s)for(let o=0;o<s.elts.length;o++){let l=s.elts[o];if(l.pos==n)return l}else resolveCache.set(t,s=new ResolveCache);let a=s.elts[s.i]=ResolvedPos.resolve(t,n);return s.i=(s.i+1)%resolveCacheSize,a}}class ResolveCache{constructor(){this.elts=[],this.i=0}}const resolveCacheSize=12,resolveCache=new WeakMap;class NodeRange{constructor(t,n,s){this.$from=t,this.$to=n,this.depth=s}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const emptyAttrs=Object.create(null);let Node$1=class zn{constructor(t,n,s,a=Mark$1.none){this.type=t,this.attrs=n,this.marks=a,this.content=s||Fragment.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,n,s,a=0){this.content.nodesBetween(t,n,s,a,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,n,s,a){return this.content.textBetween(t,n,s,a)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,n,s){return this.type==t&&compareDeep(this.attrs,n||t.defaultAttrs||emptyAttrs)&&Mark$1.sameSet(this.marks,s||Mark$1.none)}copy(t=null){return t==this.content?this:new zn(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new zn(this.type,this.attrs,this.content,t)}cut(t,n=this.content.size){return t==0&&n==this.content.size?this:this.copy(this.content.cut(t,n))}slice(t,n=this.content.size,s=!1){if(t==n)return Slice.empty;let a=this.resolve(t),o=this.resolve(n),l=s?0:a.sharedDepth(n),c=a.start(l),f=a.node(l).content.cut(a.pos-c,o.pos-c);return new Slice(f,a.depth-l,o.depth-l)}replace(t,n,s){return replace(this.resolve(t),this.resolve(n),s)}nodeAt(t){for(let n=this;;){let{index:s,offset:a}=n.content.findIndex(t);if(n=n.maybeChild(s),!n)return null;if(a==t||n.isText)return n;t-=a+1}}childAfter(t){let{index:n,offset:s}=this.content.findIndex(t);return{node:this.content.maybeChild(n),index:n,offset:s}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:n,offset:s}=this.content.findIndex(t);if(s<t)return{node:this.content.child(n),index:n,offset:s};let a=this.content.child(n-1);return{node:a,index:n-1,offset:s-a.nodeSize}}resolve(t){return ResolvedPos.resolveCached(this,t)}resolveNoCache(t){return ResolvedPos.resolve(this,t)}rangeHasMark(t,n,s){let a=!1;return n>t&&this.nodesBetween(t,n,o=>(s.isInSet(o.marks)&&(a=!0),!a)),a}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),wrapMarks(this.marks,t)}contentMatchAt(t){let n=this.type.contentMatch.matchFragment(this.content,0,t);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(t,n,s=Fragment.empty,a=0,o=s.childCount){let l=this.contentMatchAt(t).matchFragment(s,a,o),c=l&&l.matchFragment(this.content,n);if(!c||!c.validEnd)return!1;for(let d=a;d<o;d++)if(!this.type.allowsMarks(s.child(d).marks))return!1;return!0}canReplaceWith(t,n,s,a){if(a&&!this.type.allowsMarks(a))return!1;let o=this.contentMatchAt(t).matchType(s),l=o&&o.matchFragment(this.content,n);return l?l.validEnd:!1}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let t=Mark$1.none;for(let n=0;n<this.marks.length;n++){let s=this.marks[n];s.type.checkAttrs(s.attrs),t=s.addToSet(t)}if(!Mark$1.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map(n=>n.toJSON())),t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let s;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");s=n.marks.map(t.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(n.text,s)}let a=Fragment.fromJSON(t,n.content),o=t.nodeType(n.type).create(n.attrs,a,s);return o.type.checkAttrs(o.attrs),o}};Node$1.prototype.text=void 0;class TextNode extends Node$1{constructor(t,n,s,a){if(super(t,n,null,a),!s)throw new RangeError("Empty text nodes are not allowed");this.text=s}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):wrapMarks(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,n){return this.text.slice(t,n)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new TextNode(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new TextNode(this.type,this.attrs,t,this.marks)}cut(t=0,n=this.text.length){return t==0&&n==this.text.length?this:this.withText(this.text.slice(t,n))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function wrapMarks(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class ContentMatch{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,n){let s=new TokenStream(t,n);if(s.next==null)return ContentMatch.empty;let a=parseExpr(s);s.next&&s.err("Unexpected trailing text");let o=dfa(nfa(a));return checkForDeadEnds(o,s),o}matchType(t){for(let n=0;n<this.next.length;n++)if(this.next[n].type==t)return this.next[n].next;return null}matchFragment(t,n=0,s=t.childCount){let a=this;for(let o=n;a&&o<s;o++)a=a.matchType(t.child(o).type);return a}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:n}=this.next[t];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(t){for(let n=0;n<this.next.length;n++)for(let s=0;s<t.next.length;s++)if(this.next[n].type==t.next[s].type)return!0;return!1}fillBefore(t,n=!1,s=0){let a=[this];function o(l,c){let d=l.matchFragment(t,s);if(d&&(!n||d.validEnd))return Fragment.from(c.map(f=>f.createAndFill()));for(let f=0;f<l.next.length;f++){let{type:R,next:S}=l.next[f];if(!(R.isText||R.hasRequiredAttrs())&&a.indexOf(S)==-1){a.push(S);let te=o(S,c.concat(R));if(te)return te}}return null}return o(this,[])}findWrapping(t){for(let s=0;s<this.wrapCache.length;s+=2)if(this.wrapCache[s]==t)return this.wrapCache[s+1];let n=this.computeWrapping(t);return this.wrapCache.push(t,n),n}computeWrapping(t){let n=Object.create(null),s=[{match:this,type:null,via:null}];for(;s.length;){let a=s.shift(),o=a.match;if(o.matchType(t)){let l=[];for(let c=a;c.type;c=c.via)l.push(c.type);return l.reverse()}for(let l=0;l<o.next.length;l++){let{type:c,next:d}=o.next[l];!c.isLeaf&&!c.hasRequiredAttrs()&&!(c.name in n)&&(!a.type||d.validEnd)&&(s.push({match:c.contentMatch,type:c,via:a}),n[c.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function n(s){t.push(s);for(let a=0;a<s.next.length;a++)t.indexOf(s.next[a].next)==-1&&n(s.next[a].next)}return n(this),t.map((s,a)=>{let o=a+(s.validEnd?"*":" ")+" ";for(let l=0;l<s.next.length;l++)o+=(l?", ":"")+s.next[l].type.name+"->"+t.indexOf(s.next[l].next);return o}).join(`
|
|
523
|
+
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return React__namespace.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},Root2$1=AlertDialog$1,Trigger2$1=AlertDialogTrigger$1,Portal2=AlertDialogPortal$1,Overlay2=AlertDialogOverlay$1,Content2$1=AlertDialogContent$1,Action=AlertDialogAction$1,Cancel=AlertDialogCancel$1,Title2=AlertDialogTitle$1,Description2=AlertDialogDescription$1;const AlertDialog=Root2$1,AlertDialogTrigger=Trigger2$1,AlertDialogPortal=Portal2,AlertDialogOverlay=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Overlay2,{className:cn("fixed inset-0 z-50 bg-foreground/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));AlertDialogOverlay.displayName=Overlay2.displayName;const AlertDialogContent=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsxs(AlertDialogPortal,{children:[jsxRuntime.jsx(AlertDialogOverlay,{}),jsxRuntime.jsx(Content2$1,{ref:n,className:cn("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]}));AlertDialogContent.displayName=Content2$1.displayName;const AlertDialogHeader=({className:e,...t})=>jsxRuntime.jsx("div",{className:cn("flex flex-col space-y-2 text-center sm:text-left",e),...t});AlertDialogHeader.displayName="AlertDialogHeader";const AlertDialogFooter=({className:e,...t})=>jsxRuntime.jsx("div",{className:cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});AlertDialogFooter.displayName="AlertDialogFooter";const AlertDialogTitle=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Title2,{ref:n,className:cn("text-lg font-semibold",e),...t}));AlertDialogTitle.displayName=Title2.displayName;const AlertDialogDescription=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Description2,{ref:n,className:cn("text-sm text-muted-foreground",e),...t}));AlertDialogDescription.displayName=Description2.displayName;const AlertDialogAction=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Action,{ref:n,className:cn(buttonVariants(),e),...t}));AlertDialogAction.displayName=Action.displayName;const AlertDialogCancel=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Cancel,{ref:n,className:cn(buttonVariants({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));AlertDialogCancel.displayName=Cancel.displayName;const MOBILE_ASSISTANT_URL="https://assistant.randmar.io";function parseDate(e){if(e==null)return null;const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?null:t}function formatLastRefresh(e){const t=parseDate(e);if(!t)return"Never";const n=new Date;return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate()?`Today at ${new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit",timeZoneName:"short"}).format(t)}`:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}).format(t)}function RefreshCluster({lastRefreshAt:e,onRefresh:t,onProgressiveRefresh:n,onAssistantClick:s,isRefreshing:a=!1,refreshLabel:o="Refresh",assistantLabel:l="Assistant",className:c,disabled:d=!1}){const[f,R]=React__namespace.useState(!1),[S,te]=React__namespace.useState(e);React__namespace.useEffect(()=>{te(e)},[e]);const A=!!(t||n),rt=a||f,st=e??S,it=React__namespace.useCallback(async()=>{if(!(!A||d||rt)){R(!0);try{n?(await n(!1),await n(!0)):await t?.(),te(new Date)}finally{R(!1)}}},[A,d,rt,n,t]);return jsxRuntime.jsxs("div",{className:cn("flex w-full flex-wrap items-center justify-start gap-2 lg:w-auto lg:justify-end",c),children:[jsxRuntime.jsxs("p",{className:"w-full text-xs text-muted-foreground sm:text-sm lg:w-auto",children:["Last refresh:"," ",jsxRuntime.jsx("span",{className:"font-medium text-foreground",children:formatLastRefresh(st)})]}),jsxRuntime.jsxs(Button$1,{type:"button",variant:"outline",className:"min-h-11",disabled:d||rt||!A,onClick:it,children:[rt?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}):jsxRuntime.jsx(RefreshCw,{className:"h-4 w-4","aria-hidden":"true"}),jsxRuntime.jsx("span",{children:o})]}),jsxRuntime.jsx(Button$1,{asChild:!0,variant:"default",className:cn("min-h-11 lg:hidden",d&&"pointer-events-none opacity-50"),children:jsxRuntime.jsxs("a",{href:MOBILE_ASSISTANT_URL,target:"_blank",rel:"noopener noreferrer","aria-disabled":d||void 0,onClick:d?at=>at.preventDefault():void 0,children:[jsxRuntime.jsx(Bot,{className:"h-4 w-4","aria-hidden":"true"}),jsxRuntime.jsx("span",{children:l})]})}),jsxRuntime.jsxs(Button$1,{type:"button",variant:"default",className:"hidden min-h-11 lg:inline-flex",disabled:d,onClick:s,children:[jsxRuntime.jsx(Bot,{className:"h-4 w-4","aria-hidden":"true"}),jsxRuntime.jsx("span",{children:l})]})]})}function DataRefreshAssistantCluster({onAssistantClick:e,assistantPromptOptions:t,onAssistantUnavailable:n,...s}){const a=useOptionalChat(),o=React__namespace.useCallback(()=>{if(e){e();return}if(t){if(!a){n?.();return}a.sendMessageWithClear(t.prompt,t.hiddenPrompt,t.sopID)||n?.();return}n?.()},[t,a,e,n]);return jsxRuntime.jsx(RefreshCluster,{...s,onAssistantClick:o})}const fullBleedClassName="w-full max-w-none w-[100cqw] ml-[calc(50%-50cqw)] mr-[calc(50%-50cqw)]",rowInlinePaddingClassName="px-4 lg:px-6",primaryRowPaddingClassName=`${rowInlinePaddingClassName} py-4`,secondaryRowPaddingClassName=`${rowInlinePaddingClassName} py-3`;function RmPageHeaderBreadcrumbLink({item:e,isCurrent:t}){return!t&&e.href?jsxRuntime.jsx("a",{href:e.href,className:"text-xs font-medium text-muted-foreground underline-offset-4 transition-colors hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:e.label}):!t&&e.onClick?jsxRuntime.jsx("button",{type:"button",className:"text-xs font-medium text-muted-foreground underline-offset-4 transition-colors hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",onClick:e.onClick,children:e.label}):jsxRuntime.jsx("span",{"aria-current":t?"page":void 0,className:cn("text-xs font-medium",t?"text-foreground":"text-muted-foreground"),children:e.label})}function RmPageHeaderBreadcrumbs({items:e}){return e.length===0?null:jsxRuntime.jsx("nav",{"aria-label":"Breadcrumb",className:"w-full",children:jsxRuntime.jsx("ol",{className:"flex flex-wrap items-center gap-1.5",children:e.map((t,n)=>{const s=n===e.length-1,a=t.key??`${String(t.label)}-${n}`;return jsxRuntime.jsxs("li",{className:"inline-flex items-center gap-1.5",children:[jsxRuntime.jsx(RmPageHeaderBreadcrumbLink,{item:t,isCurrent:!!t.current||s}),s?null:jsxRuntime.jsx("span",{"aria-hidden":"true",className:"text-xs text-muted-foreground",children:"/"})]},a)})})})}function RmPageHeader({title:e,subtitle:t,breadcrumbs:n,rightTopActions:s,rightBottomActions:a,secondaryRow:o,sticky:l=!1,stickyClassName:c,className:d,cardClassName:f,contentClassName:R}){const S=!!(s||a),te=jsxRuntime.jsxs("header",{className:cn("w-full border-b border-border bg-background",d),children:[jsxRuntime.jsx("div",{className:cn(primaryRowPaddingClassName,f),children:jsxRuntime.jsxs("div",{className:cn("flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",R),children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[n?.length?jsxRuntime.jsx(RmPageHeaderBreadcrumbs,{items:n}):null,jsxRuntime.jsx("h1",{className:"text-2xl font-semibold leading-tight tracking-tight text-foreground",children:e}),t?jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:t}):null]}),S?jsxRuntime.jsxs("div",{className:"flex w-full flex-col items-start gap-2 lg:w-auto lg:min-w-[16rem] lg:items-end",children:[s?jsxRuntime.jsx("div",{className:"flex w-full flex-wrap items-center justify-start gap-2 lg:justify-end",children:s}):null,a?jsxRuntime.jsx("div",{className:"flex w-full flex-wrap items-center justify-start gap-2 lg:justify-end",children:a}):null]}):null]})}),o?jsxRuntime.jsx("div",{className:"border-t border-border bg-primary/5",children:jsxRuntime.jsx("div",{className:secondaryRowPaddingClassName,children:o})}):null]});return l?jsxRuntime.jsx("div",{className:fullBleedClassName,children:jsxRuntime.jsx("div",{className:cn("sticky top-0 z-20",c),children:te})}):jsxRuntime.jsx("div",{className:fullBleedClassName,children:te})}function PageHeader({title:e,children:t,className:n}){return jsxRuntime.jsx(RmPageHeader,{title:e,rightBottomActions:t?jsxRuntime.jsx("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:t}):void 0,cardClassName:n})}const PARTNER_PAGE_SHELL_STACK_CLASS_NAME="space-y-8",PARTNER_PAGE_SHELL_CONTENT_CLASS_NAME="px-4 py-4 sm:px-6 sm:py-6";function PartnerPageShell({header:e,children:t,className:n,contentClassName:s,contentProps:a,...o}){return jsxRuntime.jsxs("section",{className:cn(PARTNER_PAGE_SHELL_STACK_CLASS_NAME,n),...o,children:[e,jsxRuntime.jsx("div",{className:cn(PARTNER_PAGE_SHELL_CONTENT_CLASS_NAME,s),...a,children:t})]})}function RmBodyZone({className:e,children:t,...n}){return jsxRuntime.jsx("section",{className:cn("px-4 py-4 sm:px-6 sm:py-6",e),...n,children:t})}function OrderedMap(e){this.content=e}OrderedMap.prototype={constructor:OrderedMap,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var s=n&&n!=e?this.remove(n):this,a=s.find(e),o=s.content.slice();return a==-1?o.push(n||e,t):(o[a+1]=t,n&&(o[a]=n)),new OrderedMap(o)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new OrderedMap(n)},addToStart:function(e,t){return new OrderedMap([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new OrderedMap(n)},addBefore:function(e,t,n){var s=this.remove(t),a=s.content.slice(),o=s.find(e);return a.splice(o==-1?a.length:o,0,t,n),new OrderedMap(a)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=OrderedMap.from(e),e.size?new OrderedMap(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=OrderedMap.from(e),e.size?new OrderedMap(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=OrderedMap.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},OrderedMap.from=function(e){if(e instanceof OrderedMap)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new OrderedMap(t)};function findDiffStart(e,t,n){for(let s=0;;s++){if(s==e.childCount||s==t.childCount)return e.childCount==t.childCount?null:n;let a=e.child(s),o=t.child(s);if(a==o){n+=a.nodeSize;continue}if(!a.sameMarkup(o))return n;if(a.isText&&a.text!=o.text){for(let l=0;a.text[l]==o.text[l];l++)n++;return n}if(a.content.size||o.content.size){let l=findDiffStart(a.content,o.content,n+1);if(l!=null)return l}n+=a.nodeSize}}function findDiffEnd(e,t,n,s){for(let a=e.childCount,o=t.childCount;;){if(a==0||o==0)return a==o?null:{a:n,b:s};let l=e.child(--a),c=t.child(--o),d=l.nodeSize;if(l==c){n-=d,s-=d;continue}if(!l.sameMarkup(c))return{a:n,b:s};if(l.isText&&l.text!=c.text){let f=0,R=Math.min(l.text.length,c.text.length);for(;f<R&&l.text[l.text.length-f-1]==c.text[c.text.length-f-1];)f++,n--,s--;return{a:n,b:s}}if(l.content.size||c.content.size){let f=findDiffEnd(l.content,c.content,n-1,s-1);if(f)return f}n-=d,s-=d}}class Fragment{constructor(t,n){if(this.content=t,this.size=n||0,n==null)for(let s=0;s<t.length;s++)this.size+=t[s].nodeSize}nodesBetween(t,n,s,a=0,o){for(let l=0,c=0;c<n;l++){let d=this.content[l],f=c+d.nodeSize;if(f>t&&s(d,a+c,o||null,l)!==!1&&d.content.size){let R=c+1;d.nodesBetween(Math.max(0,t-R),Math.min(d.content.size,n-R),s,a+R)}c=f}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,n,s,a){let o="",l=!0;return this.nodesBetween(t,n,(c,d)=>{let f=c.isText?c.text.slice(Math.max(t,d)-d,n-d):c.isLeaf?a?typeof a=="function"?a(c):a:c.type.spec.leafText?c.type.spec.leafText(c):"":"";c.isBlock&&(c.isLeaf&&f||c.isTextblock)&&s&&(l?l=!1:o+=s),o+=f},0),o}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,s=t.firstChild,a=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(s)&&(a[a.length-1]=n.withText(n.text+s.text),o=1);o<t.content.length;o++)a.push(t.content[o]);return new Fragment(a,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let s=[],a=0;if(n>t)for(let o=0,l=0;l<n;o++){let c=this.content[o],d=l+c.nodeSize;d>t&&((l<t||d>n)&&(c.isText?c=c.cut(Math.max(0,t-l),Math.min(c.text.length,n-l)):c=c.cut(Math.max(0,t-l-1),Math.min(c.content.size,n-l-1))),s.push(c),a+=c.nodeSize),l=d}return new Fragment(s,a)}cutByIndex(t,n){return t==n?Fragment.empty:t==0&&n==this.content.length?this:new Fragment(this.content.slice(t,n))}replaceChild(t,n){let s=this.content[t];if(s==n)return this;let a=this.content.slice(),o=this.size+n.nodeSize-s.nodeSize;return a[t]=n,new Fragment(a,o)}addToStart(t){return new Fragment([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new Fragment(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(t.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let n=this.content[t];if(!n)throw new RangeError("Index "+t+" out of range for "+this);return n}maybeChild(t){return this.content[t]||null}forEach(t){for(let n=0,s=0;n<this.content.length;n++){let a=this.content[n];t(a,s,n),s+=a.nodeSize}}findDiffStart(t,n=0){return findDiffStart(this,t,n)}findDiffEnd(t,n=this.size,s=t.size){return findDiffEnd(this,t,n,s)}findIndex(t){if(t==0)return retIndex(0,t);if(t==this.size)return retIndex(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,s=0;;n++){let a=this.child(n),o=s+a.nodeSize;if(o>=t)return o==t?retIndex(n+1,o):retIndex(n,s);s=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,n){if(!n)return Fragment.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Fragment(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return Fragment.empty;let n,s=0;for(let a=0;a<t.length;a++){let o=t[a];s+=o.nodeSize,a&&o.isText&&t[a-1].sameMarkup(o)?(n||(n=t.slice(0,a)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new Fragment(n||t,s)}static from(t){if(!t)return Fragment.empty;if(t instanceof Fragment)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new Fragment([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Fragment.empty=new Fragment([],0);const found={index:0,offset:0};function retIndex(e,t){return found.index=e,found.offset=t,found}function compareDeep(e,t){if(e===t)return!0;if(!(e&&typeof e=="object")||!(t&&typeof t=="object"))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let s=0;s<e.length;s++)if(!compareDeep(e[s],t[s]))return!1}else{for(let s in e)if(!(s in t)||!compareDeep(e[s],t[s]))return!1;for(let s in t)if(!(s in e))return!1}return!0}let Mark$1=class Vn{constructor(t,n){this.type=t,this.attrs=n}addToSet(t){let n,s=!1;for(let a=0;a<t.length;a++){let o=t[a];if(this.eq(o))return t;if(this.type.excludes(o.type))n||(n=t.slice(0,a));else{if(o.type.excludes(this.type))return t;!s&&o.type.rank>this.type.rank&&(n||(n=t.slice(0,a)),n.push(this),s=!0),n&&n.push(o)}}return n||(n=t.slice()),s||n.push(this),n}removeFromSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return t.slice(0,n).concat(t.slice(n+1));return t}isInSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return!0;return!1}eq(t){return this==t||this.type==t.type&&compareDeep(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let s=t.marks[n.type];if(!s)throw new RangeError(`There is no mark type ${n.type} in this schema`);let a=s.create(n.attrs);return s.checkAttrs(a.attrs),a}static sameSet(t,n){if(t==n)return!0;if(t.length!=n.length)return!1;for(let s=0;s<t.length;s++)if(!t[s].eq(n[s]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return Vn.none;if(t instanceof Vn)return[t];let n=t.slice();return n.sort((s,a)=>s.type.rank-a.type.rank),n}};Mark$1.none=[];class ReplaceError extends Error{}class Slice{constructor(t,n,s){this.content=t,this.openStart=n,this.openEnd=s}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let s=insertInto(this.content,t+this.openStart,n);return s&&new Slice(s,this.openStart,this.openEnd)}removeBetween(t,n){return new Slice(removeRange(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,n){if(!n)return Slice.empty;let s=n.openStart||0,a=n.openEnd||0;if(typeof s!="number"||typeof a!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Slice(Fragment.fromJSON(t,n.content),s,a)}static maxOpen(t,n=!0){let s=0,a=0;for(let o=t.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)s++;for(let o=t.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)a++;return new Slice(t,s,a)}}Slice.empty=new Slice(Fragment.empty,0,0);function removeRange(e,t,n){let{index:s,offset:a}=e.findIndex(t),o=e.maybeChild(s),{index:l,offset:c}=e.findIndex(n);if(a==t||o.isText){if(c!=n&&!e.child(l).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(s!=l)throw new RangeError("Removing non-flat range");return e.replaceChild(s,o.copy(removeRange(o.content,t-a-1,n-a-1)))}function insertInto(e,t,n,s){let{index:a,offset:o}=e.findIndex(t),l=e.maybeChild(a);if(o==t||l.isText)return s&&!s.canReplace(a,a,n)?null:e.cut(0,t).append(n).append(e.cut(t));let c=insertInto(l.content,t-o-1,n,l);return c&&e.replaceChild(a,l.copy(c))}function replace(e,t,n){if(n.openStart>e.depth)throw new ReplaceError("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new ReplaceError("Inconsistent open depths");return replaceOuter(e,t,n,0)}function replaceOuter(e,t,n,s){let a=e.index(s),o=e.node(s);if(a==t.index(s)&&s<e.depth-n.openStart){let l=replaceOuter(e,t,n,s+1);return o.copy(o.content.replaceChild(a,l))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&e.depth==s&&t.depth==s){let l=e.parent,c=l.content;return close(l,c.cut(0,e.parentOffset).append(n.content).append(c.cut(t.parentOffset)))}else{let{start:l,end:c}=prepareSliceForReplace(n,e);return close(o,replaceThreeWay(e,l,c,t,s))}else return close(o,replaceTwoWay(e,t,s))}function checkJoin(e,t){if(!t.type.compatibleContent(e.type))throw new ReplaceError("Cannot join "+t.type.name+" onto "+e.type.name)}function joinable$1(e,t,n){let s=e.node(n);return checkJoin(s,t.node(n)),s}function addNode(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function addRange(e,t,n,s){let a=(t||e).node(n),o=0,l=t?t.index(n):a.childCount;e&&(o=e.index(n),e.depth>n?o++:e.textOffset&&(addNode(e.nodeAfter,s),o++));for(let c=o;c<l;c++)addNode(a.child(c),s);t&&t.depth==n&&t.textOffset&&addNode(t.nodeBefore,s)}function close(e,t){return e.type.checkContent(t),e.copy(t)}function replaceThreeWay(e,t,n,s,a){let o=e.depth>a&&joinable$1(e,t,a+1),l=s.depth>a&&joinable$1(n,s,a+1),c=[];return addRange(null,e,a,c),o&&l&&t.index(a)==n.index(a)?(checkJoin(o,l),addNode(close(o,replaceThreeWay(e,t,n,s,a+1)),c)):(o&&addNode(close(o,replaceTwoWay(e,t,a+1)),c),addRange(t,n,a,c),l&&addNode(close(l,replaceTwoWay(n,s,a+1)),c)),addRange(s,null,a,c),new Fragment(c)}function replaceTwoWay(e,t,n){let s=[];if(addRange(null,e,n,s),e.depth>n){let a=joinable$1(e,t,n+1);addNode(close(a,replaceTwoWay(e,t,n+1)),s)}return addRange(t,null,n,s),new Fragment(s)}function prepareSliceForReplace(e,t){let n=t.depth-e.openStart,a=t.node(n).copy(e.content);for(let o=n-1;o>=0;o--)a=t.node(o).copy(Fragment.from(a));return{start:a.resolveNoCache(e.openStart+n),end:a.resolveNoCache(a.content.size-e.openEnd-n)}}class ResolvedPos{constructor(t,n,s){this.pos=t,this.path=n,this.parentOffset=s,this.depth=n.length/3-1}resolveDepth(t){return t==null?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){return t=this.resolveDepth(t),t==0?0:this.path[t*3-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,n=this.index(this.depth);if(n==t.childCount)return null;let s=this.pos-this.path[this.path.length-1],a=t.child(n);return s?t.child(n).cut(s):a}get nodeBefore(){let t=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(t).cut(0,n):t==0?null:this.parent.child(t-1)}posAtIndex(t,n){n=this.resolveDepth(n);let s=this.path[n*3],a=n==0?0:this.path[n*3-1]+1;for(let o=0;o<t;o++)a+=s.child(o).nodeSize;return a}marks(){let t=this.parent,n=this.index();if(t.content.size==0)return Mark$1.none;if(this.textOffset)return t.child(n).marks;let s=t.maybeChild(n-1),a=t.maybeChild(n);if(!s){let c=s;s=a,a=c}let o=s.marks;for(var l=0;l<o.length;l++)o[l].type.spec.inclusive===!1&&(!a||!o[l].isInSet(a.marks))&&(o=o[l--].removeFromSet(o));return o}marksAcross(t){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let s=n.marks,a=t.parent.maybeChild(t.index());for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!a||!s[o].isInSet(a.marks))&&(s=s[o--].removeFromSet(s));return s}sharedDepth(t){for(let n=this.depth;n>0;n--)if(this.start(n)<=t&&this.end(n)>=t)return n;return 0}blockRange(t=this,n){if(t.pos<this.pos)return t.blockRange(this);for(let s=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);s>=0;s--)if(t.pos<=this.end(s)&&(!n||n(this.node(s))))return new NodeRange(this,t,s);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let n=1;n<=this.depth;n++)t+=(t?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return t+":"+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw new RangeError("Position "+n+" out of range");let s=[],a=0,o=n;for(let l=t;;){let{index:c,offset:d}=l.content.findIndex(o),f=o-d;if(s.push(l,c,a+d),!f||(l=l.child(c),l.isText))break;o=f-1,a+=d+1}return new ResolvedPos(n,s,o)}static resolveCached(t,n){let s=resolveCache.get(t);if(s)for(let o=0;o<s.elts.length;o++){let l=s.elts[o];if(l.pos==n)return l}else resolveCache.set(t,s=new ResolveCache);let a=s.elts[s.i]=ResolvedPos.resolve(t,n);return s.i=(s.i+1)%resolveCacheSize,a}}class ResolveCache{constructor(){this.elts=[],this.i=0}}const resolveCacheSize=12,resolveCache=new WeakMap;class NodeRange{constructor(t,n,s){this.$from=t,this.$to=n,this.depth=s}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const emptyAttrs=Object.create(null);let Node$1=class zn{constructor(t,n,s,a=Mark$1.none){this.type=t,this.attrs=n,this.marks=a,this.content=s||Fragment.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,n,s,a=0){this.content.nodesBetween(t,n,s,a,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,n,s,a){return this.content.textBetween(t,n,s,a)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,n,s){return this.type==t&&compareDeep(this.attrs,n||t.defaultAttrs||emptyAttrs)&&Mark$1.sameSet(this.marks,s||Mark$1.none)}copy(t=null){return t==this.content?this:new zn(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new zn(this.type,this.attrs,this.content,t)}cut(t,n=this.content.size){return t==0&&n==this.content.size?this:this.copy(this.content.cut(t,n))}slice(t,n=this.content.size,s=!1){if(t==n)return Slice.empty;let a=this.resolve(t),o=this.resolve(n),l=s?0:a.sharedDepth(n),c=a.start(l),f=a.node(l).content.cut(a.pos-c,o.pos-c);return new Slice(f,a.depth-l,o.depth-l)}replace(t,n,s){return replace(this.resolve(t),this.resolve(n),s)}nodeAt(t){for(let n=this;;){let{index:s,offset:a}=n.content.findIndex(t);if(n=n.maybeChild(s),!n)return null;if(a==t||n.isText)return n;t-=a+1}}childAfter(t){let{index:n,offset:s}=this.content.findIndex(t);return{node:this.content.maybeChild(n),index:n,offset:s}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:n,offset:s}=this.content.findIndex(t);if(s<t)return{node:this.content.child(n),index:n,offset:s};let a=this.content.child(n-1);return{node:a,index:n-1,offset:s-a.nodeSize}}resolve(t){return ResolvedPos.resolveCached(this,t)}resolveNoCache(t){return ResolvedPos.resolve(this,t)}rangeHasMark(t,n,s){let a=!1;return n>t&&this.nodesBetween(t,n,o=>(s.isInSet(o.marks)&&(a=!0),!a)),a}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),wrapMarks(this.marks,t)}contentMatchAt(t){let n=this.type.contentMatch.matchFragment(this.content,0,t);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(t,n,s=Fragment.empty,a=0,o=s.childCount){let l=this.contentMatchAt(t).matchFragment(s,a,o),c=l&&l.matchFragment(this.content,n);if(!c||!c.validEnd)return!1;for(let d=a;d<o;d++)if(!this.type.allowsMarks(s.child(d).marks))return!1;return!0}canReplaceWith(t,n,s,a){if(a&&!this.type.allowsMarks(a))return!1;let o=this.contentMatchAt(t).matchType(s),l=o&&o.matchFragment(this.content,n);return l?l.validEnd:!1}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let t=Mark$1.none;for(let n=0;n<this.marks.length;n++){let s=this.marks[n];s.type.checkAttrs(s.attrs),t=s.addToSet(t)}if(!Mark$1.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map(n=>n.toJSON())),t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let s;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");s=n.marks.map(t.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(n.text,s)}let a=Fragment.fromJSON(t,n.content),o=t.nodeType(n.type).create(n.attrs,a,s);return o.type.checkAttrs(o.attrs),o}};Node$1.prototype.text=void 0;class TextNode extends Node$1{constructor(t,n,s,a){if(super(t,n,null,a),!s)throw new RangeError("Empty text nodes are not allowed");this.text=s}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):wrapMarks(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,n){return this.text.slice(t,n)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new TextNode(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new TextNode(this.type,this.attrs,t,this.marks)}cut(t=0,n=this.text.length){return t==0&&n==this.text.length?this:this.withText(this.text.slice(t,n))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function wrapMarks(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class ContentMatch{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,n){let s=new TokenStream(t,n);if(s.next==null)return ContentMatch.empty;let a=parseExpr(s);s.next&&s.err("Unexpected trailing text");let o=dfa(nfa(a));return checkForDeadEnds(o,s),o}matchType(t){for(let n=0;n<this.next.length;n++)if(this.next[n].type==t)return this.next[n].next;return null}matchFragment(t,n=0,s=t.childCount){let a=this;for(let o=n;a&&o<s;o++)a=a.matchType(t.child(o).type);return a}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:n}=this.next[t];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(t){for(let n=0;n<this.next.length;n++)for(let s=0;s<t.next.length;s++)if(this.next[n].type==t.next[s].type)return!0;return!1}fillBefore(t,n=!1,s=0){let a=[this];function o(l,c){let d=l.matchFragment(t,s);if(d&&(!n||d.validEnd))return Fragment.from(c.map(f=>f.createAndFill()));for(let f=0;f<l.next.length;f++){let{type:R,next:S}=l.next[f];if(!(R.isText||R.hasRequiredAttrs())&&a.indexOf(S)==-1){a.push(S);let te=o(S,c.concat(R));if(te)return te}}return null}return o(this,[])}findWrapping(t){for(let s=0;s<this.wrapCache.length;s+=2)if(this.wrapCache[s]==t)return this.wrapCache[s+1];let n=this.computeWrapping(t);return this.wrapCache.push(t,n),n}computeWrapping(t){let n=Object.create(null),s=[{match:this,type:null,via:null}];for(;s.length;){let a=s.shift(),o=a.match;if(o.matchType(t)){let l=[];for(let c=a;c.type;c=c.via)l.push(c.type);return l.reverse()}for(let l=0;l<o.next.length;l++){let{type:c,next:d}=o.next[l];!c.isLeaf&&!c.hasRequiredAttrs()&&!(c.name in n)&&(!a.type||d.validEnd)&&(s.push({match:c.contentMatch,type:c,via:a}),n[c.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function n(s){t.push(s);for(let a=0;a<s.next.length;a++)t.indexOf(s.next[a].next)==-1&&n(s.next[a].next)}return n(this),t.map((s,a)=>{let o=a+(s.validEnd?"*":" ")+" ";for(let l=0;l<s.next.length;l++)o+=(l?", ":"")+s.next[l].type.name+"->"+t.indexOf(s.next[l].next);return o}).join(`
|
|
524
524
|
`)}}ContentMatch.empty=new ContentMatch(!0);class TokenStream{constructor(t,n){this.string=t,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function parseExpr(e){let t=[];do t.push(parseExprSeq(e));while(e.eat("|"));return t.length==1?t[0]:{type:"choice",exprs:t}}function parseExprSeq(e){let t=[];do t.push(parseExprSubscript(e));while(e.next&&e.next!=")"&&e.next!="|");return t.length==1?t[0]:{type:"seq",exprs:t}}function parseExprSubscript(e){let t=parseExprAtom(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else if(e.eat("{"))t=parseExprRange(e,t);else break;return t}function parseNum(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function parseExprRange(e,t){let n=parseNum(e),s=n;return e.eat(",")&&(e.next!="}"?s=parseNum(e):s=-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:s,expr:t}}function resolveName(e,t){let n=e.nodeTypes,s=n[t];if(s)return[s];let a=[];for(let o in n){let l=n[o];l.isInGroup(t)&&a.push(l)}return a.length==0&&e.err("No node type or group '"+t+"' found"),a}function parseExprAtom(e){if(e.eat("(")){let t=parseExpr(e);return e.eat(")")||e.err("Missing closing paren"),t}else if(/\W/.test(e.next))e.err("Unexpected token '"+e.next+"'");else{let t=resolveName(e,e.next).map(n=>(e.inline==null?e.inline=n.isInline:e.inline!=n.isInline&&e.err("Mixing inline and block content"),{type:"name",value:n}));return e.pos++,t.length==1?t[0]:{type:"choice",exprs:t}}}function nfa(e){let t=[[]];return a(o(e,0),n()),t;function n(){return t.push([])-1}function s(l,c,d){let f={term:d,to:c};return t[l].push(f),f}function a(l,c){l.forEach(d=>d.to=c)}function o(l,c){if(l.type=="choice")return l.exprs.reduce((d,f)=>d.concat(o(f,c)),[]);if(l.type=="seq")for(let d=0;;d++){let f=o(l.exprs[d],c);if(d==l.exprs.length-1)return f;a(f,c=n())}else if(l.type=="star"){let d=n();return s(c,d),a(o(l.expr,d),d),[s(d)]}else if(l.type=="plus"){let d=n();return a(o(l.expr,c),d),a(o(l.expr,d),d),[s(d)]}else{if(l.type=="opt")return[s(c)].concat(o(l.expr,c));if(l.type=="range"){let d=c;for(let f=0;f<l.min;f++){let R=n();a(o(l.expr,d),R),d=R}if(l.max==-1)a(o(l.expr,d),d);else for(let f=l.min;f<l.max;f++){let R=n();s(d,R),a(o(l.expr,d),R),d=R}return[s(d)]}else{if(l.type=="name")return[s(c,void 0,l.value)];throw new Error("Unknown expr type")}}}}function cmp(e,t){return t-e}function nullFrom(e,t){let n=[];return s(t),n.sort(cmp);function s(a){let o=e[a];if(o.length==1&&!o[0].term)return s(o[0].to);n.push(a);for(let l=0;l<o.length;l++){let{term:c,to:d}=o[l];!c&&n.indexOf(d)==-1&&s(d)}}}function dfa(e){let t=Object.create(null);return n(nullFrom(e,0));function n(s){let a=[];s.forEach(l=>{e[l].forEach(({term:c,to:d})=>{if(!c)return;let f;for(let R=0;R<a.length;R++)a[R][0]==c&&(f=a[R][1]);nullFrom(e,d).forEach(R=>{f||a.push([c,f=[]]),f.indexOf(R)==-1&&f.push(R)})})});let o=t[s.join(",")]=new ContentMatch(s.indexOf(e.length-1)>-1);for(let l=0;l<a.length;l++){let c=a[l][1].sort(cmp);o.next.push({type:a[l][0],next:t[c.join(",")]||n(c)})}return o}}function checkForDeadEnds(e,t){for(let n=0,s=[e];n<s.length;n++){let a=s[n],o=!a.validEnd,l=[];for(let c=0;c<a.next.length;c++){let{type:d,next:f}=a.next[c];l.push(d.name),o&&!(d.isText||d.hasRequiredAttrs())&&(o=!1),s.indexOf(f)==-1&&s.push(f)}o&&t.err("Only non-generatable nodes ("+l.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function defaultAttrs(e){let t=Object.create(null);for(let n in e){let s=e[n];if(!s.hasDefault)return null;t[n]=s.default}return t}function computeAttrs(e,t){let n=Object.create(null);for(let s in e){let a=t&&t[s];if(a===void 0){let o=e[s];if(o.hasDefault)a=o.default;else throw new RangeError("No value supplied for attribute "+s)}n[s]=a}return n}function checkAttrs(e,t,n,s){for(let a in t)if(!(a in e))throw new RangeError(`Unsupported attribute ${a} for ${n} of type ${a}`);for(let a in e){let o=e[a];o.validate&&o.validate(t[a])}}function initAttrs(e,t){let n=Object.create(null);if(t)for(let s in t)n[s]=new Attribute(e,s,t[s]);return n}let NodeType$1=class Gn{constructor(t,n,s){this.name=t,this.schema=n,this.spec=s,this.markSet=null,this.groups=s.group?s.group.split(" "):[],this.attrs=initAttrs(t,s.attrs),this.defaultAttrs=defaultAttrs(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(s.inline||t=="text"),this.isText=t=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ContentMatch.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(t){return this.groups.indexOf(t)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:computeAttrs(this.attrs,t)}create(t=null,n,s){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Node$1(this,this.computeAttrs(t),Fragment.from(n),Mark$1.setFrom(s))}createChecked(t=null,n,s){return n=Fragment.from(n),this.checkContent(n),new Node$1(this,this.computeAttrs(t),n,Mark$1.setFrom(s))}createAndFill(t=null,n,s){if(t=this.computeAttrs(t),n=Fragment.from(n),n.size){let l=this.contentMatch.fillBefore(n);if(!l)return null;n=l.append(n)}let a=this.contentMatch.matchFragment(n),o=a&&a.fillBefore(Fragment.empty,!0);return o?new Node$1(this,t,n.append(o),Mark$1.setFrom(s)):null}validContent(t){let n=this.contentMatch.matchFragment(t);if(!n||!n.validEnd)return!1;for(let s=0;s<t.childCount;s++)if(!this.allowsMarks(t.child(s).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){checkAttrs(this.attrs,t,"node",this.name)}allowsMarkType(t){return this.markSet==null||this.markSet.indexOf(t)>-1}allowsMarks(t){if(this.markSet==null)return!0;for(let n=0;n<t.length;n++)if(!this.allowsMarkType(t[n].type))return!1;return!0}allowedMarks(t){if(this.markSet==null)return t;let n;for(let s=0;s<t.length;s++)this.allowsMarkType(t[s].type)?n&&n.push(t[s]):n||(n=t.slice(0,s));return n?n.length?n:Mark$1.none:t}static compile(t,n){let s=Object.create(null);t.forEach((o,l)=>s[o]=new Gn(o,n,l));let a=n.spec.topNode||"doc";if(!s[a])throw new RangeError("Schema is missing its top node type ('"+a+"')");if(!s.text)throw new RangeError("Every schema needs a 'text' type");for(let o in s.text.attrs)throw new RangeError("The text node type should not have attributes");return s}};function validateType(e,t,n){let s=n.split("|");return a=>{let o=a===null?"null":typeof a;if(s.indexOf(o)<0)throw new RangeError(`Expected value of type ${s} for attribute ${t} on type ${e}, got ${o}`)}}class Attribute{constructor(t,n,s){this.hasDefault=Object.prototype.hasOwnProperty.call(s,"default"),this.default=s.default,this.validate=typeof s.validate=="string"?validateType(t,n,s.validate):s.validate}get isRequired(){return!this.hasDefault}}class MarkType{constructor(t,n,s,a){this.name=t,this.rank=n,this.schema=s,this.spec=a,this.attrs=initAttrs(t,a.attrs),this.excluded=null;let o=defaultAttrs(this.attrs);this.instance=o?new Mark$1(this,o):null}create(t=null){return!t&&this.instance?this.instance:new Mark$1(this,computeAttrs(this.attrs,t))}static compile(t,n){let s=Object.create(null),a=0;return t.forEach((o,l)=>s[o]=new MarkType(o,a++,n,l)),s}removeFromSet(t){for(var n=0;n<t.length;n++)t[n].type==this&&(t=t.slice(0,n).concat(t.slice(n+1)),n--);return t}isInSet(t){for(let n=0;n<t.length;n++)if(t[n].type==this)return t[n]}checkAttrs(t){checkAttrs(this.attrs,t,"mark",this.name)}excludes(t){return this.excluded.indexOf(t)>-1}}class Schema{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let a in t)n[a]=t[a];n.nodes=OrderedMap.from(t.nodes),n.marks=OrderedMap.from(t.marks||{}),this.nodes=NodeType$1.compile(this.spec.nodes,this),this.marks=MarkType.compile(this.spec.marks,this);let s=Object.create(null);for(let a in this.nodes){if(a in this.marks)throw new RangeError(a+" can not be both a node and a mark");let o=this.nodes[a],l=o.spec.content||"",c=o.spec.marks;if(o.contentMatch=s[l]||(s[l]=ContentMatch.parse(l,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=c=="_"?null:c?gatherMarks(this,c.split(" ")):c==""||!o.inlineContent?[]:null}for(let a in this.marks){let o=this.marks[a],l=o.spec.excludes;o.excluded=l==null?[o]:l==""?[]:gatherMarks(this,l.split(" "))}this.nodeFromJSON=a=>Node$1.fromJSON(this,a),this.markFromJSON=a=>Mark$1.fromJSON(this,a),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,n=null,s,a){if(typeof t=="string")t=this.nodeType(t);else if(t instanceof NodeType$1){if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}else throw new RangeError("Invalid node type: "+t);return t.createChecked(n,s,a)}text(t,n){let s=this.nodes.text;return new TextNode(s,s.defaultAttrs,t,Mark$1.setFrom(n))}mark(t,n){return typeof t=="string"&&(t=this.marks[t]),t.create(n)}nodeType(t){let n=this.nodes[t];if(!n)throw new RangeError("Unknown node type: "+t);return n}}function gatherMarks(e,t){let n=[];for(let s=0;s<t.length;s++){let a=t[s],o=e.marks[a],l=o;if(o)n.push(o);else for(let c in e.marks){let d=e.marks[c];(a=="_"||d.spec.group&&d.spec.group.split(" ").indexOf(a)>-1)&&n.push(l=d)}if(!l)throw new SyntaxError("Unknown mark type: '"+t[s]+"'")}return n}function isTagRule(e){return e.tag!=null}function isStyleRule(e){return e.style!=null}class DOMParser{constructor(t,n){this.schema=t,this.rules=n,this.tags=[],this.styles=[];let s=this.matchedStyles=[];n.forEach(a=>{if(isTagRule(a))this.tags.push(a);else if(isStyleRule(a)){let o=/[^=]*/.exec(a.style)[0];s.indexOf(o)<0&&s.push(o),this.styles.push(a)}}),this.normalizeLists=!this.tags.some(a=>{if(!/^(ul|ol)\b/.test(a.tag)||!a.node)return!1;let o=t.nodes[a.node];return o.contentMatch.matchType(o)})}parse(t,n={}){let s=new ParseContext(this,n,!1);return s.addAll(t,Mark$1.none,n.from,n.to),s.finish()}parseSlice(t,n={}){let s=new ParseContext(this,n,!0);return s.addAll(t,Mark$1.none,n.from,n.to),Slice.maxOpen(s.finish())}matchTag(t,n,s){for(let a=s?this.tags.indexOf(s)+1:0;a<this.tags.length;a++){let o=this.tags[a];if(matches(t,o.tag)&&(o.namespace===void 0||t.namespaceURI==o.namespace)&&(!o.context||n.matchesContext(o.context))){if(o.getAttrs){let l=o.getAttrs(t);if(l===!1)continue;o.attrs=l||void 0}return o}}}matchStyle(t,n,s,a){for(let o=a?this.styles.indexOf(a)+1:0;o<this.styles.length;o++){let l=this.styles[o],c=l.style;if(!(c.indexOf(t)!=0||l.context&&!s.matchesContext(l.context)||c.length>t.length&&(c.charCodeAt(t.length)!=61||c.slice(t.length+1)!=n))){if(l.getAttrs){let d=l.getAttrs(n);if(d===!1)continue;l.attrs=d||void 0}return l}}}static schemaRules(t){let n=[];function s(a){let o=a.priority==null?50:a.priority,l=0;for(;l<n.length;l++){let c=n[l];if((c.priority==null?50:c.priority)<o)break}n.splice(l,0,a)}for(let a in t.marks){let o=t.marks[a].spec.parseDOM;o&&o.forEach(l=>{s(l=copy(l)),l.mark||l.ignore||l.clearMark||(l.mark=a)})}for(let a in t.nodes){let o=t.nodes[a].spec.parseDOM;o&&o.forEach(l=>{s(l=copy(l)),l.node||l.ignore||l.mark||(l.node=a)})}return n}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new DOMParser(t,DOMParser.schemaRules(t)))}}const blockTags={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},ignoreTags={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},listTags={ol:!0,ul:!0},OPT_PRESERVE_WS=1,OPT_PRESERVE_WS_FULL=2,OPT_OPEN_LEFT=4;function wsOptionsFor(e,t,n){return t!=null?(t?OPT_PRESERVE_WS:0)|(t==="full"?OPT_PRESERVE_WS_FULL:0):e&&e.whitespace=="pre"?OPT_PRESERVE_WS|OPT_PRESERVE_WS_FULL:n&~OPT_OPEN_LEFT}class NodeContext{constructor(t,n,s,a,o,l){this.type=t,this.attrs=n,this.marks=s,this.solid=a,this.options=l,this.content=[],this.activeMarks=Mark$1.none,this.match=o||(l&OPT_OPEN_LEFT?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Fragment.from(t));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let s=this.type.contentMatch,a;return(a=s.findWrapping(t.type))?(this.match=s,a):null}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&OPT_PRESERVE_WS)){let s=this.content[this.content.length-1],a;if(s&&s.isText&&(a=/[ \t\r\n\u000c]+$/.exec(s.text))){let o=s;s.text.length==a[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-a[0].length))}}let n=Fragment.from(this.content);return!t&&this.match&&(n=n.append(this.match.fillBefore(Fragment.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!blockTags.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class ParseContext{constructor(t,n,s){this.parser=t,this.options=n,this.isOpen=s,this.open=0,this.localPreserveWS=!1;let a=n.topNode,o,l=wsOptionsFor(null,n.preserveWhitespace,0)|(s?OPT_OPEN_LEFT:0);a?o=new NodeContext(a.type,a.attrs,Mark$1.none,!0,n.topMatch||a.type.contentMatch,l):s?o=new NodeContext(null,null,Mark$1.none,!0,null,l):o=new NodeContext(t.schema.topNodeType,null,Mark$1.none,!0,null,l),this.nodes=[o],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,n){t.nodeType==3?this.addTextNode(t,n):t.nodeType==1&&this.addElement(t,n)}addTextNode(t,n){let s=t.nodeValue,a=this.top,o=a.options&OPT_PRESERVE_WS_FULL?"full":this.localPreserveWS||(a.options&OPT_PRESERVE_WS)>0,{schema:l}=this.parser;if(o==="full"||a.inlineContext(t)||/[^ \t\r\n\u000c]/.test(s)){if(o)if(o==="full")s=s.replace(/\r\n?/g,`
|
|
525
525
|
`);else if(l.linebreakReplacement&&/[\r\n]/.test(s)&&this.top.findWrapping(l.linebreakReplacement.create())){let c=s.split(/\r?\n|\r/);for(let d=0;d<c.length;d++)d&&this.insertNode(l.linebreakReplacement.create(),n,!0),c[d]&&this.insertNode(l.text(c[d]),n,!/\S/.test(c[d]));s=""}else s=s.replace(/\r?\n|\r/g," ");else if(s=s.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(s)&&this.open==this.nodes.length-1){let c=a.content[a.content.length-1],d=t.previousSibling;(!c||d&&d.nodeName=="BR"||c.isText&&/[ \t\r\n\u000c]$/.test(c.text))&&(s=s.slice(1))}s&&this.insertNode(l.text(s),n,!/\S/.test(s)),this.findInText(t)}else this.findInside(t)}addElement(t,n,s){let a=this.localPreserveWS,o=this.top;(t.tagName=="PRE"||/pre/.test(t.style&&t.style.whiteSpace))&&(this.localPreserveWS=!0);let l=t.nodeName.toLowerCase(),c;listTags.hasOwnProperty(l)&&this.parser.normalizeLists&&normalizeList(t);let d=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(c=this.parser.matchTag(t,this,s));e:if(d?d.ignore:ignoreTags.hasOwnProperty(l))this.findInside(t),this.ignoreFallback(t,n);else if(!d||d.skip||d.closeParent){d&&d.closeParent?this.open=Math.max(0,this.open-1):d&&d.skip.nodeType&&(t=d.skip);let f,R=this.needsBlock;if(blockTags.hasOwnProperty(l))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),f=!0,o.type||(this.needsBlock=!0);else if(!t.firstChild){this.leafFallback(t,n);break e}let S=d&&d.skip?n:this.readStyles(t,n);S&&this.addAll(t,S),f&&this.sync(o),this.needsBlock=R}else{let f=this.readStyles(t,n);f&&this.addElementByRule(t,d,f,d.consuming===!1?c:void 0)}this.localPreserveWS=a}leafFallback(t,n){t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode(`
|
|
526
526
|
`),n)}ignoreFallback(t,n){t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(t,n){let s=t.style;if(s&&s.length)for(let a=0;a<this.parser.matchedStyles.length;a++){let o=this.parser.matchedStyles[a],l=s.getPropertyValue(o);if(l)for(let c=void 0;;){let d=this.parser.matchStyle(o,l,this,c);if(!d)break;if(d.ignore)return null;if(d.clearMark?n=n.filter(f=>!d.clearMark(f)):n=n.concat(this.parser.schema.marks[d.mark].create(d.attrs)),d.consuming===!1)c=d;else break}}return n}addElementByRule(t,n,s,a){let o,l;if(n.node)if(l=this.parser.schema.nodes[n.node],l.isLeaf)this.insertNode(l.create(n.attrs),s,t.nodeName=="BR")||this.leafFallback(t,s);else{let d=this.enter(l,n.attrs||null,s,n.preserveWhitespace);d&&(o=!0,s=d)}else{let d=this.parser.schema.marks[n.mark];s=s.concat(d.create(n.attrs))}let c=this.top;if(l&&l.isLeaf)this.findInside(t);else if(a)this.addElement(t,s,a);else if(n.getContent)this.findInside(t),n.getContent(t,this.parser.schema).forEach(d=>this.insertNode(d,s,!1));else{let d=t;typeof n.contentElement=="string"?d=t.querySelector(n.contentElement):typeof n.contentElement=="function"?d=n.contentElement(t):n.contentElement&&(d=n.contentElement),this.findAround(t,d,!0),this.addAll(d,s),this.findAround(t,d,!1)}o&&this.sync(c)&&this.open--}addAll(t,n,s,a){let o=s||0;for(let l=s?t.childNodes[s]:t.firstChild,c=a==null?null:t.childNodes[a];l!=c;l=l.nextSibling,++o)this.findAtPoint(t,o),this.addDOM(l,n);this.findAtPoint(t,o)}findPlace(t,n,s){let a,o;for(let l=this.open,c=0;l>=0;l--){let d=this.nodes[l],f=d.findWrapping(t);if(f&&(!a||a.length>f.length+c)&&(a=f,o=d,!f.length))break;if(d.solid){if(s)break;c+=2}}if(!a)return null;this.sync(o);for(let l=0;l<a.length;l++)n=this.enterInner(a[l],null,n,!1);return n}insertNode(t,n,s){if(t.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(n=this.enterInner(o,null,n))}let a=this.findPlace(t,n,s);if(a){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(t.type));let l=Mark$1.none;for(let c of a.concat(t.marks))(o.type?o.type.allowsMarkType(c.type):markMayApply(c.type,t.type))&&(l=c.addToSet(l));return o.content.push(t.mark(l)),!0}return!1}enter(t,n,s,a){let o=this.findPlace(t.create(n),s,!1);return o&&(o=this.enterInner(t,n,s,!0,a)),o}enterInner(t,n,s,a=!1,o){this.closeExtra();let l=this.top;l.match=l.match&&l.match.matchType(t);let c=wsOptionsFor(t,o,l.options);l.options&OPT_OPEN_LEFT&&l.content.length==0&&(c|=OPT_OPEN_LEFT);let d=Mark$1.none;return s=s.filter(f=>(l.type?l.type.allowsMarkType(f.type):markMayApply(f.type,t))?(d=f.addToSet(d),!1):!0),this.nodes.push(new NodeContext(t,n,d,a,null,c)),this.open++,s}closeExtra(t=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(t){for(let n=this.open;n>=0;n--){if(this.nodes[n]==t)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=OPT_PRESERVE_WS)}return!1}get currentPos(){this.closeExtra();let t=0;for(let n=this.open;n>=0;n--){let s=this.nodes[n].content;for(let a=s.length-1;a>=0;a--)t+=s[a].nodeSize;n&&t++}return t}findAtPoint(t,n){if(this.find)for(let s=0;s<this.find.length;s++)this.find[s].node==t&&this.find[s].offset==n&&(this.find[s].pos=this.currentPos)}findInside(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&t.nodeType==1&&t.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(t,n,s){if(t!=n&&this.find)for(let a=0;a<this.find.length;a++)this.find[a].pos==null&&t.nodeType==1&&t.contains(this.find[a].node)&&n.compareDocumentPosition(this.find[a].node)&(s?2:4)&&(this.find[a].pos=this.currentPos)}findInText(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&(this.find[n].pos=this.currentPos-(t.nodeValue.length-this.find[n].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let n=t.split("/"),s=this.options.context,a=!this.isOpen&&(!s||s.parent.type==this.nodes[0].type),o=-(s?s.depth+1:0)+(a?0:1),l=(c,d)=>{for(;c>=0;c--){let f=n[c];if(f==""){if(c==n.length-1||c==0)continue;for(;d>=o;d--)if(l(c-1,d))return!0;return!1}else{let R=d>0||d==0&&a?this.nodes[d].type:s&&d>=o?s.node(d-o).type:null;if(!R||R.name!=f&&!R.isInGroup(f))return!1;d--}}return!0};return l(n.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let n=t.depth;n>=0;n--){let s=t.node(n).contentMatchAt(t.indexAfter(n)).defaultType;if(s&&s.isTextblock&&s.defaultAttrs)return s}for(let n in this.parser.schema.nodes){let s=this.parser.schema.nodes[n];if(s.isTextblock&&s.defaultAttrs)return s}}}function normalizeList(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let s=t.nodeType==1?t.nodeName.toLowerCase():null;s&&listTags.hasOwnProperty(s)&&n?(n.appendChild(t),t=n):s=="li"?n=t:s&&(n=null)}}function matches(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function copy(e){let t={};for(let n in e)t[n]=e[n];return t}function markMayApply(e,t){let n=t.schema.nodes;for(let s in n){let a=n[s];if(!a.allowsMarkType(e))continue;let o=[],l=c=>{o.push(c);for(let d=0;d<c.edgeCount;d++){let{type:f,next:R}=c.edge(d);if(f==t||o.indexOf(R)<0&&l(R))return!0}};if(l(a.contentMatch))return!0}}class DOMSerializer{constructor(t,n){this.nodes=t,this.marks=n}serializeFragment(t,n={},s){s||(s=doc$1(n).createDocumentFragment());let a=s,o=[];return t.forEach(l=>{if(o.length||l.marks.length){let c=0,d=0;for(;c<o.length&&d<l.marks.length;){let f=l.marks[d];if(!this.marks[f.type.name]){d++;continue}if(!f.eq(o[c][0])||f.type.spec.spanning===!1)break;c++,d++}for(;c<o.length;)a=o.pop()[1];for(;d<l.marks.length;){let f=l.marks[d++],R=this.serializeMark(f,l.isInline,n);R&&(o.push([f,a]),a.appendChild(R.dom),a=R.contentDOM||R.dom)}}a.appendChild(this.serializeNodeInner(l,n))}),s}serializeNodeInner(t,n){let{dom:s,contentDOM:a}=renderSpec(doc$1(n),this.nodes[t.type.name](t),null,t.attrs);if(a){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,n,a)}return s}serializeNode(t,n={}){let s=this.serializeNodeInner(t,n);for(let a=t.marks.length-1;a>=0;a--){let o=this.serializeMark(t.marks[a],t.isInline,n);o&&((o.contentDOM||o.dom).appendChild(s),s=o.dom)}return s}serializeMark(t,n,s={}){let a=this.marks[t.type.name];return a&&renderSpec(doc$1(s),a(t,n),null,t.attrs)}static renderSpec(t,n,s=null,a){return renderSpec(t,n,s,a)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new DOMSerializer(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let n=gatherToDOM(t.nodes);return n.text||(n.text=s=>s.text),n}static marksFromSchema(t){return gatherToDOM(t.marks)}}function gatherToDOM(e){let t={};for(let n in e){let s=e[n].spec.toDOM;s&&(t[n]=s)}return t}function doc$1(e){return e.document||window.document}const suspiciousAttributeCache=new WeakMap;function suspiciousAttributes(e){let t=suspiciousAttributeCache.get(e);return t===void 0&&suspiciousAttributeCache.set(e,t=suspiciousAttributesInner(e)),t}function suspiciousAttributesInner(e){let t=null;function n(s){if(s&&typeof s=="object")if(Array.isArray(s))if(typeof s[0]=="string")t||(t=[]),t.push(s);else for(let a=0;a<s.length;a++)n(s[a]);else for(let a in s)n(s[a])}return n(e),t}function renderSpec(e,t,n,s){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let a=t[0],o;if(typeof a!="string")throw new RangeError("Invalid array passed to renderSpec");if(s&&(o=suspiciousAttributes(s))&&o.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let l=a.indexOf(" ");l>0&&(n=a.slice(0,l),a=a.slice(l+1));let c,d=n?e.createElementNS(n,a):e.createElement(a),f=t[1],R=1;if(f&&typeof f=="object"&&f.nodeType==null&&!Array.isArray(f)){R=2;for(let S in f)if(f[S]!=null){let te=S.indexOf(" ");te>0?d.setAttributeNS(S.slice(0,te),S.slice(te+1),f[S]):S=="style"&&d.style?d.style.cssText=f[S]:d.setAttribute(S,f[S])}}for(let S=R;S<t.length;S++){let te=t[S];if(te===0){if(S<t.length-1||S>R)throw new RangeError("Content hole must be the only child of its parent node");return{dom:d,contentDOM:d}}else{let{dom:A,contentDOM:rt}=renderSpec(e,te,n,s);if(d.appendChild(A),rt){if(c)throw new RangeError("Multiple content holes");c=rt}}}return{dom:d,contentDOM:c}}const lower16=65535,factor16=Math.pow(2,16);function makeRecover(e,t){return e+t*factor16}function recoverIndex(e){return e&lower16}function recoverOffset(e){return(e-(e&lower16))/factor16}const DEL_BEFORE=1,DEL_AFTER=2,DEL_ACROSS=4,DEL_SIDE=8;class MapResult{constructor(t,n,s){this.pos=t,this.delInfo=n,this.recover=s}get deleted(){return(this.delInfo&DEL_SIDE)>0}get deletedBefore(){return(this.delInfo&(DEL_BEFORE|DEL_ACROSS))>0}get deletedAfter(){return(this.delInfo&(DEL_AFTER|DEL_ACROSS))>0}get deletedAcross(){return(this.delInfo&DEL_ACROSS)>0}}class StepMap{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&StepMap.empty)return StepMap.empty}recover(t){let n=0,s=recoverIndex(t);if(!this.inverted)for(let a=0;a<s;a++)n+=this.ranges[a*3+2]-this.ranges[a*3+1];return this.ranges[s*3]+n+recoverOffset(t)}mapResult(t,n=1){return this._map(t,n,!1)}map(t,n=1){return this._map(t,n,!0)}_map(t,n,s){let a=0,o=this.inverted?2:1,l=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let d=this.ranges[c]-(this.inverted?a:0);if(d>t)break;let f=this.ranges[c+o],R=this.ranges[c+l],S=d+f;if(t<=S){let te=f?t==d?-1:t==S?1:n:n,A=d+a+(te<0?0:R);if(s)return A;let rt=t==(n<0?d:S)?null:makeRecover(c/3,t-d),st=t==d?DEL_AFTER:t==S?DEL_BEFORE:DEL_ACROSS;return(n<0?t!=d:t!=S)&&(st|=DEL_SIDE),new MapResult(A,st,rt)}a+=R-f}return s?t+a:new MapResult(t+a,0,null)}touches(t,n){let s=0,a=recoverIndex(n),o=this.inverted?2:1,l=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let d=this.ranges[c]-(this.inverted?s:0);if(d>t)break;let f=this.ranges[c+o],R=d+f;if(t<=R&&c==a*3)return!0;s+=this.ranges[c+l]-f}return!1}forEach(t){let n=this.inverted?2:1,s=this.inverted?1:2;for(let a=0,o=0;a<this.ranges.length;a+=3){let l=this.ranges[a],c=l-(this.inverted?o:0),d=l+(this.inverted?0:o),f=this.ranges[a+n],R=this.ranges[a+s];t(c,c+f,d,d+R),o+=R-f}}invert(){return new StepMap(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?StepMap.empty:new StepMap(t<0?[0,-t,0]:[0,0,t])}}StepMap.empty=new StepMap([]);class Mapping{constructor(t,n,s=0,a=t?t.length:0){this.mirror=n,this.from=s,this.to=a,this._maps=t||[],this.ownData=!(t||n)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new Mapping(this._maps,this.mirror,t,n)}appendMap(t,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(t),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(t){for(let n=0,s=this._maps.length;n<t._maps.length;n++){let a=t.getMirror(n);this.appendMap(t._maps[n],a!=null&&a<n?s+a:void 0)}}getMirror(t){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==t)return this.mirror[n+(n%2?-1:1)]}}setMirror(t,n){this.mirror||(this.mirror=[]),this.mirror.push(t,n)}appendMappingInverted(t){for(let n=t.maps.length-1,s=this._maps.length+t._maps.length;n>=0;n--){let a=t.getMirror(n);this.appendMap(t._maps[n].invert(),a!=null&&a>n?s-a-1:void 0)}}invert(){let t=new Mapping;return t.appendMappingInverted(this),t}map(t,n=1){if(this.mirror)return this._map(t,n,!0);for(let s=this.from;s<this.to;s++)t=this._maps[s].map(t,n);return t}mapResult(t,n=1){return this._map(t,n,!1)}_map(t,n,s){let a=0;for(let o=this.from;o<this.to;o++){let l=this._maps[o],c=l.mapResult(t,n);if(c.recover!=null){let d=this.getMirror(o);if(d!=null&&d>o&&d<this.to){o=d,t=this._maps[d].recover(c.recover);continue}}a|=c.delInfo,t=c.pos}return s?t:new MapResult(t,a,null)}}const stepsByID=Object.create(null);class Step{getMap(){return StepMap.empty}merge(t){return null}static fromJSON(t,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let s=stepsByID[n.stepType];if(!s)throw new RangeError(`No step type ${n.stepType} defined`);return s.fromJSON(t,n)}static jsonID(t,n){if(t in stepsByID)throw new RangeError("Duplicate use of step JSON ID "+t);return stepsByID[t]=n,n.prototype.jsonID=t,n}}class StepResult{constructor(t,n){this.doc=t,this.failed=n}static ok(t){return new StepResult(t,null)}static fail(t){return new StepResult(null,t)}static fromReplace(t,n,s,a){try{return StepResult.ok(t.replace(n,s,a))}catch(o){if(o instanceof ReplaceError)return StepResult.fail(o.message);throw o}}}function mapFragment(e,t,n){let s=[];for(let a=0;a<e.childCount;a++){let o=e.child(a);o.content.size&&(o=o.copy(mapFragment(o.content,t,o))),o.isInline&&(o=t(o,n,a)),s.push(o)}return Fragment.fromArray(s)}class AddMarkStep extends Step{constructor(t,n,s){super(),this.from=t,this.to=n,this.mark=s}apply(t){let n=t.slice(this.from,this.to),s=t.resolve(this.from),a=s.node(s.sharedDepth(this.to)),o=new Slice(mapFragment(n.content,(l,c)=>!l.isAtom||!c.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),a),n.openStart,n.openEnd);return StepResult.fromReplace(t,this.from,this.to,o)}invert(){return new RemoveMarkStep(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),s=t.mapResult(this.to,-1);return n.deleted&&s.deleted||n.pos>=s.pos?null:new AddMarkStep(n.pos,s.pos,this.mark)}merge(t){return t instanceof AddMarkStep&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new AddMarkStep(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new AddMarkStep(n.from,n.to,t.markFromJSON(n.mark))}}Step.jsonID("addMark",AddMarkStep);class RemoveMarkStep extends Step{constructor(t,n,s){super(),this.from=t,this.to=n,this.mark=s}apply(t){let n=t.slice(this.from,this.to),s=new Slice(mapFragment(n.content,a=>a.mark(this.mark.removeFromSet(a.marks)),t),n.openStart,n.openEnd);return StepResult.fromReplace(t,this.from,this.to,s)}invert(){return new AddMarkStep(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),s=t.mapResult(this.to,-1);return n.deleted&&s.deleted||n.pos>=s.pos?null:new RemoveMarkStep(n.pos,s.pos,this.mark)}merge(t){return t instanceof RemoveMarkStep&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new RemoveMarkStep(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new RemoveMarkStep(n.from,n.to,t.markFromJSON(n.mark))}}Step.jsonID("removeMark",RemoveMarkStep);class AddNodeMarkStep extends Step{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return StepResult.fail("No node at mark step's position");let s=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return StepResult.fromReplace(t,this.pos,this.pos+1,new Slice(Fragment.from(s),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);if(n){let s=this.mark.addToSet(n.marks);if(s.length==n.marks.length){for(let a=0;a<n.marks.length;a++)if(!n.marks[a].isInSet(s))return new AddNodeMarkStep(this.pos,n.marks[a]);return new AddNodeMarkStep(this.pos,this.mark)}}return new RemoveNodeMarkStep(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new AddNodeMarkStep(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new AddNodeMarkStep(n.pos,t.markFromJSON(n.mark))}}Step.jsonID("addNodeMark",AddNodeMarkStep);class RemoveNodeMarkStep extends Step{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return StepResult.fail("No node at mark step's position");let s=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return StepResult.fromReplace(t,this.pos,this.pos+1,new Slice(Fragment.from(s),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new AddNodeMarkStep(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new RemoveNodeMarkStep(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new RemoveNodeMarkStep(n.pos,t.markFromJSON(n.mark))}}Step.jsonID("removeNodeMark",RemoveNodeMarkStep);class ReplaceStep extends Step{constructor(t,n,s,a=!1){super(),this.from=t,this.to=n,this.slice=s,this.structure=a}apply(t){return this.structure&&contentBetween(t,this.from,this.to)?StepResult.fail("Structure replace would overwrite content"):StepResult.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new StepMap([this.from,this.to-this.from,this.slice.size])}invert(t){return new ReplaceStep(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),s=this.from==this.to&&ReplaceStep.MAP_BIAS<0?n:t.mapResult(this.from,1);return s.deletedAcross&&n.deletedAcross?null:new ReplaceStep(s.pos,Math.max(s.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof ReplaceStep)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?Slice.empty:new Slice(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new ReplaceStep(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?Slice.empty:new Slice(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new ReplaceStep(t.from,this.to,n,this.structure)}else return null}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new ReplaceStep(n.from,n.to,Slice.fromJSON(t,n.slice),!!n.structure)}}ReplaceStep.MAP_BIAS=1,Step.jsonID("replace",ReplaceStep);class ReplaceAroundStep extends Step{constructor(t,n,s,a,o,l,c=!1){super(),this.from=t,this.to=n,this.gapFrom=s,this.gapTo=a,this.slice=o,this.insert=l,this.structure=c}apply(t){if(this.structure&&(contentBetween(t,this.from,this.gapFrom)||contentBetween(t,this.gapTo,this.to)))return StepResult.fail("Structure gap-replace would overwrite content");let n=t.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return StepResult.fail("Gap is not a flat range");let s=this.slice.insertAt(this.insert,n.content);return s?StepResult.fromReplace(t,this.from,this.to,s):StepResult.fail("Content does not fit in gap")}getMap(){return new StepMap([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new ReplaceAroundStep(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),s=t.mapResult(this.to,-1),a=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),o=this.to==this.gapTo?s.pos:t.map(this.gapTo,1);return n.deletedAcross&&s.deletedAcross||a<n.pos||o>s.pos?null:new ReplaceAroundStep(n.pos,s.pos,a,o,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ReplaceAroundStep(n.from,n.to,n.gapFrom,n.gapTo,Slice.fromJSON(t,n.slice),n.insert,!!n.structure)}}Step.jsonID("replaceAround",ReplaceAroundStep);function contentBetween(e,t,n){let s=e.resolve(t),a=n-t,o=s.depth;for(;a>0&&o>0&&s.indexAfter(o)==s.node(o).childCount;)o--,a--;if(a>0){let l=s.node(o).maybeChild(s.indexAfter(o));for(;a>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,a--}}return!1}function addMark(e,t,n,s){let a=[],o=[],l,c;e.doc.nodesBetween(t,n,(d,f,R)=>{if(!d.isInline)return;let S=d.marks;if(!s.isInSet(S)&&R.type.allowsMarkType(s.type)){let te=Math.max(f,t),A=Math.min(f+d.nodeSize,n),rt=s.addToSet(S);for(let st=0;st<S.length;st++)S[st].isInSet(rt)||(l&&l.to==te&&l.mark.eq(S[st])?l.to=A:a.push(l=new RemoveMarkStep(te,A,S[st])));c&&c.to==te?c.to=A:o.push(c=new AddMarkStep(te,A,s))}}),a.forEach(d=>e.step(d)),o.forEach(d=>e.step(d))}function removeMark(e,t,n,s){let a=[],o=0;e.doc.nodesBetween(t,n,(l,c)=>{if(!l.isInline)return;o++;let d=null;if(s instanceof MarkType){let f=l.marks,R;for(;R=s.isInSet(f);)(d||(d=[])).push(R),f=R.removeFromSet(f)}else s?s.isInSet(l.marks)&&(d=[s]):d=l.marks;if(d&&d.length){let f=Math.min(c+l.nodeSize,n);for(let R=0;R<d.length;R++){let S=d[R],te;for(let A=0;A<a.length;A++){let rt=a[A];rt.step==o-1&&S.eq(a[A].style)&&(te=rt)}te?(te.to=f,te.step=o):a.push({style:S,from:Math.max(c,t),to:f,step:o})}}}),a.forEach(l=>e.step(new RemoveMarkStep(l.from,l.to,l.style)))}function clearIncompatible(e,t,n,s=n.contentMatch,a=!0){let o=e.doc.nodeAt(t),l=[],c=t+1;for(let d=0;d<o.childCount;d++){let f=o.child(d),R=c+f.nodeSize,S=s.matchType(f.type);if(!S)l.push(new ReplaceStep(c,R,Slice.empty));else{s=S;for(let te=0;te<f.marks.length;te++)n.allowsMarkType(f.marks[te].type)||e.step(new RemoveMarkStep(c,R,f.marks[te]));if(a&&f.isText&&n.whitespace!="pre"){let te,A=/\r?\n|\r/g,rt;for(;te=A.exec(f.text);)rt||(rt=new Slice(Fragment.from(n.schema.text(" ",n.allowedMarks(f.marks))),0,0)),l.push(new ReplaceStep(c+te.index,c+te.index+te[0].length,rt))}}c=R}if(!s.validEnd){let d=s.fillBefore(Fragment.empty,!0);e.replace(c,c,new Slice(d,0,0))}for(let d=l.length-1;d>=0;d--)e.step(l[d])}function canCut(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function liftTarget(e){let n=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let s=e.depth,a=0,o=0;;--s){let l=e.$from.node(s),c=e.$from.index(s)+a,d=e.$to.indexAfter(s)-o;if(s<e.depth&&l.canReplace(c,d,n))return s;if(s==0||l.type.spec.isolating||!canCut(l,c,d))break;c&&(a=1),d<l.childCount&&(o=1)}return null}function lift$2(e,t,n){let{$from:s,$to:a,depth:o}=t,l=s.before(o+1),c=a.after(o+1),d=l,f=c,R=Fragment.empty,S=0;for(let rt=o,st=!1;rt>n;rt--)st||s.index(rt)>0?(st=!0,R=Fragment.from(s.node(rt).copy(R)),S++):d--;let te=Fragment.empty,A=0;for(let rt=o,st=!1;rt>n;rt--)st||a.after(rt+1)<a.end(rt)?(st=!0,te=Fragment.from(a.node(rt).copy(te)),A++):f++;e.step(new ReplaceAroundStep(d,f,l,c,new Slice(R.append(te),S,A),R.size-S,!0))}function findWrapping(e,t,n=null,s=e){let a=findWrappingOutside(e,t),o=a&&findWrappingInside(s,t);return o?a.map(withAttrs).concat({type:t,attrs:n}).concat(o.map(withAttrs)):null}function withAttrs(e){return{type:e,attrs:null}}function findWrappingOutside(e,t){let{parent:n,startIndex:s,endIndex:a}=e,o=n.contentMatchAt(s).findWrapping(t);if(!o)return null;let l=o.length?o[0]:t;return n.canReplaceWith(s,a,l)?o:null}function findWrappingInside(e,t){let{parent:n,startIndex:s,endIndex:a}=e,o=n.child(s),l=t.contentMatch.findWrapping(o.type);if(!l)return null;let d=(l.length?l[l.length-1]:t).contentMatch;for(let f=s;d&&f<a;f++)d=d.matchType(n.child(f).type);return!d||!d.validEnd?null:l}function wrap(e,t,n){let s=Fragment.empty;for(let l=n.length-1;l>=0;l--){if(s.size){let c=n[l].type.contentMatch.matchFragment(s);if(!c||!c.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}s=Fragment.from(n[l].type.create(n[l].attrs,s))}let a=t.start,o=t.end;e.step(new ReplaceAroundStep(a,o,a,o,new Slice(s,0,0),n.length,!0))}function setBlockType$1(e,t,n,s,a){if(!s.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=e.steps.length;e.doc.nodesBetween(t,n,(l,c)=>{let d=typeof a=="function"?a(l):a;if(l.isTextblock&&!l.hasMarkup(s,d)&&canChangeType(e.doc,e.mapping.slice(o).map(c),s)){let f=null;if(s.schema.linebreakReplacement){let A=s.whitespace=="pre",rt=!!s.contentMatch.matchType(s.schema.linebreakReplacement);A&&!rt?f=!1:!A&&rt&&(f=!0)}f===!1&&replaceLinebreaks(e,l,c,o),clearIncompatible(e,e.mapping.slice(o).map(c,1),s,void 0,f===null);let R=e.mapping.slice(o),S=R.map(c,1),te=R.map(c+l.nodeSize,1);return e.step(new ReplaceAroundStep(S,te,S+1,te-1,new Slice(Fragment.from(s.create(d,null,l.marks)),0,0),1,!0)),f===!0&&replaceNewlines(e,l,c,o),!1}})}function replaceNewlines(e,t,n,s){t.forEach((a,o)=>{if(a.isText){let l,c=/\r?\n|\r/g;for(;l=c.exec(a.text);){let d=e.mapping.slice(s).map(n+1+o+l.index);e.replaceWith(d,d+1,t.type.schema.linebreakReplacement.create())}}})}function replaceLinebreaks(e,t,n,s){t.forEach((a,o)=>{if(a.type==a.type.schema.linebreakReplacement){let l=e.mapping.slice(s).map(n+1+o);e.replaceWith(l,l+1,t.type.schema.text(`
|