(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7177],{16618:(e,t,r)=>{"use strict";r.d(t,{J:()=>s,UserProvider:()=>l});var a=r(95155),o=r(12115);let n=(0,o.createContext)(void 0);function l(e){let{children:t}=e,[r,l]=(0,o.useState)(()=>localStorage.getItem("userName")||""),[s,i]=(0,o.useState)(()=>{{let e=localStorage.getItem("userPackage");return e?JSON.parse(e):null}}),[c,m]=(0,o.useState)("");return(0,a.jsx)(n.Provider,{value:{userName:r,setUserName:e=>{l(e),localStorage.setItem("userName",e)},userPackage:s,setUserPackage:e=>{i(e),e?localStorage.setItem("userPackage",JSON.stringify(e)):localStorage.removeItem("userPackage")},userImage:c,setUserImage:e=>{m(e)}},children:t})}function s(){let e=(0,o.useContext)(n);if(void 0===e)throw Error("useUser must be used within a UserProvider");return e}},30347:()=>{},39482:(e,t,r)=>{"use strict";r.d(t,{MarketplaceProvider:()=>l,u:()=>s});var a=r(95155),o=r(12115);let n=(0,o.createContext)(void 0);function l(e){let{children:t}=e,[r,l]=(0,o.useState)(()=>{{let e=localStorage.getItem("marketplaces");if(e)try{let t=JSON.parse(e);return Object.keys(t).forEach(e=>{"string"==typeof t[e].icon&&(t[e].icon={name:t[e].icon})}),t}catch(e){console.error("Error parsing marketplaces from localStorage:",e)}}return{}}),[s,i]=(0,o.useState)(()=>{{let e=localStorage.getItem("authorizedMarketplaces");return e?JSON.parse(e):[]}});(0,o.useEffect)(()=>{window.location.pathname.startsWith("/admin")||(async()=>{try{var e,t,r,a;let o=localStorage.getItem("token");if(!o)return;let n=await fetch("/api/auth/me",{credentials:"include",headers:{Authorization:"Bearer ".concat(o)}});if(!n.ok)return;let l=await n.json(),s=(null==l||null==(t=l.user)||null==(e=t.company)?void 0:e.marketplaces)||[],i=(null==l||null==(a=l.user)||null==(r=a.company)?void 0:r.authorizedMarketplaces)||[];if(Array.isArray(s)&&Array.isArray(i)){c(s,i);let e=localStorage.getItem("selectedPlatform");e&&!i.map(String).includes(e)&&(i.length>0?localStorage.setItem("selectedPlatform",i[0].toString()):localStorage.removeItem("selectedPlatform"))}}catch(e){console.error("Marketplace sync failed",e)}})()},[]);let c=(e,t)=>{let r=e.reduce((e,t)=>{let r=t.id.toString();return{...e,[r]:{id:t.id,name:t.name,marketplaceId:t.marketplaceId,marketplaceName:t.marketplaceName,bgColor:t.bgColor,icon:{name:t.icon}}}},{}),a=t.map(e=>e.toString());localStorage.setItem("marketplaces",JSON.stringify(r)),localStorage.setItem("authorizedMarketplaces",JSON.stringify(a)),l(r),i(a)};return(0,a.jsx)(n.Provider,{value:{marketplaces:r,authorizedMarketplaces:s,setMarketplaces:c},children:t})}function s(){let e=(0,o.useContext)(n);if(void 0===e)throw Error("useMarketplaces must be used within a MarketplaceProvider");return e}},62599:(e,t,r)=>{Promise.resolve().then(r.t.bind(r,78346,23)),Promise.resolve().then(r.t.bind(r,30347,23)),Promise.resolve().then(r.bind(r,65249)),Promise.resolve().then(r.bind(r,39482)),Promise.resolve().then(r.bind(r,16618))},65249:(e,t,r)=>{"use strict";r.d(t,{Toaster:()=>g});var a=r(95155),o=r(12115),n="(prefers-color-scheme: dark)",l=o.createContext(void 0),s={setTheme:e=>{},themes:[]},i=()=>{var e;return null!=(e=o.useContext(l))?e:s},c=null,m=(e,t)=>{let r;try{r=localStorage.getItem(e)||void 0}catch(e){}return r||t},u=e=>{let t=document.createElement("style");return e&&t.setAttribute("nonce",e),t.appendChild(document.createTextNode("*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),document.head.appendChild(t),()=>{window.getComputedStyle(document.body),setTimeout(()=>{document.head.removeChild(t)},1)}},d=e=>(e||(e=window.matchMedia(n)),e.matches?"dark":"light"),p=r(56671);let g=e=>{let{...t}=e,{theme:r="system"}=i();return(0,a.jsx)(p.l$,{theme:r,className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...t})}},78346:e=>{e.exports={style:{fontFamily:"'Inter', 'Inter Fallback'",fontStyle:"normal"},className:"__className_f367f3"}}},e=>{var t=t=>e(e.s=t);e.O(0,[3838,6671,8441,1684,7358],()=>t(62599)),_N_E=e.O()}]);