randmarcomps 1.591.0 → 1.592.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/randmarcomps.js +13 -1
- package/dist/randmarcomps.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/randmarcomps.js
CHANGED
|
@@ -63116,7 +63116,7 @@ function ProductCard({
|
|
|
63116
63116
|
]
|
|
63117
63117
|
}
|
|
63118
63118
|
),
|
|
63119
|
-
t.ManufacturerCategory !== void 0 && /* @__PURE__ */ jsxs(
|
|
63119
|
+
t.ManufacturerCategory !== void 0 && t.ManufacturerCategory?.QualificationRequired && /* @__PURE__ */ jsxs(
|
|
63120
63120
|
Badge,
|
|
63121
63121
|
{
|
|
63122
63122
|
variant: t.ManufacturerCategory?.QualificationRequired ? "info" : "secondary",
|
|
@@ -63128,6 +63128,18 @@ function ProductCard({
|
|
|
63128
63128
|
]
|
|
63129
63129
|
}
|
|
63130
63130
|
),
|
|
63131
|
+
t.OpportunityOnly && /* @__PURE__ */ jsxs(
|
|
63132
|
+
Badge,
|
|
63133
|
+
{
|
|
63134
|
+
variant: "info",
|
|
63135
|
+
className: "rounded-full px-3",
|
|
63136
|
+
children: [
|
|
63137
|
+
/* @__PURE__ */ jsx(ShieldCheck, { size: "12", className: "mr-1.5" }),
|
|
63138
|
+
" ",
|
|
63139
|
+
"Requires Opportunity"
|
|
63140
|
+
]
|
|
63141
|
+
}
|
|
63142
|
+
),
|
|
63131
63143
|
t.ManufacturerId && /* @__PURE__ */ jsxs(
|
|
63132
63144
|
Badge,
|
|
63133
63145
|
{
|
|
@@ -505,7 +505,7 @@ Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=1
|
|
|
505
505
|
`;break;default:e+=String.fromCharCode(n);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}},pp.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case"\\":++this.pos;break;case"$":if(this.input[this.pos+1]!=="{")break;case"`":return this.finishToken(types$1.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":this.input[this.pos+1]===`
|
|
506
506
|
`&&++this.pos;case`
|
|
507
507
|
`:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")},pp.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`
|
|
508
|
-
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return codePointToString(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),e){var n=this.pos-1;this.invalidStringToken(n,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var s=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],a=parseInt(s,8);return a>255&&(s=s.slice(0,-1),a=parseInt(s,8)),this.pos+=s.length-1,t=this.input.charCodeAt(this.pos),(s!=="0"||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-s.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(a)}return isNewLine(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}},pp.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,"Bad character escape sequence"),n},pp.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,n=this.pos,s=this.options.ecmaVersion>=6;this.pos<this.input.length;){var a=this.fullCharCodeAtPos();if(isIdentifierChar(a,s))this.pos+=a<=65535?1:2;else if(a===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var o=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var l=this.readCodePoint();(t?isIdentifierStart:isIdentifierChar)(l,s)||this.invalidStringToken(o,"Invalid Unicode escape"),e+=codePointToString(l),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},pp.readWord=function(){var e=this.readWord1(),t=types$1.name;return this.keywords.test(e)&&(t=keywords[e]),this.finishToken(t,e)};var version="8.12.1";Parser.acorn={Parser,version,defaultOptions,Position,SourceLocation,getLineInfo,Node:Node$2,TokenType,tokTypes:types$1,keywordTypes:keywords,TokContext,tokContexts:types,isIdentifierChar,isIdentifierStart,Token,isNewLine,lineBreak,lineBreakG,nonASCIIwhitespace};var AcornJSX=__toESM(require_acorn_jsx()),attributeNames_default={acceptcharset:"acceptCharset",accesskey:"accessKey",allowfullscreen:"allowFullScreen",autocapitalize:"autoCapitalize",autocomplete:"autoComplete",autofocus:"autoFocus",autoplay:"autoPlay",cellpadding:"cellPadding",cellspacing:"cellSpacing",charset:"charSet",class:"className",colspan:"colSpan",contenteditable:"contentEditable",crossorigin:"crossOrigin",datetime:"dateTime",enctype:"encType",for:"htmlFor",formaction:"formAction",formenctype:"formEncType",formmethod:"formMethod",formnovalidate:"formNoValidate",formtarget:"formTarget",frameborder:"frameBorder",hreflang:"hrefLang",httpequiv:"httpEquiv",inputmode:"inputMode",keyparams:"keyParams",keytype:"keyType",marginheight:"marginHeight",marginwidth:"marginWidth",maxlength:"maxLength",mediagroup:"mediaGroup",minlength:"minLength",novalidate:"noValidate",radiogroup:"radioGroup",readonly:"readOnly",referrerpolicy:"referrerPolicy",rowspan:"rowSpan",spellcheck:"spellCheck",srcdoc:"srcDoc",srclang:"srcLang",srcset:"srcSet",tabindex:"tabIndex",usemap:"useMap"},VOID_ELEMENTS=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"],NO_WHITESPACE=["table","tbody","tfoot","thead","tr"];function canHaveChildren(e){return VOID_ELEMENTS.indexOf(e.toLowerCase())===-1}function canHaveWhitespace(e){return NO_WHITESPACE.indexOf(e.toLowerCase())!==-1}class NullishShortCircuit extends Error{constructor(t="Nullish value encountered"){super(t),this.name="NullishShortCircuit"}}var hash=(e="",t=16)=>{const n=String(e);let s=0;return n.split("").forEach(a=>{s=(s<<5)-s+a.charCodeAt(0),s&=s}),Math.abs(s).toString(t)},randomHash=()=>hash(Math.random().toString()),camelCase=e=>e.replace(/([A-Z])([A-Z])/g,"$1 $2").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[^a-zA-Z\u00C0-\u00ff]/g," ").toLowerCase().split(" ").filter(t=>t).map((t,n)=>n>0?t[0].toUpperCase()+t.slice(1):t).join(""),parseStyle=e=>{switch(typeof e){case"string":return e.split(";").filter(t=>t).reduce((t,n)=>{const s=n.slice(0,n.indexOf(":")).trim(),a=n.slice(n.indexOf(":")+1).trim();return{...t,[camelCase(s)]:a}},{});case"object":return e;default:return}},pathToArrayPath=e=>e==null||e===""?[]:e.split("."),resolveArrayPath=(e,t)=>{const[n,...s]=t;if(!(e==null||n==null))return s.length===0?e[n]:resolveArrayPath(e[n],s)},resolvePath=(e,t)=>resolveArrayPath(e,pathToArrayPath(t));function handleNaN(e){return Number.isNaN(e)?"NaN":e}class JsxParser extends React.Component{static displayName="JsxParser";static defaultProps={allowUnknownElements:!0,autoCloseVoidElements:!1,bindings:{},blacklistedAttrs:[/^on.+/i],blacklistedTags:["script"],className:"",components:{},componentsOnly:!1,disableFragments:!1,disableKeyGeneration:!1,jsx:"",onError:()=>{},showWarnings:!1,renderError:void 0,renderInWrapper:!0,renderUnrecognized:()=>null};ParsedChildren=null;#n=t=>{const n=Parser.extend(AcornJSX.default({autoCloseVoidElements:this.props.autoCloseVoidElements})),s=`<root>${t}</root>`;let a=[];try{return a=n.parse(s,{ecmaVersion:"latest"}),a=a.body[0].expression.children||[],a.map(o=>this.#e(o)).filter(Boolean)}catch(o){return this.props.showWarnings&&console.warn(o),this.props.onError&&this.props.onError(o),this.props.renderError?this.props.renderError({error:String(o)}):null}};#e=(t,n)=>{switch(t.type){case"JSXAttribute":return t.value===null?!0:this.#e(t.value,n);case"JSXElement":case"JSXFragment":return this.#r(t,n);case"JSXExpressionContainer":return this.#e(t.expression,n);case"JSXText":const s=this.props.disableKeyGeneration?void 0:randomHash();return this.props.disableFragments?t.value:React.createElement(React.Fragment,{key:s},t.value);case"ArrayExpression":return t.elements.map(S=>this.#e(S,n));case"BinaryExpression":const a=this.#e(t.left,n),o=this.#e(t.right,n);let l;switch(t.operator){case"-":l=a-o;break;case"!=":l=a!=o;break;case"!==":l=a!==o;break;case"*":l=a*o;break;case"**":l=a**o;break;case"/":l=a/o;break;case"%":l=a%o;break;case"+":l=a+o;break;case"<":l=a<o;break;case"<=":l=a<=o;break;case"==":l=a==o;break;case"===":l=a===o;break;case">":l=a>o;break;case">=":l=a>=o;break;default:this.props.onError(new Error(`Unsupported binary operator: ${t.operator}`));return}return handleNaN(l);case"CallExpression":const c=this.#e(t.callee,n);if(c===void 0){if(t.optional)throw new NullishShortCircuit;this.props.onError(new Error(`The expression '${t.callee}' could not be resolved, resulting in an undefined return value.`));return}return c(...t.arguments.map(S=>this.#e(S,n)));case"ConditionalExpression":return this.#e(t.test,n)?this.#e(t.consequent,n):this.#e(t.alternate,n);case"ExpressionStatement":return this.#e(t.expression,n);case"Identifier":return t.name==="Infinity"?1/0:t.name==="-Infinity"?-1/0:t.name==="NaN"?NaN:n&&t.name in n?handleNaN(n[t.name]):handleNaN((this.props.bindings||{})[t.name]);case"Literal":return t.value;case"LogicalExpression":const d=this.#e(t.left,n);return t.operator==="||"&&d?d:t.operator==="&&"&&d||t.operator==="||"&&!d?this.#e(t.right,n):!1;case"MemberExpression":return this.#s(t,n);case"ChainExpression":return this.#i(t,n);case"ObjectExpression":const f={};return t.properties.forEach(S=>{f[S.key.name||S.key.value]=this.#e(S.value,n)}),f;case"TemplateElement":return t.value.cooked;case"TemplateLiteral":return[...t.expressions,...t.quasis].sort((S,V)=>S.start<V.start?-1:1).map(S=>this.#e(S,n)).join("");case"UnaryExpression":const R=this.#e(t.argument,n);switch(t.operator){case"+":return+R;case"-":return-R;case"!":return!R;case"~":return~R;case"typeof":return typeof R}return;case"ArrowFunctionExpression":return(t.async||t.generator)&&this.props.onError?.(new Error("Async and generator arrow functions are not supported.")),(...S)=>{const V={...n};return t.params.forEach((A,at)=>{V[A.name]=S[at]}),this.#e(t.body,V)};default:this.props.onError(new Error(`The expression type '${t.type}' is not supported.`));return}};#i=(t,n)=>{try{return this.#e(t.expression,n)}catch(s){if(s instanceof NullishShortCircuit)return;throw s}};#s=(t,n)=>{const s=this.#e(t.object,n);let a;if(t.computed)a=this.#e(t.property,n);else if(t.property.type==="Identifier")a=t.property.name;else{this.props.onError(new Error("Only simple MemberExpressions are supported."));return}if(s==null&&t.optional)throw new NullishShortCircuit;let o;try{o=s[a]}catch{this.props.onError(new Error(`The property '${a}' could not be resolved on the object '${s}'.`));return}return typeof o=="function"?o.bind(s):o};#t=t=>t.type==="JSXIdentifier"?t.name:`${this.#t(t.object)}.${this.#t(t.property)}`;#r=(t,n)=>{const{allowUnknownElements:s,components:a,componentsOnly:o,onError:l}=this.props,{children:c=[]}=t,d=t.type==="JSXElement"?t.openingElement:t.openingFragment,{attributes:f=[]}=d,R=t.type==="JSXElement"?this.#t(d.name):"",S=(this.props.blacklistedAttrs||[]).map(pt=>pt instanceof RegExp?pt:new RegExp(pt,"i")),V=(this.props.blacklistedTags||[]).map(pt=>pt.trim().toLowerCase()).filter(Boolean);if(/^(html|head|body)$/i.test(R))return c.map(pt=>this.#r(pt,n));const A=R.trim().toLowerCase();if(V.indexOf(A)!==-1)return l(new Error(`The tag <${R}> is blacklisted, and will not be rendered.`)),null;if(R!==""&&!resolvePath(a,R)){if(o)return l(new Error(`The component <${R}> is unrecognized, and will not be rendered.`)),this.props.renderUnrecognized(R);if(!s&&document.createElement(R)instanceof HTMLUnknownElement)return l(new Error(`The tag <${R}> is unrecognized in this browser, and will not be rendered.`)),this.props.renderUnrecognized(R)}let at,lt=t.type==="JSXElement"?resolvePath(a,R):React.Fragment;if(lt||canHaveChildren(R)){if(at=c.map(ft=>this.#e(ft,n)),R.includes(".")){const yt=R.split(".").reduce((mt,dt)=>mt?mt[dt]:a?.[dt],null);yt&&(lt=yt)}!lt&&!canHaveWhitespace(R)&&(at=at.filter(ft=>typeof ft!="string"||!/^\s*$/.test(ft)));const pt=at.find(ft=>typeof ft=="function");at.length===0?at=void 0:pt?at=pt:at.length===1?[at]=at:at.length>1&&!this.props.disableKeyGeneration&&(at=at.map((ft,yt)=>ft?.type&&!ft?.key?{...ft,key:ft.key||yt}:ft))}const ot={key:this.props.disableKeyGeneration?void 0:randomHash()};f.forEach(pt=>{if(pt.type==="JSXAttribute"){const ft=pt.name.name,yt=attributeNames_default[ft]||ft,mt=this.#e(pt,n);S.filter(Rt=>Rt.test(yt)).length===0&&(ot[yt]=mt)}else if(pt.type==="JSXSpreadAttribute"&&pt.argument.type==="Identifier"||pt.argument.type==="MemberExpression"){const ft=this.#e(pt.argument,n);typeof ft=="object"&&Object.keys(ft).forEach(yt=>{const mt=attributeNames_default[yt]||yt;S.filter(Rt=>Rt.test(mt)).length===0&&(ot[mt]=ft[yt])})}}),typeof ot.style=="string"&&(ot.style=parseStyle(ot.style));const ct=R.toLowerCase();return ct==="option"&&(at=at.props.children),React.createElement(lt||ct,ot,at)};render(){const t=(this.props.jsx||"").trim().replace(/<!DOCTYPE([^>]*)>/g,"");this.ParsedChildren=this.#n(t);const n=[...new Set(["jsx-parser",...String(this.props.className).split(" ")])].filter(Boolean).join(" ");return this.props.renderInWrapper?React.createElement("div",{className:n},this.ParsedChildren):this.ParsedChildren}}var source_default=JsxParser;const CountryFlag=({countryCode:e,className:t=""})=>{const[n,s]=React.useState(null),[a,o]=React.useState(!1);return React.useEffect(()=>{if(!e)return;const c=`https://purecatamphetamine.github.io/country-flag-icons/3x2/${e.toUpperCase()}.svg`;fetch(c,{method:"HEAD"}).then(d=>{d.ok?(s(c),o(!1)):o(!0)}).catch(()=>{o(!0)})},[e]),a||!n?jsxRuntime.jsx("span",{className:t,children:e}):jsxRuntime.jsx("img",{src:n,alt:`${e} flag`,className:`inline-block ${t}`,style:{width:"24px",height:"auto"}})},imgSizeMap$1={sm:100,md:200,lg:300,xl:400};async function fetchProductImagesList({apiOrigin:e,randmarSKU:t,signal:n}){const s=new URL(`/Product/${encodeURIComponent(t)}/Images`,e),a=await fetch(s.toString(),{method:"GET",credentials:"omit",headers:{Accept:"application/json"},signal:n});if(!a.ok)throw new Error(`Failed to load images list for ${t}: ${a.status}`);const o=await a.json();return Array.isArray(o)?o:o&&typeof o=="object"&&"Images"in o&&Array.isArray(o.Images)?o.Images:[]}function buildImageSrc({apiOrigin:e,randmarSKU:t,image:n,width:s,height:a}){const o=(n.Url??"").trim();if(o){if(o.startsWith("data:"))return o;try{const c=new URL(o,e),d=c.pathname.split("/").filter(Boolean),f=t.trim().toLowerCase(),R=at=>{try{return decodeURIComponent(at).toLowerCase()===f}catch{return at.toLowerCase()===f}},S=d.slice(-3),V=d.slice(-4);return(S.length===3&&S[0]?.toLowerCase()==="product"&&R(S[1]??"")&&S[2]?.toLowerCase()==="image"||V.length===4&&V[0]?.toLowerCase()==="product"&&R(V[1]??"")&&V[2]?.toLowerCase()==="image")&&(c.searchParams.set("width",String(Math.round(s))),c.searchParams.set("height",String(Math.round(a)))),c.toString()}catch{}}const l=new URL(`/Product/${encodeURIComponent(t)}/Image/${encodeURIComponent(String(n.ImageId))}`,e);return l.searchParams.set("width",String(Math.round(s))),l.searchParams.set("height",String(Math.round(a))),l.toString()}function buildLegacyImageSrc({apiOrigin:e,randmarSKU:t,width:n,height:s}){const a=new URL(`/Product/${encodeURIComponent(t)}/Image`,e);return a.searchParams.set("width",String(Math.round(n))),a.searchParams.set("height",String(Math.round(s))),a.toString()}const Placeholder$1=({size:e,alt:t})=>jsxRuntime.jsx("div",{className:"rounded-md bg-muted flex items-center justify-center",style:{width:e,height:e},"aria-label":t,children:jsxRuntime.jsx(ImageOff,{className:"h-1/2 w-1/2 text-muted-foreground"})});function ProductImageCarousel({randmarSKU:e,size:t="md",alt:n,className:s,fallback:a}){const o=imgSizeMap$1[t],l=React__namespace.useRef(null),c=useIntersectionObserver({elementRef:l,threshold:.1,rootMargin:"100px"}),d=useApiOrigin(),[f,R]=React__namespace.useState(null),[S,V]=React__namespace.useState(!1),[A,at]=React__namespace.useState(0),[lt,ot]=React__namespace.useState(!1),ct=React__namespace.useRef(!1),pt=React__namespace.useRef(new Set);React__namespace.useEffect(()=>{R(null),V(!1),at(0),ot(!1),ct.current=!1,pt.current.clear()},[e]),React__namespace.useEffect(()=>{if(!e||!c||f!==null||S)return;const zt=new AbortController;return(async()=>{try{const Kt=await fetchProductImagesList({apiOrigin:d,randmarSKU:e,signal:zt.signal});R(Kt)}catch(Kt){if(zt.signal.aborted)return;console.error("Failed to load product images list",{randmarSKU:e,error:Kt}),V(!0)}})(),()=>zt.abort()},[d,S,f,c,e]);const ft=React__namespace.useMemo(()=>f?[...f].sort((zt,Kt)=>{const Qt=zt.SortOrder??Number.POSITIVE_INFINITY,Wt=Kt.SortOrder??Number.POSITIVE_INFINITY;if(Qt!==Wt)return Qt-Wt;const qt=zt.IsPrimary===!0?0:1,Xt=Kt.IsPrimary===!0?0:1;return qt-Xt}):null,[f]),yt=React__namespace.useMemo(()=>{if(!ft?.length)return 0;const zt=ft.findIndex(Kt=>Kt.IsPrimary===!0);return zt>=0?zt:0},[ft]);React__namespace.useEffect(()=>{ft?.length&&(ct.current||(at(yt),ct.current=!0))},[yt,ft]);const mt=ft?.length??0,dt=React__namespace.useMemo(()=>{const zt=(n??"").trim();return zt?`${zt} (Product ${e})`:`Product ${e}`},[n,e]),Rt=React__namespace.useCallback(zt=>mt>1?`${dt} image ${zt+1}`:dt,[dt,mt]),Mt=ft?.[A],Dt=React__namespace.useMemo(()=>Mt?buildImageSrc({apiOrigin:d,randmarSKU:e,image:Mt,width:o*1.5,height:o*1.5}):null,[Mt,d,o,e]),$t=React__namespace.useCallback(zt=>{if(mt<=0)return;const Kt=(zt%mt+mt)%mt;at(Kt)},[mt]),Ht=React__namespace.useCallback(()=>$t(A-1),[A,$t]),Ct=React__namespace.useCallback(()=>$t(A+1),[A,$t]),Vt=React__namespace.useCallback(zt=>{if(!(mt<=1))switch(zt.key){case"ArrowLeft":zt.preventDefault(),Ht();break;case"ArrowRight":zt.preventDefault(),Ct();break;case"Home":zt.preventDefault(),$t(0);break;case"End":zt.preventDefault(),$t(mt-1);break}},[Ct,Ht,$t,mt]);if(React__namespace.useEffect(()=>{if(!ft?.length||mt<=1)return;const zt=(A-1+mt)%mt,Kt=(A+1)%mt,Qt=[zt,Kt];for(const Wt of Qt){const qt=ft[Wt];if(!qt)continue;const Xt=buildImageSrc({apiOrigin:d,randmarSKU:e,image:qt,width:o*1.5,height:o*1.5});if(pt.current.has(Xt))continue;pt.current.add(Xt);const dr=new Image;dr.src=Xt}},[A,d,o,e,mt,ft]),S)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:a??null});if(f===null&&c)return jsxRuntime.jsx("div",{className:s,ref:l,children:jsxRuntime.jsx(Skeleton,{className:"rounded-md",style:{width:o,height:o}})});if(ft&&ft.length===0){if(a!=null)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:a});const zt=buildLegacyImageSrc({apiOrigin:d,randmarSKU:e,width:o*1.5,height:o*1.5});return jsxRuntime.jsx("div",{className:s,ref:l,children:jsxRuntime.jsx("div",{className:"relative rounded-md overflow-hidden bg-muted",style:{width:o,height:o},"aria-label":dt,children:lt?jsxRuntime.jsx(Placeholder$1,{size:o,alt:dt}):jsxRuntime.jsx("img",{alt:dt,className:"w-full h-full object-contain",src:zt,width:o,height:o,loading:"eager",onError:()=>ot(!0)})})})}return Dt?jsxRuntime.jsx("div",{className:s,ref:l,children:jsxRuntime.jsxs("div",{className:"group relative rounded-md overflow-hidden bg-muted",style:{width:o,height:o},role:"region","aria-roledescription":"carousel","aria-label":`Product images for ${e}`,tabIndex:mt>1?0:-1,onKeyDown:Vt,children:[jsxRuntime.jsx("img",{alt:Rt(A),className:"w-full h-full object-contain",src:Dt,width:o,height:o,loading:"eager"}),mt>1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Button$1,{type:"button",variant:"secondary",size:"icon",className:"absolute left-2 top-1/2 -translate-y-1/2 bg-background/80 text-foreground shadow-sm ring-1 ring-border/50 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100",onClick:Ht,"aria-label":"Previous image",children:jsxRuntime.jsx(ChevronLeft,{className:"h-4 w-4"})}),jsxRuntime.jsx(Button$1,{type:"button",variant:"secondary",size:"icon",className:"absolute right-2 top-1/2 -translate-y-1/2 bg-background/80 text-foreground shadow-sm ring-1 ring-border/50 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100",onClick:Ct,"aria-label":"Next image",children:jsxRuntime.jsx(ChevronRight,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"absolute bottom-2 left-1/2 -translate-x-1/2 flex items-center gap-1 rounded-full bg-background/80 px-2 py-1",children:Array.from({length:mt}).map((zt,Kt)=>{const Qt=Kt===A;return jsxRuntime.jsx("button",{type:"button",className:["h-1.5 w-1.5 rounded-full transition-colors",Qt?"bg-foreground":"bg-muted-foreground/40 hover:bg-muted-foreground/60"].join(" "),onClick:()=>$t(Kt),"aria-label":`Go to image ${Kt+1} of ${mt}`,"aria-current":Qt?"true":void 0},Kt)})})]})]})}):jsxRuntime.jsx("div",{className:s,ref:l,children:jsxRuntime.jsx(Placeholder$1,{size:o,alt:dt})})}const getTodayIsoDate=()=>new Date().toISOString().split("T")[0],isOpportunityNotStartedYet=e=>e.StartDate?e.StartDate.split("T")[0]>getTodayIsoDate():!1,isOpportunitySelectable=e=>{if(e.Active!==!0)return!1;const t=getTodayIsoDate();return!(e.EndDate&&e.EndDate.split("T")[0]<t||e.StartDate&&e.StartDate.split("T")[0]>t)};function ProductCard({applicationId:e,product:t,viewProductLink:n,defaultOpportunityNumber:s="",onAddToCart:a,addingToCart:o=!1,shopifyHostname:l,customAction:c=jsxRuntime.jsx(jsxRuntime.Fragment,{})}){const d=reactRouterDom.useNavigate(),{toast:f}=useToast(),[R,S]=React.useState(1),[V,A]=React.useState(null),[at,lt]=React.useState(0),[ot,ct]=React.useState(!1),[pt]=usePostV4ResellerByRouteResellerIdProductAndRandmarSkuShopifyMutation(),[ft,yt]=React.useState(!1),[mt,dt]=React.useState(null),[Rt,Mt]=React.useState("idle"),[Dt,$t]=React.useState(null),[Ht]=useLazyGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery(),Ct=t?.Distribution?.Cost||0,Vt=t?.Distribution?.RegularPrice||0,Ft=t?.Distribution?.Price||0,zt=!!(e&&t?.RandmarSKU);React.useEffect(()=>{S(1),A(null),lt(0)},[t?.RandmarSKU]),React.useEffect(()=>{if(t&&s){const rr=t.Opportunities?.find(wr=>wr.BidNumber==s);rr&&isOpportunitySelectable(rr)&&A(rr)}},[t,s]),React.useEffect(()=>{if(!t)return;const rr=V?.Price?V.Price:Ft;lt(Vt>0?Math.round((Vt-rr)/Vt*100):0)},[t,V,Ft,Vt]),React.useEffect(()=>{o||S(1)},[o]),React.useEffect(()=>{if(!ft){dt(null),Mt("idle"),$t(null);return}if(!e||!t?.RandmarSKU){Mt("error"),$t("Missing identifiers to load performance data.");return}let rr=!1;const wr=t.RandmarSKU;return(async()=>{Mt("summary"),$t(null);try{const jr=await Ht({routeApplicationId:e,randmarSku:wr,withSpecification:!1});if(rr)return;if("error"in jr&&jr.error)throw jr.error;dt(jr.data??null),Mt("detailed");const Mr=await Ht({routeApplicationId:e,randmarSku:wr,withSpecification:!0});if(rr)return;if("error"in Mr&&Mr.error)throw Mr.error;dt(Mr.data??jr.data??null),Mt("complete")}catch(jr){if(rr)return;console.error("Failed to load performance data for product modal",jr),Mt("error"),$t("We couldn't load the performance details. Please try again.")}})(),()=>{rr=!0}},[e,Ht,ft,t?.RandmarSKU]);const Kt=rr=>rr>=90?{label:"Top 10% Bestseller",color:"text-primary",bgColor:"bg-primary/10"}:rr>=75?{label:"Bestseller",color:"text-info",bgColor:"bg-info/10"}:rr>=33?{label:"Popular",color:"text-success",bgColor:"bg-success/10"}:{label:"Rising",color:"text-muted-foreground",bgColor:"bg-muted/30"},Qt=Rt!=="complete"&&Rt!=="error",Wt=Rt==="summary"?40:Rt==="detailed"?80:10,qt=mt?.SalesStatistics??[],Xt=Qt?[]:qt,dr=mt?.RandmarTitle??t?.RandmarTitle??t?.RandmarSKU??"this product",cr=mt?.RandmarSKU??t?.RandmarSKU,hr=e&&t?.ManufacturerId?`/${encodeURIComponent(e)}/Partner/${encodeURIComponent(t.ManufacturerId)}?tab=manufacturer-overview`:null;if(!t)return jsxRuntime.jsx(Card,{className:"flex h-full w-full flex-col",children:jsxRuntime.jsxs(CardContent,{className:"flex h-full flex-col p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx("div",{className:"h-10 w-24 flex items-center justify-end ml-4",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-28 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-6 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsx("div",{className:"w-60 h-40",children:jsxRuntime.jsx(Skeleton,{className:"w-full h-full rounded-lg"})})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsx("div",{className:"flex flex-1",children:jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-24 mb-3"}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-full rounded-md"})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-32 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24 mt-4"})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-start gap-1 mb-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-10 flex-1 rounded-md"})]})]})]})});const mr=t?.Opportunities||[],sr=mr.length>0,vr=()=>{if(R==null){S(1);return}R>1&&S(R-1)},ur=()=>{if(R==null){S(1);return}S(R+1)},Rr=rr=>{const wr=Number.parseInt(rr.target.value,10);if(!isNaN(wr)&&wr>0){S(wr);return}S(void 0)},ar=()=>{(R==null||R<1)&&S(1)},nr=rr=>{try{return new Date(rr).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch(wr){return console.error(wr),rr.split("T")[0]||"N/A"}},xr=rr=>{const wr=typeof t?.MSRP=="number"&&t.MSRP>0?t.MSRP:typeof t?.MAP=="number"&&t.MAP>0?t.MAP:null;if(wr===null)return null;const _r=rr.Price??t?.Distribution?.Price;if(typeof _r!="number")return null;const jr=rr.Rebate??0,Mr=Math.max(_r-jr,0);return wr-Mr},Zt=()=>{typeof a<"u"&&a({quantity:R??1,bidNumber:V?.BidNumber??null})},Er=()=>{ot||!l||(ct(!0),pt({routeResellerId:e??"",randmarSku:t.RandmarSKU??"",shopifyHostName:l}).then(rr=>{if(rr.error){console.error("Error syncing to Shopify:",rr.error),f({title:"Product synced failed.",description:"Error syncing to Shopify:",variant:"destructive"});return}f({title:"Product synced",description:"Product synced to Shopify successfully",variant:"success"})}).catch(rr=>{console.error("Error syncing to Shopify:",rr),f({title:"Product synced failed.",description:"Error syncing to Shopify:",variant:"destructive"})}).finally(()=>{ct(!1)}))};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Card,{className:"flex h-full w-full flex-col hover:shadow-lg transition-shadow @container",children:jsxRuntime.jsxs(CardContent,{className:"flex h-full flex-col p-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-xl",children:t.Title||t.RandmarTitle}),jsxRuntime.jsx("div",{className:"w-24 h-10 flex items-center justify-end ml-4 flex-shrink-0",children:hr?jsxRuntime.jsx(reactRouterDom.Link,{to:hr,"aria-label":`Open manufacturer overview for ${t.ManufacturerName??"this manufacturer"}`,className:"block h-full w-full",children:jsxRuntime.jsx(PartnerLogo,{id:t.ManufacturerId,name:t.ManufacturerName,width:96,height:40,className:"cursor-pointer"},`partner_logo_${t.ManufacturerId}`)}):jsxRuntime.jsx(PartnerLogo,{id:t.ManufacturerId,name:t.ManufacturerName,width:96,height:40},`partner_logo_${t.ManufacturerId}`)})]}),jsxRuntime.jsxs("div",{className:"flex flex-col @[36rem]:flex-row gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-1 @[36rem]:order-1 order-2 flex flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 items-center justify-center @[36rem]:items-start @[36rem]:justify-start",children:[t.State&&jsxRuntime.jsxs(Badge,{variant:t.State==="Active"?"success":"destructive",className:"rounded-full px-3",children:[jsxRuntime.jsx(Check,{size:"12",className:"mr-1.5"})," ",t.State]}),jsxRuntime.jsxs(Badge,{variant:t.SerialNumber?"success":"warning",className:"rounded-full px-3",children:[jsxRuntime.jsx(QrCode,{size:"12",className:"mr-1.5"})," ",t.SerialNumber?"Serialized":"Unserialized"]}),t.TransparencyCode&&jsxRuntime.jsxs(Badge,{variant:"info",className:"rounded-full px-3",children:[jsxRuntime.jsx(CircleDashed,{size:"12",className:"mr-1.5"})," Transparency Code"]}),t.AvailableToBuy!==void 0&&jsxRuntime.jsxs(Badge,{variant:t.AvailableToBuy?"success":"destructive",className:"rounded-full px-3",children:[jsxRuntime.jsx(ShoppingCart,{size:"12",className:"mr-1.5"})," ",t.AvailableToBuy?"Available":"Unavailable"]}),t.ManufacturerCategory!==void 0&&jsxRuntime.jsxs(Badge,{variant:t.ManufacturerCategory?.QualificationRequired?"info":"secondary",className:"rounded-full px-3",children:[jsxRuntime.jsx(ShieldCheck,{size:"12",className:"mr-1.5"})," ",t.ManufacturerCategory?.QualificationRequired?"Qualified Only":"Available to all"]}),t.ManufacturerId&&jsxRuntime.jsxs(Badge,{variant:t.AutoUpdate?"info":"secondary",className:"rounded-full px-3",children:[jsxRuntime.jsx(RefreshCw,{size:"12",className:"mr-1.5"})," ",t.AutoUpdate?`Automatic Reorder (${t.MasterCarton})`:"Manually Reorders"]}),jsxRuntime.jsxs(Badge,{variant:t.BodyHTML&&t.Title&&t.MAP?"success":"warning",className:"rounded-full px-3",children:[jsxRuntime.jsx(Store,{size:"12",className:"mr-1.5"})," ",t.BodyHTML&&t.Title&&t.MAP?"Shopify Ready":"Not Shopify Ready"]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-4 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"MPN"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.MPN||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"UPC"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.UPC||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Unit Weight"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.UnitWeight?`${formatNumber(t.UnitWeight)} lbs`:"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"text-sm text-muted-foreground",children:["MAP",jsxRuntime.jsx("span",{className:"text-primary",children:" / "}),"MSRP"]}),jsxRuntime.jsxs("div",{className:"font-medium",children:[t.MAP?formatMoney(t.MAP):"N/A",jsxRuntime.jsx("span",{className:"text-primary",children:" / "}),t.MSRP?formatMoney(t.MSRP):"N/A"]})]}),!!t.OverallPercentileRank&&!!t.ManufacturerPercentileRank&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:"Bestseller Status"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{children:"Global: "}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Badge,{variant:"outline",className:`rounded-full px-3 w-fit ${Kt(t.OverallPercentileRank).bgColor} ${Kt(t.OverallPercentileRank).color} hover:${Kt(t.OverallPercentileRank).bgColor}`,children:Kt(t.OverallPercentileRank).label})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["Percentile Rank: ",t.OverallPercentileRank]})})]})})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("span",{children:[t.ManufacturerName,": "]}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Badge,{variant:"outline",className:`rounded-full px-3 w-fit ${Kt(t.ManufacturerPercentileRank).bgColor} ${Kt(t.ManufacturerPercentileRank).color} hover:${Kt(t.ManufacturerPercentileRank).bgColor}`,children:Kt(t.ManufacturerPercentileRank).label})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["Percentile Rank: ",t.ManufacturerPercentileRank]})})]})})]})]})]}),t.CountryCodeOfOrigin&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Origin"}),jsxRuntime.jsxs("div",{className:"font-medium flex items-center",children:[jsxRuntime.jsx(CountryFlag,{countryCode:t.CountryCodeOfOrigin,className:"mr-2"}),t.CountryCodeOfOrigin]})]})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col @[36rem]:order-2 order-1 items-center",children:jsxRuntime.jsx(ProductImageCarousel,{randmarSKU:t.RandmarSKU||"",alt:t.RandmarTitle||"",fallback:jsxRuntime.jsx(ProductImage,{randmarSKU:t.RandmarSKU||"",alt:t.RandmarTitle||"",sceneName:t.SceneName},`product_image_fallback_${t.RandmarSKU}`)},`product_image_${t.RandmarSKU}`)})]}),jsxRuntime.jsx("div",{className:"flex flex-col @[36rem]:flex-row gap-6 mt-4",children:jsxRuntime.jsx("div",{className:"flex flex-1 @[36rem]:order-1 order-2",children:sr&&t.Distribution&&jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx("div",{className:"flex items-center",children:"You have "+mr.length+(mr.length>1?" opportunities":" opportunity")+" for this product:"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsx("div",{className:"space-y-2 max-h-[200px] overflow-y-auto p-2 mt-1",children:mr.map((rr,wr)=>{const _r=xr(rr);return isOpportunitySelectable(rr)?jsxRuntime.jsxs("div",{className:`flex justify-between items-center rounded-lg transition-colors py-2 px-4 border cursor-pointer ${rr.BidNumber==V?.BidNumber?"bg-primary/10 border-2 border-primary":"bg-background border-border hover:bg-muted/30"}`,onClick:()=>{A(rr.BidNumber!==V?.BidNumber?rr:null)},children:[jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-medium text-sm",children:rr.Opportunity}),jsxRuntime.jsx("span",{className:"text-xs text-foreground",children:rr.BidNumber})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end",children:[jsxRuntime.jsx("span",{className:"font-semibold",children:formatMoney(rr.Price??0)}),rr.Rebate&&rr.Rebate>0&&jsxRuntime.jsxs("span",{className:"text-xs text-success",children:["Rebate: ",formatMoney(rr.Rebate)]}),_r!==null&&jsxRuntime.jsxs("span",{className:"text-xs text-info",children:["Potential Revenue: ",formatMoney(_r)]}),rr.EndDate&&jsxRuntime.jsxs("span",{className:"text-xs text-muted-foreground",children:["Ends: ",nr(rr.EndDate)]})]})]},wr):jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex justify-between items-center rounded-lg transition-colors py-2 px-4 bg-muted/30 border border-border cursor-pointer hover:bg-muted/40",onClick:()=>{rr.BidNumber&&d(`/${e}/Opportunity/${rr.ManufacturerId}/${rr.BidNumber}`)},children:[jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-medium text-sm",children:rr.Opportunity}),jsxRuntime.jsxs("span",{className:"text-xs text-foreground",children:[rr.BidNumber," ",jsxRuntime.jsx(Badge,{variant:"secondary",className:"text-xs mx-1 h-5",children:isOpportunityNotStartedYet(rr)&&rr.StartDate?`Starts ${nr(rr.StartDate)}`:"Currently unavailable"})]})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end",children:[jsxRuntime.jsx("span",{className:"font-semibold",children:formatMoney(rr.Price??0)}),rr.Rebate&&rr.Rebate>0&&jsxRuntime.jsxs("span",{className:"text-xs text-success",children:["Rebate: ",formatMoney(rr.Rebate)]}),_r!==null&&jsxRuntime.jsxs("span",{className:"text-xs text-info",children:["Potential Revenue: ",formatMoney(_r)]}),rr.EndDate&&jsxRuntime.jsxs("span",{className:"text-xs text-muted-foreground",children:["Ends: ",nr(rr.EndDate)]})]})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"View Opportunity"})})]},wr)})})})]})})})]}),jsxRuntime.jsxs("div",{className:"mt-4 flex flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-row flex-wrap justify-between items-end gap-4",children:[jsxRuntime.jsx("div",{className:"flex flex-col gap-3 flex-1",children:t.Distribution&&jsxRuntime.jsx("div",{className:"flex flex-col gap-1",children:Ct>0?jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("span",{className:"text-2xl font-bold whitespace-nowrap",children:["Cost: ",formatMoney(Ct)]})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap",children:[Vt>0&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("span",{className:"text-2xl font-bold whitespace-nowrap",children:formatMoney((V?t.Opportunities?.find(rr=>rr.BidNumber==V.BidNumber)?.Price:Ft)??0)})}),at>0&&jsxRuntime.jsx("span",{className:"text-muted-foreground line-through ml-2 whitespace-nowrap",children:formatMoney(Vt)})]}),at>0&&jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs(Badge,{variant:"info",className:"rounded-full px-3 whitespace-nowrap",children:[jsxRuntime.jsxs("span",{children:[at,"% OFF"]}),t.InstantRebate?.EndDate&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",t.InstantRebate.EndDate.split("T")[0]]}),V?.EndDate&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",V.EndDate.split("T")[0]]})]})})]})})}),jsxRuntime.jsxs("div",{className:"flex flex-col justify-center @[36rem]:justify-end items-end gap-2 w-full @[36rem]:w-auto",children:[l&&jsxRuntime.jsx(Button$1,{className:"gap-2 whitespace-nowrap",onClick:Er,disabled:ot,children:ot?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2"}),"Sync to Shopify"]})}),c,typeof a<"u"&&jsxRuntime.jsxs("div",{className:"flex gap-2 whitespace-nowrap",children:[jsxRuntime.jsxs("div",{className:"flex items-center border rounded-md",children:[jsxRuntime.jsx(Button$1,{variant:"ghost",size:"icon",className:"rounded-r-none",onClick:vr,disabled:typeof R<"u"&&(R<=1||!t.AvailableToBuy||o),children:"-"}),jsxRuntime.jsx("input",{value:R,onChange:Rr,onBlur:ar,onClick:rr=>rr.currentTarget.select(),className:`w-6 @[36rem]:w-12 text-center border-0 bg-transparent text-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${!t.AvailableToBuy||o?"text-muted-foreground":""}`,disabled:!t.AvailableToBuy||o}),jsxRuntime.jsx(Button$1,{variant:"ghost",size:"icon",className:"rounded-l-none",onClick:ur,disabled:!t.AvailableToBuy||o,children:"+"})]}),jsxRuntime.jsx(Button$1,{className:"gap-2 whitespace-nowrap",onClick:Zt,disabled:!t.AvailableToBuy||o,children:o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}),"Adding..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2"}),"Add to Cart"]})})]})]})]}),jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-2 @[36rem]:flex-row",children:[jsxRuntime.jsx("div",{className:"flex-1 min-w-[10rem]",children:jsxRuntime.jsxs(Button$1,{variant:"outline",type:"button",className:"h-11 px-4 text-sm font-medium justify-start w-full",onClick:()=>yt(!0),disabled:!zt,children:[jsxRuntime.jsx(ChartLine,{className:"mr-2"}),"View statistics"]})}),jsxRuntime.jsx("div",{className:"flex-1 min-w-[10rem]",children:jsxRuntime.jsx(ProductInventoryButton,{applicationId:e??"",randmarSku:t.RandmarSKU??"",inventory:t.Distribution?.Inventory,buttonSize:"lg",buttonClassName:"w-full h-11 justify-start"})}),n&&jsxRuntime.jsx(reactRouterDom.Link,{to:n,className:"flex-1 min-w-[10rem]",children:jsxRuntime.jsxs(Button$1,{variant:"outline",className:"h-11 px-4 text-sm font-medium justify-start w-full",children:[jsxRuntime.jsx(Eye,{className:"mr-2"}),"View Product"]})})]})]})]})}),jsxRuntime.jsx(Dialog,{open:ft,onOpenChange:yt,children:jsxRuntime.jsxs(DialogContent,{className:"w-[min(95vw,1100px)] max-w-5xl space-y-6",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Monthly Sales Performance"}),jsxRuntime.jsxs(DialogDescription,{children:["Expanded product insights for ",dr,cr?` (SKU ${cr})`:""]})]}),jsxRuntime.jsx("div",{className:"space-y-6",children:Dt?jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(AlertTitle,{children:"Unable to load details"}),jsxRuntime.jsx(AlertDescription,{children:Dt})]}):jsxRuntime.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[jsxRuntime.jsxs("div",{className:"mb-4 space-y-2",children:[jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Rolling 12-month sales dollars and units sold pulled from the detailed endpoint."}),Qt&&jsxRuntime.jsx("div",{"aria-live":"polite","aria-busy":"true",children:jsxRuntime.jsx(Progress,{value:Wt,className:"h-2 w-full animate-pulse","aria-label":"Loading performance data"})})]}),jsxRuntime.jsx(SalesChart,{statistics:Xt,mode:"month",chartHeight:320}),Qt&&jsxRuntime.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"Gathering product summary and sales statistics..."})]})})]})})]})}const complexComponents=[`----
|
|
508
|
+
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return codePointToString(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),e){var n=this.pos-1;this.invalidStringToken(n,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var s=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],a=parseInt(s,8);return a>255&&(s=s.slice(0,-1),a=parseInt(s,8)),this.pos+=s.length-1,t=this.input.charCodeAt(this.pos),(s!=="0"||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-s.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(a)}return isNewLine(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}},pp.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,"Bad character escape sequence"),n},pp.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,n=this.pos,s=this.options.ecmaVersion>=6;this.pos<this.input.length;){var a=this.fullCharCodeAtPos();if(isIdentifierChar(a,s))this.pos+=a<=65535?1:2;else if(a===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var o=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var l=this.readCodePoint();(t?isIdentifierStart:isIdentifierChar)(l,s)||this.invalidStringToken(o,"Invalid Unicode escape"),e+=codePointToString(l),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},pp.readWord=function(){var e=this.readWord1(),t=types$1.name;return this.keywords.test(e)&&(t=keywords[e]),this.finishToken(t,e)};var version="8.12.1";Parser.acorn={Parser,version,defaultOptions,Position,SourceLocation,getLineInfo,Node:Node$2,TokenType,tokTypes:types$1,keywordTypes:keywords,TokContext,tokContexts:types,isIdentifierChar,isIdentifierStart,Token,isNewLine,lineBreak,lineBreakG,nonASCIIwhitespace};var AcornJSX=__toESM(require_acorn_jsx()),attributeNames_default={acceptcharset:"acceptCharset",accesskey:"accessKey",allowfullscreen:"allowFullScreen",autocapitalize:"autoCapitalize",autocomplete:"autoComplete",autofocus:"autoFocus",autoplay:"autoPlay",cellpadding:"cellPadding",cellspacing:"cellSpacing",charset:"charSet",class:"className",colspan:"colSpan",contenteditable:"contentEditable",crossorigin:"crossOrigin",datetime:"dateTime",enctype:"encType",for:"htmlFor",formaction:"formAction",formenctype:"formEncType",formmethod:"formMethod",formnovalidate:"formNoValidate",formtarget:"formTarget",frameborder:"frameBorder",hreflang:"hrefLang",httpequiv:"httpEquiv",inputmode:"inputMode",keyparams:"keyParams",keytype:"keyType",marginheight:"marginHeight",marginwidth:"marginWidth",maxlength:"maxLength",mediagroup:"mediaGroup",minlength:"minLength",novalidate:"noValidate",radiogroup:"radioGroup",readonly:"readOnly",referrerpolicy:"referrerPolicy",rowspan:"rowSpan",spellcheck:"spellCheck",srcdoc:"srcDoc",srclang:"srcLang",srcset:"srcSet",tabindex:"tabIndex",usemap:"useMap"},VOID_ELEMENTS=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"],NO_WHITESPACE=["table","tbody","tfoot","thead","tr"];function canHaveChildren(e){return VOID_ELEMENTS.indexOf(e.toLowerCase())===-1}function canHaveWhitespace(e){return NO_WHITESPACE.indexOf(e.toLowerCase())!==-1}class NullishShortCircuit extends Error{constructor(t="Nullish value encountered"){super(t),this.name="NullishShortCircuit"}}var hash=(e="",t=16)=>{const n=String(e);let s=0;return n.split("").forEach(a=>{s=(s<<5)-s+a.charCodeAt(0),s&=s}),Math.abs(s).toString(t)},randomHash=()=>hash(Math.random().toString()),camelCase=e=>e.replace(/([A-Z])([A-Z])/g,"$1 $2").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[^a-zA-Z\u00C0-\u00ff]/g," ").toLowerCase().split(" ").filter(t=>t).map((t,n)=>n>0?t[0].toUpperCase()+t.slice(1):t).join(""),parseStyle=e=>{switch(typeof e){case"string":return e.split(";").filter(t=>t).reduce((t,n)=>{const s=n.slice(0,n.indexOf(":")).trim(),a=n.slice(n.indexOf(":")+1).trim();return{...t,[camelCase(s)]:a}},{});case"object":return e;default:return}},pathToArrayPath=e=>e==null||e===""?[]:e.split("."),resolveArrayPath=(e,t)=>{const[n,...s]=t;if(!(e==null||n==null))return s.length===0?e[n]:resolveArrayPath(e[n],s)},resolvePath=(e,t)=>resolveArrayPath(e,pathToArrayPath(t));function handleNaN(e){return Number.isNaN(e)?"NaN":e}class JsxParser extends React.Component{static displayName="JsxParser";static defaultProps={allowUnknownElements:!0,autoCloseVoidElements:!1,bindings:{},blacklistedAttrs:[/^on.+/i],blacklistedTags:["script"],className:"",components:{},componentsOnly:!1,disableFragments:!1,disableKeyGeneration:!1,jsx:"",onError:()=>{},showWarnings:!1,renderError:void 0,renderInWrapper:!0,renderUnrecognized:()=>null};ParsedChildren=null;#n=t=>{const n=Parser.extend(AcornJSX.default({autoCloseVoidElements:this.props.autoCloseVoidElements})),s=`<root>${t}</root>`;let a=[];try{return a=n.parse(s,{ecmaVersion:"latest"}),a=a.body[0].expression.children||[],a.map(o=>this.#e(o)).filter(Boolean)}catch(o){return this.props.showWarnings&&console.warn(o),this.props.onError&&this.props.onError(o),this.props.renderError?this.props.renderError({error:String(o)}):null}};#e=(t,n)=>{switch(t.type){case"JSXAttribute":return t.value===null?!0:this.#e(t.value,n);case"JSXElement":case"JSXFragment":return this.#r(t,n);case"JSXExpressionContainer":return this.#e(t.expression,n);case"JSXText":const s=this.props.disableKeyGeneration?void 0:randomHash();return this.props.disableFragments?t.value:React.createElement(React.Fragment,{key:s},t.value);case"ArrayExpression":return t.elements.map(S=>this.#e(S,n));case"BinaryExpression":const a=this.#e(t.left,n),o=this.#e(t.right,n);let l;switch(t.operator){case"-":l=a-o;break;case"!=":l=a!=o;break;case"!==":l=a!==o;break;case"*":l=a*o;break;case"**":l=a**o;break;case"/":l=a/o;break;case"%":l=a%o;break;case"+":l=a+o;break;case"<":l=a<o;break;case"<=":l=a<=o;break;case"==":l=a==o;break;case"===":l=a===o;break;case">":l=a>o;break;case">=":l=a>=o;break;default:this.props.onError(new Error(`Unsupported binary operator: ${t.operator}`));return}return handleNaN(l);case"CallExpression":const c=this.#e(t.callee,n);if(c===void 0){if(t.optional)throw new NullishShortCircuit;this.props.onError(new Error(`The expression '${t.callee}' could not be resolved, resulting in an undefined return value.`));return}return c(...t.arguments.map(S=>this.#e(S,n)));case"ConditionalExpression":return this.#e(t.test,n)?this.#e(t.consequent,n):this.#e(t.alternate,n);case"ExpressionStatement":return this.#e(t.expression,n);case"Identifier":return t.name==="Infinity"?1/0:t.name==="-Infinity"?-1/0:t.name==="NaN"?NaN:n&&t.name in n?handleNaN(n[t.name]):handleNaN((this.props.bindings||{})[t.name]);case"Literal":return t.value;case"LogicalExpression":const d=this.#e(t.left,n);return t.operator==="||"&&d?d:t.operator==="&&"&&d||t.operator==="||"&&!d?this.#e(t.right,n):!1;case"MemberExpression":return this.#s(t,n);case"ChainExpression":return this.#i(t,n);case"ObjectExpression":const f={};return t.properties.forEach(S=>{f[S.key.name||S.key.value]=this.#e(S.value,n)}),f;case"TemplateElement":return t.value.cooked;case"TemplateLiteral":return[...t.expressions,...t.quasis].sort((S,V)=>S.start<V.start?-1:1).map(S=>this.#e(S,n)).join("");case"UnaryExpression":const R=this.#e(t.argument,n);switch(t.operator){case"+":return+R;case"-":return-R;case"!":return!R;case"~":return~R;case"typeof":return typeof R}return;case"ArrowFunctionExpression":return(t.async||t.generator)&&this.props.onError?.(new Error("Async and generator arrow functions are not supported.")),(...S)=>{const V={...n};return t.params.forEach((A,at)=>{V[A.name]=S[at]}),this.#e(t.body,V)};default:this.props.onError(new Error(`The expression type '${t.type}' is not supported.`));return}};#i=(t,n)=>{try{return this.#e(t.expression,n)}catch(s){if(s instanceof NullishShortCircuit)return;throw s}};#s=(t,n)=>{const s=this.#e(t.object,n);let a;if(t.computed)a=this.#e(t.property,n);else if(t.property.type==="Identifier")a=t.property.name;else{this.props.onError(new Error("Only simple MemberExpressions are supported."));return}if(s==null&&t.optional)throw new NullishShortCircuit;let o;try{o=s[a]}catch{this.props.onError(new Error(`The property '${a}' could not be resolved on the object '${s}'.`));return}return typeof o=="function"?o.bind(s):o};#t=t=>t.type==="JSXIdentifier"?t.name:`${this.#t(t.object)}.${this.#t(t.property)}`;#r=(t,n)=>{const{allowUnknownElements:s,components:a,componentsOnly:o,onError:l}=this.props,{children:c=[]}=t,d=t.type==="JSXElement"?t.openingElement:t.openingFragment,{attributes:f=[]}=d,R=t.type==="JSXElement"?this.#t(d.name):"",S=(this.props.blacklistedAttrs||[]).map(pt=>pt instanceof RegExp?pt:new RegExp(pt,"i")),V=(this.props.blacklistedTags||[]).map(pt=>pt.trim().toLowerCase()).filter(Boolean);if(/^(html|head|body)$/i.test(R))return c.map(pt=>this.#r(pt,n));const A=R.trim().toLowerCase();if(V.indexOf(A)!==-1)return l(new Error(`The tag <${R}> is blacklisted, and will not be rendered.`)),null;if(R!==""&&!resolvePath(a,R)){if(o)return l(new Error(`The component <${R}> is unrecognized, and will not be rendered.`)),this.props.renderUnrecognized(R);if(!s&&document.createElement(R)instanceof HTMLUnknownElement)return l(new Error(`The tag <${R}> is unrecognized in this browser, and will not be rendered.`)),this.props.renderUnrecognized(R)}let at,lt=t.type==="JSXElement"?resolvePath(a,R):React.Fragment;if(lt||canHaveChildren(R)){if(at=c.map(ft=>this.#e(ft,n)),R.includes(".")){const yt=R.split(".").reduce((mt,dt)=>mt?mt[dt]:a?.[dt],null);yt&&(lt=yt)}!lt&&!canHaveWhitespace(R)&&(at=at.filter(ft=>typeof ft!="string"||!/^\s*$/.test(ft)));const pt=at.find(ft=>typeof ft=="function");at.length===0?at=void 0:pt?at=pt:at.length===1?[at]=at:at.length>1&&!this.props.disableKeyGeneration&&(at=at.map((ft,yt)=>ft?.type&&!ft?.key?{...ft,key:ft.key||yt}:ft))}const ot={key:this.props.disableKeyGeneration?void 0:randomHash()};f.forEach(pt=>{if(pt.type==="JSXAttribute"){const ft=pt.name.name,yt=attributeNames_default[ft]||ft,mt=this.#e(pt,n);S.filter(Rt=>Rt.test(yt)).length===0&&(ot[yt]=mt)}else if(pt.type==="JSXSpreadAttribute"&&pt.argument.type==="Identifier"||pt.argument.type==="MemberExpression"){const ft=this.#e(pt.argument,n);typeof ft=="object"&&Object.keys(ft).forEach(yt=>{const mt=attributeNames_default[yt]||yt;S.filter(Rt=>Rt.test(mt)).length===0&&(ot[mt]=ft[yt])})}}),typeof ot.style=="string"&&(ot.style=parseStyle(ot.style));const ct=R.toLowerCase();return ct==="option"&&(at=at.props.children),React.createElement(lt||ct,ot,at)};render(){const t=(this.props.jsx||"").trim().replace(/<!DOCTYPE([^>]*)>/g,"");this.ParsedChildren=this.#n(t);const n=[...new Set(["jsx-parser",...String(this.props.className).split(" ")])].filter(Boolean).join(" ");return this.props.renderInWrapper?React.createElement("div",{className:n},this.ParsedChildren):this.ParsedChildren}}var source_default=JsxParser;const CountryFlag=({countryCode:e,className:t=""})=>{const[n,s]=React.useState(null),[a,o]=React.useState(!1);return React.useEffect(()=>{if(!e)return;const c=`https://purecatamphetamine.github.io/country-flag-icons/3x2/${e.toUpperCase()}.svg`;fetch(c,{method:"HEAD"}).then(d=>{d.ok?(s(c),o(!1)):o(!0)}).catch(()=>{o(!0)})},[e]),a||!n?jsxRuntime.jsx("span",{className:t,children:e}):jsxRuntime.jsx("img",{src:n,alt:`${e} flag`,className:`inline-block ${t}`,style:{width:"24px",height:"auto"}})},imgSizeMap$1={sm:100,md:200,lg:300,xl:400};async function fetchProductImagesList({apiOrigin:e,randmarSKU:t,signal:n}){const s=new URL(`/Product/${encodeURIComponent(t)}/Images`,e),a=await fetch(s.toString(),{method:"GET",credentials:"omit",headers:{Accept:"application/json"},signal:n});if(!a.ok)throw new Error(`Failed to load images list for ${t}: ${a.status}`);const o=await a.json();return Array.isArray(o)?o:o&&typeof o=="object"&&"Images"in o&&Array.isArray(o.Images)?o.Images:[]}function buildImageSrc({apiOrigin:e,randmarSKU:t,image:n,width:s,height:a}){const o=(n.Url??"").trim();if(o){if(o.startsWith("data:"))return o;try{const c=new URL(o,e),d=c.pathname.split("/").filter(Boolean),f=t.trim().toLowerCase(),R=at=>{try{return decodeURIComponent(at).toLowerCase()===f}catch{return at.toLowerCase()===f}},S=d.slice(-3),V=d.slice(-4);return(S.length===3&&S[0]?.toLowerCase()==="product"&&R(S[1]??"")&&S[2]?.toLowerCase()==="image"||V.length===4&&V[0]?.toLowerCase()==="product"&&R(V[1]??"")&&V[2]?.toLowerCase()==="image")&&(c.searchParams.set("width",String(Math.round(s))),c.searchParams.set("height",String(Math.round(a)))),c.toString()}catch{}}const l=new URL(`/Product/${encodeURIComponent(t)}/Image/${encodeURIComponent(String(n.ImageId))}`,e);return l.searchParams.set("width",String(Math.round(s))),l.searchParams.set("height",String(Math.round(a))),l.toString()}function buildLegacyImageSrc({apiOrigin:e,randmarSKU:t,width:n,height:s}){const a=new URL(`/Product/${encodeURIComponent(t)}/Image`,e);return a.searchParams.set("width",String(Math.round(n))),a.searchParams.set("height",String(Math.round(s))),a.toString()}const Placeholder$1=({size:e,alt:t})=>jsxRuntime.jsx("div",{className:"rounded-md bg-muted flex items-center justify-center",style:{width:e,height:e},"aria-label":t,children:jsxRuntime.jsx(ImageOff,{className:"h-1/2 w-1/2 text-muted-foreground"})});function ProductImageCarousel({randmarSKU:e,size:t="md",alt:n,className:s,fallback:a}){const o=imgSizeMap$1[t],l=React__namespace.useRef(null),c=useIntersectionObserver({elementRef:l,threshold:.1,rootMargin:"100px"}),d=useApiOrigin(),[f,R]=React__namespace.useState(null),[S,V]=React__namespace.useState(!1),[A,at]=React__namespace.useState(0),[lt,ot]=React__namespace.useState(!1),ct=React__namespace.useRef(!1),pt=React__namespace.useRef(new Set);React__namespace.useEffect(()=>{R(null),V(!1),at(0),ot(!1),ct.current=!1,pt.current.clear()},[e]),React__namespace.useEffect(()=>{if(!e||!c||f!==null||S)return;const zt=new AbortController;return(async()=>{try{const Kt=await fetchProductImagesList({apiOrigin:d,randmarSKU:e,signal:zt.signal});R(Kt)}catch(Kt){if(zt.signal.aborted)return;console.error("Failed to load product images list",{randmarSKU:e,error:Kt}),V(!0)}})(),()=>zt.abort()},[d,S,f,c,e]);const ft=React__namespace.useMemo(()=>f?[...f].sort((zt,Kt)=>{const Qt=zt.SortOrder??Number.POSITIVE_INFINITY,Wt=Kt.SortOrder??Number.POSITIVE_INFINITY;if(Qt!==Wt)return Qt-Wt;const qt=zt.IsPrimary===!0?0:1,Xt=Kt.IsPrimary===!0?0:1;return qt-Xt}):null,[f]),yt=React__namespace.useMemo(()=>{if(!ft?.length)return 0;const zt=ft.findIndex(Kt=>Kt.IsPrimary===!0);return zt>=0?zt:0},[ft]);React__namespace.useEffect(()=>{ft?.length&&(ct.current||(at(yt),ct.current=!0))},[yt,ft]);const mt=ft?.length??0,dt=React__namespace.useMemo(()=>{const zt=(n??"").trim();return zt?`${zt} (Product ${e})`:`Product ${e}`},[n,e]),Rt=React__namespace.useCallback(zt=>mt>1?`${dt} image ${zt+1}`:dt,[dt,mt]),Mt=ft?.[A],Dt=React__namespace.useMemo(()=>Mt?buildImageSrc({apiOrigin:d,randmarSKU:e,image:Mt,width:o*1.5,height:o*1.5}):null,[Mt,d,o,e]),$t=React__namespace.useCallback(zt=>{if(mt<=0)return;const Kt=(zt%mt+mt)%mt;at(Kt)},[mt]),Ht=React__namespace.useCallback(()=>$t(A-1),[A,$t]),Ct=React__namespace.useCallback(()=>$t(A+1),[A,$t]),Vt=React__namespace.useCallback(zt=>{if(!(mt<=1))switch(zt.key){case"ArrowLeft":zt.preventDefault(),Ht();break;case"ArrowRight":zt.preventDefault(),Ct();break;case"Home":zt.preventDefault(),$t(0);break;case"End":zt.preventDefault(),$t(mt-1);break}},[Ct,Ht,$t,mt]);if(React__namespace.useEffect(()=>{if(!ft?.length||mt<=1)return;const zt=(A-1+mt)%mt,Kt=(A+1)%mt,Qt=[zt,Kt];for(const Wt of Qt){const qt=ft[Wt];if(!qt)continue;const Xt=buildImageSrc({apiOrigin:d,randmarSKU:e,image:qt,width:o*1.5,height:o*1.5});if(pt.current.has(Xt))continue;pt.current.add(Xt);const dr=new Image;dr.src=Xt}},[A,d,o,e,mt,ft]),S)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:a??null});if(f===null&&c)return jsxRuntime.jsx("div",{className:s,ref:l,children:jsxRuntime.jsx(Skeleton,{className:"rounded-md",style:{width:o,height:o}})});if(ft&&ft.length===0){if(a!=null)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:a});const zt=buildLegacyImageSrc({apiOrigin:d,randmarSKU:e,width:o*1.5,height:o*1.5});return jsxRuntime.jsx("div",{className:s,ref:l,children:jsxRuntime.jsx("div",{className:"relative rounded-md overflow-hidden bg-muted",style:{width:o,height:o},"aria-label":dt,children:lt?jsxRuntime.jsx(Placeholder$1,{size:o,alt:dt}):jsxRuntime.jsx("img",{alt:dt,className:"w-full h-full object-contain",src:zt,width:o,height:o,loading:"eager",onError:()=>ot(!0)})})})}return Dt?jsxRuntime.jsx("div",{className:s,ref:l,children:jsxRuntime.jsxs("div",{className:"group relative rounded-md overflow-hidden bg-muted",style:{width:o,height:o},role:"region","aria-roledescription":"carousel","aria-label":`Product images for ${e}`,tabIndex:mt>1?0:-1,onKeyDown:Vt,children:[jsxRuntime.jsx("img",{alt:Rt(A),className:"w-full h-full object-contain",src:Dt,width:o,height:o,loading:"eager"}),mt>1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Button$1,{type:"button",variant:"secondary",size:"icon",className:"absolute left-2 top-1/2 -translate-y-1/2 bg-background/80 text-foreground shadow-sm ring-1 ring-border/50 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100",onClick:Ht,"aria-label":"Previous image",children:jsxRuntime.jsx(ChevronLeft,{className:"h-4 w-4"})}),jsxRuntime.jsx(Button$1,{type:"button",variant:"secondary",size:"icon",className:"absolute right-2 top-1/2 -translate-y-1/2 bg-background/80 text-foreground shadow-sm ring-1 ring-border/50 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100",onClick:Ct,"aria-label":"Next image",children:jsxRuntime.jsx(ChevronRight,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"absolute bottom-2 left-1/2 -translate-x-1/2 flex items-center gap-1 rounded-full bg-background/80 px-2 py-1",children:Array.from({length:mt}).map((zt,Kt)=>{const Qt=Kt===A;return jsxRuntime.jsx("button",{type:"button",className:["h-1.5 w-1.5 rounded-full transition-colors",Qt?"bg-foreground":"bg-muted-foreground/40 hover:bg-muted-foreground/60"].join(" "),onClick:()=>$t(Kt),"aria-label":`Go to image ${Kt+1} of ${mt}`,"aria-current":Qt?"true":void 0},Kt)})})]})]})}):jsxRuntime.jsx("div",{className:s,ref:l,children:jsxRuntime.jsx(Placeholder$1,{size:o,alt:dt})})}const getTodayIsoDate=()=>new Date().toISOString().split("T")[0],isOpportunityNotStartedYet=e=>e.StartDate?e.StartDate.split("T")[0]>getTodayIsoDate():!1,isOpportunitySelectable=e=>{if(e.Active!==!0)return!1;const t=getTodayIsoDate();return!(e.EndDate&&e.EndDate.split("T")[0]<t||e.StartDate&&e.StartDate.split("T")[0]>t)};function ProductCard({applicationId:e,product:t,viewProductLink:n,defaultOpportunityNumber:s="",onAddToCart:a,addingToCart:o=!1,shopifyHostname:l,customAction:c=jsxRuntime.jsx(jsxRuntime.Fragment,{})}){const d=reactRouterDom.useNavigate(),{toast:f}=useToast(),[R,S]=React.useState(1),[V,A]=React.useState(null),[at,lt]=React.useState(0),[ot,ct]=React.useState(!1),[pt]=usePostV4ResellerByRouteResellerIdProductAndRandmarSkuShopifyMutation(),[ft,yt]=React.useState(!1),[mt,dt]=React.useState(null),[Rt,Mt]=React.useState("idle"),[Dt,$t]=React.useState(null),[Ht]=useLazyGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery(),Ct=t?.Distribution?.Cost||0,Vt=t?.Distribution?.RegularPrice||0,Ft=t?.Distribution?.Price||0,zt=!!(e&&t?.RandmarSKU);React.useEffect(()=>{S(1),A(null),lt(0)},[t?.RandmarSKU]),React.useEffect(()=>{if(t&&s){const rr=t.Opportunities?.find(wr=>wr.BidNumber==s);rr&&isOpportunitySelectable(rr)&&A(rr)}},[t,s]),React.useEffect(()=>{if(!t)return;const rr=V?.Price?V.Price:Ft;lt(Vt>0?Math.round((Vt-rr)/Vt*100):0)},[t,V,Ft,Vt]),React.useEffect(()=>{o||S(1)},[o]),React.useEffect(()=>{if(!ft){dt(null),Mt("idle"),$t(null);return}if(!e||!t?.RandmarSKU){Mt("error"),$t("Missing identifiers to load performance data.");return}let rr=!1;const wr=t.RandmarSKU;return(async()=>{Mt("summary"),$t(null);try{const jr=await Ht({routeApplicationId:e,randmarSku:wr,withSpecification:!1});if(rr)return;if("error"in jr&&jr.error)throw jr.error;dt(jr.data??null),Mt("detailed");const Mr=await Ht({routeApplicationId:e,randmarSku:wr,withSpecification:!0});if(rr)return;if("error"in Mr&&Mr.error)throw Mr.error;dt(Mr.data??jr.data??null),Mt("complete")}catch(jr){if(rr)return;console.error("Failed to load performance data for product modal",jr),Mt("error"),$t("We couldn't load the performance details. Please try again.")}})(),()=>{rr=!0}},[e,Ht,ft,t?.RandmarSKU]);const Kt=rr=>rr>=90?{label:"Top 10% Bestseller",color:"text-primary",bgColor:"bg-primary/10"}:rr>=75?{label:"Bestseller",color:"text-info",bgColor:"bg-info/10"}:rr>=33?{label:"Popular",color:"text-success",bgColor:"bg-success/10"}:{label:"Rising",color:"text-muted-foreground",bgColor:"bg-muted/30"},Qt=Rt!=="complete"&&Rt!=="error",Wt=Rt==="summary"?40:Rt==="detailed"?80:10,qt=mt?.SalesStatistics??[],Xt=Qt?[]:qt,dr=mt?.RandmarTitle??t?.RandmarTitle??t?.RandmarSKU??"this product",cr=mt?.RandmarSKU??t?.RandmarSKU,hr=e&&t?.ManufacturerId?`/${encodeURIComponent(e)}/Partner/${encodeURIComponent(t.ManufacturerId)}?tab=manufacturer-overview`:null;if(!t)return jsxRuntime.jsx(Card,{className:"flex h-full w-full flex-col",children:jsxRuntime.jsxs(CardContent,{className:"flex h-full flex-col p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx("div",{className:"h-10 w-24 flex items-center justify-end ml-4",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-28 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-6 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsx("div",{className:"w-60 h-40",children:jsxRuntime.jsx(Skeleton,{className:"w-full h-full rounded-lg"})})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsx("div",{className:"flex flex-1",children:jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-24 mb-3"}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-full rounded-md"})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-32 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24 mt-4"})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-start gap-1 mb-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-10 flex-1 rounded-md"})]})]})]})});const mr=t?.Opportunities||[],sr=mr.length>0,vr=()=>{if(R==null){S(1);return}R>1&&S(R-1)},ur=()=>{if(R==null){S(1);return}S(R+1)},Rr=rr=>{const wr=Number.parseInt(rr.target.value,10);if(!isNaN(wr)&&wr>0){S(wr);return}S(void 0)},ar=()=>{(R==null||R<1)&&S(1)},nr=rr=>{try{return new Date(rr).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch(wr){return console.error(wr),rr.split("T")[0]||"N/A"}},xr=rr=>{const wr=typeof t?.MSRP=="number"&&t.MSRP>0?t.MSRP:typeof t?.MAP=="number"&&t.MAP>0?t.MAP:null;if(wr===null)return null;const _r=rr.Price??t?.Distribution?.Price;if(typeof _r!="number")return null;const jr=rr.Rebate??0,Mr=Math.max(_r-jr,0);return wr-Mr},Zt=()=>{typeof a<"u"&&a({quantity:R??1,bidNumber:V?.BidNumber??null})},Er=()=>{ot||!l||(ct(!0),pt({routeResellerId:e??"",randmarSku:t.RandmarSKU??"",shopifyHostName:l}).then(rr=>{if(rr.error){console.error("Error syncing to Shopify:",rr.error),f({title:"Product synced failed.",description:"Error syncing to Shopify:",variant:"destructive"});return}f({title:"Product synced",description:"Product synced to Shopify successfully",variant:"success"})}).catch(rr=>{console.error("Error syncing to Shopify:",rr),f({title:"Product synced failed.",description:"Error syncing to Shopify:",variant:"destructive"})}).finally(()=>{ct(!1)}))};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Card,{className:"flex h-full w-full flex-col hover:shadow-lg transition-shadow @container",children:jsxRuntime.jsxs(CardContent,{className:"flex h-full flex-col p-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-xl",children:t.Title||t.RandmarTitle}),jsxRuntime.jsx("div",{className:"w-24 h-10 flex items-center justify-end ml-4 flex-shrink-0",children:hr?jsxRuntime.jsx(reactRouterDom.Link,{to:hr,"aria-label":`Open manufacturer overview for ${t.ManufacturerName??"this manufacturer"}`,className:"block h-full w-full",children:jsxRuntime.jsx(PartnerLogo,{id:t.ManufacturerId,name:t.ManufacturerName,width:96,height:40,className:"cursor-pointer"},`partner_logo_${t.ManufacturerId}`)}):jsxRuntime.jsx(PartnerLogo,{id:t.ManufacturerId,name:t.ManufacturerName,width:96,height:40},`partner_logo_${t.ManufacturerId}`)})]}),jsxRuntime.jsxs("div",{className:"flex flex-col @[36rem]:flex-row gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-1 @[36rem]:order-1 order-2 flex flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 items-center justify-center @[36rem]:items-start @[36rem]:justify-start",children:[t.State&&jsxRuntime.jsxs(Badge,{variant:t.State==="Active"?"success":"destructive",className:"rounded-full px-3",children:[jsxRuntime.jsx(Check,{size:"12",className:"mr-1.5"})," ",t.State]}),jsxRuntime.jsxs(Badge,{variant:t.SerialNumber?"success":"warning",className:"rounded-full px-3",children:[jsxRuntime.jsx(QrCode,{size:"12",className:"mr-1.5"})," ",t.SerialNumber?"Serialized":"Unserialized"]}),t.TransparencyCode&&jsxRuntime.jsxs(Badge,{variant:"info",className:"rounded-full px-3",children:[jsxRuntime.jsx(CircleDashed,{size:"12",className:"mr-1.5"})," Transparency Code"]}),t.AvailableToBuy!==void 0&&jsxRuntime.jsxs(Badge,{variant:t.AvailableToBuy?"success":"destructive",className:"rounded-full px-3",children:[jsxRuntime.jsx(ShoppingCart,{size:"12",className:"mr-1.5"})," ",t.AvailableToBuy?"Available":"Unavailable"]}),t.ManufacturerCategory!==void 0&&t.ManufacturerCategory?.QualificationRequired&&jsxRuntime.jsxs(Badge,{variant:t.ManufacturerCategory?.QualificationRequired?"info":"secondary",className:"rounded-full px-3",children:[jsxRuntime.jsx(ShieldCheck,{size:"12",className:"mr-1.5"})," ",t.ManufacturerCategory?.QualificationRequired?"Qualified Only":"Available to all"]}),t.OpportunityOnly&&jsxRuntime.jsxs(Badge,{variant:"info",className:"rounded-full px-3",children:[jsxRuntime.jsx(ShieldCheck,{size:"12",className:"mr-1.5"})," ","Requires Opportunity"]}),t.ManufacturerId&&jsxRuntime.jsxs(Badge,{variant:t.AutoUpdate?"info":"secondary",className:"rounded-full px-3",children:[jsxRuntime.jsx(RefreshCw,{size:"12",className:"mr-1.5"})," ",t.AutoUpdate?`Automatic Reorder (${t.MasterCarton})`:"Manually Reorders"]}),jsxRuntime.jsxs(Badge,{variant:t.BodyHTML&&t.Title&&t.MAP?"success":"warning",className:"rounded-full px-3",children:[jsxRuntime.jsx(Store,{size:"12",className:"mr-1.5"})," ",t.BodyHTML&&t.Title&&t.MAP?"Shopify Ready":"Not Shopify Ready"]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-4 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"MPN"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.MPN||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"UPC"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.UPC||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Unit Weight"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.UnitWeight?`${formatNumber(t.UnitWeight)} lbs`:"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"text-sm text-muted-foreground",children:["MAP",jsxRuntime.jsx("span",{className:"text-primary",children:" / "}),"MSRP"]}),jsxRuntime.jsxs("div",{className:"font-medium",children:[t.MAP?formatMoney(t.MAP):"N/A",jsxRuntime.jsx("span",{className:"text-primary",children:" / "}),t.MSRP?formatMoney(t.MSRP):"N/A"]})]}),!!t.OverallPercentileRank&&!!t.ManufacturerPercentileRank&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:"Bestseller Status"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{children:"Global: "}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Badge,{variant:"outline",className:`rounded-full px-3 w-fit ${Kt(t.OverallPercentileRank).bgColor} ${Kt(t.OverallPercentileRank).color} hover:${Kt(t.OverallPercentileRank).bgColor}`,children:Kt(t.OverallPercentileRank).label})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["Percentile Rank: ",t.OverallPercentileRank]})})]})})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("span",{children:[t.ManufacturerName,": "]}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Badge,{variant:"outline",className:`rounded-full px-3 w-fit ${Kt(t.ManufacturerPercentileRank).bgColor} ${Kt(t.ManufacturerPercentileRank).color} hover:${Kt(t.ManufacturerPercentileRank).bgColor}`,children:Kt(t.ManufacturerPercentileRank).label})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["Percentile Rank: ",t.ManufacturerPercentileRank]})})]})})]})]})]}),t.CountryCodeOfOrigin&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Origin"}),jsxRuntime.jsxs("div",{className:"font-medium flex items-center",children:[jsxRuntime.jsx(CountryFlag,{countryCode:t.CountryCodeOfOrigin,className:"mr-2"}),t.CountryCodeOfOrigin]})]})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col @[36rem]:order-2 order-1 items-center",children:jsxRuntime.jsx(ProductImageCarousel,{randmarSKU:t.RandmarSKU||"",alt:t.RandmarTitle||"",fallback:jsxRuntime.jsx(ProductImage,{randmarSKU:t.RandmarSKU||"",alt:t.RandmarTitle||"",sceneName:t.SceneName},`product_image_fallback_${t.RandmarSKU}`)},`product_image_${t.RandmarSKU}`)})]}),jsxRuntime.jsx("div",{className:"flex flex-col @[36rem]:flex-row gap-6 mt-4",children:jsxRuntime.jsx("div",{className:"flex flex-1 @[36rem]:order-1 order-2",children:sr&&t.Distribution&&jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx("div",{className:"flex items-center",children:"You have "+mr.length+(mr.length>1?" opportunities":" opportunity")+" for this product:"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsx("div",{className:"space-y-2 max-h-[200px] overflow-y-auto p-2 mt-1",children:mr.map((rr,wr)=>{const _r=xr(rr);return isOpportunitySelectable(rr)?jsxRuntime.jsxs("div",{className:`flex justify-between items-center rounded-lg transition-colors py-2 px-4 border cursor-pointer ${rr.BidNumber==V?.BidNumber?"bg-primary/10 border-2 border-primary":"bg-background border-border hover:bg-muted/30"}`,onClick:()=>{A(rr.BidNumber!==V?.BidNumber?rr:null)},children:[jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-medium text-sm",children:rr.Opportunity}),jsxRuntime.jsx("span",{className:"text-xs text-foreground",children:rr.BidNumber})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end",children:[jsxRuntime.jsx("span",{className:"font-semibold",children:formatMoney(rr.Price??0)}),rr.Rebate&&rr.Rebate>0&&jsxRuntime.jsxs("span",{className:"text-xs text-success",children:["Rebate: ",formatMoney(rr.Rebate)]}),_r!==null&&jsxRuntime.jsxs("span",{className:"text-xs text-info",children:["Potential Revenue: ",formatMoney(_r)]}),rr.EndDate&&jsxRuntime.jsxs("span",{className:"text-xs text-muted-foreground",children:["Ends: ",nr(rr.EndDate)]})]})]},wr):jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex justify-between items-center rounded-lg transition-colors py-2 px-4 bg-muted/30 border border-border cursor-pointer hover:bg-muted/40",onClick:()=>{rr.BidNumber&&d(`/${e}/Opportunity/${rr.ManufacturerId}/${rr.BidNumber}`)},children:[jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-medium text-sm",children:rr.Opportunity}),jsxRuntime.jsxs("span",{className:"text-xs text-foreground",children:[rr.BidNumber," ",jsxRuntime.jsx(Badge,{variant:"secondary",className:"text-xs mx-1 h-5",children:isOpportunityNotStartedYet(rr)&&rr.StartDate?`Starts ${nr(rr.StartDate)}`:"Currently unavailable"})]})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end",children:[jsxRuntime.jsx("span",{className:"font-semibold",children:formatMoney(rr.Price??0)}),rr.Rebate&&rr.Rebate>0&&jsxRuntime.jsxs("span",{className:"text-xs text-success",children:["Rebate: ",formatMoney(rr.Rebate)]}),_r!==null&&jsxRuntime.jsxs("span",{className:"text-xs text-info",children:["Potential Revenue: ",formatMoney(_r)]}),rr.EndDate&&jsxRuntime.jsxs("span",{className:"text-xs text-muted-foreground",children:["Ends: ",nr(rr.EndDate)]})]})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"View Opportunity"})})]},wr)})})})]})})})]}),jsxRuntime.jsxs("div",{className:"mt-4 flex flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-row flex-wrap justify-between items-end gap-4",children:[jsxRuntime.jsx("div",{className:"flex flex-col gap-3 flex-1",children:t.Distribution&&jsxRuntime.jsx("div",{className:"flex flex-col gap-1",children:Ct>0?jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("span",{className:"text-2xl font-bold whitespace-nowrap",children:["Cost: ",formatMoney(Ct)]})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap",children:[Vt>0&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("span",{className:"text-2xl font-bold whitespace-nowrap",children:formatMoney((V?t.Opportunities?.find(rr=>rr.BidNumber==V.BidNumber)?.Price:Ft)??0)})}),at>0&&jsxRuntime.jsx("span",{className:"text-muted-foreground line-through ml-2 whitespace-nowrap",children:formatMoney(Vt)})]}),at>0&&jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs(Badge,{variant:"info",className:"rounded-full px-3 whitespace-nowrap",children:[jsxRuntime.jsxs("span",{children:[at,"% OFF"]}),t.InstantRebate?.EndDate&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",t.InstantRebate.EndDate.split("T")[0]]}),V?.EndDate&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",V.EndDate.split("T")[0]]})]})})]})})}),jsxRuntime.jsxs("div",{className:"flex flex-col justify-center @[36rem]:justify-end items-end gap-2 w-full @[36rem]:w-auto",children:[l&&jsxRuntime.jsx(Button$1,{className:"gap-2 whitespace-nowrap",onClick:Er,disabled:ot,children:ot?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2"}),"Sync to Shopify"]})}),c,typeof a<"u"&&jsxRuntime.jsxs("div",{className:"flex gap-2 whitespace-nowrap",children:[jsxRuntime.jsxs("div",{className:"flex items-center border rounded-md",children:[jsxRuntime.jsx(Button$1,{variant:"ghost",size:"icon",className:"rounded-r-none",onClick:vr,disabled:typeof R<"u"&&(R<=1||!t.AvailableToBuy||o),children:"-"}),jsxRuntime.jsx("input",{value:R,onChange:Rr,onBlur:ar,onClick:rr=>rr.currentTarget.select(),className:`w-6 @[36rem]:w-12 text-center border-0 bg-transparent text-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${!t.AvailableToBuy||o?"text-muted-foreground":""}`,disabled:!t.AvailableToBuy||o}),jsxRuntime.jsx(Button$1,{variant:"ghost",size:"icon",className:"rounded-l-none",onClick:ur,disabled:!t.AvailableToBuy||o,children:"+"})]}),jsxRuntime.jsx(Button$1,{className:"gap-2 whitespace-nowrap",onClick:Zt,disabled:!t.AvailableToBuy||o,children:o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}),"Adding..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2"}),"Add to Cart"]})})]})]})]}),jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-2 @[36rem]:flex-row",children:[jsxRuntime.jsx("div",{className:"flex-1 min-w-[10rem]",children:jsxRuntime.jsxs(Button$1,{variant:"outline",type:"button",className:"h-11 px-4 text-sm font-medium justify-start w-full",onClick:()=>yt(!0),disabled:!zt,children:[jsxRuntime.jsx(ChartLine,{className:"mr-2"}),"View statistics"]})}),jsxRuntime.jsx("div",{className:"flex-1 min-w-[10rem]",children:jsxRuntime.jsx(ProductInventoryButton,{applicationId:e??"",randmarSku:t.RandmarSKU??"",inventory:t.Distribution?.Inventory,buttonSize:"lg",buttonClassName:"w-full h-11 justify-start"})}),n&&jsxRuntime.jsx(reactRouterDom.Link,{to:n,className:"flex-1 min-w-[10rem]",children:jsxRuntime.jsxs(Button$1,{variant:"outline",className:"h-11 px-4 text-sm font-medium justify-start w-full",children:[jsxRuntime.jsx(Eye,{className:"mr-2"}),"View Product"]})})]})]})]})}),jsxRuntime.jsx(Dialog,{open:ft,onOpenChange:yt,children:jsxRuntime.jsxs(DialogContent,{className:"w-[min(95vw,1100px)] max-w-5xl space-y-6",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Monthly Sales Performance"}),jsxRuntime.jsxs(DialogDescription,{children:["Expanded product insights for ",dr,cr?` (SKU ${cr})`:""]})]}),jsxRuntime.jsx("div",{className:"space-y-6",children:Dt?jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(AlertTitle,{children:"Unable to load details"}),jsxRuntime.jsx(AlertDescription,{children:Dt})]}):jsxRuntime.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[jsxRuntime.jsxs("div",{className:"mb-4 space-y-2",children:[jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Rolling 12-month sales dollars and units sold pulled from the detailed endpoint."}),Qt&&jsxRuntime.jsx("div",{"aria-live":"polite","aria-busy":"true",children:jsxRuntime.jsx(Progress,{value:Wt,className:"h-2 w-full animate-pulse","aria-label":"Loading performance data"})})]}),jsxRuntime.jsx(SalesChart,{statistics:Xt,mode:"month",chartHeight:320}),Qt&&jsxRuntime.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"Gathering product summary and sales statistics..."})]})})]})})]})}const complexComponents=[`----
|
|
509
509
|
PartnerCard: For data that fits this shape:
|
|
510
510
|
{ "ApplicationId": "19022", "PublicName": "BiOSS", "About": "example", "IsReseller": true, "IsManufacturer": true, "IsSalesAgency": false, "Socials": [ { "ApplicationId": "19022", "SocialNetwork": "Facebook", "Tag": "@bioss.ca" }, { "ApplicationId": "19022", "SocialNetwork": "Instagram", "Tag": "@bioss.ca" }, { "ApplicationId": "19022", "SocialNetwork": "LinkedIn", "Tag": "@biossinc" }, { "ApplicationId": "19022", "SocialNetwork": "Youtube", "Tag": "@biosssolutionssanitairessa4095" } ], "Manufacturer": null, "Reseller": null }
|
|
511
511
|
Use <PartnerCard account={data} action={<></>}>`,`----
|