randmarcomps 1.333.0 → 1.335.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 +39 -8
- package/dist/randmarcomps.umd.cjs +5 -5
- package/package.json +1 -1
package/dist/randmarcomps.js
CHANGED
|
@@ -63971,8 +63971,7 @@ function PartnerRelationshipPage({
|
|
|
63971
63971
|
AssistantInsight,
|
|
63972
63972
|
{
|
|
63973
63973
|
prompt: O,
|
|
63974
|
-
thinkingPlaceholderText: "Thinking about the relationship..."
|
|
63975
|
-
smartAndSlow: !0
|
|
63974
|
+
thinkingPlaceholderText: "Thinking about the relationship..."
|
|
63976
63975
|
}
|
|
63977
63976
|
) }) })
|
|
63978
63977
|
] }) }),
|
|
@@ -65013,7 +65012,15 @@ function ManufacturerCard({
|
|
|
65013
65012
|
return /* @__PURE__ */ jsxs(Card, { className: "manufacturer-theme flex flex-col h-full", children: [
|
|
65014
65013
|
/* @__PURE__ */ jsx(Link, { to: e ?? "#", target: e && n ? "_blank" : "_self", children: /* @__PURE__ */ jsxs(CardHeader, { className: "flex flex-row items-start justify-between space-y-0 pb-2 pt-4", children: [
|
|
65015
65014
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
65016
|
-
/* @__PURE__ */ jsx("div", { className: "h-12 w-12 overflow-hidden rounded-md", children: /* @__PURE__ */ jsx(
|
|
65015
|
+
/* @__PURE__ */ jsx("div", { className: "h-12 w-12 overflow-hidden rounded-md", children: /* @__PURE__ */ jsx(
|
|
65016
|
+
PartnerLogo,
|
|
65017
|
+
{
|
|
65018
|
+
id: t.ManufacturerId,
|
|
65019
|
+
width: 48,
|
|
65020
|
+
height: 48
|
|
65021
|
+
},
|
|
65022
|
+
`partner_logo_${t.ManufacturerId}`
|
|
65023
|
+
) }),
|
|
65017
65024
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
65018
65025
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
65019
65026
|
/* @__PURE__ */ jsx("span", { className: "text-xs text-primary", children: "Manufacturer" }),
|
|
@@ -67608,7 +67615,15 @@ function PartnerCard({
|
|
|
67608
67615
|
] })
|
|
67609
67616
|
] }) : /* @__PURE__ */ jsxs(Card, { className: `flex flex-col h-full ${o}`, children: [
|
|
67610
67617
|
/* @__PURE__ */ jsx(CardHeader, { className: "flex flex-row items-start justify-between space-y-0 pb-2 pt-4", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
67611
|
-
/* @__PURE__ */ jsx("div", { className: "h-12 w-12 overflow-hidden rounded-md", children: /* @__PURE__ */ jsx(
|
|
67618
|
+
/* @__PURE__ */ jsx("div", { className: "h-12 w-12 overflow-hidden rounded-md", children: /* @__PURE__ */ jsx(
|
|
67619
|
+
PartnerLogo,
|
|
67620
|
+
{
|
|
67621
|
+
id: t.ApplicationId,
|
|
67622
|
+
width: 64,
|
|
67623
|
+
height: 64
|
|
67624
|
+
},
|
|
67625
|
+
`partner_logo_${t.ApplicationId}`
|
|
67626
|
+
) }),
|
|
67612
67627
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
67613
67628
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
67614
67629
|
/* @__PURE__ */ jsx("span", { className: "text-xs text-primary", children: "Partner" }),
|
|
@@ -67740,7 +67755,15 @@ function ResellerCard({
|
|
|
67740
67755
|
return /* @__PURE__ */ jsxs(Card, { className: "reseller-theme flex flex-col h-full", children: [
|
|
67741
67756
|
/* @__PURE__ */ jsx(Link, { to: e ?? "#", target: e && n ? "_blank" : "_self", children: /* @__PURE__ */ jsxs(CardHeader, { className: "flex flex-row items-start justify-between space-y-0 pb-2 pt-4", children: [
|
|
67742
67757
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
67743
|
-
/* @__PURE__ */ jsx("div", { className: "h-12 w-12 overflow-hidden rounded-md", children: /* @__PURE__ */ jsx(
|
|
67758
|
+
/* @__PURE__ */ jsx("div", { className: "h-12 w-12 overflow-hidden rounded-md", children: /* @__PURE__ */ jsx(
|
|
67759
|
+
PartnerLogo,
|
|
67760
|
+
{
|
|
67761
|
+
id: t.ResellerId,
|
|
67762
|
+
width: 48,
|
|
67763
|
+
height: 48
|
|
67764
|
+
},
|
|
67765
|
+
`partner_logo_${t.ResellerId}`
|
|
67766
|
+
) }),
|
|
67744
67767
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
67745
67768
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
67746
67769
|
/* @__PURE__ */ jsx("span", { className: "text-xs text-primary", children: "Reseller" }),
|
|
@@ -74239,7 +74262,8 @@ function ProductCard({
|
|
|
74239
74262
|
name: e.ManufacturerName,
|
|
74240
74263
|
width: 96,
|
|
74241
74264
|
height: 40
|
|
74242
|
-
}
|
|
74265
|
+
},
|
|
74266
|
+
`partner_logo_${e.ManufacturerId}`
|
|
74243
74267
|
) })
|
|
74244
74268
|
] }),
|
|
74245
74269
|
/* @__PURE__ */ jsxs("div", { className: "flex gap-6", children: [
|
|
@@ -74367,7 +74391,14 @@ function ProductCard({
|
|
|
74367
74391
|
] })
|
|
74368
74392
|
] })
|
|
74369
74393
|
] }),
|
|
74370
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: /* @__PURE__ */ jsx(
|
|
74394
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: /* @__PURE__ */ jsx(
|
|
74395
|
+
ProductImage,
|
|
74396
|
+
{
|
|
74397
|
+
randmarSKU: e.RandmarSKU || "",
|
|
74398
|
+
alt: e.RandmarTitle || ""
|
|
74399
|
+
},
|
|
74400
|
+
`product_image_${e.RandmarSKU}`
|
|
74401
|
+
) })
|
|
74371
74402
|
] }),
|
|
74372
74403
|
/* @__PURE__ */ jsxs("div", { className: "flex gap-6 mt-4", children: [
|
|
74373
74404
|
/* @__PURE__ */ jsx("div", { className: "flex flex-1", children: qe && e.Distribution && /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
@@ -93567,7 +93598,7 @@ const GetTextInsightFromAI = async (t, e, n, o = 3) => {
|
|
|
93567
93598
|
Prompt: "${e}"
|
|
93568
93599
|
`;
|
|
93569
93600
|
try {
|
|
93570
|
-
const d = new GoogleGenAI({ apiKey: t }), f = n ? "gemini-
|
|
93601
|
+
const d = new GoogleGenAI({ apiKey: t }), f = n ? "gemini-2.5-pro" : "gemini-2.5-flash";
|
|
93571
93602
|
return (await d.chats.create({ model: f }).sendMessage({ message: l })).text ?? "<p>Sorry, I couldn't generate a response for this.</p>";
|
|
93572
93603
|
} catch (d) {
|
|
93573
93604
|
return console.error("Error fetching AI insight:", d), o > 0 ? (await new Promise((f) => setTimeout(f, (4 - o) * 500)), GetTextInsightFromAI(t, e, n, o - 1)) : "<p>An error occurred while generating the insight.</p>";
|
|
@@ -1104,9 +1104,9 @@ Defaulting to \`null\`.`}var Root=Progress$1,Indicator=ProgressIndicator;const P
|
|
|
1104
1104
|
\`\`\`json
|
|
1105
1105
|
${JSON.stringify(f,null,2)}
|
|
1106
1106
|
\`\`\`
|
|
1107
|
-
`,[d,f]);return jsxRuntime.jsxs("div",{className:"@container",children:[jsxRuntime.jsxs("div",{className:"grid gap-4 @2xl:grid-cols-2",children:[jsxRuntime.jsx(PartnerCard,{account:f,loading:g||b,withAbout:!0,withVoice:!1,action:" "}),jsxRuntime.jsxs("div",{className:"grid gap-4",children:[((f==null?void 0:f.Manufacturer)||g||b)&&jsxRuntime.jsx(ManufacturerCard,{manufacturer:f==null?void 0:f.Manufacturer,loading:g||b,mainAction:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[(f==null?void 0:f.Manufacturer)&&jsxRuntime.jsx(ManufacturerGetStartedButton,{applicationId:t,manufacturer:f==null?void 0:f.Manufacturer}),o&&((z=(q=f==null?void 0:f.Manufacturer)==null?void 0:q.Categories)==null?void 0:z.findIndex(V=>V.AvailableToBuy))!==-1&&jsxRuntime.jsxs(Dialog,{open:E,onOpenChange:A,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{className:"bg-green-600 hover:bg-green-700 ml-2",disabled:R,children:R?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 "',(Q=f==null?void 0:f.Manufacturer)==null?void 0:Q.PublicName,'" to Shopify? This will add all products from this manufacturer to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>A(!1),children:"Cancel"}),jsxRuntime.jsx(Button,{className:"bg-green-600 hover:bg-green-700",onClick:M,disabled:R,children:R?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})]})]})}),(f==null?void 0:f.Reseller)&&jsxRuntime.jsx(ResellerCard,{reseller:f==null?void 0:f.Reseller,loading:g||b})]})]}),((f==null?void 0:f.Reseller)||(f==null?void 0:f.Manufacturer))&&!g&&!b&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4",children:jsxRuntime.jsxs(Tabs,{defaultValue:I(),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:[(f==null?void 0:f.Reseller)&&jsxRuntime.jsx(TabsTrigger,{value:"reseller-overview",className:"reseller-theme 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"}),(f==null?void 0:f.Manufacturer)&&jsxRuntime.jsx(TabsTrigger,{value:"manufacturer-overview",className:"manufacturer-theme 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"}),(f==null?void 0:f.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"]})]}),(f==null?void 0:f.Reseller)&&jsxRuntime.jsx(TabsContent,{value:"reseller-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ResellerOverview,{readonly:!0,appID:f.ApplicationId||"",reseller:f==null?void 0:f.Reseller,userEmail:n,isSuperAdmin:l,withoutReports:!0})})}),(f==null?void 0:f.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"manufacturer-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerOverviewPage,{readonly:!0,manufacturer:f==null?void 0:f.Manufacturer,applicationId:t,userEmail:n})})}),(f==null?void 0:f.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"products",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerProducts,{applicationId:t,manufacturer:f.Manufacturer,shopifyHostName:o})})}),jsxRuntime.jsx(TabsContent,{value:"assistant",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(AssistantInsight,{prompt:j,thinkingPlaceholderText:"Thinking about the relationship...",smartAndSlow:!0})})})]})}),(g||b)&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4 mt-4 flex justify-center items-center h-32",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-primary"})})]})}const PublicInfo=({reseller:t,appID:e,isLoading:n,readonly:o,onUnsavedChanges:l})=>{const{toast:d}=useToast(),[f]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),[g,b]=React.useState({}),_=React.useMemo(()=>({publicEmail:t.PublicEmail??"",contactName:t.ContactName??"",phone:t.Phone??"",website:t.Website??""}),[t]),{register:S,handleSubmit:R,reset:C,watch:E,formState:{errors:A,isSubmitting:M}}=useForm({defaultValues:_}),I=E(),j=React.useCallback(()=>g?JSON.stringify(I)!==JSON.stringify(g):!1,[I,g]);React.useEffect(()=>{l&&l(j())},[j,l]),React.useEffect(()=>{t&&Object.keys(t).length>0&&(C(_),b(_))},[t,C,_]);const q=async Q=>{let V=!0,F=!1;const te=Object.keys(Q).map(ne=>({key:ne,keyApi:ne.charAt(0).toUpperCase()+ne.slice(1)}));for(const ne of te){const se=Q[ne.key],ge=t[ne.keyApi];if(se!==ge&&se!==void 0){F=!0;try{await f({applicationId:e,fieldName:ne.keyApi,newValue:String(se)}).unwrap()||(V=!1)}catch(oe){console.error(`Error updating ${ne.keyApi}:`,oe),V=!1}}}V&&F?(d({title:"Public info",description:"Information updated successfully",variant:"success"}),b({...Q}),l&&l(!1)):V||d({title:"Updation error",description:"Failed to update",variant:"destructive"})},z=Q=>!Q||Q.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 ",o?"(read only)":""]})}),jsxRuntime.jsxs(CardContent,{children:[(z(E("contactName"))||z(E("publicEmail"))||z(E("website"))||z(E("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:R(q),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:o,...S("contactName",{}),className:A.contactName||z(E("contactName"))?"input-error-indicator":""}),A.contactName&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.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:o,...S("publicEmail",{pattern:{value:/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,message:"Invalid email address"}}),className:A.publicEmail||z(E("publicEmail"))?"input-error-indicator":""}),A.publicEmail&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.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:o,...S("website",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:A.website||z(E("website"))?"input-error-indicator":""}),A.website&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.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:o,...S("phone",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:A.phone||z(E("phone"))?"input-error-indicator":""}),A.phone&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.phone.message})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Button,{type:"submit",disabled:M||o,className:o?"hidden":"",children:M?"Saving...":"Save"})})]})]})]})};function BillingCard({appID:t,reseller:e,isLoading:n,withoutReports:o,userEmail:l}){const{toast:d}=useToast(),{Statement:f,CreditLimit:g}=e,[b,_]=React.useState(!1),[S,R]=React.useState(!1),[C,E]=React.useState(!1),[A,M]=React.useState(!1),[I,j]=React.useState(!1),[q,z]=React.useState(l||""),Q=[{label:"0 - 30 Days",value:jsxRuntime.jsx(FormattedNumber,{value:(f==null?void 0:f.Over0)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:Calendar},{label:"31 - 45 Days",value:jsxRuntime.jsx(FormattedNumber,{value:(f==null?void 0:f.Over30)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarDays},{label:"45+ Days",value:jsxRuntime.jsx(FormattedNumber,{value:(f==null?void 0:f.Over45)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarRange},{label:"Total",value:jsxRuntime.jsx(FormattedNumber,{value:(f==null?void 0:f.Total)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:DollarSign},{label:"Credit Limit",value:jsxRuntime.jsx(FormattedNumber,{value:g||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CreditCard}],[V]=useLazyGetV4ResellerByRouteResellerIdDocumentAndDocumentNumberPdfQuery(),F=async ge=>{_(!1),ge?R(!0):E(!0);try{const Ae=(await V({routeResellerId:t,documentNumber:`ST${t}`})).data;if(!Ae)throw new Error("No data received for download.");if(ge)window.open(Ae);else{const je=document.createElement("a");je.href=Ae,je.download=`ST${t}.pdf`,document.body.appendChild(je),je.click(),je.remove()}d({title:"Success",description:"Statement downloaded successfully.",variant:"success"})}catch(oe){console.error("Download Error:",oe),d({title:"Error",description:"An error occurred while downloading the statement. Please try again.",variant:"destructive"})}finally{ge?R(!1):E(!1)}},[te]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),ne=async()=>{if(!q||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(q)){d({title:"Invalid Email",description:"Please enter a valid email address.",variant:"destructive"});return}M(!0);try{await te({routeResellerId:t,emailAddress:q}).unwrap(),d({title:"Success",description:`Statement sent to ${q} successfully.`,variant:"success"}),j(!1)}catch(oe){console.error("Send Email Error:",oe),d({title:"Error",description:"An error occurred while sending the statement. Please try again.",variant:"destructive"})}finally{M(!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(ge=>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"})]},ge))}),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(ge=>jsxRuntime.jsx("div",{className:ge===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"})]})},ge))})]}),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 se=!o;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:Q.slice(0,3).map((ge,oe)=>jsxRuntime.jsx(BillingItem,{icon:ge.icon,label:ge.label,value:ge.value},oe))}),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:Q.slice(3).map((ge,oe)=>jsxRuntime.jsx("div",{className:oe===1?"pt-6 mt-6 border-t border-border":"",children:jsxRuntime.jsx(BillingItem,{icon:ge.icon,label:ge.label,value:ge.value})},oe))})]}),se&&jsxRuntime.jsxs("div",{className:"flex justify-end mt-6 gap-2",children:[jsxRuntime.jsxs(DropdownMenu,{open:b,onOpenChange:_,children:[jsxRuntime.jsx(DropdownMenuTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"outline",disabled:S||C,children:S?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Printing..."]}):C?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Downloading..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(FileText,{className:"mr-2 h-4 w-4"}),"Statement",jsxRuntime.jsx(ChevronDown,{className:"ml-2 h-4 w-4"})]})})}),jsxRuntime.jsxs(DropdownMenuContent,{align:"end",children:[jsxRuntime.jsxs(DropdownMenuItem,{onClick:()=>F(!0),disabled:S,children:[jsxRuntime.jsx(Printer,{className:"mr-2 h-4 w-4"}),jsxRuntime.jsx("span",{children:"Print"})]}),jsxRuntime.jsx(DropdownMenuSeparator,{}),jsxRuntime.jsxs(DropdownMenuItem,{onClick:()=>F(!1),disabled:C,children:[jsxRuntime.jsx(Download,{className:"mr-2 h-4 w-4"}),jsxRuntime.jsx("span",{children:"Download"})]}),jsxRuntime.jsx(DropdownMenuSeparator,{}),jsxRuntime.jsxs(DropdownMenuItem,{onSelect:()=>j(!0),children:[jsxRuntime.jsx(Mail,{className:"mr-2 h-4 w-4"}),jsxRuntime.jsx("span",{children:"Send by Email"})]})]})]}),jsxRuntime.jsx(reactRouterDom.Link,{to:`${window.location.hostname==="dashboard.randmar.io"?"":"https://dashboard.randmar.io"}/${t}/PayInvoice`,target:window.location.hostname==="dashboard.randmar.io"?"_self":"_blank",children:jsxRuntime.jsxs(Button,{children:[jsxRuntime.jsx(CreditCard,{className:"mr-2 h-4 w-4"}),"Pay Invoices"]})})]})]})]}),jsxRuntime.jsx(Dialog,{open:I,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:q,onChange:ge=>z(ge.target.value),className:"col-span-3",placeholder:"recipient@example.com"})]})}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button,{type:"submit",onClick:ne,disabled:A||!q,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"]})})})]})})]})}function BillingItem({icon:t,label:e,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(t,{className:"size-4 text-muted-foreground"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:e})]}),jsxRuntime.jsx("span",{className:"text-base font-semibold ms-auto",children:n})]})}function ChangePricingTierModal({open:t,setOpen:e,tier:n,onTierChange:o,isLoading:l}){const d=()=>{e(!1)};return jsxRuntime.jsx(Dialog,{open:t,onOpenChange:e,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,{variant:"outline",onClick:d,disabled:l,children:"Cancel"}),jsxRuntime.jsx(Button,{onClick:o,disabled:l,children:l?"Loading...":`Apply for ${n}`})]})]})})}const getPricingText=t=>t===1?"The Best":t===2?"Fixed 12.5% GP on all items":t===3?"Advantageous":t===4?"Buying Group":t===5?"Cost":t,getShippingText=t=>t==="A"?"Free or Custom":t==="B"?"Fixed $10 anywhere":t==="C"?`Free shipping on $150+ orders to your location,
|
|
1107
|
+
`,[d,f]);return jsxRuntime.jsxs("div",{className:"@container",children:[jsxRuntime.jsxs("div",{className:"grid gap-4 @2xl:grid-cols-2",children:[jsxRuntime.jsx(PartnerCard,{account:f,loading:g||b,withAbout:!0,withVoice:!1,action:" "}),jsxRuntime.jsxs("div",{className:"grid gap-4",children:[((f==null?void 0:f.Manufacturer)||g||b)&&jsxRuntime.jsx(ManufacturerCard,{manufacturer:f==null?void 0:f.Manufacturer,loading:g||b,mainAction:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[(f==null?void 0:f.Manufacturer)&&jsxRuntime.jsx(ManufacturerGetStartedButton,{applicationId:t,manufacturer:f==null?void 0:f.Manufacturer}),o&&((z=(q=f==null?void 0:f.Manufacturer)==null?void 0:q.Categories)==null?void 0:z.findIndex(V=>V.AvailableToBuy))!==-1&&jsxRuntime.jsxs(Dialog,{open:E,onOpenChange:A,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{className:"bg-green-600 hover:bg-green-700 ml-2",disabled:R,children:R?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 "',(Q=f==null?void 0:f.Manufacturer)==null?void 0:Q.PublicName,'" to Shopify? This will add all products from this manufacturer to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>A(!1),children:"Cancel"}),jsxRuntime.jsx(Button,{className:"bg-green-600 hover:bg-green-700",onClick:M,disabled:R,children:R?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})]})]})}),(f==null?void 0:f.Reseller)&&jsxRuntime.jsx(ResellerCard,{reseller:f==null?void 0:f.Reseller,loading:g||b})]})]}),((f==null?void 0:f.Reseller)||(f==null?void 0:f.Manufacturer))&&!g&&!b&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4",children:jsxRuntime.jsxs(Tabs,{defaultValue:I(),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:[(f==null?void 0:f.Reseller)&&jsxRuntime.jsx(TabsTrigger,{value:"reseller-overview",className:"reseller-theme 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"}),(f==null?void 0:f.Manufacturer)&&jsxRuntime.jsx(TabsTrigger,{value:"manufacturer-overview",className:"manufacturer-theme 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"}),(f==null?void 0:f.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"]})]}),(f==null?void 0:f.Reseller)&&jsxRuntime.jsx(TabsContent,{value:"reseller-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ResellerOverview,{readonly:!0,appID:f.ApplicationId||"",reseller:f==null?void 0:f.Reseller,userEmail:n,isSuperAdmin:l,withoutReports:!0})})}),(f==null?void 0:f.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"manufacturer-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerOverviewPage,{readonly:!0,manufacturer:f==null?void 0:f.Manufacturer,applicationId:t,userEmail:n})})}),(f==null?void 0:f.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"products",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerProducts,{applicationId:t,manufacturer:f.Manufacturer,shopifyHostName:o})})}),jsxRuntime.jsx(TabsContent,{value:"assistant",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(AssistantInsight,{prompt:j,thinkingPlaceholderText:"Thinking about the relationship..."})})})]})}),(g||b)&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4 mt-4 flex justify-center items-center h-32",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-primary"})})]})}const PublicInfo=({reseller:t,appID:e,isLoading:n,readonly:o,onUnsavedChanges:l})=>{const{toast:d}=useToast(),[f]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),[g,b]=React.useState({}),_=React.useMemo(()=>({publicEmail:t.PublicEmail??"",contactName:t.ContactName??"",phone:t.Phone??"",website:t.Website??""}),[t]),{register:S,handleSubmit:R,reset:C,watch:E,formState:{errors:A,isSubmitting:M}}=useForm({defaultValues:_}),I=E(),j=React.useCallback(()=>g?JSON.stringify(I)!==JSON.stringify(g):!1,[I,g]);React.useEffect(()=>{l&&l(j())},[j,l]),React.useEffect(()=>{t&&Object.keys(t).length>0&&(C(_),b(_))},[t,C,_]);const q=async Q=>{let V=!0,F=!1;const te=Object.keys(Q).map(ne=>({key:ne,keyApi:ne.charAt(0).toUpperCase()+ne.slice(1)}));for(const ne of te){const se=Q[ne.key],ge=t[ne.keyApi];if(se!==ge&&se!==void 0){F=!0;try{await f({applicationId:e,fieldName:ne.keyApi,newValue:String(se)}).unwrap()||(V=!1)}catch(oe){console.error(`Error updating ${ne.keyApi}:`,oe),V=!1}}}V&&F?(d({title:"Public info",description:"Information updated successfully",variant:"success"}),b({...Q}),l&&l(!1)):V||d({title:"Updation error",description:"Failed to update",variant:"destructive"})},z=Q=>!Q||Q.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 ",o?"(read only)":""]})}),jsxRuntime.jsxs(CardContent,{children:[(z(E("contactName"))||z(E("publicEmail"))||z(E("website"))||z(E("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:R(q),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:o,...S("contactName",{}),className:A.contactName||z(E("contactName"))?"input-error-indicator":""}),A.contactName&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.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:o,...S("publicEmail",{pattern:{value:/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,message:"Invalid email address"}}),className:A.publicEmail||z(E("publicEmail"))?"input-error-indicator":""}),A.publicEmail&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.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:o,...S("website",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:A.website||z(E("website"))?"input-error-indicator":""}),A.website&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.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:o,...S("phone",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:A.phone||z(E("phone"))?"input-error-indicator":""}),A.phone&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.phone.message})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Button,{type:"submit",disabled:M||o,className:o?"hidden":"",children:M?"Saving...":"Save"})})]})]})]})};function BillingCard({appID:t,reseller:e,isLoading:n,withoutReports:o,userEmail:l}){const{toast:d}=useToast(),{Statement:f,CreditLimit:g}=e,[b,_]=React.useState(!1),[S,R]=React.useState(!1),[C,E]=React.useState(!1),[A,M]=React.useState(!1),[I,j]=React.useState(!1),[q,z]=React.useState(l||""),Q=[{label:"0 - 30 Days",value:jsxRuntime.jsx(FormattedNumber,{value:(f==null?void 0:f.Over0)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:Calendar},{label:"31 - 45 Days",value:jsxRuntime.jsx(FormattedNumber,{value:(f==null?void 0:f.Over30)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarDays},{label:"45+ Days",value:jsxRuntime.jsx(FormattedNumber,{value:(f==null?void 0:f.Over45)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarRange},{label:"Total",value:jsxRuntime.jsx(FormattedNumber,{value:(f==null?void 0:f.Total)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:DollarSign},{label:"Credit Limit",value:jsxRuntime.jsx(FormattedNumber,{value:g||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CreditCard}],[V]=useLazyGetV4ResellerByRouteResellerIdDocumentAndDocumentNumberPdfQuery(),F=async ge=>{_(!1),ge?R(!0):E(!0);try{const Ae=(await V({routeResellerId:t,documentNumber:`ST${t}`})).data;if(!Ae)throw new Error("No data received for download.");if(ge)window.open(Ae);else{const je=document.createElement("a");je.href=Ae,je.download=`ST${t}.pdf`,document.body.appendChild(je),je.click(),je.remove()}d({title:"Success",description:"Statement downloaded successfully.",variant:"success"})}catch(oe){console.error("Download Error:",oe),d({title:"Error",description:"An error occurred while downloading the statement. Please try again.",variant:"destructive"})}finally{ge?R(!1):E(!1)}},[te]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),ne=async()=>{if(!q||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(q)){d({title:"Invalid Email",description:"Please enter a valid email address.",variant:"destructive"});return}M(!0);try{await te({routeResellerId:t,emailAddress:q}).unwrap(),d({title:"Success",description:`Statement sent to ${q} successfully.`,variant:"success"}),j(!1)}catch(oe){console.error("Send Email Error:",oe),d({title:"Error",description:"An error occurred while sending the statement. Please try again.",variant:"destructive"})}finally{M(!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(ge=>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"})]},ge))}),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(ge=>jsxRuntime.jsx("div",{className:ge===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"})]})},ge))})]}),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 se=!o;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:Q.slice(0,3).map((ge,oe)=>jsxRuntime.jsx(BillingItem,{icon:ge.icon,label:ge.label,value:ge.value},oe))}),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:Q.slice(3).map((ge,oe)=>jsxRuntime.jsx("div",{className:oe===1?"pt-6 mt-6 border-t border-border":"",children:jsxRuntime.jsx(BillingItem,{icon:ge.icon,label:ge.label,value:ge.value})},oe))})]}),se&&jsxRuntime.jsxs("div",{className:"flex justify-end mt-6 gap-2",children:[jsxRuntime.jsxs(DropdownMenu,{open:b,onOpenChange:_,children:[jsxRuntime.jsx(DropdownMenuTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"outline",disabled:S||C,children:S?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Printing..."]}):C?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Downloading..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(FileText,{className:"mr-2 h-4 w-4"}),"Statement",jsxRuntime.jsx(ChevronDown,{className:"ml-2 h-4 w-4"})]})})}),jsxRuntime.jsxs(DropdownMenuContent,{align:"end",children:[jsxRuntime.jsxs(DropdownMenuItem,{onClick:()=>F(!0),disabled:S,children:[jsxRuntime.jsx(Printer,{className:"mr-2 h-4 w-4"}),jsxRuntime.jsx("span",{children:"Print"})]}),jsxRuntime.jsx(DropdownMenuSeparator,{}),jsxRuntime.jsxs(DropdownMenuItem,{onClick:()=>F(!1),disabled:C,children:[jsxRuntime.jsx(Download,{className:"mr-2 h-4 w-4"}),jsxRuntime.jsx("span",{children:"Download"})]}),jsxRuntime.jsx(DropdownMenuSeparator,{}),jsxRuntime.jsxs(DropdownMenuItem,{onSelect:()=>j(!0),children:[jsxRuntime.jsx(Mail,{className:"mr-2 h-4 w-4"}),jsxRuntime.jsx("span",{children:"Send by Email"})]})]})]}),jsxRuntime.jsx(reactRouterDom.Link,{to:`${window.location.hostname==="dashboard.randmar.io"?"":"https://dashboard.randmar.io"}/${t}/PayInvoice`,target:window.location.hostname==="dashboard.randmar.io"?"_self":"_blank",children:jsxRuntime.jsxs(Button,{children:[jsxRuntime.jsx(CreditCard,{className:"mr-2 h-4 w-4"}),"Pay Invoices"]})})]})]})]}),jsxRuntime.jsx(Dialog,{open:I,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:q,onChange:ge=>z(ge.target.value),className:"col-span-3",placeholder:"recipient@example.com"})]})}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button,{type:"submit",onClick:ne,disabled:A||!q,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"]})})})]})})]})}function BillingItem({icon:t,label:e,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(t,{className:"size-4 text-muted-foreground"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:e})]}),jsxRuntime.jsx("span",{className:"text-base font-semibold ms-auto",children:n})]})}function ChangePricingTierModal({open:t,setOpen:e,tier:n,onTierChange:o,isLoading:l}){const d=()=>{e(!1)};return jsxRuntime.jsx(Dialog,{open:t,onOpenChange:e,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,{variant:"outline",onClick:d,disabled:l,children:"Cancel"}),jsxRuntime.jsx(Button,{onClick:o,disabled:l,children:l?"Loading...":`Apply for ${n}`})]})]})})}const getPricingText=t=>t===1?"The Best":t===2?"Fixed 12.5% GP on all items":t===3?"Advantageous":t===4?"Buying Group":t===5?"Cost":t,getShippingText=t=>t==="A"?"Free or Custom":t==="B"?"Fixed $10 anywhere":t==="C"?`Free shipping on $150+ orders to your location,
|
|
1108
1108
|
$15 for drop shipped orders under $1,500,
|
|
1109
|
-
$10 with opportunities under $1,000`:t==="D"?"$15 under $1,500":t==="E"?"Full shipping charges":t,getTermsText=t=>t==="STRIPE"?"Credit card payment":t==="NET30"?"Net 30 days":t,AccountTier=({isSuperAdmin:t,readonly:e,reseller:n,appID:o,isLoading:l})=>{const{toast:d}=useToast(),[f,g]=React.useState(!1),[b,_]=React.useState(""),[S,{isLoading:R}]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),C=Oe=>Oe&&{Starter:"starter","E-Commerce":"ecommerce",Commercial:"commercial",Basics:"cws",Novexco:"novexco","Jean Coutu":"jeancoutu",Exclusive:"exclusive"}[Oe]||"",E=Oe=>Oe&&{A:"free",B:"fixed",C:"dropshipped",D:"under1500",E:"fullcharges"}[Oe]||"",A=Oe=>Oe&&{1:"exclusive",2:"ecommerce",3:"commercial",4:"buyinggroup",5:"cost"}[Oe]||"",[M,I]=React.useState(C((n==null?void 0:n.Priority)??"")),[j,q]=React.useState(E((n==null?void 0:n.ShippingProfile)??"")),[z,Q]=React.useState(A(n==null?void 0:n.PriceProfile)),V=Oe=>({starter:"Starter",ecommerce:"E-Commerce",commercial:"Commercial",cws:"Basics",novexco:"Novexco",jeancoutu:"Jean Coutu",exclusive:"Exclusive"})[Oe]||Oe,F=Oe=>({free:"A",fixed:"B",dropshipped:"C",under1500:"D",fullcharges:"E"})[Oe]||Oe,te=Oe=>({exclusive:"1",ecommerce:"2",commercial:"3",buyinggroup:"4",cost:"5"})[Oe]||Oe;React.useEffect(()=>{I(C((n==null?void 0:n.Priority)??"")),q(E((n==null?void 0:n.ShippingProfile)??"")),Q(A(n==null?void 0:n.PriceProfile))},[n]);const ne=async(Oe,Fe,ze,$e)=>{try{(await S({applicationId:o,fieldName:Oe,newValue:Fe})).error?d({title:"Error",description:$e,variant:"destructive"}):d({title:"Success",description:ze,variant:"success"})}catch{d({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}},se=async Oe=>{I(Oe);const Fe=V(Oe);ne("Priority",Fe,`Priority updated to ${Fe}`,"Failed to update priority")},ge=async Oe=>{q(Oe);const Fe=F(Oe);ne("ShippingProfile",Fe,`Shipping profile updated to ${Fe}`,"Failed to update shipping profile")},oe=async Oe=>{Q(Oe);const Fe=te(Oe);ne("PriceProfile",Fe,`Pricing profile updated to ${Fe}`,"Failed to update pricing profile")},Ae=async()=>{try{const Oe=await S({applicationId:o,fieldName:"Tier",newValue:b});Oe.error?d({title:"Error",description:"Failed to update reseller",variant:"destructive"}):Oe.data?d({title:"Success",description:`Pricing Tier changed to ${b}`,variant:"success"}):d({title:"Considered",description:"Request being considered",variant:"success"})}catch{d({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}finally{g(!1),_("")}},je=[{name:"Terms",enabled:n.Priority==="Starter"},{name:"E-Commerce",enabled:n.Priority==="Commercial"},{name:"Commercial",enabled:n.Priority==="E-Commerce"},{name:"Exclusive",enabled:t}],Ne=Oe=>{_(Oe),g(!0)};return l?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(Oe=>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"})]})]},Oe))}),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-1xl font-bold",children:"Account Tier"}),jsxRuntime.jsx(Badge,{variant:"secondary",className:"bg-green-100 text-green-700 hover:bg-green-200 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==null?void 0: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-green-600"})]}),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,{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==null?void 0:n.Terms)||"")})]})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[!e&&jsxRuntime.jsx(Button,{variant:"outline",className:"flex-1",asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:"https://www.randmar.io/docs/overview/pricingTiers",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,{disabled:e,className:e?"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"}),je.map(Oe=>jsxRuntime.jsx(Button,{variant:"ghost",size:"sm",className:"w-full justify-start h-8",disabled:!Oe.enabled,onClick:()=>Ne(Oe.name),children:Oe.name},Oe.name))]})})]})]})]})]}),jsxRuntime.jsx(ChangePricingTierModal,{isLoading:R,open:f,setOpen:g,tier:b,onTierChange:Ae}),t&&!e&&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:M,onValueChange:se,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:"jeancoutu",label:"Jean Coutu"},{value:"exclusive",label:"Exclusive"}].map(Oe=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Oe.value,id:`priority-${Oe.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`priority-${Oe.value}`,className:"cursor-pointer text-xs",children:Oe.label})]},Oe.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:j,onValueChange:ge,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(Oe=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Oe.value,id:`shipping-${Oe.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`shipping-${Oe.value}`,className:"cursor-pointer text-xs",children:Oe.label})]},Oe.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:z,onValueChange:oe,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(Oe=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Oe.value,id:`pricing-${Oe.value}`,className:"h-6 w-6 scale-50 antialiased"}),jsxRuntime.jsx(Label$2,{htmlFor:`pricing-${Oe.value}`,className:"cursor-pointer text-xs",children:Oe.label})]},Oe.value))})]})]})})]})]})};function OrderCategories({openOrders:t=[],isLoading:e=!1}){const n=(t==null?void 0:t.filter(M=>M.DocumentType==="Order"))||[],o=(t==null?void 0:t.filter(M=>M.DocumentType==="Shipment"))||[],l=n.filter(M=>M.WarehouseCode!=="3PLE"),d=l.reduce((M,I)=>M+(I.Quantity??0),0),f=l.reduce((M,I)=>M+(I.ExtendedPrice??0),0),g=n.filter(M=>M.WarehouseCode==="3PLE"),b=g.reduce((M,I)=>M+(I.Quantity??0),0),_=g.reduce((M,I)=>M+(I.ExtendedPrice??0),0),S=o.reduce((M,I)=>M+(I.Quantity??0),0),R=o.reduce((M,I)=>M+(I.ExtendedPrice??0),0),C=d+b+S,E=f+_+R,A=[{name:"All",icon:Package,color:"bg-blue-500",orders:C,amount:E},{name:"Processing",icon:RefreshCcw,color:"bg-yellow-500",orders:d,amount:f},{name:"Shipped",icon:Truck,color:"bg-green-500",orders:S,amount:R},{name:"Delayed",icon:CircleAlert,color:"bg-red-500",orders:b,amount:_}];return e?jsxRuntime.jsxs(Card,{className:"w-full @md:col-span-2 @xl:col-span-1",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(M=>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-gray-200 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"})]})]})]})]})},M))})})]}):jsxRuntime.jsxs(Card,{className:"w-full @md:col-span-2 @xl:col-span-1",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Order Categories"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:A.map(M=>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:`${M.color} bg-opacity-60 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:M.name}),jsxRuntime.jsx("div",{className:`${M.color} bg-opacity-90 p-2 rounded-full`,children:jsxRuntime.jsx(M.icon,{className:"size-4 shrink-0 text-white"})})]}),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:M.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:M.amount,style:"currency",currency:"CAD",currencyDisplay:"symbol"})})]})]})]})]})},M.name))})})]})}function ReportsSection({isLoading:t,userEmail:e,appID:n}){const{toast:o}=useToast(),[l,{isLoading:d}]=usePostV4ResellerByRouteResellerIdReportWalmartTrackingFileEmailMutation(),[f,{isLoading:g}]=usePostV4ResellerByRouteResellerIdReportAmazonTrackingFileEmailMutation(),[b,{isLoading:_}]=usePostV4ResellerByRouteResellerIdReportOpenOrdersEmailMutation(),[S,{isLoading:R}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[C,{isLoading:E}]=usePostV4ResellerByRouteResellerIdReportInvoicesEmailMutation(),[A,{isLoading:M}]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),[I,j]=React.useState(null),[q,z]=React.useState(e),[Q,V]=React.useState(!1),F=[{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}]}],te=async ge=>{j(ge),V(!0)},ne=async()=>{if(!(!I||!n))try{switch(I.id){case"Products":await S({routeResellerId:n,emailAddress:q}).unwrap();break;case"AmazonTrackingFile":await f({routeResellerId:n,emailAddress:q}).unwrap();break;case"WalmartTrackingFile":await l({routeResellerId:n,emailAddress:q}).unwrap();break;case"OpenOrders":await b({routeResellerId:n,emailAddress:q}).unwrap();break;case"Invoices":await C({routeResellerId:n,emailAddress:q}).unwrap();break;case"Statement":await A({routeResellerId:n,emailAddress:q}).unwrap();break;default:throw new Error("invalid report id")}o({title:"Report requested",description:`The ${I.title} will be sent to ${q} shortly.`,variant:"success"}),V(!1)}catch(ge){console.error("Error requesting report:",ge),o({title:"Error",description:"Failed to request report. Please try again.",variant:"destructive"})}},se=_||R||g||d||M||E;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:t?jsxRuntime.jsx(jsxRuntime.Fragment,{children:[1,2,3].map(ge=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-48"}),[1,2].map(oe=>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"})]},oe))]},ge))}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:F.map(ge=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:ge.name}),ge.reports.map(oe=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg hover:bg-gray-100 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-2 rounded-full",children:jsxRuntime.jsx(oe.icon,{className:"h-5 w-5 text-primary"})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("h4",{className:"font-semibold text-sm",children:oe.title}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:oe.description})]}),jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",className:"flex items-center gap-1",onClick:()=>te(oe),children:[jsxRuntime.jsx(Download,{className:"h-4 w-4"}),"Request"]})]},oe.id))]},ge.name))})}),jsxRuntime.jsx(Dialog,{open:Q,onOpenChange:V,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsxs(DialogTitle,{children:["Request ",I==null?void 0:I.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:q,onChange:ge=>z(ge.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,{variant:"outline",onClick:()=>V(!1),children:"Cancel"}),jsxRuntime.jsx(Button,{onClick:ne,disabled:!q||se,children:se?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}const badgeVariants=cva("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus: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-input hover:bg-accent hover:text-accent-foreground",success:"bg-green-600 text-white hover:bg-green-700",warning:"bg-yellow-500 text-white hover:bg-yellow-600",info:"bg-blue-500 text-white hover:bg-blue-600",ghost:"bg-background hover:bg-accent hover:text-accent-foreground",randmarRed:"bg-randmar-red text-white hover:bg-randmar-red/80",randmarBlue:"bg-randmar-blue text-white hover:bg-randmar-blue/80",randmarPurple:"bg-randmar-purple text-white hover:bg-randmar-purple/80",randmarGreen:"bg-randmar-green text-black hover:bg-randmar-green/80",randmarBlack:"bg-randmar-black text-white hover:bg-randmar-black/80",randmarYellow:"bg-randmar-yellow text-black hover:bg-randmar-yellow/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:t,variant:e,size:n,icon:o,children:l,...d},f)=>jsxRuntime.jsxs("div",{ref:f,className:cn(badgeVariants({variant:e,size:n}),t),...d,children:[o&&jsxRuntime.jsx("span",{className:"mr-1",children:o}),l]}));Badge.displayName="Badge";function QualificationBadge({qualification:t}){return!t.QualificationId||t.QualificationId==="Suspended"?null:t.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$1,{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:t.DefaultOpportunityNumber?"pr-1":"",children:[jsxRuntime.jsx(BadgeCheck,{className:"h-3 w-3 mr-1"}),t.QualificationId,t.DefaultOpportunityNumber&&jsxRuntime.jsx(Badge,{variant:"secondary",size:"sm",className:"ml-1",children:t.DefaultOpportunityNumber})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})})}function SalesChart({statistics:t,mode:e="month",chartHeight:n,loading:o=!1,size:l="default"}){const[d,f]=React.useState([]),[g,b]=React.useState(!1),_=[{name:"dollarVolume",label:"Dollar Volume",color:"var(--primary)",yAxisId:"left",format:"money"},{name:"unitsSold",label:"Units Sold",color:"#888",units:" units",yAxisId:"right",format:"integer"}];return React.useEffect(()=>{if(o||!t){f([]);return}let S=[];if(e==="week"){const R=new Map;t.forEach(C=>{var A;const E=((A=C.Day)==null?void 0:A.toString())||"";if(E.length===8){const M=parseInt(E.substring(0,4),10),I=parseInt(E.substring(4,6),10)-1,j=parseInt(E.substring(6,8),10),q=new Date(M,I,j),z=new Date(q);z.setDate(q.getDate()-q.getDay());const Q=`${z.getFullYear()}-${String(z.getMonth()+1).padStart(2,"0")}-${String(z.getDate()).padStart(2,"0")}`,V=R.get(Q)||{price:0,quantity:0};V.price+=C.ExtendedPrice||0,V.quantity+=C.Quantity||0,R.set(Q,V)}}),S=Array.from(R).sort(([C],[E])=>C.localeCompare(E)).map(([C,E])=>({date:`${C.substring(5,7)}/${C.substring(8,10)}`,dollarVolume:E.price,unitsSold:E.quantity}))}else{const R=new Date,C=R.getFullYear(),E=R.getMonth(),A=R.getDate(),M=`${C}-${(E+1).toString().padStart(2,"0")}`,I=Array.from({length:12},(q,z)=>{const Q=new Date(C,E-(11-z),1);return`${Q.getFullYear()}-${(Q.getMonth()+1).toString().padStart(2,"0")}`}),j=Object.fromEntries(I.map(q=>[q,{price:0,quantity:0}]));if(t.forEach(q=>{const z=String(q.Day??0);if(z.length!==8)return;const Q=`${z.substring(0,4)}-${z.substring(4,6)}`;j[Q]&&(j[Q].price+=q.ExtendedPrice??0,j[Q].quantity+=q.Quantity??0)}),S=I.map(q=>{const z=j[q],[Q,V]=q.split("-").map(Number);return{date:new Date(Q,V-1).toLocaleString("default",{month:"short",year:"numeric"}),dollarVolume:z.price,unitsSold:z.quantity}}),g){const q=j[M];if(q&&q.price>0&&A>0){const z=new Date(C,E+1,0).getDate();if(A<z){const Q=q.price/A,V=q.quantity/A,F=Q*z,te=V*z,ne=S[S.length-1];ne&&(ne.dollarVolume=F,ne.unitsSold=te)}}}}f(S)},[t,e,g,o]),o?jsxRuntime.jsx("div",{style:{height:n},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}):d.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:d,series:_,height:n,size:l}),l==="default"&&e==="month"&&jsxRuntime.jsxs("div",{className:"mt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{checked:g,onCheckedChange:b,id:"extrapolate-switch"}),jsxRuntime.jsx(Label$2,{htmlFor:"extrapolate-switch",children:"Extrapolate Current Month"})]}),g&&jsxRuntime.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["* Values for ",new Date().toLocaleString("default",{month:"long"})," are projected estimates."]})]})]})}function ManufacturerCard({manufacturer:t,link:e,linkNewTab:n=!0,actions:o,mainAction:l,loading:d=!1}){var S,R,C;if(d||!t)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 f=t.ManufacturerId||"N/A",g=[t.City,t.Province,t.Country].filter(Boolean),b=g.length>0?g.join(", "):"",_=((S=t.Tags)==null?void 0:S.split(",").map(E=>E.trim()).filter(Boolean))||[];return jsxRuntime.jsxs(Card,{className:"manufacturer-theme flex flex-col h-full",children:[jsxRuntime.jsx(reactRouterDom.Link,{to:e??"#",target:e&&n?"_blank":"_self",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("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx(PartnerLogo,{id:t.ManufacturerId,width:48,height:48})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:"Manufacturer"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:f})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:t.PublicName||"N/A"}),t.Name&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:t.Name}),b&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:b})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:t.SalesStatistics&&t.SalesStatistics.length>0&&jsxRuntime.jsx("div",{className:"h-16 w-24",children:jsxRuntime.jsx(SalesChart,{statistics:t.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:[(!!((R=t.Qualification)!=null&&R.QualificationId)&&((C=t.Qualification)==null?void 0:C.QualificationId)!=="Suspended"||!!t.OpenToWork||!!t.OnHold&&t.OnHold!==0||_.length>0)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(QualificationBadge,{qualification:t.Qualification??{}}),!!t.OpenToWork&&jsxRuntime.jsxs(Badge,{variant:"success",children:[jsxRuntime.jsx(HardHat,{className:"h-3 w-3 mr-1"}),"Open To Work"]}),!!t.OnHold&&t.OnHold!==0&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"}),_.map((E,A)=>jsxRuntime.jsx(Badge,{variant:"outline",children:E},A))]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[t.Phone&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`tel:${t.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:t.Phone})]}),t.PublicEmail&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`mailto:${t.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:t.PublicEmail})]}),t.Website&&jsxRuntime.jsxs(reactRouterDom.Link,{to:t.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:t.Website})]}),t.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:t.CurrencyCode})]})]})]}),t.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:t.SalesData.SalesYearToDay?formatMoney(t.SalesData.SalesYearToDay):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"3 mo."}),jsxRuntime.jsx("p",{children:t.SalesData.SalesLast3Months?formatMoney(t.SalesData.SalesLast3Months):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"30 days"}),jsxRuntime.jsx("p",{children:t.SalesData.SalesLast30Days?formatMoney(t.SalesData.SalesLast30Days):"—"})]})]})}),(o||l||t.PublicResourcesLink)&&jsxRuntime.jsxs(CardFooter,{className:"flex pt-2 gap-2 justify-between mt-auto",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[o&&o,t.PublicResourcesLink&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:t.PublicResourcesLink,target:"_blank",children:jsxRuntime.jsx(Button,{size:"icon",children:jsxRuntime.jsx(HardDriveDownload,{className:"h-4 w-4"})})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Public Resources Link"})})]})})]}),l&&jsxRuntime.jsx("div",{children:l})]})]})}function OrdersCard({applicationId:t,orders:e=null,loading:n=!1,title:o="Order Details"}){const l=React.useMemo(()=>[{accessorKey:"DocumentNumber",header:"Document Number",cell:({row:g})=>g.original.DocumentNumber?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${t}/Document/${g.original.DocumentNumber}`,className:"font-medium text-primary hover:underline",children:g.original.DocumentNumber})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for order ",g.original.DocumentNumber]})})]})}):"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentDate",header:"Document Date",cell:({row:g})=>formatYYYYMMDDIntToDateString(g.original.DocumentDate),enableSorting:!0,enableFiltering:!1},{accessorKey:"OrderNumber",header:"Order Number",cell:({row:g})=>g.original.OrderNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"PONumber",header:"PO Number",cell:({row:g})=>g.original.PONumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseCode",header:"Warehouse",cell:({row:g})=>g.original.WarehouseCode??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:g})=>g.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!1},{accessorKey:"ShipToName",header:"Name",cell:({row:g})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:g.original.ShipToName??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:g})=>g.original.UnitPrice?formatMoney(g.original.UnitPrice):"N/A",enableSorting:!0,enableFiltering:!1}],[t]),d=React.useMemo(()=>{const g={};if(e){const b=Array.from(new Set(e.map(E=>E.WarehouseCode).filter(E=>E!=null)));g.WarehouseCode=b;const _=Array.from(new Set(e.map(E=>E.ShipToName).filter(E=>E!=null)));g.ShipToName=_;const S=Array.from(new Set(e.map(E=>E.DocumentNumber).filter(E=>E!=null)));g.DocumentNumber=S;const R=Array.from(new Set(e.map(E=>E.OrderNumber).filter(E=>E!=null)));g.OrderNumber=R;const C=Array.from(new Set(e.map(E=>E.PONumber).filter(E=>E!=null)));g.PONumber=C}return g},[e]),f=e||[];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.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:o})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:l,data:f,uniqueValues:d})})]})}function ResellerOverview({appID:t,reseller:e,readonly:n,userEmail:o,isSuperAdmin:l,withoutReports:d=!1}){const{data:f,isLoading:g,isError:b}=useGetV4PartnerByApplicationIdAccountResellerQuery({applicationId:t??"",withSpecification:!0},{skip:!!e}),[_,S]=React.useState({publicInfo:{hasUnsavedChanges:!1}}),R=React.useCallback(()=>n?!1:_.publicInfo.hasUnsavedChanges,[n,_]),C=React.useCallback((q,z)=>{S(Q=>{var V;return((V=Q[q])==null?void 0:V.hasUnsavedChanges)!==z.hasUnsavedChanges?{...Q,[q]:z}:Q})},[]),{NavigationGuardDialog:E}=useRouterNavigationGuard(R),A=e??f,M=!n||!!(A!=null&&A.Statement)&&(A.Statement.Total??0)>0,I=(A==null?void 0:A.QualifiedManufacturers)??[],j=(A==null?void 0:A.Qualifications)??[];return jsxRuntime.jsxs("div",{className:"@container",children:[b?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:(A==null?void 0:A.FiscalYearMonthStart)||1,salesData:A==null?void 0:A.SalesData,isLoading:g}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @2xl:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:(A==null?void 0:A.SalesStatistics)??[],loading:g}),jsxRuntime.jsx(OrderCategories,{openOrders:(A==null?void 0:A.ActiveOrderDetails)??[],isLoading:g}),M&&jsxRuntime.jsx(BillingCard,{appID:t,reseller:A||{},withoutReports:d,isLoading:g,userEmail:o}),jsxRuntime.jsx(PublicInfo,{reseller:A||{},appID:t??"",isLoading:g,readonly:n,onUnsavedChanges:q=>C("publicInfo",{hasUnsavedChanges:q})}),jsxRuntime.jsx(AccountTier,{isSuperAdmin:l,readonly:n,reseller:A||{},appID:t??"",isLoading:g})]}),g||I.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 @2xl:grid-cols-2 gap-4",children:g?Array.from({length:2}).map((q,z)=>jsxRuntime.jsx(ManufacturerCard,{loading:!0},z)):I.map(q=>jsxRuntime.jsx(ManufacturerCard,{manufacturer:q,link:`https://dashboard.randmar.io/${t}/Partner/${q.ManufacturerId}`},q.ManufacturerId))})})]}):jsxRuntime.jsx(ResellerQualificationsCard,{qualifications:j}),jsxRuntime.jsx(OpportunitiesTable,{applicationId:t,opportunities:A==null?void 0:A.Opportunities,loading:g}),jsxRuntime.jsx(OrdersCard,{applicationId:t,title:"Active Orders",orders:A==null?void 0:A.ActiveOrderDetails,loading:g}),jsxRuntime.jsx(OrdersCard,{applicationId:t,title:"Completed Orders",orders:A==null?void 0:A.CompletedOrderDetails,loading:g}),jsxRuntime.jsx(ReturnsTable,{applicationId:t,returns:A==null?void 0:A.Returns,loading:g}),!d&&jsxRuntime.jsx(ReportsSection,{appID:t,userEmail:o,isLoading:g})]}),jsxRuntime.jsx(E,{})]})}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 text-destructive dark:border-destructive [&>svg]:text-destructive",success:"border-green-500/50 bg-green-50 text-green-700 dark:border-green-500 dark:bg-green-950 dark:text-green-400 [&>svg]:text-green-500",warning:"border-yellow-500/50 bg-yellow-50 text-yellow-700 dark:border-yellow-500 dark:bg-yellow-950 dark:text-yellow-400 [&>svg]:text-yellow-500",info:"border-blue-500/50 bg-blue-50 text-blue-700 dark:border-blue-500 dark:bg-blue-950 dark:text-blue-400 [&>svg]:text-blue-500"}},defaultVariants:{variant:"default"}}),Alert=React__namespace.forwardRef(({className:t,variant:e,...n},o)=>jsxRuntime.jsx("div",{ref:o,role:"alert",className:cn(alertVariants({variant:e}),t),...n}));Alert.displayName="Alert";const AlertTitle=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("h5",{ref:n,className:cn("mb-1 font-medium leading-none tracking-tight",t),...e}));AlertTitle.displayName="AlertTitle";const AlertDescription=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("text-sm [&_p]:leading-relaxed",t),...e}));AlertDescription.displayName="AlertDescription";/**
|
|
1109
|
+
$10 with opportunities under $1,000`:t==="D"?"$15 under $1,500":t==="E"?"Full shipping charges":t,getTermsText=t=>t==="STRIPE"?"Credit card payment":t==="NET30"?"Net 30 days":t,AccountTier=({isSuperAdmin:t,readonly:e,reseller:n,appID:o,isLoading:l})=>{const{toast:d}=useToast(),[f,g]=React.useState(!1),[b,_]=React.useState(""),[S,{isLoading:R}]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),C=Oe=>Oe&&{Starter:"starter","E-Commerce":"ecommerce",Commercial:"commercial",Basics:"cws",Novexco:"novexco","Jean Coutu":"jeancoutu",Exclusive:"exclusive"}[Oe]||"",E=Oe=>Oe&&{A:"free",B:"fixed",C:"dropshipped",D:"under1500",E:"fullcharges"}[Oe]||"",A=Oe=>Oe&&{1:"exclusive",2:"ecommerce",3:"commercial",4:"buyinggroup",5:"cost"}[Oe]||"",[M,I]=React.useState(C((n==null?void 0:n.Priority)??"")),[j,q]=React.useState(E((n==null?void 0:n.ShippingProfile)??"")),[z,Q]=React.useState(A(n==null?void 0:n.PriceProfile)),V=Oe=>({starter:"Starter",ecommerce:"E-Commerce",commercial:"Commercial",cws:"Basics",novexco:"Novexco",jeancoutu:"Jean Coutu",exclusive:"Exclusive"})[Oe]||Oe,F=Oe=>({free:"A",fixed:"B",dropshipped:"C",under1500:"D",fullcharges:"E"})[Oe]||Oe,te=Oe=>({exclusive:"1",ecommerce:"2",commercial:"3",buyinggroup:"4",cost:"5"})[Oe]||Oe;React.useEffect(()=>{I(C((n==null?void 0:n.Priority)??"")),q(E((n==null?void 0:n.ShippingProfile)??"")),Q(A(n==null?void 0:n.PriceProfile))},[n]);const ne=async(Oe,Fe,ze,$e)=>{try{(await S({applicationId:o,fieldName:Oe,newValue:Fe})).error?d({title:"Error",description:$e,variant:"destructive"}):d({title:"Success",description:ze,variant:"success"})}catch{d({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}},se=async Oe=>{I(Oe);const Fe=V(Oe);ne("Priority",Fe,`Priority updated to ${Fe}`,"Failed to update priority")},ge=async Oe=>{q(Oe);const Fe=F(Oe);ne("ShippingProfile",Fe,`Shipping profile updated to ${Fe}`,"Failed to update shipping profile")},oe=async Oe=>{Q(Oe);const Fe=te(Oe);ne("PriceProfile",Fe,`Pricing profile updated to ${Fe}`,"Failed to update pricing profile")},Ae=async()=>{try{const Oe=await S({applicationId:o,fieldName:"Tier",newValue:b});Oe.error?d({title:"Error",description:"Failed to update reseller",variant:"destructive"}):Oe.data?d({title:"Success",description:`Pricing Tier changed to ${b}`,variant:"success"}):d({title:"Considered",description:"Request being considered",variant:"success"})}catch{d({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}finally{g(!1),_("")}},je=[{name:"Terms",enabled:n.Priority==="Starter"},{name:"E-Commerce",enabled:n.Priority==="Commercial"},{name:"Commercial",enabled:n.Priority==="E-Commerce"},{name:"Exclusive",enabled:t}],Ne=Oe=>{_(Oe),g(!0)};return l?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(Oe=>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"})]})]},Oe))}),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-1xl font-bold",children:"Account Tier"}),jsxRuntime.jsx(Badge,{variant:"secondary",className:"bg-green-100 text-green-700 hover:bg-green-200 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==null?void 0: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-green-600"})]}),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,{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==null?void 0:n.Terms)||"")})]})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[!e&&jsxRuntime.jsx(Button,{variant:"outline",className:"flex-1",asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:"https://www.randmar.io/docs/overview/pricingTiers",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,{disabled:e,className:e?"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"}),je.map(Oe=>jsxRuntime.jsx(Button,{variant:"ghost",size:"sm",className:"w-full justify-start h-8",disabled:!Oe.enabled,onClick:()=>Ne(Oe.name),children:Oe.name},Oe.name))]})})]})]})]})]}),jsxRuntime.jsx(ChangePricingTierModal,{isLoading:R,open:f,setOpen:g,tier:b,onTierChange:Ae}),t&&!e&&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:M,onValueChange:se,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:"jeancoutu",label:"Jean Coutu"},{value:"exclusive",label:"Exclusive"}].map(Oe=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Oe.value,id:`priority-${Oe.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`priority-${Oe.value}`,className:"cursor-pointer text-xs",children:Oe.label})]},Oe.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:j,onValueChange:ge,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(Oe=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Oe.value,id:`shipping-${Oe.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`shipping-${Oe.value}`,className:"cursor-pointer text-xs",children:Oe.label})]},Oe.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:z,onValueChange:oe,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(Oe=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Oe.value,id:`pricing-${Oe.value}`,className:"h-6 w-6 scale-50 antialiased"}),jsxRuntime.jsx(Label$2,{htmlFor:`pricing-${Oe.value}`,className:"cursor-pointer text-xs",children:Oe.label})]},Oe.value))})]})]})})]})]})};function OrderCategories({openOrders:t=[],isLoading:e=!1}){const n=(t==null?void 0:t.filter(M=>M.DocumentType==="Order"))||[],o=(t==null?void 0:t.filter(M=>M.DocumentType==="Shipment"))||[],l=n.filter(M=>M.WarehouseCode!=="3PLE"),d=l.reduce((M,I)=>M+(I.Quantity??0),0),f=l.reduce((M,I)=>M+(I.ExtendedPrice??0),0),g=n.filter(M=>M.WarehouseCode==="3PLE"),b=g.reduce((M,I)=>M+(I.Quantity??0),0),_=g.reduce((M,I)=>M+(I.ExtendedPrice??0),0),S=o.reduce((M,I)=>M+(I.Quantity??0),0),R=o.reduce((M,I)=>M+(I.ExtendedPrice??0),0),C=d+b+S,E=f+_+R,A=[{name:"All",icon:Package,color:"bg-blue-500",orders:C,amount:E},{name:"Processing",icon:RefreshCcw,color:"bg-yellow-500",orders:d,amount:f},{name:"Shipped",icon:Truck,color:"bg-green-500",orders:S,amount:R},{name:"Delayed",icon:CircleAlert,color:"bg-red-500",orders:b,amount:_}];return e?jsxRuntime.jsxs(Card,{className:"w-full @md:col-span-2 @xl:col-span-1",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(M=>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-gray-200 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"})]})]})]})]})},M))})})]}):jsxRuntime.jsxs(Card,{className:"w-full @md:col-span-2 @xl:col-span-1",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Order Categories"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:A.map(M=>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:`${M.color} bg-opacity-60 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:M.name}),jsxRuntime.jsx("div",{className:`${M.color} bg-opacity-90 p-2 rounded-full`,children:jsxRuntime.jsx(M.icon,{className:"size-4 shrink-0 text-white"})})]}),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:M.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:M.amount,style:"currency",currency:"CAD",currencyDisplay:"symbol"})})]})]})]})]})},M.name))})})]})}function ReportsSection({isLoading:t,userEmail:e,appID:n}){const{toast:o}=useToast(),[l,{isLoading:d}]=usePostV4ResellerByRouteResellerIdReportWalmartTrackingFileEmailMutation(),[f,{isLoading:g}]=usePostV4ResellerByRouteResellerIdReportAmazonTrackingFileEmailMutation(),[b,{isLoading:_}]=usePostV4ResellerByRouteResellerIdReportOpenOrdersEmailMutation(),[S,{isLoading:R}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[C,{isLoading:E}]=usePostV4ResellerByRouteResellerIdReportInvoicesEmailMutation(),[A,{isLoading:M}]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),[I,j]=React.useState(null),[q,z]=React.useState(e),[Q,V]=React.useState(!1),F=[{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}]}],te=async ge=>{j(ge),V(!0)},ne=async()=>{if(!(!I||!n))try{switch(I.id){case"Products":await S({routeResellerId:n,emailAddress:q}).unwrap();break;case"AmazonTrackingFile":await f({routeResellerId:n,emailAddress:q}).unwrap();break;case"WalmartTrackingFile":await l({routeResellerId:n,emailAddress:q}).unwrap();break;case"OpenOrders":await b({routeResellerId:n,emailAddress:q}).unwrap();break;case"Invoices":await C({routeResellerId:n,emailAddress:q}).unwrap();break;case"Statement":await A({routeResellerId:n,emailAddress:q}).unwrap();break;default:throw new Error("invalid report id")}o({title:"Report requested",description:`The ${I.title} will be sent to ${q} shortly.`,variant:"success"}),V(!1)}catch(ge){console.error("Error requesting report:",ge),o({title:"Error",description:"Failed to request report. Please try again.",variant:"destructive"})}},se=_||R||g||d||M||E;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:t?jsxRuntime.jsx(jsxRuntime.Fragment,{children:[1,2,3].map(ge=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-48"}),[1,2].map(oe=>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"})]},oe))]},ge))}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:F.map(ge=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:ge.name}),ge.reports.map(oe=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg hover:bg-gray-100 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-2 rounded-full",children:jsxRuntime.jsx(oe.icon,{className:"h-5 w-5 text-primary"})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("h4",{className:"font-semibold text-sm",children:oe.title}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:oe.description})]}),jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",className:"flex items-center gap-1",onClick:()=>te(oe),children:[jsxRuntime.jsx(Download,{className:"h-4 w-4"}),"Request"]})]},oe.id))]},ge.name))})}),jsxRuntime.jsx(Dialog,{open:Q,onOpenChange:V,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsxs(DialogTitle,{children:["Request ",I==null?void 0:I.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:q,onChange:ge=>z(ge.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,{variant:"outline",onClick:()=>V(!1),children:"Cancel"}),jsxRuntime.jsx(Button,{onClick:ne,disabled:!q||se,children:se?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}const badgeVariants=cva("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus: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-input hover:bg-accent hover:text-accent-foreground",success:"bg-green-600 text-white hover:bg-green-700",warning:"bg-yellow-500 text-white hover:bg-yellow-600",info:"bg-blue-500 text-white hover:bg-blue-600",ghost:"bg-background hover:bg-accent hover:text-accent-foreground",randmarRed:"bg-randmar-red text-white hover:bg-randmar-red/80",randmarBlue:"bg-randmar-blue text-white hover:bg-randmar-blue/80",randmarPurple:"bg-randmar-purple text-white hover:bg-randmar-purple/80",randmarGreen:"bg-randmar-green text-black hover:bg-randmar-green/80",randmarBlack:"bg-randmar-black text-white hover:bg-randmar-black/80",randmarYellow:"bg-randmar-yellow text-black hover:bg-randmar-yellow/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:t,variant:e,size:n,icon:o,children:l,...d},f)=>jsxRuntime.jsxs("div",{ref:f,className:cn(badgeVariants({variant:e,size:n}),t),...d,children:[o&&jsxRuntime.jsx("span",{className:"mr-1",children:o}),l]}));Badge.displayName="Badge";function QualificationBadge({qualification:t}){return!t.QualificationId||t.QualificationId==="Suspended"?null:t.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$1,{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:t.DefaultOpportunityNumber?"pr-1":"",children:[jsxRuntime.jsx(BadgeCheck,{className:"h-3 w-3 mr-1"}),t.QualificationId,t.DefaultOpportunityNumber&&jsxRuntime.jsx(Badge,{variant:"secondary",size:"sm",className:"ml-1",children:t.DefaultOpportunityNumber})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})})}function SalesChart({statistics:t,mode:e="month",chartHeight:n,loading:o=!1,size:l="default"}){const[d,f]=React.useState([]),[g,b]=React.useState(!1),_=[{name:"dollarVolume",label:"Dollar Volume",color:"var(--primary)",yAxisId:"left",format:"money"},{name:"unitsSold",label:"Units Sold",color:"#888",units:" units",yAxisId:"right",format:"integer"}];return React.useEffect(()=>{if(o||!t){f([]);return}let S=[];if(e==="week"){const R=new Map;t.forEach(C=>{var A;const E=((A=C.Day)==null?void 0:A.toString())||"";if(E.length===8){const M=parseInt(E.substring(0,4),10),I=parseInt(E.substring(4,6),10)-1,j=parseInt(E.substring(6,8),10),q=new Date(M,I,j),z=new Date(q);z.setDate(q.getDate()-q.getDay());const Q=`${z.getFullYear()}-${String(z.getMonth()+1).padStart(2,"0")}-${String(z.getDate()).padStart(2,"0")}`,V=R.get(Q)||{price:0,quantity:0};V.price+=C.ExtendedPrice||0,V.quantity+=C.Quantity||0,R.set(Q,V)}}),S=Array.from(R).sort(([C],[E])=>C.localeCompare(E)).map(([C,E])=>({date:`${C.substring(5,7)}/${C.substring(8,10)}`,dollarVolume:E.price,unitsSold:E.quantity}))}else{const R=new Date,C=R.getFullYear(),E=R.getMonth(),A=R.getDate(),M=`${C}-${(E+1).toString().padStart(2,"0")}`,I=Array.from({length:12},(q,z)=>{const Q=new Date(C,E-(11-z),1);return`${Q.getFullYear()}-${(Q.getMonth()+1).toString().padStart(2,"0")}`}),j=Object.fromEntries(I.map(q=>[q,{price:0,quantity:0}]));if(t.forEach(q=>{const z=String(q.Day??0);if(z.length!==8)return;const Q=`${z.substring(0,4)}-${z.substring(4,6)}`;j[Q]&&(j[Q].price+=q.ExtendedPrice??0,j[Q].quantity+=q.Quantity??0)}),S=I.map(q=>{const z=j[q],[Q,V]=q.split("-").map(Number);return{date:new Date(Q,V-1).toLocaleString("default",{month:"short",year:"numeric"}),dollarVolume:z.price,unitsSold:z.quantity}}),g){const q=j[M];if(q&&q.price>0&&A>0){const z=new Date(C,E+1,0).getDate();if(A<z){const Q=q.price/A,V=q.quantity/A,F=Q*z,te=V*z,ne=S[S.length-1];ne&&(ne.dollarVolume=F,ne.unitsSold=te)}}}}f(S)},[t,e,g,o]),o?jsxRuntime.jsx("div",{style:{height:n},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}):d.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:d,series:_,height:n,size:l}),l==="default"&&e==="month"&&jsxRuntime.jsxs("div",{className:"mt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{checked:g,onCheckedChange:b,id:"extrapolate-switch"}),jsxRuntime.jsx(Label$2,{htmlFor:"extrapolate-switch",children:"Extrapolate Current Month"})]}),g&&jsxRuntime.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["* Values for ",new Date().toLocaleString("default",{month:"long"})," are projected estimates."]})]})]})}function ManufacturerCard({manufacturer:t,link:e,linkNewTab:n=!0,actions:o,mainAction:l,loading:d=!1}){var S,R,C;if(d||!t)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 f=t.ManufacturerId||"N/A",g=[t.City,t.Province,t.Country].filter(Boolean),b=g.length>0?g.join(", "):"",_=((S=t.Tags)==null?void 0:S.split(",").map(E=>E.trim()).filter(Boolean))||[];return jsxRuntime.jsxs(Card,{className:"manufacturer-theme flex flex-col h-full",children:[jsxRuntime.jsx(reactRouterDom.Link,{to:e??"#",target:e&&n?"_blank":"_self",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("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx(PartnerLogo,{id:t.ManufacturerId,width:48,height:48},`partner_logo_${t.ManufacturerId}`)}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:"Manufacturer"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:f})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:t.PublicName||"N/A"}),t.Name&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:t.Name}),b&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:b})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:t.SalesStatistics&&t.SalesStatistics.length>0&&jsxRuntime.jsx("div",{className:"h-16 w-24",children:jsxRuntime.jsx(SalesChart,{statistics:t.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:[(!!((R=t.Qualification)!=null&&R.QualificationId)&&((C=t.Qualification)==null?void 0:C.QualificationId)!=="Suspended"||!!t.OpenToWork||!!t.OnHold&&t.OnHold!==0||_.length>0)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(QualificationBadge,{qualification:t.Qualification??{}}),!!t.OpenToWork&&jsxRuntime.jsxs(Badge,{variant:"success",children:[jsxRuntime.jsx(HardHat,{className:"h-3 w-3 mr-1"}),"Open To Work"]}),!!t.OnHold&&t.OnHold!==0&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"}),_.map((E,A)=>jsxRuntime.jsx(Badge,{variant:"outline",children:E},A))]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[t.Phone&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`tel:${t.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:t.Phone})]}),t.PublicEmail&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`mailto:${t.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:t.PublicEmail})]}),t.Website&&jsxRuntime.jsxs(reactRouterDom.Link,{to:t.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:t.Website})]}),t.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:t.CurrencyCode})]})]})]}),t.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:t.SalesData.SalesYearToDay?formatMoney(t.SalesData.SalesYearToDay):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"3 mo."}),jsxRuntime.jsx("p",{children:t.SalesData.SalesLast3Months?formatMoney(t.SalesData.SalesLast3Months):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"30 days"}),jsxRuntime.jsx("p",{children:t.SalesData.SalesLast30Days?formatMoney(t.SalesData.SalesLast30Days):"—"})]})]})}),(o||l||t.PublicResourcesLink)&&jsxRuntime.jsxs(CardFooter,{className:"flex pt-2 gap-2 justify-between mt-auto",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[o&&o,t.PublicResourcesLink&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:t.PublicResourcesLink,target:"_blank",children:jsxRuntime.jsx(Button,{size:"icon",children:jsxRuntime.jsx(HardDriveDownload,{className:"h-4 w-4"})})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Public Resources Link"})})]})})]}),l&&jsxRuntime.jsx("div",{children:l})]})]})}function OrdersCard({applicationId:t,orders:e=null,loading:n=!1,title:o="Order Details"}){const l=React.useMemo(()=>[{accessorKey:"DocumentNumber",header:"Document Number",cell:({row:g})=>g.original.DocumentNumber?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${t}/Document/${g.original.DocumentNumber}`,className:"font-medium text-primary hover:underline",children:g.original.DocumentNumber})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for order ",g.original.DocumentNumber]})})]})}):"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentDate",header:"Document Date",cell:({row:g})=>formatYYYYMMDDIntToDateString(g.original.DocumentDate),enableSorting:!0,enableFiltering:!1},{accessorKey:"OrderNumber",header:"Order Number",cell:({row:g})=>g.original.OrderNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"PONumber",header:"PO Number",cell:({row:g})=>g.original.PONumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseCode",header:"Warehouse",cell:({row:g})=>g.original.WarehouseCode??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:g})=>g.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!1},{accessorKey:"ShipToName",header:"Name",cell:({row:g})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:g.original.ShipToName??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:g})=>g.original.UnitPrice?formatMoney(g.original.UnitPrice):"N/A",enableSorting:!0,enableFiltering:!1}],[t]),d=React.useMemo(()=>{const g={};if(e){const b=Array.from(new Set(e.map(E=>E.WarehouseCode).filter(E=>E!=null)));g.WarehouseCode=b;const _=Array.from(new Set(e.map(E=>E.ShipToName).filter(E=>E!=null)));g.ShipToName=_;const S=Array.from(new Set(e.map(E=>E.DocumentNumber).filter(E=>E!=null)));g.DocumentNumber=S;const R=Array.from(new Set(e.map(E=>E.OrderNumber).filter(E=>E!=null)));g.OrderNumber=R;const C=Array.from(new Set(e.map(E=>E.PONumber).filter(E=>E!=null)));g.PONumber=C}return g},[e]),f=e||[];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.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:o})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:l,data:f,uniqueValues:d})})]})}function ResellerOverview({appID:t,reseller:e,readonly:n,userEmail:o,isSuperAdmin:l,withoutReports:d=!1}){const{data:f,isLoading:g,isError:b}=useGetV4PartnerByApplicationIdAccountResellerQuery({applicationId:t??"",withSpecification:!0},{skip:!!e}),[_,S]=React.useState({publicInfo:{hasUnsavedChanges:!1}}),R=React.useCallback(()=>n?!1:_.publicInfo.hasUnsavedChanges,[n,_]),C=React.useCallback((q,z)=>{S(Q=>{var V;return((V=Q[q])==null?void 0:V.hasUnsavedChanges)!==z.hasUnsavedChanges?{...Q,[q]:z}:Q})},[]),{NavigationGuardDialog:E}=useRouterNavigationGuard(R),A=e??f,M=!n||!!(A!=null&&A.Statement)&&(A.Statement.Total??0)>0,I=(A==null?void 0:A.QualifiedManufacturers)??[],j=(A==null?void 0:A.Qualifications)??[];return jsxRuntime.jsxs("div",{className:"@container",children:[b?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:(A==null?void 0:A.FiscalYearMonthStart)||1,salesData:A==null?void 0:A.SalesData,isLoading:g}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @2xl:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:(A==null?void 0:A.SalesStatistics)??[],loading:g}),jsxRuntime.jsx(OrderCategories,{openOrders:(A==null?void 0:A.ActiveOrderDetails)??[],isLoading:g}),M&&jsxRuntime.jsx(BillingCard,{appID:t,reseller:A||{},withoutReports:d,isLoading:g,userEmail:o}),jsxRuntime.jsx(PublicInfo,{reseller:A||{},appID:t??"",isLoading:g,readonly:n,onUnsavedChanges:q=>C("publicInfo",{hasUnsavedChanges:q})}),jsxRuntime.jsx(AccountTier,{isSuperAdmin:l,readonly:n,reseller:A||{},appID:t??"",isLoading:g})]}),g||I.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 @2xl:grid-cols-2 gap-4",children:g?Array.from({length:2}).map((q,z)=>jsxRuntime.jsx(ManufacturerCard,{loading:!0},z)):I.map(q=>jsxRuntime.jsx(ManufacturerCard,{manufacturer:q,link:`https://dashboard.randmar.io/${t}/Partner/${q.ManufacturerId}`},q.ManufacturerId))})})]}):jsxRuntime.jsx(ResellerQualificationsCard,{qualifications:j}),jsxRuntime.jsx(OpportunitiesTable,{applicationId:t,opportunities:A==null?void 0:A.Opportunities,loading:g}),jsxRuntime.jsx(OrdersCard,{applicationId:t,title:"Active Orders",orders:A==null?void 0:A.ActiveOrderDetails,loading:g}),jsxRuntime.jsx(OrdersCard,{applicationId:t,title:"Completed Orders",orders:A==null?void 0:A.CompletedOrderDetails,loading:g}),jsxRuntime.jsx(ReturnsTable,{applicationId:t,returns:A==null?void 0:A.Returns,loading:g}),!d&&jsxRuntime.jsx(ReportsSection,{appID:t,userEmail:o,isLoading:g})]}),jsxRuntime.jsx(E,{})]})}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 text-destructive dark:border-destructive [&>svg]:text-destructive",success:"border-green-500/50 bg-green-50 text-green-700 dark:border-green-500 dark:bg-green-950 dark:text-green-400 [&>svg]:text-green-500",warning:"border-yellow-500/50 bg-yellow-50 text-yellow-700 dark:border-yellow-500 dark:bg-yellow-950 dark:text-yellow-400 [&>svg]:text-yellow-500",info:"border-blue-500/50 bg-blue-50 text-blue-700 dark:border-blue-500 dark:bg-blue-950 dark:text-blue-400 [&>svg]:text-blue-500"}},defaultVariants:{variant:"default"}}),Alert=React__namespace.forwardRef(({className:t,variant:e,...n},o)=>jsxRuntime.jsx("div",{ref:o,role:"alert",className:cn(alertVariants({variant:e}),t),...n}));Alert.displayName="Alert";const AlertTitle=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("h5",{ref:n,className:cn("mb-1 font-medium leading-none tracking-tight",t),...e}));AlertTitle.displayName="AlertTitle";const AlertDescription=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("text-sm [&_p]:leading-relaxed",t),...e}));AlertDescription.displayName="AlertDescription";/**
|
|
1110
1110
|
* table-core
|
|
1111
1111
|
*
|
|
1112
1112
|
* Copyright (c) TanStack
|
|
@@ -1127,7 +1127,7 @@ $10 with opportunities under $1,000`:t==="D"?"$15 under $1,500":t==="E"?"Full sh
|
|
|
1127
1127
|
* LICENSE.md file in the root directory of this source tree.
|
|
1128
1128
|
*
|
|
1129
1129
|
* @license MIT
|
|
1130
|
-
*/function flexRender(t,e){return t?isReactComponent(t)?React__namespace.createElement(t,e):t:null}function isReactComponent(t){return isClassComponent(t)||typeof t=="function"||isExoticComponent(t)}function isClassComponent(t){return typeof t=="function"&&(()=>{const e=Object.getPrototypeOf(t);return e.prototype&&e.prototype.isReactComponent})()}function isExoticComponent(t){return typeof t=="object"&&typeof t.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(t.$$typeof.description)}function useReactTable(t){const e={state:{},onStateChange:()=>{},renderFallbackValue:null,...t},[n]=React__namespace.useState(()=>({current:createTable(e)})),[o,l]=React__namespace.useState(()=>n.current.initialState);return n.current.setOptions(d=>({...d,...t,state:{...o,...t.state},onStateChange:f=>{l(f),t.onStateChange==null||t.onStateChange(f)}})),n.current}function DataTable({columns:t,data:e,uniqueValues:n,tableClass:o,loading:l}){var M;const[d,f]=React.useState([]),[g,b]=React.useState([]),[_,S]=React.useState({pageIndex:0,pageSize:10}),[R,C]=React.useState(null),E=useReactTable({data:l?[]:e,columns:t,getCoreRowModel:getCoreRowModel(),onSortingChange:f,getSortedRowModel:getSortedRowModel(),onColumnFiltersChange:b,getFilteredRowModel:getFilteredRowModel(),getPaginationRowModel:getPaginationRowModel(),onPaginationChange:S,state:{sorting:d,columnFilters:g,pagination:_},manualPagination:l,manualSorting:l,manualFiltering:l}),A=(I,j)=>{I.toggleSorting(j),C(null)};return l?jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("div",{className:`rounded-md border ${o??""}`,children:jsxRuntime.jsxs(Table,{children:[jsxRuntime.jsx(TableHeader,{children:jsxRuntime.jsx(TableRow,{children:t.map((I,j)=>jsxRuntime.jsx(TableHead,{children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-full"})},`skeleton-header-${j}`))})}),jsxRuntime.jsx(TableBody,{children:Array.from({length:_.pageSize}).map((I,j)=>jsxRuntime.jsx(TableRow,{children:t.map((q,z)=>jsxRuntime.jsx(TableCell,{children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-full"})},`skeleton-cell-${j}-${z}`))},`skeleton-row-${j}`))})]})}),jsxRuntime.jsxs("div",{className:"flex items-center 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:"space-y-4",children:[jsxRuntime.jsxs(ScrollArea,{className:`rounded-md border ${o??""}`,children:[jsxRuntime.jsxs(Table,{children:[jsxRuntime.jsx(TableHeader,{children:E.getHeaderGroups().map(I=>jsxRuntime.jsx(TableRow,{children:I.headers.map(j=>{var q;return jsxRuntime.jsx(TableHead,{children:j.isPlaceholder?null:j.column.getCanSort()||j.column.getCanFilter()?jsxRuntime.jsxs(Popover,{open:R===j.id,onOpenChange:z=>C(z?j.id:null),children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{variant:"ghost",className:"pl-0",children:[flexRender(j.column.columnDef.header,j.getContext()),j.column.getIsFiltered()?jsxRuntime.jsx(Filter,{className:"ml-2 h-4 w-4"}):j.column.getIsSorted()==="asc"?jsxRuntime.jsx(ArrowUp,{className:"ml-2 h-4 w-4"}):j.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:[j.column.getCanSort()&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button,{variant:"ghost",className:"w-full justify-start",onClick:()=>A(j.column,!1),children:[jsxRuntime.jsx(ArrowUp,{className:"mr-2 h-4 w-4"}),"Sort Ascending"]}),jsxRuntime.jsxs(Button,{variant:"ghost",className:"w-full justify-start",onClick:()=>A(j.column,!0),children:[jsxRuntime.jsx(ArrowDown,{className:"mr-2 h-4 w-4"}),"Sort Descending"]})]}),j.column.getCanFilter()&&jsxRuntime.jsx("div",{className:"px-2 py-1",children:n[j.column.id]?jsxRuntime.jsxs(Select,{onValueChange:z=>j.column.setFilterValue(z==="all"?void 0:[z]),children:[jsxRuntime.jsx(SelectTrigger,{children:jsxRuntime.jsx(SelectValue,{placeholder:`Filter ${j.column.columnDef.header}...`})}),jsxRuntime.jsxs(SelectContent,{children:[jsxRuntime.jsx(SelectItem,{value:"all",children:"All"}),(q=n[j.column.id])==null?void 0:q.map(z=>jsxRuntime.jsx(SelectItem,{value:z||"empty",children:z||"(Empty)"},z))]})]}):jsxRuntime.jsx(Input,{placeholder:`Filter ${j.column.columnDef.header}...`,value:j.column.getFilterValue()??"",onChange:z=>j.column.setFilterValue(z.target.value),className:"w-full"})})]})})]}):jsxRuntime.jsx("div",{className:"py-2 px-4",children:flexRender(j.column.columnDef.header,j.getContext())})},j.id)})},I.id))}),jsxRuntime.jsx(TableBody,{children:(M=E.getRowModel().rows)!=null&&M.length?E.getRowModel().rows.map(I=>jsxRuntime.jsx(TableRow,{"data-state":I.getIsSelected()&&"selected",children:I.getVisibleCells().map(j=>jsxRuntime.jsx(TableCell,{children:flexRender(j.column.columnDef.cell,j.getContext())},j.id))},I.id)):jsxRuntime.jsx(TableRow,{children:jsxRuntime.jsx(TableCell,{colSpan:t.length,className:"h-24 text-center",children:"No results."})})})]}),jsxRuntime.jsx(ScrollBar,{orientation:"horizontal"})]}),jsxRuntime.jsxs("div",{className:"flex items-center 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,{value:`${E.getState().pagination.pageSize}`,onValueChange:I=>{E.setPageSize(Number(I))},children:[jsxRuntime.jsx(SelectTrigger,{className:"h-8 w-[70px]",children:jsxRuntime.jsx(SelectValue,{asChild:!0,children:jsxRuntime.jsx("span",{children:E.getState().pagination.pageSize})})}),jsxRuntime.jsx(SelectContent,{side:"top",children:[10,20,30,40,50].map(I=>jsxRuntime.jsx(SelectItem,{value:`${I}`,children:jsxRuntime.jsx("span",{children:I})},I))})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsxs(Button,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>E.setPageIndex(0),disabled:!E.getCanPreviousPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to first page"}),jsxRuntime.jsx(ChevronsLeft,{className:"h-4 w-4"})]}),jsxRuntime.jsxs(Button,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>E.previousPage(),disabled:!E.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:E.getState().pagination.pageIndex+1}),jsxRuntime.jsx("p",{className:"text-sm font-medium",children:"of"}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:E.getPageCount()})]}),jsxRuntime.jsxs(Button,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>E.nextPage(),disabled:!E.getCanNextPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to next page"}),jsxRuntime.jsx(ChevronRight,{className:"h-4 w-4"})]}),jsxRuntime.jsxs(Button,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>E.setPageIndex(E.getPageCount()-1),disabled:!E.getCanNextPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to last page"}),jsxRuntime.jsx(ChevronsRight,{className:"h-4 w-4"})]})]})]})]})}function PartnerCard({account:t,action:e,loading:n=!1,className:o,withAbout:l=!1,withVoice:d=!0}){const[f,g]=React.useState(!1),[b,_]=React.useState(!0),[S,R]=React.useState(null),[C,E]=React.useState(!1),A=React.useMemo(()=>t!=null&&t.ApplicationId?{videoUrl:`https://api.randmar.io/V4/Partner/${t.ApplicationId}/Account/Video`,videoExistsUrl:`https://api.randmar.io/V4/Partner/${t.ApplicationId}/Account/Video/Exists`}:null,[t==null?void 0:t.ApplicationId]);React.useEffect(()=>{if(!A||n)return;R(null);const I=async()=>{try{const q=await fetch(A.videoExistsUrl);if(q.ok){const z=await q.text();g(z.toLowerCase()==="true")}else throw new Error(`Failed to check video: ${q.status}`)}catch(q){console.error("Failed to check if video exists:",q),g(!1)}};(async()=>{I()})()},[A,n]);const M=()=>{_(!1)};return n||!t?jsxRuntime.jsxs(Card,{className:`flex flex-col h-full ${o}`,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"})]}),l&&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"})]}),d&&jsxRuntime.jsx("div",{className:"p-3 bg-slate-50 rounded-md",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @lg:grid-cols-3 gap-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]})]})})]})}),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 ${o}`,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("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx(PartnerLogo,{id:t.ApplicationId,width:64,height:64})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:"Partner"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:t.ApplicationId})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:t.PublicName||"N/A"})]})]})}),jsxRuntime.jsxs(CardContent,{className:"pb-2 flex-grow",children:[S&&jsxRuntime.jsx("div",{className:"text-red-500 mb-4 text-sm",role:"alert",children:S}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[(t.IsManufacturer||t.IsReseller||t.IsSalesAgency)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.IsManufacturer&&jsxRuntime.jsx(Badge,{className:"manufacturer-theme",children:"Manufacturer"}),t.IsReseller&&jsxRuntime.jsx(Badge,{className:"reseller-theme",children:"Reseller"}),t.IsSalesAgency&&jsxRuntime.jsx(Badge,{children:"Agency"})]}),l&&t.About&&jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:t.About??""}}),d&&jsxRuntime.jsx("div",{className:"p-3 bg-slate-50 rounded-md",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @lg:grid-cols-3 gap-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Voice Name"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.VoiceName??"Regular"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Voice Style"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.VoiceStyle??"Regular"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Scene Name"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.SceneName??"N/A"})]})]})})]})]}),jsxRuntime.jsxs(CardFooter,{className:"px-6 py-4 flex justify-between gap-2 mt-auto",children:[f&&A?jsxRuntime.jsxs(Dialog,{open:C,onOpenChange:E,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{variant:"outline",className:"flex items-center gap-2",children:[jsxRuntime.jsx(Video,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:"Watch Video"})]})}),jsxRuntime.jsxs(DialogContent,{className:"@sm:max-w-[360px]",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsxs(DialogTitle,{children:[t.PublicName," Video"]})}),jsxRuntime.jsxs("div",{className:"w-full h-[640px] rounded-md overflow-hidden",children:[b&&jsxRuntime.jsx(Skeleton,{className:"w-full h-full"}),jsxRuntime.jsx("video",{src:A.videoUrl,controls:!0,preload:"auto",playsInline:!0,autoPlay:!0,"aria-label":`Video for ${t.PublicName}`,className:`w-full h-full object-cover ${b?"invisible":"visible"}`,style:{objectPosition:"center",imageRendering:"auto"},onLoadedData:M,onError:()=>_(!1)})]})]})]}):jsxRuntime.jsx("div",{}),e||jsxRuntime.jsxs(Button,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4"}),"Go to Partner Dashboard"]})]})]})}function ResellerCard({reseller:t,link:e,linkNewTab:n=!0,actions:o,mainAction:l,loading:d=!1}){var _,S;if(d||!t)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 f=t.ResellerId||"N/A",g=[t.City,t.Province,t.Country].filter(Boolean),b=g.length>0?g.join(", "):"Location not provided";return jsxRuntime.jsxs(Card,{className:"reseller-theme flex flex-col h-full",children:[jsxRuntime.jsx(reactRouterDom.Link,{to:e??"#",target:e&&n?"_blank":"_self",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("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx(PartnerLogo,{id:t.ResellerId,width:48,height:48})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:"Reseller"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:f})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:t.PublicName||"N/A"}),t.Name&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:t.Name}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:b})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:t.SalesStatistics&&t.SalesStatistics.length>0&&jsxRuntime.jsx("div",{className:"h-16 w-24",children:jsxRuntime.jsx(SalesChart,{statistics:t.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:[(!!((_=t.Qualification)!=null&&_.QualificationId)&&((S=t.Qualification)==null?void 0:S.QualificationId)!=="Suspended"||!!t.OnHold&&t.OnHold!==0)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(QualificationBadge,{qualification:t.Qualification??{}}),!!t.OnHold&&t.OnHold!==0&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[t.Phone&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`tel:${t.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:t.Phone})]}),t.PublicEmail&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`mailto:${t.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:t.PublicEmail})]}),t.Website&&jsxRuntime.jsxs(reactRouterDom.Link,{to:t.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:t.Website})]}),t.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:t.CurrencyCode})]})]})]}),(t==null?void 0:t.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:t!=null&&t.SalesData.SalesYearToDay?formatMoney(t==null?void 0:t.SalesData.SalesYearToDay):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"3 mo."}),jsxRuntime.jsx("p",{children:t!=null&&t.SalesData.SalesLast3Months?formatMoney(t==null?void 0:t.SalesData.SalesLast3Months):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"30 days"}),jsxRuntime.jsx("p",{children:t!=null&&t.SalesData.SalesLast30Days?formatMoney(t==null?void 0:t.SalesData.SalesLast30Days):"—"})]})]})}),(o||l)&&jsxRuntime.jsxs(CardFooter,{className:"flex pt-2 gap-2 justify-between mt-auto",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:o&&o}),l&&jsxRuntime.jsx("div",{children:l})]})]})}const Table=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("div",{className:"relative w-full overflow-auto",children:jsxRuntime.jsx("table",{ref:n,className:cn("w-full caption-bottom text-sm",t),...e})}));Table.displayName="Table";const TableHeader=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("thead",{ref:n,className:cn("[&_tr]:border-b",t),...e}));TableHeader.displayName="TableHeader";const TableBody=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("tbody",{ref:n,className:cn("[&_tr:last-child]:border-0",t),...e}));TableBody.displayName="TableBody";const TableFooter=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("tfoot",{ref:n,className:cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...e}));TableFooter.displayName="TableFooter";const TableRow=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("tr",{ref:n,className:cn("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...e}));TableRow.displayName="TableRow";const TableHead=React__namespace.forwardRef(({className:t,...e},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]",t),...e,children:React__namespace.isValidElement(e.children)&&e.children.type==="span"?e.children:jsxRuntime.jsx("span",{children:e.children})}));TableHead.displayName="TableHead";const TableCell=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("td",{ref:n,className:cn("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...e,children:React__namespace.isValidElement(e.children)&&e.children.type==="span"?e.children:jsxRuntime.jsx("span",{children:e.children})}));TableCell.displayName="TableCell";const TableCaption=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("caption",{ref:n,className:cn("mt-4 text-sm text-muted-foreground",t),...e}));TableCaption.displayName="TableCaption";const Topbar=React.forwardRef(({onSignOut:t,handleValidSearch:e,rightMenu:n,searchPlaceholder:o},l)=>{const[d,f]=React.useState(""),g=reactRouterDom.useLocation(),{toast:b}=useToast();React.useEffect(()=>{const C=new URLSearchParams(g.search).get("q");C&&f(C)},[g.search]);const _=()=>{const R=d.trim();if(!R||R.length<2){b({title:"Enter more characters to search",description:"At least 2 characters are needed to search products.",variant:"destructive",duration:5e3});return}e(R)},S=R=>{R.key==="Enter"&&_()};return jsxRuntime.jsxs("header",{className:"flex h-16 items-center gap-4 border-b sidebar-foreground bg-sidebar px-6 fixed top-0 right-0 z-50 lg:left-64 left-0 border-sidebar-border",children:[jsxRuntime.jsx(SidebarTrigger,{className:"lg:hidden",children:jsxRuntime.jsx(Menu$1,{className:"h-6 w-6"})}),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-2 top-1/2 -translate-y-1/2",onClick:_,"aria-label":"Search",children:jsxRuntime.jsx(Search,{className:"h-4 w-4 text-muted-foreground"})}),jsxRuntime.jsx(Input,{placeholder:o??"Search...",className:"w-full pl-8 bg-white text-black",value:d,onChange:R=>f(R.target.value),onKeyDown:S,ref:l},"topbar-search")]})})}),n||jsxRuntime.jsx(jsxRuntime.Fragment,{}),t&&jsxRuntime.jsx("div",{className:"flex items-center gap-4",children:jsxRuntime.jsxs(Button,{variant:"ghost",size:"icon",className:"h-9 w-9",onClick:t,children:[jsxRuntime.jsx(LogOut,{className:"h-4 w-4 text-sidebar-foreground"}),jsxRuntime.jsx("span",{className:"sr-only",children:"Sign out"})]})})]})});Topbar.displayName="Topbar";function ActiveOrdersCard({orders:t,loading:e=!1}){const n=React.useMemo(()=>{if(!t||t.length===0)return{all:{orders:0,amount:0},processing:{orders:0,amount:0},shipped:{orders:0,amount:0},delayed:{orders:0,amount:0}};const l=t.filter(I=>I.DocumentType==="Order"),d=t.filter(I=>I.DocumentType==="Shipment"),f=l.filter(I=>I.WarehouseCode!=="3PLE"),g=f.reduce((I,j)=>I+(j.Quantity||0),0),b=f.reduce((I,j)=>I+(j.ExtendedPrice||0),0),_=l.filter(I=>I.WarehouseCode==="3PLE"),S=_.reduce((I,j)=>I+(j.Quantity||0),0),R=_.reduce((I,j)=>I+(j.ExtendedPrice||0),0),C=d.length,E=d.reduce((I,j)=>I+(j.ExtendedPrice||0),0),A=g+S+C,M=b+R+E;return{all:{orders:A,amount:M},processing:{orders:g,amount:b},shipped:{orders:C,amount:E},delayed:{orders:S,amount:R}}},[t]),o=[{name:"All",icon:Package,color:"bg-blue-500",textColor:"text-blue-600",orders:n.all.orders,amount:n.all.amount},{name:"Processing",icon:RefreshCcw,color:"bg-yellow-500",textColor:"text-yellow-600",orders:n.processing.orders,amount:n.processing.amount},{name:"Shipped",icon:Truck,color:"bg-green-500",textColor:"text-green-600",orders:n.shipped.orders,amount:n.shipped.amount},{name:"Delayed",icon:CircleAlert,color:"bg-red-500",textColor:"text-red-600",orders:n.delayed.orders,amount:n.delayed.amount}];return e?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-lg font-bold",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(l=>jsxRuntime.jsxs("div",{className:"overflow-hidden rounded-md border",children:[jsxRuntime.jsx("div",{className:"bg-slate-200 dark:bg-slate-700 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"})]})]})]})]},l))})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-lg font-bold",children:"Active Orders"})}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-4 p-4",children:o.map(l=>jsxRuntime.jsxs("div",{className:"overflow-hidden rounded-md border",children:[jsxRuntime.jsx("div",{className:`${l.color} bg-opacity-60 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:l.name}),jsxRuntime.jsx("div",{className:`${l.color} bg-opacity-90 p-2 rounded-full`,children:jsxRuntime.jsx(l.icon,{className:"size-4 shrink-0 text-white"})})]}),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:l.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(l.amount)})]})]})]})]},l.name))})]})}var __create=Object.create,__getProtoOf=Object.getPrototypeOf,__defProp=Object.defineProperty,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__toESM=(t,e,n)=>{n=t!=null?__create(__getProtoOf(t)):{};const o=e||!t||!t.__esModule?__defProp(n,"default",{value:t,enumerable:!0}):n;for(let l of __getOwnPropNames(t))__hasOwnProp.call(o,l)||__defProp(o,l,{get:()=>t[l],enumerable:!0});return o},__commonJS=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),require_xhtml=__commonJS((t,e)=>{e.exports={quot:'"',amp:"&",apos:"'",lt:"<",gt:">",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",ensp:" ",emsp:" ",thinsp:" ",zwnj:"",zwj:"",lrm:"",rlm:"",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",frasl:"⁄",euro:"€",image:"ℑ",weierp:"℘",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"}}),require_acorn=__commonJS((t,e)=>{(function(n,o){typeof t=="object"&&typeof e<"u"?o(t):typeof define=="function"&&define.amd?define(["exports"],o):(n=typeof globalThis<"u"?globalThis:n||self,o(n.acorn={}))})(t,function(n){var o=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,370,1,81,2,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,9,5351,0,7,14,13835,9,87,9,39,4,60,6,26,9,1014,0,2,54,8,3,82,0,12,1,19628,1,4706,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,983,6,110,6,6,9,4759,9,787719,239],l=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,68,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,349,41,7,1,79,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,4026,582,8634,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,689,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,43,8,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,757,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],d="·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛࢘-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・",f="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲈᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꟊꟐꟑꟓꟕ-ꟙꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",g={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},b="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",_={5:b,"5module":b+" export import",6:b+" const class extends export import super"},S=/^in(stanceof)?$/,R=new RegExp("["+f+"]"),C=new RegExp("["+f+d+"]");function E(O,ae){for(var Ve=65536,Le=0;Le<ae.length;Le+=2){if(Ve+=ae[Le],Ve>O)return!1;if(Ve+=ae[Le+1],Ve>=O)return!0}return!1}function A(O,ae){return O<65?O===36:O<91?!0:O<97?O===95:O<123?!0:O<=65535?O>=170&&R.test(String.fromCharCode(O)):ae===!1?!1:E(O,l)}function M(O,ae){return O<48?O===36:O<58?!0:O<65?!1:O<91?!0:O<97?O===95:O<123?!0:O<=65535?O>=170&&C.test(String.fromCharCode(O)):ae===!1?!1:E(O,l)||E(O,o)}var I=function(ae,Ve){Ve===void 0&&(Ve={}),this.label=ae,this.keyword=Ve.keyword,this.beforeExpr=!!Ve.beforeExpr,this.startsExpr=!!Ve.startsExpr,this.isLoop=!!Ve.isLoop,this.isAssign=!!Ve.isAssign,this.prefix=!!Ve.prefix,this.postfix=!!Ve.postfix,this.binop=Ve.binop||null,this.updateContext=null};function j(O,ae){return new I(O,{beforeExpr:!0,binop:ae})}var q={beforeExpr:!0},z={startsExpr:!0},Q={};function V(O,ae){return ae===void 0&&(ae={}),ae.keyword=O,Q[O]=new I(O,ae)}var F={num:new I("num",z),regexp:new I("regexp",z),string:new I("string",z),name:new I("name",z),privateId:new I("privateId",z),eof:new I("eof"),bracketL:new I("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new I("]"),braceL:new I("{",{beforeExpr:!0,startsExpr:!0}),braceR:new I("}"),parenL:new I("(",{beforeExpr:!0,startsExpr:!0}),parenR:new I(")"),comma:new I(",",q),semi:new I(";",q),colon:new I(":",q),dot:new I("."),question:new I("?",q),questionDot:new I("?."),arrow:new I("=>",q),template:new I("template"),invalidTemplate:new I("invalidTemplate"),ellipsis:new I("...",q),backQuote:new I("`",z),dollarBraceL:new I("${",{beforeExpr:!0,startsExpr:!0}),eq:new I("=",{beforeExpr:!0,isAssign:!0}),assign:new I("_=",{beforeExpr:!0,isAssign:!0}),incDec:new I("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new I("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:j("||",1),logicalAND:j("&&",2),bitwiseOR:j("|",3),bitwiseXOR:j("^",4),bitwiseAND:j("&",5),equality:j("==/!=/===/!==",6),relational:j("</>/<=/>=",7),bitShift:j("<</>>/>>>",8),plusMin:new I("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:j("%",10),star:j("*",10),slash:j("/",10),starstar:new I("**",{beforeExpr:!0}),coalesce:j("??",1),_break:V("break"),_case:V("case",q),_catch:V("catch"),_continue:V("continue"),_debugger:V("debugger"),_default:V("default",q),_do:V("do",{isLoop:!0,beforeExpr:!0}),_else:V("else",q),_finally:V("finally"),_for:V("for",{isLoop:!0}),_function:V("function",z),_if:V("if"),_return:V("return",q),_switch:V("switch"),_throw:V("throw",q),_try:V("try"),_var:V("var"),_const:V("const"),_while:V("while",{isLoop:!0}),_with:V("with"),_new:V("new",{beforeExpr:!0,startsExpr:!0}),_this:V("this",z),_super:V("super",z),_class:V("class",z),_extends:V("extends",q),_export:V("export"),_import:V("import",z),_null:V("null",z),_true:V("true",z),_false:V("false",z),_in:V("in",{beforeExpr:!0,binop:7}),_instanceof:V("instanceof",{beforeExpr:!0,binop:7}),_typeof:V("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:V("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:V("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},te=/\r\n?|\n|\u2028|\u2029/,ne=new RegExp(te.source,"g");function se(O){return O===10||O===13||O===8232||O===8233}function ge(O,ae,Ve){Ve===void 0&&(Ve=O.length);for(var Le=ae;Le<Ve;Le++){var We=O.charCodeAt(Le);if(se(We))return Le<Ve-1&&We===13&&O.charCodeAt(Le+1)===10?Le+2:Le+1}return-1}var oe=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,Ae=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,je=Object.prototype,Ne=je.hasOwnProperty,Oe=je.toString,Fe=Object.hasOwn||function(O,ae){return Ne.call(O,ae)},ze=Array.isArray||function(O){return Oe.call(O)==="[object Array]"},$e=Object.create(null);function Be(O){return $e[O]||($e[O]=new RegExp("^(?:"+O.replace(/ /g,"|")+")$"))}function qe(O){return O<=65535?String.fromCharCode(O):(O-=65536,String.fromCharCode((O>>10)+55296,(O&1023)+56320))}var Ge=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,He=function(ae,Ve){this.line=ae,this.column=Ve};He.prototype.offset=function(ae){return new He(this.line,this.column+ae)};var Ze=function(ae,Ve,Le){this.start=Ve,this.end=Le,ae.sourceFile!==null&&(this.source=ae.sourceFile)};function tt(O,ae){for(var Ve=1,Le=0;;){var We=ge(O,Le,ae);if(We<0)return new He(Ve,ae-Le);++Ve,Le=We}}var Ye={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},Qe=!1;function Xe(O){var ae={};for(var Ve in Ye)ae[Ve]=O&&Fe(O,Ve)?O[Ve]:Ye[Ve];if(ae.ecmaVersion==="latest"?ae.ecmaVersion=1e8:ae.ecmaVersion==null?(!Qe&&typeof console=="object"&&console.warn&&(Qe=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
1130
|
+
*/function flexRender(t,e){return t?isReactComponent(t)?React__namespace.createElement(t,e):t:null}function isReactComponent(t){return isClassComponent(t)||typeof t=="function"||isExoticComponent(t)}function isClassComponent(t){return typeof t=="function"&&(()=>{const e=Object.getPrototypeOf(t);return e.prototype&&e.prototype.isReactComponent})()}function isExoticComponent(t){return typeof t=="object"&&typeof t.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(t.$$typeof.description)}function useReactTable(t){const e={state:{},onStateChange:()=>{},renderFallbackValue:null,...t},[n]=React__namespace.useState(()=>({current:createTable(e)})),[o,l]=React__namespace.useState(()=>n.current.initialState);return n.current.setOptions(d=>({...d,...t,state:{...o,...t.state},onStateChange:f=>{l(f),t.onStateChange==null||t.onStateChange(f)}})),n.current}function DataTable({columns:t,data:e,uniqueValues:n,tableClass:o,loading:l}){var M;const[d,f]=React.useState([]),[g,b]=React.useState([]),[_,S]=React.useState({pageIndex:0,pageSize:10}),[R,C]=React.useState(null),E=useReactTable({data:l?[]:e,columns:t,getCoreRowModel:getCoreRowModel(),onSortingChange:f,getSortedRowModel:getSortedRowModel(),onColumnFiltersChange:b,getFilteredRowModel:getFilteredRowModel(),getPaginationRowModel:getPaginationRowModel(),onPaginationChange:S,state:{sorting:d,columnFilters:g,pagination:_},manualPagination:l,manualSorting:l,manualFiltering:l}),A=(I,j)=>{I.toggleSorting(j),C(null)};return l?jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("div",{className:`rounded-md border ${o??""}`,children:jsxRuntime.jsxs(Table,{children:[jsxRuntime.jsx(TableHeader,{children:jsxRuntime.jsx(TableRow,{children:t.map((I,j)=>jsxRuntime.jsx(TableHead,{children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-full"})},`skeleton-header-${j}`))})}),jsxRuntime.jsx(TableBody,{children:Array.from({length:_.pageSize}).map((I,j)=>jsxRuntime.jsx(TableRow,{children:t.map((q,z)=>jsxRuntime.jsx(TableCell,{children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-full"})},`skeleton-cell-${j}-${z}`))},`skeleton-row-${j}`))})]})}),jsxRuntime.jsxs("div",{className:"flex items-center 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:"space-y-4",children:[jsxRuntime.jsxs(ScrollArea,{className:`rounded-md border ${o??""}`,children:[jsxRuntime.jsxs(Table,{children:[jsxRuntime.jsx(TableHeader,{children:E.getHeaderGroups().map(I=>jsxRuntime.jsx(TableRow,{children:I.headers.map(j=>{var q;return jsxRuntime.jsx(TableHead,{children:j.isPlaceholder?null:j.column.getCanSort()||j.column.getCanFilter()?jsxRuntime.jsxs(Popover,{open:R===j.id,onOpenChange:z=>C(z?j.id:null),children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{variant:"ghost",className:"pl-0",children:[flexRender(j.column.columnDef.header,j.getContext()),j.column.getIsFiltered()?jsxRuntime.jsx(Filter,{className:"ml-2 h-4 w-4"}):j.column.getIsSorted()==="asc"?jsxRuntime.jsx(ArrowUp,{className:"ml-2 h-4 w-4"}):j.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:[j.column.getCanSort()&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button,{variant:"ghost",className:"w-full justify-start",onClick:()=>A(j.column,!1),children:[jsxRuntime.jsx(ArrowUp,{className:"mr-2 h-4 w-4"}),"Sort Ascending"]}),jsxRuntime.jsxs(Button,{variant:"ghost",className:"w-full justify-start",onClick:()=>A(j.column,!0),children:[jsxRuntime.jsx(ArrowDown,{className:"mr-2 h-4 w-4"}),"Sort Descending"]})]}),j.column.getCanFilter()&&jsxRuntime.jsx("div",{className:"px-2 py-1",children:n[j.column.id]?jsxRuntime.jsxs(Select,{onValueChange:z=>j.column.setFilterValue(z==="all"?void 0:[z]),children:[jsxRuntime.jsx(SelectTrigger,{children:jsxRuntime.jsx(SelectValue,{placeholder:`Filter ${j.column.columnDef.header}...`})}),jsxRuntime.jsxs(SelectContent,{children:[jsxRuntime.jsx(SelectItem,{value:"all",children:"All"}),(q=n[j.column.id])==null?void 0:q.map(z=>jsxRuntime.jsx(SelectItem,{value:z||"empty",children:z||"(Empty)"},z))]})]}):jsxRuntime.jsx(Input,{placeholder:`Filter ${j.column.columnDef.header}...`,value:j.column.getFilterValue()??"",onChange:z=>j.column.setFilterValue(z.target.value),className:"w-full"})})]})})]}):jsxRuntime.jsx("div",{className:"py-2 px-4",children:flexRender(j.column.columnDef.header,j.getContext())})},j.id)})},I.id))}),jsxRuntime.jsx(TableBody,{children:(M=E.getRowModel().rows)!=null&&M.length?E.getRowModel().rows.map(I=>jsxRuntime.jsx(TableRow,{"data-state":I.getIsSelected()&&"selected",children:I.getVisibleCells().map(j=>jsxRuntime.jsx(TableCell,{children:flexRender(j.column.columnDef.cell,j.getContext())},j.id))},I.id)):jsxRuntime.jsx(TableRow,{children:jsxRuntime.jsx(TableCell,{colSpan:t.length,className:"h-24 text-center",children:"No results."})})})]}),jsxRuntime.jsx(ScrollBar,{orientation:"horizontal"})]}),jsxRuntime.jsxs("div",{className:"flex items-center 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,{value:`${E.getState().pagination.pageSize}`,onValueChange:I=>{E.setPageSize(Number(I))},children:[jsxRuntime.jsx(SelectTrigger,{className:"h-8 w-[70px]",children:jsxRuntime.jsx(SelectValue,{asChild:!0,children:jsxRuntime.jsx("span",{children:E.getState().pagination.pageSize})})}),jsxRuntime.jsx(SelectContent,{side:"top",children:[10,20,30,40,50].map(I=>jsxRuntime.jsx(SelectItem,{value:`${I}`,children:jsxRuntime.jsx("span",{children:I})},I))})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsxs(Button,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>E.setPageIndex(0),disabled:!E.getCanPreviousPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to first page"}),jsxRuntime.jsx(ChevronsLeft,{className:"h-4 w-4"})]}),jsxRuntime.jsxs(Button,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>E.previousPage(),disabled:!E.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:E.getState().pagination.pageIndex+1}),jsxRuntime.jsx("p",{className:"text-sm font-medium",children:"of"}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:E.getPageCount()})]}),jsxRuntime.jsxs(Button,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>E.nextPage(),disabled:!E.getCanNextPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to next page"}),jsxRuntime.jsx(ChevronRight,{className:"h-4 w-4"})]}),jsxRuntime.jsxs(Button,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>E.setPageIndex(E.getPageCount()-1),disabled:!E.getCanNextPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to last page"}),jsxRuntime.jsx(ChevronsRight,{className:"h-4 w-4"})]})]})]})]})}function PartnerCard({account:t,action:e,loading:n=!1,className:o,withAbout:l=!1,withVoice:d=!0}){const[f,g]=React.useState(!1),[b,_]=React.useState(!0),[S,R]=React.useState(null),[C,E]=React.useState(!1),A=React.useMemo(()=>t!=null&&t.ApplicationId?{videoUrl:`https://api.randmar.io/V4/Partner/${t.ApplicationId}/Account/Video`,videoExistsUrl:`https://api.randmar.io/V4/Partner/${t.ApplicationId}/Account/Video/Exists`}:null,[t==null?void 0:t.ApplicationId]);React.useEffect(()=>{if(!A||n)return;R(null);const I=async()=>{try{const q=await fetch(A.videoExistsUrl);if(q.ok){const z=await q.text();g(z.toLowerCase()==="true")}else throw new Error(`Failed to check video: ${q.status}`)}catch(q){console.error("Failed to check if video exists:",q),g(!1)}};(async()=>{I()})()},[A,n]);const M=()=>{_(!1)};return n||!t?jsxRuntime.jsxs(Card,{className:`flex flex-col h-full ${o}`,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"})]}),l&&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"})]}),d&&jsxRuntime.jsx("div",{className:"p-3 bg-slate-50 rounded-md",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @lg:grid-cols-3 gap-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]})]})})]})}),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 ${o}`,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("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx(PartnerLogo,{id:t.ApplicationId,width:64,height:64},`partner_logo_${t.ApplicationId}`)}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:"Partner"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:t.ApplicationId})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:t.PublicName||"N/A"})]})]})}),jsxRuntime.jsxs(CardContent,{className:"pb-2 flex-grow",children:[S&&jsxRuntime.jsx("div",{className:"text-red-500 mb-4 text-sm",role:"alert",children:S}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[(t.IsManufacturer||t.IsReseller||t.IsSalesAgency)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.IsManufacturer&&jsxRuntime.jsx(Badge,{className:"manufacturer-theme",children:"Manufacturer"}),t.IsReseller&&jsxRuntime.jsx(Badge,{className:"reseller-theme",children:"Reseller"}),t.IsSalesAgency&&jsxRuntime.jsx(Badge,{children:"Agency"})]}),l&&t.About&&jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:t.About??""}}),d&&jsxRuntime.jsx("div",{className:"p-3 bg-slate-50 rounded-md",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @lg:grid-cols-3 gap-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Voice Name"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.VoiceName??"Regular"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Voice Style"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.VoiceStyle??"Regular"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Scene Name"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.SceneName??"N/A"})]})]})})]})]}),jsxRuntime.jsxs(CardFooter,{className:"px-6 py-4 flex justify-between gap-2 mt-auto",children:[f&&A?jsxRuntime.jsxs(Dialog,{open:C,onOpenChange:E,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{variant:"outline",className:"flex items-center gap-2",children:[jsxRuntime.jsx(Video,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:"Watch Video"})]})}),jsxRuntime.jsxs(DialogContent,{className:"@sm:max-w-[360px]",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsxs(DialogTitle,{children:[t.PublicName," Video"]})}),jsxRuntime.jsxs("div",{className:"w-full h-[640px] rounded-md overflow-hidden",children:[b&&jsxRuntime.jsx(Skeleton,{className:"w-full h-full"}),jsxRuntime.jsx("video",{src:A.videoUrl,controls:!0,preload:"auto",playsInline:!0,autoPlay:!0,"aria-label":`Video for ${t.PublicName}`,className:`w-full h-full object-cover ${b?"invisible":"visible"}`,style:{objectPosition:"center",imageRendering:"auto"},onLoadedData:M,onError:()=>_(!1)})]})]})]}):jsxRuntime.jsx("div",{}),e||jsxRuntime.jsxs(Button,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4"}),"Go to Partner Dashboard"]})]})]})}function ResellerCard({reseller:t,link:e,linkNewTab:n=!0,actions:o,mainAction:l,loading:d=!1}){var _,S;if(d||!t)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 f=t.ResellerId||"N/A",g=[t.City,t.Province,t.Country].filter(Boolean),b=g.length>0?g.join(", "):"Location not provided";return jsxRuntime.jsxs(Card,{className:"reseller-theme flex flex-col h-full",children:[jsxRuntime.jsx(reactRouterDom.Link,{to:e??"#",target:e&&n?"_blank":"_self",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("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx(PartnerLogo,{id:t.ResellerId,width:48,height:48},`partner_logo_${t.ResellerId}`)}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:"Reseller"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:f})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:t.PublicName||"N/A"}),t.Name&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:t.Name}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:b})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:t.SalesStatistics&&t.SalesStatistics.length>0&&jsxRuntime.jsx("div",{className:"h-16 w-24",children:jsxRuntime.jsx(SalesChart,{statistics:t.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:[(!!((_=t.Qualification)!=null&&_.QualificationId)&&((S=t.Qualification)==null?void 0:S.QualificationId)!=="Suspended"||!!t.OnHold&&t.OnHold!==0)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(QualificationBadge,{qualification:t.Qualification??{}}),!!t.OnHold&&t.OnHold!==0&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[t.Phone&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`tel:${t.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:t.Phone})]}),t.PublicEmail&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`mailto:${t.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:t.PublicEmail})]}),t.Website&&jsxRuntime.jsxs(reactRouterDom.Link,{to:t.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:t.Website})]}),t.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:t.CurrencyCode})]})]})]}),(t==null?void 0:t.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:t!=null&&t.SalesData.SalesYearToDay?formatMoney(t==null?void 0:t.SalesData.SalesYearToDay):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"3 mo."}),jsxRuntime.jsx("p",{children:t!=null&&t.SalesData.SalesLast3Months?formatMoney(t==null?void 0:t.SalesData.SalesLast3Months):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"30 days"}),jsxRuntime.jsx("p",{children:t!=null&&t.SalesData.SalesLast30Days?formatMoney(t==null?void 0:t.SalesData.SalesLast30Days):"—"})]})]})}),(o||l)&&jsxRuntime.jsxs(CardFooter,{className:"flex pt-2 gap-2 justify-between mt-auto",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:o&&o}),l&&jsxRuntime.jsx("div",{children:l})]})]})}const Table=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("div",{className:"relative w-full overflow-auto",children:jsxRuntime.jsx("table",{ref:n,className:cn("w-full caption-bottom text-sm",t),...e})}));Table.displayName="Table";const TableHeader=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("thead",{ref:n,className:cn("[&_tr]:border-b",t),...e}));TableHeader.displayName="TableHeader";const TableBody=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("tbody",{ref:n,className:cn("[&_tr:last-child]:border-0",t),...e}));TableBody.displayName="TableBody";const TableFooter=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("tfoot",{ref:n,className:cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...e}));TableFooter.displayName="TableFooter";const TableRow=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("tr",{ref:n,className:cn("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...e}));TableRow.displayName="TableRow";const TableHead=React__namespace.forwardRef(({className:t,...e},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]",t),...e,children:React__namespace.isValidElement(e.children)&&e.children.type==="span"?e.children:jsxRuntime.jsx("span",{children:e.children})}));TableHead.displayName="TableHead";const TableCell=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("td",{ref:n,className:cn("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...e,children:React__namespace.isValidElement(e.children)&&e.children.type==="span"?e.children:jsxRuntime.jsx("span",{children:e.children})}));TableCell.displayName="TableCell";const TableCaption=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("caption",{ref:n,className:cn("mt-4 text-sm text-muted-foreground",t),...e}));TableCaption.displayName="TableCaption";const Topbar=React.forwardRef(({onSignOut:t,handleValidSearch:e,rightMenu:n,searchPlaceholder:o},l)=>{const[d,f]=React.useState(""),g=reactRouterDom.useLocation(),{toast:b}=useToast();React.useEffect(()=>{const C=new URLSearchParams(g.search).get("q");C&&f(C)},[g.search]);const _=()=>{const R=d.trim();if(!R||R.length<2){b({title:"Enter more characters to search",description:"At least 2 characters are needed to search products.",variant:"destructive",duration:5e3});return}e(R)},S=R=>{R.key==="Enter"&&_()};return jsxRuntime.jsxs("header",{className:"flex h-16 items-center gap-4 border-b sidebar-foreground bg-sidebar px-6 fixed top-0 right-0 z-50 lg:left-64 left-0 border-sidebar-border",children:[jsxRuntime.jsx(SidebarTrigger,{className:"lg:hidden",children:jsxRuntime.jsx(Menu$1,{className:"h-6 w-6"})}),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-2 top-1/2 -translate-y-1/2",onClick:_,"aria-label":"Search",children:jsxRuntime.jsx(Search,{className:"h-4 w-4 text-muted-foreground"})}),jsxRuntime.jsx(Input,{placeholder:o??"Search...",className:"w-full pl-8 bg-white text-black",value:d,onChange:R=>f(R.target.value),onKeyDown:S,ref:l},"topbar-search")]})})}),n||jsxRuntime.jsx(jsxRuntime.Fragment,{}),t&&jsxRuntime.jsx("div",{className:"flex items-center gap-4",children:jsxRuntime.jsxs(Button,{variant:"ghost",size:"icon",className:"h-9 w-9",onClick:t,children:[jsxRuntime.jsx(LogOut,{className:"h-4 w-4 text-sidebar-foreground"}),jsxRuntime.jsx("span",{className:"sr-only",children:"Sign out"})]})})]})});Topbar.displayName="Topbar";function ActiveOrdersCard({orders:t,loading:e=!1}){const n=React.useMemo(()=>{if(!t||t.length===0)return{all:{orders:0,amount:0},processing:{orders:0,amount:0},shipped:{orders:0,amount:0},delayed:{orders:0,amount:0}};const l=t.filter(I=>I.DocumentType==="Order"),d=t.filter(I=>I.DocumentType==="Shipment"),f=l.filter(I=>I.WarehouseCode!=="3PLE"),g=f.reduce((I,j)=>I+(j.Quantity||0),0),b=f.reduce((I,j)=>I+(j.ExtendedPrice||0),0),_=l.filter(I=>I.WarehouseCode==="3PLE"),S=_.reduce((I,j)=>I+(j.Quantity||0),0),R=_.reduce((I,j)=>I+(j.ExtendedPrice||0),0),C=d.length,E=d.reduce((I,j)=>I+(j.ExtendedPrice||0),0),A=g+S+C,M=b+R+E;return{all:{orders:A,amount:M},processing:{orders:g,amount:b},shipped:{orders:C,amount:E},delayed:{orders:S,amount:R}}},[t]),o=[{name:"All",icon:Package,color:"bg-blue-500",textColor:"text-blue-600",orders:n.all.orders,amount:n.all.amount},{name:"Processing",icon:RefreshCcw,color:"bg-yellow-500",textColor:"text-yellow-600",orders:n.processing.orders,amount:n.processing.amount},{name:"Shipped",icon:Truck,color:"bg-green-500",textColor:"text-green-600",orders:n.shipped.orders,amount:n.shipped.amount},{name:"Delayed",icon:CircleAlert,color:"bg-red-500",textColor:"text-red-600",orders:n.delayed.orders,amount:n.delayed.amount}];return e?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-lg font-bold",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(l=>jsxRuntime.jsxs("div",{className:"overflow-hidden rounded-md border",children:[jsxRuntime.jsx("div",{className:"bg-slate-200 dark:bg-slate-700 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"})]})]})]})]},l))})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-lg font-bold",children:"Active Orders"})}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-4 p-4",children:o.map(l=>jsxRuntime.jsxs("div",{className:"overflow-hidden rounded-md border",children:[jsxRuntime.jsx("div",{className:`${l.color} bg-opacity-60 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:l.name}),jsxRuntime.jsx("div",{className:`${l.color} bg-opacity-90 p-2 rounded-full`,children:jsxRuntime.jsx(l.icon,{className:"size-4 shrink-0 text-white"})})]}),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:l.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(l.amount)})]})]})]})]},l.name))})]})}var __create=Object.create,__getProtoOf=Object.getPrototypeOf,__defProp=Object.defineProperty,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__toESM=(t,e,n)=>{n=t!=null?__create(__getProtoOf(t)):{};const o=e||!t||!t.__esModule?__defProp(n,"default",{value:t,enumerable:!0}):n;for(let l of __getOwnPropNames(t))__hasOwnProp.call(o,l)||__defProp(o,l,{get:()=>t[l],enumerable:!0});return o},__commonJS=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),require_xhtml=__commonJS((t,e)=>{e.exports={quot:'"',amp:"&",apos:"'",lt:"<",gt:">",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",ensp:" ",emsp:" ",thinsp:" ",zwnj:"",zwj:"",lrm:"",rlm:"",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",frasl:"⁄",euro:"€",image:"ℑ",weierp:"℘",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"}}),require_acorn=__commonJS((t,e)=>{(function(n,o){typeof t=="object"&&typeof e<"u"?o(t):typeof define=="function"&&define.amd?define(["exports"],o):(n=typeof globalThis<"u"?globalThis:n||self,o(n.acorn={}))})(t,function(n){var o=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,370,1,81,2,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,9,5351,0,7,14,13835,9,87,9,39,4,60,6,26,9,1014,0,2,54,8,3,82,0,12,1,19628,1,4706,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,983,6,110,6,6,9,4759,9,787719,239],l=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,68,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,349,41,7,1,79,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,4026,582,8634,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,689,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,43,8,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,757,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],d="·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛࢘-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・",f="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲈᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꟊꟐꟑꟓꟕ-ꟙꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",g={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},b="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",_={5:b,"5module":b+" export import",6:b+" const class extends export import super"},S=/^in(stanceof)?$/,R=new RegExp("["+f+"]"),C=new RegExp("["+f+d+"]");function E(O,ae){for(var Ve=65536,Le=0;Le<ae.length;Le+=2){if(Ve+=ae[Le],Ve>O)return!1;if(Ve+=ae[Le+1],Ve>=O)return!0}return!1}function A(O,ae){return O<65?O===36:O<91?!0:O<97?O===95:O<123?!0:O<=65535?O>=170&&R.test(String.fromCharCode(O)):ae===!1?!1:E(O,l)}function M(O,ae){return O<48?O===36:O<58?!0:O<65?!1:O<91?!0:O<97?O===95:O<123?!0:O<=65535?O>=170&&C.test(String.fromCharCode(O)):ae===!1?!1:E(O,l)||E(O,o)}var I=function(ae,Ve){Ve===void 0&&(Ve={}),this.label=ae,this.keyword=Ve.keyword,this.beforeExpr=!!Ve.beforeExpr,this.startsExpr=!!Ve.startsExpr,this.isLoop=!!Ve.isLoop,this.isAssign=!!Ve.isAssign,this.prefix=!!Ve.prefix,this.postfix=!!Ve.postfix,this.binop=Ve.binop||null,this.updateContext=null};function j(O,ae){return new I(O,{beforeExpr:!0,binop:ae})}var q={beforeExpr:!0},z={startsExpr:!0},Q={};function V(O,ae){return ae===void 0&&(ae={}),ae.keyword=O,Q[O]=new I(O,ae)}var F={num:new I("num",z),regexp:new I("regexp",z),string:new I("string",z),name:new I("name",z),privateId:new I("privateId",z),eof:new I("eof"),bracketL:new I("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new I("]"),braceL:new I("{",{beforeExpr:!0,startsExpr:!0}),braceR:new I("}"),parenL:new I("(",{beforeExpr:!0,startsExpr:!0}),parenR:new I(")"),comma:new I(",",q),semi:new I(";",q),colon:new I(":",q),dot:new I("."),question:new I("?",q),questionDot:new I("?."),arrow:new I("=>",q),template:new I("template"),invalidTemplate:new I("invalidTemplate"),ellipsis:new I("...",q),backQuote:new I("`",z),dollarBraceL:new I("${",{beforeExpr:!0,startsExpr:!0}),eq:new I("=",{beforeExpr:!0,isAssign:!0}),assign:new I("_=",{beforeExpr:!0,isAssign:!0}),incDec:new I("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new I("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:j("||",1),logicalAND:j("&&",2),bitwiseOR:j("|",3),bitwiseXOR:j("^",4),bitwiseAND:j("&",5),equality:j("==/!=/===/!==",6),relational:j("</>/<=/>=",7),bitShift:j("<</>>/>>>",8),plusMin:new I("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:j("%",10),star:j("*",10),slash:j("/",10),starstar:new I("**",{beforeExpr:!0}),coalesce:j("??",1),_break:V("break"),_case:V("case",q),_catch:V("catch"),_continue:V("continue"),_debugger:V("debugger"),_default:V("default",q),_do:V("do",{isLoop:!0,beforeExpr:!0}),_else:V("else",q),_finally:V("finally"),_for:V("for",{isLoop:!0}),_function:V("function",z),_if:V("if"),_return:V("return",q),_switch:V("switch"),_throw:V("throw",q),_try:V("try"),_var:V("var"),_const:V("const"),_while:V("while",{isLoop:!0}),_with:V("with"),_new:V("new",{beforeExpr:!0,startsExpr:!0}),_this:V("this",z),_super:V("super",z),_class:V("class",z),_extends:V("extends",q),_export:V("export"),_import:V("import",z),_null:V("null",z),_true:V("true",z),_false:V("false",z),_in:V("in",{beforeExpr:!0,binop:7}),_instanceof:V("instanceof",{beforeExpr:!0,binop:7}),_typeof:V("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:V("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:V("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},te=/\r\n?|\n|\u2028|\u2029/,ne=new RegExp(te.source,"g");function se(O){return O===10||O===13||O===8232||O===8233}function ge(O,ae,Ve){Ve===void 0&&(Ve=O.length);for(var Le=ae;Le<Ve;Le++){var We=O.charCodeAt(Le);if(se(We))return Le<Ve-1&&We===13&&O.charCodeAt(Le+1)===10?Le+2:Le+1}return-1}var oe=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,Ae=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,je=Object.prototype,Ne=je.hasOwnProperty,Oe=je.toString,Fe=Object.hasOwn||function(O,ae){return Ne.call(O,ae)},ze=Array.isArray||function(O){return Oe.call(O)==="[object Array]"},$e=Object.create(null);function Be(O){return $e[O]||($e[O]=new RegExp("^(?:"+O.replace(/ /g,"|")+")$"))}function qe(O){return O<=65535?String.fromCharCode(O):(O-=65536,String.fromCharCode((O>>10)+55296,(O&1023)+56320))}var Ge=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,He=function(ae,Ve){this.line=ae,this.column=Ve};He.prototype.offset=function(ae){return new He(this.line,this.column+ae)};var Ze=function(ae,Ve,Le){this.start=Ve,this.end=Le,ae.sourceFile!==null&&(this.source=ae.sourceFile)};function tt(O,ae){for(var Ve=1,Le=0;;){var We=ge(O,Le,ae);if(We<0)return new He(Ve,ae-Le);++Ve,Le=We}}var Ye={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},Qe=!1;function Xe(O){var ae={};for(var Ve in Ye)ae[Ve]=O&&Fe(O,Ve)?O[Ve]:Ye[Ve];if(ae.ecmaVersion==="latest"?ae.ecmaVersion=1e8:ae.ecmaVersion==null?(!Qe&&typeof console=="object"&&console.warn&&(Qe=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
1131
1131
|
Defaulting to 2020, but this will stop working in the future.`)),ae.ecmaVersion=11):ae.ecmaVersion>=2015&&(ae.ecmaVersion-=2009),ae.allowReserved==null&&(ae.allowReserved=ae.ecmaVersion<5),(!O||O.allowHashBang==null)&&(ae.allowHashBang=ae.ecmaVersion>=14),ze(ae.onToken)){var Le=ae.onToken;ae.onToken=function(We){return Le.push(We)}}return ze(ae.onComment)&&(ae.onComment=st(ae,ae.onComment)),ae}function st(O,ae){return function(Ve,Le,We,lt,ut,$t){var Dt={type:Ve?"Block":"Line",value:Le,start:We,end:lt};O.locations&&(Dt.loc=new Ze(this,ut,$t)),O.ranges&&(Dt.range=[We,lt]),ae.push(Dt)}}var rt=1,at=2,ot=4,Ue=8,Ct=16,Je=32,yt=64,Mt=128,qt=256,Ht=rt|at|qt;function Ft(O,ae){return at|(O?ot:0)|(ae?Ue:0)}var Ke=0,it=1,et=2,ct=3,ft=4,dt=5,Rt=function(ae,Ve,Le){this.options=ae=Xe(ae),this.sourceFile=ae.sourceFile,this.keywords=Be(_[ae.ecmaVersion>=6?6:ae.sourceType==="module"?"5module":5]);var We="";ae.allowReserved!==!0&&(We=g[ae.ecmaVersion>=6?6:ae.ecmaVersion===5?5:3],ae.sourceType==="module"&&(We+=" await")),this.reservedWords=Be(We);var lt=(We?We+" ":"")+g.strict;this.reservedWordsStrict=Be(lt),this.reservedWordsStrictBind=Be(lt+" "+g.strictBind),this.input=String(Ve),this.containsEsc=!1,Le?(this.pos=Le,this.lineStart=this.input.lastIndexOf(`
|
|
1132
1132
|
`,Le-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(te).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=F.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=ae.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&ae.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(rt),this.regexpState=null,this.privateNameStack=[]},zt={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};Rt.prototype.parse=function(){var ae=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(ae)},zt.inFunction.get=function(){return(this.currentVarScope().flags&at)>0},zt.inGenerator.get=function(){return(this.currentVarScope().flags&Ue)>0&&!this.currentVarScope().inClassFieldInit},zt.inAsync.get=function(){return(this.currentVarScope().flags&ot)>0&&!this.currentVarScope().inClassFieldInit},zt.canAwait.get=function(){for(var O=this.scopeStack.length-1;O>=0;O--){var ae=this.scopeStack[O];if(ae.inClassFieldInit||ae.flags&qt)return!1;if(ae.flags&at)return(ae.flags&ot)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},zt.allowSuper.get=function(){var O=this.currentThisScope(),ae=O.flags,Ve=O.inClassFieldInit;return(ae&yt)>0||Ve||this.options.allowSuperOutsideMethod},zt.allowDirectSuper.get=function(){return(this.currentThisScope().flags&Mt)>0},zt.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},zt.allowNewDotTarget.get=function(){var O=this.currentThisScope(),ae=O.flags,Ve=O.inClassFieldInit;return(ae&(at|qt))>0||Ve},zt.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&qt)>0},Rt.extend=function(){for(var ae=[],Ve=arguments.length;Ve--;)ae[Ve]=arguments[Ve];for(var Le=this,We=0;We<ae.length;We++)Le=ae[We](Le);return Le},Rt.parse=function(ae,Ve){return new this(Ve,ae).parse()},Rt.parseExpressionAt=function(ae,Ve,Le){var We=new this(Le,ae,Ve);return We.nextToken(),We.parseExpression()},Rt.tokenizer=function(ae,Ve){return new this(Ve,ae)},Object.defineProperties(Rt.prototype,zt);var Yt=Rt.prototype,sr=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;Yt.strictDirective=function(O){if(this.options.ecmaVersion<5)return!1;for(;;){Ae.lastIndex=O,O+=Ae.exec(this.input)[0].length;var ae=sr.exec(this.input.slice(O));if(!ae)return!1;if((ae[1]||ae[2])==="use strict"){Ae.lastIndex=O+ae[0].length;var Ve=Ae.exec(this.input),Le=Ve.index+Ve[0].length,We=this.input.charAt(Le);return We===";"||We==="}"||te.test(Ve[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(We)||We==="!"&&this.input.charAt(Le+1)==="=")}O+=ae[0].length,Ae.lastIndex=O,O+=Ae.exec(this.input)[0].length,this.input[O]===";"&&O++}},Yt.eat=function(O){return this.type===O?(this.next(),!0):!1},Yt.isContextual=function(O){return this.type===F.name&&this.value===O&&!this.containsEsc},Yt.eatContextual=function(O){return this.isContextual(O)?(this.next(),!0):!1},Yt.expectContextual=function(O){this.eatContextual(O)||this.unexpected()},Yt.canInsertSemicolon=function(){return this.type===F.eof||this.type===F.braceR||te.test(this.input.slice(this.lastTokEnd,this.start))},Yt.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},Yt.semicolon=function(){!this.eat(F.semi)&&!this.insertSemicolon()&&this.unexpected()},Yt.afterTrailingComma=function(O,ae){if(this.type===O)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),ae||this.next(),!0},Yt.expect=function(O){this.eat(O)||this.unexpected()},Yt.unexpected=function(O){this.raise(O??this.start,"Unexpected token")};var dr=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};Yt.checkPatternErrors=function(O,ae){if(O){O.trailingComma>-1&&this.raiseRecoverable(O.trailingComma,"Comma is not permitted after the rest element");var Ve=ae?O.parenthesizedAssign:O.parenthesizedBind;Ve>-1&&this.raiseRecoverable(Ve,ae?"Assigning to rvalue":"Parenthesized pattern")}},Yt.checkExpressionErrors=function(O,ae){if(!O)return!1;var Ve=O.shorthandAssign,Le=O.doubleProto;if(!ae)return Ve>=0||Le>=0;Ve>=0&&this.raise(Ve,"Shorthand property assignments are valid only in destructuring patterns"),Le>=0&&this.raiseRecoverable(Le,"Redefinition of __proto__ property")},Yt.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,"Yield expression cannot be a default value"),this.awaitPos&&this.raise(this.awaitPos,"Await expression cannot be a default value")},Yt.isSimpleAssignTarget=function(O){return O.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(O.expression):O.type==="Identifier"||O.type==="MemberExpression"};var mt=Rt.prototype;mt.parseTopLevel=function(O){var ae=Object.create(null);for(O.body||(O.body=[]);this.type!==F.eof;){var Ve=this.parseStatement(null,!0,ae);O.body.push(Ve)}if(this.inModule)for(var Le=0,We=Object.keys(this.undefinedExports);Le<We.length;Le+=1){var lt=We[Le];this.raiseRecoverable(this.undefinedExports[lt].start,"Export '"+lt+"' is not defined")}return this.adaptDirectivePrologue(O.body),this.next(),O.sourceType=this.options.sourceType,this.finishNode(O,"Program")};var Sr={kind:"loop"},pt={kind:"switch"};mt.isLet=function(O){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;Ae.lastIndex=this.pos;var ae=Ae.exec(this.input),Ve=this.pos+ae[0].length,Le=this.input.charCodeAt(Ve);if(Le===91||Le===92)return!0;if(O)return!1;if(Le===123||Le>55295&&Le<56320)return!0;if(A(Le,!0)){for(var We=Ve+1;M(Le=this.input.charCodeAt(We),!0);)++We;if(Le===92||Le>55295&&Le<56320)return!0;var lt=this.input.slice(Ve,We);if(!S.test(lt))return!0}return!1},mt.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;Ae.lastIndex=this.pos;var O=Ae.exec(this.input),ae=this.pos+O[0].length,Ve;return!te.test(this.input.slice(this.pos,ae))&&this.input.slice(ae,ae+8)==="function"&&(ae+8===this.input.length||!(M(Ve=this.input.charCodeAt(ae+8))||Ve>55295&&Ve<56320))},mt.parseStatement=function(O,ae,Ve){var Le=this.type,We=this.startNode(),lt;switch(this.isLet(O)&&(Le=F._var,lt="let"),Le){case F._break:case F._continue:return this.parseBreakContinueStatement(We,Le.keyword);case F._debugger:return this.parseDebuggerStatement(We);case F._do:return this.parseDoStatement(We);case F._for:return this.parseForStatement(We);case F._function:return O&&(this.strict||O!=="if"&&O!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(We,!1,!O);case F._class:return O&&this.unexpected(),this.parseClass(We,!0);case F._if:return this.parseIfStatement(We);case F._return:return this.parseReturnStatement(We);case F._switch:return this.parseSwitchStatement(We);case F._throw:return this.parseThrowStatement(We);case F._try:return this.parseTryStatement(We);case F._const:case F._var:return lt=lt||this.value,O&<!=="var"&&this.unexpected(),this.parseVarStatement(We,lt);case F._while:return this.parseWhileStatement(We);case F._with:return this.parseWithStatement(We);case F.braceL:return this.parseBlock(!0,We);case F.semi:return this.parseEmptyStatement(We);case F._export:case F._import:if(this.options.ecmaVersion>10&&Le===F._import){Ae.lastIndex=this.pos;var ut=Ae.exec(this.input),$t=this.pos+ut[0].length,Dt=this.input.charCodeAt($t);if(Dt===40||Dt===46)return this.parseExpressionStatement(We,this.parseExpression())}return this.options.allowImportExportEverywhere||(ae||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),Le===F._import?this.parseImport(We):this.parseExport(We,Ve);default:if(this.isAsyncFunction())return O&&this.unexpected(),this.next(),this.parseFunctionStatement(We,!0,!O);var er=this.value,Jt=this.parseExpression();return Le===F.name&&Jt.type==="Identifier"&&this.eat(F.colon)?this.parseLabeledStatement(We,er,Jt,O):this.parseExpressionStatement(We,Jt)}},mt.parseBreakContinueStatement=function(O,ae){var Ve=ae==="break";this.next(),this.eat(F.semi)||this.insertSemicolon()?O.label=null:this.type!==F.name?this.unexpected():(O.label=this.parseIdent(),this.semicolon());for(var Le=0;Le<this.labels.length;++Le){var We=this.labels[Le];if((O.label==null||We.name===O.label.name)&&(We.kind!=null&&(Ve||We.kind==="loop")||O.label&&Ve))break}return Le===this.labels.length&&this.raise(O.start,"Unsyntactic "+ae),this.finishNode(O,Ve?"BreakStatement":"ContinueStatement")},mt.parseDebuggerStatement=function(O){return this.next(),this.semicolon(),this.finishNode(O,"DebuggerStatement")},mt.parseDoStatement=function(O){return this.next(),this.labels.push(Sr),O.body=this.parseStatement("do"),this.labels.pop(),this.expect(F._while),O.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(F.semi):this.semicolon(),this.finishNode(O,"DoWhileStatement")},mt.parseForStatement=function(O){this.next();var ae=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(Sr),this.enterScope(0),this.expect(F.parenL),this.type===F.semi)return ae>-1&&this.unexpected(ae),this.parseFor(O,null);var Ve=this.isLet();if(this.type===F._var||this.type===F._const||Ve){var Le=this.startNode(),We=Ve?"let":this.value;return this.next(),this.parseVar(Le,!0,We),this.finishNode(Le,"VariableDeclaration"),(this.type===F._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&Le.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===F._in?ae>-1&&this.unexpected(ae):O.await=ae>-1),this.parseForIn(O,Le)):(ae>-1&&this.unexpected(ae),this.parseFor(O,Le))}var lt=this.isContextual("let"),ut=!1,$t=this.containsEsc,Dt=new dr,er=this.start,Jt=ae>-1?this.parseExprSubscripts(Dt,"await"):this.parseExpression(!0,Dt);return this.type===F._in||(ut=this.options.ecmaVersion>=6&&this.isContextual("of"))?(ae>-1?(this.type===F._in&&this.unexpected(ae),O.await=!0):ut&&this.options.ecmaVersion>=8&&(Jt.start===er&&!$t&&Jt.type==="Identifier"&&Jt.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(O.await=!1)),lt&&ut&&this.raise(Jt.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(Jt,!1,Dt),this.checkLValPattern(Jt),this.parseForIn(O,Jt)):(this.checkExpressionErrors(Dt,!0),ae>-1&&this.unexpected(ae),this.parseFor(O,Jt))},mt.parseFunctionStatement=function(O,ae,Ve){return this.next(),this.parseFunction(O,Kt|(Ve?0:ur),!1,ae)},mt.parseIfStatement=function(O){return this.next(),O.test=this.parseParenExpression(),O.consequent=this.parseStatement("if"),O.alternate=this.eat(F._else)?this.parseStatement("if"):null,this.finishNode(O,"IfStatement")},mt.parseReturnStatement=function(O){return!this.inFunction&&!this.options.allowReturnOutsideFunction&&this.raise(this.start,"'return' outside of function"),this.next(),this.eat(F.semi)||this.insertSemicolon()?O.argument=null:(O.argument=this.parseExpression(),this.semicolon()),this.finishNode(O,"ReturnStatement")},mt.parseSwitchStatement=function(O){this.next(),O.discriminant=this.parseParenExpression(),O.cases=[],this.expect(F.braceL),this.labels.push(pt),this.enterScope(0);for(var ae,Ve=!1;this.type!==F.braceR;)if(this.type===F._case||this.type===F._default){var Le=this.type===F._case;ae&&this.finishNode(ae,"SwitchCase"),O.cases.push(ae=this.startNode()),ae.consequent=[],this.next(),Le?ae.test=this.parseExpression():(Ve&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),Ve=!0,ae.test=null),this.expect(F.colon)}else ae||this.unexpected(),ae.consequent.push(this.parseStatement(null));return this.exitScope(),ae&&this.finishNode(ae,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(O,"SwitchStatement")},mt.parseThrowStatement=function(O){return this.next(),te.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),O.argument=this.parseExpression(),this.semicolon(),this.finishNode(O,"ThrowStatement")};var Zt=[];mt.parseCatchClauseParam=function(){var O=this.parseBindingAtom(),ae=O.type==="Identifier";return this.enterScope(ae?Je:0),this.checkLValPattern(O,ae?ft:et),this.expect(F.parenR),O},mt.parseTryStatement=function(O){if(this.next(),O.block=this.parseBlock(),O.handler=null,this.type===F._catch){var ae=this.startNode();this.next(),this.eat(F.parenL)?ae.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),ae.param=null,this.enterScope(0)),ae.body=this.parseBlock(!1),this.exitScope(),O.handler=this.finishNode(ae,"CatchClause")}return O.finalizer=this.eat(F._finally)?this.parseBlock():null,!O.handler&&!O.finalizer&&this.raise(O.start,"Missing catch or finally clause"),this.finishNode(O,"TryStatement")},mt.parseVarStatement=function(O,ae,Ve){return this.next(),this.parseVar(O,!1,ae,Ve),this.semicolon(),this.finishNode(O,"VariableDeclaration")},mt.parseWhileStatement=function(O){return this.next(),O.test=this.parseParenExpression(),this.labels.push(Sr),O.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(O,"WhileStatement")},mt.parseWithStatement=function(O){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),O.object=this.parseParenExpression(),O.body=this.parseStatement("with"),this.finishNode(O,"WithStatement")},mt.parseEmptyStatement=function(O){return this.next(),this.finishNode(O,"EmptyStatement")},mt.parseLabeledStatement=function(O,ae,Ve,Le){for(var We=0,lt=this.labels;We<lt.length;We+=1){var ut=lt[We];ut.name===ae&&this.raise(Ve.start,"Label '"+ae+"' is already declared")}for(var $t=this.type.isLoop?"loop":this.type===F._switch?"switch":null,Dt=this.labels.length-1;Dt>=0;Dt--){var er=this.labels[Dt];if(er.statementStart===O.start)er.statementStart=this.start,er.kind=$t;else break}return this.labels.push({name:ae,kind:$t,statementStart:this.start}),O.body=this.parseStatement(Le?Le.indexOf("label")===-1?Le+"label":Le:"label"),this.labels.pop(),O.label=Ve,this.finishNode(O,"LabeledStatement")},mt.parseExpressionStatement=function(O,ae){return O.expression=ae,this.semicolon(),this.finishNode(O,"ExpressionStatement")},mt.parseBlock=function(O,ae,Ve){for(O===void 0&&(O=!0),ae===void 0&&(ae=this.startNode()),ae.body=[],this.expect(F.braceL),O&&this.enterScope(0);this.type!==F.braceR;){var Le=this.parseStatement(null);ae.body.push(Le)}return Ve&&(this.strict=!1),this.next(),O&&this.exitScope(),this.finishNode(ae,"BlockStatement")},mt.parseFor=function(O,ae){return O.init=ae,this.expect(F.semi),O.test=this.type===F.semi?null:this.parseExpression(),this.expect(F.semi),O.update=this.type===F.parenR?null:this.parseExpression(),this.expect(F.parenR),O.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(O,"ForStatement")},mt.parseForIn=function(O,ae){var Ve=this.type===F._in;return this.next(),ae.type==="VariableDeclaration"&&ae.declarations[0].init!=null&&(!Ve||this.options.ecmaVersion<8||this.strict||ae.kind!=="var"||ae.declarations[0].id.type!=="Identifier")&&this.raise(ae.start,(Ve?"for-in":"for-of")+" loop variable declaration may not have an initializer"),O.left=ae,O.right=Ve?this.parseExpression():this.parseMaybeAssign(),this.expect(F.parenR),O.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(O,Ve?"ForInStatement":"ForOfStatement")},mt.parseVar=function(O,ae,Ve,Le){for(O.declarations=[],O.kind=Ve;;){var We=this.startNode();if(this.parseVarId(We,Ve),this.eat(F.eq)?We.init=this.parseMaybeAssign(ae):!Le&&Ve==="const"&&!(this.type===F._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!Le&&We.id.type!=="Identifier"&&!(ae&&(this.type===F._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):We.init=null,O.declarations.push(this.finishNode(We,"VariableDeclarator")),!this.eat(F.comma))break}return O},mt.parseVarId=function(O,ae){O.id=this.parseBindingAtom(),this.checkLValPattern(O.id,ae==="var"?it:et,!1)};var Kt=1,ur=2,or=4;mt.parseFunction=function(O,ae,Ve,Le,We){this.initFunction(O),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!Le)&&(this.type===F.star&&ae&ur&&this.unexpected(),O.generator=this.eat(F.star)),this.options.ecmaVersion>=8&&(O.async=!!Le),ae&Kt&&(O.id=ae&or&&this.type!==F.name?null:this.parseIdent(),O.id&&!(ae&ur)&&this.checkLValSimple(O.id,this.strict||O.generator||O.async?this.treatFunctionsAsVar?it:et:ct));var lt=this.yieldPos,ut=this.awaitPos,$t=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Ft(O.async,O.generator)),ae&Kt||(O.id=this.type===F.name?this.parseIdent():null),this.parseFunctionParams(O),this.parseFunctionBody(O,Ve,!1,We),this.yieldPos=lt,this.awaitPos=ut,this.awaitIdentPos=$t,this.finishNode(O,ae&Kt?"FunctionDeclaration":"FunctionExpression")},mt.parseFunctionParams=function(O){this.expect(F.parenL),O.params=this.parseBindingList(F.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},mt.parseClass=function(O,ae){this.next();var Ve=this.strict;this.strict=!0,this.parseClassId(O,ae),this.parseClassSuper(O);var Le=this.enterClassBody(),We=this.startNode(),lt=!1;for(We.body=[],this.expect(F.braceL);this.type!==F.braceR;){var ut=this.parseClassElement(O.superClass!==null);ut&&(We.body.push(ut),ut.type==="MethodDefinition"&&ut.kind==="constructor"?(lt&&this.raiseRecoverable(ut.start,"Duplicate constructor in the same class"),lt=!0):ut.key&&ut.key.type==="PrivateIdentifier"&&Rr(Le,ut)&&this.raiseRecoverable(ut.key.start,"Identifier '#"+ut.key.name+"' has already been declared"))}return this.strict=Ve,this.next(),O.body=this.finishNode(We,"ClassBody"),this.exitClassBody(),this.finishNode(O,ae?"ClassDeclaration":"ClassExpression")},mt.parseClassElement=function(O){if(this.eat(F.semi))return null;var ae=this.options.ecmaVersion,Ve=this.startNode(),Le="",We=!1,lt=!1,ut="method",$t=!1;if(this.eatContextual("static")){if(ae>=13&&this.eat(F.braceL))return this.parseClassStaticBlock(Ve),Ve;this.isClassElementNameStart()||this.type===F.star?$t=!0:Le="static"}if(Ve.static=$t,!Le&&ae>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===F.star)&&!this.canInsertSemicolon()?lt=!0:Le="async"),!Le&&(ae>=9||!lt)&&this.eat(F.star)&&(We=!0),!Le&&!lt&&!We){var Dt=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?ut=Dt:Le=Dt)}if(Le?(Ve.computed=!1,Ve.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),Ve.key.name=Le,this.finishNode(Ve.key,"Identifier")):this.parseClassElementName(Ve),ae<13||this.type===F.parenL||ut!=="method"||We||lt){var er=!Ve.static&&Er(Ve,"constructor"),Jt=er&&O;er&&ut!=="method"&&this.raise(Ve.key.start,"Constructor can't have get/set modifier"),Ve.kind=er?"constructor":ut,this.parseClassMethod(Ve,We,lt,Jt)}else this.parseClassField(Ve);return Ve},mt.isClassElementNameStart=function(){return this.type===F.name||this.type===F.privateId||this.type===F.num||this.type===F.string||this.type===F.bracketL||this.type.keyword},mt.parseClassElementName=function(O){this.type===F.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),O.computed=!1,O.key=this.parsePrivateIdent()):this.parsePropertyName(O)},mt.parseClassMethod=function(O,ae,Ve,Le){var We=O.key;O.kind==="constructor"?(ae&&this.raise(We.start,"Constructor can't be a generator"),Ve&&this.raise(We.start,"Constructor can't be an async method")):O.static&&Er(O,"prototype")&&this.raise(We.start,"Classes may not have a static property named prototype");var lt=O.value=this.parseMethod(ae,Ve,Le);return O.kind==="get"&<.params.length!==0&&this.raiseRecoverable(lt.start,"getter should have no params"),O.kind==="set"&<.params.length!==1&&this.raiseRecoverable(lt.start,"setter should have exactly one param"),O.kind==="set"&<.params[0].type==="RestElement"&&this.raiseRecoverable(lt.params[0].start,"Setter cannot use rest params"),this.finishNode(O,"MethodDefinition")},mt.parseClassField=function(O){if(Er(O,"constructor")?this.raise(O.key.start,"Classes can't have a field named 'constructor'"):O.static&&Er(O,"prototype")&&this.raise(O.key.start,"Classes can't have a static field named 'prototype'"),this.eat(F.eq)){var ae=this.currentThisScope(),Ve=ae.inClassFieldInit;ae.inClassFieldInit=!0,O.value=this.parseMaybeAssign(),ae.inClassFieldInit=Ve}else O.value=null;return this.semicolon(),this.finishNode(O,"PropertyDefinition")},mt.parseClassStaticBlock=function(O){O.body=[];var ae=this.labels;for(this.labels=[],this.enterScope(qt|yt);this.type!==F.braceR;){var Ve=this.parseStatement(null);O.body.push(Ve)}return this.next(),this.exitScope(),this.labels=ae,this.finishNode(O,"StaticBlock")},mt.parseClassId=function(O,ae){this.type===F.name?(O.id=this.parseIdent(),ae&&this.checkLValSimple(O.id,et,!1)):(ae===!0&&this.unexpected(),O.id=null)},mt.parseClassSuper=function(O){O.superClass=this.eat(F._extends)?this.parseExprSubscripts(null,!1):null},mt.enterClassBody=function(){var O={declared:Object.create(null),used:[]};return this.privateNameStack.push(O),O.declared},mt.exitClassBody=function(){var O=this.privateNameStack.pop(),ae=O.declared,Ve=O.used;if(this.options.checkPrivateFields)for(var Le=this.privateNameStack.length,We=Le===0?null:this.privateNameStack[Le-1],lt=0;lt<Ve.length;++lt){var ut=Ve[lt];Fe(ae,ut.name)||(We?We.used.push(ut):this.raiseRecoverable(ut.start,"Private field '#"+ut.name+"' must be declared in an enclosing class"))}};function Rr(O,ae){var Ve=ae.key.name,Le=O[Ve],We="true";return ae.type==="MethodDefinition"&&(ae.kind==="get"||ae.kind==="set")&&(We=(ae.static?"s":"i")+ae.kind),Le==="iget"&&We==="iset"||Le==="iset"&&We==="iget"||Le==="sget"&&We==="sset"||Le==="sset"&&We==="sget"?(O[Ve]="true",!1):Le?!0:(O[Ve]=We,!1)}function Er(O,ae){var Ve=O.computed,Le=O.key;return!Ve&&(Le.type==="Identifier"&&Le.name===ae||Le.type==="Literal"&&Le.value===ae)}mt.parseExportAllDeclaration=function(O,ae){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(O.exported=this.parseModuleExportName(),this.checkExport(ae,O.exported,this.lastTokStart)):O.exported=null),this.expectContextual("from"),this.type!==F.string&&this.unexpected(),O.source=this.parseExprAtom(),this.semicolon(),this.finishNode(O,"ExportAllDeclaration")},mt.parseExport=function(O,ae){if(this.next(),this.eat(F.star))return this.parseExportAllDeclaration(O,ae);if(this.eat(F._default))return this.checkExport(ae,"default",this.lastTokStart),O.declaration=this.parseExportDefaultDeclaration(),this.finishNode(O,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())O.declaration=this.parseExportDeclaration(O),O.declaration.type==="VariableDeclaration"?this.checkVariableExport(ae,O.declaration.declarations):this.checkExport(ae,O.declaration.id,O.declaration.id.start),O.specifiers=[],O.source=null;else{if(O.declaration=null,O.specifiers=this.parseExportSpecifiers(ae),this.eatContextual("from"))this.type!==F.string&&this.unexpected(),O.source=this.parseExprAtom();else{for(var Ve=0,Le=O.specifiers;Ve<Le.length;Ve+=1){var We=Le[Ve];this.checkUnreserved(We.local),this.checkLocalExport(We.local),We.local.type==="Literal"&&this.raise(We.local.start,"A string literal cannot be used as an exported binding without `from`.")}O.source=null}this.semicolon()}return this.finishNode(O,"ExportNamedDeclaration")},mt.parseExportDeclaration=function(O){return this.parseStatement(null)},mt.parseExportDefaultDeclaration=function(){var O;if(this.type===F._function||(O=this.isAsyncFunction())){var ae=this.startNode();return this.next(),O&&this.next(),this.parseFunction(ae,Kt|or,!1,O)}else if(this.type===F._class){var Ve=this.startNode();return this.parseClass(Ve,"nullableID")}else{var Le=this.parseMaybeAssign();return this.semicolon(),Le}},mt.checkExport=function(O,ae,Ve){O&&(typeof ae!="string"&&(ae=ae.type==="Identifier"?ae.name:ae.value),Fe(O,ae)&&this.raiseRecoverable(Ve,"Duplicate export '"+ae+"'"),O[ae]=!0)},mt.checkPatternExport=function(O,ae){var Ve=ae.type;if(Ve==="Identifier")this.checkExport(O,ae,ae.start);else if(Ve==="ObjectPattern")for(var Le=0,We=ae.properties;Le<We.length;Le+=1){var lt=We[Le];this.checkPatternExport(O,lt)}else if(Ve==="ArrayPattern")for(var ut=0,$t=ae.elements;ut<$t.length;ut+=1){var Dt=$t[ut];Dt&&this.checkPatternExport(O,Dt)}else Ve==="Property"?this.checkPatternExport(O,ae.value):Ve==="AssignmentPattern"?this.checkPatternExport(O,ae.left):Ve==="RestElement"&&this.checkPatternExport(O,ae.argument)},mt.checkVariableExport=function(O,ae){if(O)for(var Ve=0,Le=ae;Ve<Le.length;Ve+=1){var We=Le[Ve];this.checkPatternExport(O,We.id)}},mt.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()},mt.parseExportSpecifier=function(O){var ae=this.startNode();return ae.local=this.parseModuleExportName(),ae.exported=this.eatContextual("as")?this.parseModuleExportName():ae.local,this.checkExport(O,ae.exported,ae.exported.start),this.finishNode(ae,"ExportSpecifier")},mt.parseExportSpecifiers=function(O){var ae=[],Ve=!0;for(this.expect(F.braceL);!this.eat(F.braceR);){if(Ve)Ve=!1;else if(this.expect(F.comma),this.afterTrailingComma(F.braceR))break;ae.push(this.parseExportSpecifier(O))}return ae},mt.parseImport=function(O){return this.next(),this.type===F.string?(O.specifiers=Zt,O.source=this.parseExprAtom()):(O.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),O.source=this.type===F.string?this.parseExprAtom():this.unexpected()),this.semicolon(),this.finishNode(O,"ImportDeclaration")},mt.parseImportSpecifier=function(){var O=this.startNode();return O.imported=this.parseModuleExportName(),this.eatContextual("as")?O.local=this.parseIdent():(this.checkUnreserved(O.imported),O.local=O.imported),this.checkLValSimple(O.local,et),this.finishNode(O,"ImportSpecifier")},mt.parseImportDefaultSpecifier=function(){var O=this.startNode();return O.local=this.parseIdent(),this.checkLValSimple(O.local,et),this.finishNode(O,"ImportDefaultSpecifier")},mt.parseImportNamespaceSpecifier=function(){var O=this.startNode();return this.next(),this.expectContextual("as"),O.local=this.parseIdent(),this.checkLValSimple(O.local,et),this.finishNode(O,"ImportNamespaceSpecifier")},mt.parseImportSpecifiers=function(){var O=[],ae=!0;if(this.type===F.name&&(O.push(this.parseImportDefaultSpecifier()),!this.eat(F.comma)))return O;if(this.type===F.star)return O.push(this.parseImportNamespaceSpecifier()),O;for(this.expect(F.braceL);!this.eat(F.braceR);){if(ae)ae=!1;else if(this.expect(F.comma),this.afterTrailingComma(F.braceR))break;O.push(this.parseImportSpecifier())}return O},mt.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===F.string){var O=this.parseLiteral(this.value);return Ge.test(O.value)&&this.raise(O.start,"An export name cannot include a lone surrogate."),O}return this.parseIdent(!0)},mt.adaptDirectivePrologue=function(O){for(var ae=0;ae<O.length&&this.isDirectiveCandidate(O[ae]);++ae)O[ae].directive=O[ae].expression.raw.slice(1,-1)},mt.isDirectiveCandidate=function(O){return this.options.ecmaVersion>=5&&O.type==="ExpressionStatement"&&O.expression.type==="Literal"&&typeof O.expression.value=="string"&&(this.input[O.start]==='"'||this.input[O.start]==="'")};var gr=Rt.prototype;gr.toAssignable=function(O,ae,Ve){if(this.options.ecmaVersion>=6&&O)switch(O.type){case"Identifier":this.inAsync&&O.name==="await"&&this.raise(O.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":O.type="ObjectPattern",Ve&&this.checkPatternErrors(Ve,!0);for(var Le=0,We=O.properties;Le<We.length;Le+=1){var lt=We[Le];this.toAssignable(lt,ae),lt.type==="RestElement"&&(lt.argument.type==="ArrayPattern"||lt.argument.type==="ObjectPattern")&&this.raise(lt.argument.start,"Unexpected token")}break;case"Property":O.kind!=="init"&&this.raise(O.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(O.value,ae);break;case"ArrayExpression":O.type="ArrayPattern",Ve&&this.checkPatternErrors(Ve,!0),this.toAssignableList(O.elements,ae);break;case"SpreadElement":O.type="RestElement",this.toAssignable(O.argument,ae),O.argument.type==="AssignmentPattern"&&this.raise(O.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":O.operator!=="="&&this.raise(O.left.end,"Only '=' operator can be used for specifying default value."),O.type="AssignmentPattern",delete O.operator,this.toAssignable(O.left,ae);break;case"ParenthesizedExpression":this.toAssignable(O.expression,ae,Ve);break;case"ChainExpression":this.raiseRecoverable(O.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!ae)break;default:this.raise(O.start,"Assigning to rvalue")}else Ve&&this.checkPatternErrors(Ve,!0);return O},gr.toAssignableList=function(O,ae){for(var Ve=O.length,Le=0;Le<Ve;Le++){var We=O[Le];We&&this.toAssignable(We,ae)}if(Ve){var lt=O[Ve-1];this.options.ecmaVersion===6&&ae&<&<.type==="RestElement"&<.argument.type!=="Identifier"&&this.unexpected(lt.argument.start)}return O},gr.parseSpread=function(O){var ae=this.startNode();return this.next(),ae.argument=this.parseMaybeAssign(!1,O),this.finishNode(ae,"SpreadElement")},gr.parseRestBinding=function(){var O=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==F.name&&this.unexpected(),O.argument=this.parseBindingAtom(),this.finishNode(O,"RestElement")},gr.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case F.bracketL:var O=this.startNode();return this.next(),O.elements=this.parseBindingList(F.bracketR,!0,!0),this.finishNode(O,"ArrayPattern");case F.braceL:return this.parseObj(!0)}return this.parseIdent()},gr.parseBindingList=function(O,ae,Ve,Le){for(var We=[],lt=!0;!this.eat(O);)if(lt?lt=!1:this.expect(F.comma),ae&&this.type===F.comma)We.push(null);else{if(Ve&&this.afterTrailingComma(O))break;if(this.type===F.ellipsis){var ut=this.parseRestBinding();this.parseBindingListItem(ut),We.push(ut),this.type===F.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(O);break}else We.push(this.parseAssignableListItem(Le))}return We},gr.parseAssignableListItem=function(O){var ae=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(ae),ae},gr.parseBindingListItem=function(O){return O},gr.parseMaybeDefault=function(O,ae,Ve){if(Ve=Ve||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(F.eq))return Ve;var Le=this.startNodeAt(O,ae);return Le.left=Ve,Le.right=this.parseMaybeAssign(),this.finishNode(Le,"AssignmentPattern")},gr.checkLValSimple=function(O,ae,Ve){ae===void 0&&(ae=Ke);var Le=ae!==Ke;switch(O.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(O.name)&&this.raiseRecoverable(O.start,(Le?"Binding ":"Assigning to ")+O.name+" in strict mode"),Le&&(ae===et&&O.name==="let"&&this.raiseRecoverable(O.start,"let is disallowed as a lexically bound name"),Ve&&(Fe(Ve,O.name)&&this.raiseRecoverable(O.start,"Argument name clash"),Ve[O.name]=!0),ae!==dt&&this.declareName(O.name,ae,O.start));break;case"ChainExpression":this.raiseRecoverable(O.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":Le&&this.raiseRecoverable(O.start,"Binding member expression");break;case"ParenthesizedExpression":return Le&&this.raiseRecoverable(O.start,"Binding parenthesized expression"),this.checkLValSimple(O.expression,ae,Ve);default:this.raise(O.start,(Le?"Binding":"Assigning to")+" rvalue")}},gr.checkLValPattern=function(O,ae,Ve){switch(ae===void 0&&(ae=Ke),O.type){case"ObjectPattern":for(var Le=0,We=O.properties;Le<We.length;Le+=1){var lt=We[Le];this.checkLValInnerPattern(lt,ae,Ve)}break;case"ArrayPattern":for(var ut=0,$t=O.elements;ut<$t.length;ut+=1){var Dt=$t[ut];Dt&&this.checkLValInnerPattern(Dt,ae,Ve)}break;default:this.checkLValSimple(O,ae,Ve)}},gr.checkLValInnerPattern=function(O,ae,Ve){switch(ae===void 0&&(ae=Ke),O.type){case"Property":this.checkLValInnerPattern(O.value,ae,Ve);break;case"AssignmentPattern":this.checkLValPattern(O.left,ae,Ve);break;case"RestElement":this.checkLValPattern(O.argument,ae,Ve);break;default:this.checkLValPattern(O,ae,Ve)}};var xr=function(ae,Ve,Le,We,lt){this.token=ae,this.isExpr=!!Ve,this.preserveSpace=!!Le,this.override=We,this.generator=!!lt},tr={b_stat:new xr("{",!1),b_expr:new xr("{",!0),b_tmpl:new xr("${",!1),p_stat:new xr("(",!1),p_expr:new xr("(",!0),q_tmpl:new xr("`",!0,!0,function(O){return O.tryReadTemplateToken()}),f_stat:new xr("function",!1),f_expr:new xr("function",!0),f_expr_gen:new xr("function",!0,!1,null,!0),f_gen:new xr("function",!1,!1,null,!0)},$r=Rt.prototype;$r.initialContext=function(){return[tr.b_stat]},$r.curContext=function(){return this.context[this.context.length-1]},$r.braceIsBlock=function(O){var ae=this.curContext();return ae===tr.f_expr||ae===tr.f_stat?!0:O===F.colon&&(ae===tr.b_stat||ae===tr.b_expr)?!ae.isExpr:O===F._return||O===F.name&&this.exprAllowed?te.test(this.input.slice(this.lastTokEnd,this.start)):O===F._else||O===F.semi||O===F.eof||O===F.parenR||O===F.arrow?!0:O===F.braceL?ae===tr.b_stat:O===F._var||O===F._const||O===F.name?!1:!this.exprAllowed},$r.inGeneratorContext=function(){for(var O=this.context.length-1;O>=1;O--){var ae=this.context[O];if(ae.token==="function")return ae.generator}return!1},$r.updateContext=function(O){var ae,Ve=this.type;Ve.keyword&&O===F.dot?this.exprAllowed=!1:(ae=Ve.updateContext)?ae.call(this,O):this.exprAllowed=Ve.beforeExpr},$r.overrideContext=function(O){this.curContext()!==O&&(this.context[this.context.length-1]=O)},F.parenR.updateContext=F.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var O=this.context.pop();O===tr.b_stat&&this.curContext().token==="function"&&(O=this.context.pop()),this.exprAllowed=!O.isExpr},F.braceL.updateContext=function(O){this.context.push(this.braceIsBlock(O)?tr.b_stat:tr.b_expr),this.exprAllowed=!0},F.dollarBraceL.updateContext=function(){this.context.push(tr.b_tmpl),this.exprAllowed=!0},F.parenL.updateContext=function(O){var ae=O===F._if||O===F._for||O===F._with||O===F._while;this.context.push(ae?tr.p_stat:tr.p_expr),this.exprAllowed=!0},F.incDec.updateContext=function(){},F._function.updateContext=F._class.updateContext=function(O){O.beforeExpr&&O!==F._else&&!(O===F.semi&&this.curContext()!==tr.p_stat)&&!(O===F._return&&te.test(this.input.slice(this.lastTokEnd,this.start)))&&!((O===F.colon||O===F.braceL)&&this.curContext()===tr.b_stat)?this.context.push(tr.f_expr):this.context.push(tr.f_stat),this.exprAllowed=!1},F.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0},F.backQuote.updateContext=function(){this.curContext()===tr.q_tmpl?this.context.pop():this.context.push(tr.q_tmpl),this.exprAllowed=!1},F.star.updateContext=function(O){if(O===F._function){var ae=this.context.length-1;this.context[ae]===tr.f_expr?this.context[ae]=tr.f_expr_gen:this.context[ae]=tr.f_gen}this.exprAllowed=!0},F.name.updateContext=function(O){var ae=!1;this.options.ecmaVersion>=6&&O!==F.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(ae=!0),this.exprAllowed=ae};var Xt=Rt.prototype;Xt.checkPropClash=function(O,ae,Ve){if(!(this.options.ecmaVersion>=9&&O.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(O.computed||O.method||O.shorthand))){var Le=O.key,We;switch(Le.type){case"Identifier":We=Le.name;break;case"Literal":We=String(Le.value);break;default:return}var lt=O.kind;if(this.options.ecmaVersion>=6){We==="__proto__"&<==="init"&&(ae.proto&&(Ve?Ve.doubleProto<0&&(Ve.doubleProto=Le.start):this.raiseRecoverable(Le.start,"Redefinition of __proto__ property")),ae.proto=!0);return}We="$"+We;var ut=ae[We];if(ut){var $t;lt==="init"?$t=this.strict&&ut.init||ut.get||ut.set:$t=ut.init||ut[lt],$t&&this.raiseRecoverable(Le.start,"Redefinition of property")}else ut=ae[We]={init:!1,get:!1,set:!1};ut[lt]=!0}},Xt.parseExpression=function(O,ae){var Ve=this.start,Le=this.startLoc,We=this.parseMaybeAssign(O,ae);if(this.type===F.comma){var lt=this.startNodeAt(Ve,Le);for(lt.expressions=[We];this.eat(F.comma);)lt.expressions.push(this.parseMaybeAssign(O,ae));return this.finishNode(lt,"SequenceExpression")}return We},Xt.parseMaybeAssign=function(O,ae,Ve){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(O);this.exprAllowed=!1}var Le=!1,We=-1,lt=-1,ut=-1;ae?(We=ae.parenthesizedAssign,lt=ae.trailingComma,ut=ae.doubleProto,ae.parenthesizedAssign=ae.trailingComma=-1):(ae=new dr,Le=!0);var $t=this.start,Dt=this.startLoc;(this.type===F.parenL||this.type===F.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=O==="await");var er=this.parseMaybeConditional(O,ae);if(Ve&&(er=Ve.call(this,er,$t,Dt)),this.type.isAssign){var Jt=this.startNodeAt($t,Dt);return Jt.operator=this.value,this.type===F.eq&&(er=this.toAssignable(er,!1,ae)),Le||(ae.parenthesizedAssign=ae.trailingComma=ae.doubleProto=-1),ae.shorthandAssign>=er.start&&(ae.shorthandAssign=-1),this.type===F.eq?this.checkLValPattern(er):this.checkLValSimple(er),Jt.left=er,this.next(),Jt.right=this.parseMaybeAssign(O),ut>-1&&(ae.doubleProto=ut),this.finishNode(Jt,"AssignmentExpression")}else Le&&this.checkExpressionErrors(ae,!0);return We>-1&&(ae.parenthesizedAssign=We),lt>-1&&(ae.trailingComma=lt),er},Xt.parseMaybeConditional=function(O,ae){var Ve=this.start,Le=this.startLoc,We=this.parseExprOps(O,ae);if(this.checkExpressionErrors(ae))return We;if(this.eat(F.question)){var lt=this.startNodeAt(Ve,Le);return lt.test=We,lt.consequent=this.parseMaybeAssign(),this.expect(F.colon),lt.alternate=this.parseMaybeAssign(O),this.finishNode(lt,"ConditionalExpression")}return We},Xt.parseExprOps=function(O,ae){var Ve=this.start,Le=this.startLoc,We=this.parseMaybeUnary(ae,!1,!1,O);return this.checkExpressionErrors(ae)||We.start===Ve&&We.type==="ArrowFunctionExpression"?We:this.parseExprOp(We,Ve,Le,-1,O)},Xt.parseExprOp=function(O,ae,Ve,Le,We){var lt=this.type.binop;if(lt!=null&&(!We||this.type!==F._in)&<>Le){var ut=this.type===F.logicalOR||this.type===F.logicalAND,$t=this.type===F.coalesce;$t&&(lt=F.logicalAND.binop);var Dt=this.value;this.next();var er=this.start,Jt=this.startLoc,yr=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,We),er,Jt,lt,We),Ur=this.buildBinary(ae,Ve,O,yr,Dt,ut||$t);return(ut&&this.type===F.coalesce||$t&&(this.type===F.logicalOR||this.type===F.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(Ur,ae,Ve,Le,We)}return O},Xt.buildBinary=function(O,ae,Ve,Le,We,lt){Le.type==="PrivateIdentifier"&&this.raise(Le.start,"Private identifier can only be left side of binary expression");var ut=this.startNodeAt(O,ae);return ut.left=Ve,ut.operator=We,ut.right=Le,this.finishNode(ut,lt?"LogicalExpression":"BinaryExpression")},Xt.parseMaybeUnary=function(O,ae,Ve,Le){var We=this.start,lt=this.startLoc,ut;if(this.isContextual("await")&&this.canAwait)ut=this.parseAwait(Le),ae=!0;else if(this.type.prefix){var $t=this.startNode(),Dt=this.type===F.incDec;$t.operator=this.value,$t.prefix=!0,this.next(),$t.argument=this.parseMaybeUnary(null,!0,Dt,Le),this.checkExpressionErrors(O,!0),Dt?this.checkLValSimple($t.argument):this.strict&&$t.operator==="delete"&&mr($t.argument)?this.raiseRecoverable($t.start,"Deleting local variable in strict mode"):$t.operator==="delete"&&jr($t.argument)?this.raiseRecoverable($t.start,"Private fields can not be deleted"):ae=!0,ut=this.finishNode($t,Dt?"UpdateExpression":"UnaryExpression")}else if(!ae&&this.type===F.privateId)(Le||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),ut=this.parsePrivateIdent(),this.type!==F._in&&this.unexpected();else{if(ut=this.parseExprSubscripts(O,Le),this.checkExpressionErrors(O))return ut;for(;this.type.postfix&&!this.canInsertSemicolon();){var er=this.startNodeAt(We,lt);er.operator=this.value,er.prefix=!1,er.argument=ut,this.checkLValSimple(ut),this.next(),ut=this.finishNode(er,"UpdateExpression")}}if(!Ve&&this.eat(F.starstar))if(ae)this.unexpected(this.lastTokStart);else return this.buildBinary(We,lt,ut,this.parseMaybeUnary(null,!1,!1,Le),"**",!1);else return ut};function mr(O){return O.type==="Identifier"||O.type==="ParenthesizedExpression"&&mr(O.expression)}function jr(O){return O.type==="MemberExpression"&&O.property.type==="PrivateIdentifier"||O.type==="ChainExpression"&&jr(O.expression)||O.type==="ParenthesizedExpression"&&jr(O.expression)}Xt.parseExprSubscripts=function(O,ae){var Ve=this.start,Le=this.startLoc,We=this.parseExprAtom(O,ae);if(We.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return We;var lt=this.parseSubscripts(We,Ve,Le,!1,ae);return O&<.type==="MemberExpression"&&(O.parenthesizedAssign>=lt.start&&(O.parenthesizedAssign=-1),O.parenthesizedBind>=lt.start&&(O.parenthesizedBind=-1),O.trailingComma>=lt.start&&(O.trailingComma=-1)),lt},Xt.parseSubscripts=function(O,ae,Ve,Le,We){for(var lt=this.options.ecmaVersion>=8&&O.type==="Identifier"&&O.name==="async"&&this.lastTokEnd===O.end&&!this.canInsertSemicolon()&&O.end-O.start===5&&this.potentialArrowAt===O.start,ut=!1;;){var $t=this.parseSubscript(O,ae,Ve,Le,lt,ut,We);if($t.optional&&(ut=!0),$t===O||$t.type==="ArrowFunctionExpression"){if(ut){var Dt=this.startNodeAt(ae,Ve);Dt.expression=$t,$t=this.finishNode(Dt,"ChainExpression")}return $t}O=$t}},Xt.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(F.arrow)},Xt.parseSubscriptAsyncArrow=function(O,ae,Ve,Le){return this.parseArrowExpression(this.startNodeAt(O,ae),Ve,!0,Le)},Xt.parseSubscript=function(O,ae,Ve,Le,We,lt,ut){var $t=this.options.ecmaVersion>=11,Dt=$t&&this.eat(F.questionDot);Le&&Dt&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var er=this.eat(F.bracketL);if(er||Dt&&this.type!==F.parenL&&this.type!==F.backQuote||this.eat(F.dot)){var Jt=this.startNodeAt(ae,Ve);Jt.object=O,er?(Jt.property=this.parseExpression(),this.expect(F.bracketR)):this.type===F.privateId&&O.type!=="Super"?Jt.property=this.parsePrivateIdent():Jt.property=this.parseIdent(this.options.allowReserved!=="never"),Jt.computed=!!er,$t&&(Jt.optional=Dt),O=this.finishNode(Jt,"MemberExpression")}else if(!Le&&this.eat(F.parenL)){var yr=new dr,Ur=this.yieldPos,rn=this.awaitPos,Wr=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var mn=this.parseExprList(F.parenR,this.options.ecmaVersion>=8,!1,yr);if(We&&!Dt&&this.shouldParseAsyncArrow())return this.checkPatternErrors(yr,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=Ur,this.awaitPos=rn,this.awaitIdentPos=Wr,this.parseSubscriptAsyncArrow(ae,Ve,mn,ut);this.checkExpressionErrors(yr,!0),this.yieldPos=Ur||this.yieldPos,this.awaitPos=rn||this.awaitPos,this.awaitIdentPos=Wr||this.awaitIdentPos;var Kr=this.startNodeAt(ae,Ve);Kr.callee=O,Kr.arguments=mn,$t&&(Kr.optional=Dt),O=this.finishNode(Kr,"CallExpression")}else if(this.type===F.backQuote){(Dt||lt)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var Yr=this.startNodeAt(ae,Ve);Yr.tag=O,Yr.quasi=this.parseTemplate({isTagged:!0}),O=this.finishNode(Yr,"TaggedTemplateExpression")}return O},Xt.parseExprAtom=function(O,ae,Ve){this.type===F.slash&&this.readRegexp();var Le,We=this.potentialArrowAt===this.start;switch(this.type){case F._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),Le=this.startNode(),this.next(),this.type===F.parenL&&!this.allowDirectSuper&&this.raise(Le.start,"super() call outside constructor of a subclass"),this.type!==F.dot&&this.type!==F.bracketL&&this.type!==F.parenL&&this.unexpected(),this.finishNode(Le,"Super");case F._this:return Le=this.startNode(),this.next(),this.finishNode(Le,"ThisExpression");case F.name:var lt=this.start,ut=this.startLoc,$t=this.containsEsc,Dt=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!$t&&Dt.name==="async"&&!this.canInsertSemicolon()&&this.eat(F._function))return this.overrideContext(tr.f_expr),this.parseFunction(this.startNodeAt(lt,ut),0,!1,!0,ae);if(We&&!this.canInsertSemicolon()){if(this.eat(F.arrow))return this.parseArrowExpression(this.startNodeAt(lt,ut),[Dt],!1,ae);if(this.options.ecmaVersion>=8&&Dt.name==="async"&&this.type===F.name&&!$t&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return Dt=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(F.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(lt,ut),[Dt],!0,ae)}return Dt;case F.regexp:var er=this.value;return Le=this.parseLiteral(er.value),Le.regex={pattern:er.pattern,flags:er.flags},Le;case F.num:case F.string:return this.parseLiteral(this.value);case F._null:case F._true:case F._false:return Le=this.startNode(),Le.value=this.type===F._null?null:this.type===F._true,Le.raw=this.type.keyword,this.next(),this.finishNode(Le,"Literal");case F.parenL:var Jt=this.start,yr=this.parseParenAndDistinguishExpression(We,ae);return O&&(O.parenthesizedAssign<0&&!this.isSimpleAssignTarget(yr)&&(O.parenthesizedAssign=Jt),O.parenthesizedBind<0&&(O.parenthesizedBind=Jt)),yr;case F.bracketL:return Le=this.startNode(),this.next(),Le.elements=this.parseExprList(F.bracketR,!0,!0,O),this.finishNode(Le,"ArrayExpression");case F.braceL:return this.overrideContext(tr.b_expr),this.parseObj(!1,O);case F._function:return Le=this.startNode(),this.next(),this.parseFunction(Le,0);case F._class:return this.parseClass(this.startNode(),!1);case F._new:return this.parseNew();case F.backQuote:return this.parseTemplate();case F._import:return this.options.ecmaVersion>=11?this.parseExprImport(Ve):this.unexpected();default:return this.parseExprAtomDefault()}},Xt.parseExprAtomDefault=function(){this.unexpected()},Xt.parseExprImport=function(O){var ae=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===F.parenL&&!O)return this.parseDynamicImport(ae);if(this.type===F.dot){var Ve=this.startNodeAt(ae.start,ae.loc&&ae.loc.start);return Ve.name="import",ae.meta=this.finishNode(Ve,"Identifier"),this.parseImportMeta(ae)}else this.unexpected()},Xt.parseDynamicImport=function(O){if(this.next(),O.source=this.parseMaybeAssign(),!this.eat(F.parenR)){var ae=this.start;this.eat(F.comma)&&this.eat(F.parenR)?this.raiseRecoverable(ae,"Trailing comma is not allowed in import()"):this.unexpected(ae)}return this.finishNode(O,"ImportExpression")},Xt.parseImportMeta=function(O){this.next();var ae=this.containsEsc;return O.property=this.parseIdent(!0),O.property.name!=="meta"&&this.raiseRecoverable(O.property.start,"The only valid meta property for import is 'import.meta'"),ae&&this.raiseRecoverable(O.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(O.start,"Cannot use 'import.meta' outside a module"),this.finishNode(O,"MetaProperty")},Xt.parseLiteral=function(O){var ae=this.startNode();return ae.value=O,ae.raw=this.input.slice(this.start,this.end),ae.raw.charCodeAt(ae.raw.length-1)===110&&(ae.bigint=ae.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(ae,"Literal")},Xt.parseParenExpression=function(){this.expect(F.parenL);var O=this.parseExpression();return this.expect(F.parenR),O},Xt.shouldParseArrow=function(O){return!this.canInsertSemicolon()},Xt.parseParenAndDistinguishExpression=function(O,ae){var Ve=this.start,Le=this.startLoc,We,lt=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var ut=this.start,$t=this.startLoc,Dt=[],er=!0,Jt=!1,yr=new dr,Ur=this.yieldPos,rn=this.awaitPos,Wr;for(this.yieldPos=0,this.awaitPos=0;this.type!==F.parenR;)if(er?er=!1:this.expect(F.comma),lt&&this.afterTrailingComma(F.parenR,!0)){Jt=!0;break}else if(this.type===F.ellipsis){Wr=this.start,Dt.push(this.parseParenItem(this.parseRestBinding())),this.type===F.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else Dt.push(this.parseMaybeAssign(!1,yr,this.parseParenItem));var mn=this.lastTokEnd,Kr=this.lastTokEndLoc;if(this.expect(F.parenR),O&&this.shouldParseArrow(Dt)&&this.eat(F.arrow))return this.checkPatternErrors(yr,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=Ur,this.awaitPos=rn,this.parseParenArrowList(Ve,Le,Dt,ae);(!Dt.length||Jt)&&this.unexpected(this.lastTokStart),Wr&&this.unexpected(Wr),this.checkExpressionErrors(yr,!0),this.yieldPos=Ur||this.yieldPos,this.awaitPos=rn||this.awaitPos,Dt.length>1?(We=this.startNodeAt(ut,$t),We.expressions=Dt,this.finishNodeAt(We,"SequenceExpression",mn,Kr)):We=Dt[0]}else We=this.parseParenExpression();if(this.options.preserveParens){var Yr=this.startNodeAt(Ve,Le);return Yr.expression=We,this.finishNode(Yr,"ParenthesizedExpression")}else return We},Xt.parseParenItem=function(O){return O},Xt.parseParenArrowList=function(O,ae,Ve,Le){return this.parseArrowExpression(this.startNodeAt(O,ae),Ve,!1,Le)};var gn=[];Xt.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var O=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===F.dot){var ae=this.startNodeAt(O.start,O.loc&&O.loc.start);ae.name="new",O.meta=this.finishNode(ae,"Identifier"),this.next();var Ve=this.containsEsc;return O.property=this.parseIdent(!0),O.property.name!=="target"&&this.raiseRecoverable(O.property.start,"The only valid meta property for new is 'new.target'"),Ve&&this.raiseRecoverable(O.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(O.start,"'new.target' can only be used in functions and class static block"),this.finishNode(O,"MetaProperty")}var Le=this.start,We=this.startLoc;return O.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),Le,We,!0,!1),this.eat(F.parenL)?O.arguments=this.parseExprList(F.parenR,this.options.ecmaVersion>=8,!1):O.arguments=gn,this.finishNode(O,"NewExpression")},Xt.parseTemplateElement=function(O){var ae=O.isTagged,Ve=this.startNode();return this.type===F.invalidTemplate?(ae||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),Ve.value={raw:this.value.replace(/\r\n?/g,`
|
|
1133
1133
|
`),cooked:null}):Ve.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
|
|
@@ -1145,7 +1145,7 @@ Defaulting to 2020, but this will stop working in the future.`)),e.ecmaVersion=1
|
|
|
1145
1145
|
`;break;default:t+=String.fromCharCode(n);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),e=this.pos}else++this.pos}},pp.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case"\\":++this.pos;break;case"$":if(this.input[this.pos+1]!=="{")break;case"`":return this.finishToken(types$1.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":this.input[this.pos+1]===`
|
|
1146
1146
|
`&&++this.pos;case`
|
|
1147
1147
|
`:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")},pp.readEscapedChar=function(t){var e=this.input.charCodeAt(++this.pos);switch(++this.pos,e){case 110:return`
|
|
1148
|
-
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return codePointToString(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),t){var n=this.pos-1;this.invalidStringToken(n,"Invalid escape sequence in template string")}default:if(e>=48&&e<=55){var o=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],l=parseInt(o,8);return l>255&&(o=o.slice(0,-1),l=parseInt(o,8)),this.pos+=o.length-1,e=this.input.charCodeAt(this.pos),(o!=="0"||e===56||e===57)&&(this.strict||t)&&this.invalidStringToken(this.pos-1-o.length,t?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(l)}return isNewLine(e)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(e)}},pp.readHexChar=function(t){var e=this.pos,n=this.readInt(16,t);return n===null&&this.invalidStringToken(e,"Bad character escape sequence"),n},pp.readWord1=function(){this.containsEsc=!1;for(var t="",e=!0,n=this.pos,o=this.options.ecmaVersion>=6;this.pos<this.input.length;){var l=this.fullCharCodeAtPos();if(isIdentifierChar(l,o))this.pos+=l<=65535?1:2;else if(l===92){this.containsEsc=!0,t+=this.input.slice(n,this.pos);var d=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var f=this.readCodePoint();(e?isIdentifierStart:isIdentifierChar)(f,o)||this.invalidStringToken(d,"Invalid Unicode escape"),t+=codePointToString(f),n=this.pos}else break;e=!1}return t+this.input.slice(n,this.pos)},pp.readWord=function(){var t=this.readWord1(),e=types$1.name;return this.keywords.test(t)&&(e=keywords[t]),this.finishToken(e,t)};var version="8.12.1";Parser.acorn={Parser,version,defaultOptions,Position,SourceLocation,getLineInfo,Node:Node$3,TokenType,tokTypes:types$1,keywordTypes:keywords,TokContext,tokContexts:types,isIdentifierChar,isIdentifierStart,Token,isNewLine,lineBreak,lineBreakG,nonASCIIwhitespace};var AcornJSX=__toESM(require_acorn_jsx(),1),attributeNames_default={acceptcharset:"acceptCharset",accesskey:"accessKey",allowfullscreen:"allowFullScreen",autocapitalize:"autoCapitalize",autocomplete:"autoComplete",autofocus:"autoFocus",autoplay:"autoPlay",cellpadding:"cellPadding",cellspacing:"cellSpacing",charset:"charSet",class:"className",colspan:"colSpan",contenteditable:"contentEditable",crossorigin:"crossOrigin",datetime:"dateTime",enctype:"encType",for:"htmlFor",formaction:"formAction",formenctype:"formEncType",formmethod:"formMethod",formnovalidate:"formNoValidate",formtarget:"formTarget",frameborder:"frameBorder",hreflang:"hrefLang",httpequiv:"httpEquiv",inputmode:"inputMode",keyparams:"keyParams",keytype:"keyType",marginheight:"marginHeight",marginwidth:"marginWidth",maxlength:"maxLength",mediagroup:"mediaGroup",minlength:"minLength",novalidate:"noValidate",radiogroup:"radioGroup",readonly:"readOnly",referrerpolicy:"referrerPolicy",rowspan:"rowSpan",spellcheck:"spellCheck",srcdoc:"srcDoc",srclang:"srcLang",srcset:"srcSet",tabindex:"tabIndex",usemap:"useMap"},VOID_ELEMENTS=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"],NO_WHITESPACE=["table","tbody","tfoot","thead","tr"];function canHaveChildren(t){return VOID_ELEMENTS.indexOf(t.toLowerCase())===-1}function canHaveWhitespace(t){return NO_WHITESPACE.indexOf(t.toLowerCase())!==-1}class NullishShortCircuit extends Error{constructor(e="Nullish value encountered"){super(e),this.name="NullishShortCircuit"}}var hash=(t="",e=16)=>{const n=String(t);let o=0;return n.split("").forEach(l=>{o=(o<<5)-o+l.charCodeAt(0),o&=o}),Math.abs(o).toString(e)},randomHash=()=>hash(Math.random().toString()),camelCase=t=>t.replace(/([A-Z])([A-Z])/g,"$1 $2").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[^a-zA-Z\u00C0-\u00ff]/g," ").toLowerCase().split(" ").filter(e=>e).map((e,n)=>n>0?e[0].toUpperCase()+e.slice(1):e).join(""),parseStyle=t=>{switch(typeof t){case"string":return t.split(";").filter(e=>e).reduce((e,n)=>{const o=n.slice(0,n.indexOf(":")).trim(),l=n.slice(n.indexOf(":")+1).trim();return{...e,[camelCase(o)]:l}},{});case"object":return t;default:return}},pathToArrayPath=t=>t==null||t===""?[]:t.split("."),resolveArrayPath=(t,e)=>{const[n,...o]=e;if(!(t==null||n==null))return o.length===0?t[n]:resolveArrayPath(t[n],o)},resolvePath=(t,e)=>resolveArrayPath(t,pathToArrayPath(e));function handleNaN(t){return Number.isNaN(t)?"NaN":t}class JsxParser extends React.Component{constructor(){super(...arguments);Qt(this,"ParsedChildren",null);Hr(this,lr,n=>{const o=Parser.extend(AcornJSX.default({autoCloseVoidElements:this.props.autoCloseVoidElements})),l=`<root>${n}</root>`;let d=[];try{d=o.parse(l,{ecmaVersion:"latest"}),d=d.body[0].expression.children||[]}catch(f){return this.props.showWarnings&&console.warn(f),this.props.onError&&this.props.onError(f),this.props.renderError?this.props.renderError({error:String(f)}):null}return d.map(f=>ir(this,rr).call(this,f)).filter(Boolean)});Hr(this,rr,(n,o)=>{var l,d;switch(n.type){case"JSXAttribute":return n.value===null?!0:ir(this,rr).call(this,n.value,o);case"JSXElement":case"JSXFragment":return ir(this,Zr).call(this,n,o);case"JSXExpressionContainer":return ir(this,rr).call(this,n.expression,o);case"JSXText":const f=this.props.disableKeyGeneration?void 0:randomHash();return this.props.disableFragments?n.value:React.createElement(React.Fragment,{key:f},n.value);case"ArrayExpression":return n.elements.map(A=>ir(this,rr).call(this,A,o));case"BinaryExpression":const g=ir(this,rr).call(this,n.left,o),b=ir(this,rr).call(this,n.right,o);let _;switch(n.operator){case"-":_=g-b;break;case"!=":_=g!=b;break;case"!==":_=g!==b;break;case"*":_=g*b;break;case"**":_=g**b;break;case"/":_=g/b;break;case"%":_=g%b;break;case"+":_=g+b;break;case"<":_=g<b;break;case"<=":_=g<=b;break;case"==":_=g==b;break;case"===":_=g===b;break;case">":_=g>b;break;case">=":_=g>=b;break;default:this.props.onError(new Error(`Unsupported binary operator: ${n.operator}`));return}return handleNaN(_);case"CallExpression":const S=ir(this,rr).call(this,n.callee,o);if(S===void 0){if(n.optional)throw new NullishShortCircuit;this.props.onError(new Error(`The expression '${n.callee}' could not be resolved, resulting in an undefined return value.`));return}return S(...n.arguments.map(A=>ir(this,rr).call(this,A,o)));case"ConditionalExpression":return ir(this,rr).call(this,n.test,o)?ir(this,rr).call(this,n.consequent,o):ir(this,rr).call(this,n.alternate,o);case"ExpressionStatement":return ir(this,rr).call(this,n.expression,o);case"Identifier":return n.name==="Infinity"?1/0:n.name==="-Infinity"?-1/0:n.name==="NaN"?NaN:o&&n.name in o?handleNaN(o[n.name]):handleNaN((this.props.bindings||{})[n.name]);case"Literal":return n.value;case"LogicalExpression":const R=ir(this,rr).call(this,n.left,o);return n.operator==="||"&&R?R:n.operator==="&&"&&R||n.operator==="||"&&!R?ir(this,rr).call(this,n.right,o):!1;case"MemberExpression":return ir(this,an).call(this,n,o);case"ChainExpression":return ir(this,nn).call(this,n,o);case"ObjectExpression":const C={};return n.properties.forEach(A=>{C[A.key.name||A.key.value]=ir(this,rr).call(this,A.value,o)}),C;case"TemplateElement":return n.value.cooked;case"TemplateLiteral":return[...n.expressions,...n.quasis].sort((A,M)=>A.start<M.start?-1:1).map(A=>ir(this,rr).call(this,A,o)).join("");case"UnaryExpression":const E=ir(this,rr).call(this,n.argument,o);switch(n.operator){case"+":return+E;case"-":return-E;case"!":return!E}return;case"ArrowFunctionExpression":return(n.async||n.generator)&&((d=(l=this.props).onError)==null||d.call(l,new Error("Async and generator arrow functions are not supported."))),(...A)=>{const M={...o};return n.params.forEach((I,j)=>{M[I.name]=A[j]}),ir(this,rr).call(this,n.body,M)};default:this.props.onError(new Error(`The expression type '${n.type}' is not supported.`));return}});Hr(this,nn,(n,o)=>{try{return ir(this,rr).call(this,n.expression,o)}catch(l){if(l instanceof NullishShortCircuit)return;throw l}});Hr(this,an,(n,o)=>{const l=ir(this,rr).call(this,n.object,o);let d;if(n.computed)d=ir(this,rr).call(this,n.property,o);else if(n.property.type==="Identifier")d=n.property.name;else{this.props.onError(new Error("Only simple MemberExpressions are supported."));return}if(l==null&&n.optional)throw new NullishShortCircuit;let f;try{f=l[d]}catch{this.props.onError(new Error(`The property '${d}' could not be resolved on the object '${l}'.`));return}return typeof f=="function"?f.bind(l):f});Hr(this,zr,n=>n.type==="JSXIdentifier"?n.name:`${ir(this,zr).call(this,n.object)}.${ir(this,zr).call(this,n.property)}`);Hr(this,Zr,(n,o)=>{const{allowUnknownElements:l,components:d,componentsOnly:f,onError:g}=this.props,{children:b=[]}=n,_=n.type==="JSXElement"?n.openingElement:n.openingFragment,{attributes:S=[]}=_,R=n.type==="JSXElement"?ir(this,zr).call(this,_.name):"",C=(this.props.blacklistedAttrs||[]).map(z=>z instanceof RegExp?z:new RegExp(z,"i")),E=(this.props.blacklistedTags||[]).map(z=>z.trim().toLowerCase()).filter(Boolean);if(/^(html|head|body)$/i.test(R))return b.map(z=>ir(this,Zr).call(this,z,o));const A=R.trim().toLowerCase();if(E.indexOf(A)!==-1)return g(new Error(`The tag <${R}> is blacklisted, and will not be rendered.`)),null;if(R!==""&&!resolvePath(d,R)){if(f)return g(new Error(`The component <${R}> is unrecognized, and will not be rendered.`)),this.props.renderUnrecognized(R);if(!l&&document.createElement(R)instanceof HTMLUnknownElement)return g(new Error(`The tag <${R}> is unrecognized in this browser, and will not be rendered.`)),this.props.renderUnrecognized(R)}let M,I=n.type==="JSXElement"?resolvePath(d,R):React.Fragment;if(I||canHaveChildren(R)){if(M=b.map(Q=>ir(this,rr).call(this,Q,o)),R.includes(".")){const V=R.split(".").reduce((F,te)=>F?F[te]:d==null?void 0:d[te],null);V&&(I=V)}!I&&!canHaveWhitespace(R)&&(M=M.filter(Q=>typeof Q!="string"||!/^\s*$/.test(Q)));const z=M.find(Q=>typeof Q=="function");M.length===0?M=void 0:z?M=z:M.length===1?[M]=M:M.length>1&&!this.props.disableKeyGeneration&&(M=M.map((Q,V)=>Q!=null&&Q.type&&!(Q!=null&&Q.key)?{...Q,key:Q.key||V}:Q))}const j={key:this.props.disableKeyGeneration?void 0:randomHash()};S.forEach(z=>{if(z.type==="JSXAttribute"){const Q=z.name.name,V=attributeNames_default[Q]||Q,F=ir(this,rr).call(this,z,o);C.filter(ne=>ne.test(V)).length===0&&(j[V]=F)}else if(z.type==="JSXSpreadAttribute"&&z.argument.type==="Identifier"||z.argument.type==="MemberExpression"){const Q=ir(this,rr).call(this,z.argument,o);typeof Q=="object"&&Object.keys(Q).forEach(V=>{const F=attributeNames_default[V]||V;C.filter(ne=>ne.test(F)).length===0&&(j[F]=Q[V])})}}),typeof j.style=="string"&&(j.style=parseStyle(j.style));const q=R.toLowerCase();return q==="option"&&(M=M.props.children),React.createElement(I||q,j,M)})}render(){const n=(this.props.jsx||"").trim().replace(/<!DOCTYPE([^>]*)>/g,"");this.ParsedChildren=ir(this,lr).call(this,n);const o=[...new Set(["jsx-parser",...String(this.props.className).split(" ")])].filter(Boolean).join(" ");return this.props.renderInWrapper?React.createElement("div",{className:o},this.ParsedChildren):this.ParsedChildren}}lr=new WeakMap,rr=new WeakMap,nn=new WeakMap,an=new WeakMap,zr=new WeakMap,Zr=new WeakMap,Qt(JsxParser,"displayName","JsxParser"),Qt(JsxParser,"defaultProps",{allowUnknownElements:!0,autoCloseVoidElements:!1,bindings:{},blacklistedAttrs:[/^on.+/i],blacklistedTags:["script"],className:"",components:{},componentsOnly:!1,disableFragments:!1,disableKeyGeneration:!1,jsx:"",onError:()=>{},showWarnings:!1,renderError:void 0,renderInWrapper:!0,renderUnrecognized:()=>null});var source_default=JsxParser;const CountryFlag=({countryCode:t,className:e=""})=>{const[n,o]=React.useState(null),[l,d]=React.useState(!1);return React.useEffect(()=>{if(!t)return;const g=`https://purecatamphetamine.github.io/country-flag-icons/3x2/${t.toUpperCase()}.svg`;fetch(g,{method:"HEAD"}).then(b=>{b.ok?(o(g),d(!1)):d(!0)}).catch(()=>{d(!0)})},[t]),l||!n?jsxRuntime.jsx("span",{className:e,children:t}):jsxRuntime.jsx("img",{src:n,alt:`${t} flag`,className:`inline-block ${e}`,style:{width:"24px",height:"auto"}})};function ProductCard({applicationId:t,product:e,viewProductLink:n,defaultOpportunityNumber:o="",onAddToCart:l,addingToCart:d=!1,shopifyHostname:f,customAction:g=jsxRuntime.jsx(jsxRuntime.Fragment,{})}){var at,ot,Ue,Ct,Je,yt,Mt,qt,Ht,Ft,Ke,it;const b=React.useRef(null),_=useIntersectionObserver({elementRef:b,threshold:.1,rootMargin:"100px",freezeOnceVisible:!0}),{toast:S}=useToast(),[R,C]=React.useState(1),[E,A]=React.useState(null),[M,I]=React.useState(0),[j,q]=React.useState(!1),[z,Q]=React.useState(!1),[V,F]=React.useState(!1),[te]=usePutV4ResellerByRouteResellerIdProductAndRandmarSkuRequisitionMutation(),[ne,se]=React.useState(!1),[ge]=usePostV4ResellerByRouteResellerIdProductAndRandmarSkuShopifyMutation(),{data:oe,isLoading:Ae,isFetching:je}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:t},{skip:!t||!_}),Ne=((at=e==null?void 0:e.Distribution)==null?void 0:at.Cost)||0,Oe=((ot=e==null?void 0:e.Distribution)==null?void 0:ot.RegularPrice)||0,Fe=((Ue=e==null?void 0:e.Distribution)==null?void 0:Ue.Price)||0,ze=React.useMemo(()=>{var et;return!((et=e==null?void 0:e.Distribution)!=null&&et.Inventory)||e.Distribution.Inventory.length===0?0:e.Distribution.Inventory.reduce((ct,ft)=>ct+(ft.PurchaseOrderQuantity||0),0)},[(Ct=e==null?void 0:e.Distribution)==null?void 0:Ct.Inventory]);React.useEffect(()=>{C(1),A(null),I(0),q(!1)},[e==null?void 0:e.RandmarSKU]),React.useEffect(()=>{var et;if(e&&o){const ct=(et=e.Opportunities)==null?void 0:et.find(ft=>ft.BidNumber==o);ct&&$e(ct)&&A(ct)}},[e,o]),React.useEffect(()=>{if(!e)return;const et=E!=null&&E.Price?E.Price:Fe;I(Oe>0?Math.round((Oe-et)/Oe*100):0)},[e,E,Fe,Oe]),React.useEffect(()=>{d||C(1)},[d]);const $e=et=>{if(et.Active!==!0)return!1;const ct=new Date().toISOString().split("T")[0];return!(et.EndDate&&et.EndDate.split("T")[0]<ct||et.StartDate&&et.StartDate.split("T")[0]>ct)};if(React.useEffect(()=>{d||C(1)},[d]),!e||Ae||je)return jsxRuntime.jsx(Card,{children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between products-start mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx("div",{className:"h-10 w-24 flex products-center justify-end ml-4",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-28 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-6 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsx("div",{className:"w-60 h-40",children:jsxRuntime.jsx(Skeleton,{className:"w-full h-full rounded-lg"})})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsx("div",{className:"flex flex-1",children:jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-24 mb-3"}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-full rounded-md"})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col products-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-32 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24 mt-4"})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-col products-start gap-1 mb-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 products-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-10 flex-1 rounded-md"})]})]})]})});const Be=(e==null?void 0:e.Opportunities)||[],qe=Be.length>0,Ge=()=>{if(R==null){C(1);return}R>1&&C(R-1)},He=()=>{if(R==null){C(1);return}C(R+1)},Ze=et=>{const ct=Number.parseInt(et.target.value,10);if(!isNaN(ct)&&ct>0){C(ct);return}C(void 0)},tt=()=>{(R==null||R<1)&&C(1)},Ye=()=>{z||!(oe!=null&&oe.IsReseller)||(Q(!0),te({routeResellerId:oe.ApplicationId??"",randmarSku:e.RandmarSKU??""}).then(et=>{if(et.error){console.error(et.error),S({title:"Error",description:"Error submitting your qualification.",variant:"destructive"});return}S({title:"Success",description:"Qualification successfully submitted.",variant:"success"}),F(!1)}).catch(et=>{console.error(et),S({title:"Error",description:"Error submitting your qualification.",variant:"destructive"})}).finally(()=>{Q(!1)}))},Qe=((yt=(Je=e.Distribution)==null?void 0:Je.Inventory)==null?void 0:yt.reduce((et,ct)=>et+(ct.AvailableQuantity||0),0))||0,Xe=et=>{try{return new Date(et).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch(ct){return console.error(ct),et.split("T")[0]||"N/A"}},st=()=>{typeof l<"u"&&l({quantity:R??1,bidNumber:(E==null?void 0:E.BidNumber)??null})},rt=()=>{ne||!f||(se(!0),ge({routeResellerId:t??"",randmarSku:e.RandmarSKU??"",shopifyHostName:f}).then(et=>{if(et.error){console.error("Error syncing to Shopify:",et.error),S({title:"Product synced failed.",description:"Error syncing to Shopify:",variant:"destructive"});return}S({title:"Product synced",description:"Product synced to Shopify successfully",variant:"success"})}).catch(et=>{console.error("Error syncing to Shopify:",et),S({title:"Product synced failed.",description:"Error syncing to Shopify:",variant:"destructive"})}).finally(()=>{se(!1)}))};return jsxRuntime.jsx(Card,{className:"hover:shadow-lg transition-shadow",ref:b,children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between products-start mb-3",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-xl",children:e.Title||e.RandmarTitle}),jsxRuntime.jsx("div",{className:"w-24 h-10 flex products-center justify-end ml-4",children:jsxRuntime.jsx(PartnerLogo,{id:e.ManufacturerId,name:e.ManufacturerName,width:96,height:40})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[e.State&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.State==="Active"?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(Check,{size:"12",className:"mr-1.5"})," ",e.State]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.SerialNumber?"bg-green-50 text-green-700 hover:bg-green-50":"bg-yellow-50 text-yellow-700 hover:bg-yellow-50"}`,children:[jsxRuntime.jsx(QrCode,{size:"12",className:"mr-1.5"})," ",e.SerialNumber?"Serialized":"Unserialized"]}),e.TransparencyCode&&jsxRuntime.jsxs(Badge,{variant:"outline",className:"rounded-full px-3 bg-green-50 text-green-700 hover:bg-green-50",children:[jsxRuntime.jsx(CircleDashed,{size:"12",className:"mr-1.5"})," Transparency Code"]}),e.AvailableToBuy!==void 0&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.AvailableToBuy?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(ShoppingCart,{size:"12",className:"mr-1.5"})," ",e.AvailableToBuy?"Available":"Unavailable"]}),e.ManufacturerCategory!==void 0&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${(Mt=e.ManufacturerCategory)!=null&&Mt.QualificationRequired?"bg-blue-50 text-blue-700 hover:bg-blue-50":"bg-neutral-50 text-neutral-700 hover:bg-neutral-50"}`,children:[jsxRuntime.jsx(ShieldCheck,{size:"12",className:"mr-1.5"})," ",(qt=e.ManufacturerCategory)!=null&&qt.QualificationRequired?"Qualified Only":"Available to all"]}),e.ManufacturerId&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.AutoUpdate?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(RefreshCw,{size:"12",className:"mr-1.5"})," ",e.AutoUpdate?`Automatic Reorder (${e.MasterCarton})`:"Manually Reorders"]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.BodyHTML&&e.Title&&e.MAP?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(Store,{size:"12",className:"mr-1.5"})," ",e.BodyHTML&&e.Title&&e.MAP?"Shopify Ready":"Not Shopify Ready"]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-4 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"MPN"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.MPN||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"UPC"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.UPC||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Unit Weight"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.UnitWeight?`${formatNumber(e.UnitWeight)} lbs`:"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"text-sm text-muted-foreground",children:["MAP",jsxRuntime.jsx("span",{className:"text-primary",children:" / "}),"MSRP"]}),jsxRuntime.jsxs("div",{className:"font-medium",children:[e.MAP?formatMoney(e.MAP):"N/A",jsxRuntime.jsx("span",{className:"text-primary",children:" / "}),e.MSRP?formatMoney(e.MSRP):"N/A"]})]}),!!e.OverallPercentileRank&&!!e.ManufacturerPercentileRank&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Percentile"}),jsxRuntime.jsxs("div",{className:`font-medium flex products-center ${e.OverallPercentileRank>=80?"text-green-700":""}`,children:[formatNumber(Math.round(e.OverallPercentileRank))," Overall"]}),jsxRuntime.jsxs("div",{className:"font-light flex products-center text-sm",children:[formatNumber(Math.round(e.ManufacturerPercentileRank))," with Manufacturer"]})]}),e.CountryCodeOfOrigin&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Origin"}),jsxRuntime.jsxs("div",{className:"font-medium flex products-center",children:[jsxRuntime.jsx(CountryFlag,{countryCode:e.CountryCodeOfOrigin,className:"mr-2"}),e.CountryCodeOfOrigin]})]})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsx(ProductImage,{randmarSKU:e.RandmarSKU||"",alt:e.RandmarTitle||""})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsx("div",{className:"flex flex-1",children:qe&&e.Distribution&&jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx("div",{className:"flex products-center",children:"You have "+Be.length+(Be.length>1?" opportunities":" opportunity")+" for this product:"}),jsxRuntime.jsx("div",{className:"space-y-2 max-h-[200px] overflow-y-auto p-2 mt-1",children:Be.map((et,ct)=>jsxRuntime.jsxs("div",{className:`flex justify-between products-center rounded-lg transition-colors py-2 px-4 bg-purple-100 border border-muted
|
|
1148
|
+
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return codePointToString(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),t){var n=this.pos-1;this.invalidStringToken(n,"Invalid escape sequence in template string")}default:if(e>=48&&e<=55){var o=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],l=parseInt(o,8);return l>255&&(o=o.slice(0,-1),l=parseInt(o,8)),this.pos+=o.length-1,e=this.input.charCodeAt(this.pos),(o!=="0"||e===56||e===57)&&(this.strict||t)&&this.invalidStringToken(this.pos-1-o.length,t?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(l)}return isNewLine(e)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(e)}},pp.readHexChar=function(t){var e=this.pos,n=this.readInt(16,t);return n===null&&this.invalidStringToken(e,"Bad character escape sequence"),n},pp.readWord1=function(){this.containsEsc=!1;for(var t="",e=!0,n=this.pos,o=this.options.ecmaVersion>=6;this.pos<this.input.length;){var l=this.fullCharCodeAtPos();if(isIdentifierChar(l,o))this.pos+=l<=65535?1:2;else if(l===92){this.containsEsc=!0,t+=this.input.slice(n,this.pos);var d=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var f=this.readCodePoint();(e?isIdentifierStart:isIdentifierChar)(f,o)||this.invalidStringToken(d,"Invalid Unicode escape"),t+=codePointToString(f),n=this.pos}else break;e=!1}return t+this.input.slice(n,this.pos)},pp.readWord=function(){var t=this.readWord1(),e=types$1.name;return this.keywords.test(t)&&(e=keywords[t]),this.finishToken(e,t)};var version="8.12.1";Parser.acorn={Parser,version,defaultOptions,Position,SourceLocation,getLineInfo,Node:Node$3,TokenType,tokTypes:types$1,keywordTypes:keywords,TokContext,tokContexts:types,isIdentifierChar,isIdentifierStart,Token,isNewLine,lineBreak,lineBreakG,nonASCIIwhitespace};var AcornJSX=__toESM(require_acorn_jsx(),1),attributeNames_default={acceptcharset:"acceptCharset",accesskey:"accessKey",allowfullscreen:"allowFullScreen",autocapitalize:"autoCapitalize",autocomplete:"autoComplete",autofocus:"autoFocus",autoplay:"autoPlay",cellpadding:"cellPadding",cellspacing:"cellSpacing",charset:"charSet",class:"className",colspan:"colSpan",contenteditable:"contentEditable",crossorigin:"crossOrigin",datetime:"dateTime",enctype:"encType",for:"htmlFor",formaction:"formAction",formenctype:"formEncType",formmethod:"formMethod",formnovalidate:"formNoValidate",formtarget:"formTarget",frameborder:"frameBorder",hreflang:"hrefLang",httpequiv:"httpEquiv",inputmode:"inputMode",keyparams:"keyParams",keytype:"keyType",marginheight:"marginHeight",marginwidth:"marginWidth",maxlength:"maxLength",mediagroup:"mediaGroup",minlength:"minLength",novalidate:"noValidate",radiogroup:"radioGroup",readonly:"readOnly",referrerpolicy:"referrerPolicy",rowspan:"rowSpan",spellcheck:"spellCheck",srcdoc:"srcDoc",srclang:"srcLang",srcset:"srcSet",tabindex:"tabIndex",usemap:"useMap"},VOID_ELEMENTS=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"],NO_WHITESPACE=["table","tbody","tfoot","thead","tr"];function canHaveChildren(t){return VOID_ELEMENTS.indexOf(t.toLowerCase())===-1}function canHaveWhitespace(t){return NO_WHITESPACE.indexOf(t.toLowerCase())!==-1}class NullishShortCircuit extends Error{constructor(e="Nullish value encountered"){super(e),this.name="NullishShortCircuit"}}var hash=(t="",e=16)=>{const n=String(t);let o=0;return n.split("").forEach(l=>{o=(o<<5)-o+l.charCodeAt(0),o&=o}),Math.abs(o).toString(e)},randomHash=()=>hash(Math.random().toString()),camelCase=t=>t.replace(/([A-Z])([A-Z])/g,"$1 $2").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[^a-zA-Z\u00C0-\u00ff]/g," ").toLowerCase().split(" ").filter(e=>e).map((e,n)=>n>0?e[0].toUpperCase()+e.slice(1):e).join(""),parseStyle=t=>{switch(typeof t){case"string":return t.split(";").filter(e=>e).reduce((e,n)=>{const o=n.slice(0,n.indexOf(":")).trim(),l=n.slice(n.indexOf(":")+1).trim();return{...e,[camelCase(o)]:l}},{});case"object":return t;default:return}},pathToArrayPath=t=>t==null||t===""?[]:t.split("."),resolveArrayPath=(t,e)=>{const[n,...o]=e;if(!(t==null||n==null))return o.length===0?t[n]:resolveArrayPath(t[n],o)},resolvePath=(t,e)=>resolveArrayPath(t,pathToArrayPath(e));function handleNaN(t){return Number.isNaN(t)?"NaN":t}class JsxParser extends React.Component{constructor(){super(...arguments);Qt(this,"ParsedChildren",null);Hr(this,lr,n=>{const o=Parser.extend(AcornJSX.default({autoCloseVoidElements:this.props.autoCloseVoidElements})),l=`<root>${n}</root>`;let d=[];try{d=o.parse(l,{ecmaVersion:"latest"}),d=d.body[0].expression.children||[]}catch(f){return this.props.showWarnings&&console.warn(f),this.props.onError&&this.props.onError(f),this.props.renderError?this.props.renderError({error:String(f)}):null}return d.map(f=>ir(this,rr).call(this,f)).filter(Boolean)});Hr(this,rr,(n,o)=>{var l,d;switch(n.type){case"JSXAttribute":return n.value===null?!0:ir(this,rr).call(this,n.value,o);case"JSXElement":case"JSXFragment":return ir(this,Zr).call(this,n,o);case"JSXExpressionContainer":return ir(this,rr).call(this,n.expression,o);case"JSXText":const f=this.props.disableKeyGeneration?void 0:randomHash();return this.props.disableFragments?n.value:React.createElement(React.Fragment,{key:f},n.value);case"ArrayExpression":return n.elements.map(A=>ir(this,rr).call(this,A,o));case"BinaryExpression":const g=ir(this,rr).call(this,n.left,o),b=ir(this,rr).call(this,n.right,o);let _;switch(n.operator){case"-":_=g-b;break;case"!=":_=g!=b;break;case"!==":_=g!==b;break;case"*":_=g*b;break;case"**":_=g**b;break;case"/":_=g/b;break;case"%":_=g%b;break;case"+":_=g+b;break;case"<":_=g<b;break;case"<=":_=g<=b;break;case"==":_=g==b;break;case"===":_=g===b;break;case">":_=g>b;break;case">=":_=g>=b;break;default:this.props.onError(new Error(`Unsupported binary operator: ${n.operator}`));return}return handleNaN(_);case"CallExpression":const S=ir(this,rr).call(this,n.callee,o);if(S===void 0){if(n.optional)throw new NullishShortCircuit;this.props.onError(new Error(`The expression '${n.callee}' could not be resolved, resulting in an undefined return value.`));return}return S(...n.arguments.map(A=>ir(this,rr).call(this,A,o)));case"ConditionalExpression":return ir(this,rr).call(this,n.test,o)?ir(this,rr).call(this,n.consequent,o):ir(this,rr).call(this,n.alternate,o);case"ExpressionStatement":return ir(this,rr).call(this,n.expression,o);case"Identifier":return n.name==="Infinity"?1/0:n.name==="-Infinity"?-1/0:n.name==="NaN"?NaN:o&&n.name in o?handleNaN(o[n.name]):handleNaN((this.props.bindings||{})[n.name]);case"Literal":return n.value;case"LogicalExpression":const R=ir(this,rr).call(this,n.left,o);return n.operator==="||"&&R?R:n.operator==="&&"&&R||n.operator==="||"&&!R?ir(this,rr).call(this,n.right,o):!1;case"MemberExpression":return ir(this,an).call(this,n,o);case"ChainExpression":return ir(this,nn).call(this,n,o);case"ObjectExpression":const C={};return n.properties.forEach(A=>{C[A.key.name||A.key.value]=ir(this,rr).call(this,A.value,o)}),C;case"TemplateElement":return n.value.cooked;case"TemplateLiteral":return[...n.expressions,...n.quasis].sort((A,M)=>A.start<M.start?-1:1).map(A=>ir(this,rr).call(this,A,o)).join("");case"UnaryExpression":const E=ir(this,rr).call(this,n.argument,o);switch(n.operator){case"+":return+E;case"-":return-E;case"!":return!E}return;case"ArrowFunctionExpression":return(n.async||n.generator)&&((d=(l=this.props).onError)==null||d.call(l,new Error("Async and generator arrow functions are not supported."))),(...A)=>{const M={...o};return n.params.forEach((I,j)=>{M[I.name]=A[j]}),ir(this,rr).call(this,n.body,M)};default:this.props.onError(new Error(`The expression type '${n.type}' is not supported.`));return}});Hr(this,nn,(n,o)=>{try{return ir(this,rr).call(this,n.expression,o)}catch(l){if(l instanceof NullishShortCircuit)return;throw l}});Hr(this,an,(n,o)=>{const l=ir(this,rr).call(this,n.object,o);let d;if(n.computed)d=ir(this,rr).call(this,n.property,o);else if(n.property.type==="Identifier")d=n.property.name;else{this.props.onError(new Error("Only simple MemberExpressions are supported."));return}if(l==null&&n.optional)throw new NullishShortCircuit;let f;try{f=l[d]}catch{this.props.onError(new Error(`The property '${d}' could not be resolved on the object '${l}'.`));return}return typeof f=="function"?f.bind(l):f});Hr(this,zr,n=>n.type==="JSXIdentifier"?n.name:`${ir(this,zr).call(this,n.object)}.${ir(this,zr).call(this,n.property)}`);Hr(this,Zr,(n,o)=>{const{allowUnknownElements:l,components:d,componentsOnly:f,onError:g}=this.props,{children:b=[]}=n,_=n.type==="JSXElement"?n.openingElement:n.openingFragment,{attributes:S=[]}=_,R=n.type==="JSXElement"?ir(this,zr).call(this,_.name):"",C=(this.props.blacklistedAttrs||[]).map(z=>z instanceof RegExp?z:new RegExp(z,"i")),E=(this.props.blacklistedTags||[]).map(z=>z.trim().toLowerCase()).filter(Boolean);if(/^(html|head|body)$/i.test(R))return b.map(z=>ir(this,Zr).call(this,z,o));const A=R.trim().toLowerCase();if(E.indexOf(A)!==-1)return g(new Error(`The tag <${R}> is blacklisted, and will not be rendered.`)),null;if(R!==""&&!resolvePath(d,R)){if(f)return g(new Error(`The component <${R}> is unrecognized, and will not be rendered.`)),this.props.renderUnrecognized(R);if(!l&&document.createElement(R)instanceof HTMLUnknownElement)return g(new Error(`The tag <${R}> is unrecognized in this browser, and will not be rendered.`)),this.props.renderUnrecognized(R)}let M,I=n.type==="JSXElement"?resolvePath(d,R):React.Fragment;if(I||canHaveChildren(R)){if(M=b.map(Q=>ir(this,rr).call(this,Q,o)),R.includes(".")){const V=R.split(".").reduce((F,te)=>F?F[te]:d==null?void 0:d[te],null);V&&(I=V)}!I&&!canHaveWhitespace(R)&&(M=M.filter(Q=>typeof Q!="string"||!/^\s*$/.test(Q)));const z=M.find(Q=>typeof Q=="function");M.length===0?M=void 0:z?M=z:M.length===1?[M]=M:M.length>1&&!this.props.disableKeyGeneration&&(M=M.map((Q,V)=>Q!=null&&Q.type&&!(Q!=null&&Q.key)?{...Q,key:Q.key||V}:Q))}const j={key:this.props.disableKeyGeneration?void 0:randomHash()};S.forEach(z=>{if(z.type==="JSXAttribute"){const Q=z.name.name,V=attributeNames_default[Q]||Q,F=ir(this,rr).call(this,z,o);C.filter(ne=>ne.test(V)).length===0&&(j[V]=F)}else if(z.type==="JSXSpreadAttribute"&&z.argument.type==="Identifier"||z.argument.type==="MemberExpression"){const Q=ir(this,rr).call(this,z.argument,o);typeof Q=="object"&&Object.keys(Q).forEach(V=>{const F=attributeNames_default[V]||V;C.filter(ne=>ne.test(F)).length===0&&(j[F]=Q[V])})}}),typeof j.style=="string"&&(j.style=parseStyle(j.style));const q=R.toLowerCase();return q==="option"&&(M=M.props.children),React.createElement(I||q,j,M)})}render(){const n=(this.props.jsx||"").trim().replace(/<!DOCTYPE([^>]*)>/g,"");this.ParsedChildren=ir(this,lr).call(this,n);const o=[...new Set(["jsx-parser",...String(this.props.className).split(" ")])].filter(Boolean).join(" ");return this.props.renderInWrapper?React.createElement("div",{className:o},this.ParsedChildren):this.ParsedChildren}}lr=new WeakMap,rr=new WeakMap,nn=new WeakMap,an=new WeakMap,zr=new WeakMap,Zr=new WeakMap,Qt(JsxParser,"displayName","JsxParser"),Qt(JsxParser,"defaultProps",{allowUnknownElements:!0,autoCloseVoidElements:!1,bindings:{},blacklistedAttrs:[/^on.+/i],blacklistedTags:["script"],className:"",components:{},componentsOnly:!1,disableFragments:!1,disableKeyGeneration:!1,jsx:"",onError:()=>{},showWarnings:!1,renderError:void 0,renderInWrapper:!0,renderUnrecognized:()=>null});var source_default=JsxParser;const CountryFlag=({countryCode:t,className:e=""})=>{const[n,o]=React.useState(null),[l,d]=React.useState(!1);return React.useEffect(()=>{if(!t)return;const g=`https://purecatamphetamine.github.io/country-flag-icons/3x2/${t.toUpperCase()}.svg`;fetch(g,{method:"HEAD"}).then(b=>{b.ok?(o(g),d(!1)):d(!0)}).catch(()=>{d(!0)})},[t]),l||!n?jsxRuntime.jsx("span",{className:e,children:t}):jsxRuntime.jsx("img",{src:n,alt:`${t} flag`,className:`inline-block ${e}`,style:{width:"24px",height:"auto"}})};function ProductCard({applicationId:t,product:e,viewProductLink:n,defaultOpportunityNumber:o="",onAddToCart:l,addingToCart:d=!1,shopifyHostname:f,customAction:g=jsxRuntime.jsx(jsxRuntime.Fragment,{})}){var at,ot,Ue,Ct,Je,yt,Mt,qt,Ht,Ft,Ke,it;const b=React.useRef(null),_=useIntersectionObserver({elementRef:b,threshold:.1,rootMargin:"100px",freezeOnceVisible:!0}),{toast:S}=useToast(),[R,C]=React.useState(1),[E,A]=React.useState(null),[M,I]=React.useState(0),[j,q]=React.useState(!1),[z,Q]=React.useState(!1),[V,F]=React.useState(!1),[te]=usePutV4ResellerByRouteResellerIdProductAndRandmarSkuRequisitionMutation(),[ne,se]=React.useState(!1),[ge]=usePostV4ResellerByRouteResellerIdProductAndRandmarSkuShopifyMutation(),{data:oe,isLoading:Ae,isFetching:je}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:t},{skip:!t||!_}),Ne=((at=e==null?void 0:e.Distribution)==null?void 0:at.Cost)||0,Oe=((ot=e==null?void 0:e.Distribution)==null?void 0:ot.RegularPrice)||0,Fe=((Ue=e==null?void 0:e.Distribution)==null?void 0:Ue.Price)||0,ze=React.useMemo(()=>{var et;return!((et=e==null?void 0:e.Distribution)!=null&&et.Inventory)||e.Distribution.Inventory.length===0?0:e.Distribution.Inventory.reduce((ct,ft)=>ct+(ft.PurchaseOrderQuantity||0),0)},[(Ct=e==null?void 0:e.Distribution)==null?void 0:Ct.Inventory]);React.useEffect(()=>{C(1),A(null),I(0),q(!1)},[e==null?void 0:e.RandmarSKU]),React.useEffect(()=>{var et;if(e&&o){const ct=(et=e.Opportunities)==null?void 0:et.find(ft=>ft.BidNumber==o);ct&&$e(ct)&&A(ct)}},[e,o]),React.useEffect(()=>{if(!e)return;const et=E!=null&&E.Price?E.Price:Fe;I(Oe>0?Math.round((Oe-et)/Oe*100):0)},[e,E,Fe,Oe]),React.useEffect(()=>{d||C(1)},[d]);const $e=et=>{if(et.Active!==!0)return!1;const ct=new Date().toISOString().split("T")[0];return!(et.EndDate&&et.EndDate.split("T")[0]<ct||et.StartDate&&et.StartDate.split("T")[0]>ct)};if(React.useEffect(()=>{d||C(1)},[d]),!e||Ae||je)return jsxRuntime.jsx(Card,{children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between products-start mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx("div",{className:"h-10 w-24 flex products-center justify-end ml-4",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-28 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-6 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsx("div",{className:"w-60 h-40",children:jsxRuntime.jsx(Skeleton,{className:"w-full h-full rounded-lg"})})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsx("div",{className:"flex flex-1",children:jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-24 mb-3"}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-full rounded-md"})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col products-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-32 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24 mt-4"})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-col products-start gap-1 mb-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 products-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-10 flex-1 rounded-md"})]})]})]})});const Be=(e==null?void 0:e.Opportunities)||[],qe=Be.length>0,Ge=()=>{if(R==null){C(1);return}R>1&&C(R-1)},He=()=>{if(R==null){C(1);return}C(R+1)},Ze=et=>{const ct=Number.parseInt(et.target.value,10);if(!isNaN(ct)&&ct>0){C(ct);return}C(void 0)},tt=()=>{(R==null||R<1)&&C(1)},Ye=()=>{z||!(oe!=null&&oe.IsReseller)||(Q(!0),te({routeResellerId:oe.ApplicationId??"",randmarSku:e.RandmarSKU??""}).then(et=>{if(et.error){console.error(et.error),S({title:"Error",description:"Error submitting your qualification.",variant:"destructive"});return}S({title:"Success",description:"Qualification successfully submitted.",variant:"success"}),F(!1)}).catch(et=>{console.error(et),S({title:"Error",description:"Error submitting your qualification.",variant:"destructive"})}).finally(()=>{Q(!1)}))},Qe=((yt=(Je=e.Distribution)==null?void 0:Je.Inventory)==null?void 0:yt.reduce((et,ct)=>et+(ct.AvailableQuantity||0),0))||0,Xe=et=>{try{return new Date(et).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch(ct){return console.error(ct),et.split("T")[0]||"N/A"}},st=()=>{typeof l<"u"&&l({quantity:R??1,bidNumber:(E==null?void 0:E.BidNumber)??null})},rt=()=>{ne||!f||(se(!0),ge({routeResellerId:t??"",randmarSku:e.RandmarSKU??"",shopifyHostName:f}).then(et=>{if(et.error){console.error("Error syncing to Shopify:",et.error),S({title:"Product synced failed.",description:"Error syncing to Shopify:",variant:"destructive"});return}S({title:"Product synced",description:"Product synced to Shopify successfully",variant:"success"})}).catch(et=>{console.error("Error syncing to Shopify:",et),S({title:"Product synced failed.",description:"Error syncing to Shopify:",variant:"destructive"})}).finally(()=>{se(!1)}))};return jsxRuntime.jsx(Card,{className:"hover:shadow-lg transition-shadow",ref:b,children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between products-start mb-3",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-xl",children:e.Title||e.RandmarTitle}),jsxRuntime.jsx("div",{className:"w-24 h-10 flex products-center justify-end ml-4",children:jsxRuntime.jsx(PartnerLogo,{id:e.ManufacturerId,name:e.ManufacturerName,width:96,height:40},`partner_logo_${e.ManufacturerId}`)})]}),jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[e.State&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.State==="Active"?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(Check,{size:"12",className:"mr-1.5"})," ",e.State]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.SerialNumber?"bg-green-50 text-green-700 hover:bg-green-50":"bg-yellow-50 text-yellow-700 hover:bg-yellow-50"}`,children:[jsxRuntime.jsx(QrCode,{size:"12",className:"mr-1.5"})," ",e.SerialNumber?"Serialized":"Unserialized"]}),e.TransparencyCode&&jsxRuntime.jsxs(Badge,{variant:"outline",className:"rounded-full px-3 bg-green-50 text-green-700 hover:bg-green-50",children:[jsxRuntime.jsx(CircleDashed,{size:"12",className:"mr-1.5"})," Transparency Code"]}),e.AvailableToBuy!==void 0&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.AvailableToBuy?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(ShoppingCart,{size:"12",className:"mr-1.5"})," ",e.AvailableToBuy?"Available":"Unavailable"]}),e.ManufacturerCategory!==void 0&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${(Mt=e.ManufacturerCategory)!=null&&Mt.QualificationRequired?"bg-blue-50 text-blue-700 hover:bg-blue-50":"bg-neutral-50 text-neutral-700 hover:bg-neutral-50"}`,children:[jsxRuntime.jsx(ShieldCheck,{size:"12",className:"mr-1.5"})," ",(qt=e.ManufacturerCategory)!=null&&qt.QualificationRequired?"Qualified Only":"Available to all"]}),e.ManufacturerId&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.AutoUpdate?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(RefreshCw,{size:"12",className:"mr-1.5"})," ",e.AutoUpdate?`Automatic Reorder (${e.MasterCarton})`:"Manually Reorders"]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.BodyHTML&&e.Title&&e.MAP?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(Store,{size:"12",className:"mr-1.5"})," ",e.BodyHTML&&e.Title&&e.MAP?"Shopify Ready":"Not Shopify Ready"]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-4 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"MPN"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.MPN||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"UPC"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.UPC||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Unit Weight"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.UnitWeight?`${formatNumber(e.UnitWeight)} lbs`:"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"text-sm text-muted-foreground",children:["MAP",jsxRuntime.jsx("span",{className:"text-primary",children:" / "}),"MSRP"]}),jsxRuntime.jsxs("div",{className:"font-medium",children:[e.MAP?formatMoney(e.MAP):"N/A",jsxRuntime.jsx("span",{className:"text-primary",children:" / "}),e.MSRP?formatMoney(e.MSRP):"N/A"]})]}),!!e.OverallPercentileRank&&!!e.ManufacturerPercentileRank&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Percentile"}),jsxRuntime.jsxs("div",{className:`font-medium flex products-center ${e.OverallPercentileRank>=80?"text-green-700":""}`,children:[formatNumber(Math.round(e.OverallPercentileRank))," Overall"]}),jsxRuntime.jsxs("div",{className:"font-light flex products-center text-sm",children:[formatNumber(Math.round(e.ManufacturerPercentileRank))," with Manufacturer"]})]}),e.CountryCodeOfOrigin&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Origin"}),jsxRuntime.jsxs("div",{className:"font-medium flex products-center",children:[jsxRuntime.jsx(CountryFlag,{countryCode:e.CountryCodeOfOrigin,className:"mr-2"}),e.CountryCodeOfOrigin]})]})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsx(ProductImage,{randmarSKU:e.RandmarSKU||"",alt:e.RandmarTitle||""},`product_image_${e.RandmarSKU}`)})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsx("div",{className:"flex flex-1",children:qe&&e.Distribution&&jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx("div",{className:"flex products-center",children:"You have "+Be.length+(Be.length>1?" opportunities":" opportunity")+" for this product:"}),jsxRuntime.jsx("div",{className:"space-y-2 max-h-[200px] overflow-y-auto p-2 mt-1",children:Be.map((et,ct)=>jsxRuntime.jsxs("div",{className:`flex justify-between products-center rounded-lg transition-colors py-2 px-4 bg-purple-100 border border-muted
|
|
1149
1149
|
${et.BidNumber==(E==null?void 0:E.BidNumber)?"cursor-pointer border-2 border-purple-900":$e(et)?"hover:bg-purple-200 cursor-pointer":"!bg-neutral-50"}
|
|
1150
1150
|
`,onClick:()=>{$e(et)&&A(et.BidNumber!=(E==null?void 0:E.BidNumber)?et:null)},children:[jsxRuntime.jsx("div",{className:"flex products-center",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-medium text-sm",children:et.Opportunity}),jsxRuntime.jsxs("span",{className:"text-xs text-neutral-900",children:[et.BidNumber," ",!$e(et)&&jsxRuntime.jsx(Badge,{variant:"outline",className:"text-xs mx-1 h-5 bg-gray-100",children:"Currently unavailable"})]})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col products-end",children:[jsxRuntime.jsx("span",{className:"font-semibold",children:formatMoney(et.Price??0)}),et.Rebate&&et.Rebate>0&&jsxRuntime.jsxs("span",{className:"text-xs text-green-600",children:["Rebate: ",formatMoney(et.Rebate)]}),et.EndDate&&jsxRuntime.jsxs("span",{className:"text-xs text-neutral-600",children:["Ends: ",Xe(et.EndDate)]})]})]},ct))})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col products-center",children:[n&&jsxRuntime.jsx(reactRouterDom.Link,{to:n,children:jsxRuntime.jsxs(Button,{variant:"secondary",children:[jsxRuntime.jsx(Eye,{className:"mr-2"}),"View Product"]})}),((Ht=e.Distribution)==null?void 0:Ht.Inventory)&&jsxRuntime.jsx("div",{className:"mt-4",children:oe!=null&&oe.IsReseller&&Qe<=0&&ze<=0?jsxRuntime.jsxs(Dialog,{open:V,onOpenChange:F,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{variant:"ghost",className:"flex products-center text-sm reseller-theme text-primary",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,{variant:"outline",onClick:()=>F(!1),disabled:z,children:"Cancel"}),jsxRuntime.jsx(Button,{onClick:Ye,disabled:z,children:z?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin mr-2"}),"Requesting..."]}):"Confirm"})]})]})]}):Qe<=0&&ze>0?jsxRuntime.jsxs(Dialog,{open:j,onOpenChange:q,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{variant:"ghost",className:"flex products-center text-sm manufacturer-theme text-primary",children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),formatNumber(ze)," Incoming"]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-4xl",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsxs(DialogTitle,{className:"flex products-center",children:[jsxRuntime.jsx(Warehouse,{className:"mr-2",size:18}),"Inventory Information"]})}),jsxRuntime.jsx(ProductInventoryGrid,{inventory:e.Distribution.Inventory})]})]}):jsxRuntime.jsxs(Dialog,{open:j,onOpenChange:q,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{variant:"ghost",className:`flex products-center text-sm ${Qe>0?"text-green-700":"text-red-700"}`,children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),Qe>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(Qe)," 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 products-center",children:[jsxRuntime.jsx(Warehouse,{className:"mr-2",size:18}),"Inventory Information"]})}),jsxRuntime.jsx(ProductInventoryGrid,{inventory:e.Distribution.Inventory})]})]})})]})]}),e.Distribution&&jsxRuntime.jsxs("div",{className:"flex justify-between products-end mt-4",children:[jsxRuntime.jsx("div",{className:"flex-shrink-1 flex flex-col products-start gap-1",children:Ne>0?jsxRuntime.jsx("div",{className:"flex products-center",children:jsxRuntime.jsxs("span",{className:"text-2xl font-bold whitespace-nowrap",children:["Cost: ",formatMoney(Ne)]})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex products-center flex-wrap",children:[jsxRuntime.jsx("span",{className:"text-2xl font-bold whitespace-nowrap",children:formatMoney((E?(Ke=(Ft=e.Opportunities)==null?void 0:Ft.find(et=>et.BidNumber==E.BidNumber))==null?void 0:Ke.Price:Fe)??0)}),M>0&&jsxRuntime.jsx("span",{className:"text-muted-foreground line-through ml-2 whitespace-nowrap",children:formatMoney(Oe)})]}),M>0&&jsxRuntime.jsx("div",{className:"flex products-center",children:jsxRuntime.jsxs(Badge,{variant:"outline",className:"bg-red-50 text-red-700 rounded-full px-3 whitespace-nowrap",children:[jsxRuntime.jsxs("span",{children:[M,"% OFF"]}),((it=e.InstantRebate)==null?void 0:it.EndDate)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",e.InstantRebate.EndDate.split("T")[0]]}),(E==null?void 0:E.EndDate)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",E.EndDate.split("T")[0]]})]})})]})}),jsxRuntime.jsxs("div",{className:"flex flex-shrink-0 gap-2 ml-4",children:[typeof l<"u"&&jsxRuntime.jsxs("div",{className:"flex products-center border rounded-md",children:[jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"rounded-r-none",onClick:Ge,disabled:typeof R<"u"&&(R<=1||!e.AvailableToBuy||d),children:"-"}),jsxRuntime.jsx("input",{value:R,onChange:Ze,onBlur:tt,onClick:et=>et.currentTarget.select(),className:`w-12 text-center border-0 focus:ring-0 focus:outline-none ${!e.AvailableToBuy||d?"text-gray-400":""}`,disabled:!e.AvailableToBuy||d}),jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"rounded-l-none",onClick:He,disabled:!e.AvailableToBuy||d,children:"+"})]}),typeof l<"u"&&jsxRuntime.jsx(Button,{className:"gap-2 whitespace-nowrap",onClick:st,disabled:!e.AvailableToBuy||d,children:d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}),"Adding..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2"}),"Add to Cart"]})}),f&&jsxRuntime.jsx(Button,{className:"gap-2 whitespace-nowrap bg-green-600 hover:bg-green-700",onClick:rt,disabled:ne,children:ne?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2"}),"Sync to Shopify"]})}),g]})]})]})})}const complexComponents=[`----
|
|
1151
1151
|
PartnerCard: For data that fits this shape:
|
|
@@ -1359,4 +1359,4 @@ img.ProseMirror-separator {
|
|
|
1359
1359
|
- Do not include <html>, <head>, <body>, or markdown \`\`\` fences. Output only the content itself.
|
|
1360
1360
|
---
|
|
1361
1361
|
Prompt: "${e}"
|
|
1362
|
-
`;try{const d=new GoogleGenAI({apiKey:t}),f=n?"gemini-
|
|
1362
|
+
`;try{const d=new GoogleGenAI({apiKey:t}),f=n?"gemini-2.5-pro":"gemini-2.5-flash";return(await d.chats.create({model:f}).sendMessage({message:l})).text??"<p>Sorry, I couldn't generate a response for this.</p>"}catch(d){return console.error("Error fetching AI insight:",d),o>0?(await new Promise(f=>setTimeout(f,(4-o)*500)),GetTextInsightFromAI(t,e,n,o-1)):"<p>An error occurred while generating the insight.</p>"}};function AssistantInsight({prompt:t,smartAndSlow:e=!1,thinkingPlaceholderText:n="Thinking..."}){const[o,l]=React.useState(""),[d,f]=React.useState(!0),[g,b]=React.useState(null),{apiKey:_}=useGeminiApiKey();return React.useEffect(()=>{let S=!1;return(async()=>{if(!_||!t){if(S)return;b("Prompt and API Key are required."),f(!1);return}if(resultCache.has(t)){if(S)return;l(resultCache.get(t)),f(!1);return}if(requestCache.has(t)){if(S)return;f(!0),await requestCache.get(t),!S&&resultCache.has(t)&&l(resultCache.get(t)),S||f(!1);return}try{if(S)return;f(!0);const C=GetTextInsightFromAI(_,t,e).then(E=>{const A=cleanHtmlString(E);resultCache.set(t,A)});if(requestCache.set(t,C),await C,S)return;resultCache.has(t)&&l(resultCache.get(t))}catch(C){if(S)return;const E=C instanceof Error?C.message:"An unknown error occurred.";b(E),console.error(C)}finally{requestCache.delete(t),S||f(!1)}})(),()=>{S=!0}},[t,_,e]),jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg bg-background",children:[jsxRuntime.jsx(Bot,{className:`mt-1 h-6 w-6 flex-shrink-0 ${d?"animate-pulse text-primary":"text-primary"}`}),jsxRuntime.jsxs("div",{className:"w-full min-h-[4rem]",children:[d&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("p",{className:"font-medium text-muted-foreground",children:n}),jsxRuntime.jsxs("div",{className:"space-y-2 mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-5/6"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-3/4"})]})]}),g&&jsxRuntime.jsx("p",{className:"text-sm text-red-600",children:g}),!d&&!g&&o&&jsxRuntime.jsx("div",{className:"chat-bubble-in-animation text-sm text-foreground space-y-4",dangerouslySetInnerHTML:{__html:o}})]})]})}exports.ActiveOrdersCard=ActiveOrdersCard,exports.AiGeneratedContent=AiGeneratedContent,exports.Alert=Alert,exports.AlertDescription=AlertDescription,exports.AlertDialog=AlertDialog,exports.AlertDialogAction=AlertDialogAction,exports.AlertDialogCancel=AlertDialogCancel,exports.AlertDialogContent=AlertDialogContent,exports.AlertDialogDescription=AlertDialogDescription,exports.AlertDialogFooter=AlertDialogFooter,exports.AlertDialogHeader=AlertDialogHeader,exports.AlertDialogTitle=AlertDialogTitle,exports.AlertDialogTrigger=AlertDialogTrigger,exports.AlertTitle=AlertTitle,exports.AreaChart=AreaChart,exports.AssistantChat=AssistantChat,exports.AssistantInsight=AssistantInsight,exports.Avatar=Avatar,exports.AvatarFallback=AvatarFallback,exports.AvatarFooter=AvatarFooter,exports.AvatarImage=AvatarImage,exports.Badge=Badge,exports.Button=Button,exports.Card=Card,exports.CardContent=CardContent,exports.CardDescription=CardDescription,exports.CardFooter=CardFooter,exports.CardHeader=CardHeader,exports.CardTitle=CardTitle,exports.ChatLayout=ChatLayout,exports.ChatProvider=ChatProvider,exports.Checkbox=Checkbox,exports.Command=Command,exports.CommandDialog=CommandDialog,exports.CommandEmpty=CommandEmpty,exports.CommandGroup=CommandGroup,exports.CommandInput=CommandInput,exports.CommandItem=CommandItem,exports.CommandList=CommandList,exports.CommandSeparator=CommandSeparator,exports.CommandShortcut=CommandShortcut,exports.CountryFlag=CountryFlag,exports.DataTable=DataTable,exports.Dialog=Dialog,exports.DialogClose=DialogClose,exports.DialogContent=DialogContent,exports.DialogDescription=DialogDescription,exports.DialogFooter=DialogFooter,exports.DialogHeader=DialogHeader,exports.DialogOverlay=DialogOverlay,exports.DialogPortal=DialogPortal,exports.DialogTitle=DialogTitle,exports.DialogTrigger=DialogTrigger,exports.DropdownMenu=DropdownMenu,exports.DropdownMenuCheckboxItem=DropdownMenuCheckboxItem,exports.DropdownMenuContent=DropdownMenuContent,exports.DropdownMenuGroup=DropdownMenuGroup,exports.DropdownMenuItem=DropdownMenuItem,exports.DropdownMenuLabel=DropdownMenuLabel,exports.DropdownMenuPortal=DropdownMenuPortal,exports.DropdownMenuRadioGroup=DropdownMenuRadioGroup,exports.DropdownMenuRadioItem=DropdownMenuRadioItem,exports.DropdownMenuSeparator=DropdownMenuSeparator,exports.DropdownMenuShortcut=DropdownMenuShortcut,exports.DropdownMenuSub=DropdownMenuSub,exports.DropdownMenuSubContent=DropdownMenuSubContent,exports.DropdownMenuSubTrigger=DropdownMenuSubTrigger,exports.DropdownMenuTrigger=DropdownMenuTrigger,exports.ExploreManufacturers=ExploreManufacturers,exports.ExternalProductCard=ExternalProductCard,exports.GeminiApiKeyProvider=GeminiApiKeyProvider,exports.GeneralDocumentCard=GeneralDocumentCard,exports.Input=Input,exports.InputOTP=InputOTP,exports.InputOTPGroup=InputOTPGroup,exports.InputOTPSeparator=InputOTPSeparator,exports.InputOTPSlot=InputOTPSlot,exports.Label=Label$2,exports.Layout=Layout,exports.ManufacturerCard=ManufacturerCard,exports.ManufacturerGetStartedButton=ManufacturerGetStartedButton,exports.ManufacturerOverviewPage=ManufacturerOverviewPage,exports.ManufacturerReorderingCard=ManufacturerReorderingCard,exports.MultiSelect=MultiSelect,exports.Navbar=Navbar,exports.OpportunitiesTable=OpportunitiesTable,exports.PageHeader=PageHeader,exports.PartnerCard=PartnerCard,exports.PartnerRelationshipPage=PartnerRelationshipPage,exports.Popover=Popover,exports.PopoverAnchor=PopoverAnchor,exports.PopoverContent=PopoverContent,exports.PopoverTrigger=PopoverTrigger,exports.Preloader=Preloader,exports.ProductCard=ProductCard,exports.ProductImage=ProductImage,exports.ProductInventoryGrid=ProductInventoryGrid,exports.ProductOverviewPage=ProductOverviewPage,exports.Progress=Progress,exports.RadioGroup=RadioGroup$1,exports.RadioGroupItem=RadioGroupItem,exports.ResellerBillingOverviewCard=ResellerBillingOverviewCard,exports.ResellerCard=ResellerCard,exports.ResellerOverview=ResellerOverview,exports.ResellerQualificationsCard=ResellerQualificationsCard,exports.ReturnsTable=ReturnsTable,exports.RichTextEditor=RichTextEditor,exports.SalesChart=SalesChart,exports.SalesOverviewCard=SalesOverviewCard,exports.ScrollArea=ScrollArea,exports.ScrollBar=ScrollBar,exports.Select=Select,exports.SelectContent=SelectContent,exports.SelectGroup=SelectGroup,exports.SelectItem=SelectItem,exports.SelectLabel=SelectLabel,exports.SelectScrollDownButton=SelectScrollDownButton,exports.SelectScrollUpButton=SelectScrollUpButton,exports.SelectTrigger=SelectTrigger,exports.SelectValue=SelectValue,exports.Separator=Separator$1,exports.Sheet=Sheet,exports.SheetClose=SheetClose,exports.SheetContent=SheetContent,exports.SheetDescription=SheetDescription,exports.SheetFooter=SheetFooter,exports.SheetHeader=SheetHeader,exports.SheetOverlay=SheetOverlay,exports.SheetPortal=SheetPortal,exports.SheetTitle=SheetTitle,exports.SheetTrigger=SheetTrigger,exports.Sidebar=Sidebar,exports.SidebarContent=SidebarContent,exports.SidebarFooter=SidebarFooter,exports.SidebarGroup=SidebarGroup,exports.SidebarGroupAction=SidebarGroupAction,exports.SidebarGroupContent=SidebarGroupContent,exports.SidebarGroupLabel=SidebarGroupLabel,exports.SidebarHeader=SidebarHeader,exports.SidebarInput=SidebarInput,exports.SidebarInset=SidebarInset,exports.SidebarMenu=SidebarMenu,exports.SidebarMenuAction=SidebarMenuAction,exports.SidebarMenuBadge=SidebarMenuBadge,exports.SidebarMenuButton=SidebarMenuButton,exports.SidebarMenuItem=SidebarMenuItem,exports.SidebarMenuSkeleton=SidebarMenuSkeleton,exports.SidebarMenuSub=SidebarMenuSub,exports.SidebarMenuSubButton=SidebarMenuSubButton,exports.SidebarMenuSubItem=SidebarMenuSubItem,exports.SidebarProvider=SidebarProvider,exports.SidebarRail=SidebarRail,exports.SidebarSeparator=SidebarSeparator,exports.SidebarTrigger=SidebarTrigger,exports.Skeleton=Skeleton,exports.Switch=Switch,exports.Table=Table,exports.TableBody=TableBody,exports.TableCaption=TableCaption,exports.TableCell=TableCell,exports.TableFooter=TableFooter,exports.TableHead=TableHead,exports.TableHeader=TableHeader,exports.TableRow=TableRow,exports.Tabs=Tabs,exports.TabsContent=TabsContent,exports.TabsList=TabsList,exports.TabsTrigger=TabsTrigger,exports.Textarea=Textarea,exports.Toast=Toast,exports.ToastAction=ToastAction,exports.ToastClose=ToastClose,exports.ToastDescription=ToastDescription,exports.ToastProvider=ToastProvider,exports.ToastTitle=ToastTitle,exports.ToastViewport=ToastViewport,exports.Toaster=Toaster,exports.Tooltip=Tooltip$1,exports.TooltipContent=TooltipContent,exports.TooltipProvider=TooltipProvider,exports.TooltipTrigger=TooltipTrigger,exports.TopPercentTreemap=TopPercentTreemap,exports.Topbar=Topbar,exports.Treemap=Treemap,exports.badgeVariants=badgeVariants,exports.buttonVariants=buttonVariants,exports.formatMoney=formatMoney,exports.formatNumber=formatNumber,exports.formatYYYYMMDDIntToDateString=formatYYYYMMDDIntToDateString,exports.toast=toast,exports.useChat=useChat,exports.useGeminiApiKey=useGeminiApiKey,exports.useIsMobile=useIsMobile,exports.useSidebar=useSidebar,exports.useToast=useToast,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
|