randmarcomps 1.89.0 → 1.90.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 +7 -1
- package/dist/randmarcomps.js +25 -13
- package/dist/randmarcomps.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/randmarcomps.d.ts
CHANGED
|
@@ -211,16 +211,22 @@ declare interface LayoutProps {
|
|
|
211
211
|
dashboardTitle?: string;
|
|
212
212
|
onSignOut?: () => void;
|
|
213
213
|
searchPlaceholder?: string;
|
|
214
|
+
withRandmarAssistant?: boolean;
|
|
215
|
+
chatUserName?: string;
|
|
216
|
+
chatApiKey?: string;
|
|
214
217
|
}
|
|
215
218
|
|
|
216
219
|
declare type MaskType = "phone" | "postal-code-ca" | "zip-code-us";
|
|
217
220
|
|
|
218
|
-
export declare function Navbar({ routes, footer, dashboardTitle }: NavbarProps): JSX.Element;
|
|
221
|
+
export declare function Navbar({ routes, footer, dashboardTitle, withRandmarAssistant, chatUserName, chatApiKey }: NavbarProps): JSX.Element;
|
|
219
222
|
|
|
220
223
|
declare interface NavbarProps {
|
|
221
224
|
routes: NavRoute[];
|
|
222
225
|
dashboardTitle?: string;
|
|
223
226
|
footer: React.ReactNode;
|
|
227
|
+
withRandmarAssistant?: boolean;
|
|
228
|
+
chatUserName?: string;
|
|
229
|
+
chatApiKey?: string;
|
|
224
230
|
}
|
|
225
231
|
|
|
226
232
|
export declare interface NavRoute {
|
package/dist/randmarcomps.js
CHANGED
|
@@ -44786,8 +44786,8 @@ const CountryFlag = ({ countryCode: e, className: t = "" }) => {
|
|
|
44786
44786
|
}
|
|
44787
44787
|
);
|
|
44788
44788
|
};
|
|
44789
|
-
function Navbar({ routes: e, footer: t, dashboardTitle: n }) {
|
|
44790
|
-
const { appID:
|
|
44789
|
+
function Navbar({ routes: e, footer: t, dashboardTitle: n, withRandmarAssistant: i, chatUserName: o, chatApiKey: l }) {
|
|
44790
|
+
const { appID: u } = useParams(), f = e.filter((d) => d.showInNav);
|
|
44791
44791
|
return /* @__PURE__ */ jsxs(Sidebar, { className: "border-r border-sidebar-border", children: [
|
|
44792
44792
|
/* @__PURE__ */ jsx(SidebarHeader, { className: "border-b border-sidebar-border px-6 h-16 justify-center bg-sidebar text-sidebar-foreground", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
44793
44793
|
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(
|
|
@@ -44800,14 +44800,20 @@ function Navbar({ routes: e, footer: t, dashboardTitle: n }) {
|
|
|
44800
44800
|
) }),
|
|
44801
44801
|
/* @__PURE__ */ jsx("span", { className: "font-semibold text-lg", children: n })
|
|
44802
44802
|
] }) }),
|
|
44803
|
-
/* @__PURE__ */ jsx(SidebarContent, { className: "py-4 bg-sidebar text-sidebar-foreground", children: /* @__PURE__ */ jsx(SidebarMenu, { children:
|
|
44804
|
-
const
|
|
44805
|
-
return /* @__PURE__ */ jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsx(SidebarMenuButton, { asChild: !0, children: /* @__PURE__ */ jsxs(Link, { to:
|
|
44806
|
-
|
|
44807
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
44808
|
-
] }) }) },
|
|
44803
|
+
/* @__PURE__ */ jsx(SidebarContent, { className: "py-4 bg-sidebar text-sidebar-foreground", children: /* @__PURE__ */ jsx(SidebarMenu, { children: f.map((d) => {
|
|
44804
|
+
const p = d.icon, m = `/${d.path.replace(":appID", u ?? "")}`;
|
|
44805
|
+
return /* @__PURE__ */ jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsx(SidebarMenuButton, { asChild: !0, children: /* @__PURE__ */ jsxs(Link, { to: m, className: "transition-colors hover:bg-muted px-6", children: [
|
|
44806
|
+
p && /* @__PURE__ */ jsx(p, { className: "h-4 w-4" }),
|
|
44807
|
+
/* @__PURE__ */ jsx("span", { children: d.label })
|
|
44808
|
+
] }) }) }, d.key);
|
|
44809
44809
|
}) }) }),
|
|
44810
|
-
/* @__PURE__ */
|
|
44810
|
+
/* @__PURE__ */ jsxs(SidebarFooter, { className: "border-t border-sidebar-border p-4 bg-sidebar-background text-sidebar-foreground", children: [
|
|
44811
|
+
i === !0 && /* @__PURE__ */ jsxs(Dialog, { children: [
|
|
44812
|
+
/* @__PURE__ */ jsx(DialogTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(Button, { size: "lg", children: "Randmar Assistant" }) }),
|
|
44813
|
+
/* @__PURE__ */ jsx(DialogContent, { className: "max-w-[85vw] p-0", children: /* @__PURE__ */ jsx(ChatLayout, { userId: u ?? "2", userName: o ?? "Unknown user", apiKey: l ?? "" }) })
|
|
44814
|
+
] }),
|
|
44815
|
+
t
|
|
44816
|
+
] })
|
|
44811
44817
|
] });
|
|
44812
44818
|
}
|
|
44813
44819
|
const Layout = forwardRef(({
|
|
@@ -44818,21 +44824,27 @@ const Layout = forwardRef(({
|
|
|
44818
44824
|
handleValidSearch: o,
|
|
44819
44825
|
dashboardTitle: l,
|
|
44820
44826
|
onSignOut: u,
|
|
44821
|
-
searchPlaceholder: f
|
|
44822
|
-
|
|
44827
|
+
searchPlaceholder: f,
|
|
44828
|
+
withRandmarAssistant: d,
|
|
44829
|
+
chatUserName: p,
|
|
44830
|
+
chatApiKey: m
|
|
44831
|
+
}, g) => /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(SidebarProvider, { children: /* @__PURE__ */ jsxs("div", { className: "flex grow", children: [
|
|
44823
44832
|
/* @__PURE__ */ jsx(
|
|
44824
44833
|
Navbar,
|
|
44825
44834
|
{
|
|
44826
44835
|
routes: n,
|
|
44827
44836
|
footer: i,
|
|
44828
|
-
dashboardTitle: l
|
|
44837
|
+
dashboardTitle: l,
|
|
44838
|
+
withRandmarAssistant: d,
|
|
44839
|
+
chatUserName: p,
|
|
44840
|
+
chatApiKey: m
|
|
44829
44841
|
}
|
|
44830
44842
|
),
|
|
44831
44843
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
44832
44844
|
/* @__PURE__ */ jsx(
|
|
44833
44845
|
Topbar,
|
|
44834
44846
|
{
|
|
44835
|
-
ref:
|
|
44847
|
+
ref: g,
|
|
44836
44848
|
onSignOut: u,
|
|
44837
44849
|
rightMenu: t,
|
|
44838
44850
|
handleValidSearch: o,
|
|
@@ -863,6 +863,6 @@ ${p.description}`:p.summary||`${f.toUpperCase()} ${m[m.length-1]}`,parameters:{t
|
|
|
863
863
|
This is MANDATORY for ALL API function calls.
|
|
864
864
|
|
|
865
865
|
REPEAT: For ANY API function that requires an ID in the path, ALWAYS use "${e}" as the value.
|
|
866
|
-
NEVER ask the user for these IDs.`,I=C.startChat({generationConfig:{maxOutputTokens:4096},history:[{role:"user",parts:[{text:"Please introduce yourself"}]},{role:"model",parts:[{text:T}]}],tools:f.length>0?[{functionDeclarations:f.map(({declaration:M})=>M)}]:[]});l(I)}catch(C){console.error("Error initializing chat:",C)}};o||m||S()},[m,o]),React.useEffect(()=>{(async()=>{try{const C=await fetchApiFunctions(e);p(C)}catch(C){console.error("Error loading API functions:",C)}finally{g(!1)}})()},[e]);const _=Object.fromEntries(f.map(({declaration:S,handler:C})=>[S.name,C])),R=async S=>{var T,I;const C=S.name;if(C in _){const M=_[C],A=S.args||{};console.log(`[Function Call] ${C} with args:`,A);const O=(T=f.find(D=>D.declaration.name===C))==null?void 0:T.declaration;if(!O){console.error(`[Function Call] Could not find declaration for ${C}`);return}const N=Object.keys(((I=O.parameters)==null?void 0:I.properties)||{});console.log("[Function Call] Parameter names from declaration:",N);const j=[];N.forEach(D=>{if(D.toLowerCase().includes("id")||D.toLowerCase().includes("reseller")||D.toLowerCase().includes("manufacturer")||D.toLowerCase().includes("partner")||D.toLowerCase().includes("application"))j.push("");else if(D in A){const L=A[D];typeof L=="object"?j.push(JSON.stringify(L)):j.push(typeof L=="string"?L:String(L))}else j.push("")}),console.log("[Function Call] Converted args to:",j);try{const D=await M(j);let F,L=null,B=!1;if(typeof D=="string"?F=D:(F=D.summary,L=D.component,B=!0),console.log(`[Function Response] ${C} returned:`,F),o){const V={functionResponse:{name:C,response:{content:F}}};if(B&&L){const U={role:"assistant",content:L,timestamp:new Date,isComponent:!0};d(Q=>[...Q,U])}const G={role:"assistant",content:(await o.sendMessage([V])).response.text(),timestamp:new Date};d(U=>[...U,G])}}catch(D){console.error("Error executing function:",D);const F={role:"assistant",content:"I encountered an error while processing your request. Please try again.",timestamp:new Date};d(L=>[...L,F])}}else console.error(`Function ${C} not found`)};return{handleSubmitToBot:async S=>{if(S.trim()&&!n&&o){const C={role:"user",content:S,timestamp:new Date};d(T=>[...T,C]),i(!0);try{const I=(await o.sendMessage(S.trim())).response,M=I.functionCalls();if(M&&M.length>0)for(const A of M)await R(A);else{const A={role:"assistant",content:I.text(),timestamp:new Date};d(O=>[...O,A])}}catch(T){console.error("Error sending message:",T);const I={role:"assistant",content:"I'm sorry, I encountered an error processing your request. Please try again later.",timestamp:new Date};d(M=>[...M,I])}finally{i(!1)}}},botMessages:u,botReady:!!o,isProcessingSubmission:n}}const ASSISTANT_ID="RandmarAIChatAssistant";function ChatLayout({userId:e,userName:t,apiKey:n}){var U,Q,q;const{data:i}=useGetV4PartnerByApplicationIdBusinessDevelopmentConversationsQuery({applicationId:e}),[o]=useLazyGetV4PartnerByApplicationIdBusinessDevelopmentConversationAndConversationIdMessagesQuery(),{handleSubmitToBot:l,botMessages:u,botReady:d,isProcessingSubmission:f}=useAIAssistant({userId:e,apiKey:n});React.useEffect(()=>{if(!i)return;const z={partner1:[e,ASSISTANT_ID].sort()[0],partner2:[e,ASSISTANT_ID].sort()[1],name:"Randmar Assistant",unread:0,pending:!1,historyFetched:!0,messages:[],conversationID:-1},W=i.map(K=>{var J;return{partner1:[K.Participant1,K.Participant2].sort()[0],partner2:[K.Participant1,K.Participant2].sort()[1],name:((J=K.Participant)==null?void 0:J.PublicName)??"missing public name",unread:0,pending:K.Status!="Approved",historyFetched:!1,messages:[],conversationID:K.ConversationId}});setTimeout(()=>{var K;return(K=j.current)==null?void 0:K.focus()},50),T([z,...W])},[i]);const[p,m]=React.useState("all"),[g,b]=React.useState([[e,ASSISTANT_ID].sort()[0],[e,ASSISTANT_ID].sort()[1]]),[_,R]=React.useState(""),[E,S]=React.useState(null),[C,T]=React.useState([]),[I,M]=React.useState(""),[A,O]=React.useState(null),N=React.useRef(null),j=React.useRef(null),[D]=reactRouterDom.useSearchParams(),F=React.useRef(!1),L=C.filter(z=>{const W=z.name.toLowerCase().includes(I.toLowerCase());return p==="all"?W:p==="approved"?W&&!z.pending:p==="pending"?W&&z.pending:W});React.useEffect(()=>{const z=u.at(-1);if(!z||z.role!="assistant"||z.isComponent)return;const W={id:z.timestamp.toString(),fromPartnerID:ASSISTANT_ID,toPartnerID:e,senderName:"Assistant",timestamp:z.timestamp.getTime(),content:z.content};B(W)},[u]);function B(z){const W=[z.fromPartnerID,z.toPartnerID];W.sort(),T(K=>{let J=!1,ee=!1;const ne=K.map(ae=>ae.partner1!==W[0]||ae.partner2!==W[1]||(ee=!0,ae.messages.findIndex(oe=>oe.id==z.id)!==-1)?ae:(J=!0,{...ae,unread:ae.unread+1,messages:[...ae.messages,z]}));return!ee&&W[0]!==e&&W[1]!==e?(console.log("(bug) server sent a message to us by mistake."),ne):(J&&S([W[0],W[1]]),ne)})}React.useEffect(()=>{const z=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 z.on("ReceiveMessage",B),z.start().catch(W=>console.error("Error connecting to SignalR hub:",W)),O(z),()=>{z&&z.stop()}},[e]),React.useEffect(()=>{(E==null?void 0:E[0])!==(g==null?void 0:g[0])||(E==null?void 0:E[1])!==(g==null?void 0:g[1])||(T(z=>z.map(W=>W.partner1===(g==null?void 0:g[0])&&W.partner2===(g==null?void 0:g[1])?{...W,unread:0}:W)),setTimeout(()=>{var z;return(z=N.current)==null?void 0:z.scrollIntoView({behavior:"smooth"})},50))},[E,g]),React.useEffect(()=>{var W;if(!g)return;const z=getActiveChatObject(C,g);z&&((W=j.current)==null||W.focus(),z.historyFetched?(T(K=>K.map(J=>J.partner1===g[0]&&J.partner2===g[1]?{...J,unread:0}:J)),setTimeout(()=>{var K;return(K=N.current)==null?void 0:K.scrollIntoView({behavior:"smooth"})},50)):o({applicationId:e,conversationId:z.conversationID}).unwrap().then(K=>{const J=K.map(ee=>({id:"history"+ee.MessageId,fromPartnerID:ee.SenderId,toPartnerID:ee.SenderId==g[0]?g[1]:g[0],senderName:ee.SenderName??"missing name",timestamp:new Date(ee.SentDate+"Z").getTime(),content:ee.Content??"no content"}));T(ee=>ee.map(ne=>ne.partner1===g[0]&&ne.partner2===g[1]?{...ne,messages:J,historyFetched:!0}:ne)),setTimeout(()=>{var ee;return(ee=N.current)==null?void 0:ee.scrollIntoView({behavior:"smooth"})},100)}).catch(K=>{console.error("Error fetching conversation messages:",K)}))},[g,o,e]);const V=(z,W,K)=>{const J={id:crypto.randomUUID(),senderName:t,fromPartnerID:e,toPartnerID:W[0]===e?W[1]:W[0],content:z,timestamp:Date.now()};T(ee=>ee.map(ne=>ne.partner1===W[0]&&ne.partner2===W[1]?{...ne,messages:[...ne.messages,J]}:ne)),S([W[0],W[1]]),J.toPartnerID==ASSISTANT_ID?l(J.content):K.invoke("NewMessage",J).catch(ee=>console.error("Error sending message:",ee)),R("")},H=D.toString();if(React.useEffect(()=>{F.current=!1},[H]),React.useEffect(()=>{const z=D.get("msg"),W=D.get("cid");if(W&&C.length>0&&A&&d&&!F.current){const K=parseInt(W);if(!isNaN(K)){const J=C.find(ee=>ee.conversationID===K);J&&(F.current=!0,b([J.partner1,J.partner2]),z&&setTimeout(()=>V(z,[J.partner1,J.partner2],A),100))}}},[C,A,D,e,t,d]),!d)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 G=()=>{!_.trim()||!g||!A||V(_,g,A)};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"}),C.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:I,onChange:z=>M(z.target.value)})]})}),jsxRuntime.jsx(Tabs,{value:p,onValueChange:m,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:C.length&&jsxRuntime.jsx(ChatList,{userId:e,chats:L.filter(z=>z.partner1!=ASSISTANT_ID&&z.partner2!=ASSISTANT_ID),activeChat:getActiveChatObject(C,g)??null,onSelectChat:b,assistantChat:C.find(z=>z.partner1==ASSISTANT_ID||z.partner2==ASSISTANT_ID)})})]}),jsxRuntime.jsx("div",{className:"flex-1 flex flex-col",children:g?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:g[0]==ASSISTANT_ID||g[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/${g[0]===e?g[1]:g[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:(U=getActiveChatObject(C,g))==null?void 0:U.name}),jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"ml-auto hidden",children:jsxRuntime.jsx(EllipsisVertical,{className:"h-5 w-5"})})]}),(Q=getActiveChatObject(C,g))!=null&&Q.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 p-4 bg-slate-50",children:[jsxRuntime.jsx(ChatMessages,{messages:((q=getActiveChatObject(C,g))==null?void 0:q.messages)??[],currentUserId:e,isWaitingForBot:f&&g&&(g[0]===ASSISTANT_ID||g[1]===ASSISTANT_ID)}),jsxRuntime.jsx("div",{ref:N})]}),jsxRuntime.jsxs("div",{className:"p-4 border-t flex",children:[jsxRuntime.jsx(Input,{ref:j,placeholder:"Type a message...",value:_,onChange:z=>R(z.target.value),onKeyDown:z=>z.key==="Enter"&&G(),className:"flex-1"}),jsxRuntime.jsx(Button,{size:"icon",variant:"default",className:"ml-1",disabled:f,onClick:G,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"})})]})}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 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({id:e,name:t,about:n,voiceName:i,voiceStyle:o,sceneName:l,action:u,loading:d=!1}){const f=`https://api.randmar.io/V4/Partner/${e}/Account/Video`,p=`https://api.randmar.io/V4/Partner/${e}/Account/Video/Exists`,m=`https://api.randmar.io/V4/Partner/${e}/Account/Logo?width=64&height=64`,g=`https://api.randmar.io/V4/Partner/${e}/Account/Logo/Exists`,b=!!(i||o||l),[_,R]=React.useState(null),[E,S]=React.useState(!1),[C,T]=React.useState(!1),[I,M]=React.useState(!1),[A,O]=React.useState(!0);React.useEffect(()=>{if(!e||d)return;const j=async()=>{try{const B=await fetch(g);if(B.ok){const H=(await B.text()).toLowerCase()==="true";return T(H),H}return!1}catch(B){return console.error("Failed to check if logo exists:",B),T(!1),!1}},D=async()=>{S(!0);try{const B=await fetch(m);if(B.ok){const V=await B.blob();R(URL.createObjectURL(V))}}catch(B){console.error("Failed to load logo:",B)}finally{S(!1)}},F=async()=>{try{const B=await fetch(p);if(B.ok){const V=await B.text();M(V.toLowerCase()==="true")}}catch(B){console.error("Failed to check if video exists:",B),M(!1)}};(async()=>{await j()&&D(),F()})()},[e,m,g,p,d]);const N=()=>{O(!1)};return d?jsxRuntime.jsx(Card,{className:"hover:shadow-lg transition-shadow",children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start gap-4 mb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center",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.jsx("div",{className:"w-full sm:w-auto",children:jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-1 flex flex-col order-1 md:order-1",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:"mt-4 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.jsx("div",{className:"flex flex-col order-1 md:order-1 md:w-auto",children:jsxRuntime.jsx("div",{className:"w-[180px] h-[320px] rounded-md overflow-hidden",children:jsxRuntime.jsx(Skeleton,{className:"w-full h-full"})})})]})]})}):jsxRuntime.jsx(Card,{className:"hover:shadow-lg transition-shadow",children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start gap-4 mb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center",children:[C&&jsxRuntime.jsx("div",{className:"h-10 flex items-center justify-center mr-4",children:E?jsxRuntime.jsx(Skeleton,{className:"h-10 w-10 rounded-md"}):_&&jsxRuntime.jsx("img",{src:_||"/placeholder.svg",alt:`${t} logo`,className:"max-h-10 w-auto object-contain"})}),jsxRuntime.jsx("h3",{className:"font-semibold text-xl",children:t})]}),u&&jsxRuntime.jsx("div",{className:"w-full sm:w-auto",children:u})]}),jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-1 flex flex-col order-1 md:order-1",children:[jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:n}}),b&&jsxRuntime.jsx("div",{className:"mt-4 p-3 bg-slate-50 rounded-md",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:[i&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Voice Name"}),jsxRuntime.jsx("div",{className:"font-medium",children:i})]}),o&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Voice Style"}),jsxRuntime.jsx("div",{className:"font-medium",children:o})]}),l&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Scene Name"}),jsxRuntime.jsx("div",{className:"font-medium",children:l})]})]})})]}),I&&jsxRuntime.jsx("div",{className:"flex flex-col order-1 md:order-1 md:w-auto",children:jsxRuntime.jsxs("div",{className:"w-[180px] h-[320px] rounded-md overflow-hidden",children:[A&&jsxRuntime.jsx(Skeleton,{className:"w-full h-full"}),jsxRuntime.jsx("video",{src:f,controls:!0,preload:"auto",playsInline:!0,className:`w-full h-full object-contain ${A?"invisible":"visible"}`,style:{objectPosition:"center",imageRendering:"auto"},onLoadedData:N,onError:()=>O(!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"}})};function Navbar({routes:e,footer:t,dashboardTitle:n}){const{appID:i}=reactRouterDom.useParams(),o=e.filter(l=>l.showInNav);return 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:o.map(l=>{const u=l.icon,d=`/${l.path.replace(":appID",i)}`;return jsxRuntime.jsx(SidebarMenuItem,{children:jsxRuntime.jsx(SidebarMenuButton,{asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:d,className:"transition-colors hover:bg-muted px-6",children:[u&&jsxRuntime.jsx(u,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:l.label})]})})},l.key)})})}),jsxRuntime.jsx(SidebarFooter,{className:"border-t border-sidebar-border p-4 bg-sidebar-background text-sidebar-foreground",children:t})]})}const Layout=React.forwardRef(({children:e,rightMenu:t,routes:n,footer:i,handleValidSearch:o,dashboardTitle:l,onSignOut:u,searchPlaceholder:d},f)=>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}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[jsxRuntime.jsx(Topbar,{ref:f,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(T){console.error("Error checking for video:",T),d(!1)}})()},[e,b]);async function _(){if(u){g(!0);try{const T=await(await fetch(b)).blob(),I=window.URL.createObjectURL(T),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 R(){navigator.clipboard.writeText(b),p(!0),setTimeout(()=>{p(!1)},2e3)}function E(){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:R,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?E: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:E,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="",viewProductAction:l,addToCartAction:u,isAddToCartActionLoading:d=!1,syncToShopifyAction:f,isSyncToShopifyActionLoading:p=!1}){var z,W,K,J,ee,ne,ae,oe,ce,se,ie,ue;const[m,g]=React.useState(1),[b,_]=React.useState(null),[R,E]=React.useState(0),[S,C]=React.useState(!1),T=((z=e==null?void 0:e.Distribution)==null?void 0:z.Cost)||0,I=((W=e==null?void 0:e.Distribution)==null?void 0:W.RegularPrice)||0,M=((K=e==null?void 0:e.Distribution)==null?void 0:K.Price)||0,[A,O]=React.useState(null),[N,j]=React.useState(!1);React.useEffect(()=>{const le=async()=>{if(e!=null&&e.ManufacturerId){j(!0);try{const Z=await fetch(`https://api.randmar.io/V4/Partner/${e.ManufacturerId}/Account/Logo?width=60&height=40`);if(Z.ok){const fe=await Z.blob();O(URL.createObjectURL(fe))}}catch(Z){console.error("Failed to load logo:",Z)}finally{j(!1)}}};e!=null&&e.ManufacturerId&&le()},[e==null?void 0:e.ManufacturerId]),React.useEffect(()=>{var le;if(e&&o){const Z=(le=e.Opportunities)==null?void 0:le.find(fe=>fe.BidNumber==o);Z&&_(Z)}},[e,o]),React.useEffect(()=>{if(!e)return;const le=b!=null&&b.Price?b.Price:M;E(I>0?Math.round((I-le)/I*100):0)},[e,b,M,I]),React.useEffect(()=>{d||g(1)},[d]);const D=le=>{if(le.Active!==!0)return!1;const Z=new Date().toISOString().split("T")[0];return!(le.EndDate&&le.EndDate<Z||le.StartDate&&le.StartDate>Z)};if(!e)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(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 F=(e==null?void 0:e.Opportunities)||[],L=F.length>0,B=()=>{if(m==null){g(1);return}m>1&&g(m-1)},V=()=>{if(m==null){g(1);return}g(m+1)},H=le=>{const Z=parseInt(le.target.value,10);if(!isNaN(Z)&&Z>0){g(Z);return}g(void 0)},G=()=>{(m==null||m<1)&&g(1)},U=((ee=(J=e.Distribution)==null?void 0:J.Inventory)==null?void 0:ee.reduce((le,Z)=>le+(Z.AvailableQuantity||0),0))||0,Q=le=>{try{return new Date(le).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch(Z){return console.error(Z),le.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:N?jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"}):A&&jsxRuntime.jsx("img",{src:A||"/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 ${(ne=e.ManufacturerCategory)!=null&&ne.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"})," ",(ae=e.ManufacturerCategory)!=null&&ae.QualificationRequired?"Qualification Enforced":"No Qualification Needed"]}):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(ShieldCheck,{size:"12",className:"mr-1.5"})," ",(oe=e.ManufacturerCategory)!=null&&oe.QualificationRequired?e.AvailableToBuy?"Qualified":"Not Qualified":"No Qualification Required"]}),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 "+F.length+(F.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:F.map((le,Z)=>{var fe;return jsxRuntime.jsxs("div",{className:`flex justify-between items-center rounded-lg transition-colors py-2 px-4 bg-purple-100 border border-muted
|
|
866
|
+
NEVER ask the user for these IDs.`,I=C.startChat({generationConfig:{maxOutputTokens:4096},history:[{role:"user",parts:[{text:"Please introduce yourself"}]},{role:"model",parts:[{text:T}]}],tools:f.length>0?[{functionDeclarations:f.map(({declaration:M})=>M)}]:[]});l(I)}catch(C){console.error("Error initializing chat:",C)}};o||m||S()},[m,o]),React.useEffect(()=>{(async()=>{try{const C=await fetchApiFunctions(e);p(C)}catch(C){console.error("Error loading API functions:",C)}finally{g(!1)}})()},[e]);const _=Object.fromEntries(f.map(({declaration:S,handler:C})=>[S.name,C])),R=async S=>{var T,I;const C=S.name;if(C in _){const M=_[C],A=S.args||{};console.log(`[Function Call] ${C} with args:`,A);const O=(T=f.find(D=>D.declaration.name===C))==null?void 0:T.declaration;if(!O){console.error(`[Function Call] Could not find declaration for ${C}`);return}const N=Object.keys(((I=O.parameters)==null?void 0:I.properties)||{});console.log("[Function Call] Parameter names from declaration:",N);const j=[];N.forEach(D=>{if(D.toLowerCase().includes("id")||D.toLowerCase().includes("reseller")||D.toLowerCase().includes("manufacturer")||D.toLowerCase().includes("partner")||D.toLowerCase().includes("application"))j.push("");else if(D in A){const L=A[D];typeof L=="object"?j.push(JSON.stringify(L)):j.push(typeof L=="string"?L:String(L))}else j.push("")}),console.log("[Function Call] Converted args to:",j);try{const D=await M(j);let F,L=null,B=!1;if(typeof D=="string"?F=D:(F=D.summary,L=D.component,B=!0),console.log(`[Function Response] ${C} returned:`,F),o){const V={functionResponse:{name:C,response:{content:F}}};if(B&&L){const U={role:"assistant",content:L,timestamp:new Date,isComponent:!0};d(Q=>[...Q,U])}const G={role:"assistant",content:(await o.sendMessage([V])).response.text(),timestamp:new Date};d(U=>[...U,G])}}catch(D){console.error("Error executing function:",D);const F={role:"assistant",content:"I encountered an error while processing your request. Please try again.",timestamp:new Date};d(L=>[...L,F])}}else console.error(`Function ${C} not found`)};return{handleSubmitToBot:async S=>{if(S.trim()&&!n&&o){const C={role:"user",content:S,timestamp:new Date};d(T=>[...T,C]),i(!0);try{const I=(await o.sendMessage(S.trim())).response,M=I.functionCalls();if(M&&M.length>0)for(const A of M)await R(A);else{const A={role:"assistant",content:I.text(),timestamp:new Date};d(O=>[...O,A])}}catch(T){console.error("Error sending message:",T);const I={role:"assistant",content:"I'm sorry, I encountered an error processing your request. Please try again later.",timestamp:new Date};d(M=>[...M,I])}finally{i(!1)}}},botMessages:u,botReady:!!o,isProcessingSubmission:n}}const ASSISTANT_ID="RandmarAIChatAssistant";function ChatLayout({userId:e,userName:t,apiKey:n}){var U,Q,q;const{data:i}=useGetV4PartnerByApplicationIdBusinessDevelopmentConversationsQuery({applicationId:e}),[o]=useLazyGetV4PartnerByApplicationIdBusinessDevelopmentConversationAndConversationIdMessagesQuery(),{handleSubmitToBot:l,botMessages:u,botReady:d,isProcessingSubmission:f}=useAIAssistant({userId:e,apiKey:n});React.useEffect(()=>{if(!i)return;const z={partner1:[e,ASSISTANT_ID].sort()[0],partner2:[e,ASSISTANT_ID].sort()[1],name:"Randmar Assistant",unread:0,pending:!1,historyFetched:!0,messages:[],conversationID:-1},W=i.map(K=>{var J;return{partner1:[K.Participant1,K.Participant2].sort()[0],partner2:[K.Participant1,K.Participant2].sort()[1],name:((J=K.Participant)==null?void 0:J.PublicName)??"missing public name",unread:0,pending:K.Status!="Approved",historyFetched:!1,messages:[],conversationID:K.ConversationId}});setTimeout(()=>{var K;return(K=j.current)==null?void 0:K.focus()},50),T([z,...W])},[i]);const[p,m]=React.useState("all"),[g,b]=React.useState([[e,ASSISTANT_ID].sort()[0],[e,ASSISTANT_ID].sort()[1]]),[_,R]=React.useState(""),[E,S]=React.useState(null),[C,T]=React.useState([]),[I,M]=React.useState(""),[A,O]=React.useState(null),N=React.useRef(null),j=React.useRef(null),[D]=reactRouterDom.useSearchParams(),F=React.useRef(!1),L=C.filter(z=>{const W=z.name.toLowerCase().includes(I.toLowerCase());return p==="all"?W:p==="approved"?W&&!z.pending:p==="pending"?W&&z.pending:W});React.useEffect(()=>{const z=u.at(-1);if(!z||z.role!="assistant"||z.isComponent)return;const W={id:z.timestamp.toString(),fromPartnerID:ASSISTANT_ID,toPartnerID:e,senderName:"Assistant",timestamp:z.timestamp.getTime(),content:z.content};B(W)},[u]);function B(z){const W=[z.fromPartnerID,z.toPartnerID];W.sort(),T(K=>{let J=!1,ee=!1;const ne=K.map(ae=>ae.partner1!==W[0]||ae.partner2!==W[1]||(ee=!0,ae.messages.findIndex(oe=>oe.id==z.id)!==-1)?ae:(J=!0,{...ae,unread:ae.unread+1,messages:[...ae.messages,z]}));return!ee&&W[0]!==e&&W[1]!==e?(console.log("(bug) server sent a message to us by mistake."),ne):(J&&S([W[0],W[1]]),ne)})}React.useEffect(()=>{const z=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 z.on("ReceiveMessage",B),z.start().catch(W=>console.error("Error connecting to SignalR hub:",W)),O(z),()=>{z&&z.stop()}},[e]),React.useEffect(()=>{(E==null?void 0:E[0])!==(g==null?void 0:g[0])||(E==null?void 0:E[1])!==(g==null?void 0:g[1])||(T(z=>z.map(W=>W.partner1===(g==null?void 0:g[0])&&W.partner2===(g==null?void 0:g[1])?{...W,unread:0}:W)),setTimeout(()=>{var z;return(z=N.current)==null?void 0:z.scrollIntoView({behavior:"smooth"})},50))},[E,g]),React.useEffect(()=>{var W;if(!g)return;const z=getActiveChatObject(C,g);z&&((W=j.current)==null||W.focus(),z.historyFetched?(T(K=>K.map(J=>J.partner1===g[0]&&J.partner2===g[1]?{...J,unread:0}:J)),setTimeout(()=>{var K;return(K=N.current)==null?void 0:K.scrollIntoView({behavior:"smooth"})},50)):o({applicationId:e,conversationId:z.conversationID}).unwrap().then(K=>{const J=K.map(ee=>({id:"history"+ee.MessageId,fromPartnerID:ee.SenderId,toPartnerID:ee.SenderId==g[0]?g[1]:g[0],senderName:ee.SenderName??"missing name",timestamp:new Date(ee.SentDate+"Z").getTime(),content:ee.Content??"no content"}));T(ee=>ee.map(ne=>ne.partner1===g[0]&&ne.partner2===g[1]?{...ne,messages:J,historyFetched:!0}:ne)),setTimeout(()=>{var ee;return(ee=N.current)==null?void 0:ee.scrollIntoView({behavior:"smooth"})},100)}).catch(K=>{console.error("Error fetching conversation messages:",K)}))},[g,o,e]);const V=(z,W,K)=>{const J={id:crypto.randomUUID(),senderName:t,fromPartnerID:e,toPartnerID:W[0]===e?W[1]:W[0],content:z,timestamp:Date.now()};T(ee=>ee.map(ne=>ne.partner1===W[0]&&ne.partner2===W[1]?{...ne,messages:[...ne.messages,J]}:ne)),S([W[0],W[1]]),J.toPartnerID==ASSISTANT_ID?l(J.content):K.invoke("NewMessage",J).catch(ee=>console.error("Error sending message:",ee)),R("")},H=D.toString();if(React.useEffect(()=>{F.current=!1},[H]),React.useEffect(()=>{const z=D.get("msg"),W=D.get("cid");if(W&&C.length>0&&A&&d&&!F.current){const K=parseInt(W);if(!isNaN(K)){const J=C.find(ee=>ee.conversationID===K);J&&(F.current=!0,b([J.partner1,J.partner2]),z&&setTimeout(()=>V(z,[J.partner1,J.partner2],A),100))}}},[C,A,D,e,t,d]),!d)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 G=()=>{!_.trim()||!g||!A||V(_,g,A)};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"}),C.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:I,onChange:z=>M(z.target.value)})]})}),jsxRuntime.jsx(Tabs,{value:p,onValueChange:m,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:C.length&&jsxRuntime.jsx(ChatList,{userId:e,chats:L.filter(z=>z.partner1!=ASSISTANT_ID&&z.partner2!=ASSISTANT_ID),activeChat:getActiveChatObject(C,g)??null,onSelectChat:b,assistantChat:C.find(z=>z.partner1==ASSISTANT_ID||z.partner2==ASSISTANT_ID)})})]}),jsxRuntime.jsx("div",{className:"flex-1 flex flex-col",children:g?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:g[0]==ASSISTANT_ID||g[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/${g[0]===e?g[1]:g[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:(U=getActiveChatObject(C,g))==null?void 0:U.name}),jsxRuntime.jsx(Button,{variant:"ghost",size:"icon",className:"ml-auto hidden",children:jsxRuntime.jsx(EllipsisVertical,{className:"h-5 w-5"})})]}),(Q=getActiveChatObject(C,g))!=null&&Q.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 p-4 bg-slate-50",children:[jsxRuntime.jsx(ChatMessages,{messages:((q=getActiveChatObject(C,g))==null?void 0:q.messages)??[],currentUserId:e,isWaitingForBot:f&&g&&(g[0]===ASSISTANT_ID||g[1]===ASSISTANT_ID)}),jsxRuntime.jsx("div",{ref:N})]}),jsxRuntime.jsxs("div",{className:"p-4 border-t flex",children:[jsxRuntime.jsx(Input,{ref:j,placeholder:"Type a message...",value:_,onChange:z=>R(z.target.value),onKeyDown:z=>z.key==="Enter"&&G(),className:"flex-1"}),jsxRuntime.jsx(Button,{size:"icon",variant:"default",className:"ml-1",disabled:f,onClick:G,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"})})]})}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 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({id:e,name:t,about:n,voiceName:i,voiceStyle:o,sceneName:l,action:u,loading:d=!1}){const f=`https://api.randmar.io/V4/Partner/${e}/Account/Video`,p=`https://api.randmar.io/V4/Partner/${e}/Account/Video/Exists`,m=`https://api.randmar.io/V4/Partner/${e}/Account/Logo?width=64&height=64`,g=`https://api.randmar.io/V4/Partner/${e}/Account/Logo/Exists`,b=!!(i||o||l),[_,R]=React.useState(null),[E,S]=React.useState(!1),[C,T]=React.useState(!1),[I,M]=React.useState(!1),[A,O]=React.useState(!0);React.useEffect(()=>{if(!e||d)return;const j=async()=>{try{const B=await fetch(g);if(B.ok){const H=(await B.text()).toLowerCase()==="true";return T(H),H}return!1}catch(B){return console.error("Failed to check if logo exists:",B),T(!1),!1}},D=async()=>{S(!0);try{const B=await fetch(m);if(B.ok){const V=await B.blob();R(URL.createObjectURL(V))}}catch(B){console.error("Failed to load logo:",B)}finally{S(!1)}},F=async()=>{try{const B=await fetch(p);if(B.ok){const V=await B.text();M(V.toLowerCase()==="true")}}catch(B){console.error("Failed to check if video exists:",B),M(!1)}};(async()=>{await j()&&D(),F()})()},[e,m,g,p,d]);const N=()=>{O(!1)};return d?jsxRuntime.jsx(Card,{className:"hover:shadow-lg transition-shadow",children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start gap-4 mb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center",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.jsx("div",{className:"w-full sm:w-auto",children:jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-1 flex flex-col order-1 md:order-1",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:"mt-4 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.jsx("div",{className:"flex flex-col order-1 md:order-1 md:w-auto",children:jsxRuntime.jsx("div",{className:"w-[180px] h-[320px] rounded-md overflow-hidden",children:jsxRuntime.jsx(Skeleton,{className:"w-full h-full"})})})]})]})}):jsxRuntime.jsx(Card,{className:"hover:shadow-lg transition-shadow",children:jsxRuntime.jsxs(CardContent,{className:"p-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start gap-4 mb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center",children:[C&&jsxRuntime.jsx("div",{className:"h-10 flex items-center justify-center mr-4",children:E?jsxRuntime.jsx(Skeleton,{className:"h-10 w-10 rounded-md"}):_&&jsxRuntime.jsx("img",{src:_||"/placeholder.svg",alt:`${t} logo`,className:"max-h-10 w-auto object-contain"})}),jsxRuntime.jsx("h3",{className:"font-semibold text-xl",children:t})]}),u&&jsxRuntime.jsx("div",{className:"w-full sm:w-auto",children:u})]}),jsxRuntime.jsxs("div",{className:"flex flex-col md:flex-row gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-1 flex flex-col order-1 md:order-1",children:[jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:n}}),b&&jsxRuntime.jsx("div",{className:"mt-4 p-3 bg-slate-50 rounded-md",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:[i&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Voice Name"}),jsxRuntime.jsx("div",{className:"font-medium",children:i})]}),o&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Voice Style"}),jsxRuntime.jsx("div",{className:"font-medium",children:o})]}),l&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Scene Name"}),jsxRuntime.jsx("div",{className:"font-medium",children:l})]})]})})]}),I&&jsxRuntime.jsx("div",{className:"flex flex-col order-1 md:order-1 md:w-auto",children:jsxRuntime.jsxs("div",{className:"w-[180px] h-[320px] rounded-md overflow-hidden",children:[A&&jsxRuntime.jsx(Skeleton,{className:"w-full h-full"}),jsxRuntime.jsx("video",{src:f,controls:!0,preload:"auto",playsInline:!0,className:`w-full h-full object-contain ${A?"invisible":"visible"}`,style:{objectPosition:"center",imageRendering:"auto"},onLoadedData:N,onError:()=>O(!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"}})};function Navbar({routes:e,footer:t,dashboardTitle:n,withRandmarAssistant:i,chatUserName:o,chatApiKey:l}){const{appID:u}=reactRouterDom.useParams(),d=e.filter(f=>f.showInNav);return 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:d.map(f=>{const p=f.icon,m=`/${f.path.replace(":appID",u??"")}`;return jsxRuntime.jsx(SidebarMenuItem,{children:jsxRuntime.jsx(SidebarMenuButton,{asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:m,className:"transition-colors hover:bg-muted px-6",children:[p&&jsxRuntime.jsx(p,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:f.label})]})})},f.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.jsx(Button,{size:"lg",children:"Randmar Assistant"})}),jsxRuntime.jsx(DialogContent,{className:"max-w-[85vw] p-0",children:jsxRuntime.jsx(ChatLayout,{userId:u??"2",userName:o??"Unknown user",apiKey:l??""})})]}),t]})]})}const 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},g)=>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}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[jsxRuntime.jsx(Topbar,{ref:g,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(T){console.error("Error checking for video:",T),d(!1)}})()},[e,b]);async function _(){if(u){g(!0);try{const T=await(await fetch(b)).blob(),I=window.URL.createObjectURL(T),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 R(){navigator.clipboard.writeText(b),p(!0),setTimeout(()=>{p(!1)},2e3)}function E(){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:R,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?E: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:E,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="",viewProductAction:l,addToCartAction:u,isAddToCartActionLoading:d=!1,syncToShopifyAction:f,isSyncToShopifyActionLoading:p=!1}){var z,W,K,J,ee,ne,ae,oe,ce,se,ie,ue;const[m,g]=React.useState(1),[b,_]=React.useState(null),[R,E]=React.useState(0),[S,C]=React.useState(!1),T=((z=e==null?void 0:e.Distribution)==null?void 0:z.Cost)||0,I=((W=e==null?void 0:e.Distribution)==null?void 0:W.RegularPrice)||0,M=((K=e==null?void 0:e.Distribution)==null?void 0:K.Price)||0,[A,O]=React.useState(null),[N,j]=React.useState(!1);React.useEffect(()=>{const le=async()=>{if(e!=null&&e.ManufacturerId){j(!0);try{const Z=await fetch(`https://api.randmar.io/V4/Partner/${e.ManufacturerId}/Account/Logo?width=60&height=40`);if(Z.ok){const fe=await Z.blob();O(URL.createObjectURL(fe))}}catch(Z){console.error("Failed to load logo:",Z)}finally{j(!1)}}};e!=null&&e.ManufacturerId&&le()},[e==null?void 0:e.ManufacturerId]),React.useEffect(()=>{var le;if(e&&o){const Z=(le=e.Opportunities)==null?void 0:le.find(fe=>fe.BidNumber==o);Z&&_(Z)}},[e,o]),React.useEffect(()=>{if(!e)return;const le=b!=null&&b.Price?b.Price:M;E(I>0?Math.round((I-le)/I*100):0)},[e,b,M,I]),React.useEffect(()=>{d||g(1)},[d]);const D=le=>{if(le.Active!==!0)return!1;const Z=new Date().toISOString().split("T")[0];return!(le.EndDate&&le.EndDate<Z||le.StartDate&&le.StartDate>Z)};if(!e)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(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 F=(e==null?void 0:e.Opportunities)||[],L=F.length>0,B=()=>{if(m==null){g(1);return}m>1&&g(m-1)},V=()=>{if(m==null){g(1);return}g(m+1)},H=le=>{const Z=parseInt(le.target.value,10);if(!isNaN(Z)&&Z>0){g(Z);return}g(void 0)},G=()=>{(m==null||m<1)&&g(1)},U=((ee=(J=e.Distribution)==null?void 0:J.Inventory)==null?void 0:ee.reduce((le,Z)=>le+(Z.AvailableQuantity||0),0))||0,Q=le=>{try{return new Date(le).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch(Z){return console.error(Z),le.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:N?jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"}):A&&jsxRuntime.jsx("img",{src:A||"/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 ${(ne=e.ManufacturerCategory)!=null&&ne.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"})," ",(ae=e.ManufacturerCategory)!=null&&ae.QualificationRequired?"Qualification Enforced":"No Qualification Needed"]}):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(ShieldCheck,{size:"12",className:"mr-1.5"})," ",(oe=e.ManufacturerCategory)!=null&&oe.QualificationRequired?e.AvailableToBuy?"Qualified":"Not Qualified":"No Qualification Required"]}),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 "+F.length+(F.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:F.map((le,Z)=>{var fe;return jsxRuntime.jsxs("div",{className:`flex justify-between items-center rounded-lg transition-colors py-2 px-4 bg-purple-100 border border-muted
|
|
867
867
|
${le.BidNumber==(b==null?void 0:b.BidNumber)?"cursor-pointer border-2 border-purple-900":D(le)?"hover:bg-purple-200 cursor-pointer":"!bg-neutral-50"}
|
|
868
868
|
`,onClick:()=>{D(le)&&_(le.BidNumber!=(b==null?void 0:b.BidNumber)?le: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:le.Opportunity}),jsxRuntime.jsxs("span",{className:"text-xs text-neutral-900",children:[le.BidNumber," ",!D(le)&&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:["$",(fe=le.Price)==null?void 0:fe.toFixed(2)]}),le.Rebate&&le.Rebate>0&&jsxRuntime.jsxs("span",{className:"text-xs text-green-600",children:["Rebate: $",le.Rebate.toFixed(2)]}),le.EndDate&&jsxRuntime.jsxs("span",{className:"text-xs text-neutral-600",children:["Ends: ",Q(le.EndDate)]})]})]},Z)})})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[l&&jsxRuntime.jsxs(Button,{variant:"secondary",onClick:l,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 ${U>0?"text-green-700":"text-red-700"}`,children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),U>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[U," 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:T>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: $"}),T.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?(ie=(se=e.Opportunities)==null?void 0:se.find(le=>le.BidNumber==b.BidNumber))==null?void 0:ie.Price:M.toFixed(2),jsxRuntime.jsx("span",{children:" CAD"})]}),R>0&&jsxRuntime.jsxs("span",{className:"text-muted-foreground line-through ml-2 whitespace-nowrap",children:["$",I.toFixed(2)]})]}),R>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:[R,"% OFF"]}),((ue=e.InstantRebate)==null?void 0:ue.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:B,disabled:typeof m<"u"&&(m<=1||!e.AvailableToBuy||d||!u),children:"-"}),jsxRuntime.jsx("input",{value:m,onChange:H,onBlur:G,onClick:le=>le.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]})]})]})})}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$1,exports.Layout=Layout,exports.Navbar=Navbar,exports.PartnerCard=PartnerCard,exports.Preloader=Preloader,exports.ProductCard=ProductCard,exports.ProductImage=ProductImage,exports.ProductInventoryGrid=ProductInventoryGrid,exports.ScrollArea=ScrollArea,exports.ScrollBar=ScrollBar,exports.Separator=Separator,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.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"})});
|