randmarcomps 1.479.0 → 1.481.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.
@@ -61105,10 +61105,10 @@ const PeopleSection = ({ appID: e, activeChatObj: t }) => {
61105
61105
  return /* @__PURE__ */ jsxs("li", { className: "rounded border px-3 py-2 text-sm", children: [
61106
61106
  /* @__PURE__ */ jsx("p", { className: "font-medium leading-tight", children: _.Name ?? "Unknown person" }),
61107
61107
  /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: _.Role ?? "Role unavailable" }),
61108
- /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
61109
- _.Active ? "Active" : "Inactive",
61110
- R ? ` · Last auth ${R}` : ""
61111
- ] })
61108
+ R ? /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
61109
+ "Last auth ",
61110
+ R
61111
+ ] }) : null
61112
61112
  ] }, E);
61113
61113
  }) })
61114
61114
  ] });
@@ -76510,8 +76510,8 @@ function ProductCard({
76510
76510
  shopifyHostname: f,
76511
76511
  customAction: g = /* @__PURE__ */ jsx(Fragment$1, {})
76512
76512
  }) {
76513
- var Ge, $t, nt, Ct, dt, It, Mt, Rt, Ke, Ye;
76514
- const b = useNavigate(), { toast: S } = useToast(), [_, C] = useState(1), [E, R] = useState(null), [A, M] = useState(0), [I, V] = useState(!1), [q] = usePostV4ResellerByRouteResellerIdProductAndRandmarSkuShopifyMutation(), [Q, te] = useState(!1), [j, F] = useState(null), [ne, ae] = useState("idle"), [se, Ve] = useState(null), [Ne] = useLazyGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery(), oe = ((Ge = t == null ? void 0 : t.Distribution) == null ? void 0 : Ge.Cost) || 0, Oe = (($t = t == null ? void 0 : t.Distribution) == null ? void 0 : $t.RegularPrice) || 0, Ae = ((nt = t == null ? void 0 : t.Distribution) == null ? void 0 : nt.Price) || 0, $e = !!(e && (t != null && t.RandmarSKU));
76513
+ var $t, nt, Ct, dt, It, Mt, Rt, Ke, Ye;
76514
+ const b = useNavigate(), { toast: S } = useToast(), [_, C] = useState(1), [E, R] = useState(null), [A, M] = useState(0), [I, V] = useState(!1), [q] = usePostV4ResellerByRouteResellerIdProductAndRandmarSkuShopifyMutation(), [Q, te] = useState(!1), [j, F] = useState(null), [ne, ae] = useState("idle"), [se, Ve] = useState(null), [Ne] = useLazyGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery(), oe = (($t = t == null ? void 0 : t.Distribution) == null ? void 0 : $t.Cost) || 0, Oe = ((nt = t == null ? void 0 : t.Distribution) == null ? void 0 : nt.RegularPrice) || 0, Ae = ((Ct = t == null ? void 0 : t.Distribution) == null ? void 0 : Ct.Price) || 0, $e = !!(e && (t != null && t.RandmarSKU));
76515
76515
  useEffect(() => {
76516
76516
  C(1), R(null), M(0);
76517
76517
  }, [t == null ? void 0 : t.RandmarSKU]), useEffect(() => {
@@ -76570,7 +76570,7 @@ function ProductCard({
76570
76570
  if (Ze.Active !== !0) return !1;
76571
76571
  const ct = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
76572
76572
  return !(Ze.EndDate && Ze.EndDate.split("T")[0] < ct || Ze.StartDate && Ze.StartDate.split("T")[0] > ct);
76573
- }, qe = (Ze) => Ze >= 90 ? { label: "Top 10% Bestseller", color: "text-purple-950", bgColor: "bg-purple-200" } : Ze >= 75 ? { label: "Bestseller", color: "text-blue-700", bgColor: "bg-blue-50" } : Ze >= 33 ? { label: "Popular", color: "text-green-700", bgColor: "bg-green-50" } : { label: "Rising", color: "text-gray-700", bgColor: "bg-white" }, Be = ne !== "complete" && (((Ct = j == null ? void 0 : j.SalesStatistics) == null ? void 0 : Ct.length) ?? 0) === 0, Fe = ne !== "complete" && ne !== "error", He = ne === "summary" ? 40 : ne === "detailed" ? 80 : 10, We = (j == null ? void 0 : j.RandmarTitle) ?? (t == null ? void 0 : t.RandmarTitle) ?? (t == null ? void 0 : t.RandmarSKU) ?? "this product", ze = (j == null ? void 0 : j.RandmarSKU) ?? (t == null ? void 0 : t.RandmarSKU);
76573
+ }, qe = (Ze) => Ze >= 90 ? { label: "Top 10% Bestseller", color: "text-purple-950", bgColor: "bg-purple-200" } : Ze >= 75 ? { label: "Bestseller", color: "text-blue-700", bgColor: "bg-blue-50" } : Ze >= 33 ? { label: "Popular", color: "text-green-700", bgColor: "bg-green-50" } : { label: "Rising", color: "text-gray-700", bgColor: "bg-white" }, Be = ne !== "complete" && ne !== "error", Fe = ne === "summary" ? 40 : ne === "detailed" ? 80 : 10, He = (j == null ? void 0 : j.SalesStatistics) ?? [], We = Be ? [] : He, ze = (j == null ? void 0 : j.RandmarTitle) ?? (t == null ? void 0 : t.RandmarTitle) ?? (t == null ? void 0 : t.RandmarSKU) ?? "this product", Xe = (j == null ? void 0 : j.RandmarSKU) ?? (t == null ? void 0 : t.RandmarSKU);
76574
76574
  if (!t)
76575
76575
  return /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(CardContent, { className: "p-6", children: [
76576
76576
  /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-start mb-3", children: [
@@ -76624,36 +76624,36 @@ function ProductCard({
76624
76624
  ] })
76625
76625
  ] })
76626
76626
  ] }) });
76627
- const Xe = (t == null ? void 0 : t.Opportunities) || [], rt = Xe.length > 0, Je = () => {
76627
+ const rt = (t == null ? void 0 : t.Opportunities) || [], Je = rt.length > 0, st = () => {
76628
76628
  if (_ == null) {
76629
76629
  C(1);
76630
76630
  return;
76631
76631
  }
76632
76632
  _ > 1 && C(_ - 1);
76633
- }, st = () => {
76633
+ }, et = () => {
76634
76634
  if (_ == null) {
76635
76635
  C(1);
76636
76636
  return;
76637
76637
  }
76638
76638
  C(_ + 1);
76639
- }, et = (Ze) => {
76639
+ }, at = (Ze) => {
76640
76640
  const ct = Number.parseInt(Ze.target.value, 10);
76641
76641
  if (!isNaN(ct) && ct > 0) {
76642
76642
  C(ct);
76643
76643
  return;
76644
76644
  }
76645
76645
  C(void 0);
76646
- }, at = () => {
76646
+ }, tt = () => {
76647
76647
  (_ == null || _ < 1) && C(1);
76648
- }, tt = (Ze) => {
76648
+ }, ot = (Ze) => {
76649
76649
  try {
76650
76650
  return new Date(Ze).toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" });
76651
76651
  } catch (ct) {
76652
76652
  return console.error(ct), Ze.split("T")[0] || "N/A";
76653
76653
  }
76654
- }, ot = () => {
76655
- typeof l < "u" && l({ quantity: _ ?? 1, bidNumber: (E == null ? void 0 : E.BidNumber) ?? null });
76656
76654
  }, lt = () => {
76655
+ typeof l < "u" && l({ quantity: _ ?? 1, bidNumber: (E == null ? void 0 : E.BidNumber) ?? null });
76656
+ }, Ge = () => {
76657
76657
  I || !f || (V(!0), q({
76658
76658
  routeResellerId: e ?? "",
76659
76659
  randmarSku: t.RandmarSKU ?? "",
@@ -76877,9 +76877,9 @@ function ProductCard({
76877
76877
  }
76878
76878
  )
76879
76879
  ] }),
76880
- /* @__PURE__ */ jsx("div", { className: "flex flex-1 @[36rem]:order-1 order-2", children: rt && t.Distribution && /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
76881
- /* @__PURE__ */ jsx("div", { className: "flex items-center", children: "You have " + Xe.length + (Xe.length > 1 ? " opportunities" : " opportunity") + " for this product:" }),
76882
- /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsx("div", { className: "space-y-2 max-h-[200px] overflow-y-auto p-2 mt-1", children: Xe.map(
76880
+ /* @__PURE__ */ jsx("div", { className: "flex flex-1 @[36rem]:order-1 order-2", children: Je && t.Distribution && /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
76881
+ /* @__PURE__ */ jsx("div", { className: "flex items-center", children: "You have " + rt.length + (rt.length > 1 ? " opportunities" : " opportunity") + " for this product:" }),
76882
+ /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsx("div", { className: "space-y-2 max-h-[200px] overflow-y-auto p-2 mt-1", children: rt.map(
76883
76883
  (Ze, ct) => Le(Ze) ? /* @__PURE__ */ jsxs("div", { className: `flex justify-between items-center rounded-lg transition-colors py-2 px-4 border border-muted cursor-pointer ${Ze.BidNumber == (E == null ? void 0 : E.BidNumber) ? "bg-purple-100 border-2 border-purple-900" : "bg-white border-1 border-purple-600 hover:bg-purple-200"}`, onClick: () => {
76884
76884
  R(Ze.BidNumber !== (E == null ? void 0 : E.BidNumber) ? Ze : null);
76885
76885
  }, children: [
@@ -76895,7 +76895,7 @@ function ProductCard({
76895
76895
  ] }),
76896
76896
  Ze.EndDate && /* @__PURE__ */ jsxs("span", { className: "text-xs text-neutral-600", children: [
76897
76897
  "Ends: ",
76898
- tt(Ze.EndDate)
76898
+ ot(Ze.EndDate)
76899
76899
  ] })
76900
76900
  ] })
76901
76901
  ] }, ct) : /* @__PURE__ */ jsxs(Tooltip$1, { children: [
@@ -76918,7 +76918,7 @@ function ProductCard({
76918
76918
  ] }),
76919
76919
  Ze.EndDate && /* @__PURE__ */ jsxs("span", { className: "text-xs text-neutral-600", children: [
76920
76920
  "Ends: ",
76921
- tt(Ze.EndDate)
76921
+ ot(Ze.EndDate)
76922
76922
  ] })
76923
76923
  ] })
76924
76924
  ] }) }),
@@ -76974,7 +76974,7 @@ function ProductCard({
76974
76974
  Button$1,
76975
76975
  {
76976
76976
  className: "gap-2 whitespace-nowrap bg-green-600 hover:bg-green-700",
76977
- onClick: lt,
76977
+ onClick: Ge,
76978
76978
  disabled: I,
76979
76979
  children: I ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
76980
76980
  /* @__PURE__ */ jsx(LoaderCircle, { className: "h-4 w-4 animate-spin" }),
@@ -76994,7 +76994,7 @@ function ProductCard({
76994
76994
  variant: "ghost",
76995
76995
  size: "icon",
76996
76996
  className: "rounded-r-none",
76997
- onClick: Je,
76997
+ onClick: st,
76998
76998
  disabled: typeof _ < "u" && (_ <= 1 || !t.AvailableToBuy || d),
76999
76999
  children: "-"
77000
77000
  }
@@ -77003,8 +77003,8 @@ function ProductCard({
77003
77003
  "input",
77004
77004
  {
77005
77005
  value: _,
77006
- onChange: et,
77007
- onBlur: at,
77006
+ onChange: at,
77007
+ onBlur: tt,
77008
77008
  onClick: (Ze) => Ze.currentTarget.select(),
77009
77009
  className: `w-6 @[36rem]:w-12 text-center border-0 focus:ring-0 focus:outline-none ${!t.AvailableToBuy || d ? "text-gray-400" : ""}`,
77010
77010
  disabled: !t.AvailableToBuy || d
@@ -77016,7 +77016,7 @@ function ProductCard({
77016
77016
  variant: "ghost",
77017
77017
  size: "icon",
77018
77018
  className: "rounded-l-none",
77019
- onClick: st,
77019
+ onClick: et,
77020
77020
  disabled: !t.AvailableToBuy || d,
77021
77021
  children: "+"
77022
77022
  }
@@ -77026,7 +77026,7 @@ function ProductCard({
77026
77026
  Button$1,
77027
77027
  {
77028
77028
  className: "gap-2 whitespace-nowrap",
77029
- onClick: ot,
77029
+ onClick: lt,
77030
77030
  disabled: !t.AvailableToBuy || d,
77031
77031
  children: d ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
77032
77032
  /* @__PURE__ */ jsx(LoaderCircle, { className: "h-4 w-4 animate-spin" }),
@@ -77046,65 +77046,35 @@ function ProductCard({
77046
77046
  /* @__PURE__ */ jsx(DialogTitle, { children: "Monthly Sales Performance" }),
77047
77047
  /* @__PURE__ */ jsxs(DialogDescription, { children: [
77048
77048
  "Expanded product insights for ",
77049
- We,
77050
- ze ? ` (SKU ${ze})` : ""
77049
+ ze,
77050
+ Xe ? ` (SKU ${Xe})` : ""
77051
77051
  ] })
77052
77052
  ] }),
77053
- /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
77054
- Fe && /* @__PURE__ */ jsx(
77055
- "div",
77056
- {
77057
- className: "rounded-xl border bg-background p-4",
77058
- "aria-live": "polite",
77059
- "aria-busy": "true",
77060
- children: /* @__PURE__ */ jsx(
77061
- Progress,
77062
- {
77063
- value: He,
77064
- className: "h-2 w-full animate-pulse",
77065
- "aria-label": "Loading performance data"
77066
- }
77067
- )
77068
- }
77069
- ),
77070
- se ? /* @__PURE__ */ jsxs(Alert, { variant: "destructive", children: [
77071
- /* @__PURE__ */ jsx(AlertTitle, { children: "Unable to load details" }),
77072
- /* @__PURE__ */ jsx(AlertDescription, { children: se })
77073
- ] }) : j ? /* @__PURE__ */ jsxs("div", { className: "rounded-xl border bg-background p-4", children: [
77074
- /* @__PURE__ */ jsxs("div", { className: "mb-4", children: [
77075
- /* @__PURE__ */ jsx("p", { className: "text-base font-semibold", children: "Monthly Sales Performance" }),
77076
- /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Rolling 12-month sales dollars and units sold pulled from the detailed endpoint." })
77077
- ] }),
77078
- /* @__PURE__ */ jsx(
77079
- SalesChart,
77053
+ /* @__PURE__ */ jsx("div", { className: "space-y-6", children: se ? /* @__PURE__ */ jsxs(Alert, { variant: "destructive", children: [
77054
+ /* @__PURE__ */ jsx(AlertTitle, { children: "Unable to load details" }),
77055
+ /* @__PURE__ */ jsx(AlertDescription, { children: se })
77056
+ ] }) : /* @__PURE__ */ jsxs("div", { className: "rounded-xl border bg-background p-4", children: [
77057
+ /* @__PURE__ */ jsxs("div", { className: "mb-4 space-y-2", children: [
77058
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Rolling 12-month sales dollars and units sold pulled from the detailed endpoint." }),
77059
+ Be && /* @__PURE__ */ jsx("div", { "aria-live": "polite", "aria-busy": "true", children: /* @__PURE__ */ jsx(
77060
+ Progress,
77080
77061
  {
77081
- statistics: j.SalesStatistics ?? [],
77082
- mode: "month",
77083
- chartHeight: 320,
77084
- loading: Be
77062
+ value: Fe,
77063
+ className: "h-2 w-full animate-pulse",
77064
+ "aria-label": "Loading performance data"
77085
77065
  }
77086
- )
77087
- ] }) : /* @__PURE__ */ jsxs(
77088
- "div",
77066
+ ) })
77067
+ ] }),
77068
+ /* @__PURE__ */ jsx(
77069
+ SalesChart,
77089
77070
  {
77090
- className: "rounded-xl border bg-background p-6 text-sm text-muted-foreground",
77091
- "aria-live": "polite",
77092
- "aria-busy": "true",
77093
- children: [
77094
- /* @__PURE__ */ jsx("p", { className: "text-base font-semibold text-foreground", children: "Loading monthly sales performance" }),
77095
- /* @__PURE__ */ jsx(
77096
- Progress,
77097
- {
77098
- value: 65,
77099
- className: "mt-4 h-2 w-full animate-pulse",
77100
- "aria-label": "Loading monthly sales performance"
77101
- }
77102
- ),
77103
- /* @__PURE__ */ jsx("p", { className: "mt-2 text-xs", children: "Gathering product summary and sales statistics..." })
77104
- ]
77071
+ statistics: We,
77072
+ mode: "month",
77073
+ chartHeight: 320
77105
77074
  }
77106
- )
77107
- ] })
77075
+ ),
77076
+ Be && /* @__PURE__ */ jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: "Gathering product summary and sales statistics..." })
77077
+ ] }) })
77108
77078
  ] }) })
77109
77079
  ] });
77110
77080
  }
@@ -1161,7 +1161,7 @@ ${e}</tr>
1161
1161
  `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${escape2(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){const o=this.parser.parseInline(n),l=cleanUrl(e);if(l===null)return o;e=l;let d='<a href="'+e+'"';return t&&(d+=' title="'+escape2(t)+'"'),d+=">"+o+"</a>",d}image({href:e,title:t,text:n,tokens:o}){o&&(n=this.parser.parseInline(o,this.parser.textRenderer));const l=cleanUrl(e);if(l===null)return escape2(n);e=l;let d=`<img src="${e}" alt="${n}"`;return t&&(d+=` title="${escape2(t)}"`),d+=">",d}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:escape2(e.text)}},_TextRenderer=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}},_Parser=class vr{constructor(t){en(this,"options");en(this,"renderer");en(this,"textRenderer");this.options=t||_defaults,this.options.renderer=this.options.renderer||new _Renderer,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new _TextRenderer}static parse(t,n){return new vr(n).parse(t)}static parseInline(t,n){return new vr(n).parseInline(t)}parse(t,n=!0){var l,d;let o="";for(let f=0;f<t.length;f++){const g=t[f];if((d=(l=this.options.extensions)==null?void 0:l.renderers)!=null&&d[g.type]){const _=g,S=this.options.extensions.renderers[_.type].call({parser:this},_);if(S!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(_.type)){o+=S||"";continue}}const b=g;switch(b.type){case"space":{o+=this.renderer.space(b);continue}case"hr":{o+=this.renderer.hr(b);continue}case"heading":{o+=this.renderer.heading(b);continue}case"code":{o+=this.renderer.code(b);continue}case"table":{o+=this.renderer.table(b);continue}case"blockquote":{o+=this.renderer.blockquote(b);continue}case"list":{o+=this.renderer.list(b);continue}case"html":{o+=this.renderer.html(b);continue}case"paragraph":{o+=this.renderer.paragraph(b);continue}case"text":{let _=b,S=this.renderer.text(_);for(;f+1<t.length&&t[f+1].type==="text";)_=t[++f],S+=`
1162
1162
  `+this.renderer.text(_);n?o+=this.renderer.paragraph({type:"paragraph",raw:S,text:S,tokens:[{type:"text",raw:S,text:S,escaped:!0}]}):o+=S;continue}default:{const _='Token with "'+b.type+'" type was not found.';if(this.options.silent)return console.error(_),"";throw new Error(_)}}}return o}parseInline(t,n=this.renderer){var l,d;let o="";for(let f=0;f<t.length;f++){const g=t[f];if((d=(l=this.options.extensions)==null?void 0:l.renderers)!=null&&d[g.type]){const _=this.options.extensions.renderers[g.type].call({parser:this},g);if(_!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(g.type)){o+=_||"";continue}}const b=g;switch(b.type){case"escape":{o+=n.text(b);break}case"html":{o+=n.html(b);break}case"link":{o+=n.link(b);break}case"image":{o+=n.image(b);break}case"strong":{o+=n.strong(b);break}case"em":{o+=n.em(b);break}case"codespan":{o+=n.codespan(b);break}case"br":{o+=n.br(b);break}case"del":{o+=n.del(b);break}case"text":{o+=n.text(b);break}default:{const _='Token with "'+b.type+'" type was not found.';if(this.options.silent)return console.error(_),"";throw new Error(_)}}}return o}},_Hooks=(dn=class{constructor(e){en(this,"options");en(this,"block");this.options=e||_defaults}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?_Lexer.lex:_Lexer.lexInline}provideParser(){return this.block?_Parser.parse:_Parser.parseInline}},en(dn,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"])),dn),Marked=class{constructor(...e){en(this,"defaults",_getDefaults());en(this,"options",this.setOptions);en(this,"parse",this.parseMarkdown(!0));en(this,"parseInline",this.parseMarkdown(!1));en(this,"Parser",_Parser);en(this,"Renderer",_Renderer);en(this,"TextRenderer",_TextRenderer);en(this,"Lexer",_Lexer);en(this,"Tokenizer",_Tokenizer);en(this,"Hooks",_Hooks);this.use(...e)}walkTokens(e,t){var o,l;let n=[];for(const d of e)switch(n=n.concat(t.call(this,d)),d.type){case"table":{const f=d;for(const g of f.header)n=n.concat(this.walkTokens(g.tokens,t));for(const g of f.rows)for(const b of g)n=n.concat(this.walkTokens(b.tokens,t));break}case"list":{const f=d;n=n.concat(this.walkTokens(f.items,t));break}default:{const f=d;(l=(o=this.defaults.extensions)==null?void 0:o.childTokens)!=null&&l[f.type]?this.defaults.extensions.childTokens[f.type].forEach(g=>{const b=f[g].flat(1/0);n=n.concat(this.walkTokens(b,t))}):f.tokens&&(n=n.concat(this.walkTokens(f.tokens,t)))}}return n}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{const o={...n};if(o.async=this.defaults.async||o.async||!1,n.extensions&&(n.extensions.forEach(l=>{if(!l.name)throw new Error("extension name required");if("renderer"in l){const d=t.renderers[l.name];d?t.renderers[l.name]=function(...f){let g=l.renderer.apply(this,f);return g===!1&&(g=d.apply(this,f)),g}:t.renderers[l.name]=l.renderer}if("tokenizer"in l){if(!l.level||l.level!=="block"&&l.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const d=t[l.level];d?d.unshift(l.tokenizer):t[l.level]=[l.tokenizer],l.start&&(l.level==="block"?t.startBlock?t.startBlock.push(l.start):t.startBlock=[l.start]:l.level==="inline"&&(t.startInline?t.startInline.push(l.start):t.startInline=[l.start]))}"childTokens"in l&&l.childTokens&&(t.childTokens[l.name]=l.childTokens)}),o.extensions=t),n.renderer){const l=this.defaults.renderer||new _Renderer(this.defaults);for(const d in n.renderer){if(!(d in l))throw new Error(`renderer '${d}' does not exist`);if(["options","parser"].includes(d))continue;const f=d,g=n.renderer[f],b=l[f];l[f]=(..._)=>{let S=g.apply(l,_);return S===!1&&(S=b.apply(l,_)),S||""}}o.renderer=l}if(n.tokenizer){const l=this.defaults.tokenizer||new _Tokenizer(this.defaults);for(const d in n.tokenizer){if(!(d in l))throw new Error(`tokenizer '${d}' does not exist`);if(["options","rules","lexer"].includes(d))continue;const f=d,g=n.tokenizer[f],b=l[f];l[f]=(..._)=>{let S=g.apply(l,_);return S===!1&&(S=b.apply(l,_)),S}}o.tokenizer=l}if(n.hooks){const l=this.defaults.hooks||new _Hooks;for(const d in n.hooks){if(!(d in l))throw new Error(`hook '${d}' does not exist`);if(["options","block"].includes(d))continue;const f=d,g=n.hooks[f],b=l[f];_Hooks.passThroughHooks.has(d)?l[f]=_=>{if(this.defaults.async)return Promise.resolve(g.call(l,_)).then(R=>b.call(l,R));const S=g.call(l,_);return b.call(l,S)}:l[f]=(..._)=>{let S=g.apply(l,_);return S===!1&&(S=b.apply(l,_)),S}}o.hooks=l}if(n.walkTokens){const l=this.defaults.walkTokens,d=n.walkTokens;o.walkTokens=function(f){let g=[];return g.push(d.call(this,f)),l&&(g=g.concat(l.call(this,f))),g}}this.defaults={...this.defaults,...o}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return _Lexer.lex(e,t??this.defaults)}parser(e,t){return _Parser.parse(e,t??this.defaults)}parseMarkdown(e){return(n,o)=>{const l={...o},d={...this.defaults,...l},f=this.onError(!!d.silent,!!d.async);if(this.defaults.async===!0&&l.async===!1)return f(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return f(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return f(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));d.hooks&&(d.hooks.options=d,d.hooks.block=e);const g=d.hooks?d.hooks.provideLexer():e?_Lexer.lex:_Lexer.lexInline,b=d.hooks?d.hooks.provideParser():e?_Parser.parse:_Parser.parseInline;if(d.async)return Promise.resolve(d.hooks?d.hooks.preprocess(n):n).then(_=>g(_,d)).then(_=>d.hooks?d.hooks.processAllTokens(_):_).then(_=>d.walkTokens?Promise.all(this.walkTokens(_,d.walkTokens)).then(()=>_):_).then(_=>b(_,d)).then(_=>d.hooks?d.hooks.postprocess(_):_).catch(f);try{d.hooks&&(n=d.hooks.preprocess(n));let _=g(n,d);d.hooks&&(_=d.hooks.processAllTokens(_)),d.walkTokens&&this.walkTokens(_,d.walkTokens);let S=b(_,d);return d.hooks&&(S=d.hooks.postprocess(S)),S}catch(_){return f(_)}}}onError(e,t){return n=>{if(n.message+=`
1163
1163
  Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+escape2(n.message+"",!0)+"</pre>";return t?Promise.resolve(o):o}if(t)return Promise.reject(n);throw n}}},markedInstance=new Marked;function marked(e,t){return markedInstance.parse(e,t)}marked.options=marked.setOptions=function(e){return markedInstance.setOptions(e),marked.defaults=markedInstance.defaults,changeDefaults(marked.defaults),marked},marked.getDefaults=_getDefaults,marked.defaults=_defaults,marked.use=function(...e){return markedInstance.use(...e),marked.defaults=markedInstance.defaults,changeDefaults(marked.defaults),marked},marked.walkTokens=function(e,t){return markedInstance.walkTokens(e,t)},marked.parseInline=markedInstance.parseInline,marked.Parser=_Parser,marked.parser=_Parser.parse,marked.Renderer=_Renderer,marked.TextRenderer=_TextRenderer,marked.Lexer=_Lexer,marked.lexer=_Lexer.lex,marked.Tokenizer=_Tokenizer,marked.Hooks=_Hooks,marked.parse=marked,marked.options,marked.setOptions,marked.use,marked.walkTokens,marked.parseInline,_Parser.parse,_Lexer.lex;/*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0/LICENSE */const{entries,setPrototypeOf,isFrozen,getPrototypeOf,getOwnPropertyDescriptor}=Object;let{freeze,seal,create}=Object,{apply:apply$1,construct}=typeof Reflect<"u"&&Reflect;freeze||(freeze=function(t){return t}),seal||(seal=function(t){return t}),apply$1||(apply$1=function(t,n){for(var o=arguments.length,l=new Array(o>2?o-2:0),d=2;d<o;d++)l[d-2]=arguments[d];return t.apply(n,l)}),construct||(construct=function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),l=1;l<n;l++)o[l-1]=arguments[l];return new t(...o)});const arrayForEach=unapply(Array.prototype.forEach),arrayLastIndexOf=unapply(Array.prototype.lastIndexOf),arrayPop=unapply(Array.prototype.pop),arrayPush=unapply(Array.prototype.push),arraySplice=unapply(Array.prototype.splice),stringToLowerCase=unapply(String.prototype.toLowerCase),stringToString=unapply(String.prototype.toString),stringMatch=unapply(String.prototype.match),stringReplace=unapply(String.prototype.replace),stringIndexOf=unapply(String.prototype.indexOf),stringTrim=unapply(String.prototype.trim),objectHasOwnProperty=unapply(Object.prototype.hasOwnProperty),regExpTest=unapply(RegExp.prototype.test),typeErrorCreate=unconstruct(TypeError);function unapply(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,o=new Array(n>1?n-1:0),l=1;l<n;l++)o[l-1]=arguments[l];return apply$1(e,t,o)}}function unconstruct(e){return function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return construct(e,n)}}function addToSet(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:stringToLowerCase;setPrototypeOf&&setPrototypeOf(e,null);let o=t.length;for(;o--;){let l=t[o];if(typeof l=="string"){const d=n(l);d!==l&&(isFrozen(t)||(t[o]=d),l=d)}e[l]=!0}return e}function cleanArray(e){for(let t=0;t<e.length;t++)objectHasOwnProperty(e,t)||(e[t]=null);return e}function clone(e){const t=create(null);for(const[n,o]of entries(e))objectHasOwnProperty(e,n)&&(Array.isArray(o)?t[n]=cleanArray(o):o&&typeof o=="object"&&o.constructor===Object?t[n]=clone(o):t[n]=o);return t}function lookupGetter(e,t){for(;e!==null;){const o=getOwnPropertyDescriptor(e,t);if(o){if(o.get)return unapply(o.get);if(typeof o.value=="function")return unapply(o.value)}e=getPrototypeOf(e)}function n(){return null}return n}const html$1=freeze(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),svg$1=freeze(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),svgFilters=freeze(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),svgDisallowed=freeze(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),mathMl$1=freeze(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),mathMlDisallowed=freeze(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),text$1=freeze(["#text"]),html=freeze(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),svg=freeze(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),mathMl=freeze(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),xml=freeze(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),MUSTACHE_EXPR=seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm),ERB_EXPR=seal(/<%[\w\W]*|[\w\W]*%>/gm),TMPLIT_EXPR=seal(/\$\{[\w\W]*/gm),DATA_ATTR=seal(/^data-[\-\w.\u00B7-\uFFFF]+$/),ARIA_ATTR=seal(/^aria-[\-\w]+$/),IS_ALLOWED_URI=seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),IS_SCRIPT_OR_DATA=seal(/^(?:\w+script|data):/i),ATTR_WHITESPACE=seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),DOCTYPE_NAME=seal(/^html$/i),CUSTOM_ELEMENT=seal(/^[a-z][.\w]*(-[.\w]+)+$/i);var EXPRESSIONS=Object.freeze({__proto__:null,ARIA_ATTR,ATTR_WHITESPACE,CUSTOM_ELEMENT,DATA_ATTR,DOCTYPE_NAME,ERB_EXPR,IS_ALLOWED_URI,IS_SCRIPT_OR_DATA,MUSTACHE_EXPR,TMPLIT_EXPR});const NODE_TYPE={element:1,text:3,progressingInstruction:7,comment:8,document:9},getGlobal=function e(){return typeof window>"u"?null:window},_createTrustedTypesPolicy=function e(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let o=null;const l="data-tt-policy-suffix";n&&n.hasAttribute(l)&&(o=n.getAttribute(l));const d="dompurify"+(o?"#"+o:"");try{return t.createPolicy(d,{createHTML(f){return f},createScriptURL(f){return f}})}catch{return console.warn("TrustedTypes policy "+d+" could not be created."),null}},_createHooksMap=function e(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function createDOMPurify(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:getGlobal();const t=Xt=>createDOMPurify(Xt);if(t.version="3.3.0",t.removed=[],!e||!e.document||e.document.nodeType!==NODE_TYPE.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const o=n,l=o.currentScript,{DocumentFragment:d,HTMLTemplateElement:f,Node:g,Element:b,NodeFilter:_,NamedNodeMap:S=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:R,DOMParser:C,trustedTypes:E}=e,A=b.prototype,M=lookupGetter(A,"cloneNode"),I=lookupGetter(A,"remove"),j=lookupGetter(A,"nextSibling"),q=lookupGetter(A,"childNodes"),Q=lookupGetter(A,"parentNode");if(typeof f=="function"){const Xt=n.createElement("template");Xt.content&&Xt.content.ownerDocument&&(n=Xt.content.ownerDocument)}let te,F="";const{implementation:V,createNodeIterator:ne,createDocumentFragment:ae,getElementsByTagName:se}=n,{importNode:Oe}=o;let Ne=_createHooksMap();t.isSupported=typeof entries=="function"&&typeof Q=="function"&&V&&V.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:oe,ERB_EXPR:$e,TMPLIT_EXPR:Ae,DATA_ATTR:je,ARIA_ATTR:Be,IS_SCRIPT_OR_DATA:qe,ATTR_WHITESPACE:Ve,CUSTOM_ELEMENT:Le}=EXPRESSIONS;let{IS_ALLOWED_URI:He}=EXPRESSIONS,We=null;const ze=addToSet({},[...html$1,...svg$1,...svgFilters,...mathMl$1,...text$1]);let Xe=null;const nt=addToSet({},[...html,...svg,...mathMl,...xml]);let Je=Object.seal(create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),st=null,et=null;const at=Object.seal(create(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let tt=!0,ot=!0,lt=!1,Ge=!0,$t=!1,rt=!0,Rt=!1,dt=!1,It=!1,Mt=!1,Ct=!1,Ke=!1,Ye=!0,Ze=!1;const ct="user-content-";let mt=!0,ft=!1,yt={},Ht=null;const Kt=addToSet({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let un=null;const hn=addToSet({},["audio","video","img","source","image","track"]);let qt=null;const An=addToSet({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),xn="http://www.w3.org/1998/Math/MathML",Rn="http://www.w3.org/2000/svg",vn="http://www.w3.org/1999/xhtml";let Pn=vn,Mn=!1,$n=null;const Vn=addToSet({},[xn,Rn,vn],stringToString);let Jt=addToSet({},["mi","mo","mn","ms","mtext"]),Zt=addToSet({},["annotation-xml"]);const Ut=addToSet({},["title","style","font","a","script"]);let tn=null;const Yt=["application/xhtml+xml","text/html"],an="text/html";let mn=null,On=null;const Fn=n.createElement("form"),Cn=function(it){return it instanceof RegExp||it instanceof Function},Bn=function(){let it=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(On&&On===it)){if((!it||typeof it!="object")&&(it={}),it=clone(it),tn=Yt.indexOf(it.PARSER_MEDIA_TYPE)===-1?an:it.PARSER_MEDIA_TYPE,mn=tn==="application/xhtml+xml"?stringToString:stringToLowerCase,We=objectHasOwnProperty(it,"ALLOWED_TAGS")?addToSet({},it.ALLOWED_TAGS,mn):ze,Xe=objectHasOwnProperty(it,"ALLOWED_ATTR")?addToSet({},it.ALLOWED_ATTR,mn):nt,$n=objectHasOwnProperty(it,"ALLOWED_NAMESPACES")?addToSet({},it.ALLOWED_NAMESPACES,stringToString):Vn,qt=objectHasOwnProperty(it,"ADD_URI_SAFE_ATTR")?addToSet(clone(An),it.ADD_URI_SAFE_ATTR,mn):An,un=objectHasOwnProperty(it,"ADD_DATA_URI_TAGS")?addToSet(clone(hn),it.ADD_DATA_URI_TAGS,mn):hn,Ht=objectHasOwnProperty(it,"FORBID_CONTENTS")?addToSet({},it.FORBID_CONTENTS,mn):Kt,st=objectHasOwnProperty(it,"FORBID_TAGS")?addToSet({},it.FORBID_TAGS,mn):clone({}),et=objectHasOwnProperty(it,"FORBID_ATTR")?addToSet({},it.FORBID_ATTR,mn):clone({}),yt=objectHasOwnProperty(it,"USE_PROFILES")?it.USE_PROFILES:!1,tt=it.ALLOW_ARIA_ATTR!==!1,ot=it.ALLOW_DATA_ATTR!==!1,lt=it.ALLOW_UNKNOWN_PROTOCOLS||!1,Ge=it.ALLOW_SELF_CLOSE_IN_ATTR!==!1,$t=it.SAFE_FOR_TEMPLATES||!1,rt=it.SAFE_FOR_XML!==!1,Rt=it.WHOLE_DOCUMENT||!1,Mt=it.RETURN_DOM||!1,Ct=it.RETURN_DOM_FRAGMENT||!1,Ke=it.RETURN_TRUSTED_TYPE||!1,It=it.FORCE_BODY||!1,Ye=it.SANITIZE_DOM!==!1,Ze=it.SANITIZE_NAMED_PROPS||!1,mt=it.KEEP_CONTENT!==!1,ft=it.IN_PLACE||!1,He=it.ALLOWED_URI_REGEXP||IS_ALLOWED_URI,Pn=it.NAMESPACE||vn,Jt=it.MATHML_TEXT_INTEGRATION_POINTS||Jt,Zt=it.HTML_INTEGRATION_POINTS||Zt,Je=it.CUSTOM_ELEMENT_HANDLING||{},it.CUSTOM_ELEMENT_HANDLING&&Cn(it.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Je.tagNameCheck=it.CUSTOM_ELEMENT_HANDLING.tagNameCheck),it.CUSTOM_ELEMENT_HANDLING&&Cn(it.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Je.attributeNameCheck=it.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),it.CUSTOM_ELEMENT_HANDLING&&typeof it.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Je.allowCustomizedBuiltInElements=it.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),$t&&(ot=!1),Ct&&(Mt=!0),yt&&(We=addToSet({},text$1),Xe=[],yt.html===!0&&(addToSet(We,html$1),addToSet(Xe,html)),yt.svg===!0&&(addToSet(We,svg$1),addToSet(Xe,svg),addToSet(Xe,xml)),yt.svgFilters===!0&&(addToSet(We,svgFilters),addToSet(Xe,svg),addToSet(Xe,xml)),yt.mathMl===!0&&(addToSet(We,mathMl$1),addToSet(Xe,mathMl),addToSet(Xe,xml))),it.ADD_TAGS&&(typeof it.ADD_TAGS=="function"?at.tagCheck=it.ADD_TAGS:(We===ze&&(We=clone(We)),addToSet(We,it.ADD_TAGS,mn))),it.ADD_ATTR&&(typeof it.ADD_ATTR=="function"?at.attributeCheck=it.ADD_ATTR:(Xe===nt&&(Xe=clone(Xe)),addToSet(Xe,it.ADD_ATTR,mn))),it.ADD_URI_SAFE_ATTR&&addToSet(qt,it.ADD_URI_SAFE_ATTR,mn),it.FORBID_CONTENTS&&(Ht===Kt&&(Ht=clone(Ht)),addToSet(Ht,it.FORBID_CONTENTS,mn)),mt&&(We["#text"]=!0),Rt&&addToSet(We,["html","head","body"]),We.table&&(addToSet(We,["tbody"]),delete st.tbody),it.TRUSTED_TYPES_POLICY){if(typeof it.TRUSTED_TYPES_POLICY.createHTML!="function")throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof it.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');te=it.TRUSTED_TYPES_POLICY,F=te.createHTML("")}else te===void 0&&(te=_createTrustedTypesPolicy(E,l)),te!==null&&typeof F=="string"&&(F=te.createHTML(""));freeze&&freeze(it),On=it}},qn=addToSet({},[...svg$1,...svgFilters,...svgDisallowed]),Un=addToSet({},[...mathMl$1,...mathMlDisallowed]),sr=function(it){let Dt=Q(it);(!Dt||!Dt.tagName)&&(Dt={namespaceURI:Pn,tagName:"template"});const Wt=stringToLowerCase(it.tagName),pn=stringToLowerCase(Dt.tagName);return $n[it.namespaceURI]?it.namespaceURI===Rn?Dt.namespaceURI===vn?Wt==="svg":Dt.namespaceURI===xn?Wt==="svg"&&(pn==="annotation-xml"||Jt[pn]):!!qn[Wt]:it.namespaceURI===xn?Dt.namespaceURI===vn?Wt==="math":Dt.namespaceURI===Rn?Wt==="math"&&Zt[pn]:!!Un[Wt]:it.namespaceURI===vn?Dt.namespaceURI===Rn&&!Zt[pn]||Dt.namespaceURI===xn&&!Jt[pn]?!1:!Un[Wt]&&(Ut[Wt]||!qn[Wt]):!!(tn==="application/xhtml+xml"&&$n[it.namespaceURI]):!1},wn=function(it){arrayPush(t.removed,{element:it});try{Q(it).removeChild(it)}catch{I(it)}},Dn=function(it,Dt){try{arrayPush(t.removed,{attribute:Dt.getAttributeNode(it),from:Dt})}catch{arrayPush(t.removed,{attribute:null,from:Dt})}if(Dt.removeAttribute(it),it==="is")if(Mt||Ct)try{wn(Dt)}catch{}else try{Dt.setAttribute(it,"")}catch{}},Zn=function(it){let Dt=null,Wt=null;if(It)it="<remove></remove>"+it;else{const gn=stringMatch(it,/^[\r\n\t ]+/);Wt=gn&&gn[0]}tn==="application/xhtml+xml"&&Pn===vn&&(it='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+it+"</body></html>");const pn=te?te.createHTML(it):it;if(Pn===vn)try{Dt=new C().parseFromString(pn,tn)}catch{}if(!Dt||!Dt.documentElement){Dt=V.createDocument(Pn,"template",null);try{Dt.documentElement.innerHTML=Mn?F:pn}catch{}}const bn=Dt.body||Dt.documentElement;return it&&Wt&&bn.insertBefore(n.createTextNode(Wt),bn.childNodes[0]||null),Pn===vn?se.call(Dt,Rt?"html":"body")[0]:Rt?Dt.documentElement:bn},er=function(it){return ne.call(it.ownerDocument||it,it,_.SHOW_ELEMENT|_.SHOW_COMMENT|_.SHOW_TEXT|_.SHOW_PROCESSING_INSTRUCTION|_.SHOW_CDATA_SECTION,null)},Kn=function(it){return it instanceof R&&(typeof it.nodeName!="string"||typeof it.textContent!="string"||typeof it.removeChild!="function"||!(it.attributes instanceof S)||typeof it.removeAttribute!="function"||typeof it.setAttribute!="function"||typeof it.namespaceURI!="string"||typeof it.insertBefore!="function"||typeof it.hasChildNodes!="function")},or=function(it){return typeof g=="function"&&it instanceof g};function kn(Xt,it,Dt){arrayForEach(Xt,Wt=>{Wt.call(t,it,Dt,On)})}const lr=function(it){let Dt=null;if(kn(Ne.beforeSanitizeElements,it,null),Kn(it))return wn(it),!0;const Wt=mn(it.nodeName);if(kn(Ne.uponSanitizeElement,it,{tagName:Wt,allowedTags:We}),rt&&it.hasChildNodes()&&!or(it.firstElementChild)&&regExpTest(/<[/\w!]/g,it.innerHTML)&&regExpTest(/<[/\w!]/g,it.textContent)||it.nodeType===NODE_TYPE.progressingInstruction||rt&&it.nodeType===NODE_TYPE.comment&&regExpTest(/<[/\w]/g,it.data))return wn(it),!0;if(!(at.tagCheck instanceof Function&&at.tagCheck(Wt))&&(!We[Wt]||st[Wt])){if(!st[Wt]&&tr(Wt)&&(Je.tagNameCheck instanceof RegExp&&regExpTest(Je.tagNameCheck,Wt)||Je.tagNameCheck instanceof Function&&Je.tagNameCheck(Wt)))return!1;if(mt&&!Ht[Wt]){const pn=Q(it)||it.parentNode,bn=q(it)||it.childNodes;if(bn&&pn){const gn=bn.length;for(let Sn=gn-1;Sn>=0;--Sn){const In=M(bn[Sn],!0);In.__removalCount=(it.__removalCount||0)+1,pn.insertBefore(In,j(it))}}}return wn(it),!0}return it instanceof b&&!sr(it)||(Wt==="noscript"||Wt==="noembed"||Wt==="noframes")&&regExpTest(/<\/no(script|embed|frames)/i,it.innerHTML)?(wn(it),!0):($t&&it.nodeType===NODE_TYPE.text&&(Dt=it.textContent,arrayForEach([oe,$e,Ae],pn=>{Dt=stringReplace(Dt,pn," ")}),it.textContent!==Dt&&(arrayPush(t.removed,{element:it.cloneNode()}),it.textContent=Dt)),kn(Ne.afterSanitizeElements,it,null),!1)},cr=function(it,Dt,Wt){if(Ye&&(Dt==="id"||Dt==="name")&&(Wt in n||Wt in Fn))return!1;if(!(ot&&!et[Dt]&&regExpTest(je,Dt))){if(!(tt&&regExpTest(Be,Dt))){if(!(at.attributeCheck instanceof Function&&at.attributeCheck(Dt,it))){if(!Xe[Dt]||et[Dt]){if(!(tr(it)&&(Je.tagNameCheck instanceof RegExp&&regExpTest(Je.tagNameCheck,it)||Je.tagNameCheck instanceof Function&&Je.tagNameCheck(it))&&(Je.attributeNameCheck instanceof RegExp&&regExpTest(Je.attributeNameCheck,Dt)||Je.attributeNameCheck instanceof Function&&Je.attributeNameCheck(Dt,it))||Dt==="is"&&Je.allowCustomizedBuiltInElements&&(Je.tagNameCheck instanceof RegExp&&regExpTest(Je.tagNameCheck,Wt)||Je.tagNameCheck instanceof Function&&Je.tagNameCheck(Wt))))return!1}else if(!qt[Dt]){if(!regExpTest(He,stringReplace(Wt,Ve,""))){if(!((Dt==="src"||Dt==="xlink:href"||Dt==="href")&&it!=="script"&&stringIndexOf(Wt,"data:")===0&&un[it])){if(!(lt&&!regExpTest(qe,stringReplace(Wt,Ve,"")))){if(Wt)return!1}}}}}}}return!0},tr=function(it){return it!=="annotation-xml"&&stringMatch(it,Le)},nr=function(it){kn(Ne.beforeSanitizeAttributes,it,null);const{attributes:Dt}=it;if(!Dt||Kn(it))return;const Wt={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Xe,forceKeepAttr:void 0};let pn=Dt.length;for(;pn--;){const bn=Dt[pn],{name:gn,namespaceURI:Sn,value:In}=bn,Hn=mn(gn),zt=In;let yn=gn==="value"?zt:stringTrim(zt);if(Wt.attrName=Hn,Wt.attrValue=yn,Wt.keepAttr=!0,Wt.forceKeepAttr=void 0,kn(Ne.uponSanitizeAttribute,it,Wt),yn=Wt.attrValue,Ze&&(Hn==="id"||Hn==="name")&&(Dn(gn,it),yn=ct+yn),rt&&regExpTest(/((--!?|])>)|<\/(style|title|textarea)/i,yn)){Dn(gn,it);continue}if(Hn==="attributename"&&stringMatch(yn,"href")){Dn(gn,it);continue}if(Wt.forceKeepAttr)continue;if(!Wt.keepAttr){Dn(gn,it);continue}if(!Ge&&regExpTest(/\/>/i,yn)){Dn(gn,it);continue}$t&&arrayForEach([oe,$e,Ae],dr=>{yn=stringReplace(yn,dr," ")});const En=mn(it.nodeName);if(!cr(En,Hn,yn)){Dn(gn,it);continue}if(te&&typeof E=="object"&&typeof E.getAttributeType=="function"&&!Sn)switch(E.getAttributeType(En,Hn)){case"TrustedHTML":{yn=te.createHTML(yn);break}case"TrustedScriptURL":{yn=te.createScriptURL(yn);break}}if(yn!==zt)try{Sn?it.setAttributeNS(Sn,gn,yn):it.setAttribute(gn,yn),Kn(it)?wn(it):arrayPop(t.removed)}catch{Dn(gn,it)}}kn(Ne.afterSanitizeAttributes,it,null)},ur=function Xt(it){let Dt=null;const Wt=er(it);for(kn(Ne.beforeSanitizeShadowDOM,it,null);Dt=Wt.nextNode();)kn(Ne.uponSanitizeShadowNode,Dt,null),lr(Dt),nr(Dt),Dt.content instanceof d&&Xt(Dt.content);kn(Ne.afterSanitizeShadowDOM,it,null)};return t.sanitize=function(Xt){let it=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Dt=null,Wt=null,pn=null,bn=null;if(Mn=!Xt,Mn&&(Xt="<!-->"),typeof Xt!="string"&&!or(Xt))if(typeof Xt.toString=="function"){if(Xt=Xt.toString(),typeof Xt!="string")throw typeErrorCreate("dirty is not a string, aborting")}else throw typeErrorCreate("toString is not a function");if(!t.isSupported)return Xt;if(dt||Bn(it),t.removed=[],typeof Xt=="string"&&(ft=!1),ft){if(Xt.nodeName){const In=mn(Xt.nodeName);if(!We[In]||st[In])throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place")}}else if(Xt instanceof g)Dt=Zn("<!---->"),Wt=Dt.ownerDocument.importNode(Xt,!0),Wt.nodeType===NODE_TYPE.element&&Wt.nodeName==="BODY"||Wt.nodeName==="HTML"?Dt=Wt:Dt.appendChild(Wt);else{if(!Mt&&!$t&&!Rt&&Xt.indexOf("<")===-1)return te&&Ke?te.createHTML(Xt):Xt;if(Dt=Zn(Xt),!Dt)return Mt?null:Ke?F:""}Dt&&It&&wn(Dt.firstChild);const gn=er(ft?Xt:Dt);for(;pn=gn.nextNode();)lr(pn),nr(pn),pn.content instanceof d&&ur(pn.content);if(ft)return Xt;if(Mt){if(Ct)for(bn=ae.call(Dt.ownerDocument);Dt.firstChild;)bn.appendChild(Dt.firstChild);else bn=Dt;return(Xe.shadowroot||Xe.shadowrootmode)&&(bn=Oe.call(o,bn,!0)),bn}let Sn=Rt?Dt.outerHTML:Dt.innerHTML;return Rt&&We["!doctype"]&&Dt.ownerDocument&&Dt.ownerDocument.doctype&&Dt.ownerDocument.doctype.name&&regExpTest(DOCTYPE_NAME,Dt.ownerDocument.doctype.name)&&(Sn="<!DOCTYPE "+Dt.ownerDocument.doctype.name+`>
1164
- `+Sn),$t&&arrayForEach([oe,$e,Ae],In=>{Sn=stringReplace(Sn,In," ")}),te&&Ke?te.createHTML(Sn):Sn},t.setConfig=function(){let Xt=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Bn(Xt),dt=!0},t.clearConfig=function(){On=null,dt=!1},t.isValidAttribute=function(Xt,it,Dt){On||Bn({});const Wt=mn(Xt),pn=mn(it);return cr(Wt,pn,Dt)},t.addHook=function(Xt,it){typeof it=="function"&&arrayPush(Ne[Xt],it)},t.removeHook=function(Xt,it){if(it!==void 0){const Dt=arrayLastIndexOf(Ne[Xt],it);return Dt===-1?void 0:arraySplice(Ne[Xt],Dt,1)[0]}return arrayPop(Ne[Xt])},t.removeHooks=function(Xt){Ne[Xt]=[]},t.removeAllHooks=function(){Ne=_createHooksMap()},t}var purify=createDOMPurify();function markdownToSafeHTML(e){const t=marked(e,{async:!1});return purify.sanitize(t,{ALLOWED_TAGS:["h1","h2","h3","h4","h5","h6","b","strong","i","em","u","s","sub","sup","mark","blockquote","q","ul","ol","li","dl","dt","dd","p","div","span","br","hr","table","thead","tbody","tfoot","tr","th","td"]})}function SkeletonMessage({botStatus:e}){return jsxRuntime.jsxs("div",{className:"flex items-start gap-2",children:[jsxRuntime.jsx("div",{className:"h-8 w-8 mt-1 rounded-full bg-gray-300 animate-pulse flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex flex-col max-w-[70%]",children:[jsxRuntime.jsx("p",{className:"mb-1",children:"Assistant"}),jsxRuntime.jsxs("div",{className:"flex items-end gap-2",children:[jsxRuntime.jsx("div",{className:"rounded-md p-3 break-words bg-white border rounded-tl-none",children:jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse"}),jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse delay-150"}),jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse delay-300"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:e})]})}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:new Date().toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})})]})]})]})}function ChatMessages({messages:e,appID:t,botStatus:n,isAssistantChat:o}){const l=(()=>{const d=new Set;let f=null;for(const g of e){const b=(g.senderName??"").trim();b&&(f===b?d.add(g.id):f=b)}return d})();return jsxRuntime.jsxs("div",{children:[e.map(d=>{var g;const f=d.fromPartnerID===t;return jsxRuntime.jsx("div",{className:cn("flex items-start gap-2 mt-2 mb-2",f&&"flex-row-reverse"),children:jsxRuntime.jsxs("div",{className:"flex flex-col max-w-[70%]",children:[!l.has(d.id)&&!!((g=d.senderName)!=null&&g.trim())&&jsxRuntime.jsx("p",{className:cn("mb-1 flex",f&&"flex-row-reverse"),children:d.senderName}),jsxRuntime.jsxs("div",{className:cn("flex items-baseline gap-2",f&&"flex-row-reverse"),children:[jsxRuntime.jsx("div",{className:cn("rounded-md p-3 break-words [&_li]:ml-6 [&_li]:list-disc [&_h1]:text-lg [&_h1]:font-bold [&_h1]:mt-4 [&_h2]:font-bold [&_h2]:mt-4 [&_h3]:mt-4 ",f?"bg-primary text-white rounded-tr-none":"bg-white border rounded-tl-none"),children:parser(markdownToSafeHTML(d.content))}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:(()=>{const b=new Date(d.timestamp);return isToday(b)?b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}):isYesterday(b)?`Yesterday, ${b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})}`:`${b.toLocaleDateString([],{month:"short",day:"numeric"})} ${b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})}`})()})]})]})},d.id)}),n!==""&&jsxRuntime.jsx(SkeletonMessage,{botStatus:n}),e.length===0&&!o&&jsxRuntime.jsxs("div",{className:"mt-1 text-xl",children:[jsxRuntime.jsx(Send,{className:"w-full h-32"}),jsxRuntime.jsx("p",{className:"text-center",children:"No messages yet... Say hello!"})]}),e.length===0&&n===""&&o&&jsxRuntime.jsxs("div",{className:"text-center py-8",children:[jsxRuntime.jsx("p",{children:"The Randmar Assistant is ready to help you. Ask anything about products, orders, carts, shipments and tracking numbers."}),jsxRuntime.jsx("p",{children:jsxRuntime.jsx("strong",{children:'Try it now, type "my open orders"!'})})]})]})}const Textarea=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("textarea",{className:cn("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...t}));Textarea.displayName="Textarea";function ChatMainArea({activeChat:e,activeChatObj:t,appID:n,messagesEndRef:o,inputRef:l,content:d,setContent:f,handleSendMessage:g,isPostBizDevConvoLoading:b,acceptChat:_}){return jsxRuntime.jsx("div",{className:"flex-5 flex flex-col",children:e?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center p-4 border-b",children:[jsxRuntime.jsx(Avatar,{className:"h-8 w-8 flex-shrink-0 rounded-none",children:jsxRuntime.jsx(PartnerLogo,{id:e[0]===n?e[1]:e[0],width:72,height:72})}),jsxRuntime.jsx("div",{className:"ml-3 font-medium",children:t==null?void 0:t.name})]}),t!=null&&t.pending&&t.partner1==n?jsxRuntime.jsx("p",{className:"mt-8 p-2 mx-auto",children:"This conversation is awaiting approval by the other party — please check back later."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(ScrollArea,{className:"flex-1 pl-2 pr-2 bg-slate-50",children:[jsxRuntime.jsx("div",{className:(t==null?void 0:t.messages)===null?" opacity-0":"",children:jsxRuntime.jsx(ChatMessages,{messages:(t==null?void 0:t.messages)??[],appID:n,isAssistantChat:!1,botStatus:""})}),jsxRuntime.jsx("div",{ref:o})]}),jsxRuntime.jsxs("div",{className:"p-4 border-t border-r flex",children:[(t==null?void 0:t.pending)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button$1,{disabled:b,onClick:()=>_(),children:[jsxRuntime.jsx(Handshake,{}),"Accept Conversation Request"]}),jsxRuntime.jsxs(Button$1,{disabled:!0,className:"ml-2",children:[jsxRuntime.jsx(ThumbsDown,{}),"Block Partner"]})]}),jsxRuntime.jsx(Textarea,{ref:l,placeholder:"Type a message...",value:d,onChange:S=>f(S.target.value),onKeyDown:S=>{S.key!=="Enter"||S.shiftKey||(S.preventDefault(),g())},className:t!=null&&t.pending?"collapse":"flex-1 resize-none field-sizing-content max-h-[30em]",disabled:t==null?void 0:t.pending}),jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",className:t!=null&&t.pending?"collapse":"ml-2 h-8 w-8",disabled:t==null?void 0:t.pending,onClick:g,children:jsxRuntime.jsx(Send,{className:"h-6 w-6"})})})]})]})]}):jsxRuntime.jsxs("div",{className:"flex flex-col m-auto text-xl",children:[jsxRuntime.jsx(MousePointerClick,{className:"w-full h-32"}),jsxRuntime.jsx("p",{children:"Select a chat from the left menu to start messaging"})]})})}function ChatRightSidebar({activeChatObj:e,appID:t,sendChatToAssistant:n,isAnalyzingPartnership:o,analyzePartnership:l}){const d=e?[e.partner1,e.partner2]:void 0;return jsxRuntime.jsx("div",{className:"flex border-l flex-1",children:jsxRuntime.jsxs("div",{className:"flex flex-col p-4 border-b gap-2",children:[jsxRuntime.jsx("p",{className:"h-9 font-medium text-base/9",children:"Actions"}),jsxRuntime.jsx(reactRouterDom.Link,{className:"w-full",inert:d===void 0,to:`/${t}/Partner/${(d==null?void 0:d[0])===t?d[1]:d==null?void 0:d[0]}`,children:jsxRuntime.jsx(Button$1,{className:"w-full",disabled:d===void 0,children:"View Partner"})}),jsxRuntime.jsx(Button$1,{disabled:((e==null?void 0:e.messages)??[]).length<1,onClick:()=>n(e.messages),children:"Export to Randmar Assistant"}),jsxRuntime.jsx(Button$1,{disabled:d===void 0||o,onClick:l,children:o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Analyzing..."]}):"Analyze Partnership"}),jsxRuntime.jsx(PartnerActions,{userId:t,partnerId:(d==null?void 0:d[0])===t?d[1]:(d==null?void 0:d[0])||"",isAdmin:!1}),jsxRuntime.jsx(PeopleSection,{appID:t,activeChatObj:e}),jsxRuntime.jsx(LinkSection,{appID:t,activeChatObj:e})]})})}const PeopleSection=({appID:e,activeChatObj:t})=>{const n=(t==null?void 0:t.conversationID)??-1,o=!t||n===-1,{data:l,isLoading:d,isError:f,refetch:g,isFetching:b}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdPeopleQuery({routeApplicationId:e,conversationId:n},{skip:o}),_=l??[];return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("p",{className:"font-medium pt-2 border-t",children:"People"}),o?jsxRuntime.jsx("p",{className:"font-light",children:"Select a chat to see participants."}):d||b?jsxRuntime.jsx("p",{children:"Loading people..."}):f?jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx("p",{className:"text-sm text-destructive",children:"Could not load people."}),jsxRuntime.jsx(Button$1,{variant:"secondary",size:"sm",onClick:()=>g(),children:"Retry"})]}):_.length===0?jsxRuntime.jsx("p",{className:"font-light",children:"No participants found."}):jsxRuntime.jsx("ul",{className:"flex flex-col gap-2",children:_.map((S,R)=>{const C=S.ApplicationId??`${S.Name??"person"}-${R}`,E=S.LastAuthentication?new Date(S.LastAuthentication).toLocaleString():void 0;return jsxRuntime.jsxs("li",{className:"rounded border px-3 py-2 text-sm",children:[jsxRuntime.jsx("p",{className:"font-medium leading-tight",children:S.Name??"Unknown person"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:S.Role??"Role unavailable"}),jsxRuntime.jsxs("p",{className:"text-xs text-muted-foreground",children:[S.Active?"Active":"Inactive",E?` · Last auth ${E}`:""]})]},C)})})]})},LinkSection=({appID:e,activeChatObj:t})=>{const[n,o]=React.useState(!1),l=t==null?void 0:t.conversationID,d=l===void 0||l===-1,{data:f,isLoading:g}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdLinksQuery({routeApplicationId:e,conversationId:l??-1},{skip:d}),[b]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdLinkMutation(),[_]=useDeleteV4PartnerByRouteApplicationIdBusinessDevelopmentConversationLinkAndLinkIdMutation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("p",{className:"font-medium pt-2 border-t",children:"Links"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[g?jsxRuntime.jsx("p",{children:"Loading links..."}):(f==null?void 0:f.length)===0?jsxRuntime.jsx("p",{children:"No links attached."}):null,f==null?void 0:f.map(S=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("a",{href:S.URL,target:"_blank",rel:"noopener noreferrer",className:"text-randmar-red underline break-all",children:S.Title}),jsxRuntime.jsx(Button$1,{variant:"secondary",size:"icon",onClick:()=>_({routeApplicationId:e,linkId:S.LinkId}),children:jsxRuntime.jsx(Trash2,{className:"h-4 w-4"})})]},S.LinkId))]}),jsxRuntime.jsxs(Dialog,{open:n,onOpenChange:o,children:[jsxRuntime.jsx(DialogTrigger$1,{asChild:!0,children:jsxRuntime.jsx(Button$1,{className:"p-0",disabled:d,children:"Add Link"})}),jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle$1,{children:"Add Link"}),jsxRuntime.jsx(DialogDescription$1,{children:"Please enter the details for the new link."})]}),jsxRuntime.jsxs("form",{className:"space-y-4",onSubmit:S=>{S.preventDefault();const R=document.getElementById("link-title").value,C=document.getElementById("link-url").value;l===void 0||l===-1||(b({routeApplicationId:e,conversationId:l,createLinkRequest:{Title:R,Url:C}}),o(!1))},children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"link-title",children:"Title"}),jsxRuntime.jsx(Input,{id:"link-title",required:!0,minLength:2})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"link-url",children:"URL"}),jsxRuntime.jsx(Input,{id:"link-url",type:"url",required:!0,minLength:2,placeholder:"https://"})]}),jsxRuntime.jsx(Button$1,{type:"submit",disabled:d,children:"Add Link"})]})]})]})]})},UserSetupForm=e=>{const[t]=usePostV4UserByFieldNameMutation(),[n,o]=React.useState(""),[l,d]=React.useState(""),[f,g]=React.useState(!1),[b]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation();return jsxRuntime.jsxs("div",{className:"mx-auto mt-2",children:[jsxRuntime.jsx("p",{className:"mb-4",children:"Before you can start chatting, please set up your profile."}),jsxRuntime.jsxs("form",{className:"space-y-2",onSubmit:_=>{f||(g(!0),_.preventDefault(),t({fieldName:"Name",newValue:n}).then(()=>{b({routeApplicationId:e.appID,partnerId:"2"})}),t({fieldName:"Role",newValue:l}))},children:[jsxRuntime.jsx(Label$2,{htmlFor:"name",children:"Name"}),jsxRuntime.jsx(Input,{id:"name",required:!0,minLength:2,value:n,onChange:_=>o(_.target.value)}),jsxRuntime.jsx(Label$2,{htmlFor:"role",children:"Role"}),jsxRuntime.jsx(Input,{id:"role",required:!0,minLength:2,value:l,onChange:_=>d(_.target.value)}),jsxRuntime.jsx(Button$1,{type:"submit",disabled:f,children:f?"Saving...":"Save"})]})]})},sortChats=(e,t)=>e.unread>0&&t.unread===0?-1:t.unread>0&&e.unread===0?1:e.name.localeCompare(t.name);function ChatLayout({appID:e,inputRef:t,className:n}){const{setHasUnreads:o}=useChat(),{data:l,refetch:d}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationsQuery({routeApplicationId:e}),[f,g]=React.useState(!1),[b,{isLoading:_}]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation(),S=React.useRef(null),[R]=useLazyGetV4PartnerByApplicationIdAccountQuery(),{sendPrompt:C}=useGemini({outputFormat:"text",useProModel:!0}),[E,A]=React.useState(!1),[M]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation(),[I]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdReadMutation(),[j]=useLazyGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdMessagesQuery(),[q]=useLazyGetV4PartnerByRouteApplicationIdPartnerAndPartnerIdQuery(),[Q,te]=React.useState(!1);React.useEffect(()=>{l&&(oe(dt=>{const It=l.map(Mt=>{var Ke;const Ct=dt.find(Ye=>Ye.conversationID===Mt.ConversationId);return{partner1:Mt.Participant1,partner2:Mt.Participant2,name:((Ke=Mt.Participant)==null?void 0:Ke.PublicName)??"missing public name",unread:(Ct==null?void 0:Ct.unread)??0,pending:Mt.Status!=="Approved",messages:(Ct==null?void 0:Ct.messages)??null,conversationID:Mt.ConversationId,lastMessageTime:Mt.LastMessageTime??null}});return It.sort(sortChats),It}),g(!0),setTimeout(()=>{var dt;return(dt=Le.current)==null?void 0:dt.focus()},50))},[l,e]);const[F,V]=React.useState(void 0),[ne,ae]=React.useState(""),[se,Oe]=React.useState(null),[Ne,oe]=React.useState([]),[$e,Ae]=React.useState(null),je=React.useRef(null),Be=React.useRef(null),[qe,Ve]=React.useState([]),Le=t||Be,He=React.useRef(null),{toast:We}=useToast(),ze=()=>Ne.find(dt=>dt.partner1===(F==null?void 0:F[0])&&dt.partner2===(F==null?void 0:F[1]));function Xe(){const dt=ze();dt&&I({routeApplicationId:e,conversationId:dt.conversationID})}const nt=dt=>Ve(It=>[...It,dt]);React.useEffect(()=>{if(qe.length==0)return;console.log(qe.length,"unprocessedMessages detected");const dt=(Mt,Ct)=>Ct.partner1===Mt.toPartnerID&&Ct.partner2===Mt.fromPartnerID||Ct.partner2===Mt.toPartnerID&&Ct.partner1===Mt.fromPartnerID;let It=!1;qe.forEach(Mt=>{if(!Ne.some(Ct=>dt(Mt,Ct))){console.log("message received for unknown convo ID - need to refetch!"),It=!0;return}oe(Ct=>Ct.map(Ke=>{if(!dt(Mt,Ke))return Ke;const Ye=Ke.messages??[];if(Ye.some(mt=>mt.id===Mt.id))return Ke;let Ze=1;const ct=document.activeElement&&document.activeElement===Le.current;return(F==null?void 0:F[0])==Ke.partner1&&F[1]==Ke.partner2&&ct&&(ct&&(Ze=0,Xe()),setTimeout(()=>{var mt;return(mt=je.current)==null?void 0:mt.scrollIntoView({behavior:"smooth"})},50)),{...Ke,pending:!1,unread:Ke.unread+Ze,messages:[...Ye,Mt]}}).sort(sortChats))}),console.log("need refetch:",It),It&&d(),Ve([])},[qe,Ve,oe,V,F]),React.useEffect(()=>{const dt=new HubConnectionBuilder().withUrl("https://api.randmar.io/hub",{accessTokenFactory:()=>localStorage.getItem("access_token"),headers:{"X-Impersonated-Id":e}}).configureLogging(LogLevel.Information).withAutomaticReconnect().withHubProtocol(new JsonHubProtocol).build();return dt.on("ReceiveMessage",nt),dt.start().catch(It=>console.error("Error connecting to SignalR hub:",It)),Ae(dt),()=>{dt&&dt.stop()}},[e]),React.useEffect(()=>{var It;!F||!ze()||((It=Le.current)==null||It.focus(),setTimeout(()=>{var Mt;return(Mt=je.current)==null?void 0:Mt.scrollIntoView({behavior:"smooth"})},50))},[F]),React.useEffect(()=>{if(!F)return;const dt=ze();dt&&dt.conversationID!==-1&&(async()=>{var It;try{const Ct=((It=(await j({routeApplicationId:e,conversationId:dt.conversationID})).data)==null?void 0:It.map(Ke=>({id:"history"+Ke.MessageId,fromPartnerID:Ke.SenderId,toPartnerID:Ke.SenderId==dt.partner1?dt.partner2:dt.partner1,senderName:Ke.SenderName??"missing name",timestamp:new Date(Ke.SentDate+"Z").getTime(),content:Ke.Content??"no content"})))??[];oe(Ke=>Ke.map(Ye=>Ye.conversationID===dt.conversationID?{...Ye,messages:Ct}:Ye).sort(sortChats))}catch(Mt){console.error("Error fetching conversation messages:",Mt)}})()},[F,j,e]),React.useEffect(()=>{if(!F)return;const dt=ze();if(!dt)return;const It=document.activeElement&&document.activeElement===Le.current;dt.unread>0&&It&&(Xe(),oe(Mt=>Mt.map(Ct=>Ct.partner1===F[0]&&Ct.partner2===F[1]?{...Ct,unread:0}:Ct)))},[F,Ne]);const{sendMessage:Je}=useChat(),st=React.useCallback(dt=>{Je(`We have been talking with another Randmar partner and would like you to have the conversation as context for follow-up questions. Please acknowledge your reception of this chat history (one line summary of recent messages will do) and let me know that you're ready to answer questions: ${JSON.stringify(dt,null,2)}`)},[Je]),et=React.useCallback(async()=>{if(F)try{te(!0);const dt=await R({applicationId:e}),It=F[0]===e?F[1]:F[0],Mt=await q({routeApplicationId:e,partnerId:It,withSpecification:!0}),Ct=buildPartnershipAssistantPrompt(dt.data,Mt.data);Ct?Je(Ct):We({title:"Missing data",description:"We couldn't load enough data to analyze this partnership yet. Please try again shortly.",variant:"destructive"})}catch(dt){console.error("Error preparing partnership analysis:",dt),We({title:"Error",description:"Could not analyze the partnership. Please try again later.",variant:"destructive"})}finally{te(!1)}},[F,R,q,Je,We,e]);React.useEffect(()=>{o(Ne.some(dt=>dt.unread>0))},[Ne,o]);const at=(dt,It)=>{It=It.replace(/\n/g,`
1164
+ `+Sn),$t&&arrayForEach([oe,$e,Ae],In=>{Sn=stringReplace(Sn,In," ")}),te&&Ke?te.createHTML(Sn):Sn},t.setConfig=function(){let Xt=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Bn(Xt),dt=!0},t.clearConfig=function(){On=null,dt=!1},t.isValidAttribute=function(Xt,it,Dt){On||Bn({});const Wt=mn(Xt),pn=mn(it);return cr(Wt,pn,Dt)},t.addHook=function(Xt,it){typeof it=="function"&&arrayPush(Ne[Xt],it)},t.removeHook=function(Xt,it){if(it!==void 0){const Dt=arrayLastIndexOf(Ne[Xt],it);return Dt===-1?void 0:arraySplice(Ne[Xt],Dt,1)[0]}return arrayPop(Ne[Xt])},t.removeHooks=function(Xt){Ne[Xt]=[]},t.removeAllHooks=function(){Ne=_createHooksMap()},t}var purify=createDOMPurify();function markdownToSafeHTML(e){const t=marked(e,{async:!1});return purify.sanitize(t,{ALLOWED_TAGS:["h1","h2","h3","h4","h5","h6","b","strong","i","em","u","s","sub","sup","mark","blockquote","q","ul","ol","li","dl","dt","dd","p","div","span","br","hr","table","thead","tbody","tfoot","tr","th","td"]})}function SkeletonMessage({botStatus:e}){return jsxRuntime.jsxs("div",{className:"flex items-start gap-2",children:[jsxRuntime.jsx("div",{className:"h-8 w-8 mt-1 rounded-full bg-gray-300 animate-pulse flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex flex-col max-w-[70%]",children:[jsxRuntime.jsx("p",{className:"mb-1",children:"Assistant"}),jsxRuntime.jsxs("div",{className:"flex items-end gap-2",children:[jsxRuntime.jsx("div",{className:"rounded-md p-3 break-words bg-white border rounded-tl-none",children:jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse"}),jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse delay-150"}),jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full bg-primary animate-pulse delay-300"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:e})]})}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:new Date().toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})})]})]})]})}function ChatMessages({messages:e,appID:t,botStatus:n,isAssistantChat:o}){const l=(()=>{const d=new Set;let f=null;for(const g of e){const b=(g.senderName??"").trim();b&&(f===b?d.add(g.id):f=b)}return d})();return jsxRuntime.jsxs("div",{children:[e.map(d=>{var g;const f=d.fromPartnerID===t;return jsxRuntime.jsx("div",{className:cn("flex items-start gap-2 mt-2 mb-2",f&&"flex-row-reverse"),children:jsxRuntime.jsxs("div",{className:"flex flex-col max-w-[70%]",children:[!l.has(d.id)&&!!((g=d.senderName)!=null&&g.trim())&&jsxRuntime.jsx("p",{className:cn("mb-1 flex",f&&"flex-row-reverse"),children:d.senderName}),jsxRuntime.jsxs("div",{className:cn("flex items-baseline gap-2",f&&"flex-row-reverse"),children:[jsxRuntime.jsx("div",{className:cn("rounded-md p-3 break-words [&_li]:ml-6 [&_li]:list-disc [&_h1]:text-lg [&_h1]:font-bold [&_h1]:mt-4 [&_h2]:font-bold [&_h2]:mt-4 [&_h3]:mt-4 ",f?"bg-primary text-white rounded-tr-none":"bg-white border rounded-tl-none"),children:parser(markdownToSafeHTML(d.content))}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:(()=>{const b=new Date(d.timestamp);return isToday(b)?b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}):isYesterday(b)?`Yesterday, ${b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})}`:`${b.toLocaleDateString([],{month:"short",day:"numeric"})} ${b.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})}`})()})]})]})},d.id)}),n!==""&&jsxRuntime.jsx(SkeletonMessage,{botStatus:n}),e.length===0&&!o&&jsxRuntime.jsxs("div",{className:"mt-1 text-xl",children:[jsxRuntime.jsx(Send,{className:"w-full h-32"}),jsxRuntime.jsx("p",{className:"text-center",children:"No messages yet... Say hello!"})]}),e.length===0&&n===""&&o&&jsxRuntime.jsxs("div",{className:"text-center py-8",children:[jsxRuntime.jsx("p",{children:"The Randmar Assistant is ready to help you. Ask anything about products, orders, carts, shipments and tracking numbers."}),jsxRuntime.jsx("p",{children:jsxRuntime.jsx("strong",{children:'Try it now, type "my open orders"!'})})]})]})}const Textarea=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("textarea",{className:cn("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...t}));Textarea.displayName="Textarea";function ChatMainArea({activeChat:e,activeChatObj:t,appID:n,messagesEndRef:o,inputRef:l,content:d,setContent:f,handleSendMessage:g,isPostBizDevConvoLoading:b,acceptChat:_}){return jsxRuntime.jsx("div",{className:"flex-5 flex flex-col",children:e?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center p-4 border-b",children:[jsxRuntime.jsx(Avatar,{className:"h-8 w-8 flex-shrink-0 rounded-none",children:jsxRuntime.jsx(PartnerLogo,{id:e[0]===n?e[1]:e[0],width:72,height:72})}),jsxRuntime.jsx("div",{className:"ml-3 font-medium",children:t==null?void 0:t.name})]}),t!=null&&t.pending&&t.partner1==n?jsxRuntime.jsx("p",{className:"mt-8 p-2 mx-auto",children:"This conversation is awaiting approval by the other party — please check back later."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(ScrollArea,{className:"flex-1 pl-2 pr-2 bg-slate-50",children:[jsxRuntime.jsx("div",{className:(t==null?void 0:t.messages)===null?" opacity-0":"",children:jsxRuntime.jsx(ChatMessages,{messages:(t==null?void 0:t.messages)??[],appID:n,isAssistantChat:!1,botStatus:""})}),jsxRuntime.jsx("div",{ref:o})]}),jsxRuntime.jsxs("div",{className:"p-4 border-t border-r flex",children:[(t==null?void 0:t.pending)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button$1,{disabled:b,onClick:()=>_(),children:[jsxRuntime.jsx(Handshake,{}),"Accept Conversation Request"]}),jsxRuntime.jsxs(Button$1,{disabled:!0,className:"ml-2",children:[jsxRuntime.jsx(ThumbsDown,{}),"Block Partner"]})]}),jsxRuntime.jsx(Textarea,{ref:l,placeholder:"Type a message...",value:d,onChange:S=>f(S.target.value),onKeyDown:S=>{S.key!=="Enter"||S.shiftKey||(S.preventDefault(),g())},className:t!=null&&t.pending?"collapse":"flex-1 resize-none field-sizing-content max-h-[30em]",disabled:t==null?void 0:t.pending}),jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",className:t!=null&&t.pending?"collapse":"ml-2 h-8 w-8",disabled:t==null?void 0:t.pending,onClick:g,children:jsxRuntime.jsx(Send,{className:"h-6 w-6"})})})]})]})]}):jsxRuntime.jsxs("div",{className:"flex flex-col m-auto text-xl",children:[jsxRuntime.jsx(MousePointerClick,{className:"w-full h-32"}),jsxRuntime.jsx("p",{children:"Select a chat from the left menu to start messaging"})]})})}function ChatRightSidebar({activeChatObj:e,appID:t,sendChatToAssistant:n,isAnalyzingPartnership:o,analyzePartnership:l}){const d=e?[e.partner1,e.partner2]:void 0;return jsxRuntime.jsx("div",{className:"flex border-l flex-1",children:jsxRuntime.jsxs("div",{className:"flex flex-col p-4 border-b gap-2",children:[jsxRuntime.jsx("p",{className:"h-9 font-medium text-base/9",children:"Actions"}),jsxRuntime.jsx(reactRouterDom.Link,{className:"w-full",inert:d===void 0,to:`/${t}/Partner/${(d==null?void 0:d[0])===t?d[1]:d==null?void 0:d[0]}`,children:jsxRuntime.jsx(Button$1,{className:"w-full",disabled:d===void 0,children:"View Partner"})}),jsxRuntime.jsx(Button$1,{disabled:((e==null?void 0:e.messages)??[]).length<1,onClick:()=>n(e.messages),children:"Export to Randmar Assistant"}),jsxRuntime.jsx(Button$1,{disabled:d===void 0||o,onClick:l,children:o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Analyzing..."]}):"Analyze Partnership"}),jsxRuntime.jsx(PartnerActions,{userId:t,partnerId:(d==null?void 0:d[0])===t?d[1]:(d==null?void 0:d[0])||"",isAdmin:!1}),jsxRuntime.jsx(PeopleSection,{appID:t,activeChatObj:e}),jsxRuntime.jsx(LinkSection,{appID:t,activeChatObj:e})]})})}const PeopleSection=({appID:e,activeChatObj:t})=>{const n=(t==null?void 0:t.conversationID)??-1,o=!t||n===-1,{data:l,isLoading:d,isError:f,refetch:g,isFetching:b}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdPeopleQuery({routeApplicationId:e,conversationId:n},{skip:o}),_=l??[];return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("p",{className:"font-medium pt-2 border-t",children:"People"}),o?jsxRuntime.jsx("p",{className:"font-light",children:"Select a chat to see participants."}):d||b?jsxRuntime.jsx("p",{children:"Loading people..."}):f?jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsx("p",{className:"text-sm text-destructive",children:"Could not load people."}),jsxRuntime.jsx(Button$1,{variant:"secondary",size:"sm",onClick:()=>g(),children:"Retry"})]}):_.length===0?jsxRuntime.jsx("p",{className:"font-light",children:"No participants found."}):jsxRuntime.jsx("ul",{className:"flex flex-col gap-2",children:_.map((S,R)=>{const C=S.ApplicationId??`${S.Name??"person"}-${R}`,E=S.LastAuthentication?new Date(S.LastAuthentication).toLocaleString():void 0;return jsxRuntime.jsxs("li",{className:"rounded border px-3 py-2 text-sm",children:[jsxRuntime.jsx("p",{className:"font-medium leading-tight",children:S.Name??"Unknown person"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:S.Role??"Role unavailable"}),E?jsxRuntime.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last auth ",E]}):null]},C)})})]})},LinkSection=({appID:e,activeChatObj:t})=>{const[n,o]=React.useState(!1),l=t==null?void 0:t.conversationID,d=l===void 0||l===-1,{data:f,isLoading:g}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdLinksQuery({routeApplicationId:e,conversationId:l??-1},{skip:d}),[b]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdLinkMutation(),[_]=useDeleteV4PartnerByRouteApplicationIdBusinessDevelopmentConversationLinkAndLinkIdMutation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("p",{className:"font-medium pt-2 border-t",children:"Links"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[g?jsxRuntime.jsx("p",{children:"Loading links..."}):(f==null?void 0:f.length)===0?jsxRuntime.jsx("p",{children:"No links attached."}):null,f==null?void 0:f.map(S=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("a",{href:S.URL,target:"_blank",rel:"noopener noreferrer",className:"text-randmar-red underline break-all",children:S.Title}),jsxRuntime.jsx(Button$1,{variant:"secondary",size:"icon",onClick:()=>_({routeApplicationId:e,linkId:S.LinkId}),children:jsxRuntime.jsx(Trash2,{className:"h-4 w-4"})})]},S.LinkId))]}),jsxRuntime.jsxs(Dialog,{open:n,onOpenChange:o,children:[jsxRuntime.jsx(DialogTrigger$1,{asChild:!0,children:jsxRuntime.jsx(Button$1,{className:"p-0",disabled:d,children:"Add Link"})}),jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle$1,{children:"Add Link"}),jsxRuntime.jsx(DialogDescription$1,{children:"Please enter the details for the new link."})]}),jsxRuntime.jsxs("form",{className:"space-y-4",onSubmit:S=>{S.preventDefault();const R=document.getElementById("link-title").value,C=document.getElementById("link-url").value;l===void 0||l===-1||(b({routeApplicationId:e,conversationId:l,createLinkRequest:{Title:R,Url:C}}),o(!1))},children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"link-title",children:"Title"}),jsxRuntime.jsx(Input,{id:"link-title",required:!0,minLength:2})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"link-url",children:"URL"}),jsxRuntime.jsx(Input,{id:"link-url",type:"url",required:!0,minLength:2,placeholder:"https://"})]}),jsxRuntime.jsx(Button$1,{type:"submit",disabled:d,children:"Add Link"})]})]})]})]})},UserSetupForm=e=>{const[t]=usePostV4UserByFieldNameMutation(),[n,o]=React.useState(""),[l,d]=React.useState(""),[f,g]=React.useState(!1),[b]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation();return jsxRuntime.jsxs("div",{className:"mx-auto mt-2",children:[jsxRuntime.jsx("p",{className:"mb-4",children:"Before you can start chatting, please set up your profile."}),jsxRuntime.jsxs("form",{className:"space-y-2",onSubmit:_=>{f||(g(!0),_.preventDefault(),t({fieldName:"Name",newValue:n}).then(()=>{b({routeApplicationId:e.appID,partnerId:"2"})}),t({fieldName:"Role",newValue:l}))},children:[jsxRuntime.jsx(Label$2,{htmlFor:"name",children:"Name"}),jsxRuntime.jsx(Input,{id:"name",required:!0,minLength:2,value:n,onChange:_=>o(_.target.value)}),jsxRuntime.jsx(Label$2,{htmlFor:"role",children:"Role"}),jsxRuntime.jsx(Input,{id:"role",required:!0,minLength:2,value:l,onChange:_=>d(_.target.value)}),jsxRuntime.jsx(Button$1,{type:"submit",disabled:f,children:f?"Saving...":"Save"})]})]})},sortChats=(e,t)=>e.unread>0&&t.unread===0?-1:t.unread>0&&e.unread===0?1:e.name.localeCompare(t.name);function ChatLayout({appID:e,inputRef:t,className:n}){const{setHasUnreads:o}=useChat(),{data:l,refetch:d}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationsQuery({routeApplicationId:e}),[f,g]=React.useState(!1),[b,{isLoading:_}]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation(),S=React.useRef(null),[R]=useLazyGetV4PartnerByApplicationIdAccountQuery(),{sendPrompt:C}=useGemini({outputFormat:"text",useProModel:!0}),[E,A]=React.useState(!1),[M]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation(),[I]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdReadMutation(),[j]=useLazyGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationAndConversationIdMessagesQuery(),[q]=useLazyGetV4PartnerByRouteApplicationIdPartnerAndPartnerIdQuery(),[Q,te]=React.useState(!1);React.useEffect(()=>{l&&(oe(dt=>{const It=l.map(Mt=>{var Ke;const Ct=dt.find(Ye=>Ye.conversationID===Mt.ConversationId);return{partner1:Mt.Participant1,partner2:Mt.Participant2,name:((Ke=Mt.Participant)==null?void 0:Ke.PublicName)??"missing public name",unread:(Ct==null?void 0:Ct.unread)??0,pending:Mt.Status!=="Approved",messages:(Ct==null?void 0:Ct.messages)??null,conversationID:Mt.ConversationId,lastMessageTime:Mt.LastMessageTime??null}});return It.sort(sortChats),It}),g(!0),setTimeout(()=>{var dt;return(dt=Le.current)==null?void 0:dt.focus()},50))},[l,e]);const[F,V]=React.useState(void 0),[ne,ae]=React.useState(""),[se,Oe]=React.useState(null),[Ne,oe]=React.useState([]),[$e,Ae]=React.useState(null),je=React.useRef(null),Be=React.useRef(null),[qe,Ve]=React.useState([]),Le=t||Be,He=React.useRef(null),{toast:We}=useToast(),ze=()=>Ne.find(dt=>dt.partner1===(F==null?void 0:F[0])&&dt.partner2===(F==null?void 0:F[1]));function Xe(){const dt=ze();dt&&I({routeApplicationId:e,conversationId:dt.conversationID})}const nt=dt=>Ve(It=>[...It,dt]);React.useEffect(()=>{if(qe.length==0)return;console.log(qe.length,"unprocessedMessages detected");const dt=(Mt,Ct)=>Ct.partner1===Mt.toPartnerID&&Ct.partner2===Mt.fromPartnerID||Ct.partner2===Mt.toPartnerID&&Ct.partner1===Mt.fromPartnerID;let It=!1;qe.forEach(Mt=>{if(!Ne.some(Ct=>dt(Mt,Ct))){console.log("message received for unknown convo ID - need to refetch!"),It=!0;return}oe(Ct=>Ct.map(Ke=>{if(!dt(Mt,Ke))return Ke;const Ye=Ke.messages??[];if(Ye.some(mt=>mt.id===Mt.id))return Ke;let Ze=1;const ct=document.activeElement&&document.activeElement===Le.current;return(F==null?void 0:F[0])==Ke.partner1&&F[1]==Ke.partner2&&ct&&(ct&&(Ze=0,Xe()),setTimeout(()=>{var mt;return(mt=je.current)==null?void 0:mt.scrollIntoView({behavior:"smooth"})},50)),{...Ke,pending:!1,unread:Ke.unread+Ze,messages:[...Ye,Mt]}}).sort(sortChats))}),console.log("need refetch:",It),It&&d(),Ve([])},[qe,Ve,oe,V,F]),React.useEffect(()=>{const dt=new HubConnectionBuilder().withUrl("https://api.randmar.io/hub",{accessTokenFactory:()=>localStorage.getItem("access_token"),headers:{"X-Impersonated-Id":e}}).configureLogging(LogLevel.Information).withAutomaticReconnect().withHubProtocol(new JsonHubProtocol).build();return dt.on("ReceiveMessage",nt),dt.start().catch(It=>console.error("Error connecting to SignalR hub:",It)),Ae(dt),()=>{dt&&dt.stop()}},[e]),React.useEffect(()=>{var It;!F||!ze()||((It=Le.current)==null||It.focus(),setTimeout(()=>{var Mt;return(Mt=je.current)==null?void 0:Mt.scrollIntoView({behavior:"smooth"})},50))},[F]),React.useEffect(()=>{if(!F)return;const dt=ze();dt&&dt.conversationID!==-1&&(async()=>{var It;try{const Ct=((It=(await j({routeApplicationId:e,conversationId:dt.conversationID})).data)==null?void 0:It.map(Ke=>({id:"history"+Ke.MessageId,fromPartnerID:Ke.SenderId,toPartnerID:Ke.SenderId==dt.partner1?dt.partner2:dt.partner1,senderName:Ke.SenderName??"missing name",timestamp:new Date(Ke.SentDate+"Z").getTime(),content:Ke.Content??"no content"})))??[];oe(Ke=>Ke.map(Ye=>Ye.conversationID===dt.conversationID?{...Ye,messages:Ct}:Ye).sort(sortChats))}catch(Mt){console.error("Error fetching conversation messages:",Mt)}})()},[F,j,e]),React.useEffect(()=>{if(!F)return;const dt=ze();if(!dt)return;const It=document.activeElement&&document.activeElement===Le.current;dt.unread>0&&It&&(Xe(),oe(Mt=>Mt.map(Ct=>Ct.partner1===F[0]&&Ct.partner2===F[1]?{...Ct,unread:0}:Ct)))},[F,Ne]);const{sendMessage:Je}=useChat(),st=React.useCallback(dt=>{Je(`We have been talking with another Randmar partner and would like you to have the conversation as context for follow-up questions. Please acknowledge your reception of this chat history (one line summary of recent messages will do) and let me know that you're ready to answer questions: ${JSON.stringify(dt,null,2)}`)},[Je]),et=React.useCallback(async()=>{if(F)try{te(!0);const dt=await R({applicationId:e}),It=F[0]===e?F[1]:F[0],Mt=await q({routeApplicationId:e,partnerId:It,withSpecification:!0}),Ct=buildPartnershipAssistantPrompt(dt.data,Mt.data);Ct?Je(Ct):We({title:"Missing data",description:"We couldn't load enough data to analyze this partnership yet. Please try again shortly.",variant:"destructive"})}catch(dt){console.error("Error preparing partnership analysis:",dt),We({title:"Error",description:"Could not analyze the partnership. Please try again later.",variant:"destructive"})}finally{te(!1)}},[F,R,q,Je,We,e]);React.useEffect(()=>{o(Ne.some(dt=>dt.unread>0))},[Ne,o]);const at=(dt,It)=>{It=It.replace(/\n/g,`
1165
1165
  `),console.log("doSend",It),console.log("target",dt);const Mt={id:crypto.randomUUID(),senderName:(lt==null?void 0:lt.Name)??(lt==null?void 0:lt.EmailAddress)??"User",fromPartnerID:e,toPartnerID:dt.partner1===e?dt.partner2:dt.partner1,content:It,timestamp:Date.now()};nt(Mt),$e.invoke("NewMessage",Mt).catch(Ct=>console.error("Error sending message:",Ct)),ae(""),He.current&&(He.current.value="")},tt=()=>{const dt=ne.trim();!Rt||!dt||!F||!$e||(Rt.unread>0&&(Xe(),oe(It=>It.map(Mt=>Mt.partner1===F[0]&&Mt.partner2===F[1]?{...Mt,unread:0}:Mt))),at(Rt,dt))},ot=(dt,It)=>Oe([dt,It]);React.useEffect(()=>{if(se===null)return;const dt=Ne.find(Mt=>Mt.conversationID===se[0]);if(!dt||(V([dt.partner1,dt.partner2]),!$e))return;const It=se[1];Oe(null),It&&at(dt,It)},[se,Ne,V,$e]);const{data:lt,isLoading:Ge}=useGetV4UserQuery();if(!f||Ge)return jsxRuntime.jsx(LoaderCircle,{className:"h-12 w-12 animate-spin mx-auto mb-4"});if(!(lt!=null&&lt.Name))return jsxRuntime.jsx(UserSetupForm,{appID:(lt==null?void 0:lt.ApplicationId)??""});const $t=async()=>{var dt,It,Mt,Ct,Ke;S.current&&(S.current.disabled=!0),A(!0);try{const Ye=await R({applicationId:e}),Ze=((dt=Ye.data)==null?void 0:dt.About)??"a new business venture",ct=[];(It=Ye.data)!=null&&It.IsManufacturer&&ct.push("Manufacturer"),(Mt=Ye.data)!=null&&Mt.IsReseller&&ct.push("Reseller"),(Ct=Ye.data)!=null&&Ct.IsSalesAgency&&ct.push("Sales Agency");const ft=`
1166
1166
  Your task is to draft a ready-to-send opening message from a user to the Randmar team.
1167
1167
 
@@ -1242,7 +1242,7 @@ Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=1
1242
1242
  `;break;default:e+=String.fromCharCode(n);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=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]===`
1243
1243
  `&&++this.pos;case`
1244
1244
  `:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")},pp.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`
1245
- `;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"),e){var n=this.pos-1;this.invalidStringToken(n,"Invalid escape sequence in template string")}default:if(t>=48&&t<=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,t=this.input.charCodeAt(this.pos),(o!=="0"||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-o.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(l)}return isNewLine(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}},pp.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,"Bad character escape sequence"),n},pp.readWord1=function(){this.containsEsc=!1;for(var e="",t=!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,e+=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();(t?isIdentifierStart:isIdentifierChar)(f,o)||this.invalidStringToken(d,"Invalid Unicode escape"),e+=codePointToString(f),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},pp.readWord=function(){var e=this.readWord1(),t=types$1.name;return this.keywords.test(e)&&(t=keywords[e]),this.finishToken(t,e)};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()),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(e){return VOID_ELEMENTS.indexOf(e.toLowerCase())===-1}function canHaveWhitespace(e){return NO_WHITESPACE.indexOf(e.toLowerCase())!==-1}class NullishShortCircuit extends Error{constructor(t="Nullish value encountered"){super(t),this.name="NullishShortCircuit"}}var hash=(e="",t=16)=>{const n=String(e);let o=0;return n.split("").forEach(l=>{o=(o<<5)-o+l.charCodeAt(0),o&=o}),Math.abs(o).toString(t)},randomHash=()=>hash(Math.random().toString()),camelCase=e=>e.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(t=>t).map((t,n)=>n>0?t[0].toUpperCase()+t.slice(1):t).join(""),parseStyle=e=>{switch(typeof e){case"string":return e.split(";").filter(t=>t).reduce((t,n)=>{const o=n.slice(0,n.indexOf(":")).trim(),l=n.slice(n.indexOf(":")+1).trim();return{...t,[camelCase(o)]:l}},{});case"object":return e;default:return}},pathToArrayPath=e=>e==null||e===""?[]:e.split("."),resolveArrayPath=(e,t)=>{const[n,...o]=t;if(!(e==null||n==null))return o.length===0?e[n]:resolveArrayPath(e[n],o)},resolvePath=(e,t)=>resolveArrayPath(e,pathToArrayPath(t));function handleNaN(e){return Number.isNaN(e)?"NaN":e}class JsxParser extends React.Component{constructor(){super(...arguments);en(this,"ParsedChildren",null);zn(this,fn,n=>{const o=Parser.extend(AcornJSX.default({autoCloseVoidElements:this.props.autoCloseVoidElements})),l=`<root>${n}</root>`;let d=[];try{return d=o.parse(l,{ecmaVersion:"latest"}),d=d.body[0].expression.children||[],d.map(f=>on(this,rn).call(this,f)).filter(Boolean)}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}});zn(this,rn,(n,o)=>{var l,d;switch(n.type){case"JSXAttribute":return n.value===null?!0:on(this,rn).call(this,n.value,o);case"JSXElement":case"JSXFragment":return on(this,Qn).call(this,n,o);case"JSXExpressionContainer":return on(this,rn).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=>on(this,rn).call(this,A,o));case"BinaryExpression":const g=on(this,rn).call(this,n.left,o),b=on(this,rn).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=on(this,rn).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=>on(this,rn).call(this,A,o)));case"ConditionalExpression":return on(this,rn).call(this,n.test,o)?on(this,rn).call(this,n.consequent,o):on(this,rn).call(this,n.alternate,o);case"ExpressionStatement":return on(this,rn).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=on(this,rn).call(this,n.left,o);return n.operator==="||"&&R?R:n.operator==="&&"&&R||n.operator==="||"&&!R?on(this,rn).call(this,n.right,o):!1;case"MemberExpression":return on(this,ar).call(this,n,o);case"ChainExpression":return on(this,ir).call(this,n,o);case"ObjectExpression":const C={};return n.properties.forEach(A=>{C[A.key.name||A.key.value]=on(this,rn).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=>on(this,rn).call(this,A,o)).join("");case"UnaryExpression":const E=on(this,rn).call(this,n.argument,o);switch(n.operator){case"+":return+E;case"-":return-E;case"!":return!E;case"~":return~E;case"typeof":return typeof 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]}),on(this,rn).call(this,n.body,M)};default:this.props.onError(new Error(`The expression type '${n.type}' is not supported.`));return}});zn(this,ir,(n,o)=>{try{return on(this,rn).call(this,n.expression,o)}catch(l){if(l instanceof NullishShortCircuit)return;throw l}});zn(this,ar,(n,o)=>{const l=on(this,rn).call(this,n.object,o);let d;if(n.computed)d=on(this,rn).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});zn(this,Wn,n=>n.type==="JSXIdentifier"?n.name:`${on(this,Wn).call(this,n.object)}.${on(this,Wn).call(this,n.property)}`);zn(this,Qn,(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"?on(this,Wn).call(this,_.name):"",C=(this.props.blacklistedAttrs||[]).map(Q=>Q instanceof RegExp?Q:new RegExp(Q,"i")),E=(this.props.blacklistedTags||[]).map(Q=>Q.trim().toLowerCase()).filter(Boolean);if(/^(html|head|body)$/i.test(R))return b.map(Q=>on(this,Qn).call(this,Q,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(te=>on(this,rn).call(this,te,o)),R.includes(".")){const F=R.split(".").reduce((V,ne)=>V?V[ne]:d==null?void 0:d[ne],null);F&&(I=F)}!I&&!canHaveWhitespace(R)&&(M=M.filter(te=>typeof te!="string"||!/^\s*$/.test(te)));const Q=M.find(te=>typeof te=="function");M.length===0?M=void 0:Q?M=Q:M.length===1?[M]=M:M.length>1&&!this.props.disableKeyGeneration&&(M=M.map((te,F)=>te!=null&&te.type&&!(te!=null&&te.key)?{...te,key:te.key||F}:te))}const j={key:this.props.disableKeyGeneration?void 0:randomHash()};S.forEach(Q=>{if(Q.type==="JSXAttribute"){const te=Q.name.name,F=attributeNames_default[te]||te,V=on(this,rn).call(this,Q,o);C.filter(ae=>ae.test(F)).length===0&&(j[F]=V)}else if(Q.type==="JSXSpreadAttribute"&&Q.argument.type==="Identifier"||Q.argument.type==="MemberExpression"){const te=on(this,rn).call(this,Q.argument,o);typeof te=="object"&&Object.keys(te).forEach(F=>{const V=attributeNames_default[F]||F;C.filter(ae=>ae.test(V)).length===0&&(j[V]=te[F])})}}),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=on(this,fn).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}}fn=new WeakMap,rn=new WeakMap,ir=new WeakMap,ar=new WeakMap,Wn=new WeakMap,Qn=new WeakMap,en(JsxParser,"displayName","JsxParser"),en(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:e,className:t=""})=>{const[n,o]=React.useState(null),[l,d]=React.useState(!1);return React.useEffect(()=>{if(!e)return;const g=`https://purecatamphetamine.github.io/country-flag-icons/3x2/${e.toUpperCase()}.svg`;fetch(g,{method:"HEAD"}).then(b=>{b.ok?(o(g),d(!1)):d(!0)}).catch(()=>{d(!0)})},[e]),l||!n?jsxRuntime.jsx("span",{className:t,children:e}):jsxRuntime.jsx("img",{src:n,alt:`${e} flag`,className:`inline-block ${t}`,style:{width:"24px",height:"auto"}})};function ProductCard({applicationId:e,product:t,viewProductLink:n,defaultOpportunityNumber:o="",onAddToCart:l,addingToCart:d=!1,shopifyHostname:f,customAction:g=jsxRuntime.jsx(jsxRuntime.Fragment,{})}){var Ge,$t,rt,Rt,dt,It,Mt,Ct,Ke,Ye;const b=reactRouterDom.useNavigate(),{toast:_}=useToast(),[S,R]=React.useState(1),[C,E]=React.useState(null),[A,M]=React.useState(0),[I,j]=React.useState(!1),[q]=usePostV4ResellerByRouteResellerIdProductAndRandmarSkuShopifyMutation(),[Q,te]=React.useState(!1),[F,V]=React.useState(null),[ne,ae]=React.useState("idle"),[se,Oe]=React.useState(null),[Ne]=useLazyGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery(),oe=((Ge=t==null?void 0:t.Distribution)==null?void 0:Ge.Cost)||0,$e=(($t=t==null?void 0:t.Distribution)==null?void 0:$t.RegularPrice)||0,Ae=((rt=t==null?void 0:t.Distribution)==null?void 0:rt.Price)||0,je=!!(e&&(t!=null&&t.RandmarSKU));React.useEffect(()=>{R(1),E(null),M(0)},[t==null?void 0:t.RandmarSKU]),React.useEffect(()=>{var Ze;if(t&&o){const ct=(Ze=t.Opportunities)==null?void 0:Ze.find(mt=>mt.BidNumber==o);ct&&Be(ct)&&E(ct)}},[t,o]),React.useEffect(()=>{if(!t)return;const Ze=C!=null&&C.Price?C.Price:Ae;M($e>0?Math.round(($e-Ze)/$e*100):0)},[t,C,Ae,$e]),React.useEffect(()=>{d||R(1)},[d]),React.useEffect(()=>{if(!Q){V(null),ae("idle"),Oe(null);return}if(!e||!(t!=null&&t.RandmarSKU)){ae("error"),Oe("Missing identifiers to load performance data.");return}let Ze=!1;const ct=t.RandmarSKU;return(async()=>{ae("summary"),Oe(null);try{const ft=await Ne({routeApplicationId:e,randmarSku:ct,withSpecification:!1});if(Ze)return;if("error"in ft&&ft.error)throw ft.error;V(ft.data??null),ae("detailed");const yt=await Ne({routeApplicationId:e,randmarSku:ct,withSpecification:!0});if(Ze)return;if("error"in yt&&yt.error)throw yt.error;V(yt.data??ft.data??null),ae("complete")}catch(ft){if(Ze)return;console.error("Failed to load performance data for product modal",ft),ae("error"),Oe("We couldn't load the performance details. Please try again.")}})(),()=>{Ze=!0}},[e,Ne,Q,t==null?void 0:t.RandmarSKU]);const Be=Ze=>{if(Ze.Active!==!0)return!1;const ct=new Date().toISOString().split("T")[0];return!(Ze.EndDate&&Ze.EndDate.split("T")[0]<ct||Ze.StartDate&&Ze.StartDate.split("T")[0]>ct)},qe=Ze=>Ze>=90?{label:"Top 10% Bestseller",color:"text-purple-950",bgColor:"bg-purple-200"}:Ze>=75?{label:"Bestseller",color:"text-blue-700",bgColor:"bg-blue-50"}:Ze>=33?{label:"Popular",color:"text-green-700",bgColor:"bg-green-50"}:{label:"Rising",color:"text-gray-700",bgColor:"bg-white"},Ve=ne!=="complete"&&(((Rt=F==null?void 0:F.SalesStatistics)==null?void 0:Rt.length)??0)===0,Le=ne!=="complete"&&ne!=="error",He=ne==="summary"?40:ne==="detailed"?80:10,We=(F==null?void 0:F.RandmarTitle)??(t==null?void 0:t.RandmarTitle)??(t==null?void 0:t.RandmarSKU)??"this product",ze=(F==null?void 0:F.RandmarSKU)??(t==null?void 0:t.RandmarSKU);if(!t)return jsxRuntime.jsx(Card,{children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx("div",{className:"h-10 w-24 flex items-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 items-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 items-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 items-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 Xe=(t==null?void 0:t.Opportunities)||[],nt=Xe.length>0,Je=()=>{if(S==null){R(1);return}S>1&&R(S-1)},st=()=>{if(S==null){R(1);return}R(S+1)},et=Ze=>{const ct=Number.parseInt(Ze.target.value,10);if(!isNaN(ct)&&ct>0){R(ct);return}R(void 0)},at=()=>{(S==null||S<1)&&R(1)},tt=Ze=>{try{return new Date(Ze).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch(ct){return console.error(ct),Ze.split("T")[0]||"N/A"}},ot=()=>{typeof l<"u"&&l({quantity:S??1,bidNumber:(C==null?void 0:C.BidNumber)??null})},lt=()=>{I||!f||(j(!0),q({routeResellerId:e??"",randmarSku:t.RandmarSKU??"",shopifyHostName:f}).then(Ze=>{if(Ze.error){console.error("Error syncing to Shopify:",Ze.error),_({title:"Product synced failed.",description:"Error syncing to Shopify:",variant:"destructive"});return}_({title:"Product synced",description:"Product synced to Shopify successfully",variant:"success"})}).catch(Ze=>{console.error("Error syncing to Shopify:",Ze),_({title:"Product synced failed.",description:"Error syncing to Shopify:",variant:"destructive"})}).finally(()=>{j(!1)}))};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Card,{className:"w-full hover:shadow-lg transition-shadow @container",children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-xl",children:t.Title||t.RandmarTitle}),jsxRuntime.jsx("div",{className:"w-24 h-10 flex items-center justify-end ml-4 flex-shrink-0",children:jsxRuntime.jsx(PartnerLogo,{id:t.ManufacturerId,name:t.ManufacturerName,width:96,height:40},`partner_logo_${t.ManufacturerId}`)})]}),jsxRuntime.jsxs("div",{className:"flex flex-col @[36rem]:flex-row gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-1 @[36rem]:order-1 order-2 flex flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 items-center justify-center @[36rem]:items-start @[36rem]:justify-start",children:[t.State&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${t.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"})," ",t.State]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${t.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"})," ",t.SerialNumber?"Serialized":"Unserialized"]}),t.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"]}),t.AvailableToBuy!==void 0&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${t.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"})," ",t.AvailableToBuy?"Available":"Unavailable"]}),t.ManufacturerCategory!==void 0&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${(dt=t.ManufacturerCategory)!=null&&dt.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"})," ",(It=t.ManufacturerCategory)!=null&&It.QualificationRequired?"Qualified Only":"Available to all"]}),t.ManufacturerId&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${t.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"})," ",t.AutoUpdate?`Automatic Reorder (${t.MasterCarton})`:"Manually Reorders"]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${t.BodyHTML&&t.Title&&t.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"})," ",t.BodyHTML&&t.Title&&t.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:t.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:t.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:t.UnitWeight?`${formatNumber(t.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:[t.MAP?formatMoney(t.MAP):"N/A",jsxRuntime.jsx("span",{className:"text-primary",children:" / "}),t.MSRP?formatMoney(t.MSRP):"N/A"]})]}),!!t.OverallPercentileRank&&!!t.ManufacturerPercentileRank&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:"Bestseller Status"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{children:"Global: "}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Badge,{variant:"outline",className:`rounded-full px-3 w-fit ${qe(t.OverallPercentileRank).bgColor} ${qe(t.OverallPercentileRank).color} hover:${qe(t.OverallPercentileRank).bgColor}`,children:qe(t.OverallPercentileRank).label})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["Percentile Rank: ",t.OverallPercentileRank]})})]})})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("span",{children:[t.ManufacturerName,": "]}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Badge,{variant:"outline",className:`rounded-full px-3 w-fit ${qe(t.ManufacturerPercentileRank).bgColor} ${qe(t.ManufacturerPercentileRank).color} hover:${qe(t.ManufacturerPercentileRank).bgColor}`,children:qe(t.ManufacturerPercentileRank).label})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["Percentile Rank: ",t.ManufacturerPercentileRank]})})]})})]})]})]}),t.CountryCodeOfOrigin&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Origin"}),jsxRuntime.jsxs("div",{className:"font-medium flex items-center",children:[jsxRuntime.jsx(CountryFlag,{countryCode:t.CountryCodeOfOrigin,className:"mr-2"}),t.CountryCodeOfOrigin]})]})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col @[36rem]:order-2 order-1 items-center",children:jsxRuntime.jsx(ProductImage,{randmarSKU:t.RandmarSKU||"",alt:t.RandmarTitle||""},`product_image_${t.RandmarSKU}`)})]}),jsxRuntime.jsxs("div",{className:"flex flex-col @[36rem]:flex-row gap-6 mt-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-row @[36rem]:flex-col gap-4 justify-center @[36rem]:justify-start @[36rem]:order-2 order-1",children:[n&&jsxRuntime.jsx(reactRouterDom.Link,{to:n,children:jsxRuntime.jsxs(Button$1,{variant:"outline",className:"h-11 px-4 text-sm font-medium justify-start",children:[jsxRuntime.jsx(Eye,{className:"mr-2"}),"View Product"]})}),jsxRuntime.jsx(ProductInventoryButton,{applicationId:e??"",randmarSku:t.RandmarSKU??"",inventory:(Mt=t.Distribution)==null?void 0:Mt.Inventory})]}),jsxRuntime.jsx("div",{className:"flex flex-1 @[36rem]:order-1 order-2",children:nt&&t.Distribution&&jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx("div",{className:"flex items-center",children:"You have "+Xe.length+(Xe.length>1?" opportunities":" opportunity")+" for this product:"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsx("div",{className:"space-y-2 max-h-[200px] overflow-y-auto p-2 mt-1",children:Xe.map((Ze,ct)=>Be(Ze)?jsxRuntime.jsxs("div",{className:`flex justify-between items-center rounded-lg transition-colors py-2 px-4 border border-muted cursor-pointer ${Ze.BidNumber==(C==null?void 0:C.BidNumber)?"bg-purple-100 border-2 border-purple-900":"bg-white border-1 border-purple-600 hover:bg-purple-200"}`,onClick:()=>{E(Ze.BidNumber!==(C==null?void 0:C.BidNumber)?Ze:null)},children:[jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-medium text-sm",children:Ze.Opportunity}),jsxRuntime.jsx("span",{className:"text-xs text-neutral-900",children:Ze.BidNumber})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end",children:[jsxRuntime.jsx("span",{className:"font-semibold",children:formatMoney(Ze.Price??0)}),Ze.Rebate&&Ze.Rebate>0&&jsxRuntime.jsxs("span",{className:"text-xs text-green-600",children:["Rebate: ",formatMoney(Ze.Rebate)]}),Ze.EndDate&&jsxRuntime.jsxs("span",{className:"text-xs text-neutral-600",children:["Ends: ",tt(Ze.EndDate)]})]})]},ct):jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex justify-between items-center rounded-lg transition-colors py-2 px-4 bg-purple-100 border border-muted cursor-pointer !bg-neutral-50 hover:bg-neutral-100",onClick:()=>{Ze.BidNumber&&b(`/${e}/Opportunity/${Ze.ManufacturerId}/${Ze.BidNumber}`)},children:[jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-medium text-sm",children:Ze.Opportunity}),jsxRuntime.jsxs("span",{className:"text-xs text-neutral-900",children:[Ze.BidNumber," ",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 items-end",children:[jsxRuntime.jsx("span",{className:"font-semibold",children:formatMoney(Ze.Price??0)}),Ze.Rebate&&Ze.Rebate>0&&jsxRuntime.jsxs("span",{className:"text-xs text-green-600",children:["Rebate: ",formatMoney(Ze.Rebate)]}),Ze.EndDate&&jsxRuntime.jsxs("span",{className:"text-xs text-neutral-600",children:["Ends: ",tt(Ze.EndDate)]})]})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"View Opportunity"})})]},ct))})})]})})]}),jsxRuntime.jsxs("div",{className:"flex flex-row flex-wrap justify-between items-end mt-4 gap-4",children:[jsxRuntime.jsxs("div",{className:"flex-shrink-1 flex flex-col gap-3",children:[t.Distribution&&jsxRuntime.jsx("div",{className:"flex flex-col gap-1",children:oe>0?jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("span",{className:"text-2xl font-bold whitespace-nowrap",children:["Cost: ",formatMoney(oe)]})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap",children:[$e>0&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("span",{className:"text-2xl font-bold whitespace-nowrap",children:formatMoney((C?(Ke=(Ct=t.Opportunities)==null?void 0:Ct.find(Ze=>Ze.BidNumber==C.BidNumber))==null?void 0:Ke.Price:Ae)??0)})}),A>0&&jsxRuntime.jsx("span",{className:"text-muted-foreground line-through ml-2 whitespace-nowrap",children:formatMoney($e)})]}),A>0&&jsxRuntime.jsx("div",{className:"flex items-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:[A,"% OFF"]}),((Ye=t.InstantRebate)==null?void 0:Ye.EndDate)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",t.InstantRebate.EndDate.split("T")[0]]}),(C==null?void 0:C.EndDate)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",C.EndDate.split("T")[0]]})]})})]})}),jsxRuntime.jsxs(Button$1,{variant:"outline",type:"button",className:"h-11 px-4 text-sm font-medium justify-start w-fit",onClick:()=>te(!0),disabled:!je,children:[jsxRuntime.jsx(ChartLine,{className:"mr-2"}),"View statistics"]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col justify-center @[36rem]:justify-end items-end gap-2 w-full",children:[f&&jsxRuntime.jsx(Button$1,{className:"gap-2 whitespace-nowrap bg-green-600 hover:bg-green-700",onClick:lt,disabled:I,children:I?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,typeof l<"u"&&jsxRuntime.jsxs("div",{className:"flex gap-2 whitespace-nowrap",children:[jsxRuntime.jsxs("div",{className:"flex items-center border rounded-md",children:[jsxRuntime.jsx(Button$1,{variant:"ghost",size:"icon",className:"rounded-r-none",onClick:Je,disabled:typeof S<"u"&&(S<=1||!t.AvailableToBuy||d),children:"-"}),jsxRuntime.jsx("input",{value:S,onChange:et,onBlur:at,onClick:Ze=>Ze.currentTarget.select(),className:`w-6 @[36rem]:w-12 text-center border-0 focus:ring-0 focus:outline-none ${!t.AvailableToBuy||d?"text-gray-400":""}`,disabled:!t.AvailableToBuy||d}),jsxRuntime.jsx(Button$1,{variant:"ghost",size:"icon",className:"rounded-l-none",onClick:st,disabled:!t.AvailableToBuy||d,children:"+"})]}),jsxRuntime.jsx(Button$1,{className:"gap-2 whitespace-nowrap",onClick:ot,disabled:!t.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"]})})]})]})]})]})}),jsxRuntime.jsx(Dialog,{open:Q,onOpenChange:te,children:jsxRuntime.jsxs(DialogContent,{className:"w-[min(95vw,1100px)] max-w-5xl space-y-6",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Monthly Sales Performance"}),jsxRuntime.jsxs(DialogDescription,{children:["Expanded product insights for ",We,ze?` (SKU ${ze})`:""]})]}),jsxRuntime.jsxs("div",{className:"space-y-6",children:[Le&&jsxRuntime.jsx("div",{className:"rounded-xl border bg-background p-4","aria-live":"polite","aria-busy":"true",children:jsxRuntime.jsx(Progress,{value:He,className:"h-2 w-full animate-pulse","aria-label":"Loading performance data"})}),se?jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(AlertTitle,{children:"Unable to load details"}),jsxRuntime.jsx(AlertDescription,{children:se})]}):F?jsxRuntime.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx("p",{className:"text-base font-semibold",children:"Monthly Sales Performance"}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Rolling 12-month sales dollars and units sold pulled from the detailed endpoint."})]}),jsxRuntime.jsx(SalesChart,{statistics:F.SalesStatistics??[],mode:"month",chartHeight:320,loading:Ve})]}):jsxRuntime.jsxs("div",{className:"rounded-xl border bg-background p-6 text-sm text-muted-foreground","aria-live":"polite","aria-busy":"true",children:[jsxRuntime.jsx("p",{className:"text-base font-semibold text-foreground",children:"Loading monthly sales performance"}),jsxRuntime.jsx(Progress,{value:65,className:"mt-4 h-2 w-full animate-pulse","aria-label":"Loading monthly sales performance"}),jsxRuntime.jsx("p",{className:"mt-2 text-xs",children:"Gathering product summary and sales statistics..."})]})]})]})})]})}const complexComponents=[`----
1245
+ `;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"),e){var n=this.pos-1;this.invalidStringToken(n,"Invalid escape sequence in template string")}default:if(t>=48&&t<=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,t=this.input.charCodeAt(this.pos),(o!=="0"||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-o.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(l)}return isNewLine(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}},pp.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,"Bad character escape sequence"),n},pp.readWord1=function(){this.containsEsc=!1;for(var e="",t=!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,e+=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();(t?isIdentifierStart:isIdentifierChar)(f,o)||this.invalidStringToken(d,"Invalid Unicode escape"),e+=codePointToString(f),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},pp.readWord=function(){var e=this.readWord1(),t=types$1.name;return this.keywords.test(e)&&(t=keywords[e]),this.finishToken(t,e)};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()),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(e){return VOID_ELEMENTS.indexOf(e.toLowerCase())===-1}function canHaveWhitespace(e){return NO_WHITESPACE.indexOf(e.toLowerCase())!==-1}class NullishShortCircuit extends Error{constructor(t="Nullish value encountered"){super(t),this.name="NullishShortCircuit"}}var hash=(e="",t=16)=>{const n=String(e);let o=0;return n.split("").forEach(l=>{o=(o<<5)-o+l.charCodeAt(0),o&=o}),Math.abs(o).toString(t)},randomHash=()=>hash(Math.random().toString()),camelCase=e=>e.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(t=>t).map((t,n)=>n>0?t[0].toUpperCase()+t.slice(1):t).join(""),parseStyle=e=>{switch(typeof e){case"string":return e.split(";").filter(t=>t).reduce((t,n)=>{const o=n.slice(0,n.indexOf(":")).trim(),l=n.slice(n.indexOf(":")+1).trim();return{...t,[camelCase(o)]:l}},{});case"object":return e;default:return}},pathToArrayPath=e=>e==null||e===""?[]:e.split("."),resolveArrayPath=(e,t)=>{const[n,...o]=t;if(!(e==null||n==null))return o.length===0?e[n]:resolveArrayPath(e[n],o)},resolvePath=(e,t)=>resolveArrayPath(e,pathToArrayPath(t));function handleNaN(e){return Number.isNaN(e)?"NaN":e}class JsxParser extends React.Component{constructor(){super(...arguments);en(this,"ParsedChildren",null);zn(this,fn,n=>{const o=Parser.extend(AcornJSX.default({autoCloseVoidElements:this.props.autoCloseVoidElements})),l=`<root>${n}</root>`;let d=[];try{return d=o.parse(l,{ecmaVersion:"latest"}),d=d.body[0].expression.children||[],d.map(f=>on(this,rn).call(this,f)).filter(Boolean)}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}});zn(this,rn,(n,o)=>{var l,d;switch(n.type){case"JSXAttribute":return n.value===null?!0:on(this,rn).call(this,n.value,o);case"JSXElement":case"JSXFragment":return on(this,Qn).call(this,n,o);case"JSXExpressionContainer":return on(this,rn).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=>on(this,rn).call(this,A,o));case"BinaryExpression":const g=on(this,rn).call(this,n.left,o),b=on(this,rn).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=on(this,rn).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=>on(this,rn).call(this,A,o)));case"ConditionalExpression":return on(this,rn).call(this,n.test,o)?on(this,rn).call(this,n.consequent,o):on(this,rn).call(this,n.alternate,o);case"ExpressionStatement":return on(this,rn).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=on(this,rn).call(this,n.left,o);return n.operator==="||"&&R?R:n.operator==="&&"&&R||n.operator==="||"&&!R?on(this,rn).call(this,n.right,o):!1;case"MemberExpression":return on(this,ar).call(this,n,o);case"ChainExpression":return on(this,ir).call(this,n,o);case"ObjectExpression":const C={};return n.properties.forEach(A=>{C[A.key.name||A.key.value]=on(this,rn).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=>on(this,rn).call(this,A,o)).join("");case"UnaryExpression":const E=on(this,rn).call(this,n.argument,o);switch(n.operator){case"+":return+E;case"-":return-E;case"!":return!E;case"~":return~E;case"typeof":return typeof 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]}),on(this,rn).call(this,n.body,M)};default:this.props.onError(new Error(`The expression type '${n.type}' is not supported.`));return}});zn(this,ir,(n,o)=>{try{return on(this,rn).call(this,n.expression,o)}catch(l){if(l instanceof NullishShortCircuit)return;throw l}});zn(this,ar,(n,o)=>{const l=on(this,rn).call(this,n.object,o);let d;if(n.computed)d=on(this,rn).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});zn(this,Wn,n=>n.type==="JSXIdentifier"?n.name:`${on(this,Wn).call(this,n.object)}.${on(this,Wn).call(this,n.property)}`);zn(this,Qn,(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"?on(this,Wn).call(this,_.name):"",C=(this.props.blacklistedAttrs||[]).map(Q=>Q instanceof RegExp?Q:new RegExp(Q,"i")),E=(this.props.blacklistedTags||[]).map(Q=>Q.trim().toLowerCase()).filter(Boolean);if(/^(html|head|body)$/i.test(R))return b.map(Q=>on(this,Qn).call(this,Q,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(te=>on(this,rn).call(this,te,o)),R.includes(".")){const F=R.split(".").reduce((V,ne)=>V?V[ne]:d==null?void 0:d[ne],null);F&&(I=F)}!I&&!canHaveWhitespace(R)&&(M=M.filter(te=>typeof te!="string"||!/^\s*$/.test(te)));const Q=M.find(te=>typeof te=="function");M.length===0?M=void 0:Q?M=Q:M.length===1?[M]=M:M.length>1&&!this.props.disableKeyGeneration&&(M=M.map((te,F)=>te!=null&&te.type&&!(te!=null&&te.key)?{...te,key:te.key||F}:te))}const j={key:this.props.disableKeyGeneration?void 0:randomHash()};S.forEach(Q=>{if(Q.type==="JSXAttribute"){const te=Q.name.name,F=attributeNames_default[te]||te,V=on(this,rn).call(this,Q,o);C.filter(ae=>ae.test(F)).length===0&&(j[F]=V)}else if(Q.type==="JSXSpreadAttribute"&&Q.argument.type==="Identifier"||Q.argument.type==="MemberExpression"){const te=on(this,rn).call(this,Q.argument,o);typeof te=="object"&&Object.keys(te).forEach(F=>{const V=attributeNames_default[F]||F;C.filter(ae=>ae.test(V)).length===0&&(j[V]=te[F])})}}),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=on(this,fn).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}}fn=new WeakMap,rn=new WeakMap,ir=new WeakMap,ar=new WeakMap,Wn=new WeakMap,Qn=new WeakMap,en(JsxParser,"displayName","JsxParser"),en(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:e,className:t=""})=>{const[n,o]=React.useState(null),[l,d]=React.useState(!1);return React.useEffect(()=>{if(!e)return;const g=`https://purecatamphetamine.github.io/country-flag-icons/3x2/${e.toUpperCase()}.svg`;fetch(g,{method:"HEAD"}).then(b=>{b.ok?(o(g),d(!1)):d(!0)}).catch(()=>{d(!0)})},[e]),l||!n?jsxRuntime.jsx("span",{className:t,children:e}):jsxRuntime.jsx("img",{src:n,alt:`${e} flag`,className:`inline-block ${t}`,style:{width:"24px",height:"auto"}})};function ProductCard({applicationId:e,product:t,viewProductLink:n,defaultOpportunityNumber:o="",onAddToCart:l,addingToCart:d=!1,shopifyHostname:f,customAction:g=jsxRuntime.jsx(jsxRuntime.Fragment,{})}){var $t,rt,Rt,dt,It,Mt,Ct,Ke,Ye;const b=reactRouterDom.useNavigate(),{toast:_}=useToast(),[S,R]=React.useState(1),[C,E]=React.useState(null),[A,M]=React.useState(0),[I,j]=React.useState(!1),[q]=usePostV4ResellerByRouteResellerIdProductAndRandmarSkuShopifyMutation(),[Q,te]=React.useState(!1),[F,V]=React.useState(null),[ne,ae]=React.useState("idle"),[se,Oe]=React.useState(null),[Ne]=useLazyGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery(),oe=(($t=t==null?void 0:t.Distribution)==null?void 0:$t.Cost)||0,$e=((rt=t==null?void 0:t.Distribution)==null?void 0:rt.RegularPrice)||0,Ae=((Rt=t==null?void 0:t.Distribution)==null?void 0:Rt.Price)||0,je=!!(e&&(t!=null&&t.RandmarSKU));React.useEffect(()=>{R(1),E(null),M(0)},[t==null?void 0:t.RandmarSKU]),React.useEffect(()=>{var Ze;if(t&&o){const ct=(Ze=t.Opportunities)==null?void 0:Ze.find(mt=>mt.BidNumber==o);ct&&Be(ct)&&E(ct)}},[t,o]),React.useEffect(()=>{if(!t)return;const Ze=C!=null&&C.Price?C.Price:Ae;M($e>0?Math.round(($e-Ze)/$e*100):0)},[t,C,Ae,$e]),React.useEffect(()=>{d||R(1)},[d]),React.useEffect(()=>{if(!Q){V(null),ae("idle"),Oe(null);return}if(!e||!(t!=null&&t.RandmarSKU)){ae("error"),Oe("Missing identifiers to load performance data.");return}let Ze=!1;const ct=t.RandmarSKU;return(async()=>{ae("summary"),Oe(null);try{const ft=await Ne({routeApplicationId:e,randmarSku:ct,withSpecification:!1});if(Ze)return;if("error"in ft&&ft.error)throw ft.error;V(ft.data??null),ae("detailed");const yt=await Ne({routeApplicationId:e,randmarSku:ct,withSpecification:!0});if(Ze)return;if("error"in yt&&yt.error)throw yt.error;V(yt.data??ft.data??null),ae("complete")}catch(ft){if(Ze)return;console.error("Failed to load performance data for product modal",ft),ae("error"),Oe("We couldn't load the performance details. Please try again.")}})(),()=>{Ze=!0}},[e,Ne,Q,t==null?void 0:t.RandmarSKU]);const Be=Ze=>{if(Ze.Active!==!0)return!1;const ct=new Date().toISOString().split("T")[0];return!(Ze.EndDate&&Ze.EndDate.split("T")[0]<ct||Ze.StartDate&&Ze.StartDate.split("T")[0]>ct)},qe=Ze=>Ze>=90?{label:"Top 10% Bestseller",color:"text-purple-950",bgColor:"bg-purple-200"}:Ze>=75?{label:"Bestseller",color:"text-blue-700",bgColor:"bg-blue-50"}:Ze>=33?{label:"Popular",color:"text-green-700",bgColor:"bg-green-50"}:{label:"Rising",color:"text-gray-700",bgColor:"bg-white"},Ve=ne!=="complete"&&ne!=="error",Le=ne==="summary"?40:ne==="detailed"?80:10,He=(F==null?void 0:F.SalesStatistics)??[],We=Ve?[]:He,ze=(F==null?void 0:F.RandmarTitle)??(t==null?void 0:t.RandmarTitle)??(t==null?void 0:t.RandmarSKU)??"this product",Xe=(F==null?void 0:F.RandmarSKU)??(t==null?void 0:t.RandmarSKU);if(!t)return jsxRuntime.jsx(Card,{children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx("div",{className:"h-10 w-24 flex items-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 items-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 items-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 items-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 nt=(t==null?void 0:t.Opportunities)||[],Je=nt.length>0,st=()=>{if(S==null){R(1);return}S>1&&R(S-1)},et=()=>{if(S==null){R(1);return}R(S+1)},at=Ze=>{const ct=Number.parseInt(Ze.target.value,10);if(!isNaN(ct)&&ct>0){R(ct);return}R(void 0)},tt=()=>{(S==null||S<1)&&R(1)},ot=Ze=>{try{return new Date(Ze).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch(ct){return console.error(ct),Ze.split("T")[0]||"N/A"}},lt=()=>{typeof l<"u"&&l({quantity:S??1,bidNumber:(C==null?void 0:C.BidNumber)??null})},Ge=()=>{I||!f||(j(!0),q({routeResellerId:e??"",randmarSku:t.RandmarSKU??"",shopifyHostName:f}).then(Ze=>{if(Ze.error){console.error("Error syncing to Shopify:",Ze.error),_({title:"Product synced failed.",description:"Error syncing to Shopify:",variant:"destructive"});return}_({title:"Product synced",description:"Product synced to Shopify successfully",variant:"success"})}).catch(Ze=>{console.error("Error syncing to Shopify:",Ze),_({title:"Product synced failed.",description:"Error syncing to Shopify:",variant:"destructive"})}).finally(()=>{j(!1)}))};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Card,{className:"w-full hover:shadow-lg transition-shadow @container",children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-xl",children:t.Title||t.RandmarTitle}),jsxRuntime.jsx("div",{className:"w-24 h-10 flex items-center justify-end ml-4 flex-shrink-0",children:jsxRuntime.jsx(PartnerLogo,{id:t.ManufacturerId,name:t.ManufacturerName,width:96,height:40},`partner_logo_${t.ManufacturerId}`)})]}),jsxRuntime.jsxs("div",{className:"flex flex-col @[36rem]:flex-row gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-1 @[36rem]:order-1 order-2 flex flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 items-center justify-center @[36rem]:items-start @[36rem]:justify-start",children:[t.State&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${t.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"})," ",t.State]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${t.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"})," ",t.SerialNumber?"Serialized":"Unserialized"]}),t.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"]}),t.AvailableToBuy!==void 0&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${t.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"})," ",t.AvailableToBuy?"Available":"Unavailable"]}),t.ManufacturerCategory!==void 0&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${(dt=t.ManufacturerCategory)!=null&&dt.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"})," ",(It=t.ManufacturerCategory)!=null&&It.QualificationRequired?"Qualified Only":"Available to all"]}),t.ManufacturerId&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${t.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"})," ",t.AutoUpdate?`Automatic Reorder (${t.MasterCarton})`:"Manually Reorders"]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${t.BodyHTML&&t.Title&&t.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"})," ",t.BodyHTML&&t.Title&&t.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:t.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:t.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:t.UnitWeight?`${formatNumber(t.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:[t.MAP?formatMoney(t.MAP):"N/A",jsxRuntime.jsx("span",{className:"text-primary",children:" / "}),t.MSRP?formatMoney(t.MSRP):"N/A"]})]}),!!t.OverallPercentileRank&&!!t.ManufacturerPercentileRank&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:"Bestseller Status"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{children:"Global: "}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Badge,{variant:"outline",className:`rounded-full px-3 w-fit ${qe(t.OverallPercentileRank).bgColor} ${qe(t.OverallPercentileRank).color} hover:${qe(t.OverallPercentileRank).bgColor}`,children:qe(t.OverallPercentileRank).label})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["Percentile Rank: ",t.OverallPercentileRank]})})]})})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("span",{children:[t.ManufacturerName,": "]}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Badge,{variant:"outline",className:`rounded-full px-3 w-fit ${qe(t.ManufacturerPercentileRank).bgColor} ${qe(t.ManufacturerPercentileRank).color} hover:${qe(t.ManufacturerPercentileRank).bgColor}`,children:qe(t.ManufacturerPercentileRank).label})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["Percentile Rank: ",t.ManufacturerPercentileRank]})})]})})]})]})]}),t.CountryCodeOfOrigin&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Origin"}),jsxRuntime.jsxs("div",{className:"font-medium flex items-center",children:[jsxRuntime.jsx(CountryFlag,{countryCode:t.CountryCodeOfOrigin,className:"mr-2"}),t.CountryCodeOfOrigin]})]})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col @[36rem]:order-2 order-1 items-center",children:jsxRuntime.jsx(ProductImage,{randmarSKU:t.RandmarSKU||"",alt:t.RandmarTitle||""},`product_image_${t.RandmarSKU}`)})]}),jsxRuntime.jsxs("div",{className:"flex flex-col @[36rem]:flex-row gap-6 mt-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-row @[36rem]:flex-col gap-4 justify-center @[36rem]:justify-start @[36rem]:order-2 order-1",children:[n&&jsxRuntime.jsx(reactRouterDom.Link,{to:n,children:jsxRuntime.jsxs(Button$1,{variant:"outline",className:"h-11 px-4 text-sm font-medium justify-start",children:[jsxRuntime.jsx(Eye,{className:"mr-2"}),"View Product"]})}),jsxRuntime.jsx(ProductInventoryButton,{applicationId:e??"",randmarSku:t.RandmarSKU??"",inventory:(Mt=t.Distribution)==null?void 0:Mt.Inventory})]}),jsxRuntime.jsx("div",{className:"flex flex-1 @[36rem]:order-1 order-2",children:Je&&t.Distribution&&jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx("div",{className:"flex items-center",children:"You have "+nt.length+(nt.length>1?" opportunities":" opportunity")+" for this product:"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsx("div",{className:"space-y-2 max-h-[200px] overflow-y-auto p-2 mt-1",children:nt.map((Ze,ct)=>Be(Ze)?jsxRuntime.jsxs("div",{className:`flex justify-between items-center rounded-lg transition-colors py-2 px-4 border border-muted cursor-pointer ${Ze.BidNumber==(C==null?void 0:C.BidNumber)?"bg-purple-100 border-2 border-purple-900":"bg-white border-1 border-purple-600 hover:bg-purple-200"}`,onClick:()=>{E(Ze.BidNumber!==(C==null?void 0:C.BidNumber)?Ze:null)},children:[jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-medium text-sm",children:Ze.Opportunity}),jsxRuntime.jsx("span",{className:"text-xs text-neutral-900",children:Ze.BidNumber})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end",children:[jsxRuntime.jsx("span",{className:"font-semibold",children:formatMoney(Ze.Price??0)}),Ze.Rebate&&Ze.Rebate>0&&jsxRuntime.jsxs("span",{className:"text-xs text-green-600",children:["Rebate: ",formatMoney(Ze.Rebate)]}),Ze.EndDate&&jsxRuntime.jsxs("span",{className:"text-xs text-neutral-600",children:["Ends: ",ot(Ze.EndDate)]})]})]},ct):jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex justify-between items-center rounded-lg transition-colors py-2 px-4 bg-purple-100 border border-muted cursor-pointer !bg-neutral-50 hover:bg-neutral-100",onClick:()=>{Ze.BidNumber&&b(`/${e}/Opportunity/${Ze.ManufacturerId}/${Ze.BidNumber}`)},children:[jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-medium text-sm",children:Ze.Opportunity}),jsxRuntime.jsxs("span",{className:"text-xs text-neutral-900",children:[Ze.BidNumber," ",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 items-end",children:[jsxRuntime.jsx("span",{className:"font-semibold",children:formatMoney(Ze.Price??0)}),Ze.Rebate&&Ze.Rebate>0&&jsxRuntime.jsxs("span",{className:"text-xs text-green-600",children:["Rebate: ",formatMoney(Ze.Rebate)]}),Ze.EndDate&&jsxRuntime.jsxs("span",{className:"text-xs text-neutral-600",children:["Ends: ",ot(Ze.EndDate)]})]})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"View Opportunity"})})]},ct))})})]})})]}),jsxRuntime.jsxs("div",{className:"flex flex-row flex-wrap justify-between items-end mt-4 gap-4",children:[jsxRuntime.jsxs("div",{className:"flex-shrink-1 flex flex-col gap-3",children:[t.Distribution&&jsxRuntime.jsx("div",{className:"flex flex-col gap-1",children:oe>0?jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("span",{className:"text-2xl font-bold whitespace-nowrap",children:["Cost: ",formatMoney(oe)]})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap",children:[$e>0&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("span",{className:"text-2xl font-bold whitespace-nowrap",children:formatMoney((C?(Ke=(Ct=t.Opportunities)==null?void 0:Ct.find(Ze=>Ze.BidNumber==C.BidNumber))==null?void 0:Ke.Price:Ae)??0)})}),A>0&&jsxRuntime.jsx("span",{className:"text-muted-foreground line-through ml-2 whitespace-nowrap",children:formatMoney($e)})]}),A>0&&jsxRuntime.jsx("div",{className:"flex items-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:[A,"% OFF"]}),((Ye=t.InstantRebate)==null?void 0:Ye.EndDate)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",t.InstantRebate.EndDate.split("T")[0]]}),(C==null?void 0:C.EndDate)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",C.EndDate.split("T")[0]]})]})})]})}),jsxRuntime.jsxs(Button$1,{variant:"outline",type:"button",className:"h-11 px-4 text-sm font-medium justify-start w-fit",onClick:()=>te(!0),disabled:!je,children:[jsxRuntime.jsx(ChartLine,{className:"mr-2"}),"View statistics"]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col justify-center @[36rem]:justify-end items-end gap-2 w-full",children:[f&&jsxRuntime.jsx(Button$1,{className:"gap-2 whitespace-nowrap bg-green-600 hover:bg-green-700",onClick:Ge,disabled:I,children:I?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,typeof l<"u"&&jsxRuntime.jsxs("div",{className:"flex gap-2 whitespace-nowrap",children:[jsxRuntime.jsxs("div",{className:"flex items-center border rounded-md",children:[jsxRuntime.jsx(Button$1,{variant:"ghost",size:"icon",className:"rounded-r-none",onClick:st,disabled:typeof S<"u"&&(S<=1||!t.AvailableToBuy||d),children:"-"}),jsxRuntime.jsx("input",{value:S,onChange:at,onBlur:tt,onClick:Ze=>Ze.currentTarget.select(),className:`w-6 @[36rem]:w-12 text-center border-0 focus:ring-0 focus:outline-none ${!t.AvailableToBuy||d?"text-gray-400":""}`,disabled:!t.AvailableToBuy||d}),jsxRuntime.jsx(Button$1,{variant:"ghost",size:"icon",className:"rounded-l-none",onClick:et,disabled:!t.AvailableToBuy||d,children:"+"})]}),jsxRuntime.jsx(Button$1,{className:"gap-2 whitespace-nowrap",onClick:lt,disabled:!t.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"]})})]})]})]})]})}),jsxRuntime.jsx(Dialog,{open:Q,onOpenChange:te,children:jsxRuntime.jsxs(DialogContent,{className:"w-[min(95vw,1100px)] max-w-5xl space-y-6",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Monthly Sales Performance"}),jsxRuntime.jsxs(DialogDescription,{children:["Expanded product insights for ",ze,Xe?` (SKU ${Xe})`:""]})]}),jsxRuntime.jsx("div",{className:"space-y-6",children:se?jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(AlertTitle,{children:"Unable to load details"}),jsxRuntime.jsx(AlertDescription,{children:se})]}):jsxRuntime.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[jsxRuntime.jsxs("div",{className:"mb-4 space-y-2",children:[jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Rolling 12-month sales dollars and units sold pulled from the detailed endpoint."}),Ve&&jsxRuntime.jsx("div",{"aria-live":"polite","aria-busy":"true",children:jsxRuntime.jsx(Progress,{value:Le,className:"h-2 w-full animate-pulse","aria-label":"Loading performance data"})})]}),jsxRuntime.jsx(SalesChart,{statistics:We,mode:"month",chartHeight:320}),Ve&&jsxRuntime.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"Gathering product summary and sales statistics..."})]})})]})})]})}const complexComponents=[`----
1246
1246
  PartnerCard: For data that fits this shape:
1247
1247
  { "ApplicationId": "19022", "PublicName": "BiOSS", "VoiceName": null, "VoiceStyle": null, "About": "example", "SceneName": "Kitchen Counter", "IsReseller": true, "IsManufacturer": true, "IsSalesAgency": false, "Socials": [ { "ApplicationId": "19022", "SocialNetwork": "Facebook", "Tag": "@bioss.ca" }, { "ApplicationId": "19022", "SocialNetwork": "Instagram", "Tag": "@bioss.ca" }, { "ApplicationId": "19022", "SocialNetwork": "LinkedIn", "Tag": "@biossinc" }, { "ApplicationId": "19022", "SocialNetwork": "Youtube", "Tag": "@biosssolutionssanitairessa4095" } ], "Manufacturer": null, "Reseller": null }
1248
1248
  Use <PartnerCard account={data} action={<></>}>`,`----
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "randmarcomps",
3
3
  "private": false,
4
- "version": "1.479.0",
4
+ "version": "1.481.0",
5
5
  "description": "The UI library enabling speed and consistency in Randmar frontends.",
6
6
  "type": "module",
7
7
  "files": [