randmarcomps 1.197.0 → 1.198.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.
@@ -63971,7 +63971,7 @@ function ManufacturerGetStartedButton({ applicationId: e, manufacturer: t }) {
63971
63971
  `);
63972
63972
  M(!0), Le({
63973
63973
  applicationId: e,
63974
- partnerId: "2",
63974
+ partnerId: t.ManufactuerId,
63975
63975
  message: st
63976
63976
  }).then((Fe) => {
63977
63977
  var Qe;
@@ -966,4 +966,4 @@ Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=1
966
966
  Use <ProductCard item={data}>`],basicComponents=["<Card> <CardHeader> <CardTitle>...</CardTitle> <CardDescription>...</CardDescription> </CardHeader> <CardContent> ... </CardContent> </Card>","<Badge>...</Badge>",'<Tabs defaultValue="eg1"> <TabsList> <TabsTrigger value="eg1">Example1</TabsTrigger> <TabsTrigger value="eg2">Example2</TabsTrigger> </TabsList> <TabsContent value="eg1"> ... </TabsContent> <TabsContent value="eg2"> ... </TabsContent> </Tabs>',"<ScrollArea>...</ScrollArea>","<ScrollArea orientation='horizontal'>...</ScrollArea>"],GetJSXFromAI=async(e,t,n,o,l=3)=>{const d="In addition to basic html tags, You have access to these beautiful Handmade Components. Try to use them even when you get an array of search results. For example, use ProductCard when ContentType is Product:",f="You also have access to these few Shadcn UI components:",g='Here is the data to display to the user (If a Handmade Component is a good fit for the data, use it. Otherwise, use regular html tags) (You have access to this data object in React via the data variable. Do not use JSON.parse, it is already parsed. For example, if data is an array, you can use {data.map(item, idx => <>...</>)} directly. CAUTION: when using map, you must use implicit return rather than a block body, as shown before. AGAIN: never use JSON.parse - data is already parsed and never a block body with arrow functions such as: (item => { return "EXAMPLE - DO NOT DO THIS" }):',b="Only output a single JSX code snippet. Start with <> and end with </>. All other code will be ignored, so make sure to place all CSS styles inline. Use CSS flex layouts when there is a lot of stuff to display.",_=JSON.stringify(n),S=[t,d,...complexComponents,f,...basicComponents,b,g,_,b].join(`\r
967
967
  `),E=await new GoogleGenAI({apiKey:e}).chats.create({model:o?"gemini-2.5-pro-preview-03-25":"gemini-2.0-flash-lite"}).sendMessage({message:S}),M=trimJSXString(E.text??"");return M&&!containsBlockArrowFunc(M)?M:l==0?"<p>Could not generate visuals for this data.</p>":await GetJSXFromAI(e,t,n,o,l-1)};function containsBlockArrowFunc(e){return e.replace(/\s+/g,"").indexOf("=>{")>=0}function trimJSXString(e){const t=e.indexOf("<"),n=e.lastIndexOf("</");return t===-1||n===-1?"":e.slice(t,e.indexOf(">",n)+1)}function AiGeneratedContent(e){const[t,n]=React.useState(""),{apiKey:o}=useApiKey();return React.useEffect(()=>{if(!o||!e.prompt||!e.data)return;n("");let l=!1;return GetJSXFromAI(o,e.prompt,e.data,e.smartAndSlow===!0).then(d=>{l||n(d)}),()=>{l=!0}},[e.prompt,e.data,n,o,e.smartAndSlow]),t?jsxRuntime.jsx(source_default,{bindings:{data:e.data},components:{ResellerCard,ManufacturerCard,PartnerCard,ProductCard,Card,CardHeader,CardTitle,CardContent,CardDescription,Badge,Tabs,TabsList,TabsContent,TabsTrigger,ScrollArea},jsx:t}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(Skeleton,{className:"h-32 w-32",children:jsxRuntime.jsx(Bot,{className:"m-auto align-middle h-full"})})})}var CHECKBOX_NAME="Checkbox",[createCheckboxContext,createCheckboxScope]=createContextScope(CHECKBOX_NAME),[CheckboxProvider,useCheckboxContext]=createCheckboxContext(CHECKBOX_NAME),Checkbox$1=React__namespace.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:o,checked:l,defaultChecked:d,required:f,disabled:g,value:b="on",onCheckedChange:_,form:S,...R}=e,[C,E]=React__namespace.useState(null),M=useComposedRefs(t,Q=>E(Q)),I=React__namespace.useRef(!1),A=C?S||!!C.closest("form"):!0,[V,q]=useControllableState({prop:l,defaultProp:d??!1,onChange:_,caller:CHECKBOX_NAME}),z=React__namespace.useRef(V);return React__namespace.useEffect(()=>{const Q=C==null?void 0:C.form;if(Q){const F=()=>q(z.current);return Q.addEventListener("reset",F),()=>Q.removeEventListener("reset",F)}},[C,q]),jsxRuntime.jsxs(CheckboxProvider,{scope:n,state:V,disabled:g,children:[jsxRuntime.jsx(Primitive.button,{type:"button",role:"checkbox","aria-checked":isIndeterminate(V)?"mixed":V,"aria-required":f,"data-state":getState$1(V),"data-disabled":g?"":void 0,disabled:g,value:b,...R,ref:M,onKeyDown:composeEventHandlers(e.onKeyDown,Q=>{Q.key==="Enter"&&Q.preventDefault()}),onClick:composeEventHandlers(e.onClick,Q=>{q(F=>isIndeterminate(F)?!0:!F),A&&(I.current=Q.isPropagationStopped(),I.current||Q.stopPropagation())})}),A&&jsxRuntime.jsx(CheckboxBubbleInput,{control:C,bubbles:!I.current,name:o,value:b,checked:V,required:f,disabled:g,form:S,style:{transform:"translateX(-100%)"},defaultChecked:isIndeterminate(d)?!1:d})]})});Checkbox$1.displayName=CHECKBOX_NAME;var INDICATOR_NAME="CheckboxIndicator",CheckboxIndicator=React__namespace.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:o,...l}=e,d=useCheckboxContext(INDICATOR_NAME,n);return jsxRuntime.jsx(Presence,{present:o||isIndeterminate(d.state)||d.state===!0,children:jsxRuntime.jsx(Primitive.span,{"data-state":getState$1(d.state),"data-disabled":d.disabled?"":void 0,...l,ref:t,style:{pointerEvents:"none",...e.style}})})});CheckboxIndicator.displayName=INDICATOR_NAME;var BUBBLE_INPUT_NAME$1="CheckboxBubbleInput",CheckboxBubbleInput=React__namespace.forwardRef(({__scopeCheckbox:e,control:t,checked:n,bubbles:o=!0,defaultChecked:l,...d},f)=>{const g=React__namespace.useRef(null),b=useComposedRefs(g,f),_=usePrevious(n),S=useSize(t);React__namespace.useEffect(()=>{const C=g.current;if(!C)return;const E=window.HTMLInputElement.prototype,I=Object.getOwnPropertyDescriptor(E,"checked").set;if(_!==n&&I){const A=new Event("click",{bubbles:o});C.indeterminate=isIndeterminate(n),I.call(C,isIndeterminate(n)?!1:n),C.dispatchEvent(A)}},[_,n,o]);const R=React__namespace.useRef(isIndeterminate(n)?!1:n);return jsxRuntime.jsx(Primitive.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??R.current,...d,tabIndex:-1,ref:b,style:{...d.style,...S,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});CheckboxBubbleInput.displayName=BUBBLE_INPUT_NAME$1;function isIndeterminate(e){return e==="indeterminate"}function getState$1(e){return isIndeterminate(e)?"indeterminate":e?"checked":"unchecked"}var Root=Checkbox$1,Indicator=CheckboxIndicator;const Checkbox=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Root,{ref:n,className:cn("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:jsxRuntime.jsx(Indicator,{className:cn("flex items-center justify-center text-current"),children:jsxRuntime.jsx(Check,{className:"h-4 w-4"})})}));Checkbox.displayName=Root.displayName;var U=1,Y$1=.9,H=.8,J=.17,p=.1,u=.999,$=.9999,k$1=.99,m=/[\\\/_+.#"@\[\(\{&]/,B$1=/[\\\/_+.#"@\[\(\{&]/g,K$1=/[\s-]/,X=/[\s-]/g;function G(e,t,n,o,l,d,f){if(d===t.length)return l===e.length?U:k$1;var g=`${l},${d}`;if(f[g]!==void 0)return f[g];for(var b=o.charAt(d),_=n.indexOf(b,l),S=0,R,C,E,M;_>=0;)R=G(e,t,n,o,_+1,d+1,f),R>S&&(_===l?R*=U:m.test(e.charAt(_-1))?(R*=H,E=e.slice(l,_-1).match(B$1),E&&l>0&&(R*=Math.pow(u,E.length))):K$1.test(e.charAt(_-1))?(R*=Y$1,M=e.slice(l,_-1).match(X),M&&l>0&&(R*=Math.pow(u,M.length))):(R*=J,l>0&&(R*=Math.pow(u,_-l))),e.charAt(_)!==t.charAt(d)&&(R*=$)),(R<p&&n.charAt(_-1)===o.charAt(d+1)||o.charAt(d+1)===o.charAt(d)&&n.charAt(_-1)!==o.charAt(d))&&(C=G(e,t,n,o,_+1,d+2,f),C*p>R&&(R=C*p)),R>S&&(S=R),_=n.indexOf(b,_+1);return f[g]=S,S}function D(e){return e.toLowerCase().replace(X," ")}function W(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,G(e,t,D(e),D(t),0,0,{})}var N='[cmdk-group=""]',Y='[cmdk-group-items=""]',be='[cmdk-group-heading=""]',le='[cmdk-item=""]',ce=`${le}:not([aria-disabled="true"])`,Z="cmdk-item-select",T="data-value",Re=(e,t,n)=>W(e,t,n),ue=React__namespace.createContext(void 0),K=()=>React__namespace.useContext(ue),de=React__namespace.createContext(void 0),ee=()=>React__namespace.useContext(de),fe=React__namespace.createContext(void 0),me=React__namespace.forwardRef((e,t)=>{let n=L(()=>{var Ue,Xe;return{search:"",value:(Xe=(Ue=e.value)!=null?Ue:e.defaultValue)!=null?Xe:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),o=L(()=>new Set),l=L(()=>new Map),d=L(()=>new Map),f=L(()=>new Set),g=pe(e),{label:b,children:_,value:S,onValueChange:R,filter:C,shouldFilter:E,loop:M,disablePointerSelection:I=!1,vimBindings:A=!0,...V}=e,q=useId(),z=useId(),Q=useId(),F=React__namespace.useRef(null),O=ke();k(()=>{if(S!==void 0){let Ue=S.trim();n.current.value=Ue,te.emit()}},[S]),k(()=>{O(6,Ne)},[]);let te=React__namespace.useMemo(()=>({subscribe:Ue=>(f.current.add(Ue),()=>f.current.delete(Ue)),snapshot:()=>n.current,setState:(Ue,Xe,Je)=>{var Ye,it,Ke,et;if(!Object.is(n.current[Ue],Xe)){if(n.current[Ue]=Xe,Ue==="search")Ae(),oe(),O(1,se);else if(Ue==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Ze=document.getElementById(Q);Ze?Ze.focus():(Ye=document.getElementById(q))==null||Ye.focus()}if(O(7,()=>{var Ze;n.current.selectedItemId=(Ze=ge())==null?void 0:Ze.id,te.emit()}),Je||O(5,Ne),((it=g.current)==null?void 0:it.value)!==void 0){let Ze=Xe??"";(et=(Ke=g.current).onValueChange)==null||et.call(Ke,Ze);return}}te.emit()}},emit:()=>{f.current.forEach(Ue=>Ue())}}),[]),ae=React__namespace.useMemo(()=>({value:(Ue,Xe,Je)=>{var Ye;Xe!==((Ye=d.current.get(Ue))==null?void 0:Ye.value)&&(d.current.set(Ue,{value:Xe,keywords:Je}),n.current.filtered.items.set(Ue,ie(Xe,Je)),O(2,()=>{oe(),te.emit()}))},item:(Ue,Xe)=>(o.current.add(Ue),Xe&&(l.current.has(Xe)?l.current.get(Xe).add(Ue):l.current.set(Xe,new Set([Ue]))),O(3,()=>{Ae(),oe(),n.current.value||se(),te.emit()}),()=>{d.current.delete(Ue),o.current.delete(Ue),n.current.filtered.items.delete(Ue);let Je=ge();O(4,()=>{Ae(),(Je==null?void 0:Je.getAttribute("id"))===Ue&&se(),te.emit()})}),group:Ue=>(l.current.has(Ue)||l.current.set(Ue,new Set),()=>{d.current.delete(Ue),l.current.delete(Ue)}),filter:()=>g.current.shouldFilter,label:b||e["aria-label"],getDisablePointerSelection:()=>g.current.disablePointerSelection,listId:q,inputId:Q,labelId:z,listInnerRef:F}),[]);function ie(Ue,Xe){var Je,Ye;let it=(Ye=(Je=g.current)==null?void 0:Je.filter)!=null?Ye:Re;return Ue?it(Ue,n.current.search,Xe):0}function oe(){if(!n.current.search||g.current.shouldFilter===!1)return;let Ue=n.current.filtered.items,Xe=[];n.current.filtered.groups.forEach(Ye=>{let it=l.current.get(Ye),Ke=0;it.forEach(et=>{let Ze=Ue.get(et);Ke=Math.max(Ze,Ke)}),Xe.push([Ye,Ke])});let Je=F.current;Oe().sort((Ye,it)=>{var Ke,et;let Ze=Ye.getAttribute("id"),tt=it.getAttribute("id");return((Ke=Ue.get(tt))!=null?Ke:0)-((et=Ue.get(Ze))!=null?et:0)}).forEach(Ye=>{let it=Ye.closest(Y);it?it.appendChild(Ye.parentElement===it?Ye:Ye.closest(`${Y} > *`)):Je.appendChild(Ye.parentElement===Je?Ye:Ye.closest(`${Y} > *`))}),Xe.sort((Ye,it)=>it[1]-Ye[1]).forEach(Ye=>{var it;let Ke=(it=F.current)==null?void 0:it.querySelector(`${N}[${T}="${encodeURIComponent(Ye[0])}"]`);Ke==null||Ke.parentElement.appendChild(Ke)})}function se(){let Ue=Oe().find(Je=>Je.getAttribute("aria-disabled")!=="true"),Xe=Ue==null?void 0:Ue.getAttribute(T);te.setState("value",Xe||void 0)}function Ae(){var Ue,Xe,Je,Ye;if(!n.current.search||g.current.shouldFilter===!1){n.current.filtered.count=o.current.size;return}n.current.filtered.groups=new Set;let it=0;for(let Ke of o.current){let et=(Xe=(Ue=d.current.get(Ke))==null?void 0:Ue.value)!=null?Xe:"",Ze=(Ye=(Je=d.current.get(Ke))==null?void 0:Je.keywords)!=null?Ye:[],tt=ie(et,Ze);n.current.filtered.items.set(Ke,tt),tt>0&&it++}for(let[Ke,et]of l.current)for(let Ze of et)if(n.current.filtered.items.get(Ze)>0){n.current.filtered.groups.add(Ke);break}n.current.filtered.count=it}function Ne(){var Ue,Xe,Je;let Ye=ge();Ye&&(((Ue=Ye.parentElement)==null?void 0:Ue.firstChild)===Ye&&((Je=(Xe=Ye.closest(N))==null?void 0:Xe.querySelector(be))==null||Je.scrollIntoView({block:"nearest"})),Ye.scrollIntoView({block:"nearest"}))}function ge(){var Ue;return(Ue=F.current)==null?void 0:Ue.querySelector(`${le}[aria-selected="true"]`)}function Oe(){var Ue;return Array.from(((Ue=F.current)==null?void 0:Ue.querySelectorAll(ce))||[])}function Le(Ue){let Xe=Oe()[Ue];Xe&&te.setState("value",Xe.getAttribute(T))}function Ge(Ue){var Xe;let Je=ge(),Ye=Oe(),it=Ye.findIndex(et=>et===Je),Ke=Ye[it+Ue];(Xe=g.current)!=null&&Xe.loop&&(Ke=it+Ue<0?Ye[Ye.length-1]:it+Ue===Ye.length?Ye[0]:Ye[it+Ue]),Ke&&te.setState("value",Ke.getAttribute(T))}function je(Ue){let Xe=ge(),Je=Xe==null?void 0:Xe.closest(N),Ye;for(;Je&&!Ye;)Je=Ue>0?we(Je,N):De(Je,N),Ye=Je==null?void 0:Je.querySelector(ce);Ye?te.setState("value",Ye.getAttribute(T)):Ge(Ue)}let Be=()=>Le(Oe().length-1),qe=Ue=>{Ue.preventDefault(),Ue.metaKey?Be():Ue.altKey?je(1):Ge(1)},ze=Ue=>{Ue.preventDefault(),Ue.metaKey?Le(0):Ue.altKey?je(-1):Ge(-1)};return React__namespace.createElement(Primitive.div,{ref:t,tabIndex:-1,...V,"cmdk-root":"",onKeyDown:Ue=>{var Xe;(Xe=V.onKeyDown)==null||Xe.call(V,Ue);let Je=Ue.nativeEvent.isComposing||Ue.keyCode===229;if(!(Ue.defaultPrevented||Je))switch(Ue.key){case"n":case"j":{A&&Ue.ctrlKey&&qe(Ue);break}case"ArrowDown":{qe(Ue);break}case"p":case"k":{A&&Ue.ctrlKey&&ze(Ue);break}case"ArrowUp":{ze(Ue);break}case"Home":{Ue.preventDefault(),Le(0);break}case"End":{Ue.preventDefault(),Be();break}case"Enter":{Ue.preventDefault();let Ye=ge();if(Ye){let it=new Event(Z);Ye.dispatchEvent(it)}}}}},React__namespace.createElement("label",{"cmdk-label":"",htmlFor:ae.inputId,id:ae.labelId,style:Te},b),B(e,Ue=>React__namespace.createElement(de.Provider,{value:te},React__namespace.createElement(ue.Provider,{value:ae},Ue))))}),he=React__namespace.forwardRef((e,t)=>{var n,o;let l=useId(),d=React__namespace.useRef(null),f=React__namespace.useContext(fe),g=K(),b=pe(e),_=(o=(n=b.current)==null?void 0:n.forceMount)!=null?o:f==null?void 0:f.forceMount;k(()=>{if(!_)return g.item(l,f==null?void 0:f.id)},[_]);let S=ve(l,d,[e.value,e.children,d],e.keywords),R=ee(),C=P(O=>O.value&&O.value===S.current),E=P(O=>_||g.filter()===!1?!0:O.search?O.filtered.items.get(l)>0:!0);React__namespace.useEffect(()=>{let O=d.current;if(!(!O||e.disabled))return O.addEventListener(Z,M),()=>O.removeEventListener(Z,M)},[E,e.onSelect,e.disabled]);function M(){var O,te;I(),(te=(O=b.current).onSelect)==null||te.call(O,S.current)}function I(){R.setState("value",S.current,!0)}if(!E)return null;let{disabled:A,value:V,onSelect:q,forceMount:z,keywords:Q,...F}=e;return React__namespace.createElement(Primitive.div,{ref:composeRefs(d,t),...F,id:l,"cmdk-item":"",role:"option","aria-disabled":!!A,"aria-selected":!!C,"data-disabled":!!A,"data-selected":!!C,onPointerMove:A||g.getDisablePointerSelection()?void 0:I,onClick:A?void 0:M},e.children)}),Ee=React__namespace.forwardRef((e,t)=>{let{heading:n,children:o,forceMount:l,...d}=e,f=useId(),g=React__namespace.useRef(null),b=React__namespace.useRef(null),_=useId(),S=K(),R=P(E=>l||S.filter()===!1?!0:E.search?E.filtered.groups.has(f):!0);k(()=>S.group(f),[]),ve(f,g,[e.value,e.heading,b]);let C=React__namespace.useMemo(()=>({id:f,forceMount:l}),[l]);return React__namespace.createElement(Primitive.div,{ref:composeRefs(g,t),...d,"cmdk-group":"",role:"presentation",hidden:R?void 0:!0},n&&React__namespace.createElement("div",{ref:b,"cmdk-group-heading":"","aria-hidden":!0,id:_},n),B(e,E=>React__namespace.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?_:void 0},React__namespace.createElement(fe.Provider,{value:C},E))))}),ye=React__namespace.forwardRef((e,t)=>{let{alwaysRender:n,...o}=e,l=React__namespace.useRef(null),d=P(f=>!f.search);return!n&&!d?null:React__namespace.createElement(Primitive.div,{ref:composeRefs(l,t),...o,"cmdk-separator":"",role:"separator"})}),Se=React__namespace.forwardRef((e,t)=>{let{onValueChange:n,...o}=e,l=e.value!=null,d=ee(),f=P(_=>_.search),g=P(_=>_.selectedItemId),b=K();return React__namespace.useEffect(()=>{e.value!=null&&d.setState("search",e.value)},[e.value]),React__namespace.createElement(Primitive.input,{ref:t,...o,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":b.listId,"aria-labelledby":b.labelId,"aria-activedescendant":g,id:b.inputId,type:"text",value:l?e.value:f,onChange:_=>{l||d.setState("search",_.target.value),n==null||n(_.target.value)}})}),Ce=React__namespace.forwardRef((e,t)=>{let{children:n,label:o="Suggestions",...l}=e,d=React__namespace.useRef(null),f=React__namespace.useRef(null),g=P(_=>_.selectedItemId),b=K();return React__namespace.useEffect(()=>{if(f.current&&d.current){let _=f.current,S=d.current,R,C=new ResizeObserver(()=>{R=requestAnimationFrame(()=>{let E=_.offsetHeight;S.style.setProperty("--cmdk-list-height",E.toFixed(1)+"px")})});return C.observe(_),()=>{cancelAnimationFrame(R),C.unobserve(_)}}},[]),React__namespace.createElement(Primitive.div,{ref:composeRefs(d,t),...l,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":g,"aria-label":o,id:b.listId},B(e,_=>React__namespace.createElement("div",{ref:composeRefs(f,b.listInnerRef),"cmdk-list-sizer":""},_)))}),xe=React__namespace.forwardRef((e,t)=>{let{open:n,onOpenChange:o,overlayClassName:l,contentClassName:d,container:f,...g}=e;return React__namespace.createElement(Root$9,{open:n,onOpenChange:o},React__namespace.createElement(Portal$4,{container:f},React__namespace.createElement(Overlay,{"cmdk-overlay":"",className:l}),React__namespace.createElement(Content$2,{"aria-label":e.label,"cmdk-dialog":"",className:d},React__namespace.createElement(me,{ref:t,...g}))))}),Ie=React__namespace.forwardRef((e,t)=>P(n=>n.filtered.count===0)?React__namespace.createElement(Primitive.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Pe=React__namespace.forwardRef((e,t)=>{let{progress:n,children:o,label:l="Loading...",...d}=e;return React__namespace.createElement(Primitive.div,{ref:t,...d,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":l},B(e,f=>React__namespace.createElement("div",{"aria-hidden":!0},f)))}),_e=Object.assign(me,{List:Ce,Item:he,Input:Se,Group:Ee,Separator:ye,Dialog:xe,Empty:Ie,Loading:Pe});function we(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function De(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function pe(e){let t=React__namespace.useRef(e);return k(()=>{t.current=e}),t}var k=typeof window>"u"?React__namespace.useEffect:React__namespace.useLayoutEffect;function L(e){let t=React__namespace.useRef();return t.current===void 0&&(t.current=e()),t}function P(e){let t=ee(),n=()=>e(t.snapshot());return React__namespace.useSyncExternalStore(t.subscribe,n,n)}function ve(e,t,n,o=[]){let l=React__namespace.useRef(),d=K();return k(()=>{var f;let g=(()=>{var _;for(let S of n){if(typeof S=="string")return S.trim();if(typeof S=="object"&&"current"in S)return S.current?(_=S.current.textContent)==null?void 0:_.trim():l.current}})(),b=o.map(_=>_.trim());d.value(e,g,b),(f=t.current)==null||f.setAttribute(T,g),l.current=g}),l}var ke=()=>{let[e,t]=React__namespace.useState(),n=L(()=>new Map);return k(()=>{n.current.forEach(o=>o()),n.current=new Map},[e]),(o,l)=>{n.current.set(o,l),t({})}};function Me(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function B({asChild:e,children:t},n){return e&&React__namespace.isValidElement(t)?React__namespace.cloneElement(Me(t),{ref:t.ref},n(t.props.children)):n(t)}var Te={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Command=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(_e,{ref:n,className:cn("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Command.displayName=_e.displayName;const CommandDialog=({children:e,...t})=>jsxRuntime.jsx(Dialog,{...t,children:jsxRuntime.jsx(DialogContent,{className:"overflow-hidden p-0",children:jsxRuntime.jsx(Command,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:e})})}),CommandInput=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[jsxRuntime.jsx(Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),jsxRuntime.jsx(_e.Input,{ref:n,className:cn("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));CommandInput.displayName=_e.Input.displayName;const CommandList=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(_e.List,{ref:n,className:cn("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));CommandList.displayName=_e.List.displayName;const CommandEmpty=React__namespace.forwardRef((e,t)=>jsxRuntime.jsx(_e.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));CommandEmpty.displayName=_e.Empty.displayName;const CommandGroup=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(_e.Group,{ref:n,className:cn("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));CommandGroup.displayName=_e.Group.displayName;const CommandSeparator=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(_e.Separator,{ref:n,className:cn("-mx-1 h-px bg-border",e),...t}));CommandSeparator.displayName=_e.Separator.displayName;const CommandItem=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(_e.Item,{ref:n,className:cn("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",e),...t}));CommandItem.displayName=_e.Item.displayName;const CommandShortcut=({className:e,...t})=>jsxRuntime.jsx("span",{className:cn("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});CommandShortcut.displayName="CommandShortcut";function GeneralDocumentCard({document:e,loading:t=!1}){return t?jsxRuntime.jsx("div",{children:"loading..."}):jsxRuntime.jsxs("div",{children:["GENERAL DOCUMENT CARD - ",e==null?void 0:e.OrderNumber," for P.O. ",e==null?void 0:e.PONumber]})}const Navbar=React.forwardRef(({routes:e,footer:t,dashboardTitle:n,withRandmarAssistant:o,chatUserName:l,chatApiKey:d},f)=>{const{appID:g}=reactRouterDom.useParams(),b=e.filter(C=>C.showInNav),_=React.useRef(null),S=React.useRef(null),R=React.useRef(null);return React.useImperativeHandle(f,()=>({setActiveChatAndSendMessage:(C,E)=>{var M;return(M=R.current)==null||M.click(),setTimeout(()=>{var I;(I=_.current)==null||I.focus(),S.current&&S.current.setActiveChatAndSendMessage(C,E)},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:b.map(C=>{const E=C.icon,M=`/${C.path.replace(":appID",g??"")}`;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:[E&&jsxRuntime.jsx(E,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:C.label})]})})},C.key)})})}),jsxRuntime.jsxs(SidebarFooter,{className:"border-t border-sidebar-border p-4 bg-sidebar-background text-sidebar-foreground",children:[o===!0&&jsxRuntime.jsxs(Dialog,{children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{ref:R,size:"lg",className:"collapse md:visible",onClick:()=>setTimeout(()=>{var C;return(C=_.current)==null?void 0:C.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:S,inputRef:_,userId:g??"2",userName:l??"Unknown user",apiKey:d??""})})]}),t]})]})}),Layout=React.forwardRef(({children:e,rightMenu:t,routes:n,footer:o,handleValidSearch:l,dashboardTitle:d,onSignOut:f,searchPlaceholder:g,withRandmarAssistant:b,chatUserName:_,chatApiKey:S,chatRef:R},C)=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(SidebarProvider,{children:jsxRuntime.jsxs("div",{className:"flex grow",children:[jsxRuntime.jsx(Navbar,{routes:n,footer:o,dashboardTitle:d,withRandmarAssistant:b,chatUserName:_,chatApiKey:S,ref:R}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[jsxRuntime.jsx(Topbar,{ref:C,onSignOut:f,rightMenu:t,handleValidSearch:l,searchPlaceholder:g}),jsxRuntime.jsx("main",{className:"flex-1 overflow-auto mt-16",children:e}),jsxRuntime.jsx(Toaster,{})]})]})})}));Layout.displayName="Layout";const salesChannels=[{id:"online-store",label:"Online store (Shopify, Amazon, etc.)"},{id:"brick-and-mortar",label:"Brick-and-mortar (Physical Store)"},{id:"marketplace",label:"Marketplace seller (eBay, Walmart, etc.)"},{id:"b2b",label:"B2B wholesale"},{id:"other-channel",label:"Other (please specify)"}],markets=[{id:"canada",label:"Canada - Nationwide"},{id:"ontario",label:"Ontario & Quebec"},{id:"atlantic",label:"Atlantic Provinces (NS, NB, PEI, NL)"},{id:"prairie",label:"Prairie (Saskatchewan, Manitoba)"},{id:"western",label:"Western Provinces (BC, Alberta, etc.)"},{id:"united-states",label:"United States"},{id:"other-market",label:"Other (please specify)"}];function ManufacturerGetStartedButton({applicationId:e,manufacturer:t}){const{toast:n}=useToast(),[o,l]=React.useState(!1),[d,f]=React.useState(!1),[g,b]=React.useState(!1),[_,S]=React.useState(""),[R,C]=React.useState(""),[E,M]=React.useState(!1),[I,A]=React.useState(""),[V,q]=React.useState(""),[z,Q]=React.useState([]),[F,O]=React.useState(""),[te,ae]=React.useState(""),[ie,oe]=React.useState([]),[se,Ae]=React.useState(""),[Ne,ge]=React.useState(""),[Oe]=usePutV4ResellerByRouteResellerIdCommunicationMutation(),[Le]=usePostV4PartnerByApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation(),{sendMessage:Ge}=useChat(),je=()=>{S(""),C("")},Be=()=>{A(""),q(""),Q([]),O(""),ae(""),oe([]),Ae(""),ge("")},qe=()=>{t.PartnerRegistrationLink?l(!0):t.OpenToWork&&f(!0)},ze=Ke=>{if(Ke.preventDefault(),!g){if(!_.trim()){C("Qualification ID is required");return}b(!0),Oe({routeResellerId:e,body:JSON.stringify({ManufactuerId:t.ManufacturerId??"",Message:`Qualification Id: ${_}`,Subject:"Qualification"})}).then(et=>{if(et.error){console.error(et.error),n({title:"Error",description:"Error submitting your qualification.",variant:"destructive"});return}n({title:"Success",description:"Qualification successfully submitted.",variant:"success"}),l(!1),je()}).catch(et=>{console.error(et),n({title:"Error",description:"Error submitting your qualification.",variant:"destructive"})}).finally(()=>{b(!1)})}},Ue=Ke=>{if(Ke.preventDefault(),E)return;q(""),O(""),Ae("");let et=!1;if(I.trim().length<10&&(q("Please provide a brief description of your business (minimum 10 characters)"),et=!0),z.length===0&&(O("Please select at least one sales channel"),et=!0),ie.length===0&&(Ae("Please select at least one market"),et=!0),et)return;const Ze=salesChannels.filter(Fe=>z.includes(Fe.id)).map(Fe=>Fe.label);te&&Ze.push(`Other: ${te}`);const tt=markets.filter(Fe=>ie.includes(Fe.id)).map(Fe=>Fe.label);Ne&&tt.push(`Other: ${Ne}`);const st=["Hello! I'd like to introduce my business:",`Business Description: ${I}`,`Sales Channels: ${Ze.join(", ")}`,`Markets: ${tt.join(", ")}`].join(`
968
968
 
969
- `);M(!0),Le({applicationId:e,partnerId:"2",message:st}).then(Fe=>{var Qe;if(Fe.error){console.error(Fe.error),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"});return}const ct=(Qe=Fe.data)==null?void 0:Qe.ConversationId;ct&&Ge(ct)?(f(!1),Be()):n({title:"Could not send message",description:"Try again later.",variant:"destructive"})}).catch(Fe=>{console.error(Fe),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"})}).finally(()=>{M(!1)})},Xe=(Ke,et)=>{Q(Ze=>et?[...Ze,Ke]:Ze.filter(tt=>tt!==Ke)),O("")},Je=(Ke,et)=>{oe(Ze=>et?[...Ze,Ke]:Ze.filter(tt=>tt!==Ke)),Ae("")},Ye=z.includes("other-channel"),it=ie.includes("other-market");return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[!t.Qualification&&jsxRuntime.jsxs(Button,{onClick:qe,disabled:!t.PartnerRegistrationLink&&!t.OpenToWork,children:[jsxRuntime.jsx(Check,{className:"mr-2 h-4 w-4"}),"Get Started"]}),t.PartnerRegistrationLink&&jsxRuntime.jsx(Dialog,{open:o,onOpenChange:Ke=>{l(Ke)},children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[400px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:t.PublicName}),jsxRuntime.jsxs(DialogDescription,{children:[jsxRuntime.jsx("span",{className:"font-bold",children:"Already qualified?"})," Provide your Qualification ID."]})]}),jsxRuntime.jsxs("form",{onSubmit:ze,className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"qualificationId",children:"Qualification ID"}),jsxRuntime.jsx(Input,{id:"qualificationId",placeholder:"Enter your qualification ID",value:_,onChange:Ke=>{S(Ke.target.value),C("")}}),R&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:R})]}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button,{type:"submit",className:"w-full",disabled:g,children:g?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Applying..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Check,{className:"mr-2 h-4 w-4"}),"Apply for Qualification"]})})})]}),jsxRuntime.jsx(Separator$1,{className:"my-4"}),jsxRuntime.jsxs("div",{className:"text-center space-y-2",children:[jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Don't have a qualification ID?"}),jsxRuntime.jsx("a",{href:t.PartnerRegistrationLink,target:"_blank",rel:"noopener noreferrer",children:jsxRuntime.jsxs(Button,{variant:"outline",className:"w-full",disabled:!t.PartnerRegistrationLink,children:[jsxRuntime.jsx(ExternalLink,{className:"mr-2 h-4 w-4"}),"Register here"]})})]})]})}),jsxRuntime.jsx(Dialog,{open:d,onOpenChange:Ke=>{f(Ke)},children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[768px]",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Introduce Yourself"})}),jsxRuntime.jsxs("form",{onSubmit:Ue,className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs(Label$2,{htmlFor:"businessDescription",children:["Tell Us About Your Business ",jsxRuntime.jsx("span",{className:"text-sm text-muted-foreground",children:"(Briefly describe your business)"})]}),jsxRuntime.jsx(Textarea,{id:"businessDescription",placeholder:"We are an online retailer specializing in office supplies, serving businesses since 2018...",className:"min-h-[100px]",value:I,onChange:Ke=>{A(Ke.target.value),q("")}}),V&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:V})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs(Label$2,{children:["Sales Channel(s) ",jsxRuntime.jsx("span",{className:"text-sm text-muted-foreground",children:"(Multi-Select where you currently sell your products)"})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-2 gap-2",children:salesChannels.map(Ke=>jsxRuntime.jsxs("div",{className:"flex items-start space-x-2",children:[jsxRuntime.jsx(Checkbox,{id:`channel-${Ke.id}`,checked:z.includes(Ke.id),onCheckedChange:et=>Xe(Ke.id,et===!0)}),jsxRuntime.jsx(Label$2,{htmlFor:`channel-${Ke.id}`,className:"text-sm font-normal",children:Ke.label})]},Ke.id))}),Ye&&jsxRuntime.jsx(Input,{placeholder:"Please specify",value:te,onChange:Ke=>ae(Ke.target.value)}),F&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:F})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs(Label$2,{children:["Your Primary Market(s) ",jsxRuntime.jsx("span",{className:"text-sm text-muted-foreground",children:"(Multi-Select which regions you sell to)"})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-2 gap-2",children:markets.map(Ke=>jsxRuntime.jsxs("div",{className:"flex items-start space-x-2",children:[jsxRuntime.jsx(Checkbox,{id:`market-${Ke.id}`,checked:ie.includes(Ke.id),onCheckedChange:et=>Je(Ke.id,et===!0)}),jsxRuntime.jsx(Label$2,{htmlFor:`market-${Ke.id}`,className:"text-sm font-normal",children:Ke.label})]},Ke.id))}),it&&jsxRuntime.jsx(Input,{placeholder:"Please specify",value:Ne,onChange:Ke=>ge(Ke.target.value)}),se&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:se})]}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button,{type:"submit",disabled:E,children:E?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Submitting..."]}):"Submit"})})]})]})})]})}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$1=createPopperScope(),[SelectProvider,useSelectContext]=createSelectContext(SELECT_NAME),[SelectNativeOptionsProvider,useSelectNativeOptionsContext]=createSelectContext(SELECT_NAME),Select$1=e=>{const{__scopeSelect:t,children:n,open:o,defaultOpen:l,onOpenChange:d,value:f,defaultValue:g,onValueChange:b,dir:_,name:S,autoComplete:R,disabled:C,required:E,form:M}=e,I=usePopperScope$1(t),[A,V]=React__namespace.useState(null),[q,z]=React__namespace.useState(null),[Q,F]=React__namespace.useState(!1),O=useDirection(_),[te,ae]=useControllableState({prop:o,defaultProp:l??!1,onChange:d,caller:SELECT_NAME}),[ie,oe]=useControllableState({prop:f,defaultProp:g,onChange:b,caller:SELECT_NAME}),se=React__namespace.useRef(null),Ae=A?M||!!A.closest("form"):!0,[Ne,ge]=React__namespace.useState(new Set),Oe=Array.from(Ne).map(Le=>Le.props.value).join(";");return jsxRuntime.jsx(Root2$5,{...I,children:jsxRuntime.jsxs(SelectProvider,{required:E,scope:t,trigger:A,onTriggerChange:V,valueNode:q,onValueNodeChange:z,valueNodeHasChildren:Q,onValueNodeHasChildrenChange:F,contentId:useId(),value:ie,onValueChange:oe,open:te,onOpenChange:ae,dir:O,triggerPointerDownPosRef:se,disabled:C,children:[jsxRuntime.jsx(Collection.Provider,{scope:t,children:jsxRuntime.jsx(SelectNativeOptionsProvider,{scope:e.__scopeSelect,onNativeOptionAdd:React__namespace.useCallback(Le=>{ge(Ge=>new Set(Ge).add(Le))},[]),onNativeOptionRemove:React__namespace.useCallback(Le=>{ge(Ge=>{const je=new Set(Ge);return je.delete(Le),je})},[]),children:n})}),Ae?jsxRuntime.jsxs(SelectBubbleInput,{"aria-hidden":!0,required:E,tabIndex:-1,name:S,autoComplete:R,value:ie,onChange:Le=>oe(Le.target.value),disabled:C,form:M,children:[ie===void 0?jsxRuntime.jsx("option",{value:""}):null,Array.from(Ne)]},Oe):null]})})};Select$1.displayName=SELECT_NAME;var TRIGGER_NAME$1="SelectTrigger",SelectTrigger$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:o=!1,...l}=e,d=usePopperScope$1(n),f=useSelectContext(TRIGGER_NAME$1,n),g=f.disabled||o,b=useComposedRefs(t,f.onTriggerChange),_=useCollection(n),S=React__namespace.useRef("touch"),[R,C,E]=useTypeaheadSearch(I=>{const A=_().filter(z=>!z.disabled),V=A.find(z=>z.value===f.value),q=findNextItem(A,I,V);q!==void 0&&f.onValueChange(q.value)}),M=I=>{g||(f.onOpenChange(!0),E()),I&&(f.triggerPointerDownPosRef.current={x:Math.round(I.pageX),y:Math.round(I.pageY)})};return jsxRuntime.jsx(Anchor,{asChild:!0,...d,children:jsxRuntime.jsx(Primitive.button,{type:"button",role:"combobox","aria-controls":f.contentId,"aria-expanded":f.open,"aria-required":f.required,"aria-autocomplete":"none",dir:f.dir,"data-state":f.open?"open":"closed",disabled:g,"data-disabled":g?"":void 0,"data-placeholder":shouldShowPlaceholder(f.value)?"":void 0,...l,ref:b,onClick:composeEventHandlers(l.onClick,I=>{I.currentTarget.focus(),S.current!=="mouse"&&M(I)}),onPointerDown:composeEventHandlers(l.onPointerDown,I=>{S.current=I.pointerType;const A=I.target;A.hasPointerCapture(I.pointerId)&&A.releasePointerCapture(I.pointerId),I.button===0&&I.ctrlKey===!1&&I.pointerType==="mouse"&&(M(I),I.preventDefault())}),onKeyDown:composeEventHandlers(l.onKeyDown,I=>{const A=R.current!=="";!(I.ctrlKey||I.altKey||I.metaKey)&&I.key.length===1&&C(I.key),!(A&&I.key===" ")&&OPEN_KEYS.includes(I.key)&&(M(),I.preventDefault())})})})});SelectTrigger$1.displayName=TRIGGER_NAME$1;var VALUE_NAME="SelectValue",SelectValue$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,className:o,style:l,children:d,placeholder:f="",...g}=e,b=useSelectContext(VALUE_NAME,n),{onValueNodeHasChildrenChange:_}=b,S=d!==void 0,R=useComposedRefs(t,b.onValueNodeChange);return useLayoutEffect2(()=>{_(S)},[_,S]),jsxRuntime.jsx(Primitive.span,{...g,ref:R,style:{pointerEvents:"none"},children:shouldShowPlaceholder(b.value)?jsxRuntime.jsx(jsxRuntime.Fragment,{children:f}):d})});SelectValue$1.displayName=VALUE_NAME;var ICON_NAME="SelectIcon",SelectIcon=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,children:o,...l}=e;return jsxRuntime.jsx(Primitive.span,{"aria-hidden":!0,...l,ref:t,children:o||"▼"})});SelectIcon.displayName=ICON_NAME;var PORTAL_NAME$1="SelectPortal",SelectPortal=e=>jsxRuntime.jsx(Portal$5,{asChild:!0,...e});SelectPortal.displayName=PORTAL_NAME$1;var CONTENT_NAME$1="SelectContent",SelectContent$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContext(CONTENT_NAME$1,e.__scopeSelect),[o,l]=React__namespace.useState();if(useLayoutEffect2(()=>{l(new DocumentFragment)},[]),!n.open){const d=o;return d?ReactDOM__namespace.createPortal(jsxRuntime.jsx(SelectContentProvider,{scope:e.__scopeSelect,children:jsxRuntime.jsx(Collection.Slot,{scope:e.__scopeSelect,children:jsxRuntime.jsx("div",{children:e.children})})}),d):null}return jsxRuntime.jsx(SelectContentImpl,{...e,ref:t})});SelectContent$1.displayName=CONTENT_NAME$1;var CONTENT_MARGIN=10,[SelectContentProvider,useSelectContentContext]=createSelectContext(CONTENT_NAME$1),CONTENT_IMPL_NAME="SelectContentImpl",Slot$1=createSlot("SelectContent.RemoveScroll"),SelectContentImpl=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,position:o="item-aligned",onCloseAutoFocus:l,onEscapeKeyDown:d,onPointerDownOutside:f,side:g,sideOffset:b,align:_,alignOffset:S,arrowPadding:R,collisionBoundary:C,collisionPadding:E,sticky:M,hideWhenDetached:I,avoidCollisions:A,...V}=e,q=useSelectContext(CONTENT_NAME$1,n),[z,Q]=React__namespace.useState(null),[F,O]=React__namespace.useState(null),te=useComposedRefs(t,Ke=>Q(Ke)),[ae,ie]=React__namespace.useState(null),[oe,se]=React__namespace.useState(null),Ae=useCollection(n),[Ne,ge]=React__namespace.useState(!1),Oe=React__namespace.useRef(!1);React__namespace.useEffect(()=>{if(z)return hideOthers(z)},[z]),useFocusGuards();const Le=React__namespace.useCallback(Ke=>{const[et,...Ze]=Ae().map(Fe=>Fe.ref.current),[tt]=Ze.slice(-1),st=document.activeElement;for(const Fe of Ke)if(Fe===st||(Fe==null||Fe.scrollIntoView({block:"nearest"}),Fe===et&&F&&(F.scrollTop=0),Fe===tt&&F&&(F.scrollTop=F.scrollHeight),Fe==null||Fe.focus(),document.activeElement!==st))return},[Ae,F]),Ge=React__namespace.useCallback(()=>Le([ae,z]),[Le,ae,z]);React__namespace.useEffect(()=>{Ne&&Ge()},[Ne,Ge]);const{onOpenChange:je,triggerPointerDownPosRef:Be}=q;React__namespace.useEffect(()=>{if(z){let Ke={x:0,y:0};const et=tt=>{var st,Fe;Ke={x:Math.abs(Math.round(tt.pageX)-(((st=Be.current)==null?void 0:st.x)??0)),y:Math.abs(Math.round(tt.pageY)-(((Fe=Be.current)==null?void 0:Fe.y)??0))}},Ze=tt=>{Ke.x<=10&&Ke.y<=10?tt.preventDefault():z.contains(tt.target)||je(!1),document.removeEventListener("pointermove",et),Be.current=null};return Be.current!==null&&(document.addEventListener("pointermove",et),document.addEventListener("pointerup",Ze,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",et),document.removeEventListener("pointerup",Ze,{capture:!0})}}},[z,je,Be]),React__namespace.useEffect(()=>{const Ke=()=>je(!1);return window.addEventListener("blur",Ke),window.addEventListener("resize",Ke),()=>{window.removeEventListener("blur",Ke),window.removeEventListener("resize",Ke)}},[je]);const[qe,ze]=useTypeaheadSearch(Ke=>{const et=Ae().filter(st=>!st.disabled),Ze=et.find(st=>st.ref.current===document.activeElement),tt=findNextItem(et,Ke,Ze);tt&&setTimeout(()=>tt.ref.current.focus())}),Ue=React__namespace.useCallback((Ke,et,Ze)=>{const tt=!Oe.current&&!Ze;(q.value!==void 0&&q.value===et||tt)&&(ie(Ke),tt&&(Oe.current=!0))},[q.value]),Xe=React__namespace.useCallback(()=>z==null?void 0:z.focus(),[z]),Je=React__namespace.useCallback((Ke,et,Ze)=>{const tt=!Oe.current&&!Ze;(q.value!==void 0&&q.value===et||tt)&&se(Ke)},[q.value]),Ye=o==="popper"?SelectPopperPosition:SelectItemAlignedPosition,it=Ye===SelectPopperPosition?{side:g,sideOffset:b,align:_,alignOffset:S,arrowPadding:R,collisionBoundary:C,collisionPadding:E,sticky:M,hideWhenDetached:I,avoidCollisions:A}:{};return jsxRuntime.jsx(SelectContentProvider,{scope:n,content:z,viewport:F,onViewportChange:O,itemRefCallback:Ue,selectedItem:ae,onItemLeave:Xe,itemTextRefCallback:Je,focusSelectedItem:Ge,selectedItemText:oe,position:o,isPositioned:Ne,searchRef:qe,children:jsxRuntime.jsx(ReactRemoveScroll,{as:Slot$1,allowPinchZoom:!0,children:jsxRuntime.jsx(FocusScope,{asChild:!0,trapped:q.open,onMountAutoFocus:Ke=>{Ke.preventDefault()},onUnmountAutoFocus:composeEventHandlers(l,Ke=>{var et;(et=q.trigger)==null||et.focus({preventScroll:!0}),Ke.preventDefault()}),children:jsxRuntime.jsx(DismissableLayer,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:Ke=>Ke.preventDefault(),onDismiss:()=>q.onOpenChange(!1),children:jsxRuntime.jsx(Ye,{role:"listbox",id:q.contentId,"data-state":q.open?"open":"closed",dir:q.dir,onContextMenu:Ke=>Ke.preventDefault(),...V,...it,onPlaced:()=>ge(!0),ref:te,style:{display:"flex",flexDirection:"column",outline:"none",...V.style},onKeyDown:composeEventHandlers(V.onKeyDown,Ke=>{const et=Ke.ctrlKey||Ke.altKey||Ke.metaKey;if(Ke.key==="Tab"&&Ke.preventDefault(),!et&&Ke.key.length===1&&ze(Ke.key),["ArrowUp","ArrowDown","Home","End"].includes(Ke.key)){let tt=Ae().filter(st=>!st.disabled).map(st=>st.ref.current);if(["ArrowUp","End"].includes(Ke.key)&&(tt=tt.slice().reverse()),["ArrowUp","ArrowDown"].includes(Ke.key)){const st=Ke.target,Fe=tt.indexOf(st);tt=tt.slice(Fe+1)}setTimeout(()=>Le(tt)),Ke.preventDefault()}})})})})})})});SelectContentImpl.displayName=CONTENT_IMPL_NAME;var ITEM_ALIGNED_POSITION_NAME="SelectItemAlignedPosition",SelectItemAlignedPosition=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:o,...l}=e,d=useSelectContext(CONTENT_NAME$1,n),f=useSelectContentContext(CONTENT_NAME$1,n),[g,b]=React__namespace.useState(null),[_,S]=React__namespace.useState(null),R=useComposedRefs(t,te=>S(te)),C=useCollection(n),E=React__namespace.useRef(!1),M=React__namespace.useRef(!0),{viewport:I,selectedItem:A,selectedItemText:V,focusSelectedItem:q}=f,z=React__namespace.useCallback(()=>{if(d.trigger&&d.valueNode&&g&&_&&I&&A&&V){const te=d.trigger.getBoundingClientRect(),ae=_.getBoundingClientRect(),ie=d.valueNode.getBoundingClientRect(),oe=V.getBoundingClientRect();if(d.dir!=="rtl"){const st=oe.left-ae.left,Fe=ie.left-st,ct=te.left-Fe,Qe=te.width+ct,nt=Math.max(Qe,ae.width),ut=window.innerWidth-CONTENT_MARGIN,ft=clamp(Fe,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,ut-nt)]);g.style.minWidth=Qe+"px",g.style.left=ft+"px"}else{const st=ae.right-oe.right,Fe=window.innerWidth-ie.right-st,ct=window.innerWidth-te.right-Fe,Qe=te.width+ct,nt=Math.max(Qe,ae.width),ut=window.innerWidth-CONTENT_MARGIN,ft=clamp(Fe,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,ut-nt)]);g.style.minWidth=Qe+"px",g.style.right=ft+"px"}const se=C(),Ae=window.innerHeight-CONTENT_MARGIN*2,Ne=I.scrollHeight,ge=window.getComputedStyle(_),Oe=parseInt(ge.borderTopWidth,10),Le=parseInt(ge.paddingTop,10),Ge=parseInt(ge.borderBottomWidth,10),je=parseInt(ge.paddingBottom,10),Be=Oe+Le+Ne+je+Ge,qe=Math.min(A.offsetHeight*5,Be),ze=window.getComputedStyle(I),Ue=parseInt(ze.paddingTop,10),Xe=parseInt(ze.paddingBottom,10),Je=te.top+te.height/2-CONTENT_MARGIN,Ye=Ae-Je,it=A.offsetHeight/2,Ke=A.offsetTop+it,et=Oe+Le+Ke,Ze=Be-et;if(et<=Je){const st=se.length>0&&A===se[se.length-1].ref.current;g.style.bottom="0px";const Fe=_.clientHeight-I.offsetTop-I.offsetHeight,ct=Math.max(Ye,it+(st?Xe:0)+Fe+Ge),Qe=et+ct;g.style.height=Qe+"px"}else{const st=se.length>0&&A===se[0].ref.current;g.style.top="0px";const ct=Math.max(Je,Oe+I.offsetTop+(st?Ue:0)+it)+Ze;g.style.height=ct+"px",I.scrollTop=et-Je+I.offsetTop}g.style.margin=`${CONTENT_MARGIN}px 0`,g.style.minHeight=qe+"px",g.style.maxHeight=Ae+"px",o==null||o(),requestAnimationFrame(()=>E.current=!0)}},[C,d.trigger,d.valueNode,g,_,I,A,V,d.dir,o]);useLayoutEffect2(()=>z(),[z]);const[Q,F]=React__namespace.useState();useLayoutEffect2(()=>{_&&F(window.getComputedStyle(_).zIndex)},[_]);const O=React__namespace.useCallback(te=>{te&&M.current===!0&&(z(),q==null||q(),M.current=!1)},[z,q]);return jsxRuntime.jsx(SelectViewportProvider,{scope:n,contentWrapper:g,shouldExpandOnScrollRef:E,onScrollButtonChange:O,children:jsxRuntime.jsx("div",{ref:b,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:Q},children:jsxRuntime.jsx(Primitive.div,{...l,ref:R,style:{boxSizing:"border-box",maxHeight:"100%",...l.style}})})})});SelectItemAlignedPosition.displayName=ITEM_ALIGNED_POSITION_NAME;var POPPER_POSITION_NAME="SelectPopperPosition",SelectPopperPosition=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,align:o="start",collisionPadding:l=CONTENT_MARGIN,...d}=e,f=usePopperScope$1(n);return jsxRuntime.jsx(Content$1,{...f,...d,ref:t,align:o,collisionPadding:l,style:{boxSizing:"border-box",...d.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$1,{}),VIEWPORT_NAME="SelectViewport",SelectViewport=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:o,...l}=e,d=useSelectContentContext(VIEWPORT_NAME,n),f=useSelectViewportContext(VIEWPORT_NAME,n),g=useComposedRefs(t,d.onViewportChange),b=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:o}),jsxRuntime.jsx(Collection.Slot,{scope:n,children:jsxRuntime.jsx(Primitive.div,{"data-radix-select-viewport":"",role:"presentation",...l,ref:g,style:{position:"relative",flex:1,overflow:"hidden auto",...l.style},onScroll:composeEventHandlers(l.onScroll,_=>{const S=_.currentTarget,{contentWrapper:R,shouldExpandOnScrollRef:C}=f;if(C!=null&&C.current&&R){const E=Math.abs(b.current-S.scrollTop);if(E>0){const M=window.innerHeight-CONTENT_MARGIN*2,I=parseFloat(R.style.minHeight),A=parseFloat(R.style.height),V=Math.max(I,A);if(V<M){const q=V+E,z=Math.min(M,q),Q=q-z;R.style.height=z+"px",R.style.bottom==="0px"&&(S.scrollTop=Q>0?Q:0,R.style.justifyContent="flex-end")}}}b.current=S.scrollTop})})})]})});SelectViewport.displayName=VIEWPORT_NAME;var GROUP_NAME="SelectGroup",[SelectGroupContextProvider,useSelectGroupContext]=createSelectContext(GROUP_NAME),SelectGroup$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e,l=useId();return jsxRuntime.jsx(SelectGroupContextProvider,{scope:n,id:l,children:jsxRuntime.jsx(Primitive.div,{role:"group","aria-labelledby":l,...o,ref:t})})});SelectGroup$1.displayName=GROUP_NAME;var LABEL_NAME="SelectLabel",SelectLabel$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e,l=useSelectGroupContext(LABEL_NAME,n);return jsxRuntime.jsx(Primitive.div,{id:l.id,...o,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:o,disabled:l=!1,textValue:d,...f}=e,g=useSelectContext(ITEM_NAME,n),b=useSelectContentContext(ITEM_NAME,n),_=g.value===o,[S,R]=React__namespace.useState(d??""),[C,E]=React__namespace.useState(!1),M=useComposedRefs(t,q=>{var z;return(z=b.itemRefCallback)==null?void 0:z.call(b,q,o,l)}),I=useId(),A=React__namespace.useRef("touch"),V=()=>{l||(g.onValueChange(o),g.onOpenChange(!1))};if(o==="")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:o,disabled:l,textId:I,isSelected:_,onItemTextChange:React__namespace.useCallback(q=>{R(z=>z||((q==null?void 0:q.textContent)??"").trim())},[]),children:jsxRuntime.jsx(Collection.ItemSlot,{scope:n,value:o,disabled:l,textValue:S,children:jsxRuntime.jsx(Primitive.div,{role:"option","aria-labelledby":I,"data-highlighted":C?"":void 0,"aria-selected":_&&C,"data-state":_?"checked":"unchecked","aria-disabled":l||void 0,"data-disabled":l?"":void 0,tabIndex:l?void 0:-1,...f,ref:M,onFocus:composeEventHandlers(f.onFocus,()=>E(!0)),onBlur:composeEventHandlers(f.onBlur,()=>E(!1)),onClick:composeEventHandlers(f.onClick,()=>{A.current!=="mouse"&&V()}),onPointerUp:composeEventHandlers(f.onPointerUp,()=>{A.current==="mouse"&&V()}),onPointerDown:composeEventHandlers(f.onPointerDown,q=>{A.current=q.pointerType}),onPointerMove:composeEventHandlers(f.onPointerMove,q=>{var z;A.current=q.pointerType,l?(z=b.onItemLeave)==null||z.call(b):A.current==="mouse"&&q.currentTarget.focus({preventScroll:!0})}),onPointerLeave:composeEventHandlers(f.onPointerLeave,q=>{var z;q.currentTarget===document.activeElement&&((z=b.onItemLeave)==null||z.call(b))}),onKeyDown:composeEventHandlers(f.onKeyDown,q=>{var Q;((Q=b.searchRef)==null?void 0:Q.current)!==""&&q.key===" "||(SELECTION_KEYS.includes(q.key)&&V(),q.key===" "&&q.preventDefault())})})})})});SelectItem$1.displayName=ITEM_NAME;var ITEM_TEXT_NAME="SelectItemText",SelectItemText=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,className:o,style:l,...d}=e,f=useSelectContext(ITEM_TEXT_NAME,n),g=useSelectContentContext(ITEM_TEXT_NAME,n),b=useSelectItemContext(ITEM_TEXT_NAME,n),_=useSelectNativeOptionsContext(ITEM_TEXT_NAME,n),[S,R]=React__namespace.useState(null),C=useComposedRefs(t,V=>R(V),b.onItemTextChange,V=>{var q;return(q=g.itemTextRefCallback)==null?void 0:q.call(g,V,b.value,b.disabled)}),E=S==null?void 0:S.textContent,M=React__namespace.useMemo(()=>jsxRuntime.jsx("option",{value:b.value,disabled:b.disabled,children:E},b.value),[b.disabled,b.value,E]),{onNativeOptionAdd:I,onNativeOptionRemove:A}=_;return useLayoutEffect2(()=>(I(M),()=>A(M)),[I,A,M]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Primitive.span,{id:b.textId,...d,ref:C}),b.isSelected&&f.valueNode&&!f.valueNodeHasChildren?ReactDOM__namespace.createPortal(d.children,f.valueNode):null]})});SelectItemText.displayName=ITEM_TEXT_NAME;var ITEM_INDICATOR_NAME="SelectItemIndicator",SelectItemIndicator=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e;return useSelectItemContext(ITEM_INDICATOR_NAME,n).isSelected?jsxRuntime.jsx(Primitive.span,{"aria-hidden":!0,...o,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),o=useSelectViewportContext(SCROLL_UP_BUTTON_NAME,e.__scopeSelect),[l,d]=React__namespace.useState(!1),f=useComposedRefs(t,o.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let g=function(){const _=b.scrollTop>0;d(_)};const b=n.viewport;return g(),b.addEventListener("scroll",g),()=>b.removeEventListener("scroll",g)}},[n.viewport,n.isPositioned]),l?jsxRuntime.jsx(SelectScrollButtonImpl,{...e,ref:f,onAutoScroll:()=>{const{viewport:g,selectedItem:b}=n;g&&b&&(g.scrollTop=g.scrollTop-b.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),o=useSelectViewportContext(SCROLL_DOWN_BUTTON_NAME,e.__scopeSelect),[l,d]=React__namespace.useState(!1),f=useComposedRefs(t,o.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let g=function(){const _=b.scrollHeight-b.clientHeight,S=Math.ceil(b.scrollTop)<_;d(S)};const b=n.viewport;return g(),b.addEventListener("scroll",g),()=>b.removeEventListener("scroll",g)}},[n.viewport,n.isPositioned]),l?jsxRuntime.jsx(SelectScrollButtonImpl,{...e,ref:f,onAutoScroll:()=>{const{viewport:g,selectedItem:b}=n;g&&b&&(g.scrollTop=g.scrollTop+b.offsetHeight)}}):null});SelectScrollDownButton$1.displayName=SCROLL_DOWN_BUTTON_NAME;var SelectScrollButtonImpl=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:o,...l}=e,d=useSelectContentContext("SelectScrollButton",n),f=React__namespace.useRef(null),g=useCollection(n),b=React__namespace.useCallback(()=>{f.current!==null&&(window.clearInterval(f.current),f.current=null)},[]);return React__namespace.useEffect(()=>()=>b(),[b]),useLayoutEffect2(()=>{var S;const _=g().find(R=>R.ref.current===document.activeElement);(S=_==null?void 0:_.ref.current)==null||S.scrollIntoView({block:"nearest"})},[g]),jsxRuntime.jsx(Primitive.div,{"aria-hidden":!0,...l,ref:t,style:{flexShrink:0,...l.style},onPointerDown:composeEventHandlers(l.onPointerDown,()=>{f.current===null&&(f.current=window.setInterval(o,50))}),onPointerMove:composeEventHandlers(l.onPointerMove,()=>{var _;(_=d.onItemLeave)==null||_.call(d),f.current===null&&(f.current=window.setInterval(o,50))}),onPointerLeave:composeEventHandlers(l.onPointerLeave,()=>{b()})})}),SEPARATOR_NAME="SelectSeparator",SelectSeparator$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e;return jsxRuntime.jsx(Primitive.div,{"aria-hidden":!0,...o,ref:t})});SelectSeparator$1.displayName=SEPARATOR_NAME;var ARROW_NAME$1="SelectArrow",SelectArrow=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e,l=usePopperScope$1(n),d=useSelectContext(ARROW_NAME$1,n),f=useSelectContentContext(ARROW_NAME$1,n);return d.open&&f.position==="popper"?jsxRuntime.jsx(Arrow,{...l,...o,ref:t}):null});SelectArrow.displayName=ARROW_NAME$1;var BUBBLE_INPUT_NAME="SelectBubbleInput",SelectBubbleInput=React__namespace.forwardRef(({__scopeSelect:e,value:t,...n},o)=>{const l=React__namespace.useRef(null),d=useComposedRefs(o,l),f=usePrevious(t);return React__namespace.useEffect(()=>{const g=l.current;if(!g)return;const b=window.HTMLSelectElement.prototype,S=Object.getOwnPropertyDescriptor(b,"value").set;if(f!==t&&S){const R=new Event("change",{bubbles:!0});S.call(g,t),g.dispatchEvent(R)}},[f,t]),jsxRuntime.jsx(Primitive.select,{...n,style:{...VISUALLY_HIDDEN_STYLES,...n.style},ref:d,defaultValue:t})});SelectBubbleInput.displayName=BUBBLE_INPUT_NAME;function shouldShowPlaceholder(e){return e===""||e===void 0}function useTypeaheadSearch(e){const t=useCallbackRef$1(e),n=React__namespace.useRef(""),o=React__namespace.useRef(0),l=React__namespace.useCallback(f=>{const g=n.current+f;t(g),function b(_){n.current=_,window.clearTimeout(o.current),_!==""&&(o.current=window.setTimeout(()=>b(""),1e3))}(g)},[t]),d=React__namespace.useCallback(()=>{n.current="",window.clearTimeout(o.current)},[]);return React__namespace.useEffect(()=>()=>window.clearTimeout(o.current),[]),[n,l,d]}function findNextItem(e,t,n){const l=t.length>1&&Array.from(t).every(_=>_===t[0])?t[0]:t,d=n?e.indexOf(n):-1;let f=wrapArray(e,Math.max(d,0));l.length===1&&(f=f.filter(_=>_!==n));const b=f.find(_=>_.textValue.toLowerCase().startsWith(l.toLowerCase()));return b!==n?b:void 0}function wrapArray(e,t){return e.map((n,o)=>e[(t+o)%e.length])}var Root2$1=Select$1,Trigger$1=SelectTrigger$1,Value=SelectValue$1,Icon=SelectIcon,Portal$1=SelectPortal,Content2$1=SelectContent$1,Viewport=SelectViewport,Group=SelectGroup$1,Label=SelectLabel$1,Item=SelectItem$1,ItemText=SelectItemText,ItemIndicator=SelectItemIndicator,ScrollUpButton=SelectScrollUpButton$1,ScrollDownButton=SelectScrollDownButton$1,Separator=SelectSeparator$1;const Select=Root2$1,SelectGroup=Group,SelectValue=Value,SelectTrigger=React__namespace.forwardRef(({className:e,children:t,...n},o)=>jsxRuntime.jsxs(Trigger$1,{ref:o,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$1.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",...o},l)=>jsxRuntime.jsx(Portal$1,{children:jsxRuntime.jsxs(Content2$1,{ref:l,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,...o,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$1.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},o)=>jsxRuntime.jsxs(Item,{ref:o,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;const DAYS_OF_WEEK=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function ManufacturerReorderingCard({manufacturer:e,onSave:t,loading:n=!1,saving:o=!1}){const[l,d]=React.useState({...e}),f=(C,E)=>{d(M=>({...M,[C]:E}))},g=(C,E)=>{d(M=>({...M,[C]:E}))},b=(C,E)=>{d(M=>({...M,[C]:E}))},_=()=>{o||t(l)},S=C=>C===-1?"ASAP":C===void 0||C<0||C>6?"Sunday":DAYS_OF_WEEK[C],R=C=>C==="ASAP"?-1:DAYS_OF_WEEK.indexOf(C);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-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.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:l.AutoUpdate,onCheckedChange:C=>f("AutoUpdate",C),disabled:o}),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:S(l.AutoReorderDate),onValueChange:C=>g("AutoReorderDate",R(C)),disabled:o,children:[jsxRuntime.jsx(SelectTrigger,{id:"reorder-date",children:jsxRuntime.jsx(SelectValue,{placeholder:"Select day"})}),jsxRuntime.jsxs(SelectContent,{children:[jsxRuntime.jsx(SelectItem,{value:"ASAP",children:"ASAP"}),DAYS_OF_WEEK.map(C=>jsxRuntime.jsx(SelectItem,{value:C,children:C},C))]})]})]}),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:l.DefaultWeeksOfStocking||"",onChange:C=>g("DefaultWeeksOfStocking",Number(C.target.value)),disabled:o}),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:l.DefaultMinimumOrder||"",onChange:C=>g("DefaultMinimumOrder",Number(C.target.value)),disabled:o})]})]}),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:l.DefaultLeadTime||"",onChange:C=>g("DefaultLeadTime",Number(C.target.value)),disabled:o}),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:"maximum-inventory-value",children:"Default Maximum Inventory Value"}),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:"maximum-inventory-value",type:"number",className:"pl-6",value:l.DefaultMaxInventoryValue||"",onChange:C=>g("DefaultMaxInventoryValue",Number(C.target.value)),disabled:o})]})]}),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:l.POEmail||"",onChange:C=>b("POEmail",C.target.value),placeholder:"email@example.com",disabled:o})]})]})]})}),jsxRuntime.jsx(CardFooter,{className:"flex justify-end",children:n?jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"}):jsxRuntime.jsxs(Button,{onClick:_,disabled:o,children:[o&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]})})]})}var POPOVER_NAME="Popover",[createPopoverContext,createPopoverScope]=createContextScope(POPOVER_NAME,[createPopperScope]),usePopperScope=createPopperScope(),[PopoverProvider,usePopoverContext]=createPopoverContext(POPOVER_NAME),Popover$1=e=>{const{__scopePopover:t,children:n,open:o,defaultOpen:l,onOpenChange:d,modal:f=!1}=e,g=usePopperScope(t),b=React__namespace.useRef(null),[_,S]=React__namespace.useState(!1),[R,C]=useControllableState({prop:o,defaultProp:l??!1,onChange:d,caller:POPOVER_NAME});return jsxRuntime.jsx(Root2$5,{...g,children:jsxRuntime.jsx(PopoverProvider,{scope:t,contentId:useId(),triggerRef:b,open:R,onOpenChange:C,onOpenToggle:React__namespace.useCallback(()=>C(E=>!E),[C]),hasCustomAnchor:_,onCustomAnchorAdd:React__namespace.useCallback(()=>S(!0),[]),onCustomAnchorRemove:React__namespace.useCallback(()=>S(!1),[]),modal:f,children:n})})};Popover$1.displayName=POPOVER_NAME;var ANCHOR_NAME="PopoverAnchor",PopoverAnchor$1=React__namespace.forwardRef((e,t)=>{const{__scopePopover:n,...o}=e,l=usePopoverContext(ANCHOR_NAME,n),d=usePopperScope(n),{onCustomAnchorAdd:f,onCustomAnchorRemove:g}=l;return React__namespace.useEffect(()=>(f(),()=>g()),[f,g]),jsxRuntime.jsx(Anchor,{...d,...o,ref:t})});PopoverAnchor$1.displayName=ANCHOR_NAME;var TRIGGER_NAME="PopoverTrigger",PopoverTrigger$1=React__namespace.forwardRef((e,t)=>{const{__scopePopover:n,...o}=e,l=usePopoverContext(TRIGGER_NAME,n),d=usePopperScope(n),f=useComposedRefs(t,l.triggerRef),g=jsxRuntime.jsx(Primitive.button,{type:"button","aria-haspopup":"dialog","aria-expanded":l.open,"aria-controls":l.contentId,"data-state":getState(l.open),...o,ref:f,onClick:composeEventHandlers(e.onClick,l.onOpenToggle)});return l.hasCustomAnchor?g:jsxRuntime.jsx(Anchor,{asChild:!0,...d,children:g})});PopoverTrigger$1.displayName=TRIGGER_NAME;var PORTAL_NAME="PopoverPortal",[PortalProvider,usePortalContext]=createPopoverContext(PORTAL_NAME,{forceMount:void 0}),PopoverPortal=e=>{const{__scopePopover:t,forceMount:n,children:o,container:l}=e,d=usePopoverContext(PORTAL_NAME,t);return jsxRuntime.jsx(PortalProvider,{scope:t,forceMount:n,children:jsxRuntime.jsx(Presence,{present:n||d.open,children:jsxRuntime.jsx(Portal$5,{asChild:!0,container:l,children:o})})})};PopoverPortal.displayName=PORTAL_NAME;var CONTENT_NAME="PopoverContent",PopoverContent$1=React__namespace.forwardRef((e,t)=>{const n=usePortalContext(CONTENT_NAME,e.__scopePopover),{forceMount:o=n.forceMount,...l}=e,d=usePopoverContext(CONTENT_NAME,e.__scopePopover);return jsxRuntime.jsx(Presence,{present:o||d.open,children:d.modal?jsxRuntime.jsx(PopoverContentModal,{...l,ref:t}):jsxRuntime.jsx(PopoverContentNonModal,{...l,ref:t})})});PopoverContent$1.displayName=CONTENT_NAME;var Slot=createSlot("PopoverContent.RemoveScroll"),PopoverContentModal=React__namespace.forwardRef((e,t)=>{const n=usePopoverContext(CONTENT_NAME,e.__scopePopover),o=React__namespace.useRef(null),l=useComposedRefs(t,o),d=React__namespace.useRef(!1);return React__namespace.useEffect(()=>{const f=o.current;if(f)return hideOthers(f)},[]),jsxRuntime.jsx(ReactRemoveScroll,{as:Slot,allowPinchZoom:!0,children:jsxRuntime.jsx(PopoverContentImpl,{...e,ref:l,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:composeEventHandlers(e.onCloseAutoFocus,f=>{var g;f.preventDefault(),d.current||(g=n.triggerRef.current)==null||g.focus()}),onPointerDownOutside:composeEventHandlers(e.onPointerDownOutside,f=>{const g=f.detail.originalEvent,b=g.button===0&&g.ctrlKey===!0,_=g.button===2||b;d.current=_},{checkForDefaultPrevented:!1}),onFocusOutside:composeEventHandlers(e.onFocusOutside,f=>f.preventDefault(),{checkForDefaultPrevented:!1})})})}),PopoverContentNonModal=React__namespace.forwardRef((e,t)=>{const n=usePopoverContext(CONTENT_NAME,e.__scopePopover),o=React__namespace.useRef(!1),l=React__namespace.useRef(!1);return jsxRuntime.jsx(PopoverContentImpl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:d=>{var f,g;(f=e.onCloseAutoFocus)==null||f.call(e,d),d.defaultPrevented||(o.current||(g=n.triggerRef.current)==null||g.focus(),d.preventDefault()),o.current=!1,l.current=!1},onInteractOutside:d=>{var b,_;(b=e.onInteractOutside)==null||b.call(e,d),d.defaultPrevented||(o.current=!0,d.detail.originalEvent.type==="pointerdown"&&(l.current=!0));const f=d.target;((_=n.triggerRef.current)==null?void 0:_.contains(f))&&d.preventDefault(),d.detail.originalEvent.type==="focusin"&&l.current&&d.preventDefault()}})}),PopoverContentImpl=React__namespace.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:o,onOpenAutoFocus:l,onCloseAutoFocus:d,disableOutsidePointerEvents:f,onEscapeKeyDown:g,onPointerDownOutside:b,onFocusOutside:_,onInteractOutside:S,...R}=e,C=usePopoverContext(CONTENT_NAME,n),E=usePopperScope(n);return useFocusGuards(),jsxRuntime.jsx(FocusScope,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:l,onUnmountAutoFocus:d,children:jsxRuntime.jsx(DismissableLayer,{asChild:!0,disableOutsidePointerEvents:f,onInteractOutside:S,onEscapeKeyDown:g,onPointerDownOutside:b,onFocusOutside:_,onDismiss:()=>C.onOpenChange(!1),children:jsxRuntime.jsx(Content$1,{"data-state":getState(C.open),role:"dialog",id:C.contentId,...E,...R,ref:t,style:{...R.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),CLOSE_NAME="PopoverClose",PopoverClose=React__namespace.forwardRef((e,t)=>{const{__scopePopover:n,...o}=e,l=usePopoverContext(CLOSE_NAME,n);return jsxRuntime.jsx(Primitive.button,{type:"button",...o,ref:t,onClick:composeEventHandlers(e.onClick,()=>l.onOpenChange(!1))})});PopoverClose.displayName=CLOSE_NAME;var ARROW_NAME="PopoverArrow",PopoverArrow=React__namespace.forwardRef((e,t)=>{const{__scopePopover:n,...o}=e,l=usePopperScope(n);return jsxRuntime.jsx(Arrow,{...l,...o,ref:t})});PopoverArrow.displayName=ARROW_NAME;function getState(e){return e?"open":"closed"}var Root2=Popover$1,Anchor2=PopoverAnchor$1,Trigger=PopoverTrigger$1,Portal=PopoverPortal,Content2=PopoverContent$1;const Popover=Root2,PopoverTrigger=Trigger,PopoverAnchor=Anchor2,PopoverContent=React__namespace.forwardRef(({className:e,align:t="center",sideOffset:n=4,...o},l)=>jsxRuntime.jsx(Portal,{children:jsxRuntime.jsx(Content2,{ref:l,align:t,sideOffset:n,className:cn("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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-popover-content-transform-origin]",e),...o})}));PopoverContent.displayName=Content2.displayName;function MultiSelect({options:e,selected:t,onChange:n,placeholder:o="Select items..."}){const[l,d]=React__namespace.useState(!1),[f,g]=React__namespace.useState(""),b=React__namespace.useRef(null),[_,S]=React__namespace.useState(void 0),R=React__namespace.useCallback(()=>{b.current&&S(b.current.offsetWidth)},[]);React__namespace.useLayoutEffect(()=>{R()},[R]),React__namespace.useEffect(()=>(window.addEventListener("resize",R),()=>window.removeEventListener("resize",R)),[R]);const C=I=>{n(t.filter(A=>A!==I))},E=I=>{d(!1),t.includes(I)?n(t.filter(A=>A!==I)):n([...t,I])},M=I=>{I.key==="Enter"&&f&&!e.includes(f)&&!t.includes(f)&&(I.preventDefault(),E(f),g(""))};return jsxRuntime.jsxs(Popover,{open:l,onOpenChange:d,children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{ref:b,variant:"outline",role:"combobox","aria-expanded":l,className:"w-full justify-between h-auto min-h-[40px] py-2",children:[jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1 items-center",children:t.length>0?t.map(I=>jsxRuntime.jsxs(Badge,{variant:"outline",className:"mr-1 mb-1",children:[I,jsxRuntime.jsx("span",{className:"ml-1 cursor-pointer ring-offset-background rounded-full outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2",onClick:A=>{A.preventDefault(),A.stopPropagation(),C(I)},children:jsxRuntime.jsx(X$1,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},I)):jsxRuntime.jsx("span",{className:"text-muted-foreground",children:o})}),jsxRuntime.jsx(ChevronsUpDown,{className:"h-4 w-4 shrink-0 opacity-50 ml-2"})]})}),jsxRuntime.jsx(PopoverContent,{className:"w-full p-0",style:{width:_},children:jsxRuntime.jsxs(Command,{onKeyDown:M,children:[jsxRuntime.jsx(CommandInput,{placeholder:"Search or add custom item...",value:f,onValueChange:g}),jsxRuntime.jsxs(CommandList,{children:[jsxRuntime.jsx(CommandEmpty,{children:"No item found."}),jsxRuntime.jsxs(CommandGroup,{children:[e.filter(I=>!t.includes(I)).map(I=>jsxRuntime.jsxs(CommandItem,{onSelect:()=>E(I),children:[jsxRuntime.jsx(Check,{className:cn("mr-2 h-4 w-4",t.includes(I)?"opacity-100":"opacity-0")}),I]},I)),f&&!e.includes(f)&&!t.includes(f)&&jsxRuntime.jsxs(CommandItem,{onSelect:()=>E(f),children:['Add "',f,'"']})]})]})]})})]})}function ResellerBillingOverviewCard({reseller:e,actions:t,loading:n=!1}){return n||!e?jsxRuntime.jsx(ResellerBillingOverviewSkeleton,{}):jsxRuntime.jsx(ResellerBillingOverviewData,{reseller:e,actions:t})}function ResellerBillingOverviewSkeleton(){return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-40"})})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[jsxRuntime.jsx("div",{className:"space-y-4",children:Array(3).fill(0).map((e,t)=>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"})]})]},t))}),jsxRuntime.jsx("div",{className:"space-y-4",children:Array(2).fill(0).map((e,t)=>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"})]})]},t))})]}),jsxRuntime.jsx("div",{className:"flex justify-end mt-4",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-28 rounded-md"})})]})]})}function ResellerBillingOverviewData({reseller:e,actions:t}){const n=f=>f===void 0?"$0.00":new Intl.NumberFormat("en-CA",{style:"currency",currency:"CAD",minimumFractionDigits:2,maximumFractionDigits:2}).format(f),o=e.Statement||{},l=[{title:"0 - 30 Days",amount:o.Over0||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-primary"},{title:"31 - 45 Days",amount:o.Over30||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-primary"},{title:"45+ Days",amount:o.Over45||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-primary"}],d=[{title:"Total",amount:o.Total||0,icon:jsxRuntime.jsx(DollarSign,{className:"h-5 w-5 text-white"}),color:"bg-green-500"},{title:"Credit Limit",amount:e.CreditLimit||0,icon:jsxRuntime.jsx(CreditCard,{className:"h-5 w-5 text-white"}),color:"bg-blue-500"}];return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Billing Overview"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[jsxRuntime.jsx("div",{className:"space-y-4",children:l.map((f,g)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center",children:[jsxRuntime.jsx("h3",{className:"text-sm sm:text-base font-medium",children:f.title}),jsxRuntime.jsx("div",{className:`p-2 rounded-full ${f.color}`,children:f.icon})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("p",{className:"text-base sm:text-lg font-bold",children:n(f.amount)})})]},g))}),jsxRuntime.jsx("div",{className:"space-y-4",children:d.map((f,g)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center",children:[jsxRuntime.jsx("h3",{className:"text-sm sm:text-base font-medium",children:f.title}),jsxRuntime.jsx("div",{className:`p-2 rounded-full ${f.color}`,children:f.icon})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("p",{className:"text-base sm:text-lg font-bold",children:n(f.amount)})})]},g))})]}),t&&jsxRuntime.jsx("div",{className:"flex justify-end mt-4",children:t})]})]})}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,o)=>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"})]},o))})})]}):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,o)=>jsxRuntime.jsx(ManufacturerLogo,{manufacturerId:n.ManufacturerId,opportunityNumber:n.DefaultOpportunityNumber},`${n.ManufacturerId}-${o}`))})})]})}function ManufacturerLogo({manufacturerId:e,opportunityNumber:t}){const[n,o]=React.useState(null),[l,d]=React.useState(!0),[f,g]=React.useState(!1),[b,_]=React.useState(null),S=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(!S)return;let R=!0;_(null);const C=async()=>{try{const I=await fetch(S.logoExistsUrl);if(I.ok){const V=(await I.text()).toLowerCase()==="true";return R&&g(V),V}return!1}catch(I){return console.error("Failed to check if logo exists:",I),R&&g(!1),!1}},E=async()=>{R&&d(!0);try{const I=await fetch(S.logoUrl);if(I.ok){const A=await I.blob();R&&(n&&URL.revokeObjectURL(n),o(URL.createObjectURL(A)))}else throw new Error(`Failed to load logo: ${I.status}`)}catch(I){console.error("Failed to load logo:",I),R&&_("Failed to load manufacturer logo")}finally{R&&d(!1)}};return(async()=>{await C()?E():d(!1)})(),()=>{R=!1,n&&URL.revokeObjectURL(n)}},[S]),jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx("div",{className:"h-12 flex items-center justify-center mb-2",children:l?jsxRuntime.jsx(Skeleton,{className:"h-12 w-24 rounded-md"}):f&&n?jsxRuntime.jsx("img",{src:n,alt:"Manufacturer logo",className:"max-h-12 max-w-24 object-contain",onError:()=>_("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}),b&&jsxRuntime.jsx("div",{className:"text-red-500 text-xs mt-1",role:"alert",children:b})]})}function SalesOverviewCard({salesData:e,salesStatistics:t=[],loading:n=!1}){return n||!e?jsxRuntime.jsx(SalesOverviewSkeleton,{}):jsxRuntime.jsx(SalesOverviewData,{salesData:e,salesStatistics:t})}function SalesOverviewSkeleton(){return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-lg sm:text-xl",children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-40"})})}),jsxRuntime.jsxs(CardContent,{className:"pt-4 px-3 sm:px-6",children:[jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:Array(3).fill(0).map((e,t)=>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"})]})]},t))}),jsxRuntime.jsx("div",{className:"mt-6",children:jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-[250px] w-full rounded-lg"})]})})]})]})}function SalesOverviewData({salesData:e,salesStatistics:t=[]}){const n=d=>new Intl.NumberFormat("en-CA",{style:"currency",currency:"CAD",minimumFractionDigits:2,maximumFractionDigits:2}).format(d),o=[{title:"Last 30 days",amount:e.SalesLast30Days||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-blue-500"},{title:"Last 3 months",amount:e.SalesLast3Months||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-amber-500"},{title:"Year to date",amount:e.SalesYearToDay||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-emerald-500"}],l=React.useMemo(()=>{const d=new Map;return t.forEach(f=>{var b;const g=((b=f.Day)==null?void 0:b.toString())||"";if(g.length===8){const _=parseInt(g.substring(0,4),10),S=parseInt(g.substring(4,6),10)-1,R=parseInt(g.substring(6,8),10),C=new Date(_,S,R),E=new Date(C),M=C.getDay();E.setDate(C.getDate()-M);const I=`${E.getFullYear()}-${String(E.getMonth()+1).padStart(2,"0")}-${String(E.getDate()).padStart(2,"0")}`,A=f.ExtendedPrice||0;d.has(I)?d.set(I,d.get(I)+A):d.set(I,A)}}),Array.from(d).sort(([f],[g])=>f.localeCompare(g)).map(([f,g])=>({date:`${f.substring(5,7)}/${f.substring(8,10)}`,amount:g}))},[t]);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.jsxs(CardContent,{className:"pt-4 px-3 sm:px-6",children:[jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:o.map((d,f)=>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:d.title}),jsxRuntime.jsx("div",{className:`p-2 rounded-full ${d.color}`,children:d.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(d.amount)})]})]},f))}),jsxRuntime.jsx("div",{className:"mt-6",children:t&&t.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("h3",{className:"text-sm font-medium mb-4",children:"Sales Trend"}),jsxRuntime.jsx("div",{className:"space-y-6",children:jsxRuntime.jsx(AreaChart,{data:l,units:"$",unitsPosition:"left",height:200})})]})})]})]})}exports.ActiveOrdersCard=ActiveOrdersCard,exports.AiGeneratedContent=AiGeneratedContent,exports.Alert=Alert,exports.AlertDescription=AlertDescription,exports.AlertTitle=AlertTitle,exports.ApiKeyProvider=ApiKeyProvider,exports.AreaChart=AreaChart,exports.Avatar=Avatar,exports.AvatarFallback=AvatarFallback,exports.AvatarFooter=AvatarFooter,exports.AvatarImage=AvatarImage,exports.Badge=Badge,exports.Button=Button,exports.Card=Card,exports.CardContent=CardContent,exports.CardDescription=CardDescription,exports.CardFooter=CardFooter,exports.CardHeader=CardHeader,exports.CardTitle=CardTitle,exports.ChatLayout=ChatLayout,exports.ChatProvider=ChatProvider,exports.Checkbox=Checkbox,exports.Command=Command,exports.CommandDialog=CommandDialog,exports.CommandEmpty=CommandEmpty,exports.CommandGroup=CommandGroup,exports.CommandInput=CommandInput,exports.CommandItem=CommandItem,exports.CommandList=CommandList,exports.CommandSeparator=CommandSeparator,exports.CommandShortcut=CommandShortcut,exports.CountryFlag=CountryFlag,exports.Dialog=Dialog,exports.DialogClose=DialogClose,exports.DialogContent=DialogContent,exports.DialogDescription=DialogDescription,exports.DialogFooter=DialogFooter,exports.DialogHeader=DialogHeader,exports.DialogOverlay=DialogOverlay,exports.DialogPortal=DialogPortal,exports.DialogTitle=DialogTitle,exports.DialogTrigger=DialogTrigger,exports.DropdownMenu=DropdownMenu,exports.DropdownMenuCheckboxItem=DropdownMenuCheckboxItem,exports.DropdownMenuContent=DropdownMenuContent,exports.DropdownMenuGroup=DropdownMenuGroup,exports.DropdownMenuItem=DropdownMenuItem,exports.DropdownMenuLabel=DropdownMenuLabel,exports.DropdownMenuPortal=DropdownMenuPortal,exports.DropdownMenuRadioGroup=DropdownMenuRadioGroup,exports.DropdownMenuRadioItem=DropdownMenuRadioItem,exports.DropdownMenuSeparator=DropdownMenuSeparator,exports.DropdownMenuShortcut=DropdownMenuShortcut,exports.DropdownMenuSub=DropdownMenuSub,exports.DropdownMenuSubContent=DropdownMenuSubContent,exports.DropdownMenuSubTrigger=DropdownMenuSubTrigger,exports.DropdownMenuTrigger=DropdownMenuTrigger,exports.ExploreManufacturers=ExploreManufacturers,exports.GeneralDocumentCard=GeneralDocumentCard,exports.Input=Input,exports.InputOTP=InputOTP,exports.InputOTPGroup=InputOTPGroup,exports.InputOTPSeparator=InputOTPSeparator,exports.InputOTPSlot=InputOTPSlot,exports.Label=Label$2,exports.Layout=Layout,exports.ManufacturerCard=ManufacturerCard,exports.ManufacturerGetStartedButton=ManufacturerGetStartedButton,exports.ManufacturerReorderingCard=ManufacturerReorderingCard,exports.MultiSelect=MultiSelect,exports.Navbar=Navbar,exports.PartnerCard=PartnerCard,exports.Popover=Popover,exports.PopoverAnchor=PopoverAnchor,exports.PopoverContent=PopoverContent,exports.PopoverTrigger=PopoverTrigger,exports.Preloader=Preloader,exports.ProductCard=ProductCard,exports.ProductImage=ProductImage,exports.ProductInventoryGrid=ProductInventoryGrid,exports.RadioGroup=RadioGroup$1,exports.RadioGroupItem=RadioGroupItem,exports.Reseller=Reseller,exports.ResellerBillingOverviewCard=ResellerBillingOverviewCard,exports.ResellerCard=ResellerCard,exports.ResellerQualificationsCard=ResellerQualificationsCard,exports.SalesOverviewCard=SalesOverviewCard,exports.ScrollArea=ScrollArea,exports.ScrollBar=ScrollBar,exports.Select=Select,exports.SelectContent=SelectContent,exports.SelectGroup=SelectGroup,exports.SelectItem=SelectItem,exports.SelectLabel=SelectLabel,exports.SelectScrollDownButton=SelectScrollDownButton,exports.SelectScrollUpButton=SelectScrollUpButton,exports.SelectTrigger=SelectTrigger,exports.SelectValue=SelectValue,exports.Separator=Separator$1,exports.Sheet=Sheet,exports.SheetClose=SheetClose,exports.SheetContent=SheetContent,exports.SheetDescription=SheetDescription,exports.SheetFooter=SheetFooter,exports.SheetHeader=SheetHeader,exports.SheetOverlay=SheetOverlay,exports.SheetPortal=SheetPortal,exports.SheetTitle=SheetTitle,exports.SheetTrigger=SheetTrigger,exports.Sidebar=Sidebar,exports.SidebarContent=SidebarContent,exports.SidebarFooter=SidebarFooter,exports.SidebarGroup=SidebarGroup,exports.SidebarGroupAction=SidebarGroupAction,exports.SidebarGroupContent=SidebarGroupContent,exports.SidebarGroupLabel=SidebarGroupLabel,exports.SidebarHeader=SidebarHeader,exports.SidebarInput=SidebarInput,exports.SidebarInset=SidebarInset,exports.SidebarMenu=SidebarMenu,exports.SidebarMenuAction=SidebarMenuAction,exports.SidebarMenuBadge=SidebarMenuBadge,exports.SidebarMenuButton=SidebarMenuButton,exports.SidebarMenuItem=SidebarMenuItem,exports.SidebarMenuSkeleton=SidebarMenuSkeleton,exports.SidebarMenuSub=SidebarMenuSub,exports.SidebarMenuSubButton=SidebarMenuSubButton,exports.SidebarMenuSubItem=SidebarMenuSubItem,exports.SidebarProvider=SidebarProvider,exports.SidebarRail=SidebarRail,exports.SidebarSeparator=SidebarSeparator,exports.SidebarTrigger=SidebarTrigger,exports.Skeleton=Skeleton,exports.Switch=Switch,exports.Table=Table,exports.TableBody=TableBody,exports.TableCaption=TableCaption,exports.TableCell=TableCell,exports.TableFooter=TableFooter,exports.TableHead=TableHead,exports.TableHeader=TableHeader,exports.TableRow=TableRow,exports.Tabs=Tabs,exports.TabsContent=TabsContent,exports.TabsList=TabsList,exports.TabsTrigger=TabsTrigger,exports.Textarea=Textarea,exports.Toast=Toast,exports.ToastAction=ToastAction,exports.ToastClose=ToastClose,exports.ToastDescription=ToastDescription,exports.ToastProvider=ToastProvider,exports.ToastTitle=ToastTitle,exports.ToastViewport=ToastViewport,exports.Toaster=Toaster,exports.Tooltip=Tooltip$1,exports.TooltipContent=TooltipContent,exports.TooltipProvider=TooltipProvider,exports.TooltipTrigger=TooltipTrigger,exports.Topbar=Topbar,exports.badgeVariants=badgeVariants,exports.buttonVariants=buttonVariants,exports.toast=toast,exports.useApiKey=useApiKey,exports.useChat=useChat,exports.useIsMobile=useIsMobile,exports.useSidebar=useSidebar,exports.useToast=useToast,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
969
+ `);M(!0),Le({applicationId:e,partnerId:t.ManufactuerId,message:st}).then(Fe=>{var Qe;if(Fe.error){console.error(Fe.error),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"});return}const ct=(Qe=Fe.data)==null?void 0:Qe.ConversationId;ct&&Ge(ct)?(f(!1),Be()):n({title:"Could not send message",description:"Try again later.",variant:"destructive"})}).catch(Fe=>{console.error(Fe),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"})}).finally(()=>{M(!1)})},Xe=(Ke,et)=>{Q(Ze=>et?[...Ze,Ke]:Ze.filter(tt=>tt!==Ke)),O("")},Je=(Ke,et)=>{oe(Ze=>et?[...Ze,Ke]:Ze.filter(tt=>tt!==Ke)),Ae("")},Ye=z.includes("other-channel"),it=ie.includes("other-market");return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[!t.Qualification&&jsxRuntime.jsxs(Button,{onClick:qe,disabled:!t.PartnerRegistrationLink&&!t.OpenToWork,children:[jsxRuntime.jsx(Check,{className:"mr-2 h-4 w-4"}),"Get Started"]}),t.PartnerRegistrationLink&&jsxRuntime.jsx(Dialog,{open:o,onOpenChange:Ke=>{l(Ke)},children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[400px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:t.PublicName}),jsxRuntime.jsxs(DialogDescription,{children:[jsxRuntime.jsx("span",{className:"font-bold",children:"Already qualified?"})," Provide your Qualification ID."]})]}),jsxRuntime.jsxs("form",{onSubmit:ze,className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"qualificationId",children:"Qualification ID"}),jsxRuntime.jsx(Input,{id:"qualificationId",placeholder:"Enter your qualification ID",value:_,onChange:Ke=>{S(Ke.target.value),C("")}}),R&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:R})]}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button,{type:"submit",className:"w-full",disabled:g,children:g?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Applying..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Check,{className:"mr-2 h-4 w-4"}),"Apply for Qualification"]})})})]}),jsxRuntime.jsx(Separator$1,{className:"my-4"}),jsxRuntime.jsxs("div",{className:"text-center space-y-2",children:[jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Don't have a qualification ID?"}),jsxRuntime.jsx("a",{href:t.PartnerRegistrationLink,target:"_blank",rel:"noopener noreferrer",children:jsxRuntime.jsxs(Button,{variant:"outline",className:"w-full",disabled:!t.PartnerRegistrationLink,children:[jsxRuntime.jsx(ExternalLink,{className:"mr-2 h-4 w-4"}),"Register here"]})})]})]})}),jsxRuntime.jsx(Dialog,{open:d,onOpenChange:Ke=>{f(Ke)},children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[768px]",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Introduce Yourself"})}),jsxRuntime.jsxs("form",{onSubmit:Ue,className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs(Label$2,{htmlFor:"businessDescription",children:["Tell Us About Your Business ",jsxRuntime.jsx("span",{className:"text-sm text-muted-foreground",children:"(Briefly describe your business)"})]}),jsxRuntime.jsx(Textarea,{id:"businessDescription",placeholder:"We are an online retailer specializing in office supplies, serving businesses since 2018...",className:"min-h-[100px]",value:I,onChange:Ke=>{A(Ke.target.value),q("")}}),V&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:V})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs(Label$2,{children:["Sales Channel(s) ",jsxRuntime.jsx("span",{className:"text-sm text-muted-foreground",children:"(Multi-Select where you currently sell your products)"})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-2 gap-2",children:salesChannels.map(Ke=>jsxRuntime.jsxs("div",{className:"flex items-start space-x-2",children:[jsxRuntime.jsx(Checkbox,{id:`channel-${Ke.id}`,checked:z.includes(Ke.id),onCheckedChange:et=>Xe(Ke.id,et===!0)}),jsxRuntime.jsx(Label$2,{htmlFor:`channel-${Ke.id}`,className:"text-sm font-normal",children:Ke.label})]},Ke.id))}),Ye&&jsxRuntime.jsx(Input,{placeholder:"Please specify",value:te,onChange:Ke=>ae(Ke.target.value)}),F&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:F})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs(Label$2,{children:["Your Primary Market(s) ",jsxRuntime.jsx("span",{className:"text-sm text-muted-foreground",children:"(Multi-Select which regions you sell to)"})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-2 gap-2",children:markets.map(Ke=>jsxRuntime.jsxs("div",{className:"flex items-start space-x-2",children:[jsxRuntime.jsx(Checkbox,{id:`market-${Ke.id}`,checked:ie.includes(Ke.id),onCheckedChange:et=>Je(Ke.id,et===!0)}),jsxRuntime.jsx(Label$2,{htmlFor:`market-${Ke.id}`,className:"text-sm font-normal",children:Ke.label})]},Ke.id))}),it&&jsxRuntime.jsx(Input,{placeholder:"Please specify",value:Ne,onChange:Ke=>ge(Ke.target.value)}),se&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:se})]}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button,{type:"submit",disabled:E,children:E?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Submitting..."]}):"Submit"})})]})]})})]})}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$1=createPopperScope(),[SelectProvider,useSelectContext]=createSelectContext(SELECT_NAME),[SelectNativeOptionsProvider,useSelectNativeOptionsContext]=createSelectContext(SELECT_NAME),Select$1=e=>{const{__scopeSelect:t,children:n,open:o,defaultOpen:l,onOpenChange:d,value:f,defaultValue:g,onValueChange:b,dir:_,name:S,autoComplete:R,disabled:C,required:E,form:M}=e,I=usePopperScope$1(t),[A,V]=React__namespace.useState(null),[q,z]=React__namespace.useState(null),[Q,F]=React__namespace.useState(!1),O=useDirection(_),[te,ae]=useControllableState({prop:o,defaultProp:l??!1,onChange:d,caller:SELECT_NAME}),[ie,oe]=useControllableState({prop:f,defaultProp:g,onChange:b,caller:SELECT_NAME}),se=React__namespace.useRef(null),Ae=A?M||!!A.closest("form"):!0,[Ne,ge]=React__namespace.useState(new Set),Oe=Array.from(Ne).map(Le=>Le.props.value).join(";");return jsxRuntime.jsx(Root2$5,{...I,children:jsxRuntime.jsxs(SelectProvider,{required:E,scope:t,trigger:A,onTriggerChange:V,valueNode:q,onValueNodeChange:z,valueNodeHasChildren:Q,onValueNodeHasChildrenChange:F,contentId:useId(),value:ie,onValueChange:oe,open:te,onOpenChange:ae,dir:O,triggerPointerDownPosRef:se,disabled:C,children:[jsxRuntime.jsx(Collection.Provider,{scope:t,children:jsxRuntime.jsx(SelectNativeOptionsProvider,{scope:e.__scopeSelect,onNativeOptionAdd:React__namespace.useCallback(Le=>{ge(Ge=>new Set(Ge).add(Le))},[]),onNativeOptionRemove:React__namespace.useCallback(Le=>{ge(Ge=>{const je=new Set(Ge);return je.delete(Le),je})},[]),children:n})}),Ae?jsxRuntime.jsxs(SelectBubbleInput,{"aria-hidden":!0,required:E,tabIndex:-1,name:S,autoComplete:R,value:ie,onChange:Le=>oe(Le.target.value),disabled:C,form:M,children:[ie===void 0?jsxRuntime.jsx("option",{value:""}):null,Array.from(Ne)]},Oe):null]})})};Select$1.displayName=SELECT_NAME;var TRIGGER_NAME$1="SelectTrigger",SelectTrigger$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:o=!1,...l}=e,d=usePopperScope$1(n),f=useSelectContext(TRIGGER_NAME$1,n),g=f.disabled||o,b=useComposedRefs(t,f.onTriggerChange),_=useCollection(n),S=React__namespace.useRef("touch"),[R,C,E]=useTypeaheadSearch(I=>{const A=_().filter(z=>!z.disabled),V=A.find(z=>z.value===f.value),q=findNextItem(A,I,V);q!==void 0&&f.onValueChange(q.value)}),M=I=>{g||(f.onOpenChange(!0),E()),I&&(f.triggerPointerDownPosRef.current={x:Math.round(I.pageX),y:Math.round(I.pageY)})};return jsxRuntime.jsx(Anchor,{asChild:!0,...d,children:jsxRuntime.jsx(Primitive.button,{type:"button",role:"combobox","aria-controls":f.contentId,"aria-expanded":f.open,"aria-required":f.required,"aria-autocomplete":"none",dir:f.dir,"data-state":f.open?"open":"closed",disabled:g,"data-disabled":g?"":void 0,"data-placeholder":shouldShowPlaceholder(f.value)?"":void 0,...l,ref:b,onClick:composeEventHandlers(l.onClick,I=>{I.currentTarget.focus(),S.current!=="mouse"&&M(I)}),onPointerDown:composeEventHandlers(l.onPointerDown,I=>{S.current=I.pointerType;const A=I.target;A.hasPointerCapture(I.pointerId)&&A.releasePointerCapture(I.pointerId),I.button===0&&I.ctrlKey===!1&&I.pointerType==="mouse"&&(M(I),I.preventDefault())}),onKeyDown:composeEventHandlers(l.onKeyDown,I=>{const A=R.current!=="";!(I.ctrlKey||I.altKey||I.metaKey)&&I.key.length===1&&C(I.key),!(A&&I.key===" ")&&OPEN_KEYS.includes(I.key)&&(M(),I.preventDefault())})})})});SelectTrigger$1.displayName=TRIGGER_NAME$1;var VALUE_NAME="SelectValue",SelectValue$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,className:o,style:l,children:d,placeholder:f="",...g}=e,b=useSelectContext(VALUE_NAME,n),{onValueNodeHasChildrenChange:_}=b,S=d!==void 0,R=useComposedRefs(t,b.onValueNodeChange);return useLayoutEffect2(()=>{_(S)},[_,S]),jsxRuntime.jsx(Primitive.span,{...g,ref:R,style:{pointerEvents:"none"},children:shouldShowPlaceholder(b.value)?jsxRuntime.jsx(jsxRuntime.Fragment,{children:f}):d})});SelectValue$1.displayName=VALUE_NAME;var ICON_NAME="SelectIcon",SelectIcon=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,children:o,...l}=e;return jsxRuntime.jsx(Primitive.span,{"aria-hidden":!0,...l,ref:t,children:o||"▼"})});SelectIcon.displayName=ICON_NAME;var PORTAL_NAME$1="SelectPortal",SelectPortal=e=>jsxRuntime.jsx(Portal$5,{asChild:!0,...e});SelectPortal.displayName=PORTAL_NAME$1;var CONTENT_NAME$1="SelectContent",SelectContent$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContext(CONTENT_NAME$1,e.__scopeSelect),[o,l]=React__namespace.useState();if(useLayoutEffect2(()=>{l(new DocumentFragment)},[]),!n.open){const d=o;return d?ReactDOM__namespace.createPortal(jsxRuntime.jsx(SelectContentProvider,{scope:e.__scopeSelect,children:jsxRuntime.jsx(Collection.Slot,{scope:e.__scopeSelect,children:jsxRuntime.jsx("div",{children:e.children})})}),d):null}return jsxRuntime.jsx(SelectContentImpl,{...e,ref:t})});SelectContent$1.displayName=CONTENT_NAME$1;var CONTENT_MARGIN=10,[SelectContentProvider,useSelectContentContext]=createSelectContext(CONTENT_NAME$1),CONTENT_IMPL_NAME="SelectContentImpl",Slot$1=createSlot("SelectContent.RemoveScroll"),SelectContentImpl=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,position:o="item-aligned",onCloseAutoFocus:l,onEscapeKeyDown:d,onPointerDownOutside:f,side:g,sideOffset:b,align:_,alignOffset:S,arrowPadding:R,collisionBoundary:C,collisionPadding:E,sticky:M,hideWhenDetached:I,avoidCollisions:A,...V}=e,q=useSelectContext(CONTENT_NAME$1,n),[z,Q]=React__namespace.useState(null),[F,O]=React__namespace.useState(null),te=useComposedRefs(t,Ke=>Q(Ke)),[ae,ie]=React__namespace.useState(null),[oe,se]=React__namespace.useState(null),Ae=useCollection(n),[Ne,ge]=React__namespace.useState(!1),Oe=React__namespace.useRef(!1);React__namespace.useEffect(()=>{if(z)return hideOthers(z)},[z]),useFocusGuards();const Le=React__namespace.useCallback(Ke=>{const[et,...Ze]=Ae().map(Fe=>Fe.ref.current),[tt]=Ze.slice(-1),st=document.activeElement;for(const Fe of Ke)if(Fe===st||(Fe==null||Fe.scrollIntoView({block:"nearest"}),Fe===et&&F&&(F.scrollTop=0),Fe===tt&&F&&(F.scrollTop=F.scrollHeight),Fe==null||Fe.focus(),document.activeElement!==st))return},[Ae,F]),Ge=React__namespace.useCallback(()=>Le([ae,z]),[Le,ae,z]);React__namespace.useEffect(()=>{Ne&&Ge()},[Ne,Ge]);const{onOpenChange:je,triggerPointerDownPosRef:Be}=q;React__namespace.useEffect(()=>{if(z){let Ke={x:0,y:0};const et=tt=>{var st,Fe;Ke={x:Math.abs(Math.round(tt.pageX)-(((st=Be.current)==null?void 0:st.x)??0)),y:Math.abs(Math.round(tt.pageY)-(((Fe=Be.current)==null?void 0:Fe.y)??0))}},Ze=tt=>{Ke.x<=10&&Ke.y<=10?tt.preventDefault():z.contains(tt.target)||je(!1),document.removeEventListener("pointermove",et),Be.current=null};return Be.current!==null&&(document.addEventListener("pointermove",et),document.addEventListener("pointerup",Ze,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",et),document.removeEventListener("pointerup",Ze,{capture:!0})}}},[z,je,Be]),React__namespace.useEffect(()=>{const Ke=()=>je(!1);return window.addEventListener("blur",Ke),window.addEventListener("resize",Ke),()=>{window.removeEventListener("blur",Ke),window.removeEventListener("resize",Ke)}},[je]);const[qe,ze]=useTypeaheadSearch(Ke=>{const et=Ae().filter(st=>!st.disabled),Ze=et.find(st=>st.ref.current===document.activeElement),tt=findNextItem(et,Ke,Ze);tt&&setTimeout(()=>tt.ref.current.focus())}),Ue=React__namespace.useCallback((Ke,et,Ze)=>{const tt=!Oe.current&&!Ze;(q.value!==void 0&&q.value===et||tt)&&(ie(Ke),tt&&(Oe.current=!0))},[q.value]),Xe=React__namespace.useCallback(()=>z==null?void 0:z.focus(),[z]),Je=React__namespace.useCallback((Ke,et,Ze)=>{const tt=!Oe.current&&!Ze;(q.value!==void 0&&q.value===et||tt)&&se(Ke)},[q.value]),Ye=o==="popper"?SelectPopperPosition:SelectItemAlignedPosition,it=Ye===SelectPopperPosition?{side:g,sideOffset:b,align:_,alignOffset:S,arrowPadding:R,collisionBoundary:C,collisionPadding:E,sticky:M,hideWhenDetached:I,avoidCollisions:A}:{};return jsxRuntime.jsx(SelectContentProvider,{scope:n,content:z,viewport:F,onViewportChange:O,itemRefCallback:Ue,selectedItem:ae,onItemLeave:Xe,itemTextRefCallback:Je,focusSelectedItem:Ge,selectedItemText:oe,position:o,isPositioned:Ne,searchRef:qe,children:jsxRuntime.jsx(ReactRemoveScroll,{as:Slot$1,allowPinchZoom:!0,children:jsxRuntime.jsx(FocusScope,{asChild:!0,trapped:q.open,onMountAutoFocus:Ke=>{Ke.preventDefault()},onUnmountAutoFocus:composeEventHandlers(l,Ke=>{var et;(et=q.trigger)==null||et.focus({preventScroll:!0}),Ke.preventDefault()}),children:jsxRuntime.jsx(DismissableLayer,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:Ke=>Ke.preventDefault(),onDismiss:()=>q.onOpenChange(!1),children:jsxRuntime.jsx(Ye,{role:"listbox",id:q.contentId,"data-state":q.open?"open":"closed",dir:q.dir,onContextMenu:Ke=>Ke.preventDefault(),...V,...it,onPlaced:()=>ge(!0),ref:te,style:{display:"flex",flexDirection:"column",outline:"none",...V.style},onKeyDown:composeEventHandlers(V.onKeyDown,Ke=>{const et=Ke.ctrlKey||Ke.altKey||Ke.metaKey;if(Ke.key==="Tab"&&Ke.preventDefault(),!et&&Ke.key.length===1&&ze(Ke.key),["ArrowUp","ArrowDown","Home","End"].includes(Ke.key)){let tt=Ae().filter(st=>!st.disabled).map(st=>st.ref.current);if(["ArrowUp","End"].includes(Ke.key)&&(tt=tt.slice().reverse()),["ArrowUp","ArrowDown"].includes(Ke.key)){const st=Ke.target,Fe=tt.indexOf(st);tt=tt.slice(Fe+1)}setTimeout(()=>Le(tt)),Ke.preventDefault()}})})})})})})});SelectContentImpl.displayName=CONTENT_IMPL_NAME;var ITEM_ALIGNED_POSITION_NAME="SelectItemAlignedPosition",SelectItemAlignedPosition=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:o,...l}=e,d=useSelectContext(CONTENT_NAME$1,n),f=useSelectContentContext(CONTENT_NAME$1,n),[g,b]=React__namespace.useState(null),[_,S]=React__namespace.useState(null),R=useComposedRefs(t,te=>S(te)),C=useCollection(n),E=React__namespace.useRef(!1),M=React__namespace.useRef(!0),{viewport:I,selectedItem:A,selectedItemText:V,focusSelectedItem:q}=f,z=React__namespace.useCallback(()=>{if(d.trigger&&d.valueNode&&g&&_&&I&&A&&V){const te=d.trigger.getBoundingClientRect(),ae=_.getBoundingClientRect(),ie=d.valueNode.getBoundingClientRect(),oe=V.getBoundingClientRect();if(d.dir!=="rtl"){const st=oe.left-ae.left,Fe=ie.left-st,ct=te.left-Fe,Qe=te.width+ct,nt=Math.max(Qe,ae.width),ut=window.innerWidth-CONTENT_MARGIN,ft=clamp(Fe,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,ut-nt)]);g.style.minWidth=Qe+"px",g.style.left=ft+"px"}else{const st=ae.right-oe.right,Fe=window.innerWidth-ie.right-st,ct=window.innerWidth-te.right-Fe,Qe=te.width+ct,nt=Math.max(Qe,ae.width),ut=window.innerWidth-CONTENT_MARGIN,ft=clamp(Fe,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,ut-nt)]);g.style.minWidth=Qe+"px",g.style.right=ft+"px"}const se=C(),Ae=window.innerHeight-CONTENT_MARGIN*2,Ne=I.scrollHeight,ge=window.getComputedStyle(_),Oe=parseInt(ge.borderTopWidth,10),Le=parseInt(ge.paddingTop,10),Ge=parseInt(ge.borderBottomWidth,10),je=parseInt(ge.paddingBottom,10),Be=Oe+Le+Ne+je+Ge,qe=Math.min(A.offsetHeight*5,Be),ze=window.getComputedStyle(I),Ue=parseInt(ze.paddingTop,10),Xe=parseInt(ze.paddingBottom,10),Je=te.top+te.height/2-CONTENT_MARGIN,Ye=Ae-Je,it=A.offsetHeight/2,Ke=A.offsetTop+it,et=Oe+Le+Ke,Ze=Be-et;if(et<=Je){const st=se.length>0&&A===se[se.length-1].ref.current;g.style.bottom="0px";const Fe=_.clientHeight-I.offsetTop-I.offsetHeight,ct=Math.max(Ye,it+(st?Xe:0)+Fe+Ge),Qe=et+ct;g.style.height=Qe+"px"}else{const st=se.length>0&&A===se[0].ref.current;g.style.top="0px";const ct=Math.max(Je,Oe+I.offsetTop+(st?Ue:0)+it)+Ze;g.style.height=ct+"px",I.scrollTop=et-Je+I.offsetTop}g.style.margin=`${CONTENT_MARGIN}px 0`,g.style.minHeight=qe+"px",g.style.maxHeight=Ae+"px",o==null||o(),requestAnimationFrame(()=>E.current=!0)}},[C,d.trigger,d.valueNode,g,_,I,A,V,d.dir,o]);useLayoutEffect2(()=>z(),[z]);const[Q,F]=React__namespace.useState();useLayoutEffect2(()=>{_&&F(window.getComputedStyle(_).zIndex)},[_]);const O=React__namespace.useCallback(te=>{te&&M.current===!0&&(z(),q==null||q(),M.current=!1)},[z,q]);return jsxRuntime.jsx(SelectViewportProvider,{scope:n,contentWrapper:g,shouldExpandOnScrollRef:E,onScrollButtonChange:O,children:jsxRuntime.jsx("div",{ref:b,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:Q},children:jsxRuntime.jsx(Primitive.div,{...l,ref:R,style:{boxSizing:"border-box",maxHeight:"100%",...l.style}})})})});SelectItemAlignedPosition.displayName=ITEM_ALIGNED_POSITION_NAME;var POPPER_POSITION_NAME="SelectPopperPosition",SelectPopperPosition=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,align:o="start",collisionPadding:l=CONTENT_MARGIN,...d}=e,f=usePopperScope$1(n);return jsxRuntime.jsx(Content$1,{...f,...d,ref:t,align:o,collisionPadding:l,style:{boxSizing:"border-box",...d.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$1,{}),VIEWPORT_NAME="SelectViewport",SelectViewport=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:o,...l}=e,d=useSelectContentContext(VIEWPORT_NAME,n),f=useSelectViewportContext(VIEWPORT_NAME,n),g=useComposedRefs(t,d.onViewportChange),b=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:o}),jsxRuntime.jsx(Collection.Slot,{scope:n,children:jsxRuntime.jsx(Primitive.div,{"data-radix-select-viewport":"",role:"presentation",...l,ref:g,style:{position:"relative",flex:1,overflow:"hidden auto",...l.style},onScroll:composeEventHandlers(l.onScroll,_=>{const S=_.currentTarget,{contentWrapper:R,shouldExpandOnScrollRef:C}=f;if(C!=null&&C.current&&R){const E=Math.abs(b.current-S.scrollTop);if(E>0){const M=window.innerHeight-CONTENT_MARGIN*2,I=parseFloat(R.style.minHeight),A=parseFloat(R.style.height),V=Math.max(I,A);if(V<M){const q=V+E,z=Math.min(M,q),Q=q-z;R.style.height=z+"px",R.style.bottom==="0px"&&(S.scrollTop=Q>0?Q:0,R.style.justifyContent="flex-end")}}}b.current=S.scrollTop})})})]})});SelectViewport.displayName=VIEWPORT_NAME;var GROUP_NAME="SelectGroup",[SelectGroupContextProvider,useSelectGroupContext]=createSelectContext(GROUP_NAME),SelectGroup$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e,l=useId();return jsxRuntime.jsx(SelectGroupContextProvider,{scope:n,id:l,children:jsxRuntime.jsx(Primitive.div,{role:"group","aria-labelledby":l,...o,ref:t})})});SelectGroup$1.displayName=GROUP_NAME;var LABEL_NAME="SelectLabel",SelectLabel$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e,l=useSelectGroupContext(LABEL_NAME,n);return jsxRuntime.jsx(Primitive.div,{id:l.id,...o,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:o,disabled:l=!1,textValue:d,...f}=e,g=useSelectContext(ITEM_NAME,n),b=useSelectContentContext(ITEM_NAME,n),_=g.value===o,[S,R]=React__namespace.useState(d??""),[C,E]=React__namespace.useState(!1),M=useComposedRefs(t,q=>{var z;return(z=b.itemRefCallback)==null?void 0:z.call(b,q,o,l)}),I=useId(),A=React__namespace.useRef("touch"),V=()=>{l||(g.onValueChange(o),g.onOpenChange(!1))};if(o==="")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:o,disabled:l,textId:I,isSelected:_,onItemTextChange:React__namespace.useCallback(q=>{R(z=>z||((q==null?void 0:q.textContent)??"").trim())},[]),children:jsxRuntime.jsx(Collection.ItemSlot,{scope:n,value:o,disabled:l,textValue:S,children:jsxRuntime.jsx(Primitive.div,{role:"option","aria-labelledby":I,"data-highlighted":C?"":void 0,"aria-selected":_&&C,"data-state":_?"checked":"unchecked","aria-disabled":l||void 0,"data-disabled":l?"":void 0,tabIndex:l?void 0:-1,...f,ref:M,onFocus:composeEventHandlers(f.onFocus,()=>E(!0)),onBlur:composeEventHandlers(f.onBlur,()=>E(!1)),onClick:composeEventHandlers(f.onClick,()=>{A.current!=="mouse"&&V()}),onPointerUp:composeEventHandlers(f.onPointerUp,()=>{A.current==="mouse"&&V()}),onPointerDown:composeEventHandlers(f.onPointerDown,q=>{A.current=q.pointerType}),onPointerMove:composeEventHandlers(f.onPointerMove,q=>{var z;A.current=q.pointerType,l?(z=b.onItemLeave)==null||z.call(b):A.current==="mouse"&&q.currentTarget.focus({preventScroll:!0})}),onPointerLeave:composeEventHandlers(f.onPointerLeave,q=>{var z;q.currentTarget===document.activeElement&&((z=b.onItemLeave)==null||z.call(b))}),onKeyDown:composeEventHandlers(f.onKeyDown,q=>{var Q;((Q=b.searchRef)==null?void 0:Q.current)!==""&&q.key===" "||(SELECTION_KEYS.includes(q.key)&&V(),q.key===" "&&q.preventDefault())})})})})});SelectItem$1.displayName=ITEM_NAME;var ITEM_TEXT_NAME="SelectItemText",SelectItemText=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,className:o,style:l,...d}=e,f=useSelectContext(ITEM_TEXT_NAME,n),g=useSelectContentContext(ITEM_TEXT_NAME,n),b=useSelectItemContext(ITEM_TEXT_NAME,n),_=useSelectNativeOptionsContext(ITEM_TEXT_NAME,n),[S,R]=React__namespace.useState(null),C=useComposedRefs(t,V=>R(V),b.onItemTextChange,V=>{var q;return(q=g.itemTextRefCallback)==null?void 0:q.call(g,V,b.value,b.disabled)}),E=S==null?void 0:S.textContent,M=React__namespace.useMemo(()=>jsxRuntime.jsx("option",{value:b.value,disabled:b.disabled,children:E},b.value),[b.disabled,b.value,E]),{onNativeOptionAdd:I,onNativeOptionRemove:A}=_;return useLayoutEffect2(()=>(I(M),()=>A(M)),[I,A,M]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Primitive.span,{id:b.textId,...d,ref:C}),b.isSelected&&f.valueNode&&!f.valueNodeHasChildren?ReactDOM__namespace.createPortal(d.children,f.valueNode):null]})});SelectItemText.displayName=ITEM_TEXT_NAME;var ITEM_INDICATOR_NAME="SelectItemIndicator",SelectItemIndicator=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e;return useSelectItemContext(ITEM_INDICATOR_NAME,n).isSelected?jsxRuntime.jsx(Primitive.span,{"aria-hidden":!0,...o,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),o=useSelectViewportContext(SCROLL_UP_BUTTON_NAME,e.__scopeSelect),[l,d]=React__namespace.useState(!1),f=useComposedRefs(t,o.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let g=function(){const _=b.scrollTop>0;d(_)};const b=n.viewport;return g(),b.addEventListener("scroll",g),()=>b.removeEventListener("scroll",g)}},[n.viewport,n.isPositioned]),l?jsxRuntime.jsx(SelectScrollButtonImpl,{...e,ref:f,onAutoScroll:()=>{const{viewport:g,selectedItem:b}=n;g&&b&&(g.scrollTop=g.scrollTop-b.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),o=useSelectViewportContext(SCROLL_DOWN_BUTTON_NAME,e.__scopeSelect),[l,d]=React__namespace.useState(!1),f=useComposedRefs(t,o.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let g=function(){const _=b.scrollHeight-b.clientHeight,S=Math.ceil(b.scrollTop)<_;d(S)};const b=n.viewport;return g(),b.addEventListener("scroll",g),()=>b.removeEventListener("scroll",g)}},[n.viewport,n.isPositioned]),l?jsxRuntime.jsx(SelectScrollButtonImpl,{...e,ref:f,onAutoScroll:()=>{const{viewport:g,selectedItem:b}=n;g&&b&&(g.scrollTop=g.scrollTop+b.offsetHeight)}}):null});SelectScrollDownButton$1.displayName=SCROLL_DOWN_BUTTON_NAME;var SelectScrollButtonImpl=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:o,...l}=e,d=useSelectContentContext("SelectScrollButton",n),f=React__namespace.useRef(null),g=useCollection(n),b=React__namespace.useCallback(()=>{f.current!==null&&(window.clearInterval(f.current),f.current=null)},[]);return React__namespace.useEffect(()=>()=>b(),[b]),useLayoutEffect2(()=>{var S;const _=g().find(R=>R.ref.current===document.activeElement);(S=_==null?void 0:_.ref.current)==null||S.scrollIntoView({block:"nearest"})},[g]),jsxRuntime.jsx(Primitive.div,{"aria-hidden":!0,...l,ref:t,style:{flexShrink:0,...l.style},onPointerDown:composeEventHandlers(l.onPointerDown,()=>{f.current===null&&(f.current=window.setInterval(o,50))}),onPointerMove:composeEventHandlers(l.onPointerMove,()=>{var _;(_=d.onItemLeave)==null||_.call(d),f.current===null&&(f.current=window.setInterval(o,50))}),onPointerLeave:composeEventHandlers(l.onPointerLeave,()=>{b()})})}),SEPARATOR_NAME="SelectSeparator",SelectSeparator$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e;return jsxRuntime.jsx(Primitive.div,{"aria-hidden":!0,...o,ref:t})});SelectSeparator$1.displayName=SEPARATOR_NAME;var ARROW_NAME$1="SelectArrow",SelectArrow=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e,l=usePopperScope$1(n),d=useSelectContext(ARROW_NAME$1,n),f=useSelectContentContext(ARROW_NAME$1,n);return d.open&&f.position==="popper"?jsxRuntime.jsx(Arrow,{...l,...o,ref:t}):null});SelectArrow.displayName=ARROW_NAME$1;var BUBBLE_INPUT_NAME="SelectBubbleInput",SelectBubbleInput=React__namespace.forwardRef(({__scopeSelect:e,value:t,...n},o)=>{const l=React__namespace.useRef(null),d=useComposedRefs(o,l),f=usePrevious(t);return React__namespace.useEffect(()=>{const g=l.current;if(!g)return;const b=window.HTMLSelectElement.prototype,S=Object.getOwnPropertyDescriptor(b,"value").set;if(f!==t&&S){const R=new Event("change",{bubbles:!0});S.call(g,t),g.dispatchEvent(R)}},[f,t]),jsxRuntime.jsx(Primitive.select,{...n,style:{...VISUALLY_HIDDEN_STYLES,...n.style},ref:d,defaultValue:t})});SelectBubbleInput.displayName=BUBBLE_INPUT_NAME;function shouldShowPlaceholder(e){return e===""||e===void 0}function useTypeaheadSearch(e){const t=useCallbackRef$1(e),n=React__namespace.useRef(""),o=React__namespace.useRef(0),l=React__namespace.useCallback(f=>{const g=n.current+f;t(g),function b(_){n.current=_,window.clearTimeout(o.current),_!==""&&(o.current=window.setTimeout(()=>b(""),1e3))}(g)},[t]),d=React__namespace.useCallback(()=>{n.current="",window.clearTimeout(o.current)},[]);return React__namespace.useEffect(()=>()=>window.clearTimeout(o.current),[]),[n,l,d]}function findNextItem(e,t,n){const l=t.length>1&&Array.from(t).every(_=>_===t[0])?t[0]:t,d=n?e.indexOf(n):-1;let f=wrapArray(e,Math.max(d,0));l.length===1&&(f=f.filter(_=>_!==n));const b=f.find(_=>_.textValue.toLowerCase().startsWith(l.toLowerCase()));return b!==n?b:void 0}function wrapArray(e,t){return e.map((n,o)=>e[(t+o)%e.length])}var Root2$1=Select$1,Trigger$1=SelectTrigger$1,Value=SelectValue$1,Icon=SelectIcon,Portal$1=SelectPortal,Content2$1=SelectContent$1,Viewport=SelectViewport,Group=SelectGroup$1,Label=SelectLabel$1,Item=SelectItem$1,ItemText=SelectItemText,ItemIndicator=SelectItemIndicator,ScrollUpButton=SelectScrollUpButton$1,ScrollDownButton=SelectScrollDownButton$1,Separator=SelectSeparator$1;const Select=Root2$1,SelectGroup=Group,SelectValue=Value,SelectTrigger=React__namespace.forwardRef(({className:e,children:t,...n},o)=>jsxRuntime.jsxs(Trigger$1,{ref:o,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$1.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",...o},l)=>jsxRuntime.jsx(Portal$1,{children:jsxRuntime.jsxs(Content2$1,{ref:l,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,...o,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$1.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},o)=>jsxRuntime.jsxs(Item,{ref:o,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;const DAYS_OF_WEEK=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function ManufacturerReorderingCard({manufacturer:e,onSave:t,loading:n=!1,saving:o=!1}){const[l,d]=React.useState({...e}),f=(C,E)=>{d(M=>({...M,[C]:E}))},g=(C,E)=>{d(M=>({...M,[C]:E}))},b=(C,E)=>{d(M=>({...M,[C]:E}))},_=()=>{o||t(l)},S=C=>C===-1?"ASAP":C===void 0||C<0||C>6?"Sunday":DAYS_OF_WEEK[C],R=C=>C==="ASAP"?-1:DAYS_OF_WEEK.indexOf(C);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-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.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:l.AutoUpdate,onCheckedChange:C=>f("AutoUpdate",C),disabled:o}),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:S(l.AutoReorderDate),onValueChange:C=>g("AutoReorderDate",R(C)),disabled:o,children:[jsxRuntime.jsx(SelectTrigger,{id:"reorder-date",children:jsxRuntime.jsx(SelectValue,{placeholder:"Select day"})}),jsxRuntime.jsxs(SelectContent,{children:[jsxRuntime.jsx(SelectItem,{value:"ASAP",children:"ASAP"}),DAYS_OF_WEEK.map(C=>jsxRuntime.jsx(SelectItem,{value:C,children:C},C))]})]})]}),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:l.DefaultWeeksOfStocking||"",onChange:C=>g("DefaultWeeksOfStocking",Number(C.target.value)),disabled:o}),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:l.DefaultMinimumOrder||"",onChange:C=>g("DefaultMinimumOrder",Number(C.target.value)),disabled:o})]})]}),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:l.DefaultLeadTime||"",onChange:C=>g("DefaultLeadTime",Number(C.target.value)),disabled:o}),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:"maximum-inventory-value",children:"Default Maximum Inventory Value"}),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:"maximum-inventory-value",type:"number",className:"pl-6",value:l.DefaultMaxInventoryValue||"",onChange:C=>g("DefaultMaxInventoryValue",Number(C.target.value)),disabled:o})]})]}),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:l.POEmail||"",onChange:C=>b("POEmail",C.target.value),placeholder:"email@example.com",disabled:o})]})]})]})}),jsxRuntime.jsx(CardFooter,{className:"flex justify-end",children:n?jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"}):jsxRuntime.jsxs(Button,{onClick:_,disabled:o,children:[o&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]})})]})}var POPOVER_NAME="Popover",[createPopoverContext,createPopoverScope]=createContextScope(POPOVER_NAME,[createPopperScope]),usePopperScope=createPopperScope(),[PopoverProvider,usePopoverContext]=createPopoverContext(POPOVER_NAME),Popover$1=e=>{const{__scopePopover:t,children:n,open:o,defaultOpen:l,onOpenChange:d,modal:f=!1}=e,g=usePopperScope(t),b=React__namespace.useRef(null),[_,S]=React__namespace.useState(!1),[R,C]=useControllableState({prop:o,defaultProp:l??!1,onChange:d,caller:POPOVER_NAME});return jsxRuntime.jsx(Root2$5,{...g,children:jsxRuntime.jsx(PopoverProvider,{scope:t,contentId:useId(),triggerRef:b,open:R,onOpenChange:C,onOpenToggle:React__namespace.useCallback(()=>C(E=>!E),[C]),hasCustomAnchor:_,onCustomAnchorAdd:React__namespace.useCallback(()=>S(!0),[]),onCustomAnchorRemove:React__namespace.useCallback(()=>S(!1),[]),modal:f,children:n})})};Popover$1.displayName=POPOVER_NAME;var ANCHOR_NAME="PopoverAnchor",PopoverAnchor$1=React__namespace.forwardRef((e,t)=>{const{__scopePopover:n,...o}=e,l=usePopoverContext(ANCHOR_NAME,n),d=usePopperScope(n),{onCustomAnchorAdd:f,onCustomAnchorRemove:g}=l;return React__namespace.useEffect(()=>(f(),()=>g()),[f,g]),jsxRuntime.jsx(Anchor,{...d,...o,ref:t})});PopoverAnchor$1.displayName=ANCHOR_NAME;var TRIGGER_NAME="PopoverTrigger",PopoverTrigger$1=React__namespace.forwardRef((e,t)=>{const{__scopePopover:n,...o}=e,l=usePopoverContext(TRIGGER_NAME,n),d=usePopperScope(n),f=useComposedRefs(t,l.triggerRef),g=jsxRuntime.jsx(Primitive.button,{type:"button","aria-haspopup":"dialog","aria-expanded":l.open,"aria-controls":l.contentId,"data-state":getState(l.open),...o,ref:f,onClick:composeEventHandlers(e.onClick,l.onOpenToggle)});return l.hasCustomAnchor?g:jsxRuntime.jsx(Anchor,{asChild:!0,...d,children:g})});PopoverTrigger$1.displayName=TRIGGER_NAME;var PORTAL_NAME="PopoverPortal",[PortalProvider,usePortalContext]=createPopoverContext(PORTAL_NAME,{forceMount:void 0}),PopoverPortal=e=>{const{__scopePopover:t,forceMount:n,children:o,container:l}=e,d=usePopoverContext(PORTAL_NAME,t);return jsxRuntime.jsx(PortalProvider,{scope:t,forceMount:n,children:jsxRuntime.jsx(Presence,{present:n||d.open,children:jsxRuntime.jsx(Portal$5,{asChild:!0,container:l,children:o})})})};PopoverPortal.displayName=PORTAL_NAME;var CONTENT_NAME="PopoverContent",PopoverContent$1=React__namespace.forwardRef((e,t)=>{const n=usePortalContext(CONTENT_NAME,e.__scopePopover),{forceMount:o=n.forceMount,...l}=e,d=usePopoverContext(CONTENT_NAME,e.__scopePopover);return jsxRuntime.jsx(Presence,{present:o||d.open,children:d.modal?jsxRuntime.jsx(PopoverContentModal,{...l,ref:t}):jsxRuntime.jsx(PopoverContentNonModal,{...l,ref:t})})});PopoverContent$1.displayName=CONTENT_NAME;var Slot=createSlot("PopoverContent.RemoveScroll"),PopoverContentModal=React__namespace.forwardRef((e,t)=>{const n=usePopoverContext(CONTENT_NAME,e.__scopePopover),o=React__namespace.useRef(null),l=useComposedRefs(t,o),d=React__namespace.useRef(!1);return React__namespace.useEffect(()=>{const f=o.current;if(f)return hideOthers(f)},[]),jsxRuntime.jsx(ReactRemoveScroll,{as:Slot,allowPinchZoom:!0,children:jsxRuntime.jsx(PopoverContentImpl,{...e,ref:l,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:composeEventHandlers(e.onCloseAutoFocus,f=>{var g;f.preventDefault(),d.current||(g=n.triggerRef.current)==null||g.focus()}),onPointerDownOutside:composeEventHandlers(e.onPointerDownOutside,f=>{const g=f.detail.originalEvent,b=g.button===0&&g.ctrlKey===!0,_=g.button===2||b;d.current=_},{checkForDefaultPrevented:!1}),onFocusOutside:composeEventHandlers(e.onFocusOutside,f=>f.preventDefault(),{checkForDefaultPrevented:!1})})})}),PopoverContentNonModal=React__namespace.forwardRef((e,t)=>{const n=usePopoverContext(CONTENT_NAME,e.__scopePopover),o=React__namespace.useRef(!1),l=React__namespace.useRef(!1);return jsxRuntime.jsx(PopoverContentImpl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:d=>{var f,g;(f=e.onCloseAutoFocus)==null||f.call(e,d),d.defaultPrevented||(o.current||(g=n.triggerRef.current)==null||g.focus(),d.preventDefault()),o.current=!1,l.current=!1},onInteractOutside:d=>{var b,_;(b=e.onInteractOutside)==null||b.call(e,d),d.defaultPrevented||(o.current=!0,d.detail.originalEvent.type==="pointerdown"&&(l.current=!0));const f=d.target;((_=n.triggerRef.current)==null?void 0:_.contains(f))&&d.preventDefault(),d.detail.originalEvent.type==="focusin"&&l.current&&d.preventDefault()}})}),PopoverContentImpl=React__namespace.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:o,onOpenAutoFocus:l,onCloseAutoFocus:d,disableOutsidePointerEvents:f,onEscapeKeyDown:g,onPointerDownOutside:b,onFocusOutside:_,onInteractOutside:S,...R}=e,C=usePopoverContext(CONTENT_NAME,n),E=usePopperScope(n);return useFocusGuards(),jsxRuntime.jsx(FocusScope,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:l,onUnmountAutoFocus:d,children:jsxRuntime.jsx(DismissableLayer,{asChild:!0,disableOutsidePointerEvents:f,onInteractOutside:S,onEscapeKeyDown:g,onPointerDownOutside:b,onFocusOutside:_,onDismiss:()=>C.onOpenChange(!1),children:jsxRuntime.jsx(Content$1,{"data-state":getState(C.open),role:"dialog",id:C.contentId,...E,...R,ref:t,style:{...R.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),CLOSE_NAME="PopoverClose",PopoverClose=React__namespace.forwardRef((e,t)=>{const{__scopePopover:n,...o}=e,l=usePopoverContext(CLOSE_NAME,n);return jsxRuntime.jsx(Primitive.button,{type:"button",...o,ref:t,onClick:composeEventHandlers(e.onClick,()=>l.onOpenChange(!1))})});PopoverClose.displayName=CLOSE_NAME;var ARROW_NAME="PopoverArrow",PopoverArrow=React__namespace.forwardRef((e,t)=>{const{__scopePopover:n,...o}=e,l=usePopperScope(n);return jsxRuntime.jsx(Arrow,{...l,...o,ref:t})});PopoverArrow.displayName=ARROW_NAME;function getState(e){return e?"open":"closed"}var Root2=Popover$1,Anchor2=PopoverAnchor$1,Trigger=PopoverTrigger$1,Portal=PopoverPortal,Content2=PopoverContent$1;const Popover=Root2,PopoverTrigger=Trigger,PopoverAnchor=Anchor2,PopoverContent=React__namespace.forwardRef(({className:e,align:t="center",sideOffset:n=4,...o},l)=>jsxRuntime.jsx(Portal,{children:jsxRuntime.jsx(Content2,{ref:l,align:t,sideOffset:n,className:cn("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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-popover-content-transform-origin]",e),...o})}));PopoverContent.displayName=Content2.displayName;function MultiSelect({options:e,selected:t,onChange:n,placeholder:o="Select items..."}){const[l,d]=React__namespace.useState(!1),[f,g]=React__namespace.useState(""),b=React__namespace.useRef(null),[_,S]=React__namespace.useState(void 0),R=React__namespace.useCallback(()=>{b.current&&S(b.current.offsetWidth)},[]);React__namespace.useLayoutEffect(()=>{R()},[R]),React__namespace.useEffect(()=>(window.addEventListener("resize",R),()=>window.removeEventListener("resize",R)),[R]);const C=I=>{n(t.filter(A=>A!==I))},E=I=>{d(!1),t.includes(I)?n(t.filter(A=>A!==I)):n([...t,I])},M=I=>{I.key==="Enter"&&f&&!e.includes(f)&&!t.includes(f)&&(I.preventDefault(),E(f),g(""))};return jsxRuntime.jsxs(Popover,{open:l,onOpenChange:d,children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{ref:b,variant:"outline",role:"combobox","aria-expanded":l,className:"w-full justify-between h-auto min-h-[40px] py-2",children:[jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1 items-center",children:t.length>0?t.map(I=>jsxRuntime.jsxs(Badge,{variant:"outline",className:"mr-1 mb-1",children:[I,jsxRuntime.jsx("span",{className:"ml-1 cursor-pointer ring-offset-background rounded-full outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2",onClick:A=>{A.preventDefault(),A.stopPropagation(),C(I)},children:jsxRuntime.jsx(X$1,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},I)):jsxRuntime.jsx("span",{className:"text-muted-foreground",children:o})}),jsxRuntime.jsx(ChevronsUpDown,{className:"h-4 w-4 shrink-0 opacity-50 ml-2"})]})}),jsxRuntime.jsx(PopoverContent,{className:"w-full p-0",style:{width:_},children:jsxRuntime.jsxs(Command,{onKeyDown:M,children:[jsxRuntime.jsx(CommandInput,{placeholder:"Search or add custom item...",value:f,onValueChange:g}),jsxRuntime.jsxs(CommandList,{children:[jsxRuntime.jsx(CommandEmpty,{children:"No item found."}),jsxRuntime.jsxs(CommandGroup,{children:[e.filter(I=>!t.includes(I)).map(I=>jsxRuntime.jsxs(CommandItem,{onSelect:()=>E(I),children:[jsxRuntime.jsx(Check,{className:cn("mr-2 h-4 w-4",t.includes(I)?"opacity-100":"opacity-0")}),I]},I)),f&&!e.includes(f)&&!t.includes(f)&&jsxRuntime.jsxs(CommandItem,{onSelect:()=>E(f),children:['Add "',f,'"']})]})]})]})})]})}function ResellerBillingOverviewCard({reseller:e,actions:t,loading:n=!1}){return n||!e?jsxRuntime.jsx(ResellerBillingOverviewSkeleton,{}):jsxRuntime.jsx(ResellerBillingOverviewData,{reseller:e,actions:t})}function ResellerBillingOverviewSkeleton(){return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-40"})})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[jsxRuntime.jsx("div",{className:"space-y-4",children:Array(3).fill(0).map((e,t)=>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"})]})]},t))}),jsxRuntime.jsx("div",{className:"space-y-4",children:Array(2).fill(0).map((e,t)=>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"})]})]},t))})]}),jsxRuntime.jsx("div",{className:"flex justify-end mt-4",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-28 rounded-md"})})]})]})}function ResellerBillingOverviewData({reseller:e,actions:t}){const n=f=>f===void 0?"$0.00":new Intl.NumberFormat("en-CA",{style:"currency",currency:"CAD",minimumFractionDigits:2,maximumFractionDigits:2}).format(f),o=e.Statement||{},l=[{title:"0 - 30 Days",amount:o.Over0||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-primary"},{title:"31 - 45 Days",amount:o.Over30||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-primary"},{title:"45+ Days",amount:o.Over45||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-primary"}],d=[{title:"Total",amount:o.Total||0,icon:jsxRuntime.jsx(DollarSign,{className:"h-5 w-5 text-white"}),color:"bg-green-500"},{title:"Credit Limit",amount:e.CreditLimit||0,icon:jsxRuntime.jsx(CreditCard,{className:"h-5 w-5 text-white"}),color:"bg-blue-500"}];return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Billing Overview"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[jsxRuntime.jsx("div",{className:"space-y-4",children:l.map((f,g)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center",children:[jsxRuntime.jsx("h3",{className:"text-sm sm:text-base font-medium",children:f.title}),jsxRuntime.jsx("div",{className:`p-2 rounded-full ${f.color}`,children:f.icon})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("p",{className:"text-base sm:text-lg font-bold",children:n(f.amount)})})]},g))}),jsxRuntime.jsx("div",{className:"space-y-4",children:d.map((f,g)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center",children:[jsxRuntime.jsx("h3",{className:"text-sm sm:text-base font-medium",children:f.title}),jsxRuntime.jsx("div",{className:`p-2 rounded-full ${f.color}`,children:f.icon})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("p",{className:"text-base sm:text-lg font-bold",children:n(f.amount)})})]},g))})]}),t&&jsxRuntime.jsx("div",{className:"flex justify-end mt-4",children:t})]})]})}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,o)=>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"})]},o))})})]}):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,o)=>jsxRuntime.jsx(ManufacturerLogo,{manufacturerId:n.ManufacturerId,opportunityNumber:n.DefaultOpportunityNumber},`${n.ManufacturerId}-${o}`))})})]})}function ManufacturerLogo({manufacturerId:e,opportunityNumber:t}){const[n,o]=React.useState(null),[l,d]=React.useState(!0),[f,g]=React.useState(!1),[b,_]=React.useState(null),S=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(!S)return;let R=!0;_(null);const C=async()=>{try{const I=await fetch(S.logoExistsUrl);if(I.ok){const V=(await I.text()).toLowerCase()==="true";return R&&g(V),V}return!1}catch(I){return console.error("Failed to check if logo exists:",I),R&&g(!1),!1}},E=async()=>{R&&d(!0);try{const I=await fetch(S.logoUrl);if(I.ok){const A=await I.blob();R&&(n&&URL.revokeObjectURL(n),o(URL.createObjectURL(A)))}else throw new Error(`Failed to load logo: ${I.status}`)}catch(I){console.error("Failed to load logo:",I),R&&_("Failed to load manufacturer logo")}finally{R&&d(!1)}};return(async()=>{await C()?E():d(!1)})(),()=>{R=!1,n&&URL.revokeObjectURL(n)}},[S]),jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx("div",{className:"h-12 flex items-center justify-center mb-2",children:l?jsxRuntime.jsx(Skeleton,{className:"h-12 w-24 rounded-md"}):f&&n?jsxRuntime.jsx("img",{src:n,alt:"Manufacturer logo",className:"max-h-12 max-w-24 object-contain",onError:()=>_("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}),b&&jsxRuntime.jsx("div",{className:"text-red-500 text-xs mt-1",role:"alert",children:b})]})}function SalesOverviewCard({salesData:e,salesStatistics:t=[],loading:n=!1}){return n||!e?jsxRuntime.jsx(SalesOverviewSkeleton,{}):jsxRuntime.jsx(SalesOverviewData,{salesData:e,salesStatistics:t})}function SalesOverviewSkeleton(){return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-lg sm:text-xl",children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-40"})})}),jsxRuntime.jsxs(CardContent,{className:"pt-4 px-3 sm:px-6",children:[jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:Array(3).fill(0).map((e,t)=>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"})]})]},t))}),jsxRuntime.jsx("div",{className:"mt-6",children:jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-[250px] w-full rounded-lg"})]})})]})]})}function SalesOverviewData({salesData:e,salesStatistics:t=[]}){const n=d=>new Intl.NumberFormat("en-CA",{style:"currency",currency:"CAD",minimumFractionDigits:2,maximumFractionDigits:2}).format(d),o=[{title:"Last 30 days",amount:e.SalesLast30Days||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-blue-500"},{title:"Last 3 months",amount:e.SalesLast3Months||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-amber-500"},{title:"Year to date",amount:e.SalesYearToDay||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-emerald-500"}],l=React.useMemo(()=>{const d=new Map;return t.forEach(f=>{var b;const g=((b=f.Day)==null?void 0:b.toString())||"";if(g.length===8){const _=parseInt(g.substring(0,4),10),S=parseInt(g.substring(4,6),10)-1,R=parseInt(g.substring(6,8),10),C=new Date(_,S,R),E=new Date(C),M=C.getDay();E.setDate(C.getDate()-M);const I=`${E.getFullYear()}-${String(E.getMonth()+1).padStart(2,"0")}-${String(E.getDate()).padStart(2,"0")}`,A=f.ExtendedPrice||0;d.has(I)?d.set(I,d.get(I)+A):d.set(I,A)}}),Array.from(d).sort(([f],[g])=>f.localeCompare(g)).map(([f,g])=>({date:`${f.substring(5,7)}/${f.substring(8,10)}`,amount:g}))},[t]);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.jsxs(CardContent,{className:"pt-4 px-3 sm:px-6",children:[jsxRuntime.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:o.map((d,f)=>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:d.title}),jsxRuntime.jsx("div",{className:`p-2 rounded-full ${d.color}`,children:d.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(d.amount)})]})]},f))}),jsxRuntime.jsx("div",{className:"mt-6",children:t&&t.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("h3",{className:"text-sm font-medium mb-4",children:"Sales Trend"}),jsxRuntime.jsx("div",{className:"space-y-6",children:jsxRuntime.jsx(AreaChart,{data:l,units:"$",unitsPosition:"left",height:200})})]})})]})]})}exports.ActiveOrdersCard=ActiveOrdersCard,exports.AiGeneratedContent=AiGeneratedContent,exports.Alert=Alert,exports.AlertDescription=AlertDescription,exports.AlertTitle=AlertTitle,exports.ApiKeyProvider=ApiKeyProvider,exports.AreaChart=AreaChart,exports.Avatar=Avatar,exports.AvatarFallback=AvatarFallback,exports.AvatarFooter=AvatarFooter,exports.AvatarImage=AvatarImage,exports.Badge=Badge,exports.Button=Button,exports.Card=Card,exports.CardContent=CardContent,exports.CardDescription=CardDescription,exports.CardFooter=CardFooter,exports.CardHeader=CardHeader,exports.CardTitle=CardTitle,exports.ChatLayout=ChatLayout,exports.ChatProvider=ChatProvider,exports.Checkbox=Checkbox,exports.Command=Command,exports.CommandDialog=CommandDialog,exports.CommandEmpty=CommandEmpty,exports.CommandGroup=CommandGroup,exports.CommandInput=CommandInput,exports.CommandItem=CommandItem,exports.CommandList=CommandList,exports.CommandSeparator=CommandSeparator,exports.CommandShortcut=CommandShortcut,exports.CountryFlag=CountryFlag,exports.Dialog=Dialog,exports.DialogClose=DialogClose,exports.DialogContent=DialogContent,exports.DialogDescription=DialogDescription,exports.DialogFooter=DialogFooter,exports.DialogHeader=DialogHeader,exports.DialogOverlay=DialogOverlay,exports.DialogPortal=DialogPortal,exports.DialogTitle=DialogTitle,exports.DialogTrigger=DialogTrigger,exports.DropdownMenu=DropdownMenu,exports.DropdownMenuCheckboxItem=DropdownMenuCheckboxItem,exports.DropdownMenuContent=DropdownMenuContent,exports.DropdownMenuGroup=DropdownMenuGroup,exports.DropdownMenuItem=DropdownMenuItem,exports.DropdownMenuLabel=DropdownMenuLabel,exports.DropdownMenuPortal=DropdownMenuPortal,exports.DropdownMenuRadioGroup=DropdownMenuRadioGroup,exports.DropdownMenuRadioItem=DropdownMenuRadioItem,exports.DropdownMenuSeparator=DropdownMenuSeparator,exports.DropdownMenuShortcut=DropdownMenuShortcut,exports.DropdownMenuSub=DropdownMenuSub,exports.DropdownMenuSubContent=DropdownMenuSubContent,exports.DropdownMenuSubTrigger=DropdownMenuSubTrigger,exports.DropdownMenuTrigger=DropdownMenuTrigger,exports.ExploreManufacturers=ExploreManufacturers,exports.GeneralDocumentCard=GeneralDocumentCard,exports.Input=Input,exports.InputOTP=InputOTP,exports.InputOTPGroup=InputOTPGroup,exports.InputOTPSeparator=InputOTPSeparator,exports.InputOTPSlot=InputOTPSlot,exports.Label=Label$2,exports.Layout=Layout,exports.ManufacturerCard=ManufacturerCard,exports.ManufacturerGetStartedButton=ManufacturerGetStartedButton,exports.ManufacturerReorderingCard=ManufacturerReorderingCard,exports.MultiSelect=MultiSelect,exports.Navbar=Navbar,exports.PartnerCard=PartnerCard,exports.Popover=Popover,exports.PopoverAnchor=PopoverAnchor,exports.PopoverContent=PopoverContent,exports.PopoverTrigger=PopoverTrigger,exports.Preloader=Preloader,exports.ProductCard=ProductCard,exports.ProductImage=ProductImage,exports.ProductInventoryGrid=ProductInventoryGrid,exports.RadioGroup=RadioGroup$1,exports.RadioGroupItem=RadioGroupItem,exports.Reseller=Reseller,exports.ResellerBillingOverviewCard=ResellerBillingOverviewCard,exports.ResellerCard=ResellerCard,exports.ResellerQualificationsCard=ResellerQualificationsCard,exports.SalesOverviewCard=SalesOverviewCard,exports.ScrollArea=ScrollArea,exports.ScrollBar=ScrollBar,exports.Select=Select,exports.SelectContent=SelectContent,exports.SelectGroup=SelectGroup,exports.SelectItem=SelectItem,exports.SelectLabel=SelectLabel,exports.SelectScrollDownButton=SelectScrollDownButton,exports.SelectScrollUpButton=SelectScrollUpButton,exports.SelectTrigger=SelectTrigger,exports.SelectValue=SelectValue,exports.Separator=Separator$1,exports.Sheet=Sheet,exports.SheetClose=SheetClose,exports.SheetContent=SheetContent,exports.SheetDescription=SheetDescription,exports.SheetFooter=SheetFooter,exports.SheetHeader=SheetHeader,exports.SheetOverlay=SheetOverlay,exports.SheetPortal=SheetPortal,exports.SheetTitle=SheetTitle,exports.SheetTrigger=SheetTrigger,exports.Sidebar=Sidebar,exports.SidebarContent=SidebarContent,exports.SidebarFooter=SidebarFooter,exports.SidebarGroup=SidebarGroup,exports.SidebarGroupAction=SidebarGroupAction,exports.SidebarGroupContent=SidebarGroupContent,exports.SidebarGroupLabel=SidebarGroupLabel,exports.SidebarHeader=SidebarHeader,exports.SidebarInput=SidebarInput,exports.SidebarInset=SidebarInset,exports.SidebarMenu=SidebarMenu,exports.SidebarMenuAction=SidebarMenuAction,exports.SidebarMenuBadge=SidebarMenuBadge,exports.SidebarMenuButton=SidebarMenuButton,exports.SidebarMenuItem=SidebarMenuItem,exports.SidebarMenuSkeleton=SidebarMenuSkeleton,exports.SidebarMenuSub=SidebarMenuSub,exports.SidebarMenuSubButton=SidebarMenuSubButton,exports.SidebarMenuSubItem=SidebarMenuSubItem,exports.SidebarProvider=SidebarProvider,exports.SidebarRail=SidebarRail,exports.SidebarSeparator=SidebarSeparator,exports.SidebarTrigger=SidebarTrigger,exports.Skeleton=Skeleton,exports.Switch=Switch,exports.Table=Table,exports.TableBody=TableBody,exports.TableCaption=TableCaption,exports.TableCell=TableCell,exports.TableFooter=TableFooter,exports.TableHead=TableHead,exports.TableHeader=TableHeader,exports.TableRow=TableRow,exports.Tabs=Tabs,exports.TabsContent=TabsContent,exports.TabsList=TabsList,exports.TabsTrigger=TabsTrigger,exports.Textarea=Textarea,exports.Toast=Toast,exports.ToastAction=ToastAction,exports.ToastClose=ToastClose,exports.ToastDescription=ToastDescription,exports.ToastProvider=ToastProvider,exports.ToastTitle=ToastTitle,exports.ToastViewport=ToastViewport,exports.Toaster=Toaster,exports.Tooltip=Tooltip$1,exports.TooltipContent=TooltipContent,exports.TooltipProvider=TooltipProvider,exports.TooltipTrigger=TooltipTrigger,exports.Topbar=Topbar,exports.badgeVariants=badgeVariants,exports.buttonVariants=buttonVariants,exports.toast=toast,exports.useApiKey=useApiKey,exports.useChat=useChat,exports.useIsMobile=useIsMobile,exports.useSidebar=useSidebar,exports.useToast=useToast,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "randmarcomps",
3
3
  "private": false,
4
- "version": "1.197.0",
4
+ "version": "1.198.0",
5
5
  "description": "The UI library enabling speed and consistency in Randmar frontends.",
6
6
  "type": "module",
7
7
  "files": [