randmarcomps 1.252.0 → 1.254.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.
@@ -50751,13 +50751,13 @@ const PartnerLogo = ({
50751
50751
  freezeOnceVisible: !0
50752
50752
  }), {
50753
50753
  data: C,
50754
- isLoading: E
50754
+ isFetching: E
50755
50755
  } = useGetV4PartnerByApplicationIdAccountLogoExistsQuery(
50756
50756
  { applicationId: t ?? "" },
50757
50757
  { skip: !t || !_ }
50758
50758
  );
50759
50759
  useEffect(() => {
50760
- !C || C === "false" || (g(!0), fetch(
50760
+ !t || E || !C || C === "false" || (S(null), g(!0), fetch(
50761
50761
  `https://api.randmar.io/V4/Partner/${t}/Account/Logo?width=${n}&height=${o}&align=${l}`
50762
50762
  ).then((M) => {
50763
50763
  M.ok || console.error("error fetching logo"), M.blob().then((O) => {
@@ -50769,7 +50769,7 @@ const PartnerLogo = ({
50769
50769
  }).finally(() => {
50770
50770
  g(!1);
50771
50771
  }));
50772
- }, [C]);
50772
+ }, [t, C, E]);
50773
50773
  const R = "No Logo", A = e || (t ? `Partner ID: ${t}` : "Logo not available (no ID)");
50774
50774
  return /* @__PURE__ */ jsx(TooltipProvider, { delayDuration: 100, children: /* @__PURE__ */ jsxs(Tooltip$1, { children: [
50775
50775
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("div", { className: "flex h-full w-full cursor-default", ref: d, children: !_ || E || f ? /* @__PURE__ */ jsx(Skeleton, { className: "h-full w-full rounded-sm" }) : b ? /* @__PURE__ */ jsx("img", { src: b, alt: A, className: "h-full w-full object-contain rounded-sm" }) : /* @__PURE__ */ jsx("div", { className: "flex h-full w-full items-center justify-center border border-dashed border-border rounded-sm bg-muted/20 p-1", title: A, children: /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground font-mono text-center leading-none", children: R }) }) }) }),
@@ -84517,16 +84517,14 @@ function ProductOverviewPage({
84517
84517
  ((g == null ? void 0 : g.VoiceoverCaption) || (g == null ? void 0 : g.BodyHTML)) && /* @__PURE__ */ jsxs(Fragment$1, { children: [
84518
84518
  /* @__PURE__ */ jsx("hr", { className: "my-6" }),
84519
84519
  /* @__PURE__ */ jsx("div", { className: "text-muted-foreground mb-2", children: "Description" }),
84520
- /* @__PURE__ */ jsxs("div", { className: "max-h-44 overflow-scroll", children: [
84521
- (g == null ? void 0 : g.VoiceoverCaption) && /* @__PURE__ */ jsx("div", { children: g == null ? void 0 : g.VoiceoverCaption }),
84522
- (g == null ? void 0 : g.BodyHTML) && /* @__PURE__ */ jsx(
84523
- "div",
84524
- {
84525
- className: "prose prose-sm max-w-none",
84526
- dangerouslySetInnerHTML: { __html: (g == null ? void 0 : g.BodyHTML) ?? "" }
84527
- }
84528
- )
84529
- ] })
84520
+ (g == null ? void 0 : g.VoiceoverCaption) && /* @__PURE__ */ jsx("div", { children: g == null ? void 0 : g.VoiceoverCaption }),
84521
+ (g == null ? void 0 : g.BodyHTML) && /* @__PURE__ */ jsx(
84522
+ "div",
84523
+ {
84524
+ className: "prose prose-sm max-w-none",
84525
+ dangerouslySetInnerHTML: { __html: (g == null ? void 0 : g.BodyHTML) ?? "" }
84526
+ }
84527
+ )
84530
84528
  ] })
84531
84529
  ] }) })
84532
84530
  ] })
@@ -1000,7 +1000,7 @@ ${t}</tr>
1000
1000
  `}tablecell(t){const e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
1001
1001
  `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${escape2(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){const o=this.parser.parseInline(n),l=cleanUrl(t);if(l===null)return o;t=l;let d='<a href="'+t+'"';return e&&(d+=' title="'+escape2(e)+'"'),d+=">"+o+"</a>",d}image({href:t,title:e,text:n,tokens:o}){o&&(n=this.parser.parseInline(o,this.parser.textRenderer));const l=cleanUrl(t);if(l===null)return escape2(n);t=l;let d=`<img src="${t}" alt="${n}"`;return e&&(d+=` title="${escape2(e)}"`),d+=">",d}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:escape2(t.text)}},_TextRenderer=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}},_Parser=class qr{constructor(e){Qt(this,"options");Qt(this,"renderer");Qt(this,"textRenderer");this.options=e||_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(e,n){return new qr(n).parse(e)}static parseInline(e,n){return new qr(n).parseInline(e)}parse(e,n=!0){var l,d;let o="";for(let f=0;f<e.length;f++){const g=e[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<e.length&&e[f+1].type==="text";)_=e[++f],S+=`
1002
1002
  `+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(e,n=this.renderer){var l,d;let o="";for(let f=0;f<e.length;f++){const g=e[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=(Zt=class{constructor(t){Qt(this,"options");Qt(this,"block");this.options=t||_defaults}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?_Lexer.lex:_Lexer.lexInline}provideParser(){return this.block?_Parser.parse:_Parser.parseInline}},Qt(Zt,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"])),Zt),Marked=class{constructor(...t){Qt(this,"defaults",_getDefaults());Qt(this,"options",this.setOptions);Qt(this,"parse",this.parseMarkdown(!0));Qt(this,"parseInline",this.parseMarkdown(!1));Qt(this,"Parser",_Parser);Qt(this,"Renderer",_Renderer);Qt(this,"TextRenderer",_TextRenderer);Qt(this,"Lexer",_Lexer);Qt(this,"Tokenizer",_Tokenizer);Qt(this,"Hooks",_Hooks);this.use(...t)}walkTokens(t,e){var o,l;let n=[];for(const d of t)switch(n=n.concat(e.call(this,d)),d.type){case"table":{const f=d;for(const g of f.header)n=n.concat(this.walkTokens(g.tokens,e));for(const g of f.rows)for(const b of g)n=n.concat(this.walkTokens(b.tokens,e));break}case"list":{const f=d;n=n.concat(this.walkTokens(f.items,e));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,e))}):f.tokens&&(n=n.concat(this.walkTokens(f.tokens,e)))}}return n}use(...t){const e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.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=e.renderers[l.name];d?e.renderers[l.name]=function(...f){let g=l.renderer.apply(this,f);return g===!1&&(g=d.apply(this,f)),g}:e.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=e[l.level];d?d.unshift(l.tokenizer):e[l.level]=[l.tokenizer],l.start&&(l.level==="block"?e.startBlock?e.startBlock.push(l.start):e.startBlock=[l.start]:l.level==="inline"&&(e.startInline?e.startInline.push(l.start):e.startInline=[l.start]))}"childTokens"in l&&l.childTokens&&(e.childTokens[l.name]=l.childTokens)}),o.extensions=e),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(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return _Lexer.lex(t,e??this.defaults)}parser(t,e){return _Parser.parse(t,e??this.defaults)}parseMarkdown(t){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=t);const g=d.hooks?d.hooks.provideLexer():t?_Lexer.lex:_Lexer.lexInline,b=d.hooks?d.hooks.provideParser():t?_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(t,e){return n=>{if(n.message+=`
1003
- Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An error occurred:</p><pre>"+escape2(n.message+"",!0)+"</pre>";return e?Promise.resolve(o):o}if(e)return Promise.reject(n);throw n}}},markedInstance=new Marked;function marked(t,e){return markedInstance.parse(t,e)}marked.options=marked.setOptions=function(t){return markedInstance.setOptions(t),marked.defaults=markedInstance.defaults,changeDefaults(marked.defaults),marked},marked.getDefaults=_getDefaults,marked.defaults=_defaults,marked.use=function(...t){return markedInstance.use(...t),marked.defaults=markedInstance.defaults,changeDefaults(marked.defaults),marked},marked.walkTokens=function(t,e){return markedInstance.walkTokens(t,e)},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;const Card=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("rounded-md border bg-card text-card-foreground shadow-sm",t),...e}));Card.displayName="Card";const CardHeader=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("flex flex-col space-y-1.5 p-6",t),...e}));CardHeader.displayName="CardHeader";const CardTitle=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("font-semibold leading-none tracking-tight",t),...e}));CardTitle.displayName="CardTitle";const CardDescription=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("text-sm text-muted-foreground",t),...e}));CardDescription.displayName="CardDescription";const CardContent=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("p-6 pt-0",t),...e}));CardContent.displayName="CardContent";const CardFooter=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("flex items-center p-6 pt-0",t),...e}));CardFooter.displayName="CardFooter";const badgeVariants=cva("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground border border-input hover:bg-accent hover:text-accent-foreground",success:"bg-green-600 text-white hover:bg-green-700",warning:"bg-yellow-500 text-white hover:bg-yellow-600",info:"bg-blue-500 text-white hover:bg-blue-600",ghost:"bg-background hover:bg-accent hover:text-accent-foreground",randmarRed:"bg-randmar-red text-white hover:bg-randmar-red/80",randmarBlue:"bg-randmar-blue text-white hover:bg-randmar-blue/80",randmarPurple:"bg-randmar-purple text-white hover:bg-randmar-purple/80",randmarGreen:"bg-randmar-green text-black hover:bg-randmar-green/80",randmarBlack:"bg-randmar-black text-white hover:bg-randmar-black/80",randmarYellow:"bg-randmar-yellow text-black hover:bg-randmar-yellow/80"},size:{default:"h-6",sm:"h-5 text-[10px]",lg:"h-7 px-3"}},defaultVariants:{variant:"default",size:"default"}}),Badge=React__namespace.forwardRef(({className:t,variant:e,size:n,icon:o,children:l,...d},f)=>jsxRuntime.jsxs("div",{ref:f,className:cn(badgeVariants({variant:e,size:n}),t),...d,children:[o&&jsxRuntime.jsx("span",{className:"mr-1",children:o}),l]}));Badge.displayName="Badge";function useIntersectionObserver({elementRef:t,threshold:e=0,rootMargin:n="0px",freezeOnceVisible:o=!1}){const[l,d]=React.useState(!1);return React.useEffect(()=>{const f=t.current;if(!f){d(!1);return}const g=new IntersectionObserver(([b])=>{const _=b.isIntersecting;o&&_?(d(!0),g.unobserve(f)):d(_)},{threshold:e,rootMargin:n});return g.observe(f),()=>{g.unobserve(f)}},[t,e,n,o]),l}const PartnerLogo=({id:t,name:e,width:n=64,height:o=64,align:l=""})=>{const d=React.useRef(null),[f,g]=React.useState(!1),[b,_]=React.useState(null),S=useIntersectionObserver({elementRef:d,threshold:.1,rootMargin:"100px",freezeOnceVisible:!0}),{data:R,isLoading:C}=useGetV4PartnerByApplicationIdAccountLogoExistsQuery({applicationId:t??""},{skip:!t||!S});React.useEffect(()=>{!R||R==="false"||(g(!0),fetch(`https://api.randmar.io/V4/Partner/${t}/Account/Logo?width=${n}&height=${o}&align=${l}`).then(M=>{M.ok||console.error("error fetching logo"),M.blob().then(j=>{const q=window.URL.createObjectURL(j);_(q)})}).catch(M=>{console.error("error loading logo",M)}).finally(()=>{g(!1)}))},[R]);const E="No Logo",A=e||(t?`Partner ID: ${t}`:"Logo not available (no ID)"),I=()=>!S||C||f?jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-sm"}):b?jsxRuntime.jsx("img",{src:b,alt:A,className:"h-full w-full object-contain rounded-sm"}):jsxRuntime.jsx("div",{className:"flex h-full w-full items-center justify-center border border-dashed border-border rounded-sm bg-muted/20 p-1",title:A,children:jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground font-mono text-center leading-none",children:E})});return jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("div",{className:"flex h-full w-full cursor-default",ref:d,children:I()})}),jsxRuntime.jsx(TooltipContent,{side:"top",align:"center",children:A})]})})};function PartnerCard({account:t,action:e,loading:n=!1,className:o,withAbout:l=!1,withVoice:d=!0}){const[f,g]=React.useState(!1),[b,_]=React.useState(!0),[S,R]=React.useState(null),[C,E]=React.useState(!1),A=React.useMemo(()=>t!=null&&t.ApplicationId?{videoUrl:`https://api.randmar.io/V4/Partner/${t.ApplicationId}/Account/Video`,videoExistsUrl:`https://api.randmar.io/V4/Partner/${t.ApplicationId}/Account/Video/Exists`}:null,[t==null?void 0:t.ApplicationId]);React.useEffect(()=>{if(!A||n)return;R(null);const M=async()=>{try{const q=await fetch(A.videoExistsUrl);if(q.ok){const z=await q.text();g(z.toLowerCase()==="true")}else throw new Error(`Failed to check video: ${q.status}`)}catch(q){console.error("Failed to check if video exists:",q),g(!1)}};(async()=>{M()})()},[A,n]);const I=()=>{_(!1)};return n||!t?jsxRuntime.jsxs(Card,{className:`flex flex-col h-full ${o}`,children:[jsxRuntime.jsx(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-16"}),jsxRuntime.jsx(Skeleton,{className:"h-3 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-48 mt-1"})]})]})}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"})]}),l&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-full"})]}),d&&jsxRuntime.jsx("div",{className:"p-3 bg-slate-50 rounded-md",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]})]})})]})}),jsxRuntime.jsxs(CardFooter,{className:"px-6 py-4 flex justify-between gap-2 mt-auto",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-48"})]})]}):jsxRuntime.jsxs(Card,{className:`flex flex-col h-full ${o}`,children:[jsxRuntime.jsx(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx(PartnerLogo,{id:t.ApplicationId,width:64,height:64})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:"Partner"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:t.ApplicationId})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:t.PublicName||"N/A"})]})]})}),jsxRuntime.jsxs(CardContent,{className:"pb-2 flex-grow",children:[S&&jsxRuntime.jsx("div",{className:"text-red-500 mb-4 text-sm",role:"alert",children:S}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[(t.IsManufacturer||t.IsReseller||t.IsSalesAgency)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.IsManufacturer&&jsxRuntime.jsx(Badge,{className:"manufacturer-theme",children:"Manufacturer"}),t.IsReseller&&jsxRuntime.jsx(Badge,{className:"reseller-theme",children:"Reseller"}),t.IsSalesAgency&&jsxRuntime.jsx(Badge,{children:"Agency"})]}),l&&t.About&&jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:t.About??""}}),d&&jsxRuntime.jsx("div",{className:"p-3 bg-slate-50 rounded-md",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Voice Name"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.VoiceName??"Regular"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Voice Style"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.VoiceStyle??"Regular"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Scene Name"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.SceneName??"N/A"})]})]})})]})]}),jsxRuntime.jsxs(CardFooter,{className:"px-6 py-4 flex justify-between gap-2 mt-auto",children:[f&&A?jsxRuntime.jsxs(Dialog,{open:C,onOpenChange:E,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{variant:"outline",className:"flex items-center gap-2",children:[jsxRuntime.jsx(Video,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:"Watch Video"})]})}),jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[360px]",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsxs(DialogTitle,{children:[t.PublicName," Video"]})}),jsxRuntime.jsxs("div",{className:"w-full h-[640px] rounded-md overflow-hidden",children:[b&&jsxRuntime.jsx(Skeleton,{className:"w-full h-full"}),jsxRuntime.jsx("video",{src:A.videoUrl,controls:!0,preload:"auto",playsInline:!0,autoPlay:!0,"aria-label":`Video for ${t.PublicName}`,className:`w-full h-full object-cover ${b?"invisible":"visible"}`,style:{objectPosition:"center",imageRendering:"auto"},onLoadedData:I,onError:()=>_(!1)})]})]})]}):jsxRuntime.jsx("div",{}),e||jsxRuntime.jsxs(Button,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4"}),"Go to Partner Dashboard"]})]})]})}const Textarea=React__namespace.forwardRef(({className:t,...e},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",t),ref:n,...e}));Textarea.displayName="Textarea";function ChatList({userId:t,chats:e,activeChat:n,onSelectChat:o,assistantChat:l}){return jsxRuntime.jsxs("div",{className:"space-y-1 flex flex-col min-h-full",children:[jsxRuntime.jsx("div",{className:"flex-grow",children:e.map(d=>{const f=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(AvatarImage,{src:`https://api.randmar.io/v4/Partner/${d.partner1===t?d.partner2:d.partner1}/Account/Logo?height=72&width=72`,className:" object-contain "}),jsxRuntime.jsx(AvatarFallback,{children:jsxRuntime.jsx(Handshake,{className:"text-primary fill-white min-h-full"})})]});return display(d,n,o,f)})}),jsxRuntime.jsxs("div",{className:"mt-auto",children:[jsxRuntime.jsx(Separator$1,{className:"mb-1"}),display(l,n,o,jsxRuntime.jsx(Bot,{className:"text-primary fill-white min-h-full"}))]})]})}function display(t,e,n,o){var l;return jsxRuntime.jsxs("button",{className:cn("w-full flex items-center p-2 rounded-md hover:bg-slate-100 transition-colors",(e==null?void 0:e.partner1)===t.partner1&&(e==null?void 0:e.partner2)===t.partner2&&"bg-slate-100"),onClick:()=>n([t.partner1,t.partner2]),children:[jsxRuntime.jsx(Avatar,{className:"h-8 w-8 flex-shrink-0 rounded-none",children:t.pending?jsxRuntime.jsx(MessageSquareLock,{}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:o})}),jsxRuntime.jsxs("div",{className:"ml-2 text-left overflow-hidden",children:[jsxRuntime.jsx("div",{className:"font-medium text-sm truncate",children:t.name}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground truncate text-ellipsis",children:((l=t.messages.at(-1))==null?void 0:l.content)??""})]}),t.unread>0&&jsxRuntime.jsx("div",{className:"ml-auto bg-red-500 text-white text-xs rounded-full h-5 w-5 flex items-center justify-center",children:t.unread})]},t.partner1+" and "+t.partner2)}var md5$1={exports:{}},crypt={exports:{}},hasRequiredCrypt;function requireCrypt(){return hasRequiredCrypt||(hasRequiredCrypt=1,function(){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e={rotl:function(n,o){return n<<o|n>>>32-o},rotr:function(n,o){return n<<32-o|n>>>o},endian:function(n){if(n.constructor==Number)return e.rotl(n,8)&16711935|e.rotl(n,24)&4278255360;for(var o=0;o<n.length;o++)n[o]=e.endian(n[o]);return n},randomBytes:function(n){for(var o=[];n>0;n--)o.push(Math.floor(Math.random()*256));return o},bytesToWords:function(n){for(var o=[],l=0,d=0;l<n.length;l++,d+=8)o[d>>>5]|=n[l]<<24-d%32;return o},wordsToBytes:function(n){for(var o=[],l=0;l<n.length*32;l+=8)o.push(n[l>>>5]>>>24-l%32&255);return o},bytesToHex:function(n){for(var o=[],l=0;l<n.length;l++)o.push((n[l]>>>4).toString(16)),o.push((n[l]&15).toString(16));return o.join("")},hexToBytes:function(n){for(var o=[],l=0;l<n.length;l+=2)o.push(parseInt(n.substr(l,2),16));return o},bytesToBase64:function(n){for(var o=[],l=0;l<n.length;l+=3)for(var d=n[l]<<16|n[l+1]<<8|n[l+2],f=0;f<4;f++)l*8+f*6<=n.length*8?o.push(t.charAt(d>>>6*(3-f)&63)):o.push("=");return o.join("")},base64ToBytes:function(n){n=n.replace(/[^A-Z0-9+\/]/ig,"");for(var o=[],l=0,d=0;l<n.length;d=++l%4)d!=0&&o.push((t.indexOf(n.charAt(l-1))&Math.pow(2,-2*d+8)-1)<<d*2|t.indexOf(n.charAt(l))>>>6-d*2);return o}};crypt.exports=e}()),crypt.exports}var charenc_1,hasRequiredCharenc;function requireCharenc(){if(hasRequiredCharenc)return charenc_1;hasRequiredCharenc=1;var t={utf8:{stringToBytes:function(e){return t.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(t.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var n=[],o=0;o<e.length;o++)n.push(e.charCodeAt(o)&255);return n},bytesToString:function(e){for(var n=[],o=0;o<e.length;o++)n.push(String.fromCharCode(e[o]));return n.join("")}}};return charenc_1=t,charenc_1}/*!
1003
+ Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An error occurred:</p><pre>"+escape2(n.message+"",!0)+"</pre>";return e?Promise.resolve(o):o}if(e)return Promise.reject(n);throw n}}},markedInstance=new Marked;function marked(t,e){return markedInstance.parse(t,e)}marked.options=marked.setOptions=function(t){return markedInstance.setOptions(t),marked.defaults=markedInstance.defaults,changeDefaults(marked.defaults),marked},marked.getDefaults=_getDefaults,marked.defaults=_defaults,marked.use=function(...t){return markedInstance.use(...t),marked.defaults=markedInstance.defaults,changeDefaults(marked.defaults),marked},marked.walkTokens=function(t,e){return markedInstance.walkTokens(t,e)},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;const Card=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("rounded-md border bg-card text-card-foreground shadow-sm",t),...e}));Card.displayName="Card";const CardHeader=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("flex flex-col space-y-1.5 p-6",t),...e}));CardHeader.displayName="CardHeader";const CardTitle=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("font-semibold leading-none tracking-tight",t),...e}));CardTitle.displayName="CardTitle";const CardDescription=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("text-sm text-muted-foreground",t),...e}));CardDescription.displayName="CardDescription";const CardContent=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("p-6 pt-0",t),...e}));CardContent.displayName="CardContent";const CardFooter=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("flex items-center p-6 pt-0",t),...e}));CardFooter.displayName="CardFooter";const badgeVariants=cva("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground border border-input hover:bg-accent hover:text-accent-foreground",success:"bg-green-600 text-white hover:bg-green-700",warning:"bg-yellow-500 text-white hover:bg-yellow-600",info:"bg-blue-500 text-white hover:bg-blue-600",ghost:"bg-background hover:bg-accent hover:text-accent-foreground",randmarRed:"bg-randmar-red text-white hover:bg-randmar-red/80",randmarBlue:"bg-randmar-blue text-white hover:bg-randmar-blue/80",randmarPurple:"bg-randmar-purple text-white hover:bg-randmar-purple/80",randmarGreen:"bg-randmar-green text-black hover:bg-randmar-green/80",randmarBlack:"bg-randmar-black text-white hover:bg-randmar-black/80",randmarYellow:"bg-randmar-yellow text-black hover:bg-randmar-yellow/80"},size:{default:"h-6",sm:"h-5 text-[10px]",lg:"h-7 px-3"}},defaultVariants:{variant:"default",size:"default"}}),Badge=React__namespace.forwardRef(({className:t,variant:e,size:n,icon:o,children:l,...d},f)=>jsxRuntime.jsxs("div",{ref:f,className:cn(badgeVariants({variant:e,size:n}),t),...d,children:[o&&jsxRuntime.jsx("span",{className:"mr-1",children:o}),l]}));Badge.displayName="Badge";function useIntersectionObserver({elementRef:t,threshold:e=0,rootMargin:n="0px",freezeOnceVisible:o=!1}){const[l,d]=React.useState(!1);return React.useEffect(()=>{const f=t.current;if(!f){d(!1);return}const g=new IntersectionObserver(([b])=>{const _=b.isIntersecting;o&&_?(d(!0),g.unobserve(f)):d(_)},{threshold:e,rootMargin:n});return g.observe(f),()=>{g.unobserve(f)}},[t,e,n,o]),l}const PartnerLogo=({id:t,name:e,width:n=64,height:o=64,align:l=""})=>{const d=React.useRef(null),[f,g]=React.useState(!1),[b,_]=React.useState(null),S=useIntersectionObserver({elementRef:d,threshold:.1,rootMargin:"100px",freezeOnceVisible:!0}),{data:R,isFetching:C}=useGetV4PartnerByApplicationIdAccountLogoExistsQuery({applicationId:t??""},{skip:!t||!S});React.useEffect(()=>{!t||C||!R||R==="false"||(_(null),g(!0),fetch(`https://api.randmar.io/V4/Partner/${t}/Account/Logo?width=${n}&height=${o}&align=${l}`).then(M=>{M.ok||console.error("error fetching logo"),M.blob().then(j=>{const q=window.URL.createObjectURL(j);_(q)})}).catch(M=>{console.error("error loading logo",M)}).finally(()=>{g(!1)}))},[t,R,C]);const E="No Logo",A=e||(t?`Partner ID: ${t}`:"Logo not available (no ID)"),I=()=>!S||C||f?jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-sm"}):b?jsxRuntime.jsx("img",{src:b,alt:A,className:"h-full w-full object-contain rounded-sm"}):jsxRuntime.jsx("div",{className:"flex h-full w-full items-center justify-center border border-dashed border-border rounded-sm bg-muted/20 p-1",title:A,children:jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground font-mono text-center leading-none",children:E})});return jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("div",{className:"flex h-full w-full cursor-default",ref:d,children:I()})}),jsxRuntime.jsx(TooltipContent,{side:"top",align:"center",children:A})]})})};function PartnerCard({account:t,action:e,loading:n=!1,className:o,withAbout:l=!1,withVoice:d=!0}){const[f,g]=React.useState(!1),[b,_]=React.useState(!0),[S,R]=React.useState(null),[C,E]=React.useState(!1),A=React.useMemo(()=>t!=null&&t.ApplicationId?{videoUrl:`https://api.randmar.io/V4/Partner/${t.ApplicationId}/Account/Video`,videoExistsUrl:`https://api.randmar.io/V4/Partner/${t.ApplicationId}/Account/Video/Exists`}:null,[t==null?void 0:t.ApplicationId]);React.useEffect(()=>{if(!A||n)return;R(null);const M=async()=>{try{const q=await fetch(A.videoExistsUrl);if(q.ok){const z=await q.text();g(z.toLowerCase()==="true")}else throw new Error(`Failed to check video: ${q.status}`)}catch(q){console.error("Failed to check if video exists:",q),g(!1)}};(async()=>{M()})()},[A,n]);const I=()=>{_(!1)};return n||!t?jsxRuntime.jsxs(Card,{className:`flex flex-col h-full ${o}`,children:[jsxRuntime.jsx(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-16"}),jsxRuntime.jsx(Skeleton,{className:"h-3 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-48 mt-1"})]})]})}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"})]}),l&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-full"})]}),d&&jsxRuntime.jsx("div",{className:"p-3 bg-slate-50 rounded-md",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]})]})})]})}),jsxRuntime.jsxs(CardFooter,{className:"px-6 py-4 flex justify-between gap-2 mt-auto",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-48"})]})]}):jsxRuntime.jsxs(Card,{className:`flex flex-col h-full ${o}`,children:[jsxRuntime.jsx(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx(PartnerLogo,{id:t.ApplicationId,width:64,height:64})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:"Partner"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:t.ApplicationId})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:t.PublicName||"N/A"})]})]})}),jsxRuntime.jsxs(CardContent,{className:"pb-2 flex-grow",children:[S&&jsxRuntime.jsx("div",{className:"text-red-500 mb-4 text-sm",role:"alert",children:S}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[(t.IsManufacturer||t.IsReseller||t.IsSalesAgency)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.IsManufacturer&&jsxRuntime.jsx(Badge,{className:"manufacturer-theme",children:"Manufacturer"}),t.IsReseller&&jsxRuntime.jsx(Badge,{className:"reseller-theme",children:"Reseller"}),t.IsSalesAgency&&jsxRuntime.jsx(Badge,{children:"Agency"})]}),l&&t.About&&jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:t.About??""}}),d&&jsxRuntime.jsx("div",{className:"p-3 bg-slate-50 rounded-md",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Voice Name"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.VoiceName??"Regular"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Voice Style"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.VoiceStyle??"Regular"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Scene Name"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.SceneName??"N/A"})]})]})})]})]}),jsxRuntime.jsxs(CardFooter,{className:"px-6 py-4 flex justify-between gap-2 mt-auto",children:[f&&A?jsxRuntime.jsxs(Dialog,{open:C,onOpenChange:E,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{variant:"outline",className:"flex items-center gap-2",children:[jsxRuntime.jsx(Video,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:"Watch Video"})]})}),jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[360px]",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsxs(DialogTitle,{children:[t.PublicName," Video"]})}),jsxRuntime.jsxs("div",{className:"w-full h-[640px] rounded-md overflow-hidden",children:[b&&jsxRuntime.jsx(Skeleton,{className:"w-full h-full"}),jsxRuntime.jsx("video",{src:A.videoUrl,controls:!0,preload:"auto",playsInline:!0,autoPlay:!0,"aria-label":`Video for ${t.PublicName}`,className:`w-full h-full object-cover ${b?"invisible":"visible"}`,style:{objectPosition:"center",imageRendering:"auto"},onLoadedData:I,onError:()=>_(!1)})]})]})]}):jsxRuntime.jsx("div",{}),e||jsxRuntime.jsxs(Button,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4"}),"Go to Partner Dashboard"]})]})]})}const Textarea=React__namespace.forwardRef(({className:t,...e},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",t),ref:n,...e}));Textarea.displayName="Textarea";function ChatList({userId:t,chats:e,activeChat:n,onSelectChat:o,assistantChat:l}){return jsxRuntime.jsxs("div",{className:"space-y-1 flex flex-col min-h-full",children:[jsxRuntime.jsx("div",{className:"flex-grow",children:e.map(d=>{const f=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(AvatarImage,{src:`https://api.randmar.io/v4/Partner/${d.partner1===t?d.partner2:d.partner1}/Account/Logo?height=72&width=72`,className:" object-contain "}),jsxRuntime.jsx(AvatarFallback,{children:jsxRuntime.jsx(Handshake,{className:"text-primary fill-white min-h-full"})})]});return display(d,n,o,f)})}),jsxRuntime.jsxs("div",{className:"mt-auto",children:[jsxRuntime.jsx(Separator$1,{className:"mb-1"}),display(l,n,o,jsxRuntime.jsx(Bot,{className:"text-primary fill-white min-h-full"}))]})]})}function display(t,e,n,o){var l;return jsxRuntime.jsxs("button",{className:cn("w-full flex items-center p-2 rounded-md hover:bg-slate-100 transition-colors",(e==null?void 0:e.partner1)===t.partner1&&(e==null?void 0:e.partner2)===t.partner2&&"bg-slate-100"),onClick:()=>n([t.partner1,t.partner2]),children:[jsxRuntime.jsx(Avatar,{className:"h-8 w-8 flex-shrink-0 rounded-none",children:t.pending?jsxRuntime.jsx(MessageSquareLock,{}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:o})}),jsxRuntime.jsxs("div",{className:"ml-2 text-left overflow-hidden",children:[jsxRuntime.jsx("div",{className:"font-medium text-sm truncate",children:t.name}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground truncate text-ellipsis",children:((l=t.messages.at(-1))==null?void 0:l.content)??""})]}),t.unread>0&&jsxRuntime.jsx("div",{className:"ml-auto bg-red-500 text-white text-xs rounded-full h-5 w-5 flex items-center justify-center",children:t.unread})]},t.partner1+" and "+t.partner2)}var md5$1={exports:{}},crypt={exports:{}},hasRequiredCrypt;function requireCrypt(){return hasRequiredCrypt||(hasRequiredCrypt=1,function(){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e={rotl:function(n,o){return n<<o|n>>>32-o},rotr:function(n,o){return n<<32-o|n>>>o},endian:function(n){if(n.constructor==Number)return e.rotl(n,8)&16711935|e.rotl(n,24)&4278255360;for(var o=0;o<n.length;o++)n[o]=e.endian(n[o]);return n},randomBytes:function(n){for(var o=[];n>0;n--)o.push(Math.floor(Math.random()*256));return o},bytesToWords:function(n){for(var o=[],l=0,d=0;l<n.length;l++,d+=8)o[d>>>5]|=n[l]<<24-d%32;return o},wordsToBytes:function(n){for(var o=[],l=0;l<n.length*32;l+=8)o.push(n[l>>>5]>>>24-l%32&255);return o},bytesToHex:function(n){for(var o=[],l=0;l<n.length;l++)o.push((n[l]>>>4).toString(16)),o.push((n[l]&15).toString(16));return o.join("")},hexToBytes:function(n){for(var o=[],l=0;l<n.length;l+=2)o.push(parseInt(n.substr(l,2),16));return o},bytesToBase64:function(n){for(var o=[],l=0;l<n.length;l+=3)for(var d=n[l]<<16|n[l+1]<<8|n[l+2],f=0;f<4;f++)l*8+f*6<=n.length*8?o.push(t.charAt(d>>>6*(3-f)&63)):o.push("=");return o.join("")},base64ToBytes:function(n){n=n.replace(/[^A-Z0-9+\/]/ig,"");for(var o=[],l=0,d=0;l<n.length;d=++l%4)d!=0&&o.push((t.indexOf(n.charAt(l-1))&Math.pow(2,-2*d+8)-1)<<d*2|t.indexOf(n.charAt(l))>>>6-d*2);return o}};crypt.exports=e}()),crypt.exports}var charenc_1,hasRequiredCharenc;function requireCharenc(){if(hasRequiredCharenc)return charenc_1;hasRequiredCharenc=1;var t={utf8:{stringToBytes:function(e){return t.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(t.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var n=[],o=0;o<e.length;o++)n.push(e.charCodeAt(o)&255);return n},bytesToString:function(e){for(var n=[],o=0;o<e.length;o++)n.push(String.fromCharCode(e[o]));return n.join("")}}};return charenc_1=t,charenc_1}/*!
1004
1004
  * Determine if an object is a Buffer
1005
1005
  *
1006
1006
  * @author Feross Aboukhadijeh <https://feross.org>
@@ -1271,4 +1271,4 @@ img.ProseMirror-separator {
1271
1271
  .ProseMirror p {
1272
1272
  margin-bottom: 0.5em;
1273
1273
  }
1274
- `;function RichTextEditor({id:t,name:e,value:n,onChange:o,placeholder:l,className:d,...f}){const[g,b]=React.useState(!1),_=React.useRef(null),S=React.useRef(null),R=useEditor({extensions:[StarterKit,Underline],content:n,editorProps:{attributes:{class:"prose prose-sm sm:prose dark:prose-invert focus:outline-none",id:t??"",name:e??""}},onUpdate:({editor:j})=>{const q=j.getHTML();o({target:{id:t,name:e,value:q}})}});React.useEffect(()=>{R&&n!==R.getHTML()&&R.commands.setContent(n)},[n,R]);const C=React.useCallback(j=>{if(R)if(R.chain().focus(),j==="paragraph")R.chain().setParagraph().run();else{const q=Number.parseInt(j.slice(1));R.chain().setHeading({level:q}).run()}},[R]),E=React.useCallback(j=>{if(R)switch(R.chain().focus(),j){case"bold":R.chain().toggleBold().run();break;case"italic":R.chain().toggleItalic().run();break;case"underline":R.chain().toggleUnderline().run();break;case"strike":R.chain().toggleStrike().run();break;case"bulletList":R.chain().toggleBulletList().run();break;case"orderedList":R.chain().toggleOrderedList().run();break}},[R]),A=React.useCallback(()=>{b(j=>!j)},[]),I=React.useCallback(j=>{const q=j.target.value;R&&R.commands.setContent(q),o({target:{id:t,name:e,value:q}})},[o,R,t,e]),M=React.useCallback(()=>{!g&&R&&R.commands.focus()},[g,R]);return R?jsxRuntime.jsxs("div",{ref:S,className:cn("border border-input rounded-md overflow-hidden focus-within:outline-hidden focus-within:ring-1 focus-within:ring-ring",d),onClick:M,...f,children:[jsxRuntime.jsx("style",{children:editorStyles}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center p-2 border-b border-input gap-2 bg-background",children:[jsxRuntime.jsxs(Select,{onValueChange:C,disabled:g,children:[jsxRuntime.jsx(SelectTrigger,{className:"w-[160px]",children:jsxRuntime.jsx(SelectValue,{placeholder:"Format"})}),jsxRuntime.jsx(SelectContent,{children:formatOptions.map(j=>jsxRuntime.jsx(SelectItem,{value:j.value,children:j.label},j.value))})]}),["bold","italic","underline","strike","bulletList","orderedList"].map(j=>jsxRuntime.jsxs(Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>E(j),className:R.isActive(j)?"bg-muted":"",disabled:g,children:[j==="bold"&&jsxRuntime.jsx(Bold$1,{className:"h-4 w-4"}),j==="italic"&&jsxRuntime.jsx(Italic$1,{className:"h-4 w-4"}),j==="underline"&&jsxRuntime.jsx(Underline$1,{className:"h-4 w-4"}),j==="strike"&&jsxRuntime.jsx(Strikethrough,{className:"h-4 w-4"}),j==="bulletList"&&jsxRuntime.jsx(List$1,{className:"h-4 w-4"}),j==="orderedList"&&jsxRuntime.jsx(ListOrdered,{className:"h-4 w-4"})]},j)),jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"sm",onClick:A,className:g?"bg-muted":"",children:jsxRuntime.jsx(Code$1,{className:"h-4 w-4"})})]}),jsxRuntime.jsx("div",{className:"p-3",children:g?jsxRuntime.jsx(Textarea,{ref:_,id:t,name:e,value:R.getHTML(),onChange:I,className:cn("min-h-[150px] font-mono text-sm resize-none border-0 focus-visible:ring-0 focus-visible:ring-offset-0",d),placeholder:l}):jsxRuntime.jsx(EditorContent,{editor:R})})]}):null}function SalesChart({salesData:t,chartHeight:e=300,units:n="$",unitsPosition:o="left",className:l,isLoading:d=!1}){const[f,g]=React.useState([]),[b,_]=React.useState(!0),S=!d&&!!t&&t.length>0;return React.useEffect(()=>{if(d||!t||t.length===0){g([]);return}const R=t.reduce((Q,F)=>{const V=F.Day??0,te=Math.floor(V).toString();if(te.length!==8||isNaN(Number.parseInt(te)))return console.warn(`Skipping invalid Day format: ${F.Day}`),Q;const ae=te.substring(0,4),se=te.substring(4,6),ge=`${ae}-${se}`;return Q[ge]=(Q[ge]||0)+(F.ExtendedPrice??0),Q},{}),C=Object.keys(R).sort(),E=new Date,A=E.getFullYear(),I=E.getMonth(),M=E.getDate(),j=`${A}-${(I+1).toString().padStart(2,"0")}`,q={...R};if(b&&C.length>0&&C[C.length-1]===j){const Q=q[j],F=new Date(A,I+1,0).getDate();if(M<F&&M>0){const te=Q/M*F;q[j]=te}}const z=C.map(Q=>{const F=q[Q],[V,te]=Q.split("-").map(Number);return{month:new Date(V,te-1).toLocaleString("default",{month:"short",year:"numeric"}),sales:F}});g(z)},[t,b,d]),d?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-24"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx("div",{style:{height:e},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 my-1 pt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-10"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-20"})]}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-3/4 mt-1"})]})]}):f.length===0?jsxRuntime.jsx("div",{style:{height:e},className:l||"p-4 text-center text-muted-foreground flex items-center justify-center",children:"No monthly sales data to display."}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Sales"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx(AreaChart,{data:f,units:n,unitsPosition:o,height:e,className:l}),S&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 my-1 pt-2",children:[jsxRuntime.jsx(Switch,{checked:b,onCheckedChange:_,id:"extrapolate-switch","aria-label":"Toggle sales extrapolation"}),jsxRuntime.jsx(Label$2,{htmlFor:"extrapolate-switch",children:"Extrapolate"})]}),b&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"* Sales for the current month are projected, not actual."})]})]})]})}function getEndDateStatus(t){if(!t)return{text:"No End Date",variant:"neutral",daysRemaining:null};const e=new Date(t);if(isNaN(e.getTime()))return{text:"Invalid Date",variant:"neutral",daysRemaining:null};const n=new Date,o=new Date(e.getFullYear(),e.getMonth(),e.getDate()),l=new Date(n.getFullYear(),n.getMonth(),n.getDate()),d=o.getTime()-l.getTime(),f=Math.ceil(d/(1e3*60*60*24));return f<0?{text:`Ended ${Math.abs(f)}d ago`,variant:"destructive",daysRemaining:f}:f===0?{text:"Ends today",variant:"destructive",daysRemaining:f}:f<=7?{text:`Ends in ${f}d`,variant:"destructive",daysRemaining:f}:f<=30?{text:`Ends in ${f}d`,variant:"warning",daysRemaining:f}:{text:`Ends in ${f}d`,variant:"neutral",daysRemaining:f}}const formatDate=t=>{if(!t)return"N/A";try{const e=new Date(t);return isNaN(e.getTime())?"Invalid Date":e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return"Invalid Date"}};function OpportunitiesTable({applicationId:t,opportunities:e=null,loading:n=!1}){var te;const{toast:o}=useToast(),[l,d]=React.useState({}),[f,g]=React.useState(!1),[b,_]=React.useState(""),[S,R]=React.useState(null),{data:C}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:t},{skip:!t}),E=React.useCallback((ae,se,ge)=>{d(oe=>({...oe,[ae]:{...oe[ae],[se]:ge}}))},[]),[A]=usePutV4ResellerByRouteResellerIdOpportunityAndManufacturerIdDefaultMutation(),I=React.useCallback(async ae=>{if(!(C!=null&&C.IsReseller))return;if(!ae.BidNumber){o({title:"Error",description:"Bid Number is missing, cannot set default.",variant:"destructive"});return}const se=ae.BidNumber;E(se,"isSettingDefault",!0),A({routeResellerId:t,manufacturerId:ae.ManufacturerId??"",opportunityNumber:se}).unwrap().then(()=>{o({title:"Success",description:`Opportunity "${ae.OpportunityName||ae.Opportunity||se}" was successfully set as default.`,variant:"success"})}).catch(ge=>{var oe;console.error("Set as default error:",ge),o({title:"Error",description:((oe=ge.data)==null?void 0:oe.message)||ge.message||"An error occurred while setting this opportunity as default.",variant:"destructive"})}).finally(()=>{E(se,"isSettingDefault",!1)})},[t,A,o,E]),[M]=usePostV4ResellerByRouteResellerIdOpportunityAndManufacturerIdBidNumberEmailMutation(),j=React.useCallback(ae=>{if(C!=null&&C.IsReseller){if(!ae.BidNumber){o({title:"Error",description:"Bid Number is missing, cannot prepare report.",variant:"destructive"});return}R(ae),_(""),g(!0)}},[o]),q=React.useCallback(async()=>{if(!(C!=null&&C.IsReseller))return;if(!S||!S.BidNumber){o({title:"Error",description:"No opportunity selected or Bid Number is missing.",variant:"destructive"});return}if(!b.trim()||!/\S+@\S+\.\S+/.test(b)){o({title:"Validation Error",description:"Please enter a valid email address.",variant:"destructive"});return}const ae=S.BidNumber;E(ae,"isSendingReport",!0),M({routeResellerId:t,manufacturerId:S.ManufacturerId??"",bidNumber:ae,emailAddress:b}).unwrap().then(()=>{o({title:"Success",description:`A report for "${S.OpportunityName||S.Opportunity||ae}" was successfully sent to ${b}.`,variant:"success"}),g(!1)}).catch(se=>{var ge;console.error("Send report by email error:",se),o({title:"Error",description:((ge=se.data)==null?void 0:ge.message)||se.message||"An error occurred while sending the report by email.",variant:"destructive"})}).finally(()=>{E(ae,"isSendingReport",!1),f||(R(null),_(""))})},[S,b,t,M,o,E,g]),z=React.useMemo(()=>[{accessorKey:"ManufacturerId",header:"Manuf.",cell:({row:ae})=>jsxRuntime.jsx("div",{className:"w-20 h-8",children:jsxRuntime.jsx(PartnerLogo,{id:ae.original.ManufacturerId,width:80,height:32})}),enableSorting:!0,enableFiltering:!0},{id:"opportunityDisplay",accessorFn:ae=>ae.OpportunityName||ae.Opportunity,header:"Opportunity",cell:({getValue:ae})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:ae()??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"BidNumber",header:"Bid Number",cell:({row:ae})=>ae.original.BidNumber??"N/A",enableSorting:!0,enableFiltering:!0},{id:"statusInfo",header:"Status",cell:({row:ae})=>{const se=ae.original,ge=se.Active===!0,oe=getEndDateStatus(se.EndDate);let Ae="border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400";return oe.variant==="destructive"?Ae="border-red-500 bg-red-100 text-red-700 dark:border-red-600 dark:bg-red-900/50 dark:text-red-400":oe.variant==="warning"&&(Ae="border-yellow-500 bg-yellow-100 text-yellow-700 dark:border-yellow-600 dark:bg-yellow-900/50 dark:text-yellow-400"),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 min-w-[200px]",children:[jsxRuntime.jsx(Badge,{variant:"outline",className:ge?"border-green-500 bg-green-100 text-green-700 dark:border-green-600 dark:bg-green-900/50 dark:text-green-400 font-medium":"border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400 font-medium",children:ge?"Active":"Inactive"}),se.EndDate&&jsxRuntime.jsx(Badge,{variant:"outline",className:`${Ae} font-medium`,children:oe.text}),jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"h-6 w-6 p-0 data-[state=delayed-open]:bg-accent data-[state=instant-open]:bg-accent",children:jsxRuntime.jsx(Info,{className:"h-4 w-4 text-muted-foreground"})})}),jsxRuntime.jsx(TooltipContent,{side:"top",align:"center",className:"bg-popover text-popover-foreground p-2 rounded shadow-lg",children:jsxRuntime.jsxs("div",{className:"text-sm space-y-1",children:[jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"Start:"})," ",formatDate(se.StartDate)]}),jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"End:"})," ",formatDate(se.EndDate)]}),jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"Updated:"})," ",formatDate(se.LastUpdate)]})]})})]})})]})},enableFiltering:!1},{id:"actions",header:"Actions",cell:({row:ae})=>{var $e,Fe;const se=ae.original;if(!se.BidNumber)return jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"Actions unavailable"});const ge=se.BidNumber,oe=($e=l[ge])==null?void 0:$e.isSettingDefault,Ae=(S==null?void 0:S.BidNumber)===ge&&((Fe=l[ge])==null?void 0:Fe.isSendingReport),Ne=oe||Ae,je=se.CanBeSetAsDefault===!0;return jsxRuntime.jsxs("div",{className:"flex space-x-2",children:[jsxRuntime.jsx("a",{href:`/${t}/Opportunity/${se.ManufacturerId}/${se.BidNumber}`,children:jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",className:"flex items-center",children:[jsxRuntime.jsx(Star,{className:"mr-2 h-4 w-4"})," View"]})}),(C==null?void 0:C.IsReseller)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",onClick:()=>I(se),disabled:Ne||!je,title:je?"Set as default":"This opportunity cannot be set as default",className:"flex items-center",children:[oe?jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):jsxRuntime.jsx(Star,{className:"mr-2 h-4 w-4"})," Set Default"]}),jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",onClick:()=>j(se),disabled:Ne,title:"Send report by email",className:"flex items-center",children:[Ae?jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):jsxRuntime.jsx(Send,{className:"mr-2 h-4 w-4"})," Send Report"]})]})]})}}],[l,I,j,S]),Q=React.useMemo(()=>{const ae={};if(e){const se=Array.from(new Set(e.map(oe=>oe.ManufacturerId).filter(oe=>oe!=null)));ae.ManufacturerId=se;const ge=Array.from(new Set(e.map(oe=>oe.OpportunityName||oe.Opportunity).filter(oe=>oe!=null)));ae.opportunityDisplay=ge}return ae},[e]),F=e||[],V=S!=null&&S.BidNumber?(te=l[S.BidNumber])==null?void 0:te.isSendingReport:!1;return n?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-48 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"})," ",jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"})," ",jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})," ",jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Opportunities"})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:z,data:F,uniqueValues:Q})})]}),jsxRuntime.jsx(Dialog,{open:f,onOpenChange:ae=>{g(ae),ae||(R(null),_(""))},children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Send Opportunity Report"}),jsxRuntime.jsxs(DialogDescription,{children:["Enter the email address to send the report for opportunity: ",jsxRuntime.jsx("br",{}),jsxRuntime.jsx("span",{className:"font-semibold",children:(S==null?void 0:S.OpportunityName)||(S==null?void 0:S.Opportunity)||"N/A"}),(S==null?void 0:S.BidNumber)&&jsxRuntime.jsxs("span",{className:"block text-sm text-muted-foreground",children:["Bid Number: ",S.BidNumber]})]})]}),jsxRuntime.jsx("div",{className:"grid gap-4 py-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",className:"text-right",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",type:"email",value:b,onChange:ae=>_(ae.target.value),placeholder:"recipient@example.com",className:"col-span-3",disabled:V})]})}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>g(!1),disabled:V,children:"Cancel"}),jsxRuntime.jsxs(Button,{type:"submit",onClick:q,disabled:V,children:[V&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"})," Send Report"]})]})]})})]})}function formatYYYYMMDDIntToDateString$1(t){if(t===null||typeof t>"u")return"N/A";const e=t.toString();return e.length===8?`${e.substring(0,4)}-${e.substring(4,6)}-${e.substring(6,8)}`:e}function formatCurrency(t){return t===null||typeof t>"u"?"N/A":t.toLocaleString(void 0,{style:"currency",currency:"CAD"})}function OrdersTable({orders:t=null,loading:e=!1,title:n="Order Details"}){const o=React.useMemo(()=>[{accessorKey:"DocumentNumber",header:"Document Number",cell:({row:f})=>f.original.DocumentNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentDate",header:"Document Date",cell:({row:f})=>formatYYYYMMDDIntToDateString$1(f.original.DocumentDate),enableSorting:!0,enableFiltering:!1},{accessorKey:"OrderNumber",header:"Order Number",cell:({row:f})=>f.original.OrderNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"PONumber",header:"PO Number",cell:({row:f})=>f.original.PONumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseCode",header:"Warehouse",cell:({row:f})=>f.original.WarehouseCode??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:f})=>f.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!1},{accessorKey:"ShipToName",header:"Name",cell:({row:f})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:f.original.ShipToName??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:f})=>formatCurrency(f.original.UnitPrice),enableSorting:!0,enableFiltering:!1}],[]),l=React.useMemo(()=>{const f={};if(t){const g=Array.from(new Set(t.map(C=>C.WarehouseCode).filter(C=>C!=null)));f.WarehouseCode=g;const b=Array.from(new Set(t.map(C=>C.ShipToName).filter(C=>C!=null)));f.ShipToName=b;const _=Array.from(new Set(t.map(C=>C.DocumentNumber).filter(C=>C!=null)));f.DocumentNumber=_;const S=Array.from(new Set(t.map(C=>C.OrderNumber).filter(C=>C!=null)));f.OrderNumber=S;const R=Array.from(new Set(t.map(C=>C.PONumber).filter(C=>C!=null)));f.PONumber=R}return f},[t]),d=t||[];return e?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:n})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:o,data:d,uniqueValues:l})})]})}function formatYYYYMMDDIntToDateString(t){if(t===null||typeof t>"u")return"N/A";const e=t.toString();return e.length===8?`${e.substring(0,4)}-${e.substring(4,6)}-${e.substring(6,8)}`:e}function ReceiptsTable({receipts:t=null,loading:e=!1,title:n="Latest Warehouse Receivings"}){const o=React.useMemo(()=>[{accessorKey:"Location",header:"Location",cell:({row:f})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:f.original.Location??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"ReceiptDate",header:"Date",cell:({row:f})=>formatYYYYMMDDIntToDateString(f.original.ReceiptDate),enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:f})=>f.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!0}],[]),l=React.useMemo(()=>{const f={};if(t){const g=Array.from(new Set(t.map(_=>_.Location).filter(_=>_!=null)));f.Location=g;const b=Array.from(new Set(t.map(_=>formatYYYYMMDDIntToDateString(_.ReceiptDate)).filter(_=>_!=="N/A"&&_!=="Invalid Date"))).sort((_,S)=>new Date(S).getTime()-new Date(_).getTime());f.ReceiptDate=b}return f},[t]),d=t||[];return e?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-56"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:n})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:o,data:d,uniqueValues:l})})]})}function ProductOverviewPage({applicationId:t,sku:e,productDefaultOpportunityNumber:n="",productOnAddToCart:o,productAddingToCart:l=!1,productShopifyHostname:d,productCustomAction:f=jsxRuntime.jsx(jsxRuntime.Fragment,{})}){const{data:g,isLoading:b}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:t,randmarSku:e,withSpecification:!1},{skip:!t||!e}),{data:_,isLoading:S}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:t,randmarSku:e,withSpecification:!0},{skip:!g}),R=(g==null?void 0:g.ManufacturerId)!==t;return console.log("readonly",R),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3",children:[jsxRuntime.jsx("div",{className:"lg:col-span-2",children:jsxRuntime.jsx(ProductCard,{applicationId:t,product:_||g,defaultOpportunityNumber:n,onAddToCart:o,addingToCart:l,shopifyHostname:d,customAction:f})}),jsxRuntime.jsxs(Card,{className:"flex flex-col",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsxs(CardTitle,{children:[jsxRuntime.jsx(Info,{className:"h-5 w-5 inline mr-2"})," Additionnal information"]})}),jsxRuntime.jsx(CardContent,{className:"basis-0 grow overflow-y-auto",children:b?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-1 w-full my-6"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full mt-2"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full mt-1"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex justify-between",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Cateory Name"}),jsxRuntime.jsx("span",{className:"font-medium",children:(g==null?void 0:g.ProductType)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Master Carton"}),jsxRuntime.jsx("span",{className:"font-medium",children:(g==null?void 0:g.MasterCarton)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Skid Quantity"}),jsxRuntime.jsx("span",{className:"font-medium",children:(g==null?void 0:g.SkidQuantity)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Automatic Reorder"}),jsxRuntime.jsx("span",{className:"font-medium",children:g!=null&&g.AutoUpdate?"Yes":"No"})]}),((g==null?void 0:g.VoiceoverCaption)||(g==null?void 0:g.BodyHTML))&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("hr",{className:"my-6"}),jsxRuntime.jsx("div",{className:"text-muted-foreground mb-2",children:"Description"}),jsxRuntime.jsxs("div",{className:"max-h-44 overflow-scroll",children:[(g==null?void 0:g.VoiceoverCaption)&&jsxRuntime.jsx("div",{children:g==null?void 0:g.VoiceoverCaption}),(g==null?void 0:g.BodyHTML)&&jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:(g==null?void 0:g.BodyHTML)??""}})]})]})]})})]})]}),jsxRuntime.jsx("div",{className:"my-4",children:b?jsxRuntime.jsx("div",{className:"mx-auto flex justify-center items-center h-32",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-primary"})}):jsxRuntime.jsxs(Tabs,{defaultValue:"stats",children:[jsxRuntime.jsxs(TabsList,{className:"inline-flex h-auto items-center justify-center rounded-none border-b bg-transparent p-0",children:[jsxRuntime.jsx(TabsTrigger,{value:"stats",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Statistics"}),jsxRuntime.jsx(TabsTrigger,{value:"opportunities",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Opportunities"}),jsxRuntime.jsx(TabsTrigger,{value:"orders",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Orders"}),jsxRuntime.jsx(TabsTrigger,{value:"warehouse",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Latest Warehouse Receiving"})]}),jsxRuntime.jsx(TabsContent,{value:"stats",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(SalesChart,{salesData:(_==null?void 0:_.SalesStatistics)??[],isLoading:S})})}),jsxRuntime.jsx(TabsContent,{value:"opportunities",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OpportunitiesTable,{applicationId:t,opportunities:g==null?void 0:g.Opportunities,loading:b})})}),jsxRuntime.jsxs(TabsContent,{value:"orders",children:[jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OrdersTable,{title:"Open Orders",orders:_==null?void 0:_.ActiveOrderDetails,loading:S})}),jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OrdersTable,{title:"Completed Orders",orders:_==null?void 0:_.CompletedOrderDetails,loading:S})})]}),jsxRuntime.jsx(TabsContent,{value:"warehouse",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ReceiptsTable,{receipts:_==null?void 0:_.Receipts,loading:S})})})]})})]})}exports.ActiveOrdersCard=ActiveOrdersCard,exports.AiGeneratedContent=AiGeneratedContent,exports.Alert=Alert,exports.AlertDescription=AlertDescription,exports.AlertDialog=AlertDialog,exports.AlertDialogAction=AlertDialogAction,exports.AlertDialogCancel=AlertDialogCancel,exports.AlertDialogContent=AlertDialogContent,exports.AlertDialogDescription=AlertDialogDescription,exports.AlertDialogFooter=AlertDialogFooter,exports.AlertDialogHeader=AlertDialogHeader,exports.AlertDialogTitle=AlertDialogTitle,exports.AlertDialogTrigger=AlertDialogTrigger,exports.AlertTitle=AlertTitle,exports.ApiKeyProvider=ApiKeyProvider,exports.AreaChart=AreaChart,exports.Avatar=Avatar,exports.AvatarFallback=AvatarFallback,exports.AvatarFooter=AvatarFooter,exports.AvatarImage=AvatarImage,exports.Badge=Badge,exports.Button=Button,exports.Card=Card,exports.CardContent=CardContent,exports.CardDescription=CardDescription,exports.CardFooter=CardFooter,exports.CardHeader=CardHeader,exports.CardTitle=CardTitle,exports.ChatLayout=ChatLayout,exports.ChatProvider=ChatProvider,exports.Checkbox=Checkbox,exports.Command=Command,exports.CommandDialog=CommandDialog,exports.CommandEmpty=CommandEmpty,exports.CommandGroup=CommandGroup,exports.CommandInput=CommandInput,exports.CommandItem=CommandItem,exports.CommandList=CommandList,exports.CommandSeparator=CommandSeparator,exports.CommandShortcut=CommandShortcut,exports.CountryFlag=CountryFlag,exports.DataTable=DataTable,exports.Dialog=Dialog,exports.DialogClose=DialogClose,exports.DialogContent=DialogContent,exports.DialogDescription=DialogDescription,exports.DialogFooter=DialogFooter,exports.DialogHeader=DialogHeader,exports.DialogOverlay=DialogOverlay,exports.DialogPortal=DialogPortal,exports.DialogTitle=DialogTitle,exports.DialogTrigger=DialogTrigger,exports.DropdownMenu=DropdownMenu,exports.DropdownMenuCheckboxItem=DropdownMenuCheckboxItem,exports.DropdownMenuContent=DropdownMenuContent,exports.DropdownMenuGroup=DropdownMenuGroup,exports.DropdownMenuItem=DropdownMenuItem,exports.DropdownMenuLabel=DropdownMenuLabel,exports.DropdownMenuPortal=DropdownMenuPortal,exports.DropdownMenuRadioGroup=DropdownMenuRadioGroup,exports.DropdownMenuRadioItem=DropdownMenuRadioItem,exports.DropdownMenuSeparator=DropdownMenuSeparator,exports.DropdownMenuShortcut=DropdownMenuShortcut,exports.DropdownMenuSub=DropdownMenuSub,exports.DropdownMenuSubContent=DropdownMenuSubContent,exports.DropdownMenuSubTrigger=DropdownMenuSubTrigger,exports.DropdownMenuTrigger=DropdownMenuTrigger,exports.ExploreManufacturers=ExploreManufacturers,exports.GeneralDocumentCard=GeneralDocumentCard,exports.Input=Input,exports.InputOTP=InputOTP,exports.InputOTPGroup=InputOTPGroup,exports.InputOTPSeparator=InputOTPSeparator,exports.InputOTPSlot=InputOTPSlot,exports.Label=Label$2,exports.Layout=Layout,exports.ManufacturerCard=ManufacturerCard,exports.ManufacturerGetStartedButton=ManufacturerGetStartedButton,exports.ManufacturerOverviewPage=ManufacturerOverviewPage,exports.ManufacturerReorderingCard=ManufacturerReorderingCard,exports.MultiSelect=MultiSelect,exports.Navbar=Navbar,exports.OpportunitiesTable=OpportunitiesTable,exports.PageHeader=PageHeader,exports.PartnerCard=PartnerCard,exports.PartnerRelationshipPage=PartnerRelationshipPage,exports.Popover=Popover,exports.PopoverAnchor=PopoverAnchor,exports.PopoverContent=PopoverContent,exports.PopoverTrigger=PopoverTrigger,exports.Preloader=Preloader,exports.ProductCard=ProductCard,exports.ProductImage=ProductImage,exports.ProductInventoryGrid=ProductInventoryGrid,exports.ProductOverviewPage=ProductOverviewPage,exports.Progress=Progress,exports.RadioGroup=RadioGroup$1,exports.RadioGroupItem=RadioGroupItem,exports.ResellerBillingOverviewCard=ResellerBillingOverviewCard,exports.ResellerCard=ResellerCard,exports.ResellerOverview=ResellerOverview,exports.ResellerQualificationsCard=ResellerQualificationsCard,exports.RichTextEditor=RichTextEditor,exports.SalesChart=SalesChart,exports.SalesOverviewCard=SalesOverviewCard,exports.ScrollArea=ScrollArea,exports.ScrollBar=ScrollBar,exports.Select=Select,exports.SelectContent=SelectContent,exports.SelectGroup=SelectGroup,exports.SelectItem=SelectItem,exports.SelectLabel=SelectLabel,exports.SelectScrollDownButton=SelectScrollDownButton,exports.SelectScrollUpButton=SelectScrollUpButton,exports.SelectTrigger=SelectTrigger,exports.SelectValue=SelectValue,exports.Separator=Separator$1,exports.Sheet=Sheet,exports.SheetClose=SheetClose,exports.SheetContent=SheetContent,exports.SheetDescription=SheetDescription,exports.SheetFooter=SheetFooter,exports.SheetHeader=SheetHeader,exports.SheetOverlay=SheetOverlay,exports.SheetPortal=SheetPortal,exports.SheetTitle=SheetTitle,exports.SheetTrigger=SheetTrigger,exports.Sidebar=Sidebar,exports.SidebarContent=SidebarContent,exports.SidebarFooter=SidebarFooter,exports.SidebarGroup=SidebarGroup,exports.SidebarGroupAction=SidebarGroupAction,exports.SidebarGroupContent=SidebarGroupContent,exports.SidebarGroupLabel=SidebarGroupLabel,exports.SidebarHeader=SidebarHeader,exports.SidebarInput=SidebarInput,exports.SidebarInset=SidebarInset,exports.SidebarMenu=SidebarMenu,exports.SidebarMenuAction=SidebarMenuAction,exports.SidebarMenuBadge=SidebarMenuBadge,exports.SidebarMenuButton=SidebarMenuButton,exports.SidebarMenuItem=SidebarMenuItem,exports.SidebarMenuSkeleton=SidebarMenuSkeleton,exports.SidebarMenuSub=SidebarMenuSub,exports.SidebarMenuSubButton=SidebarMenuSubButton,exports.SidebarMenuSubItem=SidebarMenuSubItem,exports.SidebarProvider=SidebarProvider,exports.SidebarRail=SidebarRail,exports.SidebarSeparator=SidebarSeparator,exports.SidebarTrigger=SidebarTrigger,exports.Skeleton=Skeleton,exports.Switch=Switch,exports.Table=Table,exports.TableBody=TableBody,exports.TableCaption=TableCaption,exports.TableCell=TableCell,exports.TableFooter=TableFooter,exports.TableHead=TableHead,exports.TableHeader=TableHeader,exports.TableRow=TableRow,exports.Tabs=Tabs,exports.TabsContent=TabsContent,exports.TabsList=TabsList,exports.TabsTrigger=TabsTrigger,exports.Textarea=Textarea,exports.Toast=Toast,exports.ToastAction=ToastAction,exports.ToastClose=ToastClose,exports.ToastDescription=ToastDescription,exports.ToastProvider=ToastProvider,exports.ToastTitle=ToastTitle,exports.ToastViewport=ToastViewport,exports.Toaster=Toaster,exports.Tooltip=Tooltip$1,exports.TooltipContent=TooltipContent,exports.TooltipProvider=TooltipProvider,exports.TooltipTrigger=TooltipTrigger,exports.Topbar=Topbar,exports.badgeVariants=badgeVariants,exports.buttonVariants=buttonVariants,exports.toast=toast,exports.useApiKey=useApiKey,exports.useChat=useChat,exports.useIsMobile=useIsMobile,exports.useSidebar=useSidebar,exports.useToast=useToast,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
1274
+ `;function RichTextEditor({id:t,name:e,value:n,onChange:o,placeholder:l,className:d,...f}){const[g,b]=React.useState(!1),_=React.useRef(null),S=React.useRef(null),R=useEditor({extensions:[StarterKit,Underline],content:n,editorProps:{attributes:{class:"prose prose-sm sm:prose dark:prose-invert focus:outline-none",id:t??"",name:e??""}},onUpdate:({editor:j})=>{const q=j.getHTML();o({target:{id:t,name:e,value:q}})}});React.useEffect(()=>{R&&n!==R.getHTML()&&R.commands.setContent(n)},[n,R]);const C=React.useCallback(j=>{if(R)if(R.chain().focus(),j==="paragraph")R.chain().setParagraph().run();else{const q=Number.parseInt(j.slice(1));R.chain().setHeading({level:q}).run()}},[R]),E=React.useCallback(j=>{if(R)switch(R.chain().focus(),j){case"bold":R.chain().toggleBold().run();break;case"italic":R.chain().toggleItalic().run();break;case"underline":R.chain().toggleUnderline().run();break;case"strike":R.chain().toggleStrike().run();break;case"bulletList":R.chain().toggleBulletList().run();break;case"orderedList":R.chain().toggleOrderedList().run();break}},[R]),A=React.useCallback(()=>{b(j=>!j)},[]),I=React.useCallback(j=>{const q=j.target.value;R&&R.commands.setContent(q),o({target:{id:t,name:e,value:q}})},[o,R,t,e]),M=React.useCallback(()=>{!g&&R&&R.commands.focus()},[g,R]);return R?jsxRuntime.jsxs("div",{ref:S,className:cn("border border-input rounded-md overflow-hidden focus-within:outline-hidden focus-within:ring-1 focus-within:ring-ring",d),onClick:M,...f,children:[jsxRuntime.jsx("style",{children:editorStyles}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center p-2 border-b border-input gap-2 bg-background",children:[jsxRuntime.jsxs(Select,{onValueChange:C,disabled:g,children:[jsxRuntime.jsx(SelectTrigger,{className:"w-[160px]",children:jsxRuntime.jsx(SelectValue,{placeholder:"Format"})}),jsxRuntime.jsx(SelectContent,{children:formatOptions.map(j=>jsxRuntime.jsx(SelectItem,{value:j.value,children:j.label},j.value))})]}),["bold","italic","underline","strike","bulletList","orderedList"].map(j=>jsxRuntime.jsxs(Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>E(j),className:R.isActive(j)?"bg-muted":"",disabled:g,children:[j==="bold"&&jsxRuntime.jsx(Bold$1,{className:"h-4 w-4"}),j==="italic"&&jsxRuntime.jsx(Italic$1,{className:"h-4 w-4"}),j==="underline"&&jsxRuntime.jsx(Underline$1,{className:"h-4 w-4"}),j==="strike"&&jsxRuntime.jsx(Strikethrough,{className:"h-4 w-4"}),j==="bulletList"&&jsxRuntime.jsx(List$1,{className:"h-4 w-4"}),j==="orderedList"&&jsxRuntime.jsx(ListOrdered,{className:"h-4 w-4"})]},j)),jsxRuntime.jsx(Button,{type:"button",variant:"ghost",size:"sm",onClick:A,className:g?"bg-muted":"",children:jsxRuntime.jsx(Code$1,{className:"h-4 w-4"})})]}),jsxRuntime.jsx("div",{className:"p-3",children:g?jsxRuntime.jsx(Textarea,{ref:_,id:t,name:e,value:R.getHTML(),onChange:I,className:cn("min-h-[150px] font-mono text-sm resize-none border-0 focus-visible:ring-0 focus-visible:ring-offset-0",d),placeholder:l}):jsxRuntime.jsx(EditorContent,{editor:R})})]}):null}function SalesChart({salesData:t,chartHeight:e=300,units:n="$",unitsPosition:o="left",className:l,isLoading:d=!1}){const[f,g]=React.useState([]),[b,_]=React.useState(!0),S=!d&&!!t&&t.length>0;return React.useEffect(()=>{if(d||!t||t.length===0){g([]);return}const R=t.reduce((Q,F)=>{const V=F.Day??0,te=Math.floor(V).toString();if(te.length!==8||isNaN(Number.parseInt(te)))return console.warn(`Skipping invalid Day format: ${F.Day}`),Q;const ae=te.substring(0,4),se=te.substring(4,6),ge=`${ae}-${se}`;return Q[ge]=(Q[ge]||0)+(F.ExtendedPrice??0),Q},{}),C=Object.keys(R).sort(),E=new Date,A=E.getFullYear(),I=E.getMonth(),M=E.getDate(),j=`${A}-${(I+1).toString().padStart(2,"0")}`,q={...R};if(b&&C.length>0&&C[C.length-1]===j){const Q=q[j],F=new Date(A,I+1,0).getDate();if(M<F&&M>0){const te=Q/M*F;q[j]=te}}const z=C.map(Q=>{const F=q[Q],[V,te]=Q.split("-").map(Number);return{month:new Date(V,te-1).toLocaleString("default",{month:"short",year:"numeric"}),sales:F}});g(z)},[t,b,d]),d?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-24"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx("div",{style:{height:e},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 my-1 pt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-10"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-20"})]}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-3/4 mt-1"})]})]}):f.length===0?jsxRuntime.jsx("div",{style:{height:e},className:l||"p-4 text-center text-muted-foreground flex items-center justify-center",children:"No monthly sales data to display."}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Sales"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx(AreaChart,{data:f,units:n,unitsPosition:o,height:e,className:l}),S&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 my-1 pt-2",children:[jsxRuntime.jsx(Switch,{checked:b,onCheckedChange:_,id:"extrapolate-switch","aria-label":"Toggle sales extrapolation"}),jsxRuntime.jsx(Label$2,{htmlFor:"extrapolate-switch",children:"Extrapolate"})]}),b&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"* Sales for the current month are projected, not actual."})]})]})]})}function getEndDateStatus(t){if(!t)return{text:"No End Date",variant:"neutral",daysRemaining:null};const e=new Date(t);if(isNaN(e.getTime()))return{text:"Invalid Date",variant:"neutral",daysRemaining:null};const n=new Date,o=new Date(e.getFullYear(),e.getMonth(),e.getDate()),l=new Date(n.getFullYear(),n.getMonth(),n.getDate()),d=o.getTime()-l.getTime(),f=Math.ceil(d/(1e3*60*60*24));return f<0?{text:`Ended ${Math.abs(f)}d ago`,variant:"destructive",daysRemaining:f}:f===0?{text:"Ends today",variant:"destructive",daysRemaining:f}:f<=7?{text:`Ends in ${f}d`,variant:"destructive",daysRemaining:f}:f<=30?{text:`Ends in ${f}d`,variant:"warning",daysRemaining:f}:{text:`Ends in ${f}d`,variant:"neutral",daysRemaining:f}}const formatDate=t=>{if(!t)return"N/A";try{const e=new Date(t);return isNaN(e.getTime())?"Invalid Date":e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return"Invalid Date"}};function OpportunitiesTable({applicationId:t,opportunities:e=null,loading:n=!1}){var te;const{toast:o}=useToast(),[l,d]=React.useState({}),[f,g]=React.useState(!1),[b,_]=React.useState(""),[S,R]=React.useState(null),{data:C}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:t},{skip:!t}),E=React.useCallback((ae,se,ge)=>{d(oe=>({...oe,[ae]:{...oe[ae],[se]:ge}}))},[]),[A]=usePutV4ResellerByRouteResellerIdOpportunityAndManufacturerIdDefaultMutation(),I=React.useCallback(async ae=>{if(!(C!=null&&C.IsReseller))return;if(!ae.BidNumber){o({title:"Error",description:"Bid Number is missing, cannot set default.",variant:"destructive"});return}const se=ae.BidNumber;E(se,"isSettingDefault",!0),A({routeResellerId:t,manufacturerId:ae.ManufacturerId??"",opportunityNumber:se}).unwrap().then(()=>{o({title:"Success",description:`Opportunity "${ae.OpportunityName||ae.Opportunity||se}" was successfully set as default.`,variant:"success"})}).catch(ge=>{var oe;console.error("Set as default error:",ge),o({title:"Error",description:((oe=ge.data)==null?void 0:oe.message)||ge.message||"An error occurred while setting this opportunity as default.",variant:"destructive"})}).finally(()=>{E(se,"isSettingDefault",!1)})},[t,A,o,E]),[M]=usePostV4ResellerByRouteResellerIdOpportunityAndManufacturerIdBidNumberEmailMutation(),j=React.useCallback(ae=>{if(C!=null&&C.IsReseller){if(!ae.BidNumber){o({title:"Error",description:"Bid Number is missing, cannot prepare report.",variant:"destructive"});return}R(ae),_(""),g(!0)}},[o]),q=React.useCallback(async()=>{if(!(C!=null&&C.IsReseller))return;if(!S||!S.BidNumber){o({title:"Error",description:"No opportunity selected or Bid Number is missing.",variant:"destructive"});return}if(!b.trim()||!/\S+@\S+\.\S+/.test(b)){o({title:"Validation Error",description:"Please enter a valid email address.",variant:"destructive"});return}const ae=S.BidNumber;E(ae,"isSendingReport",!0),M({routeResellerId:t,manufacturerId:S.ManufacturerId??"",bidNumber:ae,emailAddress:b}).unwrap().then(()=>{o({title:"Success",description:`A report for "${S.OpportunityName||S.Opportunity||ae}" was successfully sent to ${b}.`,variant:"success"}),g(!1)}).catch(se=>{var ge;console.error("Send report by email error:",se),o({title:"Error",description:((ge=se.data)==null?void 0:ge.message)||se.message||"An error occurred while sending the report by email.",variant:"destructive"})}).finally(()=>{E(ae,"isSendingReport",!1),f||(R(null),_(""))})},[S,b,t,M,o,E,g]),z=React.useMemo(()=>[{accessorKey:"ManufacturerId",header:"Manuf.",cell:({row:ae})=>jsxRuntime.jsx("div",{className:"w-20 h-8",children:jsxRuntime.jsx(PartnerLogo,{id:ae.original.ManufacturerId,width:80,height:32})}),enableSorting:!0,enableFiltering:!0},{id:"opportunityDisplay",accessorFn:ae=>ae.OpportunityName||ae.Opportunity,header:"Opportunity",cell:({getValue:ae})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:ae()??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"BidNumber",header:"Bid Number",cell:({row:ae})=>ae.original.BidNumber??"N/A",enableSorting:!0,enableFiltering:!0},{id:"statusInfo",header:"Status",cell:({row:ae})=>{const se=ae.original,ge=se.Active===!0,oe=getEndDateStatus(se.EndDate);let Ae="border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400";return oe.variant==="destructive"?Ae="border-red-500 bg-red-100 text-red-700 dark:border-red-600 dark:bg-red-900/50 dark:text-red-400":oe.variant==="warning"&&(Ae="border-yellow-500 bg-yellow-100 text-yellow-700 dark:border-yellow-600 dark:bg-yellow-900/50 dark:text-yellow-400"),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 min-w-[200px]",children:[jsxRuntime.jsx(Badge,{variant:"outline",className:ge?"border-green-500 bg-green-100 text-green-700 dark:border-green-600 dark:bg-green-900/50 dark:text-green-400 font-medium":"border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-600 dark:bg-gray-800/50 dark:text-gray-400 font-medium",children:ge?"Active":"Inactive"}),se.EndDate&&jsxRuntime.jsx(Badge,{variant:"outline",className:`${Ae} font-medium`,children:oe.text}),jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"h-6 w-6 p-0 data-[state=delayed-open]:bg-accent data-[state=instant-open]:bg-accent",children:jsxRuntime.jsx(Info,{className:"h-4 w-4 text-muted-foreground"})})}),jsxRuntime.jsx(TooltipContent,{side:"top",align:"center",className:"bg-popover text-popover-foreground p-2 rounded shadow-lg",children:jsxRuntime.jsxs("div",{className:"text-sm space-y-1",children:[jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"Start:"})," ",formatDate(se.StartDate)]}),jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"End:"})," ",formatDate(se.EndDate)]}),jsxRuntime.jsxs("p",{children:[jsxRuntime.jsx("strong",{children:"Updated:"})," ",formatDate(se.LastUpdate)]})]})})]})})]})},enableFiltering:!1},{id:"actions",header:"Actions",cell:({row:ae})=>{var $e,Fe;const se=ae.original;if(!se.BidNumber)return jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"Actions unavailable"});const ge=se.BidNumber,oe=($e=l[ge])==null?void 0:$e.isSettingDefault,Ae=(S==null?void 0:S.BidNumber)===ge&&((Fe=l[ge])==null?void 0:Fe.isSendingReport),Ne=oe||Ae,je=se.CanBeSetAsDefault===!0;return jsxRuntime.jsxs("div",{className:"flex space-x-2",children:[jsxRuntime.jsx("a",{href:`/${t}/Opportunity/${se.ManufacturerId}/${se.BidNumber}`,children:jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",className:"flex items-center",children:[jsxRuntime.jsx(Star,{className:"mr-2 h-4 w-4"})," View"]})}),(C==null?void 0:C.IsReseller)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",onClick:()=>I(se),disabled:Ne||!je,title:je?"Set as default":"This opportunity cannot be set as default",className:"flex items-center",children:[oe?jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):jsxRuntime.jsx(Star,{className:"mr-2 h-4 w-4"})," Set Default"]}),jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",onClick:()=>j(se),disabled:Ne,title:"Send report by email",className:"flex items-center",children:[Ae?jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):jsxRuntime.jsx(Send,{className:"mr-2 h-4 w-4"})," Send Report"]})]})]})}}],[l,I,j,S]),Q=React.useMemo(()=>{const ae={};if(e){const se=Array.from(new Set(e.map(oe=>oe.ManufacturerId).filter(oe=>oe!=null)));ae.ManufacturerId=se;const ge=Array.from(new Set(e.map(oe=>oe.OpportunityName||oe.Opportunity).filter(oe=>oe!=null)));ae.opportunityDisplay=ge}return ae},[e]),F=e||[],V=S!=null&&S.BidNumber?(te=l[S.BidNumber])==null?void 0:te.isSendingReport:!1;return n?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-48 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"})," ",jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"})," ",jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})," ",jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Opportunities"})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:z,data:F,uniqueValues:Q})})]}),jsxRuntime.jsx(Dialog,{open:f,onOpenChange:ae=>{g(ae),ae||(R(null),_(""))},children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Send Opportunity Report"}),jsxRuntime.jsxs(DialogDescription,{children:["Enter the email address to send the report for opportunity: ",jsxRuntime.jsx("br",{}),jsxRuntime.jsx("span",{className:"font-semibold",children:(S==null?void 0:S.OpportunityName)||(S==null?void 0:S.Opportunity)||"N/A"}),(S==null?void 0:S.BidNumber)&&jsxRuntime.jsxs("span",{className:"block text-sm text-muted-foreground",children:["Bid Number: ",S.BidNumber]})]})]}),jsxRuntime.jsx("div",{className:"grid gap-4 py-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",className:"text-right",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",type:"email",value:b,onChange:ae=>_(ae.target.value),placeholder:"recipient@example.com",className:"col-span-3",disabled:V})]})}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>g(!1),disabled:V,children:"Cancel"}),jsxRuntime.jsxs(Button,{type:"submit",onClick:q,disabled:V,children:[V&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"})," Send Report"]})]})]})})]})}function formatYYYYMMDDIntToDateString$1(t){if(t===null||typeof t>"u")return"N/A";const e=t.toString();return e.length===8?`${e.substring(0,4)}-${e.substring(4,6)}-${e.substring(6,8)}`:e}function formatCurrency(t){return t===null||typeof t>"u"?"N/A":t.toLocaleString(void 0,{style:"currency",currency:"CAD"})}function OrdersTable({orders:t=null,loading:e=!1,title:n="Order Details"}){const o=React.useMemo(()=>[{accessorKey:"DocumentNumber",header:"Document Number",cell:({row:f})=>f.original.DocumentNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentDate",header:"Document Date",cell:({row:f})=>formatYYYYMMDDIntToDateString$1(f.original.DocumentDate),enableSorting:!0,enableFiltering:!1},{accessorKey:"OrderNumber",header:"Order Number",cell:({row:f})=>f.original.OrderNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"PONumber",header:"PO Number",cell:({row:f})=>f.original.PONumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseCode",header:"Warehouse",cell:({row:f})=>f.original.WarehouseCode??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:f})=>f.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!1},{accessorKey:"ShipToName",header:"Name",cell:({row:f})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:f.original.ShipToName??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:f})=>formatCurrency(f.original.UnitPrice),enableSorting:!0,enableFiltering:!1}],[]),l=React.useMemo(()=>{const f={};if(t){const g=Array.from(new Set(t.map(C=>C.WarehouseCode).filter(C=>C!=null)));f.WarehouseCode=g;const b=Array.from(new Set(t.map(C=>C.ShipToName).filter(C=>C!=null)));f.ShipToName=b;const _=Array.from(new Set(t.map(C=>C.DocumentNumber).filter(C=>C!=null)));f.DocumentNumber=_;const S=Array.from(new Set(t.map(C=>C.OrderNumber).filter(C=>C!=null)));f.OrderNumber=S;const R=Array.from(new Set(t.map(C=>C.PONumber).filter(C=>C!=null)));f.PONumber=R}return f},[t]),d=t||[];return e?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:n})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:o,data:d,uniqueValues:l})})]})}function formatYYYYMMDDIntToDateString(t){if(t===null||typeof t>"u")return"N/A";const e=t.toString();return e.length===8?`${e.substring(0,4)}-${e.substring(4,6)}-${e.substring(6,8)}`:e}function ReceiptsTable({receipts:t=null,loading:e=!1,title:n="Latest Warehouse Receivings"}){const o=React.useMemo(()=>[{accessorKey:"Location",header:"Location",cell:({row:f})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:f.original.Location??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"ReceiptDate",header:"Date",cell:({row:f})=>formatYYYYMMDDIntToDateString(f.original.ReceiptDate),enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:f})=>f.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!0}],[]),l=React.useMemo(()=>{const f={};if(t){const g=Array.from(new Set(t.map(_=>_.Location).filter(_=>_!=null)));f.Location=g;const b=Array.from(new Set(t.map(_=>formatYYYYMMDDIntToDateString(_.ReceiptDate)).filter(_=>_!=="N/A"&&_!=="Invalid Date"))).sort((_,S)=>new Date(S).getTime()-new Date(_).getTime());f.ReceiptDate=b}return f},[t]),d=t||[];return e?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-56"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:n})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:o,data:d,uniqueValues:l})})]})}function ProductOverviewPage({applicationId:t,sku:e,productDefaultOpportunityNumber:n="",productOnAddToCart:o,productAddingToCart:l=!1,productShopifyHostname:d,productCustomAction:f=jsxRuntime.jsx(jsxRuntime.Fragment,{})}){const{data:g,isLoading:b}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:t,randmarSku:e,withSpecification:!1},{skip:!t||!e}),{data:_,isLoading:S}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:t,randmarSku:e,withSpecification:!0},{skip:!g}),R=(g==null?void 0:g.ManufacturerId)!==t;return console.log("readonly",R),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3",children:[jsxRuntime.jsx("div",{className:"lg:col-span-2",children:jsxRuntime.jsx(ProductCard,{applicationId:t,product:_||g,defaultOpportunityNumber:n,onAddToCart:o,addingToCart:l,shopifyHostname:d,customAction:f})}),jsxRuntime.jsxs(Card,{className:"flex flex-col",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsxs(CardTitle,{children:[jsxRuntime.jsx(Info,{className:"h-5 w-5 inline mr-2"})," Additionnal information"]})}),jsxRuntime.jsx(CardContent,{className:"basis-0 grow overflow-y-auto",children:b?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-1 w-full my-6"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full mt-2"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full mt-1"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex justify-between",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Cateory Name"}),jsxRuntime.jsx("span",{className:"font-medium",children:(g==null?void 0:g.ProductType)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Master Carton"}),jsxRuntime.jsx("span",{className:"font-medium",children:(g==null?void 0:g.MasterCarton)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Skid Quantity"}),jsxRuntime.jsx("span",{className:"font-medium",children:(g==null?void 0:g.SkidQuantity)||"N/A"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between mt-2",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Automatic Reorder"}),jsxRuntime.jsx("span",{className:"font-medium",children:g!=null&&g.AutoUpdate?"Yes":"No"})]}),((g==null?void 0:g.VoiceoverCaption)||(g==null?void 0:g.BodyHTML))&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("hr",{className:"my-6"}),jsxRuntime.jsx("div",{className:"text-muted-foreground mb-2",children:"Description"}),(g==null?void 0:g.VoiceoverCaption)&&jsxRuntime.jsx("div",{children:g==null?void 0:g.VoiceoverCaption}),(g==null?void 0:g.BodyHTML)&&jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:(g==null?void 0:g.BodyHTML)??""}})]})]})})]})]}),jsxRuntime.jsx("div",{className:"my-4",children:b?jsxRuntime.jsx("div",{className:"mx-auto flex justify-center items-center h-32",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-primary"})}):jsxRuntime.jsxs(Tabs,{defaultValue:"stats",children:[jsxRuntime.jsxs(TabsList,{className:"inline-flex h-auto items-center justify-center rounded-none border-b bg-transparent p-0",children:[jsxRuntime.jsx(TabsTrigger,{value:"stats",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Statistics"}),jsxRuntime.jsx(TabsTrigger,{value:"opportunities",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Opportunities"}),jsxRuntime.jsx(TabsTrigger,{value:"orders",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Orders"}),jsxRuntime.jsx(TabsTrigger,{value:"warehouse",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Latest Warehouse Receiving"})]}),jsxRuntime.jsx(TabsContent,{value:"stats",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(SalesChart,{salesData:(_==null?void 0:_.SalesStatistics)??[],isLoading:S})})}),jsxRuntime.jsx(TabsContent,{value:"opportunities",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OpportunitiesTable,{applicationId:t,opportunities:g==null?void 0:g.Opportunities,loading:b})})}),jsxRuntime.jsxs(TabsContent,{value:"orders",children:[jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OrdersTable,{title:"Open Orders",orders:_==null?void 0:_.ActiveOrderDetails,loading:S})}),jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(OrdersTable,{title:"Completed Orders",orders:_==null?void 0:_.CompletedOrderDetails,loading:S})})]}),jsxRuntime.jsx(TabsContent,{value:"warehouse",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ReceiptsTable,{receipts:_==null?void 0:_.Receipts,loading:S})})})]})})]})}exports.ActiveOrdersCard=ActiveOrdersCard,exports.AiGeneratedContent=AiGeneratedContent,exports.Alert=Alert,exports.AlertDescription=AlertDescription,exports.AlertDialog=AlertDialog,exports.AlertDialogAction=AlertDialogAction,exports.AlertDialogCancel=AlertDialogCancel,exports.AlertDialogContent=AlertDialogContent,exports.AlertDialogDescription=AlertDialogDescription,exports.AlertDialogFooter=AlertDialogFooter,exports.AlertDialogHeader=AlertDialogHeader,exports.AlertDialogTitle=AlertDialogTitle,exports.AlertDialogTrigger=AlertDialogTrigger,exports.AlertTitle=AlertTitle,exports.ApiKeyProvider=ApiKeyProvider,exports.AreaChart=AreaChart,exports.Avatar=Avatar,exports.AvatarFallback=AvatarFallback,exports.AvatarFooter=AvatarFooter,exports.AvatarImage=AvatarImage,exports.Badge=Badge,exports.Button=Button,exports.Card=Card,exports.CardContent=CardContent,exports.CardDescription=CardDescription,exports.CardFooter=CardFooter,exports.CardHeader=CardHeader,exports.CardTitle=CardTitle,exports.ChatLayout=ChatLayout,exports.ChatProvider=ChatProvider,exports.Checkbox=Checkbox,exports.Command=Command,exports.CommandDialog=CommandDialog,exports.CommandEmpty=CommandEmpty,exports.CommandGroup=CommandGroup,exports.CommandInput=CommandInput,exports.CommandItem=CommandItem,exports.CommandList=CommandList,exports.CommandSeparator=CommandSeparator,exports.CommandShortcut=CommandShortcut,exports.CountryFlag=CountryFlag,exports.DataTable=DataTable,exports.Dialog=Dialog,exports.DialogClose=DialogClose,exports.DialogContent=DialogContent,exports.DialogDescription=DialogDescription,exports.DialogFooter=DialogFooter,exports.DialogHeader=DialogHeader,exports.DialogOverlay=DialogOverlay,exports.DialogPortal=DialogPortal,exports.DialogTitle=DialogTitle,exports.DialogTrigger=DialogTrigger,exports.DropdownMenu=DropdownMenu,exports.DropdownMenuCheckboxItem=DropdownMenuCheckboxItem,exports.DropdownMenuContent=DropdownMenuContent,exports.DropdownMenuGroup=DropdownMenuGroup,exports.DropdownMenuItem=DropdownMenuItem,exports.DropdownMenuLabel=DropdownMenuLabel,exports.DropdownMenuPortal=DropdownMenuPortal,exports.DropdownMenuRadioGroup=DropdownMenuRadioGroup,exports.DropdownMenuRadioItem=DropdownMenuRadioItem,exports.DropdownMenuSeparator=DropdownMenuSeparator,exports.DropdownMenuShortcut=DropdownMenuShortcut,exports.DropdownMenuSub=DropdownMenuSub,exports.DropdownMenuSubContent=DropdownMenuSubContent,exports.DropdownMenuSubTrigger=DropdownMenuSubTrigger,exports.DropdownMenuTrigger=DropdownMenuTrigger,exports.ExploreManufacturers=ExploreManufacturers,exports.GeneralDocumentCard=GeneralDocumentCard,exports.Input=Input,exports.InputOTP=InputOTP,exports.InputOTPGroup=InputOTPGroup,exports.InputOTPSeparator=InputOTPSeparator,exports.InputOTPSlot=InputOTPSlot,exports.Label=Label$2,exports.Layout=Layout,exports.ManufacturerCard=ManufacturerCard,exports.ManufacturerGetStartedButton=ManufacturerGetStartedButton,exports.ManufacturerOverviewPage=ManufacturerOverviewPage,exports.ManufacturerReorderingCard=ManufacturerReorderingCard,exports.MultiSelect=MultiSelect,exports.Navbar=Navbar,exports.OpportunitiesTable=OpportunitiesTable,exports.PageHeader=PageHeader,exports.PartnerCard=PartnerCard,exports.PartnerRelationshipPage=PartnerRelationshipPage,exports.Popover=Popover,exports.PopoverAnchor=PopoverAnchor,exports.PopoverContent=PopoverContent,exports.PopoverTrigger=PopoverTrigger,exports.Preloader=Preloader,exports.ProductCard=ProductCard,exports.ProductImage=ProductImage,exports.ProductInventoryGrid=ProductInventoryGrid,exports.ProductOverviewPage=ProductOverviewPage,exports.Progress=Progress,exports.RadioGroup=RadioGroup$1,exports.RadioGroupItem=RadioGroupItem,exports.ResellerBillingOverviewCard=ResellerBillingOverviewCard,exports.ResellerCard=ResellerCard,exports.ResellerOverview=ResellerOverview,exports.ResellerQualificationsCard=ResellerQualificationsCard,exports.RichTextEditor=RichTextEditor,exports.SalesChart=SalesChart,exports.SalesOverviewCard=SalesOverviewCard,exports.ScrollArea=ScrollArea,exports.ScrollBar=ScrollBar,exports.Select=Select,exports.SelectContent=SelectContent,exports.SelectGroup=SelectGroup,exports.SelectItem=SelectItem,exports.SelectLabel=SelectLabel,exports.SelectScrollDownButton=SelectScrollDownButton,exports.SelectScrollUpButton=SelectScrollUpButton,exports.SelectTrigger=SelectTrigger,exports.SelectValue=SelectValue,exports.Separator=Separator$1,exports.Sheet=Sheet,exports.SheetClose=SheetClose,exports.SheetContent=SheetContent,exports.SheetDescription=SheetDescription,exports.SheetFooter=SheetFooter,exports.SheetHeader=SheetHeader,exports.SheetOverlay=SheetOverlay,exports.SheetPortal=SheetPortal,exports.SheetTitle=SheetTitle,exports.SheetTrigger=SheetTrigger,exports.Sidebar=Sidebar,exports.SidebarContent=SidebarContent,exports.SidebarFooter=SidebarFooter,exports.SidebarGroup=SidebarGroup,exports.SidebarGroupAction=SidebarGroupAction,exports.SidebarGroupContent=SidebarGroupContent,exports.SidebarGroupLabel=SidebarGroupLabel,exports.SidebarHeader=SidebarHeader,exports.SidebarInput=SidebarInput,exports.SidebarInset=SidebarInset,exports.SidebarMenu=SidebarMenu,exports.SidebarMenuAction=SidebarMenuAction,exports.SidebarMenuBadge=SidebarMenuBadge,exports.SidebarMenuButton=SidebarMenuButton,exports.SidebarMenuItem=SidebarMenuItem,exports.SidebarMenuSkeleton=SidebarMenuSkeleton,exports.SidebarMenuSub=SidebarMenuSub,exports.SidebarMenuSubButton=SidebarMenuSubButton,exports.SidebarMenuSubItem=SidebarMenuSubItem,exports.SidebarProvider=SidebarProvider,exports.SidebarRail=SidebarRail,exports.SidebarSeparator=SidebarSeparator,exports.SidebarTrigger=SidebarTrigger,exports.Skeleton=Skeleton,exports.Switch=Switch,exports.Table=Table,exports.TableBody=TableBody,exports.TableCaption=TableCaption,exports.TableCell=TableCell,exports.TableFooter=TableFooter,exports.TableHead=TableHead,exports.TableHeader=TableHeader,exports.TableRow=TableRow,exports.Tabs=Tabs,exports.TabsContent=TabsContent,exports.TabsList=TabsList,exports.TabsTrigger=TabsTrigger,exports.Textarea=Textarea,exports.Toast=Toast,exports.ToastAction=ToastAction,exports.ToastClose=ToastClose,exports.ToastDescription=ToastDescription,exports.ToastProvider=ToastProvider,exports.ToastTitle=ToastTitle,exports.ToastViewport=ToastViewport,exports.Toaster=Toaster,exports.Tooltip=Tooltip$1,exports.TooltipContent=TooltipContent,exports.TooltipProvider=TooltipProvider,exports.TooltipTrigger=TooltipTrigger,exports.Topbar=Topbar,exports.badgeVariants=badgeVariants,exports.buttonVariants=buttonVariants,exports.toast=toast,exports.useApiKey=useApiKey,exports.useChat=useChat,exports.useIsMobile=useIsMobile,exports.useSidebar=useSidebar,exports.useToast=useToast,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "randmarcomps",
3
3
  "private": false,
4
- "version": "1.252.0",
4
+ "version": "1.254.0",
5
5
  "description": "The UI library enabling speed and consistency in Randmar frontends.",
6
6
  "type": "module",
7
7
  "files": [