randmarcomps 1.120.0 → 1.121.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.d.ts +8 -0
- package/dist/randmarcomps.js +11 -1
- package/dist/randmarcomps.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/randmarcomps.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
|
7
7
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
8
8
|
import { FC } from 'react';
|
|
9
9
|
import { ForwardRefExoticComponent } from 'react';
|
|
10
|
+
import { GeneralDocument } from 'randmar-api-client';
|
|
10
11
|
import { InputProps as InputProps_2 } from './input';
|
|
11
12
|
import { Inventory } from 'randmar-api-client';
|
|
12
13
|
import { JSX } from 'react/jsx-runtime';
|
|
@@ -202,6 +203,13 @@ export declare const DropdownMenuSubTrigger: React_2.ForwardRefExoticComponent<O
|
|
|
202
203
|
|
|
203
204
|
export declare const DropdownMenuTrigger: React_2.ForwardRefExoticComponent<DropdownMenuPrimitive.DropdownMenuTriggerProps & React_2.RefAttributes<HTMLButtonElement>>;
|
|
204
205
|
|
|
206
|
+
export declare function GeneralDocumentCard({ document, loading }: GeneralDocumentCardProps): JSX.Element;
|
|
207
|
+
|
|
208
|
+
export declare interface GeneralDocumentCardProps {
|
|
209
|
+
document?: GeneralDocument;
|
|
210
|
+
loading?: boolean;
|
|
211
|
+
}
|
|
212
|
+
|
|
205
213
|
export declare const Input: React_2.ForwardRefExoticComponent<Omit<InputProps, "ref"> & React_2.RefAttributes<HTMLInputElement>>;
|
|
206
214
|
|
|
207
215
|
export declare function InputOTP({ className, containerClassName, ...props }: React_2.ComponentProps<typeof OTPInput> & {
|
package/dist/randmarcomps.js
CHANGED
|
@@ -46154,12 +46154,14 @@ const getComponent = (e, t) => {
|
|
|
46154
46154
|
return handleSearchResults(t);
|
|
46155
46155
|
case "/Product/{productNumber}":
|
|
46156
46156
|
return handleProduct(t);
|
|
46157
|
+
case "/V4/Reseller/{routeResellerId}/Documents/GeneralDocuments":
|
|
46158
|
+
return handleGeneralDocuments(t);
|
|
46157
46159
|
default:
|
|
46158
46160
|
console.log("no component mapping for path", e);
|
|
46159
46161
|
break;
|
|
46160
46162
|
}
|
|
46161
46163
|
return null;
|
|
46162
|
-
}, handleProduct = (e) => {
|
|
46164
|
+
}, handleGeneralDocuments = (e) => Array.isArray(e) ? /* @__PURE__ */ jsx(Fragment, { children: e.map((n) => /* @__PURE__ */ jsx("div", { className: "mt-2 mb-2", children: /* @__PURE__ */ jsx(GeneralDocumentCard, { document: n }) })) }) : null, handleProduct = (e) => {
|
|
46163
46165
|
const t = e;
|
|
46164
46166
|
return t.MPN ? /* @__PURE__ */ jsx("div", { className: "mt-2 mb-2", children: /* @__PURE__ */ jsx(ProductCard, { item: t }) }) : null;
|
|
46165
46167
|
}, handleSearchResults = (e) => {
|
|
@@ -50690,6 +50692,13 @@ function ManufacturerLogo({ manufacturerId: e, opportunityNumber: t }) {
|
|
|
50690
50692
|
f && /* @__PURE__ */ jsx("div", { className: "text-red-500 text-xs mt-1", role: "alert", children: f })
|
|
50691
50693
|
] });
|
|
50692
50694
|
}
|
|
50695
|
+
function GeneralDocumentCard({ document: e, loading: t = !1 }) {
|
|
50696
|
+
return t ? /* @__PURE__ */ jsx("div", { children: "loading..." }) : /* @__PURE__ */ jsxs("div", { children: [
|
|
50697
|
+
e == null ? void 0 : e.OrderNumber,
|
|
50698
|
+
" for P.O. ",
|
|
50699
|
+
e == null ? void 0 : e.PONumber
|
|
50700
|
+
] });
|
|
50701
|
+
}
|
|
50693
50702
|
export {
|
|
50694
50703
|
ActiveOrdersCard,
|
|
50695
50704
|
AreaChart,
|
|
@@ -50732,6 +50741,7 @@ export {
|
|
|
50732
50741
|
DropdownMenuSubContent,
|
|
50733
50742
|
DropdownMenuSubTrigger,
|
|
50734
50743
|
DropdownMenuTrigger,
|
|
50744
|
+
GeneralDocumentCard,
|
|
50735
50745
|
Input,
|
|
50736
50746
|
InputOTP,
|
|
50737
50747
|
InputOTPGroup,
|
|
@@ -895,7 +895,7 @@ Hook ${d} was either not provided or not a function.`)}return{name:reactHooksMod
|
|
|
895
895
|
* limitations under the License.
|
|
896
896
|
*/class GoogleGenerativeAI{constructor(t){this.apiKey=t}getGenerativeModel(t,n){if(!t.model)throw new GoogleGenerativeAIError("Must provide a model name. Example: genai.getGenerativeModel({ model: 'my-model-name' })");return new GenerativeModel(this.apiKey,t,n)}getGenerativeModelFromCachedContent(t,n,i){if(!t.name)throw new GoogleGenerativeAIRequestInputError("Cached content must contain a `name` field.");if(!t.model)throw new GoogleGenerativeAIRequestInputError("Cached content must contain a `model` field.");const o=["model","systemInstruction"];for(const u of o)if(n!=null&&n[u]&&t[u]&&(n==null?void 0:n[u])!==t[u]){if(u==="model"){const d=n.model.startsWith("models/")?n.model.replace("models/",""):n.model,f=t.model.startsWith("models/")?t.model.replace("models/",""):t.model;if(d===f)continue}throw new GoogleGenerativeAIRequestInputError(`Different value for "${u}" specified in modelParams (${n[u]}) and cachedContent (${t[u]})`)}const l=Object.assign(Object.assign({},n),{model:t.model,tools:t.tools,toolConfig:t.toolConfig,systemInstruction:t.systemInstruction,cachedContent:t});return new GenerativeModel(this.apiKey,l,i)}}const bodyKey="TheRequestBody";async function fetchApiFunctions(){var e,t;try{const n=await fetch("https://api.randmar.io/swagger/V4/swagger.json");if(!n.ok)throw new Error("Failed to fetch Swagger spec");const i=await n.json(),o=[];for(const[l,u]of Object.entries(i.paths)){const d=["get","post","put","delete"];for(const f of d){const p=u[f];if(!p||p["x-allowed-for-chatbots"]!==!0)continue;const m=l.split("/").filter(Boolean);let g=`${f}_${m.slice(1).join("_")}`;g=g.replace(/[^a-zA-Z0-9_.-]/g,"_"),g.length>60&&(g=g.substring(0,60));const b={},_=[];(e=p.parameters)==null||e.forEach(C=>{b[C.name]={type:C.schema.type,description:C.description||`The ${C.name} parameter`},C.required&&_.push(C.name)});const E=((t=p.parameters)==null?void 0:t.filter(C=>C.in==="path").map(C=>C.name))||[];(f==="post"||f==="put")&&p.requestBody&&(b[bodyKey]={type:SchemaType.STRING,description:p.requestBody.description||"Request body content"},_.push(bodyKey));const R={name:g,description:p.description?`${p.summary}
|
|
897
897
|
|
|
898
|
-
${p.description}`:p.summary||`${f.toUpperCase()} ${m[m.length-1]}`,parameters:{type:SchemaType.OBJECT,properties:b,required:_}},S=async C=>{var A;try{let I=`https://api.randmar.io${l}`;console.log(`[API Function] ${g} called with args:`,C),console.log(`[API Function] Original URL: ${I}`),E.forEach(L=>{const F=`{${L}}`,V=L;I=I.replace(F,C[V])}),console.log(`[API Function] Final URL: ${I}`);const M=localStorage.getItem("access_token"),T={method:f.toUpperCase(),headers:{Authorization:M?`Bearer ${M}`:"","Content-Type":"application/json"}},O=[];if((((A=p.parameters)==null?void 0:A.filter(L=>L.in==="query"))||[]).forEach(L=>{const F=L.name,V=C[F];V&&O.push(`${L.name}=${encodeURIComponent(V)}`)}),O.length>0&&(I+=`?${O.join("&")}`),f==="post"||f==="put"){const F=C[bodyKey];F&&(T.body=F)}console.log(`[API Function] Making request to: ${I}`),console.log("[API Function] Request options:",T);const N=await fetch(I,T);if(console.log(`[API Function] Response status: ${N.status}`),!N.ok){const L=await N.text();throw console.error(`[API Function] Error response: ${L}`),new Error(`Error ${N.status}: ${L}`)}const D=await N.json();console.log("[API Function] Response data:",D);const B=getComponent(l,D);return B?{component:B,summary:JSON.stringify(D,null,2)}:JSON.stringify(D,null,2)}catch(I){return console.error(`Error in ${g}:`,I),`I'm sorry, I couldn't retrieve the requested information. Error: ${I instanceof Error?I.message:"Unknown error"}`}};o.push({declaration:R,handler:S})}}return console.log(o),o}catch(n){return console.error("Error fetching API functions:",n),[]}}const getComponent=(e,t)=>{switch(e){case"/V4/Partner/{routeApplicationId}/Search":return handleSearchResults(t);case"/Product/{productNumber}":return handleProduct(t);default:console.log("no component mapping for path",e);break}return null},handleProduct=e=>{const t=e;return t.MPN?jsxRuntime.jsx("div",{className:"mt-2 mb-2",children:jsxRuntime.jsx(ProductCard,{item:t})}):null},handleSearchResults=e=>{if(!Array.isArray(e))return null;const n=e.filter(i=>i.ContentType==="Product").map(i=>i.Content).filter(i=>i.MPN);return n.length==0?null:jsxRuntime.jsx(jsxRuntime.Fragment,{children:n.map(i=>jsxRuntime.jsx("div",{className:"mt-2 mb-2",children:jsxRuntime.jsx(ProductCard,{item:i})}))})};function useAIAssistant({userId:e,apiKey:t}){const[n,i]=React.useState(!1),[o,l]=React.useState(null),[u,d]=React.useState([]),[f,p]=React.useState([]),[m,g]=React.useState([]),[b,_]=React.useState(""),E=new GoogleGenerativeAI(t),[R]=useLazyGetV4PartnerByApplicationIdAccountQuery();React.useEffect(()=>{b&&p(I=>[...I,"System instructions updated."])},[b]),React.useEffect(()=>{o&&p(I=>[...I,"Gemini session initialized."])},[o]),React.useEffect(()=>{(async()=>{try{const T=await(await fetch("https://docs.google.com/document/d/e/2PACX-1vT-f5SWSJ2BcRUcyiumzT1aPUeC8kyyV7ryJTTymWJWOcRbDRgV5nX6Wyh7HaSPf8rxTY9w63Q2C8rG/pub")).text(),D=new DOMParser().parseFromString(T,"text/html").querySelector(".doc-content").innerHTML.replace(/__user_id__/g,e);console.log("google doc fetched: ",D),_(D)}catch(M){console.error("Error fetching system instructions:",M),_("You are a helpful assistant, but cannot help the user right now. They should come back another time.")}})()},[]),React.useEffect(()=>{const I=async()=>{try{const T=E.getGenerativeModel({model:"gemini-2.0-flash"}).startChat({generationConfig:{maxOutputTokens:4096},history:[{role:"user",parts:[{text:"Tell me about your instructions. What are the rules that define how you respond?"}]},{role:"model",parts:[{text:b}]}],tools:m.length>0?[{functionDeclarations:m.map(({declaration:O})=>O)}]:[]});l(T)}catch(M){console.error("Error initializing chat:",M)}};o||m.length!==0&&b!==""&&I()},[m,o,b]),React.useEffect(()=>{(async()=>{try{const M=await fetchApiFunctions(),T={declaration:{name:"set_on_behalf_id",description:"Call this function when the user wants to act on behalf of another one. It will return to you important flags such as: is user specified by the user ID a reseller, manufacturer or an agency?",parameters:{type:SchemaType.OBJECT,properties:{user_id:{type:SchemaType.STRING,description:"The user ID to use going forward."}},required:["user_id"]}},handler:async function(O){const N=O["user_id"],D=await R({applicationId:N});return{component:jsxRuntime.jsx(PartnerCard,{account:D.data}),summary:`OK. Using ${N} going forward as the user ID. Full data with important flags: ${JSON.stringify(D.data)}`}}};g([...M,T])}catch(M){console.error("Error loading API functions:",M)}})()},[]);const S=Object.fromEntries(m.map(({declaration:I,handler:M})=>[I.name,M])),C=async I=>{var N;const M=I.name;if(!(M in S)){console.error(`Function ${M} not found`);return}const T=S[M],O=I.args||{};if(console.log(`[Function Call] ${M} with args:`,O),!((N=m.find(D=>D.declaration.name===M))==null?void 0:N.declaration)){console.error(`[Function Call] Could not find declaration for ${M}`);return}try{p(G=>[...G,`Calling ${M} with:
|
|
898
|
+
${p.description}`:p.summary||`${f.toUpperCase()} ${m[m.length-1]}`,parameters:{type:SchemaType.OBJECT,properties:b,required:_}},S=async C=>{var A;try{let I=`https://api.randmar.io${l}`;console.log(`[API Function] ${g} called with args:`,C),console.log(`[API Function] Original URL: ${I}`),E.forEach(L=>{const F=`{${L}}`,V=L;I=I.replace(F,C[V])}),console.log(`[API Function] Final URL: ${I}`);const M=localStorage.getItem("access_token"),T={method:f.toUpperCase(),headers:{Authorization:M?`Bearer ${M}`:"","Content-Type":"application/json"}},O=[];if((((A=p.parameters)==null?void 0:A.filter(L=>L.in==="query"))||[]).forEach(L=>{const F=L.name,V=C[F];V&&O.push(`${L.name}=${encodeURIComponent(V)}`)}),O.length>0&&(I+=`?${O.join("&")}`),f==="post"||f==="put"){const F=C[bodyKey];F&&(T.body=F)}console.log(`[API Function] Making request to: ${I}`),console.log("[API Function] Request options:",T);const N=await fetch(I,T);if(console.log(`[API Function] Response status: ${N.status}`),!N.ok){const L=await N.text();throw console.error(`[API Function] Error response: ${L}`),new Error(`Error ${N.status}: ${L}`)}const D=await N.json();console.log("[API Function] Response data:",D);const B=getComponent(l,D);return B?{component:B,summary:JSON.stringify(D,null,2)}:JSON.stringify(D,null,2)}catch(I){return console.error(`Error in ${g}:`,I),`I'm sorry, I couldn't retrieve the requested information. Error: ${I instanceof Error?I.message:"Unknown error"}`}};o.push({declaration:R,handler:S})}}return console.log(o),o}catch(n){return console.error("Error fetching API functions:",n),[]}}const getComponent=(e,t)=>{switch(e){case"/V4/Partner/{routeApplicationId}/Search":return handleSearchResults(t);case"/Product/{productNumber}":return handleProduct(t);case"/V4/Reseller/{routeResellerId}/Documents/GeneralDocuments":return handleGeneralDocuments(t);default:console.log("no component mapping for path",e);break}return null},handleGeneralDocuments=e=>{if(!Array.isArray(e))return null;const t=e;return jsxRuntime.jsx(jsxRuntime.Fragment,{children:t.map(n=>jsxRuntime.jsx("div",{className:"mt-2 mb-2",children:jsxRuntime.jsx(GeneralDocumentCard,{document:n})}))})},handleProduct=e=>{const t=e;return t.MPN?jsxRuntime.jsx("div",{className:"mt-2 mb-2",children:jsxRuntime.jsx(ProductCard,{item:t})}):null},handleSearchResults=e=>{if(!Array.isArray(e))return null;const n=e.filter(i=>i.ContentType==="Product").map(i=>i.Content).filter(i=>i.MPN);return n.length==0?null:jsxRuntime.jsx(jsxRuntime.Fragment,{children:n.map(i=>jsxRuntime.jsx("div",{className:"mt-2 mb-2",children:jsxRuntime.jsx(ProductCard,{item:i})}))})};function useAIAssistant({userId:e,apiKey:t}){const[n,i]=React.useState(!1),[o,l]=React.useState(null),[u,d]=React.useState([]),[f,p]=React.useState([]),[m,g]=React.useState([]),[b,_]=React.useState(""),E=new GoogleGenerativeAI(t),[R]=useLazyGetV4PartnerByApplicationIdAccountQuery();React.useEffect(()=>{b&&p(I=>[...I,"System instructions updated."])},[b]),React.useEffect(()=>{o&&p(I=>[...I,"Gemini session initialized."])},[o]),React.useEffect(()=>{(async()=>{try{const T=await(await fetch("https://docs.google.com/document/d/e/2PACX-1vT-f5SWSJ2BcRUcyiumzT1aPUeC8kyyV7ryJTTymWJWOcRbDRgV5nX6Wyh7HaSPf8rxTY9w63Q2C8rG/pub")).text(),D=new DOMParser().parseFromString(T,"text/html").querySelector(".doc-content").innerHTML.replace(/__user_id__/g,e);console.log("google doc fetched: ",D),_(D)}catch(M){console.error("Error fetching system instructions:",M),_("You are a helpful assistant, but cannot help the user right now. They should come back another time.")}})()},[]),React.useEffect(()=>{const I=async()=>{try{const T=E.getGenerativeModel({model:"gemini-2.0-flash"}).startChat({generationConfig:{maxOutputTokens:4096},history:[{role:"user",parts:[{text:"Tell me about your instructions. What are the rules that define how you respond?"}]},{role:"model",parts:[{text:b}]}],tools:m.length>0?[{functionDeclarations:m.map(({declaration:O})=>O)}]:[]});l(T)}catch(M){console.error("Error initializing chat:",M)}};o||m.length!==0&&b!==""&&I()},[m,o,b]),React.useEffect(()=>{(async()=>{try{const M=await fetchApiFunctions(),T={declaration:{name:"set_on_behalf_id",description:"Call this function when the user wants to act on behalf of another one. It will return to you important flags such as: is user specified by the user ID a reseller, manufacturer or an agency?",parameters:{type:SchemaType.OBJECT,properties:{user_id:{type:SchemaType.STRING,description:"The user ID to use going forward."}},required:["user_id"]}},handler:async function(O){const N=O["user_id"],D=await R({applicationId:N});return{component:jsxRuntime.jsx(PartnerCard,{account:D.data}),summary:`OK. Using ${N} going forward as the user ID. Full data with important flags: ${JSON.stringify(D.data)}`}}};g([...M,T])}catch(M){console.error("Error loading API functions:",M)}})()},[]);const S=Object.fromEntries(m.map(({declaration:I,handler:M})=>[I.name,M])),C=async I=>{var N;const M=I.name;if(!(M in S)){console.error(`Function ${M} not found`);return}const T=S[M],O=I.args||{};if(console.log(`[Function Call] ${M} with args:`,O),!((N=m.find(D=>D.declaration.name===M))==null?void 0:N.declaration)){console.error(`[Function Call] Could not find declaration for ${M}`);return}try{p(G=>[...G,`Calling ${M} with:
|
|
899
899
|
${JSON.stringify(O,null,2)}`]);const D=await T(O);let B,L=null,F=!1;if(typeof D=="string"?B=D:(B=D.summary,L=D.component,F=!0),p(G=>[...G,`${M} returned ${B.length} character(s).`]),console.log(`[Function Response] ${M} returned:`,B),!o)return;const V={functionResponse:{name:M,response:{content:B}}};if(F&&L){const G={role:"assistant",content:L,timestamp:new Date,isComponent:!0};d(K=>[...K,G])}const z={role:"assistant",content:(await o.sendMessage([V])).response.text(),timestamp:new Date};d(G=>[...G,z])}catch(D){p(L=>[...L,`${M} failed.`]),console.error("Error executing function:",D);const B={role:"assistant",content:"I encountered an error while processing your request. Please try again.",timestamp:new Date};d(L=>[...L,B])}};return{handleSubmitToBot:async I=>{if(I.trim()&&!n&&o){const M={role:"user",content:I,timestamp:new Date};d(T=>[...T,M]),i(!0);try{const O=(await o.sendMessage(I.trim())).response,j=O.functionCalls();if(j&&j.length>0)for(const N of j)await C(N);else{const N={role:"assistant",content:O.text(),timestamp:new Date};d(D=>[...D,N])}}catch(T){console.error("Error sending message:",T);const O={role:"assistant",content:"I'm sorry, I encountered an error processing your request. Please try again later.",timestamp:new Date};d(j=>[...j,O])}finally{i(!1)}}},botMessages:u,botReady:!!o,isProcessingSubmission:n,debugMessages:f}}function _getDefaults(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let _defaults=_getDefaults();function changeDefaults(e){_defaults=e}const noopTest={exec:()=>null};function edit(e,t=""){let n=typeof e=="string"?e:e.source;const i={replace:(o,l)=>{let u=typeof l=="string"?l:l.source;return u=u.replace(other.caret,"$1"),n=n.replace(o,u),i},getRegex:()=>new RegExp(n,t)};return i}const other={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},newline=/^(?:[ \t]*(?:\n|$))+/,blockCode=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,fences=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,bullet=/(?:[*+-]|\d{1,9}[.)])/,lheadingCore=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,lheading=edit(lheadingCore).replace(/bull/g,bullet).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),lheadingGfm=edit(lheadingCore).replace(/bull/g,bullet).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),_paragraph=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,blockText=/^[^\n]+/,_blockLabel=/(?!\s*\])(?:\\.|[^\[\]\\])+/,def=edit(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",_blockLabel).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),list=edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,bullet).getRegex(),_tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",_comment=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,html=edit("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",_comment).replace("tag",_tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),paragraph=edit(_paragraph).replace("hr",hr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",_tag).getRegex(),blockquote=edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",paragraph).getRegex(),blockNormal={blockquote,code:blockCode,def,fences,heading,hr,html,lheading,list,newline,paragraph,table:noopTest,text:blockText},gfmTable=edit("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",hr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",_tag).getRegex(),blockGfm={...blockNormal,lheading:lheadingGfm,table:gfmTable,paragraph:edit(_paragraph).replace("hr",hr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",gfmTable).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",_tag).getRegex()},blockPedantic={...blockNormal,html:edit(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",_comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:noopTest,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:edit(_paragraph).replace("hr",hr).replace("heading",` *#{1,6} *[^
|
|
900
900
|
]`).replace("lheading",lheading).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},escape$1=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,inlineCode=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br=/^( {2,}|\\)\n(?!\s*$)/,inlineText=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,_punctuation=/[\p{P}\p{S}]/u,_punctuationOrSpace=/[\s\p{P}\p{S}]/u,_notPunctuationOrSpace=/[^\s\p{P}\p{S}]/u,punctuation=edit(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,_punctuationOrSpace).getRegex(),_punctuationGfmStrongEm=/(?!~)[\p{P}\p{S}]/u,_punctuationOrSpaceGfmStrongEm=/(?!~)[\s\p{P}\p{S}]/u,_notPunctuationOrSpaceGfmStrongEm=/(?:[^\s\p{P}\p{S}]|~)/u,blockSkip=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,emStrongLDelimCore=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,emStrongLDelim=edit(emStrongLDelimCore,"u").replace(/punct/g,_punctuation).getRegex(),emStrongLDelimGfm=edit(emStrongLDelimCore,"u").replace(/punct/g,_punctuationGfmStrongEm).getRegex(),emStrongRDelimAstCore="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",emStrongRDelimAst=edit(emStrongRDelimAstCore,"gu").replace(/notPunctSpace/g,_notPunctuationOrSpace).replace(/punctSpace/g,_punctuationOrSpace).replace(/punct/g,_punctuation).getRegex(),emStrongRDelimAstGfm=edit(emStrongRDelimAstCore,"gu").replace(/notPunctSpace/g,_notPunctuationOrSpaceGfmStrongEm).replace(/punctSpace/g,_punctuationOrSpaceGfmStrongEm).replace(/punct/g,_punctuationGfmStrongEm).getRegex(),emStrongRDelimUnd=edit("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,_notPunctuationOrSpace).replace(/punctSpace/g,_punctuationOrSpace).replace(/punct/g,_punctuation).getRegex(),anyPunctuation=edit(/\\(punct)/,"gu").replace(/punct/g,_punctuation).getRegex(),autolink=edit(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),_inlineComment=edit(_comment).replace("(?:-->|$)","-->").getRegex(),tag=edit("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",_inlineComment).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),_inlineLabel=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,link=edit(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",_inlineLabel).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),reflink=edit(/^!?\[(label)\]\[(ref)\]/).replace("label",_inlineLabel).replace("ref",_blockLabel).getRegex(),nolink=edit(/^!?\[(ref)\](?:\[\])?/).replace("ref",_blockLabel).getRegex(),reflinkSearch=edit("reflink|nolink(?!\\()","g").replace("reflink",reflink).replace("nolink",nolink).getRegex(),inlineNormal={_backpedal:noopTest,anyPunctuation,autolink,blockSkip,br,code:inlineCode,del:noopTest,emStrongLDelim,emStrongRDelimAst,emStrongRDelimUnd,escape:escape$1,link,nolink,punctuation,reflink,reflinkSearch,tag,text:inlineText,url:noopTest},inlinePedantic={...inlineNormal,link:edit(/^!?\[(label)\]\((.*?)\)/).replace("label",_inlineLabel).getRegex(),reflink:edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",_inlineLabel).getRegex()},inlineGfm={...inlineNormal,emStrongRDelimAst:emStrongRDelimAstGfm,emStrongLDelim:emStrongLDelimGfm,url:edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},inlineBreaks={...inlineGfm,br:edit(br).replace("{2,}","*").getRegex(),text:edit(inlineGfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},block={normal:blockNormal,gfm:blockGfm,pedantic:blockPedantic},inline={normal:inlineNormal,gfm:inlineGfm,breaks:inlineBreaks,pedantic:inlinePedantic},escapeReplacements={"&":"&","<":"<",">":">",'"':""","'":"'"},getEscapeReplacement=e=>escapeReplacements[e];function escape$2(e,t){if(t){if(other.escapeTest.test(e))return e.replace(other.escapeReplace,getEscapeReplacement)}else if(other.escapeTestNoEncode.test(e))return e.replace(other.escapeReplaceNoEncode,getEscapeReplacement);return e}function cleanUrl(e){try{e=encodeURI(e).replace(other.percentDecode,"%")}catch{return null}return e}function splitCells(e,t){var l;const n=e.replace(other.findPipe,(u,d,f)=>{let p=!1,m=d;for(;--m>=0&&f[m]==="\\";)p=!p;return p?"|":" |"}),i=n.split(other.splitPipe);let o=0;if(i[0].trim()||i.shift(),i.length>0&&!((l=i.at(-1))!=null&&l.trim())&&i.pop(),t)if(i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;o<i.length;o++)i[o]=i[o].trim().replace(other.slashPipe,"|");return i}function rtrim(e,t,n){const i=e.length;if(i===0)return"";let o=0;for(;o<i&&e.charAt(i-o-1)===t;)o++;return e.slice(0,i-o)}function findClosingBracket(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let i=0;i<e.length;i++)if(e[i]==="\\")i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&(n--,n<0))return i;return-1}function outputLink(e,t,n,i,o){const l=t.href,u=t.title||null,d=e[1].replace(o.other.outputLinkReplace,"$1");if(e[0].charAt(0)!=="!"){i.state.inLink=!0;const f={type:"link",raw:n,href:l,title:u,text:d,tokens:i.inlineTokens(d)};return i.state.inLink=!1,f}return{type:"image",raw:n,href:l,title:u,text:d}}function indentCodeCompensation(e,t,n){const i=e.match(n.other.indentCodeCompensation);if(i===null)return t;const o=i[1];return t.split(`
|
|
901
901
|
`).map(l=>{const u=l.match(n.other.beginningSpace);if(u===null)return l;const[d]=u;return d.length>=o.length?l.slice(o.length):l}).join(`
|
|
@@ -953,4 +953,4 @@ ${t}</tr>
|
|
|
953
953
|
`+this.renderer.text(p);n?i+=this.renderer.paragraph({type:"paragraph",raw:m,text:m,tokens:[{type:"text",raw:m,text:m,escaped:!0}]}):i+=m;continue}default:{const p='Token with "'+f.type+'" type was not found.';if(this.options.silent)return console.error(p),"";throw new Error(p)}}}return i}parseInline(t,n=this.renderer){var o,l;let i="";for(let u=0;u<t.length;u++){const d=t[u];if((l=(o=this.options.extensions)==null?void 0:o.renderers)!=null&&l[d.type]){const p=this.options.extensions.renderers[d.type].call({parser:this},d);if(p!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(d.type)){i+=p||"";continue}}const f=d;switch(f.type){case"escape":{i+=n.text(f);break}case"html":{i+=n.html(f);break}case"link":{i+=n.link(f);break}case"image":{i+=n.image(f);break}case"strong":{i+=n.strong(f);break}case"em":{i+=n.em(f);break}case"codespan":{i+=n.codespan(f);break}case"br":{i+=n.br(f);break}case"del":{i+=n.del(f);break}case"text":{i+=n.text(f);break}default:{const p='Token with "'+f.type+'" type was not found.';if(this.options.silent)return console.error(p),"";throw new Error(p)}}}return i}}class _Hooks{constructor(t){be(this,"options");be(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}}be(_Hooks,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class Marked{constructor(...t){be(this,"defaults",_getDefaults());be(this,"options",this.setOptions);be(this,"parse",this.parseMarkdown(!0));be(this,"parseInline",this.parseMarkdown(!1));be(this,"Parser",_Parser);be(this,"Renderer",_Renderer);be(this,"TextRenderer",_TextRenderer);be(this,"Lexer",_Lexer);be(this,"Tokenizer",_Tokenizer);be(this,"Hooks",_Hooks);this.use(...t)}walkTokens(t,n){var o,l;let i=[];for(const u of t)switch(i=i.concat(n.call(this,u)),u.type){case"table":{const d=u;for(const f of d.header)i=i.concat(this.walkTokens(f.tokens,n));for(const f of d.rows)for(const p of f)i=i.concat(this.walkTokens(p.tokens,n));break}case"list":{const d=u;i=i.concat(this.walkTokens(d.items,n));break}default:{const d=u;(l=(o=this.defaults.extensions)==null?void 0:o.childTokens)!=null&&l[d.type]?this.defaults.extensions.childTokens[d.type].forEach(f=>{const p=d[f].flat(1/0);i=i.concat(this.walkTokens(p,n))}):d.tokens&&(i=i.concat(this.walkTokens(d.tokens,n)))}}return i}use(...t){const n=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(i=>{const o={...i};if(o.async=this.defaults.async||o.async||!1,i.extensions&&(i.extensions.forEach(l=>{if(!l.name)throw new Error("extension name required");if("renderer"in l){const u=n.renderers[l.name];u?n.renderers[l.name]=function(...d){let f=l.renderer.apply(this,d);return f===!1&&(f=u.apply(this,d)),f}:n.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 u=n[l.level];u?u.unshift(l.tokenizer):n[l.level]=[l.tokenizer],l.start&&(l.level==="block"?n.startBlock?n.startBlock.push(l.start):n.startBlock=[l.start]:l.level==="inline"&&(n.startInline?n.startInline.push(l.start):n.startInline=[l.start]))}"childTokens"in l&&l.childTokens&&(n.childTokens[l.name]=l.childTokens)}),o.extensions=n),i.renderer){const l=this.defaults.renderer||new _Renderer(this.defaults);for(const u in i.renderer){if(!(u in l))throw new Error(`renderer '${u}' does not exist`);if(["options","parser"].includes(u))continue;const d=u,f=i.renderer[d],p=l[d];l[d]=(...m)=>{let g=f.apply(l,m);return g===!1&&(g=p.apply(l,m)),g||""}}o.renderer=l}if(i.tokenizer){const l=this.defaults.tokenizer||new _Tokenizer(this.defaults);for(const u in i.tokenizer){if(!(u in l))throw new Error(`tokenizer '${u}' does not exist`);if(["options","rules","lexer"].includes(u))continue;const d=u,f=i.tokenizer[d],p=l[d];l[d]=(...m)=>{let g=f.apply(l,m);return g===!1&&(g=p.apply(l,m)),g}}o.tokenizer=l}if(i.hooks){const l=this.defaults.hooks||new _Hooks;for(const u in i.hooks){if(!(u in l))throw new Error(`hook '${u}' does not exist`);if(["options","block"].includes(u))continue;const d=u,f=i.hooks[d],p=l[d];_Hooks.passThroughHooks.has(u)?l[d]=m=>{if(this.defaults.async)return Promise.resolve(f.call(l,m)).then(b=>p.call(l,b));const g=f.call(l,m);return p.call(l,g)}:l[d]=(...m)=>{let g=f.apply(l,m);return g===!1&&(g=p.apply(l,m)),g}}o.hooks=l}if(i.walkTokens){const l=this.defaults.walkTokens,u=i.walkTokens;o.walkTokens=function(d){let f=[];return f.push(u.call(this,d)),l&&(f=f.concat(l.call(this,d))),f}}this.defaults={...this.defaults,...o}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,n){return _Lexer.lex(t,n??this.defaults)}parser(t,n){return _Parser.parse(t,n??this.defaults)}parseMarkdown(t){return(i,o)=>{const l={...o},u={...this.defaults,...l},d=this.onError(!!u.silent,!!u.async);if(this.defaults.async===!0&&l.async===!1)return d(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 i>"u"||i===null)return d(new Error("marked(): input parameter is undefined or null"));if(typeof i!="string")return d(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(i)+", string expected"));u.hooks&&(u.hooks.options=u,u.hooks.block=t);const f=u.hooks?u.hooks.provideLexer():t?_Lexer.lex:_Lexer.lexInline,p=u.hooks?u.hooks.provideParser():t?_Parser.parse:_Parser.parseInline;if(u.async)return Promise.resolve(u.hooks?u.hooks.preprocess(i):i).then(m=>f(m,u)).then(m=>u.hooks?u.hooks.processAllTokens(m):m).then(m=>u.walkTokens?Promise.all(this.walkTokens(m,u.walkTokens)).then(()=>m):m).then(m=>p(m,u)).then(m=>u.hooks?u.hooks.postprocess(m):m).catch(d);try{u.hooks&&(i=u.hooks.preprocess(i));let m=f(i,u);u.hooks&&(m=u.hooks.processAllTokens(m)),u.walkTokens&&this.walkTokens(m,u.walkTokens);let g=p(m,u);return u.hooks&&(g=u.hooks.postprocess(g)),g}catch(m){return d(m)}}}onError(t,n){return i=>{if(i.message+=`
|
|
954
954
|
Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An error occurred:</p><pre>"+escape$2(i.message+"",!0)+"</pre>";return n?Promise.resolve(o):o}if(n)return Promise.reject(i);throw i}}}const markedInstance=new Marked;function marked(e,t){return markedInstance.parse(e,t)}marked.options=marked.setOptions=function(e){return markedInstance.setOptions(e),marked.defaults=markedInstance.defaults,changeDefaults(marked.defaults),marked},marked.getDefaults=_getDefaults,marked.defaults=_defaults,marked.use=function(...e){return markedInstance.use(...e),marked.defaults=markedInstance.defaults,changeDefaults(marked.defaults),marked},marked.walkTokens=function(e,t){return markedInstance.walkTokens(e,t)},marked.parseInline=markedInstance.parseInline,marked.Parser=_Parser,marked.parser=_Parser.parse,marked.Renderer=_Renderer,marked.TextRenderer=_TextRenderer,marked.Lexer=_Lexer,marked.lexer=_Lexer.lex,marked.Tokenizer=_Tokenizer,marked.Hooks=_Hooks,marked.parse=marked,marked.options,marked.setOptions,marked.use,marked.walkTokens,marked.parseInline,_Parser.parse,_Lexer.lex;const Card=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("rounded-md border bg-card text-card-foreground shadow-sm",e),...t}));Card.displayName="Card";const CardHeader=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("flex flex-col space-y-1.5 p-6",e),...t}));CardHeader.displayName="CardHeader";const CardTitle=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("font-semibold leading-none tracking-tight",e),...t}));CardTitle.displayName="CardTitle";const CardDescription=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("text-sm text-muted-foreground",e),...t}));CardDescription.displayName="CardDescription";const CardContent=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("p-6 pt-0",e),...t}));CardContent.displayName="CardContent";const CardFooter=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("flex items-center p-6 pt-0",e),...t}));CardFooter.displayName="CardFooter";function PartnerCard({account:e,action:t,loading:n=!1,withVoice:i=!0}){const[o,l]=React.useState(null),[u,d]=React.useState(!1),[f,p]=React.useState(!1),[m,g]=React.useState(!1),[b,_]=React.useState(!0),[E,R]=React.useState(null),[S,C]=React.useState(!1),A=React.useMemo(()=>e!=null&&e.ApplicationId?{videoUrl:`https://api.randmar.io/V4/Partner/${e.ApplicationId}/Account/Video`,videoExistsUrl:`https://api.randmar.io/V4/Partner/${e.ApplicationId}/Account/Video/Exists`,logoUrl:`https://api.randmar.io/V4/Partner/${e.ApplicationId}/Account/Logo?width=64&height=64`,logoExistsUrl:`https://api.randmar.io/V4/Partner/${e.ApplicationId}/Account/Logo/Exists`}:null,[e==null?void 0:e.ApplicationId]),I=!!(e!=null&&e.VoiceName||e!=null&&e.VoiceStyle||e!=null&&e.SceneName);React.useEffect(()=>{if(!A||n)return;let T=!0;R(null);const O=async()=>{try{const B=await fetch(A.logoExistsUrl);if(B.ok){const F=(await B.text()).toLowerCase()==="true";return T&&p(F),F}return!1}catch(B){return console.error("Failed to check if logo exists:",B),T&&p(!1),!1}},j=async()=>{T&&d(!0);try{const B=await fetch(A.logoUrl);if(B.ok){const L=await B.blob();T&&(o&&URL.revokeObjectURL(o),l(URL.createObjectURL(L)))}else throw new Error(`Failed to load logo: ${B.status}`)}catch(B){console.error("Failed to load logo:",B),T&&R("Failed to load partner logo")}finally{T&&d(!1)}},N=async()=>{try{const B=await fetch(A.videoExistsUrl);if(B.ok){const L=await B.text();T&&g(L.toLowerCase()==="true")}else throw new Error(`Failed to check video: ${B.status}`)}catch(B){console.error("Failed to check if video exists:",B),T&&g(!1)}};return(async()=>{await O()&&j(),N()})(),()=>{T=!1,o&&URL.revokeObjectURL(o)}},[A,n]);const M=()=>{_(!1)};return n||!e?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center mb-4",children:[jsxRuntime.jsx("div",{className:"h-10 flex items-center justify-center mr-4",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-10 rounded-md"})}),jsxRuntime.jsx(Skeleton,{className:"h-7 w-40"})]}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-3/4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-5/6"})]}),jsxRuntime.jsx("div",{className:"p-3 bg-slate-50 rounded-md",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md: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",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-48"})]})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center mb-4",children:[f&&jsxRuntime.jsx("div",{className:"h-10 flex items-center justify-center mr-4",children:u?jsxRuntime.jsx(Skeleton,{className:"h-10 w-10 rounded-md"}):o&&jsxRuntime.jsx("img",{src:o||"/placeholder.svg",alt:`${e.PublicName}'s logo`,className:"max-h-10 w-auto object-contain"})}),jsxRuntime.jsx("h3",{className:"font-semibold text-xl",children:e.PublicName})]}),E&&jsxRuntime.jsx("div",{className:"text-red-500 mb-4 text-sm",role:"alert",children:E}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:e.About??""}}),i&&I&&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:[e.VoiceName&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Voice Name"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.VoiceName})]}),e.VoiceStyle&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Voice Style"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.VoiceStyle})]}),e.SceneName&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Scene Name"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.SceneName})]})]})})]})]}),jsxRuntime.jsxs(CardFooter,{className:"px-6 py-4 flex justify-between",children:[m&&A?jsxRuntime.jsxs(Dialog,{open:S,onOpenChange:C,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-[425px]",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsxs(DialogTitle,{children:[e.PublicName," Video"]})}),jsxRuntime.jsxs("div",{className:"w-full h-[320px] 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 ${e.PublicName}`,className:`w-full h-full object-contain ${b?"invisible":"visible"}`,style:{objectPosition:"center",imageRendering:"auto"},onLoadedData:M,onError:()=>_(!1)})]})]})]}):jsxRuntime.jsx("div",{}),t||jsxRuntime.jsxs(Button,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4"}),"Go to Partner Dashboard"]})]})]})}const ASSISTANT_ID="RandmarAIChatAssistant",ChatLayout=React.forwardRef(({userId:e,userName:t,apiKey:n,inputRef:i},o)=>{var Q,ee,se;const{data:l}=useGetV4PartnerByApplicationIdBusinessDevelopmentConversationsQuery({applicationId:e}),[u]=useLazyGetV4PartnerByApplicationIdAccountQuery(),[d]=useLazyGetV4PartnerByApplicationIdBusinessDevelopmentConversationAndConversationIdMessagesQuery(),{handleSubmitToBot:f,botMessages:p,botReady:m,debugMessages:g,isProcessingSubmission:b}=useAIAssistant({userId:e,apiKey:n});React.useEffect(()=>{if(!l)return;const J={partner1:[e,ASSISTANT_ID].sort()[0],partner2:[e,ASSISTANT_ID].sort()[1],name:"Randmar Assistant",unread:0,pending:!1,historyFetched:!0,messages:[],conversationID:-1},te=l.map(ce=>{var ie;return{partner1:[ce.Participant1,ce.Participant2].sort()[0],partner2:[ce.Participant1,ce.Participant2].sort()[1],name:((ie=ce.Participant)==null?void 0:ie.PublicName)??"missing public name",unread:0,pending:ce.Status!="Approved",historyFetched:!1,messages:[],conversationID:ce.ConversationId}});setTimeout(()=>{var ce;return(ce=z.current)==null?void 0:ce.focus()},50),O([J,...te])},[l]);const[_,E]=React.useState("all"),[R,S]=React.useState([[e,ASSISTANT_ID].sort()[0],[e,ASSISTANT_ID].sort()[1]]),[C,A]=React.useState(""),[I,M]=React.useState(null),[T,O]=React.useState([]),[j,N]=React.useState(""),[D,B]=React.useState(null),[L,F]=React.useState(null),V=React.useRef(null),H=React.useRef(null),z=i||H,G=T.filter(J=>{const te=J.name.toLowerCase().includes(j.toLowerCase());return _==="all"?te:_==="approved"?te&&!J.pending:_==="pending"?te&&J.pending:te});React.useEffect(()=>{const J=p.at(-1);if(!J||J.role!="assistant")return;if(J.isComponent){F(J.content);return}const te={id:J.timestamp.toString(),fromPartnerID:ASSISTANT_ID,toPartnerID:e,senderName:"Assistant",timestamp:J.timestamp.getTime(),content:J.content};te.content=marked(te.content,{async:!1}),K(te)},[p]);function K(J){const te=[J.fromPartnerID,J.toPartnerID];te.sort(),O(ce=>{let ie=!1,le=!1;const oe=ce.map(ae=>ae.partner1!==te[0]||ae.partner2!==te[1]||(le=!0,ae.messages.findIndex(ue=>ue.id==J.id)!==-1)?ae:(ie=!0,{...ae,unread:ae.unread+1,messages:[...ae.messages,J]}));return!le&&te[0]!==e&&te[1]!==e?(console.log("(bug) server sent a message to us by mistake."),oe):(ie&&M([te[0],te[1]]),oe)})}React.useEffect(()=>{const J=new HubConnectionBuilder().withUrl("https://api.randmar.io/hub",{accessTokenFactory:()=>localStorage.getItem("access_token"),headers:{"X-Impersonated-Id":e}}).configureLogging(LogLevel.Information).withAutomaticReconnect().withHubProtocol(new JsonHubProtocol).build();return J.on("ReceiveMessage",K),J.start().catch(te=>console.error("Error connecting to SignalR hub:",te)),B(J),()=>{J&&J.stop()}},[e]),React.useEffect(()=>{(I==null?void 0:I[0])!==(R==null?void 0:R[0])||(I==null?void 0:I[1])!==(R==null?void 0:R[1])||(O(J=>J.map(te=>te.partner1===(R==null?void 0:R[0])&&te.partner2===(R==null?void 0:R[1])?{...te,unread:0}:te)),setTimeout(()=>{var J;return(J=V.current)==null?void 0:J.scrollIntoView({behavior:"smooth"})},50))},[I,R]),React.useEffect(()=>{var te;if(!R)return;const J=getActiveChatObject(T,R);J&&((te=z.current)==null||te.focus(),F(jsxRuntime.jsx(jsxRuntime.Fragment,{})),u({applicationId:J.partner1===e?J.partner2:J.partner1}).then(ce=>{ce.data&&F(jsxRuntime.jsx("div",{className:"mt-2",children:jsxRuntime.jsx(PartnerCard,{account:ce.data,action:jsxRuntime.jsx(jsxRuntime.Fragment,{}),withVoice:!1})}))}),J.historyFetched?(O(ce=>ce.map(ie=>ie.partner1===R[0]&&ie.partner2===R[1]?{...ie,unread:0}:ie)),setTimeout(()=>{var ce;return(ce=V.current)==null?void 0:ce.scrollIntoView({behavior:"smooth"})},50)):d({applicationId:e,conversationId:J.conversationID}).unwrap().then(ce=>{const ie=ce.map(le=>({id:"history"+le.MessageId,fromPartnerID:le.SenderId,toPartnerID:le.SenderId==R[0]?R[1]:R[0],senderName:le.SenderName??"missing name",timestamp:new Date(le.SentDate+"Z").getTime(),content:le.Content??"no content"}));O(le=>le.map(oe=>oe.partner1===R[0]&&oe.partner2===R[1]?{...oe,messages:ie,historyFetched:!0}:oe)),setTimeout(()=>{var le;return(le=V.current)==null?void 0:le.scrollIntoView({behavior:"smooth"})},100)}).catch(ce=>{console.error("Error fetching conversation messages:",ce)}))},[R,d,e]);const q=(J,te,ce)=>{const ie={id:crypto.randomUUID(),senderName:t,fromPartnerID:e,toPartnerID:te[0]===e?te[1]:te[0],content:J,timestamp:Date.now()};O(le=>le.map(oe=>oe.partner1===te[0]&&oe.partner2===te[1]?{...oe,messages:[...oe.messages,ie]}:oe)),M([te[0],te[1]]),ie.toPartnerID==ASSISTANT_ID?f(ie.content):ce.invoke("NewMessage",ie).catch(le=>console.error("Error sending message:",le)),A("")},W=(J,te)=>{if(!T.length||!D||!m)return!1;const ce=T.find(ie=>ie.conversationID===J);return ce?(S([ce.partner1,ce.partner2]),te&&setTimeout(()=>q(te,[ce.partner1,ce.partner2],D),100),!0):!1};if(React.useImperativeHandle(o,()=>({setActiveChatAndSendMessage:W})),!m)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("div",{className:"flex items-center justify-center p-8",children:jsxRuntime.jsxs("div",{className:"text-center",children:[jsxRuntime.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto mb-4"}),jsxRuntime.jsx("p",{children:"Loading API functions..."})]})})});const U=()=>{!C.trim()||!R||!D||(F(jsxRuntime.jsx(jsxRuntime.Fragment,{})),q(C,R,D))};return jsxRuntime.jsxs("div",{className:"flex h-[80vh] overflow-hidden",children:[jsxRuntime.jsxs("div",{className:"w-[260px] p-4 pt-3 flex flex-col border-r",children:[jsxRuntime.jsx("div",{className:"p-4 font-semibold border-b",children:"Communications"}),T.length>1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"p-2",children:jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(Search,{className:"absolute left-2 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),jsxRuntime.jsx(Input,{placeholder:"Search chats...",className:"pl-8 h-9",value:j,onChange:J=>N(J.target.value)})]})}),jsxRuntime.jsx(Tabs,{value:_,onValueChange:E,className:"w-full mb-1",children:jsxRuntime.jsxs(TabsList,{className:"grid grid-cols-8 h-9 mx-2",children:[jsxRuntime.jsx(TabsTrigger,{value:"all",className:"text-xs col-span-2",children:"All"}),jsxRuntime.jsx(TabsTrigger,{value:"approved",className:"text-xs col-span-3",children:"Approved"}),jsxRuntime.jsx(TabsTrigger,{value:"pending",className:"text-xs col-span-3",children:"Pending"})]})})]}),jsxRuntime.jsx(ScrollArea,{className:"flex-1",children:T.length&&jsxRuntime.jsx(ChatList,{userId:e,chats:G.filter(J=>J.partner1!=ASSISTANT_ID&&J.partner2!=ASSISTANT_ID),activeChat:getActiveChatObject(T,R)??null,onSelectChat:S,assistantChat:T.find(J=>J.partner1==ASSISTANT_ID||J.partner2==ASSISTANT_ID)})})]}),jsxRuntime.jsx("div",{className:"flex-1 flex flex-col",children:R?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center p-4 border-b",children:[jsxRuntime.jsx(Avatar,{className:"h-8 w-8 flex-shrink-0 rounded-none",children:R[0]==ASSISTANT_ID||R[1]==ASSISTANT_ID?jsxRuntime.jsx(Bot,{className:"text-primary fill-white min-h-full"}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(AvatarImage,{src:`https://api.randmar.io/v4/Partner/${R[0]===e?R[1]:R[0]}/Account/Logo?height=72&width=72`,className:" object-contain "}),jsxRuntime.jsx(AvatarFallback,{children:jsxRuntime.jsx(Handshake,{className:"text-primary fill-white min-h-full"})})]})}),jsxRuntime.jsx("div",{className:"ml-3 font-medium",children:(Q=getActiveChatObject(T,R))==null?void 0:Q.name}),jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"ml-auto hidden",children:jsxRuntime.jsx(EllipsisVertical,{className:"h-5 w-5"})})]}),(ee=getActiveChatObject(T,R))!=null&&ee.pending?jsxRuntime.jsx("p",{className:"mt-8 p-2 mx-auto",children:"This conversation is still awaiting approval — please check back later."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(ScrollArea,{className:"flex-1 pl-2 pr-2 bg-slate-50",children:[jsxRuntime.jsx(ChatMessages,{messages:((se=getActiveChatObject(T,R))==null?void 0:se.messages)??[],currentUserId:e,isWaitingForBot:b&&R&&(R[0]===ASSISTANT_ID||R[1]===ASSISTANT_ID)}),jsxRuntime.jsx("div",{ref:V})]}),jsxRuntime.jsxs("div",{className:"p-4 border-t flex",children:[jsxRuntime.jsx(Input,{ref:z,placeholder:"Type a message...",value:C,onChange:J=>A(J.target.value),onKeyDown:J=>J.key==="Enter"&&U(),className:"flex-1"}),jsxRuntime.jsx(Button,{size:"icon",variant:"default",className:"ml-1",disabled:b,onClick:U,children:jsxRuntime.jsx(Send,{className:"h-4 w-4"})})]})]})]}):jsxRuntime.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:"Select a chat to start messaging"})}),jsxRuntime.jsxs("div",{className:"w-[480px] flex flex-1 flex-col border-l",children:[jsxRuntime.jsx("div",{className:"flex items-center p-4 border-b",children:jsxRuntime.jsx("p",{className:"h-8 text-base/8",children:"Visuals and System Info"})}),jsxRuntime.jsx(ScrollArea,{className:"flex-4 pl-2 pr-2 bg-slate-50",children:L}),jsxRuntime.jsx(ScrollArea,{className:"flex-1 border-t pl-2 pr-2 bg-slate-50",children:jsxRuntime.jsx("div",{className:"space-y-2",children:g.map(J=>jsxRuntime.jsx("p",{className:"text-slate-600",children:J}))})})]})]})});function getActiveChatObject(e,t){return e.find(n=>n.partner1==(t==null?void 0:t[0])&&n.partner2==(t==null?void 0:t[1]))}const Topbar=React.forwardRef(({onSignOut:e,handleValidSearch:t,rightMenu:n,searchPlaceholder:i},o)=>{const[l,u]=React.useState(""),d=reactRouterDom.useLocation(),{toast:f}=useToast();React.useEffect(()=>{const b=new URLSearchParams(d.search).get("q");b&&u(b)},[d.search]);const p=()=>{const g=l.trim();if(!g||g.length<2){f({title:"Enter more characters to search",description:"At least 2 characters are needed to search products.",variant:"destructive",duration:5e3});return}t(g)},m=g=>{g.key==="Enter"&&p()};return jsxRuntime.jsxs("header",{className:"flex h-16 items-center gap-4 border-b sidebar-foreground bg-sidebar px-6 fixed top-0 right-0 z-50 lg:left-64 left-0 border-sidebar-border",children:[jsxRuntime.jsx(SidebarTrigger,{className:"lg:hidden",children:jsxRuntime.jsx(Menu$1,{className:"h-6 w-6"})}),jsxRuntime.jsx("div",{className:"flex flex-1 items-center gap-4",children:jsxRuntime.jsx("div",{className:"relative w-full max-w-sm",children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("button",{type:"button",className:"absolute left-2 top-1/2 -translate-y-1/2",onClick:p,"aria-label":"Search",children:jsxRuntime.jsx(Search,{className:"h-4 w-4 text-muted-foreground"})}),jsxRuntime.jsx(Input,{placeholder:i??"Search...",className:"w-full pl-8 bg-white text-black",value:l,onChange:g=>u(g.target.value),onKeyDown:m,ref:o},"topbar-search")]})})}),n||jsxRuntime.jsx(jsxRuntime.Fragment,{}),e&&jsxRuntime.jsx("div",{className:"flex items-center gap-4",children:jsxRuntime.jsxs(Button,{variant:"ghost",size:"icon",className:"h-9 w-9",onClick:e,children:[jsxRuntime.jsx(LogOut,{className:"h-4 w-4 text-sidebar-foreground"}),jsxRuntime.jsx("span",{className:"sr-only",children:"Sign out"})]})})]})});Topbar.displayName="Topbar";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:e,variant:t,size:n,icon:i,children:o,...l},u)=>jsxRuntime.jsxs("div",{ref:u,className:cn(badgeVariants({variant:t,size:n}),e),...l,children:[i&&jsxRuntime.jsx("span",{className:"mr-1",children:i}),o]}));Badge.displayName="Badge";const CountryFlag=({countryCode:e,className:t=""})=>{const[n,i]=React.useState(null),[o,l]=React.useState(!1);return React.useEffect(()=>{if(!e)return;const d=`https://purecatamphetamine.github.io/country-flag-icons/3x2/${e.toUpperCase()}.svg`;fetch(d,{method:"HEAD"}).then(f=>{f.ok?(i(d),l(!1)):l(!0)}).catch(()=>{l(!0)})},[e]),o||!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"}})},Navbar=React.forwardRef(({routes:e,footer:t,dashboardTitle:n,withRandmarAssistant:i,chatUserName:o,chatApiKey:l},u)=>{const{appID:d}=reactRouterDom.useParams(),f=e.filter(b=>b.showInNav),p=React.useRef(null),m=React.useRef(null),g=React.useRef(null);return React.useImperativeHandle(u,()=>({setActiveChatAndSendMessage:(b,_)=>{var E;return(E=g.current)==null||E.click(),setTimeout(()=>{var R;(R=p.current)==null||R.focus(),m.current&&m.current.setActiveChatAndSendMessage(b,_)},100),!0}})),jsxRuntime.jsxs(Sidebar,{className:"border-r border-sidebar-border",children:[jsxRuntime.jsx(SidebarHeader,{className:"border-b border-sidebar-border px-6 h-16 justify-center bg-sidebar text-sidebar-foreground",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-center",children:jsxRuntime.jsx("img",{src:"https://api.randmar.io/images/RandmarIcon.svg",alt:"Randmar Icon",className:"h-4 w-4 filter brightness-0 saturate-100 invert"})}),jsxRuntime.jsx("span",{className:"font-semibold text-lg",children:n})]})}),jsxRuntime.jsx(SidebarContent,{className:"py-4 bg-sidebar text-sidebar-foreground",children:jsxRuntime.jsx(SidebarMenu,{children:f.map(b=>{const _=b.icon,E=`/${b.path.replace(":appID",d??"")}`;return jsxRuntime.jsx(SidebarMenuItem,{children:jsxRuntime.jsx(SidebarMenuButton,{asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:E,className:"transition-colors hover:bg-muted px-6",children:[_&&jsxRuntime.jsx(_,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:b.label})]})})},b.key)})})}),jsxRuntime.jsxs(SidebarFooter,{className:"border-t border-sidebar-border p-4 bg-sidebar-background text-sidebar-foreground",children:[i===!0&&jsxRuntime.jsxs(Dialog,{children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{ref:g,size:"lg",className:"collapse md:visible",onClick:()=>setTimeout(()=>{var b;return(b=p.current)==null?void 0:b.focus()},50),children:[jsxRuntime.jsx(Bot,{}),"Assistant"]})}),jsxRuntime.jsx(DialogContent,{className:"max-w-[85vw] p-0 data-[state=open]:visible data-[state=closed]:invisible",forceMount:!0,animateExit:!1,children:jsxRuntime.jsx(ChatLayout,{ref:m,inputRef:p,userId:d??"2",userName:o??"Unknown user",apiKey:l??""})})]}),t]})]})}),Layout=React.forwardRef(({children:e,rightMenu:t,routes:n,footer:i,handleValidSearch:o,dashboardTitle:l,onSignOut:u,searchPlaceholder:d,withRandmarAssistant:f,chatUserName:p,chatApiKey:m,chatRef:g},b)=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(SidebarProvider,{children:jsxRuntime.jsxs("div",{className:"flex grow",children:[jsxRuntime.jsx(Navbar,{routes:n,footer:i,dashboardTitle:l,withRandmarAssistant:f,chatUserName:p,chatApiKey:m,ref:g}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[jsxRuntime.jsx(Topbar,{ref:b,onSignOut:u,rightMenu:t,handleValidSearch:o,searchPlaceholder:d}),jsxRuntime.jsx("main",{className:"flex-1 overflow-auto mt-16",children:e}),jsxRuntime.jsx(Toaster,{})]})]})})}));Layout.displayName="Layout";const imgSizeMap={sm:100,md:200,lg:300,xl:400};function ProductImage({randmarSKU:e,size:t="md",alt:n,secondaryContent:i}){const[o,l]=React__namespace.useState(!1),[u,d]=React__namespace.useState(!1),[f,p]=React__namespace.useState(!1),[m,g]=React__namespace.useState(!1),b=`https://api.randmar.io/Product/${e}/Video`;React__namespace.useEffect(()=>{(async()=>{try{const I=await(await fetch(b+"/Exists")).json();d(I)}catch(A){console.error("Error checking for video:",A),d(!1)}})()},[e,b]);async function _(){if(u){g(!0);try{const A=await(await fetch(b)).blob(),I=window.URL.createObjectURL(A),M=document.createElement("a");M.href=I,M.download=`${e||"product"}-video.mp4`,document.body.appendChild(M),M.click(),document.body.removeChild(M),window.URL.revokeObjectURL(I)}catch(C){console.error("Error downloading video:",C)}finally{g(!1)}}}function E(){navigator.clipboard.writeText(b),p(!0),setTimeout(()=>{p(!1)},2e3)}function R(){l(!0)}const S=imgSizeMap[t||"xl"];return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Dialog,{open:o,onOpenChange:l,children:jsxRuntime.jsx(DialogContent,{className:"max-w-4xl p-0 overflow-hidden",children:i?jsxRuntime.jsxs("div",{className:"flex flex-row",children:[jsxRuntime.jsxs("video",{className:"w-full rounded-l-lg max-h-[720px] object-contain",controls:!0,autoPlay:!0,muted:!0,loop:!0,children:[jsxRuntime.jsx("source",{src:b,type:"video/mp4"}),"Your browser does not support the video tag."]}),jsxRuntime.jsx("div",{className:"flex-grow min-w-[400px] h-[70vh] p-6",children:i})]}):jsxRuntime.jsxs("div",{className:"w-full relative",children:[jsxRuntime.jsxs("video",{className:"w-full max-h-[720px] object-contain",controls:!0,autoPlay:!0,children:[jsxRuntime.jsx("source",{src:b,type:"video/mp4"}),"Your browser does not support the video tag."]}),jsxRuntime.jsxs("div",{className:"absolute top-2 right-12 flex gap-1",children:[jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",onClick:E,children:f?jsxRuntime.jsx(Check,{className:"h-4 w-4"}):jsxRuntime.jsx(Copy,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Copy video link"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",onClick:_,disabled:m,children:jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Download video"})})]})})]})]})})}),jsxRuntime.jsxs("div",{className:"relative w-max h-max",children:[jsxRuntime.jsx("img",{alt:n||`Product ${e}`,className:`rounded-md ${u?"cursor-pointer":""}`,onClick:u?R:void 0,src:`https://api.randmar.io/Product/${e}/Image?width=${S*1.5}&height=${S*1.5}`,width:S,height:S}),u&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",className:"absolute top-2 right-2",onClick:R,children:jsxRuntime.jsx(Play,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Play video"})})]})})]})]})}function ProductCard({item:e,addToCart:t=!1,syncToShopify:n=!1,customAction:i=jsxRuntime.jsx(jsxRuntime.Fragment,{}),defaultOpportunityNumber:o="",viewProductLink:l,addToCartAction:u,isAddToCartActionLoading:d=!1,syncToShopifyAction:f,isSyncToShopifyActionLoading:p=!1}){var W,U,Q,ee,se,J,te,ce,ie,le,oe;const[m,g]=React.useState(1),[b,_]=React.useState(null),[E,R]=React.useState(0),[S,C]=React.useState(!1),A=((W=e==null?void 0:e.Distribution)==null?void 0:W.Cost)||0,I=((U=e==null?void 0:e.Distribution)==null?void 0:U.RegularPrice)||0,M=((Q=e==null?void 0:e.Distribution)==null?void 0:Q.Price)||0;React.useEffect(()=>{g(1),_(null),R(0),C(!1)},[e==null?void 0:e.RandmarSKU]);const[T,O]=React.useState(null),[j,N]=React.useState(!1);React.useEffect(()=>{const ae=async()=>{if(e!=null&&e.ManufacturerId){N(!0);try{const ue=await fetch(`https://api.randmar.io/V4/Partner/${e.ManufacturerId}/Account/Logo?width=60&height=40`);if(ue.ok){const Z=await ue.blob();O(URL.createObjectURL(Z))}}catch(ue){console.error("Failed to load logo:",ue)}finally{N(!1)}}};e!=null&&e.ManufacturerId&&ae()},[e==null?void 0:e.ManufacturerId]),React.useEffect(()=>{var ae;if(e&&o){const ue=(ae=e.Opportunities)==null?void 0:ae.find(Z=>Z.BidNumber==o);ue&&_(ue)}},[e,o]),React.useEffect(()=>{if(!e)return;const ae=b!=null&&b.Price?b.Price:M;R(I>0?Math.round((I-ae)/I*100):0)},[e,b,M,I]),React.useEffect(()=>{d||g(1)},[d]);const D=ae=>{if(ae.Active!==!0)return!1;const ue=new Date().toISOString().split("T")[0];return!(ae.EndDate&&ae.EndDate.split("T")[0]<ue||ae.StartDate&&ae.StartDate.split("T")[0]>ue)};if(!e)return jsxRuntime.jsx(Card,{children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx("div",{className:"h-10 w-24 flex items-center justify-end ml-4",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-28 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-6 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsx("div",{className:"w-60 h-40",children:jsxRuntime.jsx(Skeleton,{className:"w-full h-full rounded-lg"})})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsx("div",{className:"flex flex-1",children:jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-24 mb-3"}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-full rounded-md"})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-32 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24 mt-4"})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-start gap-1 mb-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-10 flex-1 rounded-md"})]})]})]})});const B=(e==null?void 0:e.Opportunities)||[],L=B.length>0,F=()=>{if(m==null){g(1);return}m>1&&g(m-1)},V=()=>{if(m==null){g(1);return}g(m+1)},H=ae=>{const ue=parseInt(ae.target.value,10);if(!isNaN(ue)&&ue>0){g(ue);return}g(void 0)},z=()=>{(m==null||m<1)&&g(1)},G=((se=(ee=e.Distribution)==null?void 0:ee.Inventory)==null?void 0:se.reduce((ae,ue)=>ae+(ue.AvailableQuantity||0),0))||0,K=ae=>{try{return new Date(ae).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch(ue){return console.error(ue),ae.split("T")[0]||"N/A"}},q=()=>{u&&u({quantity:m??1,bidNumber:(b==null?void 0:b.BidNumber)??null})};return jsxRuntime.jsx(Card,{className:"hover:shadow-lg transition-shadow",children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-xl",children:e.Title||e.RandmarTitle}),jsxRuntime.jsx("div",{className:"h-10 w-24 flex items-center justify-end ml-4",children:j?jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"}):T&&jsxRuntime.jsx("img",{src:T||"/placeholder.svg",alt:e.ManufacturerName??"",className:"max-h-10 max-w-24 object-contain"})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[e.State&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.State==="Active"?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(Check,{size:"12",className:"mr-1.5"})," ",e.State]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.SerialNumber?"bg-green-50 text-green-700 hover:bg-green-50":"bg-yellow-50 text-yellow-700 hover:bg-yellow-50"}`,children:[jsxRuntime.jsx(QrCode,{size:"12",className:"mr-1.5"})," ",e.SerialNumber?"Serialized":"Unserialized"]}),e.TransparencyCode&&jsxRuntime.jsxs(Badge,{variant:"outline",className:"rounded-full px-3 bg-green-50 text-green-700 hover:bg-green-50",children:[jsxRuntime.jsx(CircleDashed,{size:"12",className:"mr-1.5"})," Transparency Code"]}),e.AvailableToBuy!==void 0&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.AvailableToBuy?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(ShoppingCart,{size:"12",className:"mr-1.5"})," ",e.AvailableToBuy?"Available":"Unavailable"]}),e.ManufacturerCategory!==void 0&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${(J=e.ManufacturerCategory)!=null&&J.QualificationRequired?"bg-blue-50 text-blue-700 hover:bg-blue-50":"bg-neutral-50 text-neutral-700 hover:bg-neutral-50"}`,children:[jsxRuntime.jsx(ShieldCheck,{size:"12",className:"mr-1.5"})," ",(te=e.ManufacturerCategory)!=null&&te.QualificationRequired?"Qualified Only":"Available to all"]}),e.ManufacturerId&&jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.AutoUpdate?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(RefreshCw,{size:"12",className:"mr-1.5"})," ",e.AutoUpdate?`Automatic Reorder (${e.MasterCarton})`:"Manually Reorders"]}),jsxRuntime.jsxs(Badge,{variant:"outline",className:`rounded-full px-3 ${e.BodyHTML&&e.Title&&e.MAP?"bg-green-50 text-green-700 hover:bg-green-50":"bg-red-50 text-red-700 hover:bg-red-50"}`,children:[jsxRuntime.jsx(Store,{size:"12",className:"mr-1.5"})," ",e.BodyHTML&&e.Title&&e.MAP?"Shopify Ready":"Not Shopify Ready"]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-4 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"MPN"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.MPN||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"UPC"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.UPC||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Unit Weight"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.UnitWeight?`${e.UnitWeight} lbs`:"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"MAP"}),jsxRuntime.jsx("div",{className:"font-medium",children:e.MAP?"$"+e.MAP.toFixed(2):"N/A"})]}),e.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:e.CountryCodeOfOrigin,className:"mr-2"}),e.CountryCodeOfOrigin]})]})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsx(ProductImage,{randmarSKU:e.RandmarSKU||"",alt:e.RandmarTitle||""})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsx("div",{className:"flex flex-1",children:L&&e.Distribution&&jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx("div",{className:"flex items-center",children:"You have "+B.length+(B.length>1?" opportunities":" opportunity")+" for this product:"}),jsxRuntime.jsx("div",{className:"space-y-2 max-h-[200px] overflow-y-auto p-2 mt-1",children:B.map((ae,ue)=>{var Z;return jsxRuntime.jsxs("div",{className:`flex justify-between items-center rounded-lg transition-colors py-2 px-4 bg-purple-100 border border-muted
|
|
955
955
|
${ae.BidNumber==(b==null?void 0:b.BidNumber)?"cursor-pointer border-2 border-purple-900":D(ae)?"hover:bg-purple-200 cursor-pointer":"!bg-neutral-50"}
|
|
956
|
-
`,onClick:()=>{D(ae)&&_(ae.BidNumber!=(b==null?void 0:b.BidNumber)?ae: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:ae.Opportunity}),jsxRuntime.jsxs("span",{className:"text-xs text-neutral-900",children:[ae.BidNumber," ",!D(ae)&&jsxRuntime.jsx(Badge,{variant:"outline",className:"text-xs mx-1 h-5 bg-gray-100",children:"Currently unavailable"})]})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end",children:[jsxRuntime.jsxs("span",{className:"font-semibold",children:["$",(Z=ae.Price)==null?void 0:Z.toFixed(2)]}),ae.Rebate&&ae.Rebate>0&&jsxRuntime.jsxs("span",{className:"text-xs text-green-600",children:["Rebate: $",ae.Rebate.toFixed(2)]}),ae.EndDate&&jsxRuntime.jsxs("span",{className:"text-xs text-neutral-600",children:["Ends: ",K(ae.EndDate)]})]})]},ue)})})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[l&&jsxRuntime.jsx(reactRouterDom.Link,{to:l,children:jsxRuntime.jsxs(Button,{variant:"secondary",children:[jsxRuntime.jsx(Eye,{className:"mr-2"}),"View Product"]})}),((ce=e.Distribution)==null?void 0:ce.Inventory)&&jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsxs(Dialog,{open:S,onOpenChange:C,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{variant:"ghost",className:`flex items-center text-sm ${G>0?"text-green-700":"text-red-700"}`,children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),G>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[G," in stock"]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Out of stock"})]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-4xl",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsxs(DialogTitle,{className:"flex items-center",children:[jsxRuntime.jsx(Warehouse,{className:"mr-2",size:18}),"Inventory Information"]})}),jsxRuntime.jsx(ProductInventoryGrid,{inventory:e.Distribution.Inventory})]})]})})]})]}),e.Distribution&&jsxRuntime.jsxs("div",{className:"flex justify-between items-end mt-4",children:[jsxRuntime.jsx("div",{className:"flex-shrink-1 flex flex-col items-start gap-1",children:A>0?jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("span",{className:"text-2xl font-bold whitespace-nowrap",children:[jsxRuntime.jsx("span",{children:"Cost: $"}),A.toFixed(2),jsxRuntime.jsx("span",{children:" CAD"})]})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap",children:[jsxRuntime.jsxs("span",{className:"text-2xl font-bold whitespace-nowrap",children:[jsxRuntime.jsx("span",{children:"$"}),b?(le=(ie=e.Opportunities)==null?void 0:ie.find(ae=>ae.BidNumber==b.BidNumber))==null?void 0:le.Price:M.toFixed(2),jsxRuntime.jsx("span",{children:" CAD"})]}),E>0&&jsxRuntime.jsxs("span",{className:"text-muted-foreground line-through ml-2 whitespace-nowrap",children:["$",I.toFixed(2)]})]}),E>0&&jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs(Badge,{variant:"outline",className:"bg-red-50 text-red-700 rounded-full px-3 whitespace-nowrap",children:[jsxRuntime.jsxs("span",{children:[E,"% OFF"]}),((oe=e.InstantRebate)==null?void 0:oe.EndDate)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",e.InstantRebate.EndDate.split("T")[0]]}),(b==null?void 0:b.EndDate)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",b.EndDate.split("T")[0]]})]})})]})}),jsxRuntime.jsxs("div",{className:"flex flex-shrink-0 gap-2 ml-4",children:[typeof t<"u"&&t&&jsxRuntime.jsxs("div",{className:"flex items-center border rounded-md",children:[jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"rounded-r-none",onClick:F,disabled:typeof m<"u"&&(m<=1||!e.AvailableToBuy||d||!u),children:"-"}),jsxRuntime.jsx("input",{value:m,onChange:H,onBlur:z,onClick:ae=>ae.currentTarget.select(),className:`w-12 text-center border-0 focus:ring-0 focus:outline-none ${!e.AvailableToBuy||d||!u?"text-gray-400":""}`,disabled:!e.AvailableToBuy||d||!u}),jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"rounded-l-none",onClick:V,disabled:!e.AvailableToBuy||d||!u,children:"+"})]}),typeof t<"u"&&t&&jsxRuntime.jsx(Button,{className:"gap-2 whitespace-nowrap",onClick:q,disabled:!e.AvailableToBuy||d||!u,children:d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}),"Adding..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2"}),"Add to Cart"]})}),n&&jsxRuntime.jsx(Button,{className:"gap-2 whitespace-nowrap bg-green-600 hover:bg-green-700",onClick:f,disabled:p||!f,children:p?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"]})}),i]})]})]})})}function ManufacturerCard({manufacturer:e,link:t,actions:n,loading:i=!1}){var p;if(i||!e)return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-24 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"})]})]})}),jsxRuntime.jsx(CardContent,{className:"pb-2",children:jsxRuntime.jsxs("div",{className:"flex flex-col space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-14 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-36"})]})]})]})}),jsxRuntime.jsxs(CardFooter,{className:"flex justify-between pt-2 gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-40"})]})]});const o=e.ManufacturerId||"N/A",l=e.PublicName||"N/A",u=[e.City,e.Province,e.Country].filter(Boolean),d=u.length>0?u.join(", "):"Location not provided",f=((p=e.Tags)==null?void 0:p.split(",").map(m=>m.trim()).filter(Boolean))||[];return jsxRuntime.jsxs(Card,{className:"manufacturer-theme",children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx("img",{src:`https://api.randmar.io/V4/Partner/${o}/Account/Logo?width=64&height=64`,alt:`${l}'s logo`,className:"max-h-10 w-auto object-contain"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:"Manufacturer"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:o})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:e.PublicName||"N/A"}),e.Name&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:e.Name}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:d})]})]}),!!e.OnHold&&e.OnHold!==0&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"})]}),jsxRuntime.jsx(CardContent,{className:"pb-2",children:jsxRuntime.jsxs("div",{className:"flex flex-col space-y-2",children:[f.length>0&&jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:f.map((m,g)=>jsxRuntime.jsx(Badge,{children:m},g))}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[e.Phone&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Phone,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Phone})]}),e.PublicEmail&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.PublicEmail})]}),e.Website&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Globe,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Website})]}),e.CurrencyCode&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(DollarSign,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.CurrencyCode})]})]})]})}),(n||t)&&jsxRuntime.jsxs(CardFooter,{className:`flex pt-2 gap-2 ${n?"justify-between":"justify-end"}`,children:[n&&n,t&&jsxRuntime.jsx(Button,{className:"flex items-center gap-1",asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:t,target:"_blank",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4"}),"Go to Manufacturer"]})})]})]})}function ResellerCard({reseller:e,link:t,actions:n,loading:i=!1}){if(i||!e)return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-24 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"})]})]})}),jsxRuntime.jsx(CardContent,{className:"pb-2",children:jsxRuntime.jsx("div",{className:"flex flex-col space-y-2",children:jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-36"})]})]})})}),jsxRuntime.jsxs(CardFooter,{className:"flex justify-between pt-2 gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-40"})]})]});const o=e.ResellerId||"N/A",l=e.PublicName||"N/A",u=[e.City,e.Province,e.Country].filter(Boolean),d=u.length>0?u.join(", "):"Location not provided";return jsxRuntime.jsxs(Card,{className:"reseller-theme",children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx("img",{src:`https://api.randmar.io/V4/Partner/${o}/Account/Logo?width=64&height=64`,alt:`${l}'s logo`,className:"max-h-10 w-auto object-contain"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:"Reseller"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:o})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:e.PublicName||"N/A"}),e.Name&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:e.Name}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:d})]})]}),!!e.OnHold&&e.OnHold!==0&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"})]}),jsxRuntime.jsx(CardContent,{className:"pb-2",children:jsxRuntime.jsx("div",{className:"flex flex-col space-y-2",children:jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[e.Phone&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Phone,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Phone})]}),e.PublicEmail&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.PublicEmail})]}),e.Website&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Globe,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Website})]}),e.CurrencyCode&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(DollarSign,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.CurrencyCode})]})]})})}),(n||t)&&jsxRuntime.jsxs(CardFooter,{className:`flex pt-2 gap-2 ${n?"justify-between":"justify-end"}`,children:[n&&n,t&&jsxRuntime.jsx(Button,{className:"flex items-center gap-1",asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:t,target:"_blank",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4"}),"Go to Reseller"]})})]})]})}function usePrevious(e){const t=React__namespace.useRef({value:e,previous:e});return React__namespace.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var OPEN_KEYS=[" ","Enter","ArrowUp","ArrowDown"],SELECTION_KEYS=[" ","Enter"],SELECT_NAME="Select",[Collection,useCollection,createCollectionScope]=createCollection(SELECT_NAME),[createSelectContext,createSelectScope]=createContextScope(SELECT_NAME,[createCollectionScope,createPopperScope]),usePopperScope=createPopperScope(),[SelectProvider,useSelectContext]=createSelectContext(SELECT_NAME),[SelectNativeOptionsProvider,useSelectNativeOptionsContext]=createSelectContext(SELECT_NAME),Select$1=e=>{const{__scopeSelect:t,children:n,open:i,defaultOpen:o,onOpenChange:l,value:u,defaultValue:d,onValueChange:f,dir:p,name:m,autoComplete:g,disabled:b,required:_,form:E}=e,R=usePopperScope(t),[S,C]=React__namespace.useState(null),[A,I]=React__namespace.useState(null),[M,T]=React__namespace.useState(!1),O=useDirection(p),[j=!1,N]=useControllableState({prop:i,defaultProp:o,onChange:l}),[D,B]=useControllableState({prop:u,defaultProp:d,onChange:f}),L=React__namespace.useRef(null),F=S?E||!!S.closest("form"):!0,[V,H]=React__namespace.useState(new Set),z=Array.from(V).map(G=>G.props.value).join(";");return jsxRuntime.jsx(Root2$4,{...R,children:jsxRuntime.jsxs(SelectProvider,{required:_,scope:t,trigger:S,onTriggerChange:C,valueNode:A,onValueNodeChange:I,valueNodeHasChildren:M,onValueNodeHasChildrenChange:T,contentId:useId(),value:D,onValueChange:B,open:j,onOpenChange:N,dir:O,triggerPointerDownPosRef:L,disabled:b,children:[jsxRuntime.jsx(Collection.Provider,{scope:t,children:jsxRuntime.jsx(SelectNativeOptionsProvider,{scope:e.__scopeSelect,onNativeOptionAdd:React__namespace.useCallback(G=>{H(K=>new Set(K).add(G))},[]),onNativeOptionRemove:React__namespace.useCallback(G=>{H(K=>{const q=new Set(K);return q.delete(G),q})},[]),children:n})}),F?jsxRuntime.jsxs(BubbleSelect,{"aria-hidden":!0,required:_,tabIndex:-1,name:m,autoComplete:g,value:D,onChange:G=>B(G.target.value),disabled:b,form:E,children:[D===void 0?jsxRuntime.jsx("option",{value:""}):null,Array.from(V)]},z):null]})})};Select$1.displayName=SELECT_NAME;var TRIGGER_NAME="SelectTrigger",SelectTrigger$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:i=!1,...o}=e,l=usePopperScope(n),u=useSelectContext(TRIGGER_NAME,n),d=u.disabled||i,f=useComposedRefs(t,u.onTriggerChange),p=useCollection(n),m=React__namespace.useRef("touch"),[g,b,_]=useTypeaheadSearch(R=>{const S=p().filter(I=>!I.disabled),C=S.find(I=>I.value===u.value),A=findNextItem(S,R,C);A!==void 0&&u.onValueChange(A.value)}),E=R=>{d||(u.onOpenChange(!0),_()),R&&(u.triggerPointerDownPosRef.current={x:Math.round(R.pageX),y:Math.round(R.pageY)})};return jsxRuntime.jsx(Anchor,{asChild:!0,...l,children:jsxRuntime.jsx(Primitive.button,{type:"button",role:"combobox","aria-controls":u.contentId,"aria-expanded":u.open,"aria-required":u.required,"aria-autocomplete":"none",dir:u.dir,"data-state":u.open?"open":"closed",disabled:d,"data-disabled":d?"":void 0,"data-placeholder":shouldShowPlaceholder(u.value)?"":void 0,...o,ref:f,onClick:composeEventHandlers(o.onClick,R=>{R.currentTarget.focus(),m.current!=="mouse"&&E(R)}),onPointerDown:composeEventHandlers(o.onPointerDown,R=>{m.current=R.pointerType;const S=R.target;S.hasPointerCapture(R.pointerId)&&S.releasePointerCapture(R.pointerId),R.button===0&&R.ctrlKey===!1&&R.pointerType==="mouse"&&(E(R),R.preventDefault())}),onKeyDown:composeEventHandlers(o.onKeyDown,R=>{const S=g.current!=="";!(R.ctrlKey||R.altKey||R.metaKey)&&R.key.length===1&&b(R.key),!(S&&R.key===" ")&&OPEN_KEYS.includes(R.key)&&(E(),R.preventDefault())})})})});SelectTrigger$1.displayName=TRIGGER_NAME;var VALUE_NAME="SelectValue",SelectValue$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,className:i,style:o,children:l,placeholder:u="",...d}=e,f=useSelectContext(VALUE_NAME,n),{onValueNodeHasChildrenChange:p}=f,m=l!==void 0,g=useComposedRefs(t,f.onValueNodeChange);return useLayoutEffect2(()=>{p(m)},[p,m]),jsxRuntime.jsx(Primitive.span,{...d,ref:g,style:{pointerEvents:"none"},children:shouldShowPlaceholder(f.value)?jsxRuntime.jsx(jsxRuntime.Fragment,{children:u}):l})});SelectValue$1.displayName=VALUE_NAME;var ICON_NAME="SelectIcon",SelectIcon=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,children:i,...o}=e;return jsxRuntime.jsx(Primitive.span,{"aria-hidden":!0,...o,ref:t,children:i||"▼"})});SelectIcon.displayName=ICON_NAME;var PORTAL_NAME="SelectPortal",SelectPortal=e=>jsxRuntime.jsx(Portal$4,{asChild:!0,...e});SelectPortal.displayName=PORTAL_NAME;var CONTENT_NAME="SelectContent",SelectContent$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContext(CONTENT_NAME,e.__scopeSelect),[i,o]=React__namespace.useState();if(useLayoutEffect2(()=>{o(new DocumentFragment)},[]),!n.open){const l=i;return l?ReactDOM__namespace.createPortal(jsxRuntime.jsx(SelectContentProvider,{scope:e.__scopeSelect,children:jsxRuntime.jsx(Collection.Slot,{scope:e.__scopeSelect,children:jsxRuntime.jsx("div",{children:e.children})})}),l):null}return jsxRuntime.jsx(SelectContentImpl,{...e,ref:t})});SelectContent$1.displayName=CONTENT_NAME;var CONTENT_MARGIN=10,[SelectContentProvider,useSelectContentContext]=createSelectContext(CONTENT_NAME),CONTENT_IMPL_NAME="SelectContentImpl",Slot=createSlot("SelectContent.RemoveScroll"),SelectContentImpl=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,position:i="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:l,onPointerDownOutside:u,side:d,sideOffset:f,align:p,alignOffset:m,arrowPadding:g,collisionBoundary:b,collisionPadding:_,sticky:E,hideWhenDetached:R,avoidCollisions:S,...C}=e,A=useSelectContext(CONTENT_NAME,n),[I,M]=React__namespace.useState(null),[T,O]=React__namespace.useState(null),j=useComposedRefs(t,ie=>M(ie)),[N,D]=React__namespace.useState(null),[B,L]=React__namespace.useState(null),F=useCollection(n),[V,H]=React__namespace.useState(!1),z=React__namespace.useRef(!1);React__namespace.useEffect(()=>{if(I)return hideOthers(I)},[I]),useFocusGuards();const G=React__namespace.useCallback(ie=>{const[le,...oe]=F().map(Z=>Z.ref.current),[ae]=oe.slice(-1),ue=document.activeElement;for(const Z of ie)if(Z===ue||(Z==null||Z.scrollIntoView({block:"nearest"}),Z===le&&T&&(T.scrollTop=0),Z===ae&&T&&(T.scrollTop=T.scrollHeight),Z==null||Z.focus(),document.activeElement!==ue))return},[F,T]),K=React__namespace.useCallback(()=>G([N,I]),[G,N,I]);React__namespace.useEffect(()=>{V&&K()},[V,K]);const{onOpenChange:q,triggerPointerDownPosRef:W}=A;React__namespace.useEffect(()=>{if(I){let ie={x:0,y:0};const le=ae=>{var ue,Z;ie={x:Math.abs(Math.round(ae.pageX)-(((ue=W.current)==null?void 0:ue.x)??0)),y:Math.abs(Math.round(ae.pageY)-(((Z=W.current)==null?void 0:Z.y)??0))}},oe=ae=>{ie.x<=10&&ie.y<=10?ae.preventDefault():I.contains(ae.target)||q(!1),document.removeEventListener("pointermove",le),W.current=null};return W.current!==null&&(document.addEventListener("pointermove",le),document.addEventListener("pointerup",oe,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",le),document.removeEventListener("pointerup",oe,{capture:!0})}}},[I,q,W]),React__namespace.useEffect(()=>{const ie=()=>q(!1);return window.addEventListener("blur",ie),window.addEventListener("resize",ie),()=>{window.removeEventListener("blur",ie),window.removeEventListener("resize",ie)}},[q]);const[U,Q]=useTypeaheadSearch(ie=>{const le=F().filter(ue=>!ue.disabled),oe=le.find(ue=>ue.ref.current===document.activeElement),ae=findNextItem(le,ie,oe);ae&&setTimeout(()=>ae.ref.current.focus())}),ee=React__namespace.useCallback((ie,le,oe)=>{const ae=!z.current&&!oe;(A.value!==void 0&&A.value===le||ae)&&(D(ie),ae&&(z.current=!0))},[A.value]),se=React__namespace.useCallback(()=>I==null?void 0:I.focus(),[I]),J=React__namespace.useCallback((ie,le,oe)=>{const ae=!z.current&&!oe;(A.value!==void 0&&A.value===le||ae)&&L(ie)},[A.value]),te=i==="popper"?SelectPopperPosition:SelectItemAlignedPosition,ce=te===SelectPopperPosition?{side:d,sideOffset:f,align:p,alignOffset:m,arrowPadding:g,collisionBoundary:b,collisionPadding:_,sticky:E,hideWhenDetached:R,avoidCollisions:S}:{};return jsxRuntime.jsx(SelectContentProvider,{scope:n,content:I,viewport:T,onViewportChange:O,itemRefCallback:ee,selectedItem:N,onItemLeave:se,itemTextRefCallback:J,focusSelectedItem:K,selectedItemText:B,position:i,isPositioned:V,searchRef:U,children:jsxRuntime.jsx(ReactRemoveScroll,{as:Slot,allowPinchZoom:!0,children:jsxRuntime.jsx(FocusScope,{asChild:!0,trapped:A.open,onMountAutoFocus:ie=>{ie.preventDefault()},onUnmountAutoFocus:composeEventHandlers(o,ie=>{var le;(le=A.trigger)==null||le.focus({preventScroll:!0}),ie.preventDefault()}),children:jsxRuntime.jsx(DismissableLayer,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:ie=>ie.preventDefault(),onDismiss:()=>A.onOpenChange(!1),children:jsxRuntime.jsx(te,{role:"listbox",id:A.contentId,"data-state":A.open?"open":"closed",dir:A.dir,onContextMenu:ie=>ie.preventDefault(),...C,...ce,onPlaced:()=>H(!0),ref:j,style:{display:"flex",flexDirection:"column",outline:"none",...C.style},onKeyDown:composeEventHandlers(C.onKeyDown,ie=>{const le=ie.ctrlKey||ie.altKey||ie.metaKey;if(ie.key==="Tab"&&ie.preventDefault(),!le&&ie.key.length===1&&Q(ie.key),["ArrowUp","ArrowDown","Home","End"].includes(ie.key)){let ae=F().filter(ue=>!ue.disabled).map(ue=>ue.ref.current);if(["ArrowUp","End"].includes(ie.key)&&(ae=ae.slice().reverse()),["ArrowUp","ArrowDown"].includes(ie.key)){const ue=ie.target,Z=ae.indexOf(ue);ae=ae.slice(Z+1)}setTimeout(()=>G(ae)),ie.preventDefault()}})})})})})})});SelectContentImpl.displayName=CONTENT_IMPL_NAME;var ITEM_ALIGNED_POSITION_NAME="SelectItemAlignedPosition",SelectItemAlignedPosition=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:i,...o}=e,l=useSelectContext(CONTENT_NAME,n),u=useSelectContentContext(CONTENT_NAME,n),[d,f]=React__namespace.useState(null),[p,m]=React__namespace.useState(null),g=useComposedRefs(t,j=>m(j)),b=useCollection(n),_=React__namespace.useRef(!1),E=React__namespace.useRef(!0),{viewport:R,selectedItem:S,selectedItemText:C,focusSelectedItem:A}=u,I=React__namespace.useCallback(()=>{if(l.trigger&&l.valueNode&&d&&p&&R&&S&&C){const j=l.trigger.getBoundingClientRect(),N=p.getBoundingClientRect(),D=l.valueNode.getBoundingClientRect(),B=C.getBoundingClientRect();if(l.dir!=="rtl"){const ue=B.left-N.left,Z=D.left-ue,fe=j.left-Z,ne=j.width+fe,de=Math.max(ne,N.width),pe=window.innerWidth-CONTENT_MARGIN,me=clamp(Z,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,pe-de)]);d.style.minWidth=ne+"px",d.style.left=me+"px"}else{const ue=N.right-B.right,Z=window.innerWidth-D.right-ue,fe=window.innerWidth-j.right-Z,ne=j.width+fe,de=Math.max(ne,N.width),pe=window.innerWidth-CONTENT_MARGIN,me=clamp(Z,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,pe-de)]);d.style.minWidth=ne+"px",d.style.right=me+"px"}const L=b(),F=window.innerHeight-CONTENT_MARGIN*2,V=R.scrollHeight,H=window.getComputedStyle(p),z=parseInt(H.borderTopWidth,10),G=parseInt(H.paddingTop,10),K=parseInt(H.borderBottomWidth,10),q=parseInt(H.paddingBottom,10),W=z+G+V+q+K,U=Math.min(S.offsetHeight*5,W),Q=window.getComputedStyle(R),ee=parseInt(Q.paddingTop,10),se=parseInt(Q.paddingBottom,10),J=j.top+j.height/2-CONTENT_MARGIN,te=F-J,ce=S.offsetHeight/2,ie=S.offsetTop+ce,le=z+G+ie,oe=W-le;if(le<=J){const ue=L.length>0&&S===L[L.length-1].ref.current;d.style.bottom="0px";const Z=p.clientHeight-R.offsetTop-R.offsetHeight,fe=Math.max(te,ce+(ue?se:0)+Z+K),ne=le+fe;d.style.height=ne+"px"}else{const ue=L.length>0&&S===L[0].ref.current;d.style.top="0px";const fe=Math.max(J,z+R.offsetTop+(ue?ee:0)+ce)+oe;d.style.height=fe+"px",R.scrollTop=le-J+R.offsetTop}d.style.margin=`${CONTENT_MARGIN}px 0`,d.style.minHeight=U+"px",d.style.maxHeight=F+"px",i==null||i(),requestAnimationFrame(()=>_.current=!0)}},[b,l.trigger,l.valueNode,d,p,R,S,C,l.dir,i]);useLayoutEffect2(()=>I(),[I]);const[M,T]=React__namespace.useState();useLayoutEffect2(()=>{p&&T(window.getComputedStyle(p).zIndex)},[p]);const O=React__namespace.useCallback(j=>{j&&E.current===!0&&(I(),A==null||A(),E.current=!1)},[I,A]);return jsxRuntime.jsx(SelectViewportProvider,{scope:n,contentWrapper:d,shouldExpandOnScrollRef:_,onScrollButtonChange:O,children:jsxRuntime.jsx("div",{ref:f,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:M},children:jsxRuntime.jsx(Primitive.div,{...o,ref:g,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});SelectItemAlignedPosition.displayName=ITEM_ALIGNED_POSITION_NAME;var POPPER_POSITION_NAME="SelectPopperPosition",SelectPopperPosition=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,align:i="start",collisionPadding:o=CONTENT_MARGIN,...l}=e,u=usePopperScope(n);return jsxRuntime.jsx(Content$1,{...u,...l,ref:t,align:i,collisionPadding:o,style:{boxSizing:"border-box",...l.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});SelectPopperPosition.displayName=POPPER_POSITION_NAME;var[SelectViewportProvider,useSelectViewportContext]=createSelectContext(CONTENT_NAME,{}),VIEWPORT_NAME="SelectViewport",SelectViewport=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:i,...o}=e,l=useSelectContentContext(VIEWPORT_NAME,n),u=useSelectViewportContext(VIEWPORT_NAME,n),d=useComposedRefs(t,l.onViewportChange),f=React__namespace.useRef(0);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),jsxRuntime.jsx(Collection.Slot,{scope:n,children:jsxRuntime.jsx(Primitive.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:d,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:composeEventHandlers(o.onScroll,p=>{const m=p.currentTarget,{contentWrapper:g,shouldExpandOnScrollRef:b}=u;if(b!=null&&b.current&&g){const _=Math.abs(f.current-m.scrollTop);if(_>0){const E=window.innerHeight-CONTENT_MARGIN*2,R=parseFloat(g.style.minHeight),S=parseFloat(g.style.height),C=Math.max(R,S);if(C<E){const A=C+_,I=Math.min(E,A),M=A-I;g.style.height=I+"px",g.style.bottom==="0px"&&(m.scrollTop=M>0?M:0,g.style.justifyContent="flex-end")}}}f.current=m.scrollTop})})})]})});SelectViewport.displayName=VIEWPORT_NAME;var GROUP_NAME="SelectGroup",[SelectGroupContextProvider,useSelectGroupContext]=createSelectContext(GROUP_NAME),SelectGroup=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...i}=e,o=useId();return jsxRuntime.jsx(SelectGroupContextProvider,{scope:n,id:o,children:jsxRuntime.jsx(Primitive.div,{role:"group","aria-labelledby":o,...i,ref:t})})});SelectGroup.displayName=GROUP_NAME;var LABEL_NAME="SelectLabel",SelectLabel$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...i}=e,o=useSelectGroupContext(LABEL_NAME,n);return jsxRuntime.jsx(Primitive.div,{id:o.id,...i,ref:t})});SelectLabel$1.displayName=LABEL_NAME;var ITEM_NAME="SelectItem",[SelectItemContextProvider,useSelectItemContext]=createSelectContext(ITEM_NAME),SelectItem$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,value:i,disabled:o=!1,textValue:l,...u}=e,d=useSelectContext(ITEM_NAME,n),f=useSelectContentContext(ITEM_NAME,n),p=d.value===i,[m,g]=React__namespace.useState(l??""),[b,_]=React__namespace.useState(!1),E=useComposedRefs(t,A=>{var I;return(I=f.itemRefCallback)==null?void 0:I.call(f,A,i,o)}),R=useId(),S=React__namespace.useRef("touch"),C=()=>{o||(d.onValueChange(i),d.onOpenChange(!1))};if(i==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return jsxRuntime.jsx(SelectItemContextProvider,{scope:n,value:i,disabled:o,textId:R,isSelected:p,onItemTextChange:React__namespace.useCallback(A=>{g(I=>I||((A==null?void 0:A.textContent)??"").trim())},[]),children:jsxRuntime.jsx(Collection.ItemSlot,{scope:n,value:i,disabled:o,textValue:m,children:jsxRuntime.jsx(Primitive.div,{role:"option","aria-labelledby":R,"data-highlighted":b?"":void 0,"aria-selected":p&&b,"data-state":p?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...u,ref:E,onFocus:composeEventHandlers(u.onFocus,()=>_(!0)),onBlur:composeEventHandlers(u.onBlur,()=>_(!1)),onClick:composeEventHandlers(u.onClick,()=>{S.current!=="mouse"&&C()}),onPointerUp:composeEventHandlers(u.onPointerUp,()=>{S.current==="mouse"&&C()}),onPointerDown:composeEventHandlers(u.onPointerDown,A=>{S.current=A.pointerType}),onPointerMove:composeEventHandlers(u.onPointerMove,A=>{var I;S.current=A.pointerType,o?(I=f.onItemLeave)==null||I.call(f):S.current==="mouse"&&A.currentTarget.focus({preventScroll:!0})}),onPointerLeave:composeEventHandlers(u.onPointerLeave,A=>{var I;A.currentTarget===document.activeElement&&((I=f.onItemLeave)==null||I.call(f))}),onKeyDown:composeEventHandlers(u.onKeyDown,A=>{var M;((M=f.searchRef)==null?void 0:M.current)!==""&&A.key===" "||(SELECTION_KEYS.includes(A.key)&&C(),A.key===" "&&A.preventDefault())})})})})});SelectItem$1.displayName=ITEM_NAME;var ITEM_TEXT_NAME="SelectItemText",SelectItemText=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,className:i,style:o,...l}=e,u=useSelectContext(ITEM_TEXT_NAME,n),d=useSelectContentContext(ITEM_TEXT_NAME,n),f=useSelectItemContext(ITEM_TEXT_NAME,n),p=useSelectNativeOptionsContext(ITEM_TEXT_NAME,n),[m,g]=React__namespace.useState(null),b=useComposedRefs(t,C=>g(C),f.onItemTextChange,C=>{var A;return(A=d.itemTextRefCallback)==null?void 0:A.call(d,C,f.value,f.disabled)}),_=m==null?void 0:m.textContent,E=React__namespace.useMemo(()=>jsxRuntime.jsx("option",{value:f.value,disabled:f.disabled,children:_},f.value),[f.disabled,f.value,_]),{onNativeOptionAdd:R,onNativeOptionRemove:S}=p;return useLayoutEffect2(()=>(R(E),()=>S(E)),[R,S,E]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Primitive.span,{id:f.textId,...l,ref:b}),f.isSelected&&u.valueNode&&!u.valueNodeHasChildren?ReactDOM__namespace.createPortal(l.children,u.valueNode):null]})});SelectItemText.displayName=ITEM_TEXT_NAME;var ITEM_INDICATOR_NAME="SelectItemIndicator",SelectItemIndicator=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...i}=e;return useSelectItemContext(ITEM_INDICATOR_NAME,n).isSelected?jsxRuntime.jsx(Primitive.span,{"aria-hidden":!0,...i,ref:t}):null});SelectItemIndicator.displayName=ITEM_INDICATOR_NAME;var SCROLL_UP_BUTTON_NAME="SelectScrollUpButton",SelectScrollUpButton$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContentContext(SCROLL_UP_BUTTON_NAME,e.__scopeSelect),i=useSelectViewportContext(SCROLL_UP_BUTTON_NAME,e.__scopeSelect),[o,l]=React__namespace.useState(!1),u=useComposedRefs(t,i.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let d=function(){const p=f.scrollTop>0;l(p)};const f=n.viewport;return d(),f.addEventListener("scroll",d),()=>f.removeEventListener("scroll",d)}},[n.viewport,n.isPositioned]),o?jsxRuntime.jsx(SelectScrollButtonImpl,{...e,ref:u,onAutoScroll:()=>{const{viewport:d,selectedItem:f}=n;d&&f&&(d.scrollTop=d.scrollTop-f.offsetHeight)}}):null});SelectScrollUpButton$1.displayName=SCROLL_UP_BUTTON_NAME;var SCROLL_DOWN_BUTTON_NAME="SelectScrollDownButton",SelectScrollDownButton$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContentContext(SCROLL_DOWN_BUTTON_NAME,e.__scopeSelect),i=useSelectViewportContext(SCROLL_DOWN_BUTTON_NAME,e.__scopeSelect),[o,l]=React__namespace.useState(!1),u=useComposedRefs(t,i.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let d=function(){const p=f.scrollHeight-f.clientHeight,m=Math.ceil(f.scrollTop)<p;l(m)};const f=n.viewport;return d(),f.addEventListener("scroll",d),()=>f.removeEventListener("scroll",d)}},[n.viewport,n.isPositioned]),o?jsxRuntime.jsx(SelectScrollButtonImpl,{...e,ref:u,onAutoScroll:()=>{const{viewport:d,selectedItem:f}=n;d&&f&&(d.scrollTop=d.scrollTop+f.offsetHeight)}}):null});SelectScrollDownButton$1.displayName=SCROLL_DOWN_BUTTON_NAME;var SelectScrollButtonImpl=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:i,...o}=e,l=useSelectContentContext("SelectScrollButton",n),u=React__namespace.useRef(null),d=useCollection(n),f=React__namespace.useCallback(()=>{u.current!==null&&(window.clearInterval(u.current),u.current=null)},[]);return React__namespace.useEffect(()=>()=>f(),[f]),useLayoutEffect2(()=>{var m;const p=d().find(g=>g.ref.current===document.activeElement);(m=p==null?void 0:p.ref.current)==null||m.scrollIntoView({block:"nearest"})},[d]),jsxRuntime.jsx(Primitive.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:composeEventHandlers(o.onPointerDown,()=>{u.current===null&&(u.current=window.setInterval(i,50))}),onPointerMove:composeEventHandlers(o.onPointerMove,()=>{var p;(p=l.onItemLeave)==null||p.call(l),u.current===null&&(u.current=window.setInterval(i,50))}),onPointerLeave:composeEventHandlers(o.onPointerLeave,()=>{f()})})}),SEPARATOR_NAME="SelectSeparator",SelectSeparator$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...i}=e;return jsxRuntime.jsx(Primitive.div,{"aria-hidden":!0,...i,ref:t})});SelectSeparator$1.displayName=SEPARATOR_NAME;var ARROW_NAME="SelectArrow",SelectArrow=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...i}=e,o=usePopperScope(n),l=useSelectContext(ARROW_NAME,n),u=useSelectContentContext(ARROW_NAME,n);return l.open&&u.position==="popper"?jsxRuntime.jsx(Arrow,{...o,...i,ref:t}):null});SelectArrow.displayName=ARROW_NAME;function shouldShowPlaceholder(e){return e===""||e===void 0}var BubbleSelect=React__namespace.forwardRef((e,t)=>{const{value:n,...i}=e,o=React__namespace.useRef(null),l=useComposedRefs(t,o),u=usePrevious(n);return React__namespace.useEffect(()=>{const d=o.current,f=window.HTMLSelectElement.prototype,m=Object.getOwnPropertyDescriptor(f,"value").set;if(u!==n&&m){const g=new Event("change",{bubbles:!0});m.call(d,n),d.dispatchEvent(g)}},[u,n]),jsxRuntime.jsx(VisuallyHidden,{asChild:!0,children:jsxRuntime.jsx("select",{...i,ref:l,defaultValue:n})})});BubbleSelect.displayName="BubbleSelect";function useTypeaheadSearch(e){const t=useCallbackRef$1(e),n=React__namespace.useRef(""),i=React__namespace.useRef(0),o=React__namespace.useCallback(u=>{const d=n.current+u;t(d),function f(p){n.current=p,window.clearTimeout(i.current),p!==""&&(i.current=window.setTimeout(()=>f(""),1e3))}(d)},[t]),l=React__namespace.useCallback(()=>{n.current="",window.clearTimeout(i.current)},[]);return React__namespace.useEffect(()=>()=>window.clearTimeout(i.current),[]),[n,o,l]}function findNextItem(e,t,n){const o=t.length>1&&Array.from(t).every(p=>p===t[0])?t[0]:t,l=n?e.indexOf(n):-1;let u=wrapArray(e,Math.max(l,0));o.length===1&&(u=u.filter(p=>p!==n));const f=u.find(p=>p.textValue.toLowerCase().startsWith(o.toLowerCase()));return f!==n?f:void 0}function wrapArray(e,t){return e.map((n,i)=>e[(t+i)%e.length])}var Root2=Select$1,Trigger=SelectTrigger$1,Value=SelectValue$1,Icon=SelectIcon,Portal=SelectPortal,Content2=SelectContent$1,Viewport=SelectViewport,Label=SelectLabel$1,Item=SelectItem$1,ItemText=SelectItemText,ItemIndicator=SelectItemIndicator,ScrollUpButton=SelectScrollUpButton$1,ScrollDownButton=SelectScrollDownButton$1,Separator=SelectSeparator$1;const Select=Root2,SelectValue=Value,SelectTrigger=React__namespace.forwardRef(({className:e,children:t,...n},i)=>jsxRuntime.jsxs(Trigger,{ref:i,className:cn("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,jsxRuntime.jsx(Icon,{asChild:!0,children:jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));SelectTrigger.displayName=Trigger.displayName;const SelectScrollUpButton=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(ScrollUpButton,{ref:n,className:cn("flex cursor-default items-center justify-center py-1",e),...t,children:jsxRuntime.jsx(ChevronUp,{className:"h-4 w-4"})}));SelectScrollUpButton.displayName=ScrollUpButton.displayName;const SelectScrollDownButton=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(ScrollDownButton,{ref:n,className:cn("flex cursor-default items-center justify-center py-1",e),...t,children:jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4"})}));SelectScrollDownButton.displayName=ScrollDownButton.displayName;const SelectContent=React__namespace.forwardRef(({className:e,children:t,position:n="popper",...i},o)=>jsxRuntime.jsx(Portal,{children:jsxRuntime.jsxs(Content2,{ref:o,className:cn("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...i,children:[jsxRuntime.jsx(SelectScrollUpButton,{}),jsxRuntime.jsx(Viewport,{className:cn("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),jsxRuntime.jsx(SelectScrollDownButton,{})]})}));SelectContent.displayName=Content2.displayName;const SelectLabel=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Label,{ref:n,className:cn("px-2 py-1.5 text-sm font-semibold",e),...t}));SelectLabel.displayName=Label.displayName;const SelectItem=React__namespace.forwardRef(({className:e,children:t,...n},i)=>jsxRuntime.jsxs(Item,{ref:i,className:cn("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[jsxRuntime.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:jsxRuntime.jsx(ItemIndicator,{children:jsxRuntime.jsx(Check,{className:"h-4 w-4"})})}),jsxRuntime.jsx(ItemText,{children:t})]}));SelectItem.displayName=Item.displayName;const SelectSeparator=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Separator,{ref:n,className:cn("-mx-1 my-1 h-px bg-muted",e),...t}));SelectSeparator.displayName=Separator.displayName;var SWITCH_NAME="Switch",[createSwitchContext,createSwitchScope]=createContextScope(SWITCH_NAME),[SwitchProvider,useSwitchContext]=createSwitchContext(SWITCH_NAME),Switch$1=React__namespace.forwardRef((e,t)=>{const{__scopeSwitch:n,name:i,checked:o,defaultChecked:l,required:u,disabled:d,value:f="on",onCheckedChange:p,form:m,...g}=e,[b,_]=React__namespace.useState(null),E=useComposedRefs(t,I=>_(I)),R=React__namespace.useRef(!1),S=b?m||!!b.closest("form"):!0,[C=!1,A]=useControllableState({prop:o,defaultProp:l,onChange:p});return jsxRuntime.jsxs(SwitchProvider,{scope:n,checked:C,disabled:d,children:[jsxRuntime.jsx(Primitive.button,{type:"button",role:"switch","aria-checked":C,"aria-required":u,"data-state":getState(C),"data-disabled":d?"":void 0,disabled:d,value:f,...g,ref:E,onClick:composeEventHandlers(e.onClick,I=>{A(M=>!M),S&&(R.current=I.isPropagationStopped(),R.current||I.stopPropagation())})}),S&&jsxRuntime.jsx(BubbleInput,{control:b,bubbles:!R.current,name:i,value:f,checked:C,required:u,disabled:d,form:m,style:{transform:"translateX(-100%)"}})]})});Switch$1.displayName=SWITCH_NAME;var THUMB_NAME="SwitchThumb",SwitchThumb=React__namespace.forwardRef((e,t)=>{const{__scopeSwitch:n,...i}=e,o=useSwitchContext(THUMB_NAME,n);return jsxRuntime.jsx(Primitive.span,{"data-state":getState(o.checked),"data-disabled":o.disabled?"":void 0,...i,ref:t})});SwitchThumb.displayName=THUMB_NAME;var BubbleInput=e=>{const{control:t,checked:n,bubbles:i=!0,...o}=e,l=React__namespace.useRef(null),u=usePrevious(n),d=useSize(t);return React__namespace.useEffect(()=>{const f=l.current,p=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(p,"checked").set;if(u!==n&&g){const b=new Event("click",{bubbles:i});g.call(f,n),f.dispatchEvent(b)}},[u,n,i]),jsxRuntime.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:l,style:{...e.style,...d,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function getState(e){return e?"checked":"unchecked"}var Root=Switch$1,Thumb=SwitchThumb;const Switch=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Root,{className:cn("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:jsxRuntime.jsx(Thumb,{className:cn("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));Switch.displayName=Root.displayName;const DAYS_OF_WEEK=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];function ManufacturerReorderingCard({manufacturer:e,onSave:t,loading:n=!1,saving:i=!1}){const[o,l]=React.useState({...e}),u=(b,_)=>{l(E=>({...E,[b]:_}))},d=(b,_)=>{l(E=>({...E,[b]:_}))},f=(b,_)=>{l(E=>({...E,[b]:_}))},p=()=>{i||t(o)},m=b=>b===void 0||b<0||b>6?"Monday":DAYS_OF_WEEK[b],g=b=>DAYS_OF_WEEK.indexOf(b);return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[n?jsxRuntime.jsx(Skeleton,{className:"h-8 w-32"}):jsxRuntime.jsx(CardTitle,{className:"text-lg font-bold",children:"Reordering"}),n?jsxRuntime.jsx(Skeleton,{className:"h-4 w-full mt-2"}):jsxRuntime.jsx(CardDescription,{className:"text-sm",children:"Adjust your reordering settings to control lead times, stocking weeks, minimum orders, and reorder dates, enhancing efficiency in restocking processes."})]}),jsxRuntime.jsx(CardContent,{className:"space-y-6",children:n?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-10"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx("div",{className:"ml-2 w-12"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx("div",{className:"ml-2 w-12"})]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-60"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{id:"automatic-reordering",checked:o.AutoUpdate,onCheckedChange:b=>u("AutoUpdate",b),disabled:i}),jsxRuntime.jsx(Label$2,{htmlFor:"automatic-reordering",children:"Automatic Reordering"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"reorder-date",children:"Automatic Reorder Date"}),jsxRuntime.jsxs(Select,{value:m(o.AutoReorderDate),onValueChange:b=>d("AutoReorderDate",g(b)),disabled:i,children:[jsxRuntime.jsx(SelectTrigger,{id:"reorder-date",children:jsxRuntime.jsx(SelectValue,{placeholder:"Select day"})}),jsxRuntime.jsx(SelectContent,{children:DAYS_OF_WEEK.map(b=>jsxRuntime.jsx(SelectItem,{value:b,children:b},b))})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"weeks-stocking",children:"Default Weeks of Stocking"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Input,{id:"weeks-stocking",type:"number",value:o.DefaultWeeksOfStocking||"",onChange:b=>d("DefaultWeeksOfStocking",Number(b.target.value)),disabled:i}),jsxRuntime.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"weeks"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"minimum-order",children:"Default Minimum Order"}),jsxRuntime.jsxs("div",{className:"flex items-center relative",children:[jsxRuntime.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2",children:"$"}),jsxRuntime.jsx(Input,{id:"minimum-order",type:"number",className:"pl-6",value:o.DefaultMinimumOrder||"",onChange:b=>d("DefaultMinimumOrder",Number(b.target.value)),disabled:i})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"lead-time",children:"Default Lead Time"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Input,{id:"lead-time",type:"number",value:o.DefaultLeadTime||"",onChange:b=>d("DefaultLeadTime",Number(b.target.value)),disabled:i}),jsxRuntime.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"days"})]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"order-confirmations",children:"Send Order Confirmations To"}),jsxRuntime.jsx(Input,{id:"order-confirmations",type:"email",value:o.POEmail||"",onChange:b=>f("POEmail",b.target.value),placeholder:"email@example.com",disabled:i})]})]})}),jsxRuntime.jsx(CardFooter,{className:"flex justify-end",children:n?jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"}):jsxRuntime.jsxs(Button,{onClick:p,disabled:i,children:[i&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]})})]})}function ActiveOrdersCard({orders:e,loading:t=!1}){const n=l=>new Intl.NumberFormat("en-CA",{style:"currency",currency:"CAD",minimumFractionDigits:2,maximumFractionDigits:2}).format(l),i=React.useMemo(()=>{if(!e||e.length===0)return{all:{orders:0,amount:0},processing:{orders:0,amount:0},shipped:{orders:0,amount:0},delayed:{orders:0,amount:0}};const l=e.filter(C=>C.DocumentType==="Order"),u=e.filter(C=>C.DocumentType==="Shipment"),d=l.filter(C=>C.WarehouseCode!=="3PLE"),f=d.reduce((C,A)=>C+(A.Quantity||0),0),p=d.reduce((C,A)=>C+(A.ExtendedPrice||0),0),m=l.filter(C=>C.WarehouseCode==="3PLE"),g=m.reduce((C,A)=>C+(A.Quantity||0),0),b=m.reduce((C,A)=>C+(A.ExtendedPrice||0),0),_=u.length,E=u.reduce((C,A)=>C+(A.ExtendedPrice||0),0),R=f+g+_,S=p+b+E;return{all:{orders:R,amount:S},processing:{orders:f,amount:p},shipped:{orders:_,amount:E},delayed:{orders:g,amount:b}}},[e]),o=[{name:"All",icon:Package,color:"bg-blue-500",textColor:"text-blue-600",orders:i.all.orders,amount:i.all.amount},{name:"Processing",icon:RefreshCcw,color:"bg-yellow-500",textColor:"text-yellow-600",orders:i.processing.orders,amount:i.processing.amount},{name:"Shipped",icon:Truck,color:"bg-green-500",textColor:"text-green-600",orders:i.shipped.orders,amount:i.shipped.amount},{name:"Delayed",icon:CircleAlert,color:"bg-red-500",textColor:"text-red-600",orders:i.delayed.orders,amount:i.delayed.amount}];return t?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-lg font-bold",children:"Active Orders"})}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 p-4",children:[1,2,3,4].map(l=>jsxRuntime.jsxs("div",{className:"overflow-hidden rounded-md border",children:[jsxRuntime.jsx("div",{className:"bg-slate-200 dark:bg-slate-700 h-[3px]"}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-16 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-7 w-12"})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-16 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]})]})]},l))})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-lg font-bold",children:"Active Orders"})}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 p-4",children:o.map(l=>jsxRuntime.jsxs("div",{className:"overflow-hidden rounded-md border",children:[jsxRuntime.jsx("div",{className:`${l.color} bg-opacity-60 h-[3px]`}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-base",children:l.name}),jsxRuntime.jsx("div",{className:`${l.color} bg-opacity-90 p-2 rounded-full`,children:jsxRuntime.jsx(l.icon,{className:"size-4 shrink-0 text-white"})})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Orders"}),jsxRuntime.jsx("p",{className:"text-xl font-bold",children:l.orders})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Amount"}),jsxRuntime.jsx("p",{className:"text-base font-semibold",children:n(l.amount)})]})]})]})]},l.name))})]})}function SalesOverviewCard({salesData:e,loading:t=!1}){const n=o=>new Intl.NumberFormat("en-CA",{style:"currency",currency:"CAD",minimumFractionDigits:2,maximumFractionDigits:2}).format(o),i=[{title:"Last 30 days",amount:(e==null?void 0:e.SalesLast30Days)||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-blue-500"},{title:"Last 3 months",amount:(e==null?void 0:e.SalesLast3Months)||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-amber-500"},{title:"Year to date",amount:(e==null?void 0:e.SalesYearToDay)||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-emerald-500"}];return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-lg sm:text-xl",children:"Sales Overview"})}),jsxRuntime.jsx(CardContent,{className:"pt-4 px-3 sm:px-6",children:t||!e?jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:Array(3).fill(0).map((o,l)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-7 w-28"})]})]},l))}):jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:i.map((o,l)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx("h3",{className:"text-sm sm:text-base font-medium",children:o.title}),jsxRuntime.jsx("div",{className:`p-2 rounded-full ${o.color}`,children:o.icon})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Amount"}),jsxRuntime.jsx("p",{className:"text-base sm:text-lg font-bold",children:n(o.amount)})]})]},l))})})]})}function ResellerQualificationsCard({qualifications:e=[],loading:t=!1}){return t?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Qualifications"})}),jsxRuntime.jsx(CardContent,{className:"p-6",children:jsxRuntime.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4 gap-y-8",children:Array.from({length:10}).map((n,i)=>jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-24 rounded-md mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"})]},i))})})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Qualifications"})}),jsxRuntime.jsx(CardContent,{className:"p-6",children:jsxRuntime.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4 gap-y-8",children:e.map((n,i)=>jsxRuntime.jsx(ManufacturerLogo,{manufacturerId:n.ManufacturerId,opportunityNumber:n.DefaultOpportunityNumber},`${n.ManufacturerId}-${i}`))})})]})}function ManufacturerLogo({manufacturerId:e,opportunityNumber:t}){const[n,i]=React.useState(null),[o,l]=React.useState(!0),[u,d]=React.useState(!1),[f,p]=React.useState(null),m=React.useMemo(()=>e?{logoUrl:`https://api.randmar.io/V4/Partner/${e}/Account/Logo?width=96&height=48`,logoExistsUrl:`https://api.randmar.io/V4/Partner/${e}/Account/Logo/Exists`}:null,[e]);return React.useEffect(()=>{if(!m)return;let g=!0;p(null);const b=async()=>{try{const R=await fetch(m.logoExistsUrl);if(R.ok){const C=(await R.text()).toLowerCase()==="true";return g&&d(C),C}return!1}catch(R){return console.error("Failed to check if logo exists:",R),g&&d(!1),!1}},_=async()=>{g&&l(!0);try{const R=await fetch(m.logoUrl);if(R.ok){const S=await R.blob();g&&(n&&URL.revokeObjectURL(n),i(URL.createObjectURL(S)))}else throw new Error(`Failed to load logo: ${R.status}`)}catch(R){console.error("Failed to load logo:",R),g&&p("Failed to load manufacturer logo")}finally{g&&l(!1)}};return(async()=>{await b()?_():l(!1)})(),()=>{g=!1,n&&URL.revokeObjectURL(n)}},[m]),jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx("div",{className:"h-12 flex items-center justify-center mb-2",children:o?jsxRuntime.jsx(Skeleton,{className:"h-12 w-24 rounded-md"}):u&&n?jsxRuntime.jsx("img",{src:n,alt:"Manufacturer logo",className:"max-h-12 max-w-24 object-contain",onError:()=>p("Failed to load logo")}):jsxRuntime.jsx("div",{className:"h-12 w-24 flex items-center justify-center bg-slate-100 rounded-md text-xs text-slate-500",children:e?e.substring(0,8):"No ID"})}),t&&jsxRuntime.jsx(Badge,{variant:"outline",className:"text-xs",children:t}),f&&jsxRuntime.jsx("div",{className:"text-red-500 text-xs mt-1",role:"alert",children:f})]})}exports.ActiveOrdersCard=ActiveOrdersCard,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.CountryFlag=CountryFlag,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.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.ManufacturerReorderingCard=ManufacturerReorderingCard,exports.Navbar=Navbar,exports.PartnerCard=PartnerCard,exports.Preloader=Preloader,exports.ProductCard=ProductCard,exports.ProductImage=ProductImage,exports.ProductInventoryGrid=ProductInventoryGrid,exports.ResellerCard=ResellerCard,exports.ResellerQualificationsCard=ResellerQualificationsCard,exports.SalesOverviewCard=SalesOverviewCard,exports.ScrollArea=ScrollArea,exports.ScrollBar=ScrollBar,exports.Select=Select,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.Tabs=Tabs,exports.TabsContent=TabsContent,exports.TabsList=TabsList,exports.TabsTrigger=TabsTrigger,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.useIsMobile=useIsMobile,exports.useSidebar=useSidebar,exports.useToast=useToast,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
|
|
956
|
+
`,onClick:()=>{D(ae)&&_(ae.BidNumber!=(b==null?void 0:b.BidNumber)?ae: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:ae.Opportunity}),jsxRuntime.jsxs("span",{className:"text-xs text-neutral-900",children:[ae.BidNumber," ",!D(ae)&&jsxRuntime.jsx(Badge,{variant:"outline",className:"text-xs mx-1 h-5 bg-gray-100",children:"Currently unavailable"})]})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end",children:[jsxRuntime.jsxs("span",{className:"font-semibold",children:["$",(Z=ae.Price)==null?void 0:Z.toFixed(2)]}),ae.Rebate&&ae.Rebate>0&&jsxRuntime.jsxs("span",{className:"text-xs text-green-600",children:["Rebate: $",ae.Rebate.toFixed(2)]}),ae.EndDate&&jsxRuntime.jsxs("span",{className:"text-xs text-neutral-600",children:["Ends: ",K(ae.EndDate)]})]})]},ue)})})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[l&&jsxRuntime.jsx(reactRouterDom.Link,{to:l,children:jsxRuntime.jsxs(Button,{variant:"secondary",children:[jsxRuntime.jsx(Eye,{className:"mr-2"}),"View Product"]})}),((ce=e.Distribution)==null?void 0:ce.Inventory)&&jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsxs(Dialog,{open:S,onOpenChange:C,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{variant:"ghost",className:`flex items-center text-sm ${G>0?"text-green-700":"text-red-700"}`,children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),G>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[G," in stock"]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Out of stock"})]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-4xl",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsxs(DialogTitle,{className:"flex items-center",children:[jsxRuntime.jsx(Warehouse,{className:"mr-2",size:18}),"Inventory Information"]})}),jsxRuntime.jsx(ProductInventoryGrid,{inventory:e.Distribution.Inventory})]})]})})]})]}),e.Distribution&&jsxRuntime.jsxs("div",{className:"flex justify-between items-end mt-4",children:[jsxRuntime.jsx("div",{className:"flex-shrink-1 flex flex-col items-start gap-1",children:A>0?jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("span",{className:"text-2xl font-bold whitespace-nowrap",children:[jsxRuntime.jsx("span",{children:"Cost: $"}),A.toFixed(2),jsxRuntime.jsx("span",{children:" CAD"})]})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap",children:[jsxRuntime.jsxs("span",{className:"text-2xl font-bold whitespace-nowrap",children:[jsxRuntime.jsx("span",{children:"$"}),b?(le=(ie=e.Opportunities)==null?void 0:ie.find(ae=>ae.BidNumber==b.BidNumber))==null?void 0:le.Price:M.toFixed(2),jsxRuntime.jsx("span",{children:" CAD"})]}),E>0&&jsxRuntime.jsxs("span",{className:"text-muted-foreground line-through ml-2 whitespace-nowrap",children:["$",I.toFixed(2)]})]}),E>0&&jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs(Badge,{variant:"outline",className:"bg-red-50 text-red-700 rounded-full px-3 whitespace-nowrap",children:[jsxRuntime.jsxs("span",{children:[E,"% OFF"]}),((oe=e.InstantRebate)==null?void 0:oe.EndDate)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",e.InstantRebate.EndDate.split("T")[0]]}),(b==null?void 0:b.EndDate)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",b.EndDate.split("T")[0]]})]})})]})}),jsxRuntime.jsxs("div",{className:"flex flex-shrink-0 gap-2 ml-4",children:[typeof t<"u"&&t&&jsxRuntime.jsxs("div",{className:"flex items-center border rounded-md",children:[jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"rounded-r-none",onClick:F,disabled:typeof m<"u"&&(m<=1||!e.AvailableToBuy||d||!u),children:"-"}),jsxRuntime.jsx("input",{value:m,onChange:H,onBlur:z,onClick:ae=>ae.currentTarget.select(),className:`w-12 text-center border-0 focus:ring-0 focus:outline-none ${!e.AvailableToBuy||d||!u?"text-gray-400":""}`,disabled:!e.AvailableToBuy||d||!u}),jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"rounded-l-none",onClick:V,disabled:!e.AvailableToBuy||d||!u,children:"+"})]}),typeof t<"u"&&t&&jsxRuntime.jsx(Button,{className:"gap-2 whitespace-nowrap",onClick:q,disabled:!e.AvailableToBuy||d||!u,children:d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}),"Adding..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2"}),"Add to Cart"]})}),n&&jsxRuntime.jsx(Button,{className:"gap-2 whitespace-nowrap bg-green-600 hover:bg-green-700",onClick:f,disabled:p||!f,children:p?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"]})}),i]})]})]})})}function ManufacturerCard({manufacturer:e,link:t,actions:n,loading:i=!1}){var p;if(i||!e)return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-24 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"})]})]})}),jsxRuntime.jsx(CardContent,{className:"pb-2",children:jsxRuntime.jsxs("div",{className:"flex flex-col space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-14 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-36"})]})]})]})}),jsxRuntime.jsxs(CardFooter,{className:"flex justify-between pt-2 gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-40"})]})]});const o=e.ManufacturerId||"N/A",l=e.PublicName||"N/A",u=[e.City,e.Province,e.Country].filter(Boolean),d=u.length>0?u.join(", "):"Location not provided",f=((p=e.Tags)==null?void 0:p.split(",").map(m=>m.trim()).filter(Boolean))||[];return jsxRuntime.jsxs(Card,{className:"manufacturer-theme",children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx("img",{src:`https://api.randmar.io/V4/Partner/${o}/Account/Logo?width=64&height=64`,alt:`${l}'s logo`,className:"max-h-10 w-auto object-contain"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:"Manufacturer"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:o})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:e.PublicName||"N/A"}),e.Name&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:e.Name}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:d})]})]}),!!e.OnHold&&e.OnHold!==0&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"})]}),jsxRuntime.jsx(CardContent,{className:"pb-2",children:jsxRuntime.jsxs("div",{className:"flex flex-col space-y-2",children:[f.length>0&&jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:f.map((m,g)=>jsxRuntime.jsx(Badge,{children:m},g))}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[e.Phone&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Phone,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Phone})]}),e.PublicEmail&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.PublicEmail})]}),e.Website&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Globe,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Website})]}),e.CurrencyCode&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(DollarSign,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.CurrencyCode})]})]})]})}),(n||t)&&jsxRuntime.jsxs(CardFooter,{className:`flex pt-2 gap-2 ${n?"justify-between":"justify-end"}`,children:[n&&n,t&&jsxRuntime.jsx(Button,{className:"flex items-center gap-1",asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:t,target:"_blank",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4"}),"Go to Manufacturer"]})})]})]})}function ResellerCard({reseller:e,link:t,actions:n,loading:i=!1}){if(i||!e)return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-24 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"})]})]})}),jsxRuntime.jsx(CardContent,{className:"pb-2",children:jsxRuntime.jsx("div",{className:"flex flex-col space-y-2",children:jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-36"})]})]})})}),jsxRuntime.jsxs(CardFooter,{className:"flex justify-between pt-2 gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-40"})]})]});const o=e.ResellerId||"N/A",l=e.PublicName||"N/A",u=[e.City,e.Province,e.Country].filter(Boolean),d=u.length>0?u.join(", "):"Location not provided";return jsxRuntime.jsxs(Card,{className:"reseller-theme",children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx("img",{src:`https://api.randmar.io/V4/Partner/${o}/Account/Logo?width=64&height=64`,alt:`${l}'s logo`,className:"max-h-10 w-auto object-contain"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:"Reseller"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:o})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:e.PublicName||"N/A"}),e.Name&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:e.Name}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:d})]})]}),!!e.OnHold&&e.OnHold!==0&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"})]}),jsxRuntime.jsx(CardContent,{className:"pb-2",children:jsxRuntime.jsx("div",{className:"flex flex-col space-y-2",children:jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[e.Phone&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Phone,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Phone})]}),e.PublicEmail&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.PublicEmail})]}),e.Website&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Globe,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Website})]}),e.CurrencyCode&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(DollarSign,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.CurrencyCode})]})]})})}),(n||t)&&jsxRuntime.jsxs(CardFooter,{className:`flex pt-2 gap-2 ${n?"justify-between":"justify-end"}`,children:[n&&n,t&&jsxRuntime.jsx(Button,{className:"flex items-center gap-1",asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:t,target:"_blank",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4"}),"Go to Reseller"]})})]})]})}function usePrevious(e){const t=React__namespace.useRef({value:e,previous:e});return React__namespace.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var OPEN_KEYS=[" ","Enter","ArrowUp","ArrowDown"],SELECTION_KEYS=[" ","Enter"],SELECT_NAME="Select",[Collection,useCollection,createCollectionScope]=createCollection(SELECT_NAME),[createSelectContext,createSelectScope]=createContextScope(SELECT_NAME,[createCollectionScope,createPopperScope]),usePopperScope=createPopperScope(),[SelectProvider,useSelectContext]=createSelectContext(SELECT_NAME),[SelectNativeOptionsProvider,useSelectNativeOptionsContext]=createSelectContext(SELECT_NAME),Select$1=e=>{const{__scopeSelect:t,children:n,open:i,defaultOpen:o,onOpenChange:l,value:u,defaultValue:d,onValueChange:f,dir:p,name:m,autoComplete:g,disabled:b,required:_,form:E}=e,R=usePopperScope(t),[S,C]=React__namespace.useState(null),[A,I]=React__namespace.useState(null),[M,T]=React__namespace.useState(!1),O=useDirection(p),[j=!1,N]=useControllableState({prop:i,defaultProp:o,onChange:l}),[D,B]=useControllableState({prop:u,defaultProp:d,onChange:f}),L=React__namespace.useRef(null),F=S?E||!!S.closest("form"):!0,[V,H]=React__namespace.useState(new Set),z=Array.from(V).map(G=>G.props.value).join(";");return jsxRuntime.jsx(Root2$4,{...R,children:jsxRuntime.jsxs(SelectProvider,{required:_,scope:t,trigger:S,onTriggerChange:C,valueNode:A,onValueNodeChange:I,valueNodeHasChildren:M,onValueNodeHasChildrenChange:T,contentId:useId(),value:D,onValueChange:B,open:j,onOpenChange:N,dir:O,triggerPointerDownPosRef:L,disabled:b,children:[jsxRuntime.jsx(Collection.Provider,{scope:t,children:jsxRuntime.jsx(SelectNativeOptionsProvider,{scope:e.__scopeSelect,onNativeOptionAdd:React__namespace.useCallback(G=>{H(K=>new Set(K).add(G))},[]),onNativeOptionRemove:React__namespace.useCallback(G=>{H(K=>{const q=new Set(K);return q.delete(G),q})},[]),children:n})}),F?jsxRuntime.jsxs(BubbleSelect,{"aria-hidden":!0,required:_,tabIndex:-1,name:m,autoComplete:g,value:D,onChange:G=>B(G.target.value),disabled:b,form:E,children:[D===void 0?jsxRuntime.jsx("option",{value:""}):null,Array.from(V)]},z):null]})})};Select$1.displayName=SELECT_NAME;var TRIGGER_NAME="SelectTrigger",SelectTrigger$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:i=!1,...o}=e,l=usePopperScope(n),u=useSelectContext(TRIGGER_NAME,n),d=u.disabled||i,f=useComposedRefs(t,u.onTriggerChange),p=useCollection(n),m=React__namespace.useRef("touch"),[g,b,_]=useTypeaheadSearch(R=>{const S=p().filter(I=>!I.disabled),C=S.find(I=>I.value===u.value),A=findNextItem(S,R,C);A!==void 0&&u.onValueChange(A.value)}),E=R=>{d||(u.onOpenChange(!0),_()),R&&(u.triggerPointerDownPosRef.current={x:Math.round(R.pageX),y:Math.round(R.pageY)})};return jsxRuntime.jsx(Anchor,{asChild:!0,...l,children:jsxRuntime.jsx(Primitive.button,{type:"button",role:"combobox","aria-controls":u.contentId,"aria-expanded":u.open,"aria-required":u.required,"aria-autocomplete":"none",dir:u.dir,"data-state":u.open?"open":"closed",disabled:d,"data-disabled":d?"":void 0,"data-placeholder":shouldShowPlaceholder(u.value)?"":void 0,...o,ref:f,onClick:composeEventHandlers(o.onClick,R=>{R.currentTarget.focus(),m.current!=="mouse"&&E(R)}),onPointerDown:composeEventHandlers(o.onPointerDown,R=>{m.current=R.pointerType;const S=R.target;S.hasPointerCapture(R.pointerId)&&S.releasePointerCapture(R.pointerId),R.button===0&&R.ctrlKey===!1&&R.pointerType==="mouse"&&(E(R),R.preventDefault())}),onKeyDown:composeEventHandlers(o.onKeyDown,R=>{const S=g.current!=="";!(R.ctrlKey||R.altKey||R.metaKey)&&R.key.length===1&&b(R.key),!(S&&R.key===" ")&&OPEN_KEYS.includes(R.key)&&(E(),R.preventDefault())})})})});SelectTrigger$1.displayName=TRIGGER_NAME;var VALUE_NAME="SelectValue",SelectValue$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,className:i,style:o,children:l,placeholder:u="",...d}=e,f=useSelectContext(VALUE_NAME,n),{onValueNodeHasChildrenChange:p}=f,m=l!==void 0,g=useComposedRefs(t,f.onValueNodeChange);return useLayoutEffect2(()=>{p(m)},[p,m]),jsxRuntime.jsx(Primitive.span,{...d,ref:g,style:{pointerEvents:"none"},children:shouldShowPlaceholder(f.value)?jsxRuntime.jsx(jsxRuntime.Fragment,{children:u}):l})});SelectValue$1.displayName=VALUE_NAME;var ICON_NAME="SelectIcon",SelectIcon=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,children:i,...o}=e;return jsxRuntime.jsx(Primitive.span,{"aria-hidden":!0,...o,ref:t,children:i||"▼"})});SelectIcon.displayName=ICON_NAME;var PORTAL_NAME="SelectPortal",SelectPortal=e=>jsxRuntime.jsx(Portal$4,{asChild:!0,...e});SelectPortal.displayName=PORTAL_NAME;var CONTENT_NAME="SelectContent",SelectContent$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContext(CONTENT_NAME,e.__scopeSelect),[i,o]=React__namespace.useState();if(useLayoutEffect2(()=>{o(new DocumentFragment)},[]),!n.open){const l=i;return l?ReactDOM__namespace.createPortal(jsxRuntime.jsx(SelectContentProvider,{scope:e.__scopeSelect,children:jsxRuntime.jsx(Collection.Slot,{scope:e.__scopeSelect,children:jsxRuntime.jsx("div",{children:e.children})})}),l):null}return jsxRuntime.jsx(SelectContentImpl,{...e,ref:t})});SelectContent$1.displayName=CONTENT_NAME;var CONTENT_MARGIN=10,[SelectContentProvider,useSelectContentContext]=createSelectContext(CONTENT_NAME),CONTENT_IMPL_NAME="SelectContentImpl",Slot=createSlot("SelectContent.RemoveScroll"),SelectContentImpl=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,position:i="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:l,onPointerDownOutside:u,side:d,sideOffset:f,align:p,alignOffset:m,arrowPadding:g,collisionBoundary:b,collisionPadding:_,sticky:E,hideWhenDetached:R,avoidCollisions:S,...C}=e,A=useSelectContext(CONTENT_NAME,n),[I,M]=React__namespace.useState(null),[T,O]=React__namespace.useState(null),j=useComposedRefs(t,ie=>M(ie)),[N,D]=React__namespace.useState(null),[B,L]=React__namespace.useState(null),F=useCollection(n),[V,H]=React__namespace.useState(!1),z=React__namespace.useRef(!1);React__namespace.useEffect(()=>{if(I)return hideOthers(I)},[I]),useFocusGuards();const G=React__namespace.useCallback(ie=>{const[le,...oe]=F().map(Z=>Z.ref.current),[ae]=oe.slice(-1),ue=document.activeElement;for(const Z of ie)if(Z===ue||(Z==null||Z.scrollIntoView({block:"nearest"}),Z===le&&T&&(T.scrollTop=0),Z===ae&&T&&(T.scrollTop=T.scrollHeight),Z==null||Z.focus(),document.activeElement!==ue))return},[F,T]),K=React__namespace.useCallback(()=>G([N,I]),[G,N,I]);React__namespace.useEffect(()=>{V&&K()},[V,K]);const{onOpenChange:q,triggerPointerDownPosRef:W}=A;React__namespace.useEffect(()=>{if(I){let ie={x:0,y:0};const le=ae=>{var ue,Z;ie={x:Math.abs(Math.round(ae.pageX)-(((ue=W.current)==null?void 0:ue.x)??0)),y:Math.abs(Math.round(ae.pageY)-(((Z=W.current)==null?void 0:Z.y)??0))}},oe=ae=>{ie.x<=10&&ie.y<=10?ae.preventDefault():I.contains(ae.target)||q(!1),document.removeEventListener("pointermove",le),W.current=null};return W.current!==null&&(document.addEventListener("pointermove",le),document.addEventListener("pointerup",oe,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",le),document.removeEventListener("pointerup",oe,{capture:!0})}}},[I,q,W]),React__namespace.useEffect(()=>{const ie=()=>q(!1);return window.addEventListener("blur",ie),window.addEventListener("resize",ie),()=>{window.removeEventListener("blur",ie),window.removeEventListener("resize",ie)}},[q]);const[U,Q]=useTypeaheadSearch(ie=>{const le=F().filter(ue=>!ue.disabled),oe=le.find(ue=>ue.ref.current===document.activeElement),ae=findNextItem(le,ie,oe);ae&&setTimeout(()=>ae.ref.current.focus())}),ee=React__namespace.useCallback((ie,le,oe)=>{const ae=!z.current&&!oe;(A.value!==void 0&&A.value===le||ae)&&(D(ie),ae&&(z.current=!0))},[A.value]),se=React__namespace.useCallback(()=>I==null?void 0:I.focus(),[I]),J=React__namespace.useCallback((ie,le,oe)=>{const ae=!z.current&&!oe;(A.value!==void 0&&A.value===le||ae)&&L(ie)},[A.value]),te=i==="popper"?SelectPopperPosition:SelectItemAlignedPosition,ce=te===SelectPopperPosition?{side:d,sideOffset:f,align:p,alignOffset:m,arrowPadding:g,collisionBoundary:b,collisionPadding:_,sticky:E,hideWhenDetached:R,avoidCollisions:S}:{};return jsxRuntime.jsx(SelectContentProvider,{scope:n,content:I,viewport:T,onViewportChange:O,itemRefCallback:ee,selectedItem:N,onItemLeave:se,itemTextRefCallback:J,focusSelectedItem:K,selectedItemText:B,position:i,isPositioned:V,searchRef:U,children:jsxRuntime.jsx(ReactRemoveScroll,{as:Slot,allowPinchZoom:!0,children:jsxRuntime.jsx(FocusScope,{asChild:!0,trapped:A.open,onMountAutoFocus:ie=>{ie.preventDefault()},onUnmountAutoFocus:composeEventHandlers(o,ie=>{var le;(le=A.trigger)==null||le.focus({preventScroll:!0}),ie.preventDefault()}),children:jsxRuntime.jsx(DismissableLayer,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:ie=>ie.preventDefault(),onDismiss:()=>A.onOpenChange(!1),children:jsxRuntime.jsx(te,{role:"listbox",id:A.contentId,"data-state":A.open?"open":"closed",dir:A.dir,onContextMenu:ie=>ie.preventDefault(),...C,...ce,onPlaced:()=>H(!0),ref:j,style:{display:"flex",flexDirection:"column",outline:"none",...C.style},onKeyDown:composeEventHandlers(C.onKeyDown,ie=>{const le=ie.ctrlKey||ie.altKey||ie.metaKey;if(ie.key==="Tab"&&ie.preventDefault(),!le&&ie.key.length===1&&Q(ie.key),["ArrowUp","ArrowDown","Home","End"].includes(ie.key)){let ae=F().filter(ue=>!ue.disabled).map(ue=>ue.ref.current);if(["ArrowUp","End"].includes(ie.key)&&(ae=ae.slice().reverse()),["ArrowUp","ArrowDown"].includes(ie.key)){const ue=ie.target,Z=ae.indexOf(ue);ae=ae.slice(Z+1)}setTimeout(()=>G(ae)),ie.preventDefault()}})})})})})})});SelectContentImpl.displayName=CONTENT_IMPL_NAME;var ITEM_ALIGNED_POSITION_NAME="SelectItemAlignedPosition",SelectItemAlignedPosition=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:i,...o}=e,l=useSelectContext(CONTENT_NAME,n),u=useSelectContentContext(CONTENT_NAME,n),[d,f]=React__namespace.useState(null),[p,m]=React__namespace.useState(null),g=useComposedRefs(t,j=>m(j)),b=useCollection(n),_=React__namespace.useRef(!1),E=React__namespace.useRef(!0),{viewport:R,selectedItem:S,selectedItemText:C,focusSelectedItem:A}=u,I=React__namespace.useCallback(()=>{if(l.trigger&&l.valueNode&&d&&p&&R&&S&&C){const j=l.trigger.getBoundingClientRect(),N=p.getBoundingClientRect(),D=l.valueNode.getBoundingClientRect(),B=C.getBoundingClientRect();if(l.dir!=="rtl"){const ue=B.left-N.left,Z=D.left-ue,fe=j.left-Z,ne=j.width+fe,de=Math.max(ne,N.width),pe=window.innerWidth-CONTENT_MARGIN,me=clamp(Z,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,pe-de)]);d.style.minWidth=ne+"px",d.style.left=me+"px"}else{const ue=N.right-B.right,Z=window.innerWidth-D.right-ue,fe=window.innerWidth-j.right-Z,ne=j.width+fe,de=Math.max(ne,N.width),pe=window.innerWidth-CONTENT_MARGIN,me=clamp(Z,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,pe-de)]);d.style.minWidth=ne+"px",d.style.right=me+"px"}const L=b(),F=window.innerHeight-CONTENT_MARGIN*2,V=R.scrollHeight,H=window.getComputedStyle(p),z=parseInt(H.borderTopWidth,10),G=parseInt(H.paddingTop,10),K=parseInt(H.borderBottomWidth,10),q=parseInt(H.paddingBottom,10),W=z+G+V+q+K,U=Math.min(S.offsetHeight*5,W),Q=window.getComputedStyle(R),ee=parseInt(Q.paddingTop,10),se=parseInt(Q.paddingBottom,10),J=j.top+j.height/2-CONTENT_MARGIN,te=F-J,ce=S.offsetHeight/2,ie=S.offsetTop+ce,le=z+G+ie,oe=W-le;if(le<=J){const ue=L.length>0&&S===L[L.length-1].ref.current;d.style.bottom="0px";const Z=p.clientHeight-R.offsetTop-R.offsetHeight,fe=Math.max(te,ce+(ue?se:0)+Z+K),ne=le+fe;d.style.height=ne+"px"}else{const ue=L.length>0&&S===L[0].ref.current;d.style.top="0px";const fe=Math.max(J,z+R.offsetTop+(ue?ee:0)+ce)+oe;d.style.height=fe+"px",R.scrollTop=le-J+R.offsetTop}d.style.margin=`${CONTENT_MARGIN}px 0`,d.style.minHeight=U+"px",d.style.maxHeight=F+"px",i==null||i(),requestAnimationFrame(()=>_.current=!0)}},[b,l.trigger,l.valueNode,d,p,R,S,C,l.dir,i]);useLayoutEffect2(()=>I(),[I]);const[M,T]=React__namespace.useState();useLayoutEffect2(()=>{p&&T(window.getComputedStyle(p).zIndex)},[p]);const O=React__namespace.useCallback(j=>{j&&E.current===!0&&(I(),A==null||A(),E.current=!1)},[I,A]);return jsxRuntime.jsx(SelectViewportProvider,{scope:n,contentWrapper:d,shouldExpandOnScrollRef:_,onScrollButtonChange:O,children:jsxRuntime.jsx("div",{ref:f,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:M},children:jsxRuntime.jsx(Primitive.div,{...o,ref:g,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});SelectItemAlignedPosition.displayName=ITEM_ALIGNED_POSITION_NAME;var POPPER_POSITION_NAME="SelectPopperPosition",SelectPopperPosition=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,align:i="start",collisionPadding:o=CONTENT_MARGIN,...l}=e,u=usePopperScope(n);return jsxRuntime.jsx(Content$1,{...u,...l,ref:t,align:i,collisionPadding:o,style:{boxSizing:"border-box",...l.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});SelectPopperPosition.displayName=POPPER_POSITION_NAME;var[SelectViewportProvider,useSelectViewportContext]=createSelectContext(CONTENT_NAME,{}),VIEWPORT_NAME="SelectViewport",SelectViewport=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:i,...o}=e,l=useSelectContentContext(VIEWPORT_NAME,n),u=useSelectViewportContext(VIEWPORT_NAME,n),d=useComposedRefs(t,l.onViewportChange),f=React__namespace.useRef(0);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),jsxRuntime.jsx(Collection.Slot,{scope:n,children:jsxRuntime.jsx(Primitive.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:d,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:composeEventHandlers(o.onScroll,p=>{const m=p.currentTarget,{contentWrapper:g,shouldExpandOnScrollRef:b}=u;if(b!=null&&b.current&&g){const _=Math.abs(f.current-m.scrollTop);if(_>0){const E=window.innerHeight-CONTENT_MARGIN*2,R=parseFloat(g.style.minHeight),S=parseFloat(g.style.height),C=Math.max(R,S);if(C<E){const A=C+_,I=Math.min(E,A),M=A-I;g.style.height=I+"px",g.style.bottom==="0px"&&(m.scrollTop=M>0?M:0,g.style.justifyContent="flex-end")}}}f.current=m.scrollTop})})})]})});SelectViewport.displayName=VIEWPORT_NAME;var GROUP_NAME="SelectGroup",[SelectGroupContextProvider,useSelectGroupContext]=createSelectContext(GROUP_NAME),SelectGroup=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...i}=e,o=useId();return jsxRuntime.jsx(SelectGroupContextProvider,{scope:n,id:o,children:jsxRuntime.jsx(Primitive.div,{role:"group","aria-labelledby":o,...i,ref:t})})});SelectGroup.displayName=GROUP_NAME;var LABEL_NAME="SelectLabel",SelectLabel$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...i}=e,o=useSelectGroupContext(LABEL_NAME,n);return jsxRuntime.jsx(Primitive.div,{id:o.id,...i,ref:t})});SelectLabel$1.displayName=LABEL_NAME;var ITEM_NAME="SelectItem",[SelectItemContextProvider,useSelectItemContext]=createSelectContext(ITEM_NAME),SelectItem$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,value:i,disabled:o=!1,textValue:l,...u}=e,d=useSelectContext(ITEM_NAME,n),f=useSelectContentContext(ITEM_NAME,n),p=d.value===i,[m,g]=React__namespace.useState(l??""),[b,_]=React__namespace.useState(!1),E=useComposedRefs(t,A=>{var I;return(I=f.itemRefCallback)==null?void 0:I.call(f,A,i,o)}),R=useId(),S=React__namespace.useRef("touch"),C=()=>{o||(d.onValueChange(i),d.onOpenChange(!1))};if(i==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return jsxRuntime.jsx(SelectItemContextProvider,{scope:n,value:i,disabled:o,textId:R,isSelected:p,onItemTextChange:React__namespace.useCallback(A=>{g(I=>I||((A==null?void 0:A.textContent)??"").trim())},[]),children:jsxRuntime.jsx(Collection.ItemSlot,{scope:n,value:i,disabled:o,textValue:m,children:jsxRuntime.jsx(Primitive.div,{role:"option","aria-labelledby":R,"data-highlighted":b?"":void 0,"aria-selected":p&&b,"data-state":p?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...u,ref:E,onFocus:composeEventHandlers(u.onFocus,()=>_(!0)),onBlur:composeEventHandlers(u.onBlur,()=>_(!1)),onClick:composeEventHandlers(u.onClick,()=>{S.current!=="mouse"&&C()}),onPointerUp:composeEventHandlers(u.onPointerUp,()=>{S.current==="mouse"&&C()}),onPointerDown:composeEventHandlers(u.onPointerDown,A=>{S.current=A.pointerType}),onPointerMove:composeEventHandlers(u.onPointerMove,A=>{var I;S.current=A.pointerType,o?(I=f.onItemLeave)==null||I.call(f):S.current==="mouse"&&A.currentTarget.focus({preventScroll:!0})}),onPointerLeave:composeEventHandlers(u.onPointerLeave,A=>{var I;A.currentTarget===document.activeElement&&((I=f.onItemLeave)==null||I.call(f))}),onKeyDown:composeEventHandlers(u.onKeyDown,A=>{var M;((M=f.searchRef)==null?void 0:M.current)!==""&&A.key===" "||(SELECTION_KEYS.includes(A.key)&&C(),A.key===" "&&A.preventDefault())})})})})});SelectItem$1.displayName=ITEM_NAME;var ITEM_TEXT_NAME="SelectItemText",SelectItemText=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,className:i,style:o,...l}=e,u=useSelectContext(ITEM_TEXT_NAME,n),d=useSelectContentContext(ITEM_TEXT_NAME,n),f=useSelectItemContext(ITEM_TEXT_NAME,n),p=useSelectNativeOptionsContext(ITEM_TEXT_NAME,n),[m,g]=React__namespace.useState(null),b=useComposedRefs(t,C=>g(C),f.onItemTextChange,C=>{var A;return(A=d.itemTextRefCallback)==null?void 0:A.call(d,C,f.value,f.disabled)}),_=m==null?void 0:m.textContent,E=React__namespace.useMemo(()=>jsxRuntime.jsx("option",{value:f.value,disabled:f.disabled,children:_},f.value),[f.disabled,f.value,_]),{onNativeOptionAdd:R,onNativeOptionRemove:S}=p;return useLayoutEffect2(()=>(R(E),()=>S(E)),[R,S,E]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Primitive.span,{id:f.textId,...l,ref:b}),f.isSelected&&u.valueNode&&!u.valueNodeHasChildren?ReactDOM__namespace.createPortal(l.children,u.valueNode):null]})});SelectItemText.displayName=ITEM_TEXT_NAME;var ITEM_INDICATOR_NAME="SelectItemIndicator",SelectItemIndicator=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...i}=e;return useSelectItemContext(ITEM_INDICATOR_NAME,n).isSelected?jsxRuntime.jsx(Primitive.span,{"aria-hidden":!0,...i,ref:t}):null});SelectItemIndicator.displayName=ITEM_INDICATOR_NAME;var SCROLL_UP_BUTTON_NAME="SelectScrollUpButton",SelectScrollUpButton$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContentContext(SCROLL_UP_BUTTON_NAME,e.__scopeSelect),i=useSelectViewportContext(SCROLL_UP_BUTTON_NAME,e.__scopeSelect),[o,l]=React__namespace.useState(!1),u=useComposedRefs(t,i.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let d=function(){const p=f.scrollTop>0;l(p)};const f=n.viewport;return d(),f.addEventListener("scroll",d),()=>f.removeEventListener("scroll",d)}},[n.viewport,n.isPositioned]),o?jsxRuntime.jsx(SelectScrollButtonImpl,{...e,ref:u,onAutoScroll:()=>{const{viewport:d,selectedItem:f}=n;d&&f&&(d.scrollTop=d.scrollTop-f.offsetHeight)}}):null});SelectScrollUpButton$1.displayName=SCROLL_UP_BUTTON_NAME;var SCROLL_DOWN_BUTTON_NAME="SelectScrollDownButton",SelectScrollDownButton$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContentContext(SCROLL_DOWN_BUTTON_NAME,e.__scopeSelect),i=useSelectViewportContext(SCROLL_DOWN_BUTTON_NAME,e.__scopeSelect),[o,l]=React__namespace.useState(!1),u=useComposedRefs(t,i.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let d=function(){const p=f.scrollHeight-f.clientHeight,m=Math.ceil(f.scrollTop)<p;l(m)};const f=n.viewport;return d(),f.addEventListener("scroll",d),()=>f.removeEventListener("scroll",d)}},[n.viewport,n.isPositioned]),o?jsxRuntime.jsx(SelectScrollButtonImpl,{...e,ref:u,onAutoScroll:()=>{const{viewport:d,selectedItem:f}=n;d&&f&&(d.scrollTop=d.scrollTop+f.offsetHeight)}}):null});SelectScrollDownButton$1.displayName=SCROLL_DOWN_BUTTON_NAME;var SelectScrollButtonImpl=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:i,...o}=e,l=useSelectContentContext("SelectScrollButton",n),u=React__namespace.useRef(null),d=useCollection(n),f=React__namespace.useCallback(()=>{u.current!==null&&(window.clearInterval(u.current),u.current=null)},[]);return React__namespace.useEffect(()=>()=>f(),[f]),useLayoutEffect2(()=>{var m;const p=d().find(g=>g.ref.current===document.activeElement);(m=p==null?void 0:p.ref.current)==null||m.scrollIntoView({block:"nearest"})},[d]),jsxRuntime.jsx(Primitive.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:composeEventHandlers(o.onPointerDown,()=>{u.current===null&&(u.current=window.setInterval(i,50))}),onPointerMove:composeEventHandlers(o.onPointerMove,()=>{var p;(p=l.onItemLeave)==null||p.call(l),u.current===null&&(u.current=window.setInterval(i,50))}),onPointerLeave:composeEventHandlers(o.onPointerLeave,()=>{f()})})}),SEPARATOR_NAME="SelectSeparator",SelectSeparator$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...i}=e;return jsxRuntime.jsx(Primitive.div,{"aria-hidden":!0,...i,ref:t})});SelectSeparator$1.displayName=SEPARATOR_NAME;var ARROW_NAME="SelectArrow",SelectArrow=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...i}=e,o=usePopperScope(n),l=useSelectContext(ARROW_NAME,n),u=useSelectContentContext(ARROW_NAME,n);return l.open&&u.position==="popper"?jsxRuntime.jsx(Arrow,{...o,...i,ref:t}):null});SelectArrow.displayName=ARROW_NAME;function shouldShowPlaceholder(e){return e===""||e===void 0}var BubbleSelect=React__namespace.forwardRef((e,t)=>{const{value:n,...i}=e,o=React__namespace.useRef(null),l=useComposedRefs(t,o),u=usePrevious(n);return React__namespace.useEffect(()=>{const d=o.current,f=window.HTMLSelectElement.prototype,m=Object.getOwnPropertyDescriptor(f,"value").set;if(u!==n&&m){const g=new Event("change",{bubbles:!0});m.call(d,n),d.dispatchEvent(g)}},[u,n]),jsxRuntime.jsx(VisuallyHidden,{asChild:!0,children:jsxRuntime.jsx("select",{...i,ref:l,defaultValue:n})})});BubbleSelect.displayName="BubbleSelect";function useTypeaheadSearch(e){const t=useCallbackRef$1(e),n=React__namespace.useRef(""),i=React__namespace.useRef(0),o=React__namespace.useCallback(u=>{const d=n.current+u;t(d),function f(p){n.current=p,window.clearTimeout(i.current),p!==""&&(i.current=window.setTimeout(()=>f(""),1e3))}(d)},[t]),l=React__namespace.useCallback(()=>{n.current="",window.clearTimeout(i.current)},[]);return React__namespace.useEffect(()=>()=>window.clearTimeout(i.current),[]),[n,o,l]}function findNextItem(e,t,n){const o=t.length>1&&Array.from(t).every(p=>p===t[0])?t[0]:t,l=n?e.indexOf(n):-1;let u=wrapArray(e,Math.max(l,0));o.length===1&&(u=u.filter(p=>p!==n));const f=u.find(p=>p.textValue.toLowerCase().startsWith(o.toLowerCase()));return f!==n?f:void 0}function wrapArray(e,t){return e.map((n,i)=>e[(t+i)%e.length])}var Root2=Select$1,Trigger=SelectTrigger$1,Value=SelectValue$1,Icon=SelectIcon,Portal=SelectPortal,Content2=SelectContent$1,Viewport=SelectViewport,Label=SelectLabel$1,Item=SelectItem$1,ItemText=SelectItemText,ItemIndicator=SelectItemIndicator,ScrollUpButton=SelectScrollUpButton$1,ScrollDownButton=SelectScrollDownButton$1,Separator=SelectSeparator$1;const Select=Root2,SelectValue=Value,SelectTrigger=React__namespace.forwardRef(({className:e,children:t,...n},i)=>jsxRuntime.jsxs(Trigger,{ref:i,className:cn("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,jsxRuntime.jsx(Icon,{asChild:!0,children:jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));SelectTrigger.displayName=Trigger.displayName;const SelectScrollUpButton=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(ScrollUpButton,{ref:n,className:cn("flex cursor-default items-center justify-center py-1",e),...t,children:jsxRuntime.jsx(ChevronUp,{className:"h-4 w-4"})}));SelectScrollUpButton.displayName=ScrollUpButton.displayName;const SelectScrollDownButton=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(ScrollDownButton,{ref:n,className:cn("flex cursor-default items-center justify-center py-1",e),...t,children:jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4"})}));SelectScrollDownButton.displayName=ScrollDownButton.displayName;const SelectContent=React__namespace.forwardRef(({className:e,children:t,position:n="popper",...i},o)=>jsxRuntime.jsx(Portal,{children:jsxRuntime.jsxs(Content2,{ref:o,className:cn("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...i,children:[jsxRuntime.jsx(SelectScrollUpButton,{}),jsxRuntime.jsx(Viewport,{className:cn("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),jsxRuntime.jsx(SelectScrollDownButton,{})]})}));SelectContent.displayName=Content2.displayName;const SelectLabel=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Label,{ref:n,className:cn("px-2 py-1.5 text-sm font-semibold",e),...t}));SelectLabel.displayName=Label.displayName;const SelectItem=React__namespace.forwardRef(({className:e,children:t,...n},i)=>jsxRuntime.jsxs(Item,{ref:i,className:cn("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[jsxRuntime.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:jsxRuntime.jsx(ItemIndicator,{children:jsxRuntime.jsx(Check,{className:"h-4 w-4"})})}),jsxRuntime.jsx(ItemText,{children:t})]}));SelectItem.displayName=Item.displayName;const SelectSeparator=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Separator,{ref:n,className:cn("-mx-1 my-1 h-px bg-muted",e),...t}));SelectSeparator.displayName=Separator.displayName;var SWITCH_NAME="Switch",[createSwitchContext,createSwitchScope]=createContextScope(SWITCH_NAME),[SwitchProvider,useSwitchContext]=createSwitchContext(SWITCH_NAME),Switch$1=React__namespace.forwardRef((e,t)=>{const{__scopeSwitch:n,name:i,checked:o,defaultChecked:l,required:u,disabled:d,value:f="on",onCheckedChange:p,form:m,...g}=e,[b,_]=React__namespace.useState(null),E=useComposedRefs(t,I=>_(I)),R=React__namespace.useRef(!1),S=b?m||!!b.closest("form"):!0,[C=!1,A]=useControllableState({prop:o,defaultProp:l,onChange:p});return jsxRuntime.jsxs(SwitchProvider,{scope:n,checked:C,disabled:d,children:[jsxRuntime.jsx(Primitive.button,{type:"button",role:"switch","aria-checked":C,"aria-required":u,"data-state":getState(C),"data-disabled":d?"":void 0,disabled:d,value:f,...g,ref:E,onClick:composeEventHandlers(e.onClick,I=>{A(M=>!M),S&&(R.current=I.isPropagationStopped(),R.current||I.stopPropagation())})}),S&&jsxRuntime.jsx(BubbleInput,{control:b,bubbles:!R.current,name:i,value:f,checked:C,required:u,disabled:d,form:m,style:{transform:"translateX(-100%)"}})]})});Switch$1.displayName=SWITCH_NAME;var THUMB_NAME="SwitchThumb",SwitchThumb=React__namespace.forwardRef((e,t)=>{const{__scopeSwitch:n,...i}=e,o=useSwitchContext(THUMB_NAME,n);return jsxRuntime.jsx(Primitive.span,{"data-state":getState(o.checked),"data-disabled":o.disabled?"":void 0,...i,ref:t})});SwitchThumb.displayName=THUMB_NAME;var BubbleInput=e=>{const{control:t,checked:n,bubbles:i=!0,...o}=e,l=React__namespace.useRef(null),u=usePrevious(n),d=useSize(t);return React__namespace.useEffect(()=>{const f=l.current,p=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(p,"checked").set;if(u!==n&&g){const b=new Event("click",{bubbles:i});g.call(f,n),f.dispatchEvent(b)}},[u,n,i]),jsxRuntime.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:l,style:{...e.style,...d,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function getState(e){return e?"checked":"unchecked"}var Root=Switch$1,Thumb=SwitchThumb;const Switch=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Root,{className:cn("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:jsxRuntime.jsx(Thumb,{className:cn("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));Switch.displayName=Root.displayName;const DAYS_OF_WEEK=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];function ManufacturerReorderingCard({manufacturer:e,onSave:t,loading:n=!1,saving:i=!1}){const[o,l]=React.useState({...e}),u=(b,_)=>{l(E=>({...E,[b]:_}))},d=(b,_)=>{l(E=>({...E,[b]:_}))},f=(b,_)=>{l(E=>({...E,[b]:_}))},p=()=>{i||t(o)},m=b=>b===void 0||b<0||b>6?"Monday":DAYS_OF_WEEK[b],g=b=>DAYS_OF_WEEK.indexOf(b);return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[n?jsxRuntime.jsx(Skeleton,{className:"h-8 w-32"}):jsxRuntime.jsx(CardTitle,{className:"text-lg font-bold",children:"Reordering"}),n?jsxRuntime.jsx(Skeleton,{className:"h-4 w-full mt-2"}):jsxRuntime.jsx(CardDescription,{className:"text-sm",children:"Adjust your reordering settings to control lead times, stocking weeks, minimum orders, and reorder dates, enhancing efficiency in restocking processes."})]}),jsxRuntime.jsx(CardContent,{className:"space-y-6",children:n?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-10"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx("div",{className:"ml-2 w-12"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx("div",{className:"ml-2 w-12"})]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-60"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{id:"automatic-reordering",checked:o.AutoUpdate,onCheckedChange:b=>u("AutoUpdate",b),disabled:i}),jsxRuntime.jsx(Label$2,{htmlFor:"automatic-reordering",children:"Automatic Reordering"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"reorder-date",children:"Automatic Reorder Date"}),jsxRuntime.jsxs(Select,{value:m(o.AutoReorderDate),onValueChange:b=>d("AutoReorderDate",g(b)),disabled:i,children:[jsxRuntime.jsx(SelectTrigger,{id:"reorder-date",children:jsxRuntime.jsx(SelectValue,{placeholder:"Select day"})}),jsxRuntime.jsx(SelectContent,{children:DAYS_OF_WEEK.map(b=>jsxRuntime.jsx(SelectItem,{value:b,children:b},b))})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"weeks-stocking",children:"Default Weeks of Stocking"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Input,{id:"weeks-stocking",type:"number",value:o.DefaultWeeksOfStocking||"",onChange:b=>d("DefaultWeeksOfStocking",Number(b.target.value)),disabled:i}),jsxRuntime.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"weeks"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"minimum-order",children:"Default Minimum Order"}),jsxRuntime.jsxs("div",{className:"flex items-center relative",children:[jsxRuntime.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2",children:"$"}),jsxRuntime.jsx(Input,{id:"minimum-order",type:"number",className:"pl-6",value:o.DefaultMinimumOrder||"",onChange:b=>d("DefaultMinimumOrder",Number(b.target.value)),disabled:i})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"lead-time",children:"Default Lead Time"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Input,{id:"lead-time",type:"number",value:o.DefaultLeadTime||"",onChange:b=>d("DefaultLeadTime",Number(b.target.value)),disabled:i}),jsxRuntime.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"days"})]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"order-confirmations",children:"Send Order Confirmations To"}),jsxRuntime.jsx(Input,{id:"order-confirmations",type:"email",value:o.POEmail||"",onChange:b=>f("POEmail",b.target.value),placeholder:"email@example.com",disabled:i})]})]})}),jsxRuntime.jsx(CardFooter,{className:"flex justify-end",children:n?jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"}):jsxRuntime.jsxs(Button,{onClick:p,disabled:i,children:[i&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]})})]})}function ActiveOrdersCard({orders:e,loading:t=!1}){const n=l=>new Intl.NumberFormat("en-CA",{style:"currency",currency:"CAD",minimumFractionDigits:2,maximumFractionDigits:2}).format(l),i=React.useMemo(()=>{if(!e||e.length===0)return{all:{orders:0,amount:0},processing:{orders:0,amount:0},shipped:{orders:0,amount:0},delayed:{orders:0,amount:0}};const l=e.filter(C=>C.DocumentType==="Order"),u=e.filter(C=>C.DocumentType==="Shipment"),d=l.filter(C=>C.WarehouseCode!=="3PLE"),f=d.reduce((C,A)=>C+(A.Quantity||0),0),p=d.reduce((C,A)=>C+(A.ExtendedPrice||0),0),m=l.filter(C=>C.WarehouseCode==="3PLE"),g=m.reduce((C,A)=>C+(A.Quantity||0),0),b=m.reduce((C,A)=>C+(A.ExtendedPrice||0),0),_=u.length,E=u.reduce((C,A)=>C+(A.ExtendedPrice||0),0),R=f+g+_,S=p+b+E;return{all:{orders:R,amount:S},processing:{orders:f,amount:p},shipped:{orders:_,amount:E},delayed:{orders:g,amount:b}}},[e]),o=[{name:"All",icon:Package,color:"bg-blue-500",textColor:"text-blue-600",orders:i.all.orders,amount:i.all.amount},{name:"Processing",icon:RefreshCcw,color:"bg-yellow-500",textColor:"text-yellow-600",orders:i.processing.orders,amount:i.processing.amount},{name:"Shipped",icon:Truck,color:"bg-green-500",textColor:"text-green-600",orders:i.shipped.orders,amount:i.shipped.amount},{name:"Delayed",icon:CircleAlert,color:"bg-red-500",textColor:"text-red-600",orders:i.delayed.orders,amount:i.delayed.amount}];return t?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-lg font-bold",children:"Active Orders"})}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 p-4",children:[1,2,3,4].map(l=>jsxRuntime.jsxs("div",{className:"overflow-hidden rounded-md border",children:[jsxRuntime.jsx("div",{className:"bg-slate-200 dark:bg-slate-700 h-[3px]"}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-16 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-7 w-12"})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-16 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]})]})]},l))})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-lg font-bold",children:"Active Orders"})}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 p-4",children:o.map(l=>jsxRuntime.jsxs("div",{className:"overflow-hidden rounded-md border",children:[jsxRuntime.jsx("div",{className:`${l.color} bg-opacity-60 h-[3px]`}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-base",children:l.name}),jsxRuntime.jsx("div",{className:`${l.color} bg-opacity-90 p-2 rounded-full`,children:jsxRuntime.jsx(l.icon,{className:"size-4 shrink-0 text-white"})})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Orders"}),jsxRuntime.jsx("p",{className:"text-xl font-bold",children:l.orders})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Amount"}),jsxRuntime.jsx("p",{className:"text-base font-semibold",children:n(l.amount)})]})]})]})]},l.name))})]})}function SalesOverviewCard({salesData:e,loading:t=!1}){const n=o=>new Intl.NumberFormat("en-CA",{style:"currency",currency:"CAD",minimumFractionDigits:2,maximumFractionDigits:2}).format(o),i=[{title:"Last 30 days",amount:(e==null?void 0:e.SalesLast30Days)||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-blue-500"},{title:"Last 3 months",amount:(e==null?void 0:e.SalesLast3Months)||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-amber-500"},{title:"Year to date",amount:(e==null?void 0:e.SalesYearToDay)||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-emerald-500"}];return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-lg sm:text-xl",children:"Sales Overview"})}),jsxRuntime.jsx(CardContent,{className:"pt-4 px-3 sm:px-6",children:t||!e?jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:Array(3).fill(0).map((o,l)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-7 w-28"})]})]},l))}):jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:i.map((o,l)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx("h3",{className:"text-sm sm:text-base font-medium",children:o.title}),jsxRuntime.jsx("div",{className:`p-2 rounded-full ${o.color}`,children:o.icon})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Amount"}),jsxRuntime.jsx("p",{className:"text-base sm:text-lg font-bold",children:n(o.amount)})]})]},l))})})]})}function ResellerQualificationsCard({qualifications:e=[],loading:t=!1}){return t?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Qualifications"})}),jsxRuntime.jsx(CardContent,{className:"p-6",children:jsxRuntime.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4 gap-y-8",children:Array.from({length:10}).map((n,i)=>jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-24 rounded-md mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"})]},i))})})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Qualifications"})}),jsxRuntime.jsx(CardContent,{className:"p-6",children:jsxRuntime.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4 gap-y-8",children:e.map((n,i)=>jsxRuntime.jsx(ManufacturerLogo,{manufacturerId:n.ManufacturerId,opportunityNumber:n.DefaultOpportunityNumber},`${n.ManufacturerId}-${i}`))})})]})}function ManufacturerLogo({manufacturerId:e,opportunityNumber:t}){const[n,i]=React.useState(null),[o,l]=React.useState(!0),[u,d]=React.useState(!1),[f,p]=React.useState(null),m=React.useMemo(()=>e?{logoUrl:`https://api.randmar.io/V4/Partner/${e}/Account/Logo?width=96&height=48`,logoExistsUrl:`https://api.randmar.io/V4/Partner/${e}/Account/Logo/Exists`}:null,[e]);return React.useEffect(()=>{if(!m)return;let g=!0;p(null);const b=async()=>{try{const R=await fetch(m.logoExistsUrl);if(R.ok){const C=(await R.text()).toLowerCase()==="true";return g&&d(C),C}return!1}catch(R){return console.error("Failed to check if logo exists:",R),g&&d(!1),!1}},_=async()=>{g&&l(!0);try{const R=await fetch(m.logoUrl);if(R.ok){const S=await R.blob();g&&(n&&URL.revokeObjectURL(n),i(URL.createObjectURL(S)))}else throw new Error(`Failed to load logo: ${R.status}`)}catch(R){console.error("Failed to load logo:",R),g&&p("Failed to load manufacturer logo")}finally{g&&l(!1)}};return(async()=>{await b()?_():l(!1)})(),()=>{g=!1,n&&URL.revokeObjectURL(n)}},[m]),jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx("div",{className:"h-12 flex items-center justify-center mb-2",children:o?jsxRuntime.jsx(Skeleton,{className:"h-12 w-24 rounded-md"}):u&&n?jsxRuntime.jsx("img",{src:n,alt:"Manufacturer logo",className:"max-h-12 max-w-24 object-contain",onError:()=>p("Failed to load logo")}):jsxRuntime.jsx("div",{className:"h-12 w-24 flex items-center justify-center bg-slate-100 rounded-md text-xs text-slate-500",children:e?e.substring(0,8):"No ID"})}),t&&jsxRuntime.jsx(Badge,{variant:"outline",className:"text-xs",children:t}),f&&jsxRuntime.jsx("div",{className:"text-red-500 text-xs mt-1",role:"alert",children:f})]})}function GeneralDocumentCard({document:e,loading:t=!1}){return t?jsxRuntime.jsx("div",{children:"loading..."}):jsxRuntime.jsxs("div",{children:[e==null?void 0:e.OrderNumber," for P.O. ",e==null?void 0:e.PONumber]})}exports.ActiveOrdersCard=ActiveOrdersCard,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.CountryFlag=CountryFlag,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.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.ManufacturerReorderingCard=ManufacturerReorderingCard,exports.Navbar=Navbar,exports.PartnerCard=PartnerCard,exports.Preloader=Preloader,exports.ProductCard=ProductCard,exports.ProductImage=ProductImage,exports.ProductInventoryGrid=ProductInventoryGrid,exports.ResellerCard=ResellerCard,exports.ResellerQualificationsCard=ResellerQualificationsCard,exports.SalesOverviewCard=SalesOverviewCard,exports.ScrollArea=ScrollArea,exports.ScrollBar=ScrollBar,exports.Select=Select,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.Tabs=Tabs,exports.TabsContent=TabsContent,exports.TabsList=TabsList,exports.TabsTrigger=TabsTrigger,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.useIsMobile=useIsMobile,exports.useSidebar=useSidebar,exports.useToast=useToast,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
|