bitsnap-react 1.14.0 → 1.15.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.
Files changed (87) hide show
  1. package/AGENTS.md +246 -0
  2. package/README.md +99 -51
  3. package/dist/CartProvider-64QEJ7A7.js +2 -0
  4. package/dist/CartProvider-64QEJ7A7.js.map +1 -0
  5. package/dist/{CartProvider-GLUQHAG3.mjs → CartProvider-XKK7A3C2.mjs} +2 -2
  6. package/dist/analytics.js +1 -1
  7. package/dist/analytics.js.map +1 -1
  8. package/dist/analytics.mjs +1 -1
  9. package/dist/catalog.js +1 -1
  10. package/dist/catalog.js.map +1 -1
  11. package/dist/catalog.mjs +1 -1
  12. package/dist/{chunk-MVOJMCZG.mjs → chunk-2TLWMYXW.mjs} +2 -2
  13. package/dist/{chunk-5DDLYVBG.js → chunk-7DG4UPWE.js} +2 -2
  14. package/dist/chunk-7DG4UPWE.js.map +1 -0
  15. package/dist/{chunk-VY7RNSFP.mjs → chunk-7TLJKYZD.mjs} +2 -2
  16. package/dist/{chunk-U5SAO2SH.mjs → chunk-AZQOW73L.mjs} +2 -2
  17. package/dist/{chunk-U5SAO2SH.mjs.map → chunk-AZQOW73L.mjs.map} +1 -1
  18. package/dist/{chunk-AWG5OAK7.js → chunk-DY2S42Q6.js} +2 -2
  19. package/dist/chunk-DY2S42Q6.js.map +1 -0
  20. package/dist/{chunk-7SYNGA3R.js → chunk-FGB5FJCI.js} +2 -2
  21. package/dist/chunk-FGB5FJCI.js.map +1 -0
  22. package/dist/{chunk-JXVAT2ZE.js → chunk-GLAJPUMA.js} +2 -2
  23. package/dist/chunk-GLAJPUMA.js.map +1 -0
  24. package/dist/{chunk-FLDI3BPY.js → chunk-H4WAQQVO.js} +2 -2
  25. package/dist/chunk-H4WAQQVO.js.map +1 -0
  26. package/dist/chunk-JSDGZ4NY.js.map +1 -1
  27. package/dist/chunk-KOYBZORL.js.map +1 -1
  28. package/dist/{chunk-3N2VK426.js → chunk-MG6VV5J2.js} +2 -2
  29. package/dist/chunk-MG6VV5J2.js.map +1 -0
  30. package/dist/{chunk-3OEKRPWV.mjs → chunk-PEVB3VL4.mjs} +2 -2
  31. package/dist/{chunk-3OEKRPWV.mjs.map → chunk-PEVB3VL4.mjs.map} +1 -1
  32. package/dist/{chunk-CYLZ5GYW.mjs → chunk-Q3DSK66F.mjs} +2 -2
  33. package/dist/{chunk-SKFE6TUP.mjs → chunk-RWEP6IUC.mjs} +2 -2
  34. package/dist/{chunk-GKFET34B.mjs → chunk-S4Z4O46O.mjs} +2 -2
  35. package/dist/{chunk-R2M6W4LD.js → chunk-VY6CZVVA.js} +3 -3
  36. package/dist/chunk-VY6CZVVA.js.map +1 -0
  37. package/dist/chunk-W3RGQYPD.js.map +1 -1
  38. package/dist/{chunk-PLS5RR27.js → chunk-XZYCQ655.js} +2 -2
  39. package/dist/chunk-XZYCQ655.js.map +1 -0
  40. package/dist/{chunk-VYYUTJZB.mjs → chunk-ZIWQ57GY.mjs} +2 -2
  41. package/dist/consent.js +14 -7
  42. package/dist/consent.js.map +1 -1
  43. package/dist/consent.mjs +14 -7
  44. package/dist/consent.mjs.map +1 -1
  45. package/dist/course.js +1 -1
  46. package/dist/course.js.map +1 -1
  47. package/dist/course.mjs +1 -1
  48. package/dist/embed/analytics.js +1 -1
  49. package/dist/embed/consent.js +14 -7
  50. package/dist/errors.js.map +1 -1
  51. package/dist/index.css +1 -1
  52. package/dist/index.css.map +1 -1
  53. package/dist/index.d.mts +15 -0
  54. package/dist/index.d.ts +15 -0
  55. package/dist/index.js +1 -1
  56. package/dist/index.js.map +1 -1
  57. package/dist/index.mjs +1 -1
  58. package/dist/internal.js.map +1 -1
  59. package/dist/methods-NUMVR53L.js +2 -0
  60. package/dist/methods-NUMVR53L.js.map +1 -0
  61. package/dist/methods-YKZZ6OVT.mjs +2 -0
  62. package/dist/models.js.map +1 -1
  63. package/dist/returns.js +1 -1
  64. package/dist/returns.js.map +1 -1
  65. package/dist/returns.mjs +1 -1
  66. package/package.json +17 -16
  67. package/dist/CartProvider-6D5WE2HA.js +0 -2
  68. package/dist/CartProvider-6D5WE2HA.js.map +0 -1
  69. package/dist/chunk-3N2VK426.js.map +0 -1
  70. package/dist/chunk-5DDLYVBG.js.map +0 -1
  71. package/dist/chunk-7SYNGA3R.js.map +0 -1
  72. package/dist/chunk-AWG5OAK7.js.map +0 -1
  73. package/dist/chunk-FLDI3BPY.js.map +0 -1
  74. package/dist/chunk-JXVAT2ZE.js.map +0 -1
  75. package/dist/chunk-PLS5RR27.js.map +0 -1
  76. package/dist/chunk-R2M6W4LD.js.map +0 -1
  77. package/dist/methods-N35A2OGE.mjs +0 -2
  78. package/dist/methods-WSICR2JH.js +0 -2
  79. package/dist/methods-WSICR2JH.js.map +0 -1
  80. /package/dist/{CartProvider-GLUQHAG3.mjs.map → CartProvider-XKK7A3C2.mjs.map} +0 -0
  81. /package/dist/{chunk-MVOJMCZG.mjs.map → chunk-2TLWMYXW.mjs.map} +0 -0
  82. /package/dist/{chunk-VY7RNSFP.mjs.map → chunk-7TLJKYZD.mjs.map} +0 -0
  83. /package/dist/{chunk-CYLZ5GYW.mjs.map → chunk-Q3DSK66F.mjs.map} +0 -0
  84. /package/dist/{chunk-SKFE6TUP.mjs.map → chunk-RWEP6IUC.mjs.map} +0 -0
  85. /package/dist/{chunk-GKFET34B.mjs.map → chunk-S4Z4O46O.mjs.map} +0 -0
  86. /package/dist/{chunk-VYYUTJZB.mjs.map → chunk-ZIWQ57GY.mjs.map} +0 -0
  87. /package/dist/{methods-N35A2OGE.mjs.map → methods-YKZZ6OVT.mjs.map} +0 -0
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkFLDI3BPYjs = require('./chunk-FLDI3BPY.js');var _chunk5DDLYVBGjs = require('./chunk-5DDLYVBG.js');var _chunk7SYNGA3Rjs = require('./chunk-7SYNGA3R.js');var _chunkAWG5OAK7js = require('./chunk-AWG5OAK7.js');var _chunk3N2VK426js = require('./chunk-3N2VK426.js');var _react = require('@formkit/auto-animate/react');var _react3 = require('react'); var En = _interopRequireWildcard(_react3); var ft = _interopRequireWildcard(_react3);var _jsxruntime = require('react/jsx-runtime');function ue({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card",className:_chunkAWG5OAK7js.d.call(void 0, "bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...t})}function be({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-header",className:_chunkAWG5OAK7js.d.call(void 0, "@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),...t})}function ve({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-title",className:_chunkAWG5OAK7js.d.call(void 0, "leading-none font-semibold",e),...t})}function Mt({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-description",className:_chunkAWG5OAK7js.d.call(void 0, "text-muted-foreground text-sm",e),...t})}function me({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-content",className:_chunkAWG5OAK7js.d.call(void 0, "px-6",e),...t})}var _inputotp = require('input-otp');var _lucidereact = require('lucide-react');function On({className:e,containerClassName:t,...n}){return _jsxruntime.jsx.call(void 0, _inputotp.OTPInput,{"data-slot":"input-otp",containerClassName:_chunkAWG5OAK7js.d.call(void 0, "flex items-center gap-2 has-disabled:opacity-50",t),className:_chunkAWG5OAK7js.d.call(void 0, "disabled:cursor-not-allowed",e),...n})}function Ut({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"input-otp-group",className:_chunkAWG5OAK7js.d.call(void 0, "flex items-center",e),...t})}function Se({index:e,className:t,...n}){let o=En.useContext(_inputotp.OTPInputContext),{char:r,hasFakeCaret:a,isActive:i}=_nullishCoalesce(_optionalChain([o, 'optionalAccess', _2 => _2.slots, 'access', _3 => _3[e]]), () => ({}));return _jsxruntime.jsxs.call(void 0, "div",{"data-slot":"input-otp-slot","data-active":i,className:_chunkAWG5OAK7js.d.call(void 0, "data-[active=true]:border-ring data-[active=true]:ring-ring/50 data-[active=true]:aria-invalid:ring-destructive/20 dark:data-[active=true]:aria-invalid:ring-destructive/40 aria-invalid:border-destructive data-[active=true]:aria-invalid:border-destructive dark:bg-input/30 border-input relative flex h-9 w-9 items-center justify-center border-y border-r text-sm shadow-xs transition-all outline-none first:rounded-l-md first:border-l last:rounded-r-md data-[active=true]:z-10 data-[active=true]:ring-[3px]",t),...n,children:[r,a&&_jsxruntime.jsx.call(void 0, "div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:_jsxruntime.jsx.call(void 0, "div",{className:"animate-caret-blink bg-foreground h-4 w-px duration-1000"})})]})}function Mn({...e}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"input-otp-separator",role:"separator",...e,children:_jsxruntime.jsx.call(void 0, _lucidereact.MinusIcon,{})})}function ia(){return _jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, "div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.3s]"}),_jsxruntime.jsx.call(void 0, "div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.15s]"}),_jsxruntime.jsx.call(void 0, "div",{className:"h-3 w-3 animate-bounce rounded-full bg-current"})]})}var Z=ia;var ca="return_url",_t="__return_url",da="accessToken";function Qe(e){let t=new URLSearchParams(e).get(ca);return t?Un(t):null}function Xe(e){typeof window>"u"||(e?window.sessionStorage.setItem(_t,e):window.sessionStorage.removeItem(_t))}function Me(){if(typeof window>"u")return null;let e=window.sessionStorage.getItem(_t);return e?Un(e):null}function la(e,t){return t.some(n=>{if(e===n)return!0;let o=new URL(n).hostname,r=new URL(e).hostname;return r.endsWith(`.${o}`)||r===o})}function Un(e){try{let t=new URL(e);return t.protocol!=="https:"&&t.protocol!=="http:"||!la(t.origin,_chunk5DDLYVBGjs.h.call(void 0, ))?null:t.toString()}catch (e2){return null}}function Ue(e,t){let n=new URL(e);return n.searchParams.set(da,t),n.toString()}if(typeof window<"u"){let t=[window.location.origin,"https://bitsnap.pl","https://kursy.bitsnap.pl"];_chunk5DDLYVBGjs.h.call(void 0, ).length===0&&_chunk5DDLYVBGjs.g.call(void 0, Array.from(new Set(t)))}var pa=({projectID:e,host:t,reveal:n,email:o,setEmail:r,loginUser:a,isLoginLoading:i,errMsg:c})=>{let{projectID:d,host:l}=_chunk5DDLYVBGjs.j.call(void 0, );if(typeof window<"u"&&_chunk5DDLYVBGjs.k.call(void 0, _nullishCoalesce(e, () => (d)),_nullishCoalesce(t, () => (l)))!=null)return window.location.href=window.location.href.replaceAll("login",""),null;let[m,g]=_react3.useState.call(void 0, !1),k=s=>/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(s.trim())?g(!0):g(!1),u=s=>{let{value:P}=s.target;k(P),r(P)};function v(){n()}function C(s){s.preventDefault(),a()}return _jsxruntime.jsx.call(void 0, "main",{className:"mx-auto flex max-w-sm flex-1 flex-col justify-center space-y-12",children:_jsxruntime.jsx.call(void 0, "div",{className:_chunkAWG5OAK7js.d.call(void 0, "flex min-w-sm flex-col gap-6"),children:_jsxruntime.jsxs.call(void 0, ue,{children:[_jsxruntime.jsxs.call(void 0, be,{children:[_jsxruntime.jsx.call(void 0, ve,{className:"text-2xl",children:"Zaloguj si\u0119"}),_jsxruntime.jsx.call(void 0, Mt,{children:"Wy\u015Blemy do Ciebie kod na maila, dzi\u0119ki kt\xF3remu si\u0119 zalogujesz."})]}),_jsxruntime.jsx.call(void 0, me,{children:_jsxruntime.jsxs.call(void 0, "form",{onSubmit:C,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-6",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"grid gap-2",children:[_jsxruntime.jsx.call(void 0, _chunkFLDI3BPYjs.a,{htmlFor:"email",children:"Email"}),_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.r,{id:"email",onChange:u,type:"email",placeholder:"m@example.com",required:!0}),_jsxruntime.jsx.call(void 0, "span",{className:_chunkAWG5OAK7js.d.call(void 0, !m&&o.length>0?"font-bold text-red-500":"text-neutral-700 dark:text-neutral-400","text-xs"),children:!m&&o.length>0?"Nieprawid\u0142owy adres email":"Wpisz sw\xF3j adres email"})]}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsxs.call(void 0, _chunk7SYNGA3Rjs.q,{type:"submit",disabled:i,className:"relative w-full",onClick:a,children:[i&&_jsxruntime.jsx.call(void 0, "div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:_jsxruntime.jsx.call(void 0, Z,{})}),"Zaloguj si\u0119"]}),c.length>0&&_jsxruntime.jsx.call(void 0, "p",{className:"text-xs font-medium text-red-500",children:c})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-4 text-center text-sm",children:["Masz ju\u017C kod?"," ",_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:v,className:"underline underline-offset-4",children:"Mam ju\u017C kod"})]})]})})]})})})},fa=({projectID:e,host:t,email:n,reveal:o,setEmail:r,isLoginLoading:a,loginUserResponse:i,setLoginUserResponse:c,setResponseStatus:d,errMsg:l})=>{let m=_chunk3N2VK426js.m.call(void 0, ),{mutateAsync:g,isPending:k}=_chunk7SYNGA3Rjs.l.call(void 0, _chunk7SYNGA3Rjs.j.publicApi.userPanelLoginWithCode),[u,v]=_react3.useState.call(void 0, ""),[C,s]=_react3.useState.call(void 0, !1),[P,R]=_react3.useState.call(void 0, !1),[q,F]=_react3.useState.call(void 0, 0),A=M=>/^\d+$/.test(M.trim())?s(!0):s(!1),E=M=>{A(M),v(M)};async function z(){if(R(!0),u.length==0){s(!1);return}let M=parseInt(u),X=await g({code:M}),ye,Ce,re;if(X.result.case==="accessToken"?(s(!0),ye="ok",Ce=void 0,re=X.result.value):(s(!1),ye="error",Ce=X.result.value,re=void 0),ye==="error"&&(s(!1),console.warn("error:",`Kod b\u0142\u0119du: ${Ce}`),console.warn("Nieprawid\u0142owy kod, spr\xF3buj ponownie.")),ye==="ok"){m.track("panel_login",{}),re&&_chunk5DDLYVBGjs.l.call(void 0, e,re,n,t);let h=typeof window<"u"?Me():null;setTimeout(()=>{if(re&&h){window.location.href=Ue(h,re);return}window.location.reload()},100)}}function D(){let M=setInterval(()=>{F(X=>X>0?X-1:(clearInterval(M),0))},1e3);return()=>{clearInterval(M)}}_react3.useEffect.call(void 0, ()=>{_optionalChain([i, 'optionalAccess', _4 => _4.status])==="ok"&&_optionalChain([i, 'optionalAccess', _5 => _5.retryIn])>0&&(F(i.retryIn),D())},[i]);function $(){r(""),c(null),d("default"),o()}function ge(M){M.preventDefault(),z()}return _jsxruntime.jsx.call(void 0, "main",{className:"mx-auto flex max-w-md flex-1 flex-col justify-center space-y-8",children:_jsxruntime.jsx.call(void 0, "div",{className:_chunkAWG5OAK7js.d.call(void 0, "flex min-w-sm flex-col gap-6"),children:_jsxruntime.jsxs.call(void 0, ue,{children:[_jsxruntime.jsxs.call(void 0, be,{children:[_jsxruntime.jsx.call(void 0, ve,{className:"text-2xl",children:"Wpisz kod z maila"}),_jsxruntime.jsx.call(void 0, Mt,{children:"Sprawd\u017A czy przypadkiem nie wyl\u0105dowa\u0142 w spamie."})]}),_jsxruntime.jsxs.call(void 0, me,{children:[_jsxruntime.jsxs.call(void 0, "form",{onSubmit:ge,className:"flex flex-col gap-6",children:[_jsxruntime.jsx.call(void 0, "div",{className:"grid gap-2",children:_jsxruntime.jsx.call(void 0, "div",{className:"my-5 flex w-full items-center justify-center",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsxs.call(void 0, On,{id:"verify-code",maxLength:6,pattern:_inputotp.REGEXP_ONLY_DIGITS,onChange:M=>{E(M)},children:[_jsxruntime.jsxs.call(void 0, Ut,{children:[_jsxruntime.jsx.call(void 0, Se,{index:0}),_jsxruntime.jsx.call(void 0, Se,{index:1}),_jsxruntime.jsx.call(void 0, Se,{index:2})]}),_jsxruntime.jsx.call(void 0, Mn,{}),_jsxruntime.jsxs.call(void 0, Ut,{children:[_jsxruntime.jsx.call(void 0, Se,{index:3}),_jsxruntime.jsx.call(void 0, Se,{index:4}),_jsxruntime.jsx.call(void 0, Se,{index:5})]})]}),_jsxruntime.jsx.call(void 0, "span",{className:_chunkAWG5OAK7js.d.call(void 0, !C&&P?"text-red-500":"text-neutral-700 dark:text-neutral-400","text-xs"),children:!C&&P?u.length==0?"Kod nie mo\u017Ce by\u0107 pusty":"Kod musi sk\u0142ada\u0107 si\u0119 z cyfr":"Wpisz kod z maila"})]})})}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsxs.call(void 0, _chunk7SYNGA3Rjs.q,{type:"submit",disabled:a||k,className:"relative w-full",children:[(a||k)&&_jsxruntime.jsx.call(void 0, "div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:_jsxruntime.jsx.call(void 0, Z,{})}),"Zaloguj si\u0119"]}),l.length>0&&_jsxruntime.jsx.call(void 0, "p",{className:"text-xs font-medium text-red-500",children:l})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-4 text-center text-sm",children:["Nie masz kodu?"," ",_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:$,className:"underline underline-offset-4",children:"Wr\xF3\u0107"})]})]})]})})})},ga=({analytics:e})=>{let{theme:t,allowedReturnOrigins:n,projectID:o,host:r}=_chunk5DDLYVBGjs.j.call(void 0, ),a=_chunk3N2VK426js.n.call(void 0, o,e,"panel"),i={"--button-background-color":_nullishCoalesce(_optionalChain([t, 'optionalAccess', _6 => _6.colors, 'optionalAccess', _7 => _7.brand]), () => ("#FFFFFF")),"--button-background-color-dark":_nullishCoalesce(_optionalChain([t, 'optionalAccess', _8 => _8.colors, 'optionalAccess', _9 => _9.brandDark]), () => ("#000000")),"--button-text-color":_nullishCoalesce(_optionalChain([t, 'optionalAccess', _10 => _10.colors, 'optionalAccess', _11 => _11.brandDark]), () => ("#000000")),"--button-text-color-dark":_nullishCoalesce(_optionalChain([t, 'optionalAccess', _12 => _12.colors, 'optionalAccess', _13 => _13.brand]), () => ("#FFFFFF"))},[c,d]=_react3.useState.call(void 0, "login"),[l]=_react.useAutoAnimate.call(void 0, {duration:300,easing:"ease-in-out",disrespectUserMotionPreference:!1}),m=()=>d(E=>E==="login"?"verifyCode":"login"),[g,k]=_react3.useState.call(void 0, ""),[u,v]=_react3.useState.call(void 0, "default"),[C,s]=_react3.useState.call(void 0, null),{mutateAsync:P,isPending:R}=_chunk7SYNGA3Rjs.l.call(void 0, _chunk7SYNGA3Rjs.j.publicApi.userPanelLogin),[q,F]=_react3.useState.call(void 0, "");_react3.useEffect.call(void 0, ()=>{if(typeof window>"u"||window.parent!==window)return;let E=Qe(window.location.search);E&&Xe(E);let z=_nullishCoalesce(E, () => (Me()));if(!z)return;let D=_chunk5DDLYVBGjs.k.call(void 0, o,r);D&&(window.location.href=Ue(z,D))},[n,o,r]);async function A(){F(""),v("default");let E=await P({email:g}),z=E.result.case==="success"?"ok":"error",D=0,$;E.result.case==="success"&&(D=E.result.value.retryIn),z==="error"&&($="Nieprawid\u0142owy adres email, spr\xF3buj ponownie."),s({status:z,retryIn:D,message:$}),z==="ok"&&c==="login"?m():z==="ok"&&c==="verifyCode"?v("success"):z==="error"&&F(_nullishCoalesce($, () => ("Nieprawid\u0142owy adres email, spr\xF3buj ponownie.")))}return _jsxruntime.jsx.call(void 0, _chunk3N2VK426js.l,{value:a,children:_jsxruntime.jsx.call(void 0, "div",{className:"bg-white text-black dark:bg-black dark:text-white",children:_jsxruntime.jsxs.call(void 0, "div",{className:"font-inter flex h-screen w-screen flex-col p-4",style:i,ref:l,children:[_jsxruntime.jsxs.call(void 0, "header",{children:[_optionalChain([t, 'optionalAccess', _14 => _14.logoDarkURL])&&_jsxruntime.jsx.call(void 0, "img",{src:_optionalChain([t, 'optionalAccess', _15 => _15.logoDarkURL]),className:"hidden dark:inline",alt:"Company Logo",draggable:!1}),_optionalChain([t, 'optionalAccess', _16 => _16.logoURL])&&_jsxruntime.jsx.call(void 0, "img",{src:_optionalChain([t, 'optionalAccess', _17 => _17.logoURL]),className:"dark:hidden",alt:"Company Logo",draggable:!1})]}),c==="login"&&_jsxruntime.jsx.call(void 0, pa,{projectID:o,host:r,reveal:m,email:g,setEmail:k,loginUser:A,isLoginLoading:R,errMsg:q}),c==="verifyCode"&&_jsxruntime.jsx.call(void 0, fa,{projectID:o,host:r,email:g,reveal:m,setEmail:k,loginUser:A,isLoginLoading:R,loginUserResponse:C,setLoginUserResponse:s,responseStatus:u,setResponseStatus:v,errMsg:q})]})})})},ya= exports.n =({analytics:e}={})=>_jsxruntime.jsx.call(void 0, ga,{analytics:e});function _n(e){let[t,n]=_react3.useState.call(void 0, ()=>{if(typeof window>"u")return e;let r=new URLSearchParams(window.location.search),a={};return Object.keys(e).forEach(i=>{let c=r.get(i);if(c!==null)try{a[i]=JSON.parse(c)}catch (e3){a[i]=c}}),{...e,...a}}),o=_react3.useCallback.call(void 0, r=>{n(a=>{let i={...a,...r};if(typeof window<"u"){let c=new URLSearchParams;Object.keys(i).forEach(l=>{let m=i[l];m!=null&&c.set(l,JSON.stringify(m))});let d=`${window.location.pathname}?${c.toString()}`;window.history.pushState({},"",d)}return i})},[]);return _react3.useEffect.call(void 0, ()=>{let r=()=>{let a=new URLSearchParams(window.location.search),i={};Object.keys(e).forEach(c=>{let d=a.get(c);if(d!==null)try{i[c]=JSON.parse(d)}catch (e4){i[c]=d}}),n({...e,...i})};return window.addEventListener("popstate",r),()=>window.removeEventListener("popstate",r)},[e]),[t,o]}function zn(e,t){if(e!=null)return e;let n=_optionalChain([t, 'optionalAccess', _18 => _18.trim, 'call', _19 => _19()]);if(!(n==null||n===""))return{tokens:_chunk7SYNGA3Rjs.t.call(void 0, n)}}var _reactswitch = require('@radix-ui/react-switch'); var ut = _interopRequireWildcard(_reactswitch);function Fn({className:e,...t}){return _jsxruntime.jsx.call(void 0, ut.Root,{"data-slot":"switch",className:_chunkAWG5OAK7js.d.call(void 0, "peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:_jsxruntime.jsx.call(void 0, ut.Thumb,{"data-slot":"switch-thumb",className:_chunkAWG5OAK7js.d.call(void 0, "bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}function wa({}){let[e,t]=_react3.useState.call(void 0, {disableAll:!1});return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Powiadomienia"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:"Zarz\u0105dzaj swoimi powiadomieniami"}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-6",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center space-x-2",children:[_jsxruntime.jsx.call(void 0, Fn,{id:"disable-all-notifications",checked:e.disableAll,onCheckedChange:n=>t(o=>({...o,disableAll:n}))}),_jsxruntime.jsxs.call(void 0, _chunkFLDI3BPYjs.a,{htmlFor:"disable-all-notifications",className:"flex flex-col gap-1 text-base",children:["Wszystkie powiadomienia",_jsxruntime.jsx.call(void 0, "span",{className:"text-xs font-normal text-neutral-500 md:text-sm",children:"Ten przycisk mo\u017Ce wy\u0142\u0105czy\u0107 wszystkie powiadomienia"})]})]})})]})}var Bn=wa;function Hn({className:e,...t}){return _jsxruntime.jsx.call(void 0, "nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:_chunkAWG5OAK7js.d.call(void 0, "mx-auto flex w-full justify-center",e),...t})}function $n({className:e,...t}){return _jsxruntime.jsx.call(void 0, "ul",{"data-slot":"pagination-content",className:_chunkAWG5OAK7js.d.call(void 0, "flex flex-row items-center gap-1",e),...t})}function we({...e}){return _jsxruntime.jsx.call(void 0, "li",{"data-slot":"pagination-item",...e})}function je({className:e,isActive:t,size:n="icon",...o}){return _jsxruntime.jsx.call(void 0, "a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:_chunkAWG5OAK7js.d.call(void 0, _chunk7SYNGA3Rjs.p.call(void 0, {variant:t?"outline":"ghost",size:n}),e),...o})}function Gn({className:e,...t}){return _jsxruntime.jsxs.call(void 0, je,{"aria-label":"Go to previous page",size:"default",className:_chunkAWG5OAK7js.d.call(void 0, "gap-1 px-2.5 sm:pl-2.5",e),...t,children:[_jsxruntime.jsx.call(void 0, _lucidereact.ChevronLeftIcon,{}),_jsxruntime.jsx.call(void 0, "span",{className:"hidden sm:block",children:"Previous"})]})}function Vn({className:e,...t}){return _jsxruntime.jsxs.call(void 0, je,{"aria-label":"Go to next page",size:"default",className:_chunkAWG5OAK7js.d.call(void 0, "gap-1 px-2.5 sm:pr-2.5",e),...t,children:[_jsxruntime.jsx.call(void 0, "span",{className:"hidden sm:block",children:"Next"}),_jsxruntime.jsx.call(void 0, _lucidereact.ChevronRightIcon,{})]})}function qt({className:e,...t}){return _jsxruntime.jsxs.call(void 0, "span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:_chunkAWG5OAK7js.d.call(void 0, "flex size-9 items-center justify-center",e),...t,children:[_jsxruntime.jsx.call(void 0, _lucidereact.MoreHorizontalIcon,{className:"size-4"}),_jsxruntime.jsx.call(void 0, "span",{className:"sr-only",children:"More pages"})]})}var Sa=e=>new Date(e*1e3).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),Ra=(e,t)=>new Intl.NumberFormat("en-US",{style:"currency",currency:t.toUpperCase()}).format(e/100),Aa={draft:"Szkic",unpaid:"Nieop\u0142acona",paid:"Op\u0142acona",overdue:"Zaleg\u0142a",cancelled:"Anulowana",completed:"Zako\u0144czone",processing:"Przetwarzane",refunded:"Zwr\xF3cone"},Ta={draft:"text-neutral-400",unpaid:"text-yellow-500",paid:"text-green-600",overdue:"text-red-500",cancelled:"text-neutral-400 line-through",completed:"text-green-600",processing:"text-blue-500",refunded:"text-purple-500"};function Da({openOrderDetails:e,projectID:t,accessToken:n}){let[o,r]=_react3.useState.call(void 0, 0),a=20,{data:i,isFetching:c}=_chunk7SYNGA3Rjs.k.call(void 0, _chunk7SYNGA3Rjs.j.publicApi.getOrders,{projectId:t,accessToken:n,offset:o,limit:a}),d=_nullishCoalesce(_optionalChain([i, 'optionalAccess', _20 => _20.orders]), () => ([])),l=_nullishCoalesce(_optionalChain([i, 'optionalAccess', _21 => _21.totalCount]), () => (0)),m=Math.floor(o/a)+1,g=Math.ceil(l/a),k=u=>{r(u)};return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Historia zam\xF3wie\u0144"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:"Twoje zam\xF3wienia"}),c?_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 flex w-full flex-col gap-3",children:[...Array(5)].map((u,v)=>_jsxruntime.jsxs.call(void 0, "div",{className:"rounded-xl bg-white p-4 shadow-sm dark:bg-neutral-800",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2",children:[_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.u,{className:"h-4 w-24"}),_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.u,{className:"h-3 w-32"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2 text-right",children:[_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.u,{className:"ml-auto h-4 w-16"}),_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.u,{className:"ml-auto h-3 w-12"})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-3",children:_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.u,{className:"h-3 w-40"})})]},v))}):d.length===0?_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 text-sm text-neutral-400",children:"Brak zam\xF3wie\u0144."}):_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 flex w-full flex-col gap-3",children:d.map(u=>_jsxruntime.jsxs.call(void 0, "button",{onClick:()=>e(u.id),className:"block rounded-xl bg-white p-4 text-left shadow-sm transition-colors hover:bg-neutral-50 dark:bg-neutral-800 dark:hover:bg-neutral-700",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsxs.call(void 0, "p",{className:"font-medium",children:["Zam\xF3wienie #",u.id]}),_jsxruntime.jsx.call(void 0, "p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:u.customerName||"Klient"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"text-right",children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-semibold",children:Ra(u.totalAmount,u.currency)}),_jsxruntime.jsx.call(void 0, "p",{className:`text-xs font-medium ${_nullishCoalesce(Ta[u.status], () => ("text-neutral-400"))}`,children:_nullishCoalesce(Aa[u.status], () => (u.status))})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-2 flex items-center justify-between text-xs text-neutral-500 dark:text-neutral-400",children:_jsxruntime.jsxs.call(void 0, "span",{children:["Data:"," ",u.createdAt?Sa(Number(u.createdAt.seconds)):"-"]})})]},u.id))}),g>1&&!c&&_jsxruntime.jsx.call(void 0, "div",{className:"mt-4 flex justify-center",children:_jsxruntime.jsx.call(void 0, Hn,{children:_jsxruntime.jsxs.call(void 0, $n,{children:[m>1&&_jsxruntime.jsx.call(void 0, we,{children:_jsxruntime.jsx.call(void 0, Gn,{onClick:()=>k(o-a)})}),m>2&&_jsxruntime.jsx.call(void 0, we,{children:_jsxruntime.jsx.call(void 0, je,{onClick:()=>k(0),children:"1"})}),m>3&&_jsxruntime.jsx.call(void 0, we,{children:_jsxruntime.jsx.call(void 0, qt,{})}),[m-1,m,m+1].filter(u=>u>0&&u<=g).map(u=>_jsxruntime.jsx.call(void 0, we,{children:_jsxruntime.jsx.call(void 0, je,{onClick:()=>k((u-1)*a),isActive:m===u,children:u})},u)),m<g-2&&_jsxruntime.jsx.call(void 0, we,{children:_jsxruntime.jsx.call(void 0, qt,{})}),m<g&&_jsxruntime.jsx.call(void 0, we,{children:_jsxruntime.jsx.call(void 0, je,{onClick:()=>k((g-1)*a),children:g})}),m<g&&_jsxruntime.jsx.call(void 0, we,{children:_jsxruntime.jsx.call(void 0, Vn,{onClick:()=>k(o+a)})})]})})})]})]})}var Kn=Da;var Zn=e=>new Date(e*1e3).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),Ea={active:"Aktywny",cancelled:"Anulowany",paused:"Wstrzymany"},Oa={active:"text-green-600",cancelled:"text-red-500",paused:"text-yellow-500"};function Ma({projectID:e}){let[t,n]=_react3.useState.call(void 0, []),[o,r]=_react3.useState.call(void 0, !0);return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Plany"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:"Twoje aktywne subskrypcje"}),o?_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 text-sm text-neutral-400",children:"\u0141adowanie..."}):t.length===0?_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 text-sm text-neutral-400",children:"Brak aktywnych plan\xF3w."}):_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 flex flex-col gap-4",children:t.map(a=>_jsxruntime.jsxs.call(void 0, "div",{className:"rounded-xl bg-white p-5 shadow-sm dark:bg-neutral-800",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-start justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-semibold",children:a.tierName}),a.configName&&_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:a.configName})]}),_jsxruntime.jsx.call(void 0, "span",{className:`text-sm font-medium ${_nullishCoalesce(Oa[a.status], () => ("text-neutral-500"))}`,children:_nullishCoalesce(Ea[a.status], () => (a.status))})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-3 grid grid-cols-2 gap-2 text-sm text-neutral-600 dark:text-neutral-400",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Dzie\u0144 rozliczenia:"})," ",a.billingDay]}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Data startu:"})," ",Zn(a.startDate)]}),a.endDate&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Data zako\u0144czenia:"})," ",Zn(a.endDate)]})]})]},a.id))})]})}var Jn=Ma;function _a(e,t,n,o){typeof window>"u"||(t&&_chunk5DDLYVBGjs.n.call(void 0, n,o),window.location.href=e)}function za({projectID:e,host:t,loginURL:n,screen:o,params:r,setParams:a,setActiveScreen:i}){let{status:c,exchangeError:d}=_chunkFLDI3BPYjs.j.call(void 0, "PanelReturns"),l=_chunkFLDI3BPYjs.i.call(void 0, ),m=c==="anonymous"&&(d==null||_chunkFLDI3BPYjs.g.call(void 0, d));_react3.useEffect.call(void 0, ()=>{m&&_a(n,d!=null,e,t)},[m,n,d,e,t]);let[g,k]=_react3.useState.call(void 0, "orders"),[u,v]=_react3.useState.call(void 0, {items:[],note:""}),[C,s]=_react3.useState.call(void 0, );if(c==="anonymous"&&!m)return _jsxruntime.jsxs.call(void 0, "div",{role:"alert",className:"flex flex-col items-start gap-3",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",children:l(_chunkFLDI3BPYjs.h.call(void 0, d))}),_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.q,{type:"button",onClick:()=>window.location.reload(),children:l("errorRetry")})]});if(c!=="authenticated")return _jsxruntime.jsx.call(void 0, _chunkFLDI3BPYjs.s,{});let P=R=>{k(R),a({state:"returns",orderId:void 0,returnId:void 0}),i("returns")};if(o==="return-details"&&r.returnId)return _jsxruntime.jsx.call(void 0, _chunkFLDI3BPYjs.A,{returnId:r.returnId,onBack:()=>P("myReturns")});if(g==="myReturns")return _jsxruntime.jsx.call(void 0, _chunkFLDI3BPYjs.z,{onBack:()=>P("orders"),onSelectReturn:R=>{a({state:"return-details",returnId:R,orderId:void 0}),i("return-details")}});if(g==="result"&&C!=null)return _jsxruntime.jsx.call(void 0, _chunkFLDI3BPYjs.y,{returnId:C,onContinue:()=>P("orders"),onOpenMyReturns:()=>P("myReturns")});if(r.orderId){let R=r.orderId;return g==="confirmation"?_jsxruntime.jsx.call(void 0, _chunkFLDI3BPYjs.x,{orderId:R,items:u.items,note:u.note,onBack:()=>k("orders"),onSubmitted:q=>{s(q),v({items:[],note:""}),k("result"),a({orderId:void 0})}}):_jsxruntime.jsx.call(void 0, _chunkFLDI3BPYjs.w,{orderId:R,initialItems:u.items.length>0?u.items:void 0,initialNote:u.note,onBack:()=>{v({items:[],note:""}),a({orderId:void 0})},onContinue:q=>{v(q),k("confirmation")}})}return _jsxruntime.jsx.call(void 0, _chunkFLDI3BPYjs.v,{showLogout:!1,onSelectOrder:R=>{v({items:[],note:""}),k("orders"),a({orderId:R})},onOpenMyReturns:()=>P("myReturns")})}function Ht({accessToken:e,appearance:t,texts:n,...o}){return _jsxruntime.jsx.call(void 0, _chunkFLDI3BPYjs.k,{projectID:o.projectID,host:o.host,appearance:t,texts:n,panelAccessToken:e,children:_jsxruntime.jsx.call(void 0, za,{...o})})}var Fa=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g,Ba=e=>[...e.matchAll(Fa)].map(n=>({url:n[0],startIndex:n.index,endIndex:n.index+n[0].length-1})),Ha=(e,t)=>{let n="",o=0;t.sort((r,a)=>r.startIndex-a.startIndex);for(let{startIndex:r,endIndex:a,replacementText:i}of t)n+=e.slice(o,r),n+=i,o=a+1;return n+=e.slice(o),n},Yn=e=>{let t=Ba(e);return _jsxruntime.jsx.call(void 0, "p",{dangerouslySetInnerHTML:{__html:Ha(e,t.map(n=>(n.replacementText=`<a key=${n.url} href=${n.url} style="text-decoration: underline;" target="_blank">
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkH4WAQQVOjs = require('./chunk-H4WAQQVO.js');var _chunk7DG4UPWEjs = require('./chunk-7DG4UPWE.js');var _chunkFGB5FJCIjs = require('./chunk-FGB5FJCI.js');var _chunkDY2S42Q6js = require('./chunk-DY2S42Q6.js');var _chunkMG6VV5J2js = require('./chunk-MG6VV5J2.js');var _react = require('@formkit/auto-animate/react');var _react3 = require('react'); var En = _interopRequireWildcard(_react3); var ft = _interopRequireWildcard(_react3);var _jsxruntime = require('react/jsx-runtime');function ue({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card",className:_chunkDY2S42Q6js.d.call(void 0, "bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...t})}function be({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-header",className:_chunkDY2S42Q6js.d.call(void 0, "@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),...t})}function ve({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-title",className:_chunkDY2S42Q6js.d.call(void 0, "leading-none font-semibold",e),...t})}function Mt({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-description",className:_chunkDY2S42Q6js.d.call(void 0, "text-muted-foreground text-sm",e),...t})}function me({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-content",className:_chunkDY2S42Q6js.d.call(void 0, "px-6",e),...t})}var _inputotp = require('input-otp');var _lucidereact = require('lucide-react');function On({className:e,containerClassName:t,...n}){return _jsxruntime.jsx.call(void 0, _inputotp.OTPInput,{"data-slot":"input-otp",containerClassName:_chunkDY2S42Q6js.d.call(void 0, "flex items-center gap-2 has-disabled:opacity-50",t),className:_chunkDY2S42Q6js.d.call(void 0, "disabled:cursor-not-allowed",e),...n})}function Ut({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"input-otp-group",className:_chunkDY2S42Q6js.d.call(void 0, "flex items-center",e),...t})}function Se({index:e,className:t,...n}){let o=En.useContext(_inputotp.OTPInputContext),{char:r,hasFakeCaret:a,isActive:i}=_nullishCoalesce(_optionalChain([o, 'optionalAccess', _2 => _2.slots, 'access', _3 => _3[e]]), () => ({}));return _jsxruntime.jsxs.call(void 0, "div",{"data-slot":"input-otp-slot","data-active":i,className:_chunkDY2S42Q6js.d.call(void 0, "data-[active=true]:border-ring data-[active=true]:ring-ring/50 data-[active=true]:aria-invalid:ring-destructive/20 dark:data-[active=true]:aria-invalid:ring-destructive/40 aria-invalid:border-destructive data-[active=true]:aria-invalid:border-destructive dark:bg-input/30 border-input relative flex h-9 w-9 items-center justify-center border-y border-r text-sm shadow-xs transition-all outline-none first:rounded-l-md first:border-l last:rounded-r-md data-[active=true]:z-10 data-[active=true]:ring-[3px]",t),...n,children:[r,a&&_jsxruntime.jsx.call(void 0, "div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:_jsxruntime.jsx.call(void 0, "div",{className:"animate-caret-blink bg-foreground h-4 w-px duration-1000"})})]})}function Mn({...e}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"input-otp-separator",role:"separator",...e,children:_jsxruntime.jsx.call(void 0, _lucidereact.MinusIcon,{})})}function ia(){return _jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, "div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.3s]"}),_jsxruntime.jsx.call(void 0, "div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.15s]"}),_jsxruntime.jsx.call(void 0, "div",{className:"h-3 w-3 animate-bounce rounded-full bg-current"})]})}var Z=ia;var ca="return_url",_t="__return_url",da="accessToken";function Qe(e){let t=new URLSearchParams(e).get(ca);return t?Un(t):null}function Xe(e){typeof window>"u"||(e?window.sessionStorage.setItem(_t,e):window.sessionStorage.removeItem(_t))}function Me(){if(typeof window>"u")return null;let e=window.sessionStorage.getItem(_t);return e?Un(e):null}function la(e,t){return t.some(n=>{if(e===n)return!0;let o=new URL(n).hostname,r=new URL(e).hostname;return r.endsWith(`.${o}`)||r===o})}function Un(e){try{let t=new URL(e);return t.protocol!=="https:"&&t.protocol!=="http:"||!la(t.origin,_chunk7DG4UPWEjs.h.call(void 0, ))?null:t.toString()}catch (e2){return null}}function Ue(e,t){let n=new URL(e);return n.searchParams.set(da,t),n.toString()}if(typeof window<"u"){let t=[window.location.origin,"https://bitsnap.pl","https://kursy.bitsnap.pl"];_chunk7DG4UPWEjs.h.call(void 0, ).length===0&&_chunk7DG4UPWEjs.g.call(void 0, Array.from(new Set(t)))}var pa=({projectID:e,host:t,reveal:n,email:o,setEmail:r,loginUser:a,isLoginLoading:i,errMsg:c})=>{let{projectID:d,host:l}=_chunk7DG4UPWEjs.j.call(void 0, );if(typeof window<"u"&&_chunk7DG4UPWEjs.k.call(void 0, _nullishCoalesce(e, () => (d)),_nullishCoalesce(t, () => (l)))!=null)return window.location.href=window.location.href.replaceAll("login",""),null;let[m,g]=_react3.useState.call(void 0, !1),k=s=>/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(s.trim())?g(!0):g(!1),u=s=>{let{value:P}=s.target;k(P),r(P)};function v(){n()}function C(s){s.preventDefault(),a()}return _jsxruntime.jsx.call(void 0, "main",{className:"mx-auto flex max-w-sm flex-1 flex-col justify-center space-y-12",children:_jsxruntime.jsx.call(void 0, "div",{className:_chunkDY2S42Q6js.d.call(void 0, "flex min-w-sm flex-col gap-6"),children:_jsxruntime.jsxs.call(void 0, ue,{children:[_jsxruntime.jsxs.call(void 0, be,{children:[_jsxruntime.jsx.call(void 0, ve,{className:"text-2xl",children:"Zaloguj si\u0119"}),_jsxruntime.jsx.call(void 0, Mt,{children:"Wy\u015Blemy do Ciebie kod na maila, dzi\u0119ki kt\xF3remu si\u0119 zalogujesz."})]}),_jsxruntime.jsx.call(void 0, me,{children:_jsxruntime.jsxs.call(void 0, "form",{onSubmit:C,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-6",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"grid gap-2",children:[_jsxruntime.jsx.call(void 0, _chunkH4WAQQVOjs.a,{htmlFor:"email",children:"Email"}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.r,{id:"email",onChange:u,type:"email",placeholder:"m@example.com",required:!0}),_jsxruntime.jsx.call(void 0, "span",{className:_chunkDY2S42Q6js.d.call(void 0, !m&&o.length>0?"font-bold text-red-500":"text-neutral-700 dark:text-neutral-400","text-xs"),children:!m&&o.length>0?"Nieprawid\u0142owy adres email":"Wpisz sw\xF3j adres email"})]}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsxs.call(void 0, _chunkFGB5FJCIjs.q,{type:"submit",disabled:i,className:"relative w-full",onClick:a,children:[i&&_jsxruntime.jsx.call(void 0, "div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:_jsxruntime.jsx.call(void 0, Z,{})}),"Zaloguj si\u0119"]}),c.length>0&&_jsxruntime.jsx.call(void 0, "p",{className:"text-xs font-medium text-red-500",children:c})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-4 text-center text-sm",children:["Masz ju\u017C kod?"," ",_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:v,className:"underline underline-offset-4",children:"Mam ju\u017C kod"})]})]})})]})})})},fa=({projectID:e,host:t,email:n,reveal:o,setEmail:r,isLoginLoading:a,loginUserResponse:i,setLoginUserResponse:c,setResponseStatus:d,errMsg:l})=>{let m=_chunkMG6VV5J2js.m.call(void 0, ),{mutateAsync:g,isPending:k}=_chunkFGB5FJCIjs.l.call(void 0, _chunkFGB5FJCIjs.j.publicApi.userPanelLoginWithCode),[u,v]=_react3.useState.call(void 0, ""),[C,s]=_react3.useState.call(void 0, !1),[P,R]=_react3.useState.call(void 0, !1),[q,F]=_react3.useState.call(void 0, 0),A=M=>/^\d+$/.test(M.trim())?s(!0):s(!1),E=M=>{A(M),v(M)};async function z(){if(R(!0),u.length==0){s(!1);return}let M=parseInt(u),X=await g({code:M}),ye,Ce,re;if(X.result.case==="accessToken"?(s(!0),ye="ok",Ce=void 0,re=X.result.value):(s(!1),ye="error",Ce=X.result.value,re=void 0),ye==="error"&&(s(!1),console.warn("error:",`Kod b\u0142\u0119du: ${Ce}`),console.warn("Nieprawid\u0142owy kod, spr\xF3buj ponownie.")),ye==="ok"){m.track("panel_login",{}),re&&_chunk7DG4UPWEjs.l.call(void 0, e,re,n,t);let h=typeof window<"u"?Me():null;setTimeout(()=>{if(re&&h){window.location.href=Ue(h,re);return}window.location.reload()},100)}}function D(){let M=setInterval(()=>{F(X=>X>0?X-1:(clearInterval(M),0))},1e3);return()=>{clearInterval(M)}}_react3.useEffect.call(void 0, ()=>{_optionalChain([i, 'optionalAccess', _4 => _4.status])==="ok"&&_optionalChain([i, 'optionalAccess', _5 => _5.retryIn])>0&&(F(i.retryIn),D())},[i]);function $(){r(""),c(null),d("default"),o()}function ge(M){M.preventDefault(),z()}return _jsxruntime.jsx.call(void 0, "main",{className:"mx-auto flex max-w-md flex-1 flex-col justify-center space-y-8",children:_jsxruntime.jsx.call(void 0, "div",{className:_chunkDY2S42Q6js.d.call(void 0, "flex min-w-sm flex-col gap-6"),children:_jsxruntime.jsxs.call(void 0, ue,{children:[_jsxruntime.jsxs.call(void 0, be,{children:[_jsxruntime.jsx.call(void 0, ve,{className:"text-2xl",children:"Wpisz kod z maila"}),_jsxruntime.jsx.call(void 0, Mt,{children:"Sprawd\u017A czy przypadkiem nie wyl\u0105dowa\u0142 w spamie."})]}),_jsxruntime.jsxs.call(void 0, me,{children:[_jsxruntime.jsxs.call(void 0, "form",{onSubmit:ge,className:"flex flex-col gap-6",children:[_jsxruntime.jsx.call(void 0, "div",{className:"grid gap-2",children:_jsxruntime.jsx.call(void 0, "div",{className:"my-5 flex w-full items-center justify-center",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsxs.call(void 0, On,{id:"verify-code",maxLength:6,pattern:_inputotp.REGEXP_ONLY_DIGITS,onChange:M=>{E(M)},children:[_jsxruntime.jsxs.call(void 0, Ut,{children:[_jsxruntime.jsx.call(void 0, Se,{index:0}),_jsxruntime.jsx.call(void 0, Se,{index:1}),_jsxruntime.jsx.call(void 0, Se,{index:2})]}),_jsxruntime.jsx.call(void 0, Mn,{}),_jsxruntime.jsxs.call(void 0, Ut,{children:[_jsxruntime.jsx.call(void 0, Se,{index:3}),_jsxruntime.jsx.call(void 0, Se,{index:4}),_jsxruntime.jsx.call(void 0, Se,{index:5})]})]}),_jsxruntime.jsx.call(void 0, "span",{className:_chunkDY2S42Q6js.d.call(void 0, !C&&P?"text-red-500":"text-neutral-700 dark:text-neutral-400","text-xs"),children:!C&&P?u.length==0?"Kod nie mo\u017Ce by\u0107 pusty":"Kod musi sk\u0142ada\u0107 si\u0119 z cyfr":"Wpisz kod z maila"})]})})}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsxs.call(void 0, _chunkFGB5FJCIjs.q,{type:"submit",disabled:a||k,className:"relative w-full",children:[(a||k)&&_jsxruntime.jsx.call(void 0, "div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:_jsxruntime.jsx.call(void 0, Z,{})}),"Zaloguj si\u0119"]}),l.length>0&&_jsxruntime.jsx.call(void 0, "p",{className:"text-xs font-medium text-red-500",children:l})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-4 text-center text-sm",children:["Nie masz kodu?"," ",_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:$,className:"underline underline-offset-4",children:"Wr\xF3\u0107"})]})]})]})})})},ga=({analytics:e})=>{let{theme:t,allowedReturnOrigins:n,projectID:o,host:r}=_chunk7DG4UPWEjs.j.call(void 0, ),a=_chunkMG6VV5J2js.n.call(void 0, o,e,"panel"),i={"--button-background-color":_nullishCoalesce(_optionalChain([t, 'optionalAccess', _6 => _6.colors, 'optionalAccess', _7 => _7.brand]), () => ("#FFFFFF")),"--button-background-color-dark":_nullishCoalesce(_optionalChain([t, 'optionalAccess', _8 => _8.colors, 'optionalAccess', _9 => _9.brandDark]), () => ("#000000")),"--button-text-color":_nullishCoalesce(_optionalChain([t, 'optionalAccess', _10 => _10.colors, 'optionalAccess', _11 => _11.brandDark]), () => ("#000000")),"--button-text-color-dark":_nullishCoalesce(_optionalChain([t, 'optionalAccess', _12 => _12.colors, 'optionalAccess', _13 => _13.brand]), () => ("#FFFFFF"))},[c,d]=_react3.useState.call(void 0, "login"),[l]=_react.useAutoAnimate.call(void 0, {duration:300,easing:"ease-in-out",disrespectUserMotionPreference:!1}),m=()=>d(E=>E==="login"?"verifyCode":"login"),[g,k]=_react3.useState.call(void 0, ""),[u,v]=_react3.useState.call(void 0, "default"),[C,s]=_react3.useState.call(void 0, null),{mutateAsync:P,isPending:R}=_chunkFGB5FJCIjs.l.call(void 0, _chunkFGB5FJCIjs.j.publicApi.userPanelLogin),[q,F]=_react3.useState.call(void 0, "");_react3.useEffect.call(void 0, ()=>{if(typeof window>"u"||window.parent!==window)return;let E=Qe(window.location.search);E&&Xe(E);let z=_nullishCoalesce(E, () => (Me()));if(!z)return;let D=_chunk7DG4UPWEjs.k.call(void 0, o,r);D&&(window.location.href=Ue(z,D))},[n,o,r]);async function A(){F(""),v("default");let E=await P({email:g}),z=E.result.case==="success"?"ok":"error",D=0,$;E.result.case==="success"&&(D=E.result.value.retryIn),z==="error"&&($="Nieprawid\u0142owy adres email, spr\xF3buj ponownie."),s({status:z,retryIn:D,message:$}),z==="ok"&&c==="login"?m():z==="ok"&&c==="verifyCode"?v("success"):z==="error"&&F(_nullishCoalesce($, () => ("Nieprawid\u0142owy adres email, spr\xF3buj ponownie.")))}return _jsxruntime.jsx.call(void 0, _chunkMG6VV5J2js.l,{value:a,children:_jsxruntime.jsx.call(void 0, "div",{className:"bg-white text-black dark:bg-black dark:text-white",children:_jsxruntime.jsxs.call(void 0, "div",{className:"font-inter flex h-screen w-screen flex-col p-4",style:i,ref:l,children:[_jsxruntime.jsxs.call(void 0, "header",{children:[_optionalChain([t, 'optionalAccess', _14 => _14.logoDarkURL])&&_jsxruntime.jsx.call(void 0, "img",{src:_optionalChain([t, 'optionalAccess', _15 => _15.logoDarkURL]),className:"hidden dark:inline",alt:"Company Logo",draggable:!1}),_optionalChain([t, 'optionalAccess', _16 => _16.logoURL])&&_jsxruntime.jsx.call(void 0, "img",{src:_optionalChain([t, 'optionalAccess', _17 => _17.logoURL]),className:"dark:hidden",alt:"Company Logo",draggable:!1})]}),c==="login"&&_jsxruntime.jsx.call(void 0, pa,{projectID:o,host:r,reveal:m,email:g,setEmail:k,loginUser:A,isLoginLoading:R,errMsg:q}),c==="verifyCode"&&_jsxruntime.jsx.call(void 0, fa,{projectID:o,host:r,email:g,reveal:m,setEmail:k,loginUser:A,isLoginLoading:R,loginUserResponse:C,setLoginUserResponse:s,responseStatus:u,setResponseStatus:v,errMsg:q})]})})})},ya= exports.n =({analytics:e}={})=>_jsxruntime.jsx.call(void 0, ga,{analytics:e});function _n(e){let[t,n]=_react3.useState.call(void 0, ()=>{if(typeof window>"u")return e;let r=new URLSearchParams(window.location.search),a={};return Object.keys(e).forEach(i=>{let c=r.get(i);if(c!==null)try{a[i]=JSON.parse(c)}catch (e3){a[i]=c}}),{...e,...a}}),o=_react3.useCallback.call(void 0, r=>{n(a=>{let i={...a,...r};if(typeof window<"u"){let c=new URLSearchParams;Object.keys(i).forEach(l=>{let m=i[l];m!=null&&c.set(l,JSON.stringify(m))});let d=`${window.location.pathname}?${c.toString()}`;window.history.pushState({},"",d)}return i})},[]);return _react3.useEffect.call(void 0, ()=>{let r=()=>{let a=new URLSearchParams(window.location.search),i={};Object.keys(e).forEach(c=>{let d=a.get(c);if(d!==null)try{i[c]=JSON.parse(d)}catch (e4){i[c]=d}}),n({...e,...i})};return window.addEventListener("popstate",r),()=>window.removeEventListener("popstate",r)},[e]),[t,o]}function zn(e,t){if(e!=null)return e;let n=_optionalChain([t, 'optionalAccess', _18 => _18.trim, 'call', _19 => _19()]);if(!(n==null||n===""))return{tokens:_chunkFGB5FJCIjs.t.call(void 0, n)}}var _reactswitch = require('@radix-ui/react-switch'); var ut = _interopRequireWildcard(_reactswitch);function Fn({className:e,...t}){return _jsxruntime.jsx.call(void 0, ut.Root,{"data-slot":"switch",className:_chunkDY2S42Q6js.d.call(void 0, "peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:_jsxruntime.jsx.call(void 0, ut.Thumb,{"data-slot":"switch-thumb",className:_chunkDY2S42Q6js.d.call(void 0, "bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}function wa({}){let[e,t]=_react3.useState.call(void 0, {disableAll:!1});return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Powiadomienia"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:"Zarz\u0105dzaj swoimi powiadomieniami"}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-6",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center space-x-2",children:[_jsxruntime.jsx.call(void 0, Fn,{id:"disable-all-notifications",checked:e.disableAll,onCheckedChange:n=>t(o=>({...o,disableAll:n}))}),_jsxruntime.jsxs.call(void 0, _chunkH4WAQQVOjs.a,{htmlFor:"disable-all-notifications",className:"flex flex-col gap-1 text-base",children:["Wszystkie powiadomienia",_jsxruntime.jsx.call(void 0, "span",{className:"text-xs font-normal text-neutral-500 md:text-sm",children:"Ten przycisk mo\u017Ce wy\u0142\u0105czy\u0107 wszystkie powiadomienia"})]})]})})]})}var Bn=wa;function Hn({className:e,...t}){return _jsxruntime.jsx.call(void 0, "nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:_chunkDY2S42Q6js.d.call(void 0, "mx-auto flex w-full justify-center",e),...t})}function $n({className:e,...t}){return _jsxruntime.jsx.call(void 0, "ul",{"data-slot":"pagination-content",className:_chunkDY2S42Q6js.d.call(void 0, "flex flex-row items-center gap-1",e),...t})}function we({...e}){return _jsxruntime.jsx.call(void 0, "li",{"data-slot":"pagination-item",...e})}function je({className:e,isActive:t,size:n="icon",...o}){return _jsxruntime.jsx.call(void 0, "a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:_chunkDY2S42Q6js.d.call(void 0, _chunkFGB5FJCIjs.p.call(void 0, {variant:t?"outline":"ghost",size:n}),e),...o})}function Gn({className:e,...t}){return _jsxruntime.jsxs.call(void 0, je,{"aria-label":"Go to previous page",size:"default",className:_chunkDY2S42Q6js.d.call(void 0, "gap-1 px-2.5 sm:pl-2.5",e),...t,children:[_jsxruntime.jsx.call(void 0, _lucidereact.ChevronLeftIcon,{}),_jsxruntime.jsx.call(void 0, "span",{className:"hidden sm:block",children:"Previous"})]})}function Vn({className:e,...t}){return _jsxruntime.jsxs.call(void 0, je,{"aria-label":"Go to next page",size:"default",className:_chunkDY2S42Q6js.d.call(void 0, "gap-1 px-2.5 sm:pr-2.5",e),...t,children:[_jsxruntime.jsx.call(void 0, "span",{className:"hidden sm:block",children:"Next"}),_jsxruntime.jsx.call(void 0, _lucidereact.ChevronRightIcon,{})]})}function qt({className:e,...t}){return _jsxruntime.jsxs.call(void 0, "span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:_chunkDY2S42Q6js.d.call(void 0, "flex size-9 items-center justify-center",e),...t,children:[_jsxruntime.jsx.call(void 0, _lucidereact.MoreHorizontalIcon,{className:"size-4"}),_jsxruntime.jsx.call(void 0, "span",{className:"sr-only",children:"More pages"})]})}var Sa=e=>new Date(e*1e3).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),Ra=(e,t)=>new Intl.NumberFormat("en-US",{style:"currency",currency:t.toUpperCase()}).format(e/100),Aa={draft:"Szkic",unpaid:"Nieop\u0142acona",paid:"Op\u0142acona",overdue:"Zaleg\u0142a",cancelled:"Anulowana",completed:"Zako\u0144czone",processing:"Przetwarzane",refunded:"Zwr\xF3cone"},Ta={draft:"text-neutral-400",unpaid:"text-yellow-500",paid:"text-green-600",overdue:"text-red-500",cancelled:"text-neutral-400 line-through",completed:"text-green-600",processing:"text-blue-500",refunded:"text-purple-500"};function Da({openOrderDetails:e,projectID:t,accessToken:n}){let[o,r]=_react3.useState.call(void 0, 0),a=20,{data:i,isFetching:c}=_chunkFGB5FJCIjs.k.call(void 0, _chunkFGB5FJCIjs.j.publicApi.getOrders,{projectId:t,accessToken:n,offset:o,limit:a}),d=_nullishCoalesce(_optionalChain([i, 'optionalAccess', _20 => _20.orders]), () => ([])),l=_nullishCoalesce(_optionalChain([i, 'optionalAccess', _21 => _21.totalCount]), () => (0)),m=Math.floor(o/a)+1,g=Math.ceil(l/a),k=u=>{r(u)};return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Historia zam\xF3wie\u0144"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:"Twoje zam\xF3wienia"}),c?_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 flex w-full flex-col gap-3",children:[...Array(5)].map((u,v)=>_jsxruntime.jsxs.call(void 0, "div",{className:"rounded-xl bg-white p-4 shadow-sm dark:bg-neutral-800",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2",children:[_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.u,{className:"h-4 w-24"}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.u,{className:"h-3 w-32"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2 text-right",children:[_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.u,{className:"ml-auto h-4 w-16"}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.u,{className:"ml-auto h-3 w-12"})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-3",children:_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.u,{className:"h-3 w-40"})})]},v))}):d.length===0?_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 text-sm text-neutral-400",children:"Brak zam\xF3wie\u0144."}):_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 flex w-full flex-col gap-3",children:d.map(u=>_jsxruntime.jsxs.call(void 0, "button",{onClick:()=>e(u.id),className:"block rounded-xl bg-white p-4 text-left shadow-sm transition-colors hover:bg-neutral-50 dark:bg-neutral-800 dark:hover:bg-neutral-700",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsxs.call(void 0, "p",{className:"font-medium",children:["Zam\xF3wienie #",u.id]}),_jsxruntime.jsx.call(void 0, "p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:u.customerName||"Klient"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"text-right",children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-semibold",children:Ra(u.totalAmount,u.currency)}),_jsxruntime.jsx.call(void 0, "p",{className:`text-xs font-medium ${_nullishCoalesce(Ta[u.status], () => ("text-neutral-400"))}`,children:_nullishCoalesce(Aa[u.status], () => (u.status))})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-2 flex items-center justify-between text-xs text-neutral-500 dark:text-neutral-400",children:_jsxruntime.jsxs.call(void 0, "span",{children:["Data:"," ",u.createdAt?Sa(Number(u.createdAt.seconds)):"-"]})})]},u.id))}),g>1&&!c&&_jsxruntime.jsx.call(void 0, "div",{className:"mt-4 flex justify-center",children:_jsxruntime.jsx.call(void 0, Hn,{children:_jsxruntime.jsxs.call(void 0, $n,{children:[m>1&&_jsxruntime.jsx.call(void 0, we,{children:_jsxruntime.jsx.call(void 0, Gn,{onClick:()=>k(o-a)})}),m>2&&_jsxruntime.jsx.call(void 0, we,{children:_jsxruntime.jsx.call(void 0, je,{onClick:()=>k(0),children:"1"})}),m>3&&_jsxruntime.jsx.call(void 0, we,{children:_jsxruntime.jsx.call(void 0, qt,{})}),[m-1,m,m+1].filter(u=>u>0&&u<=g).map(u=>_jsxruntime.jsx.call(void 0, we,{children:_jsxruntime.jsx.call(void 0, je,{onClick:()=>k((u-1)*a),isActive:m===u,children:u})},u)),m<g-2&&_jsxruntime.jsx.call(void 0, we,{children:_jsxruntime.jsx.call(void 0, qt,{})}),m<g&&_jsxruntime.jsx.call(void 0, we,{children:_jsxruntime.jsx.call(void 0, je,{onClick:()=>k((g-1)*a),children:g})}),m<g&&_jsxruntime.jsx.call(void 0, we,{children:_jsxruntime.jsx.call(void 0, Vn,{onClick:()=>k(o+a)})})]})})})]})]})}var Kn=Da;var Zn=e=>new Date(e*1e3).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),Ea={active:"Aktywny",cancelled:"Anulowany",paused:"Wstrzymany"},Oa={active:"text-green-600",cancelled:"text-red-500",paused:"text-yellow-500"};function Ma({projectID:e}){let[t,n]=_react3.useState.call(void 0, []),[o,r]=_react3.useState.call(void 0, !0);return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Plany"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:"Twoje aktywne subskrypcje"}),o?_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 text-sm text-neutral-400",children:"\u0141adowanie..."}):t.length===0?_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 text-sm text-neutral-400",children:"Brak aktywnych plan\xF3w."}):_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 flex flex-col gap-4",children:t.map(a=>_jsxruntime.jsxs.call(void 0, "div",{className:"rounded-xl bg-white p-5 shadow-sm dark:bg-neutral-800",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-start justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-semibold",children:a.tierName}),a.configName&&_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:a.configName})]}),_jsxruntime.jsx.call(void 0, "span",{className:`text-sm font-medium ${_nullishCoalesce(Oa[a.status], () => ("text-neutral-500"))}`,children:_nullishCoalesce(Ea[a.status], () => (a.status))})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-3 grid grid-cols-2 gap-2 text-sm text-neutral-600 dark:text-neutral-400",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Dzie\u0144 rozliczenia:"})," ",a.billingDay]}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Data startu:"})," ",Zn(a.startDate)]}),a.endDate&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Data zako\u0144czenia:"})," ",Zn(a.endDate)]})]})]},a.id))})]})}var Jn=Ma;function _a(e,t,n,o){typeof window>"u"||(t&&_chunk7DG4UPWEjs.n.call(void 0, n,o),window.location.href=e)}function za({projectID:e,host:t,loginURL:n,screen:o,params:r,setParams:a,setActiveScreen:i}){let{status:c,exchangeError:d}=_chunkH4WAQQVOjs.j.call(void 0, "PanelReturns"),l=_chunkH4WAQQVOjs.i.call(void 0, ),m=c==="anonymous"&&(d==null||_chunkH4WAQQVOjs.g.call(void 0, d));_react3.useEffect.call(void 0, ()=>{m&&_a(n,d!=null,e,t)},[m,n,d,e,t]);let[g,k]=_react3.useState.call(void 0, "orders"),[u,v]=_react3.useState.call(void 0, {items:[],note:""}),[C,s]=_react3.useState.call(void 0, );if(c==="anonymous"&&!m)return _jsxruntime.jsxs.call(void 0, "div",{role:"alert",className:"flex flex-col items-start gap-3",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",children:l(_chunkH4WAQQVOjs.h.call(void 0, d))}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{type:"button",onClick:()=>window.location.reload(),children:l("errorRetry")})]});if(c!=="authenticated")return _jsxruntime.jsx.call(void 0, _chunkH4WAQQVOjs.s,{});let P=R=>{k(R),a({state:"returns",orderId:void 0,returnId:void 0}),i("returns")};if(o==="return-details"&&r.returnId)return _jsxruntime.jsx.call(void 0, _chunkH4WAQQVOjs.A,{returnId:r.returnId,onBack:()=>P("myReturns")});if(g==="myReturns")return _jsxruntime.jsx.call(void 0, _chunkH4WAQQVOjs.z,{onBack:()=>P("orders"),onSelectReturn:R=>{a({state:"return-details",returnId:R,orderId:void 0}),i("return-details")}});if(g==="result"&&C!=null)return _jsxruntime.jsx.call(void 0, _chunkH4WAQQVOjs.y,{returnId:C,onContinue:()=>P("orders"),onOpenMyReturns:()=>P("myReturns")});if(r.orderId){let R=r.orderId;return g==="confirmation"?_jsxruntime.jsx.call(void 0, _chunkH4WAQQVOjs.x,{orderId:R,items:u.items,note:u.note,onBack:()=>k("orders"),onSubmitted:q=>{s(q),v({items:[],note:""}),k("result"),a({orderId:void 0})}}):_jsxruntime.jsx.call(void 0, _chunkH4WAQQVOjs.w,{orderId:R,initialItems:u.items.length>0?u.items:void 0,initialNote:u.note,onBack:()=>{v({items:[],note:""}),a({orderId:void 0})},onContinue:q=>{v(q),k("confirmation")}})}return _jsxruntime.jsx.call(void 0, _chunkH4WAQQVOjs.v,{showLogout:!1,onSelectOrder:R=>{v({items:[],note:""}),k("orders"),a({orderId:R})},onOpenMyReturns:()=>P("myReturns")})}function Ht({accessToken:e,appearance:t,texts:n,...o}){return _jsxruntime.jsx.call(void 0, _chunkH4WAQQVOjs.k,{projectID:o.projectID,host:o.host,appearance:t,texts:n,panelAccessToken:e,children:_jsxruntime.jsx.call(void 0, za,{...o})})}var Fa=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g,Ba=e=>[...e.matchAll(Fa)].map(n=>({url:n[0],startIndex:n.index,endIndex:n.index+n[0].length-1})),Ha=(e,t)=>{let n="",o=0;t.sort((r,a)=>r.startIndex-a.startIndex);for(let{startIndex:r,endIndex:a,replacementText:i}of t)n+=e.slice(o,r),n+=i,o=a+1;return n+=e.slice(o),n},Yn=e=>{let t=Ba(e);return _jsxruntime.jsx.call(void 0, "p",{dangerouslySetInnerHTML:{__html:Ha(e,t.map(n=>(n.replacementText=`<a key=${n.url} href=${n.url} style="text-decoration: underline;" target="_blank">
2
2
  ${n.url}
3
- </a>`,n)))}})};var _protobuf = require('@bufbuild/protobuf');var _hlsjs = require('hls.js'); var _hlsjs2 = _interopRequireDefault(_hlsjs);function Qn(){typeof navigator>"u"||typeof navigator.mediaSession>"u"||(navigator.mediaSession.playbackState="playing")}function Xn(){typeof navigator>"u"||typeof navigator.mediaSession>"u"||(navigator.mediaSession.playbackState="paused")}function er(e,t){typeof navigator>"u"||typeof navigator.mediaSession>"u"||e!=null&&isNaN(e)||t!=null&&isNaN(t)||navigator.mediaSession.setPositionState({playbackRate:1,duration:e,position:t})}function tr(e){typeof navigator>"u"||typeof navigator.mediaSession>"u"||(navigator.mediaSession.metadata=new MediaMetadata({title:e.title,artwork:e.artwork?[{type:"image/png",src:e.artwork}]:void 0}),navigator.mediaSession.setActionHandler("play",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("pause",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("stop",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("seekbackward",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("seekforward",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("seekto",t=>{e.action(t)}))}function nr(){navigator.mediaSession.metadata=null}var Za=_react3.forwardRef.call(void 0, ({chapters:e,styles:t,updateCurrentTime:n,setCurrentTimeHandler:o,title:r,imageURL:a,uniqueProductID:i,onChapterChange:c},d)=>{let l;(G=>(G[G.Playing=0]="Playing",G[G.Paused=1]="Paused"))(l||={});let[m,g]=_react3.useState.call(void 0, 1);_react3.useEffect.call(void 0, ()=>{switch(m){case 0:Qn();break;case 1:Xn();break}},[m]),_react3.useImperativeHandle.call(void 0, d,()=>({selectChapter:f=>{Ke(f)}}));let[k,u]=_react3.useState.call(void 0, void 0),[v,C]=_react3.useState.call(void 0, void 0),s=_react3.useRef.call(void 0, null),P=_react3.useRef.call(void 0, void 0),R=_react3.useRef.call(void 0, void 0),q=_react3.useRef.call(void 0, null),F=_react3.useRef.call(void 0, null),[A,E]=_react3.useState.call(void 0, !0),[z,D]=_react3.useState.call(void 0, !1),[$,ge]=_react3.useState.call(void 0, !Ja());function M(f){f<10||localStorage.setItem(`__player__${i}_${_optionalChain([F, 'access', _22 => _22.current, 'optionalAccess', _23 => _23.id])}`,`${f}`)}function X(){let f=localStorage.getItem(`__player__${i}_${_optionalChain([F, 'access', _24 => _24.current, 'optionalAccess', _25 => _25.id])}`);if(f!=null)try{let U=parseInt(f);return isNaN(U)||U<0?void 0:U}catch (e5){return}}function ye(){let f=localStorage.getItem(`__player__${i}_last_chapter`);if(f!=null)return f}function Ce(f){localStorage.setItem(`__player__${i}_last_chapter`,f)}function re(f){localStorage.removeItem(`__player__${i}_${f}`)}function h(){s.current!=null&&(s.current.onloadeddata=()=>{if(s.current!=null){if(s.current.readyState<2&&ge(!0),s.current.readyState>=2&&ge(!1),!z){let f=X();f!=null&&it(f),D(!0)}if(A){E(!1);try{Nt()}catch(f){console.log("play error",f)}}}},s.current.onplay=()=>{},s.current.onseeked=()=>{},s.current.onseeking=()=>{},s.current.onpause=()=>{},s.current.onended=()=>{ae()},tr({title:_nullishCoalesce(r, () => ("")),artwork:a,action:f=>{switch(f.action){case"play":Nt();break;case"pause":It();break;case"seekbackward":ot(-15);break;case"seekforward":ot(15);break;case"seekto":f.seekTime&&it(f.seekTime);break;case"stop":It();break;default:break}}}),Ne())}function ae(){if(e==null||e.length==0)return;let f=e.findIndex(G=>G.id==_optionalChain([F, 'access', _26 => _26.current, 'optionalAccess', _27 => _27.id]));f==-1||(re(e[f].id),f+1>=e.length)||Ke(e[f+1])}function Ne(){Re(),R.current==null&&(R.current=setTimeout(()=>{Re(),R.current=void 0,Ne()},500))}function Ve(){R.current!=null&&clearTimeout(R.current)}function Re(){s.current!=null&&(g(s.current.paused?1:0),C(s.current.duration),u(s.current.currentTime),M(s.current.currentTime),er(s.current.duration,s.current.currentTime),s.current.networkState===s.current.NETWORK_LOADING&&s.current.readyState<=s.current.HAVE_FUTURE_DATA?ge(!0):ge(!1),n&&n(s.current.currentTime))}function Nt(){_optionalChain([s, 'access', _28 => _28.current, 'optionalAccess', _29 => _29.play, 'call', _30 => _30(), 'access', _31 => _31.then, 'call', _32 => _32(), 'access', _33 => _33.catch, 'call', _34 => _34()]),Re()}function It(){_optionalChain([s, 'access', _35 => _35.current, 'optionalAccess', _36 => _36.pause, 'call', _37 => _37()]),Re()}function Jr(){if(m===0){It();return}Nt()}function ot(f){if(s.current==null)return;let U=s.current.currentTime+f;if(U<0){s.current.currentTime=0;return}if(U>s.current.duration){s.current.currentTime=s.current.duration;return}s.current.currentTime+=f}function it(f){if(s.current!=null){if(u(f),f<0){s.current.currentTime=0;return}if(f>s.current.duration){s.current.currentTime=s.current.duration;return}s.current.currentTime=f}}function Yr(){s.current!=null&&(s.current.onplay=null,s.current.onseeked=null,s.current.onseeking=null,s.current.onpause=null,s.current.onended=null,s.current.src="",_optionalChain([P, 'access', _38 => _38.current, 'optionalAccess', _39 => _39.destroy, 'call', _40 => _40()]))}function dn(f){if(f.length==0)return;let U=ye();if(U==null){Ke(f[0]);return}let G=f.find(Ae=>Ae.id==U);if(G==null){Ke(f[0]);return}Ke(G)}function Ke(f){D(!1),E(!0),F.current=f,Qr(f.publicUrl),_optionalChain([c, 'optionalCall', _41 => _41(f)]),Ce(f.id)}function Qr(f){s.current!=null&&(s.current.canPlayType("application/vnd.apple.mpegurl")?s.current.src=f:_hlsjs2.default.isSupported()&&(P.current==null&&(P.current=new _hlsjs2.default,_optionalChain([P, 'access', _42 => _42.current, 'optionalAccess', _43 => _43.attachMedia, 'call', _44 => _44(s.current)])),_optionalChain([P, 'access', _45 => _45.current, 'optionalAccess', _46 => _46.loadSource, 'call', _47 => _47(f)])))}_react3.useEffect.call(void 0, ()=>{s.current!=null&&(h(),dn(e))},[s.current]),_react3.useEffect.call(void 0, ()=>{dn(e)},[e]),_react3.useEffect.call(void 0, ()=>(_optionalChain([o, 'optionalCall', _48 => _48(it)]),()=>{u(void 0),_optionalChain([s, 'access', _49 => _49.current, 'optionalAccess', _50 => _50.pause, 'call', _51 => _51()]),Yr(),nr()}),[]);let ln=f=>{let U=Math.floor(f/3600),G=Math.floor(f/60)%60,Ae=Math.floor(f%60),ea=U>0?U<10?`0${U}:`:`${U}:`:"",ta=Ae<10?`0${Ae}`:`${Ae}`;return isNaN(Ae)||isNaN(G)||isNaN(U)?"":`${ea}${G}:${ta}`},Xr=f=>{let U=parseFloat(f.value)/parseFloat(f.max)*100;q.current.style.setProperty("--seek-before-width",U+"%");let G=v*U/100;it(G)};return _jsxruntime.jsxs.call(void 0, "div",{id:"audio-player-container",className:"flex flex-col",style:t,ref:q,children:[_jsxruntime.jsx.call(void 0, "video",{ref:s,className:"hidden",poster:a,title:r}),_jsxruntime.jsx.call(void 0, "input",{type:"range",min:"0",max:v!=null?Math.floor(v).toString():100,value:_nullishCoalesce(k, () => (0)),onChange:f=>Xr(f.target),className:"w-full"}),_jsxruntime.jsxs.call(void 0, "section",{className:"flex w-full items-center justify-between text-sm font-medium",children:[_jsxruntime.jsx.call(void 0, "span",{id:"current-time",children:ln(k)}),_jsxruntime.jsx.call(void 0, "span",{id:"duration",children:ln(v)})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-6 flex items-center justify-center gap-x-12",children:[_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.q,{variant:"outline",onClick:()=>ot(-10),"aria-label":"Rewind 10 Seconds",children:"-10"}),_jsxruntime.jsxs.call(void 0, _chunk7SYNGA3Rjs.q,{variant:"outline",onClick:Jr,"aria-label":"Play Or Pause",children:[m===1&&_jsxruntime.jsx.call(void 0, _lucidereact.Play,{className:"h-5 w-5"}),m===0&&_jsxruntime.jsx.call(void 0, _lucidereact.Pause,{className:"h-5 w-5"})]}),_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.q,{variant:"outline",onClick:()=>ot(10),"aria-label":"Fast Forward 10 Seconds",children:"+10"})]}),$&&_jsxruntime.jsx.call(void 0, "div",{className:"mt-2 flex w-full justify-center",children:_jsxruntime.jsx.call(void 0, Z,{})})]})});function Ja(){return navigator.userAgent.toLowerCase().indexOf("safari/")>-1}var ar=Za;var Ya={pl:{returnsNavLabel:"Zwroty",openCourse:"Otw\xF3rz kurs"},en:{returnsNavLabel:"Returns",openCourse:"Open the course"}};function nt(e=_chunkAWG5OAK7js.m.call(void 0, )){return _chunkAWG5OAK7js.h.call(void 0, Ya,e)}function ir(){let[e,t]=ft.useState(13);return ft.useEffect(()=>{let n=setTimeout(()=>t(66),500);return()=>clearTimeout(n)},[]),_jsxruntime.jsx.call(void 0, "div",{className:"w-[60%] h-2 bg-gray-200 rounded-full overflow-hidden",children:_jsxruntime.jsx.call(void 0, "div",{className:"h-full bg-blue-600 transition-all duration-300",style:{width:`${e}%`}})})}function pe(e,...t){console.warn(e,...t)}function $t(e){console.error(e)}var eo=({accessToken:e,product:t,styles:n,reveal:o,onOpenCourse:r})=>{let a=t.productType,i=_chunk3N2VK426js.m.call(void 0, ),c=()=>i.track("panel_download",{},{product_id:t.productId.length<=64?t.productId:null}),d=_react3.useRef.call(void 0, null),[l]=_react.useAutoAnimate.call(void 0, ),[m,g]=_react3.useState.call(void 0, null),{mutateAsync:k,isPending:u}=_chunk7SYNGA3Rjs.l.call(void 0, _chunk7SYNGA3Rjs.j.publicApi.userPanelGetFileDetails),v=_react3.useRef.call(void 0, void 0),[C,s]=_react3.useState.call(void 0, null),[P,R]=_react3.useState.call(void 0, null),[q,F]=_react3.useState.call(void 0, !1),{mutateAsync:A,isPending:E}=_chunk7SYNGA3Rjs.l.call(void 0, _chunk7SYNGA3Rjs.j.publicApi.userPanelGetAudiobookDetails),{mutateAsync:z,isPending:D}=_chunk7SYNGA3Rjs.l.call(void 0, _chunk7SYNGA3Rjs.j.publicApi.userPanelGetAudiobookDetailsDownloadURLs),[$,ge]=_react3.useState.call(void 0, null),[M,X]=_react3.useState.call(void 0, null);async function ye(){try{let h=await k({accessId:t.accessId,accessToken:e});if(h.result.case==="success"){g(h.result.value.files);return}else pe("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),pe("Kod b\u0142\u0119du: ",h.result.value)}catch(h){pe("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),$t("B\u0142\u0105d podczas pobierania danych:"+h)}}async function Ce(){try{let h=await A({accessId:t.accessId,accessToken:e});if(h.result.case==="audiobook"){s(h.result.value);return}else pe("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),pe("Kod b\u0142\u0119du: ",h.result.value)}catch(h){pe("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),$t("B\u0142\u0105d podczas pobierania danych:"+h)}}async function re(){try{let h=await z({accessId:t.accessId,accessToken:e,isBrowser:!0});if(h.result.case==="success"){R(h.result.value.audiobookDownloadDetails),F(h.result.value.isAvailableToDownloadInMobileApp===!0);return}else pe("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),pe("Kod b\u0142\u0119du: ",h.result.value)}catch(h){pe("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),$t("B\u0142\u0105d podczas pobierania danych:"+h)}}return _react3.useEffect.call(void 0, ()=>{a===1&&(Ce().then().catch(),re().then().catch())},[]),_react3.useEffect.call(void 0, ()=>{if(C!=null&&P!=null){let h=C.chapters;if(!h)return;let ae=h.map(Ne=>{let Ve=_optionalChain([P, 'optionalAccess', _52 => _52.find, 'call', _53 => _53(Re=>Re.chapterId===Ne.id)]);if(Ve!=null)return{...Ne,publicUrl:Ve.publicUrl,downloadableUrl:Ve.downloadableUrl,duration:Ve.duration}}).filter(Ne=>Ne!=null);ae!=null&&ae.length>0&&X(ae)}},[C,P]),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "div",{className:"mb-3 space-y-4 rounded bg-white p-4 dark:bg-black",children:_jsxruntime.jsxs.call(void 0, _chunk7SYNGA3Rjs.q,{onClick:()=>o(),variant:"ghost",className:"w-fit",children:[_jsxruntime.jsx.call(void 0, _lucidereact.ChevronLeft,{className:"h-6 w-6"}),_jsxruntime.jsx.call(void 0, "span",{className:"font-inter text-sm font-medium",children:"Wr\xF3\u0107"})]})}),_jsxruntime.jsxs.call(void 0, "main",{className:"grid grid-cols-1 justify-center gap-6 sm:justify-start lg:grid-cols-2",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full max-w-xl flex-col gap-6",children:[a===2&&_jsxruntime.jsxs.call(void 0, "div",{ref:l,className:"flex flex-col space-y-4 rounded bg-white p-6 drop-shadow-xl dark:border dark:border-neutral-700 dark:bg-neutral-800 dark:drop-shadow-none",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between gap-x-4",children:[_jsxruntime.jsx.call(void 0, "h4",{className:"text-xl font-semibold",children:"Twoje pliki"}),(m==null||m.length==0)&&_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.q,{onClick:ye,"aria-label":"Download Product",className:"text-sm font-medium transition-opacity duration-300 ease-in-out hover:opacity-80 active:opacity-80",style:n,children:u?_jsxruntime.jsx.call(void 0, Z,{}):"Wy\u015Bwietl"})]}),u&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col items-start gap-2",children:[_jsxruntime.jsx.call(void 0, ir,{}),_jsxruntime.jsx.call(void 0, "p",{className:"font-bold transition hover:text-blue-600",children:"Trwa przygotowanie plik\xF3w..."})]}),m!=null&&m.length>0&&_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col items-start justify-start gap-2",children:m.map((h,ae)=>_jsxruntime.jsxs.call(void 0, "a",{target:"_blank",className:"flex w-fit items-center gap-2 rounded-md bg-neutral-800 px-3 py-2 text-neutral-200 dark:bg-neutral-200 dark:text-neutral-800",href:h,download:!0,onClick:c,children:[`Plik numer ${ae+1}`,_jsxruntime.jsx.call(void 0, _lucidereact.Download,{width:14,height:14})]},ae))})]}),a===4&&_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col items-center justify-center rounded-xl bg-white p-6 drop-shadow-xl dark:bg-neutral-900 dark:drop-shadow-none",children:_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.q,{onClick:()=>r(t.accessId),className:"text-sm font-medium transition-opacity duration-300 ease-in-out hover:opacity-80 active:opacity-80",style:n,children:nt().openCourse})}),a===1&&_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col space-y-6 rounded-xl bg-white p-3 drop-shadow-xl dark:bg-neutral-900 dark:drop-shadow-none",children:[_jsxruntime.jsx.call(void 0, "h4",{className:"text-xl font-semibold",children:_nullishCoalesce(_optionalChain([$, 'optionalAccess', _54 => _54.name]), () => ("Odtwarzacz"))}),_optionalChain([$, 'optionalAccess', _55 => _55.description])&&_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",children:_optionalChain([$, 'optionalAccess', _56 => _56.description])}),_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:E?_jsxruntime.jsxs.call(void 0, "div",{className:"flex gap-2",children:[_jsxruntime.jsx.call(void 0, Z,{}),_jsxruntime.jsx.call(void 0, "p",{className:"text-xl font-semibold",children:"Trwa pobierania audiobooka..."})]}):_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:M!=null?_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:_jsxruntime.jsx.call(void 0, ar,{ref:d,chapters:M,title:_nullishCoalesce(_nullishCoalesce(_optionalChain([C, 'optionalAccess', _57 => _57.name]), () => (t.productName)), () => (void 0)),imageURL:_nullishCoalesce(_nullishCoalesce(_optionalChain([C, 'optionalAccess', _58 => _58.coverImage]), () => (t.productImageUrl)), () => (void 0)),styles:n,setCurrentTimeHandler:h=>{v.current=h},uniqueProductID:t.productId,onChapterChange:h=>{ge(h)}})}):_jsxruntime.jsx.call(void 0, "p",{className:"mt-2",children:"Wybierz rozdzia\u0142, kt\xF3ry ci\u0119 interesuje."})})}),_jsxruntime.jsxs.call(void 0, "div",{className:"rounded-xl bg-neutral-100 p-3 dark:bg-neutral-800",children:[_jsxruntime.jsx.call(void 0, "p",{className:"mt-3 mb-3 text-xs",children:q?"Mo\u017Cesz s\u0142ucha\u0107 tego audiobooka w aplikacji r\xF3wnie\u017C bez dost\u0119pu do internetu.":"Mo\u017Cesz s\u0142ucha\u0107 tego audiobooka w aplikacji."}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex gap-3",children:[_jsxruntime.jsx.call(void 0, "a",{href:"https://apps.apple.com/us/app/bitsnap/id6741902807",children:_jsxruntime.jsx.call(void 0, "img",{width:"100",src:"https://bitsnap.pl/appstore.svg",alt:"Pobierz aplikacje z AppStore"})}),_jsxruntime.jsx.call(void 0, "a",{href:"https://docs.bitsnap.pl/guides/audiobook",children:_jsxruntime.jsx.call(void 0, "img",{width:"100",src:"https://bitsnap.pl/playstore.svg",alt:"Pobierz aplikacj\u0119 z GooglePlay"})})]})]})]})}),_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center justify-center rounded-xl bg-white p-3 drop-shadow-xl dark:bg-neutral-900 dark:drop-shadow-none",children:a===1&&_jsxruntime.jsx.call(void 0, "div",{className:"max-h-96 w-full overflow-y-auto",children:E?_jsxruntime.jsxs.call(void 0, "div",{className:"jusitfy-center flex flex-col items-center gap-2",children:[_jsxruntime.jsx.call(void 0, Z,{}),_jsxruntime.jsx.call(void 0, "p",{children:"\u0141adowanie rozdzia\u0142\xF3w..."})]}):_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "h2",{className:"mb-3 text-xl font-semibold",children:"Rozdzia\u0142y"}),M==null?_jsxruntime.jsx.call(void 0, "p",{children:"Brak rozdzia\u0142\xF3w do wy\u015Bwietlenia."}):_jsxruntime.jsx.call(void 0, "ul",{className:"flex w-full flex-col gap-2",children:M.map((h,ae)=>_jsxruntime.jsxs.call(void 0, "li",{className:"flex items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "button",{className:_chunkAWG5OAK7js.d.call(void 0, "w-full rounded-lg p-2 text-left transition hover:bg-neutral-200 active:bg-neutral-200 dark:hover:bg-neutral-700 dark:active:bg-neutral-700",_optionalChain([$, 'optionalAccess', _59 => _59.id])==h.id?"bg-neutral-200 dark:bg-neutral-700":"bg-neutral-100 dark:bg-neutral-800 dark:text-neutral-300"),onClick:()=>{d.current.selectChapter(h)},children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-medium",children:h.name}),h.duration&&_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs text-neutral-500",children:[Math.floor(h.duration/60),":",String(Math.floor(h.duration%60)).padStart(2,"0")]})]}),h.description&&_jsxruntime.jsx.call(void 0, "p",{className:"mt-3 text-xs",children:h.description})]}),C&&C.isDownloadable&&h.downloadableUrl&&_jsxruntime.jsx.call(void 0, "a",{href:h.downloadableUrl,onClick:c,children:_jsxruntime.jsx.call(void 0, _lucidereact.Download,{width:14,height:14})})]},ae))})]})})})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"w-full max-w-3xl space-y-6 rounded-xl bg-white p-6 drop-shadow-xl dark:bg-neutral-900 dark:drop-shadow-none",children:[_jsxruntime.jsx.call(void 0, "h2",{className:"text-3xl font-semibold",children:t.productName}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-normal text-neutral-600 dark:text-neutral-300",children:t.productDescription}),_jsxruntime.jsx.call(void 0, "img",{src:t.productImageUrl,alt:"Product Photo",width:384,height:384,className:"max-h-sm max-w-sm",draggable:!1})]})]})]})},lr=eo;var ao=({accessToken:e,projectID:t,loginURL:n,styles:o,activeScreen:r,params:a,setParams:i,openCourse:c})=>{let{data:d,isLoading:l}=_chunk7SYNGA3Rjs.k.call(void 0, _chunk7SYNGA3Rjs.j.publicApi.userPanelGetProducts,{accessToken:e});if(l)return _jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2 bg-white p-2 dark:bg-black",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-dark font-inter font-medium dark:text-white",children:"\u0141adowanie..."}),_jsxruntime.jsx.call(void 0, Z,{})]});if(d&&d.result.case==="failure")return console.warn("error:",`Kod b\u0142\u0119du: ${d.result.value}`),_chunk5DDLYVBGjs.n.call(void 0, t),window.location.href=n,null;let m=d&&d.result.case==="success"?d.result.value.products:[];return _jsxruntime.jsx.call(void 0, oo,{accessToken:e,products:m,styles:o,loginURL:n,activeScreen:r,params:a,setParams:i,openCourse:c})},ur=ao,oo=({accessToken:e,products:t,styles:n,loginURL:o,activeScreen:r,params:a,setParams:i,openCourse:c})=>{if(t.length===0)return window.location.href=o,null;let[d,l]=_react3.useState.call(void 0, a.product?_protobuf.fromJsonString.call(void 0, _chunk7SYNGA3Rjs.e,a.product):void 0),m=u=>{u==null?(l(void 0),i({product:void 0,state:"products"})):i({product:_protobuf.toJsonString.call(void 0, _chunk7SYNGA3Rjs.e,u),state:"products"})};function g(u){switch(u){case 1:return"Audio";case 2:return"Plik";case 3:return"Bilet";case 4:return"Kurs";default:return}}function k(u){if(u.productType===4){c(u.accessId);return}l(u),m(u)}return r==="products"&&d!=null?_jsxruntime.jsx.call(void 0, lr,{accessToken:e,product:d,styles:n,reveal:m,onOpenCourse:c}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Hej \u{1F44B}"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:"Poni\u017Cej znajdziesz swoje produkty"}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 flex flex-wrap items-center justify-center gap-9 sm:justify-start",children:_optionalChain([t, 'optionalAccess', _60 => _60.map, 'call', _61 => _61((u,v)=>_jsxruntime.jsxs.call(void 0, "section",{onClick:()=>k(u),className:"w-full max-w-xs cursor-pointer rounded drop-shadow-xl dark:border dark:border-slate-600 dark:drop-shadow-none",children:[_jsxruntime.jsxs.call(void 0, "section",{className:"flex flex-col items-center space-y-2 rounded bg-slate-100 p-4 dark:bg-neutral-900",children:[u.productType&&_jsxruntime.jsx.call(void 0, "div",{className:"w-fit self-end rounded bg-red-900 px-4 py-1",children:_jsxruntime.jsx.call(void 0, "span",{className:"text-sm font-medium text-white dark:text-slate-100",children:g(u.productType)})}),_jsxruntime.jsx.call(void 0, "div",{className:"jusitfy-center flex max-h-40 items-center",children:_jsxruntime.jsx.call(void 0, "img",{src:u.productImageUrl,alt:`Product ${v} Photo`,draggable:!1,className:"aspect-auto max-h-40"})})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-4 rounded bg-white p-4 dark:bg-black",children:[_jsxruntime.jsx.call(void 0, "h2",{className:"text-xl font-semibold",children:u.productName}),_jsxruntime.jsx.call(void 0, "p",{title:u.productDescription,className:"line-clamp-3 text-sm font-normal text-neutral-600 dark:text-neutral-300",children:Yn(u.productDescription)}),_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.q,{onClick:C=>{C.stopPropagation(),k(u)},className:"w-full text-sm font-medium transition-opacity duration-300 ease-in-out hover:opacity-80 active:opacity-80",style:n,children:"Zobacz"})]})]},v))])})]})};function uo({activeScreen:e,setActiveScreen:t,setParams:n,styles:o,theme:r,logout:a}){return _jsxruntime.jsxs.call(void 0, "header",{className:"md:border-r-neutral-150 md:bg-beige-50 fixed right-0 bottom-0 left-0 z-10 flex h-12 w-full items-center bg-neutral-800 md:static md:z-0 md:min-h-screen md:w-auto md:border-r dark:md:border-r-neutral-900",children:[_jsxruntime.jsx.call(void 0, mo,{activeScreen:e,setActiveScreen:t,setParams:n}),_jsxruntime.jsx.call(void 0, po,{activeScreen:e,setActiveScreen:t,setParams:n,theme:r,logout:a})]})}var fr=uo;function mo({activeScreen:e,setActiveScreen:t,setParams:n}){let{returnsNavLabel:o}=nt();return _jsxruntime.jsxs.call(void 0, "nav",{className:"flex w-full items-center justify-evenly gap-4 md:hidden",children:[_jsxruntime.jsx.call(void 0, yt,{panelScreen:"products",label:"Produkty",imageURL:"/icons/bitsnap-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n}),_jsxruntime.jsx.call(void 0, yt,{panelScreen:"orders",label:"Faktury",imageURL:"/icons/category-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n}),_jsxruntime.jsx.call(void 0, yt,{panelScreen:"returns",label:o,icon:_jsxruntime.jsx.call(void 0, _lucidereact.Undo2,{className:"h-5 w-5 text-white","aria-hidden":!0}),activeScreen:e,setActiveScreen:t,setParams:n}),_jsxruntime.jsx.call(void 0, yt,{panelScreen:"profile",label:"Profil",imageURL:"/icons/profile-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n})]})}function yt({panelScreen:e,label:t,imageURL:n,icon:o,activeScreen:r,setActiveScreen:a,setParams:i}){return _jsxruntime.jsxs.call(void 0, _chunk7SYNGA3Rjs.q,{onClick:()=>{a(e),i({product:void 0,state:e})},"aria-label":t,variant:null,className:_chunkAWG5OAK7js.d.call(void 0, "flex flex-col gap-0",r===e?"opacity-100":"opacity-50"),children:[_nullishCoalesce(o, () => (_jsxruntime.jsx.call(void 0, "img",{src:n,alt:t,className:"scale-75"}))),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs font-normal text-white",children:t})]})}function ht({panelScreen:e,label:t,imageURL:n,darkImageURL:o,icon:r,activeScreen:a,setActiveScreen:i,setParams:c,isExpanded:d}){return _jsxruntime.jsxs.call(void 0, _chunk7SYNGA3Rjs.q,{onClick:()=>{i(e),c({product:void 0,state:e})},variant:a===e?"secondary":"ghost",className:"justify-start",children:[r!=null?_jsxruntime.jsx.call(void 0, "span",{className:_chunkAWG5OAK7js.d.call(void 0, "inline-flex h-5 w-5 items-center justify-center",d?"mr-4":"mr-2"),children:r}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "img",{src:n,alt:t,className:_chunkAWG5OAK7js.d.call(void 0, "aspect-auto h-5 w-5 dark:hidden",d?"mr-4":"mr-2")}),_jsxruntime.jsx.call(void 0, "img",{src:o,alt:t,className:_chunkAWG5OAK7js.d.call(void 0, "hidden aspect-auto h-5 w-5 dark:inline",d?"mr-4":"mr-2")})]}),d&&_jsxruntime.jsx.call(void 0, "span",{className:"md:text-medium hidden md:inline",children:t})]})}function po({activeScreen:e,setActiveScreen:t,setParams:n,theme:o,logout:r}){let[a]=_react.useAutoAnimate.call(void 0, ),[i,c]=_react3.useState.call(void 0, !0),{returnsNavLabel:d}=nt();return _jsxruntime.jsxs.call(void 0, "div",{ref:a,className:_chunkAWG5OAK7js.d.call(void 0, "hidden px-4 pt-4 pb-12 md:flex md:h-full md:flex-col dark:bg-neutral-900",i?"md:w-52":"md:w-16"),children:[_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center justify-between",children:_jsxruntime.jsx.call(void 0, fo,{theme:o,isExpanded:i})}),_jsxruntime.jsx.call(void 0, mr,{className:"my-6"}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-1 flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, ht,{panelScreen:"products",label:"Produkty",imageURL:"/icons/bitsnap-dark-24x24.svg",darkImageURL:"/icons/bitsnap-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i}),_jsxruntime.jsx.call(void 0, ht,{panelScreen:"orders",label:"Zam\xF3wienia",imageURL:"/icons/category-dark-24x24.svg",darkImageURL:"/icons/category-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i}),_jsxruntime.jsx.call(void 0, ht,{panelScreen:"returns",label:d,icon:_jsxruntime.jsx.call(void 0, _lucidereact.Undo2,{className:"h-5 w-5","aria-hidden":!0}),activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i}),_jsxruntime.jsx.call(void 0, ht,{panelScreen:"profile",label:"Profil",imageURL:"/icons/profile-dark-24x24.svg",darkImageURL:"/icons/profile-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i})]}),_jsxruntime.jsx.call(void 0, mr,{className:"mb-6"}),_jsxruntime.jsxs.call(void 0, _chunk7SYNGA3Rjs.q,{onClick:r,children:[_jsxruntime.jsx.call(void 0, _lucidereact.LogOut,{className:"mr-2",width:16,height:16}),i&&_jsxruntime.jsx.call(void 0, "p",{className:"md:text-medium hidden md:inline md:text-center",children:"Wyloguj si\u0119"})]})]})}function mr({className:e}){return _jsxruntime.jsxs.call(void 0, "div",{className:_chunkAWG5OAK7js.d.call(void 0, "relative h-px w-full bg-neutral-300",e),children:[_jsxruntime.jsx.call(void 0, "div",{className:"absolute -top-px left-0 h-1 w-1 rounded-full bg-neutral-500"}),_jsxruntime.jsx.call(void 0, "div",{className:"absolute -top-px right-0 h-1 w-1 rounded-full bg-neutral-500"})]})}function fo({theme:e,isExpanded:t}){return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[e==null&&_jsxruntime.jsx.call(void 0, "p",{className:"text-xl tracking-wider md:inline dark:text-neutral-200",children:"bitsnap."}),(_optionalChain([e, 'optionalAccess', _62 => _62.logoDarkURL])||_optionalChain([e, 'optionalAccess', _63 => _63.logoURL]))&&_jsxruntime.jsx.call(void 0, "img",{src:_nullishCoalesce(e.logoDarkURL, () => (e.logoURL)),alt:"Company Logo",className:"hidden h-6 w-6 dark:inline",draggable:!1}),_optionalChain([e, 'optionalAccess', _64 => _64.logoURL])&&_jsxruntime.jsx.call(void 0, "img",{src:e.logoURL,alt:"Company Logo",className:"h-6 w-6 dark:hidden",draggable:!1})]})}function yo({email:e,logout:t}){return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Profil"}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-6 flex-1 md:flex-none",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-sm text-neutral-500",children:"Email"}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-2 text-base",children:e||"Brak danych"})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex w-full flex-col items-center space-y-2",children:_jsxruntime.jsxs.call(void 0, _chunk7SYNGA3Rjs.q,{onClick:t,className:"max-w-64 md:hidden",children:[_jsxruntime.jsx.call(void 0, _lucidereact.LogOut,{className:"mr-2",width:16,height:16}),_jsxruntime.jsx.call(void 0, "p",{className:"text-medium inline text-center",children:"Wyloguj si\u0119"})]})})]})}var yr=yo;var vo=_react3.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./course.js"))).then(e=>({default:e.PanelCourse})));function Vt(e){return _jsxruntime.jsx.call(void 0, _react3.Suspense,{fallback:_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center gap-2 p-2",role:"status",children:_jsxruntime.jsx.call(void 0, Z,{})}),children:_jsxruntime.jsx.call(void 0, vo,{...e})})}function Co({status:e}){let t={created:{color:"bg-neutral-100 text-neutral-700",icon:null},paid:{color:"bg-green-100 text-green-700",icon:_lucidereact.CheckCircle2},completed:{color:"bg-blue-100 text-blue-700",icon:_lucidereact.CheckCircle2},canceled:{color:"bg-red-100 text-red-700",icon:_lucidereact.AlertCircle},sent:{color:"bg-purple-100 text-purple-700",icon:_lucidereact.Truck},processing:{color:"bg-yellow-100 text-yellow-700",icon:_lucidereact.Loader2}},n=t[e]||t.created,o=n.icon,r={created:"Utworzone",paid:"Op\u0142acone",completed:"Zako\u0144czone",canceled:"Anulowane",sent:"Wys\u0142ane",processing:"Przetwarzane"};return _jsxruntime.jsxs.call(void 0, "span",{className:`inline-flex items-center gap-1 rounded-full px-3 py-1 text-sm font-medium ${n.color}`,children:[o&&_jsxruntime.jsx.call(void 0, o,{className:"h-4 w-4"}),r[e]||e]})}function No({orderID:e,email:t}){let[n,o]=_react3.useState.call(void 0, ""),r=_chunk7SYNGA3Rjs.l.call(void 0, _chunk7SYNGA3Rjs.j.publicApi.addPublicOrderComment);return _jsxruntime.jsxs.call(void 0, "form",{onSubmit:async i=>{if(i.preventDefault(),!!n.trim())try{await r.mutateAsync({projectId:"",orderId:e,message:n.trim(),accessToken:t}),o("")}catch(c){console.error("Failed to add comment:",c)}},className:"mt-4 space-y-2",children:[_jsxruntime.jsx.call(void 0, _chunkFLDI3BPYjs.a,{htmlFor:"comment",children:"Dodaj komentarz"}),_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.v,{id:"comment",value:n,onChange:i=>o(i.target.value),placeholder:"Wpisz komentarz...",rows:3,disabled:r.isPending}),_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.q,{type:"submit",disabled:!n.trim()||r.isPending,children:r.isPending?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _lucidereact.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Wysy\u0142anie..."]}):"Dodaj komentarz"})]})}function br(e){return e?new Date(Number(e.seconds)*1e3).toLocaleDateString("pl-PL",{year:"numeric",month:"long",day:"numeric"}):"N/A"}function vr(e,t){return new Intl.NumberFormat("pl-PL",{style:"currency",currency:t.toUpperCase()}).format(e/100)}function Io({orderID:e,initialEmail:t,onBack:n,accessToken:o,analytics:r}){let{theme:a,projectID:i}=_chunk5DDLYVBGjs.j.call(void 0, ),c=_chunk3N2VK426js.n.call(void 0, i,r,"order"),[d,l]=_react3.useState.call(void 0, t||""),[m,g]=_react3.useState.call(void 0, !1),{data:k,isLoading:u,error:v,refetch:C}=_chunk7SYNGA3Rjs.k.call(void 0, _chunk7SYNGA3Rjs.j.publicApi.getPublicOrderDetails,{projectId:_nullishCoalesce(i, () => ("")),orderId:e,email:d||void 0,accessToken:o},{enabled:!!e}),s=_optionalChain([k, 'optionalAccess', _65 => _65.result, 'access', _66 => _66.case])==="order"?k.result.value:null,P=_nullishCoalesce(_optionalChain([s, 'optionalAccess', _67 => _67.isVerified]), () => (!1)),R=s!=null;_react3.useEffect.call(void 0, ()=>{R&&c.track("panel_order_viewed",{},{order_ref:null})},[c,R]);let q=()=>{C(),g(!1)},F={"--button-background-color":_nullishCoalesce(_optionalChain([a, 'optionalAccess', _68 => _68.colors, 'optionalAccess', _69 => _69.brand]), () => ("#000000")),"--button-background-color-dark":_nullishCoalesce(_optionalChain([a, 'optionalAccess', _70 => _70.colors, 'optionalAccess', _71 => _71.brandDark]), () => ("#ffffff")),"--button-text-color":_nullishCoalesce(_optionalChain([a, 'optionalAccess', _72 => _72.colors, 'optionalAccess', _73 => _73.brandDark]), () => ("#000000")),"--button-text-color-dark":_nullishCoalesce(_optionalChain([a, 'optionalAccess', _74 => _74.colors, 'optionalAccess', _75 => _75.brand]), () => ("#000000"))};return u?_jsxruntime.jsx.call(void 0, "div",{className:"flex min-h-screen items-center justify-center",children:_jsxruntime.jsxs.call(void 0, "div",{className:"text-center",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Loader2,{className:"mx-auto h-8 w-8 animate-spin text-neutral-400"}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"\u0141adowanie zam\xF3wienia..."})]})}):v||!s?_jsxruntime.jsx.call(void 0, "div",{className:"flex min-h-screen items-center justify-center",children:_jsxruntime.jsx.call(void 0, ue,{className:"w-full max-w-md",children:_jsxruntime.jsx.call(void 0, me,{className:"pt-6",children:_jsxruntime.jsxs.call(void 0, "div",{className:"text-center",children:[_jsxruntime.jsx.call(void 0, _lucidereact.AlertCircle,{className:"mx-auto h-12 w-12 text-red-500"}),_jsxruntime.jsx.call(void 0, "h2",{className:"mt-4 text-xl font-semibold",children:"Zam\xF3wienie nie znalezione"}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"Nie znaleziono zam\xF3wienia o podanym numerze."})]})})})}):_jsxruntime.jsx.call(void 0, "div",{className:"w-full bg-white py-8 dark:bg-black",style:F,children:_jsxruntime.jsxs.call(void 0, "div",{className:"w-full px-4",children:[n&&_jsxruntime.jsxs.call(void 0, _chunk7SYNGA3Rjs.q,{onClick:n,variant:"ghost",className:"mb-4 w-fit",children:[_jsxruntime.jsx.call(void 0, _lucidereact.ChevronLeft,{className:"h-4 w-4"}),"Wr\xF3\u0107 do historii zam\xF3wie\u0144"]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mb-6 flex items-center gap-4",children:[_optionalChain([a, 'optionalAccess', _76 => _76.logoURL])&&_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "img",{src:a.logoURL,alt:"Project logo",className:`h-12 w-auto ${a.logoDarkURL?"dark:hidden":""}`}),a.logoDarkURL&&_jsxruntime.jsx.call(void 0, "img",{src:a.logoDarkURL,alt:"Project logo",className:"hidden h-12 w-auto dark:block"})]}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "h1",{className:"text-3xl font-bold",children:"Zam\xF3wienie"}),_jsxruntime.jsxs.call(void 0, "p",{className:"text-neutral-600 dark:text-neutral-400",children:["Numer zam\xF3wienia: #",s.orderId]})]})]}),_jsxruntime.jsxs.call(void 0, ue,{className:"mb-6",children:[_jsxruntime.jsx.call(void 0, be,{children:_jsxruntime.jsxs.call(void 0, ve,{className:"flex items-center",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Package,{className:"mr-2 h-5 w-5"}),"Status zam\xF3wienia"]})}),_jsxruntime.jsxs.call(void 0, me,{className:"space-y-6",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, Co,{status:s.status}),s.processingStatus&&_jsxruntime.jsxs.call(void 0, "span",{className:"text-sm text-neutral-600",children:["\xB7 ",s.processingStatus]})]}),_jsxruntime.jsxs.call(void 0, "p",{className:"mt-2 text-sm text-neutral-600",children:["Zam\xF3wienie z\u0142o\u017Cone ",br(s.createdAt)]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"border-t pt-4",children:[_jsxruntime.jsx.call(void 0, "h3",{className:"mb-3 font-semibold",children:"Dane klienta"}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Imi\u0119 i nazwisko:"})," ",_jsxruntime.jsx.call(void 0, "span",{className:P?"":"text-neutral-500",children:s.customerName})]}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Email:"})," ",_jsxruntime.jsx.call(void 0, "span",{className:P?"":"text-neutral-500",children:s.customerEmail})]}),s.customerPhone&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Telefon:"})," ",_jsxruntime.jsx.call(void 0, "span",{className:P?"":"text-neutral-500",children:s.customerPhone})]})]})]}),!P&&_jsxruntime.jsx.call(void 0, "div",{className:"border-t pt-4",children:_jsxruntime.jsxs.call(void 0, _chunk7SYNGA3Rjs.q,{onClick:()=>g(!0),variant:"outline",className:"w-full",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Lock,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),_jsxruntime.jsxs.call(void 0, ue,{className:"mb-6",children:[_jsxruntime.jsx.call(void 0, be,{children:_jsxruntime.jsx.call(void 0, ve,{children:"Produkty"})}),_jsxruntime.jsxs.call(void 0, me,{className:"space-y-6",children:[_jsxruntime.jsx.call(void 0, "div",{className:"space-y-4",children:s.items.map((A,E)=>_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-4",children:[A.imageUrl&&_jsxruntime.jsx.call(void 0, "img",{src:A.imageUrl,alt:A.name,className:"h-16 w-16 rounded object-cover"}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex-1",children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-medium",children:A.name}),_jsxruntime.jsxs.call(void 0, "p",{className:"text-sm text-neutral-600",children:["Ilo\u015B\u0107: ",A.quantity]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"text-right",children:_jsxruntime.jsx.call(void 0, "p",{className:"font-medium",children:vr(Number(A.price),A.currency)})})]},E))}),(s.deliveryAddress||s.deliveryMethod)&&_jsxruntime.jsxs.call(void 0, "div",{className:"border-t pt-4",children:[_jsxruntime.jsxs.call(void 0, "h3",{className:"mb-3 flex items-center font-semibold",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Truck,{className:"mr-2 h-5 w-5"}),"Informacje o dostawie"]}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2",children:[s.deliveryAddress&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Adres:"})," ",_jsxruntime.jsx.call(void 0, "span",{className:P?"":"text-neutral-500",children:s.deliveryAddress})]}),s.deliveryMethod&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Metoda:"})," ",s.deliveryMethod]}),s.trackingNumber&&P&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Tracking:"})," ",s.trackingNumber]})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"border-t pt-4",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between text-lg font-bold",children:[_jsxruntime.jsx.call(void 0, "span",{children:"Suma:"}),_jsxruntime.jsx.call(void 0, "span",{children:vr(Number(s.totalAmount),s.currency)})]})})]})]}),_jsxruntime.jsxs.call(void 0, ue,{children:[_jsxruntime.jsx.call(void 0, be,{children:_jsxruntime.jsxs.call(void 0, ve,{children:["Komentarze ",s.commentCount>0&&`(${s.commentCount})`]})}),_jsxruntime.jsxs.call(void 0, me,{children:[s.comments.length>0?_jsxruntime.jsx.call(void 0, "div",{className:"space-y-4",children:s.comments.map(A=>_jsxruntime.jsxs.call(void 0, "div",{className:"border-b pb-4 last:border-b-0",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"mb-1 flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:A.authorName||"System"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs text-neutral-500",children:br(A.createdAt)}),A.authorType==="admin"&&_jsxruntime.jsx.call(void 0, "span",{className:"rounded bg-blue-100 px-2 py-0.5 text-xs text-blue-700",children:"Admin"})]}),_jsxruntime.jsx.call(void 0, "p",{className:P?"":"text-neutral-500",children:A.message})]},A.id))}):_jsxruntime.jsx.call(void 0, "p",{className:"text-neutral-600",children:"Brak komentarzy."}),P?_jsxruntime.jsx.call(void 0, No,{orderID:s.orderId,email:d}):_jsxruntime.jsx.call(void 0, "div",{className:"mt-4",children:_jsxruntime.jsxs.call(void 0, _chunk7SYNGA3Rjs.q,{onClick:()=>g(!0),variant:"outline",className:"w-full",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Lock,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),m&&_jsxruntime.jsx.call(void 0, "div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:_jsxruntime.jsxs.call(void 0, ue,{className:"w-full max-w-md",children:[_jsxruntime.jsx.call(void 0, be,{children:_jsxruntime.jsx.call(void 0, ve,{children:"Zweryfikuj sw\xF3j email"})}),_jsxruntime.jsxs.call(void 0, me,{className:"space-y-4",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-700",children:"Podaj adres email u\u017Cyty przy sk\u0142adaniu zam\xF3wienia."}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2",children:[_jsxruntime.jsx.call(void 0, _chunkFLDI3BPYjs.a,{htmlFor:"verify-email",children:"Adres email"}),_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.r,{id:"verify-email",type:"email",placeholder:"twoj@email.com",value:d,onChange:A=>l(A.target.value)})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex gap-2",children:[_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.q,{variant:"outline",onClick:()=>g(!1),className:"flex-1",children:"Anuluj"}),_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.q,{onClick:q,className:"flex-1",children:"Zweryfikuj"})]})]})]})})]})})}function So(e){return _jsxruntime.jsx.call(void 0, Io,{...e})}var Zt=So;var To=({returnsAppearance:e,returnsTexts:t,analytics:n}={})=>{let{projectID:o,theme:r,loginURL:a,host:i}=_chunk5DDLYVBGjs.j.call(void 0, ),c=_chunk3N2VK426js.n.call(void 0, o,n,"panel"),d=_chunk5DDLYVBGjs.k.call(void 0, o,i),l=_chunk5DDLYVBGjs.m.call(void 0, o,i),{mutateAsync:m}=_chunk7SYNGA3Rjs.l.call(void 0, _chunk7SYNGA3Rjs.j.publicApi.userPanelLogout);async function g(){d&&await m({accessToken:d}),typeof window<"u"&&(_chunk5DDLYVBGjs.n.call(void 0, o,i),window.location.reload())}let[k]=_react.useAutoAnimate.call(void 0, ),u=D=>["products","notifications","profile","plans","orders","order-details","returns","return-details","course"].includes(D),[v,C]=_n({product:void 0,state:"products",orderId:void 0,returnId:void 0,course:void 0,item:void 0}),[s,P]=_react3.useState.call(void 0, u(v.state)?v.state:"products"),R=D=>{C({state:"order-details",orderId:D}),P("order-details")},q=()=>{C({state:"orders",orderId:void 0}),P("orders")},F=D=>C({orderId:void 0,returnId:void 0,course:void 0,item:void 0,...D}),A=D=>{C({state:"course",course:D,item:void 0,product:void 0}),P("course")},E=()=>{C({state:"products",course:void 0,item:void 0,product:void 0}),P("products")};_react3.useEffect.call(void 0, ()=>{u(v.state)&&(v.state==="course"||s==="course")&&P(v.state)},[v.state]);let z={"--button-background-color":_nullishCoalesce(_optionalChain([r, 'optionalAccess', _77 => _77.colors, 'optionalAccess', _78 => _78.brand]), () => ("#000000")),"--button-background-color-dark":_nullishCoalesce(_optionalChain([r, 'optionalAccess', _79 => _79.colors, 'optionalAccess', _80 => _80.brandDark]), () => ("#ffffff")),"--button-text-color":_nullishCoalesce(_optionalChain([r, 'optionalAccess', _81 => _81.colors, 'optionalAccess', _82 => _82.brandDark]), () => ("#000000")),"--button-text-color-dark":_nullishCoalesce(_optionalChain([r, 'optionalAccess', _83 => _83.colors, 'optionalAccess', _84 => _84.brand]), () => ("#000000"))};return _react3.useEffect.call(void 0, ()=>{if(d==null||d.length===0){window.location.href=_nullishCoalesce(a, () => ("/panel/login"));return}},[]),_react3.useEffect.call(void 0, ()=>{if(d==null||d.length===0){window.location.href=_nullishCoalesce(a, () => ("/panel/login"));return}},[s]),_react3.useEffect.call(void 0, ()=>{if(typeof window>"u"||window.parent!==window||!d)return;let D=Qe(window.location.search);D&&Xe(D);let $=_nullishCoalesce(D, () => (Me()));$&&(window.location.href=Ue($,d))},[d]),_jsxruntime.jsx.call(void 0, _chunk3N2VK426js.l,{value:c,children:_jsxruntime.jsxs.call(void 0, "div",{ref:k,className:"font-inter relative min-h-screen w-screen bg-beige-100 text-black dark:bg-black dark:text-white md:flex",children:[_jsxruntime.jsx.call(void 0, fr,{activeScreen:s,setActiveScreen:P,setParams:F,styles:z,theme:r,logout:g}),_jsxruntime.jsxs.call(void 0, "main",{className:"flex h-[calc(100vh-80px)] flex-col overflow-y-auto w-full p-5 md:h-screen",children:[s==="products"&&_jsxruntime.jsx.call(void 0, ur,{projectID:_nullishCoalesce(o, () => ("")),accessToken:d,loginURL:_nullishCoalesce(a, () => ("/panel/login")),styles:z,activeScreen:s,params:v,setParams:C,openCourse:A}),s==="course"&&v.course&&d&&_jsxruntime.jsx.call(void 0, Vt,{accessId:v.course,accessToken:d,theme:r,itemId:v.item,onItemChange:D=>C({item:D}),onBack:E}),s==="notifications"&&_jsxruntime.jsx.call(void 0, Bn,{}),s==="plans"&&_jsxruntime.jsx.call(void 0, Jn,{projectID:_nullishCoalesce(o, () => (""))}),s==="orders"&&_jsxruntime.jsx.call(void 0, Kn,{projectID:_nullishCoalesce(o, () => ("")),accessToken:_nullishCoalesce(d, () => ("")),openOrderDetails:R}),s==="order-details"&&v.orderId&&_jsxruntime.jsx.call(void 0, Zt,{orderID:v.orderId,onBack:q}),(s==="returns"||s==="return-details")&&d&&_jsxruntime.jsx.call(void 0, Ht,{projectID:_nullishCoalesce(o, () => ("")),host:i,accessToken:d,loginURL:_nullishCoalesce(a, () => ("/panel/login")),appearance:zn(e,_optionalChain([r, 'optionalAccess', _85 => _85.colors, 'optionalAccess', _86 => _86.brand])),texts:t,screen:s,params:v,setParams:C,setActiveScreen:P}),s==="profile"&&_jsxruntime.jsx.call(void 0, yr,{email:l,logout:g})]})]})})},Do= exports.q =To;var _reactquery = require('@tanstack/react-query');var _connect = require('@connectrpc/connect');var _connectweb = require('@connectrpc/connect-web');var le;(o=>{function e(r){return _connect.createClient.call(void 0, _chunk7SYNGA3Rjs.f,n(r))}o.get=e;let t=new Map;function n(r){let a=t.get(r);return a==null&&(a=_connectweb.createConnectTransport.call(void 0, {useBinaryFormat:!0,baseUrl:r+"/api/rpc",interceptors:[_chunkAWG5OAK7js.b]}),t.set(r,a)),a}})(le = exports.a||={});var _zod = require('zod'); var _zod2 = _interopRequireDefault(_zod);function _(e,t=2){return+(Math.round(+(e+"e+"+t))+"e-"+t)}function Nr(e,t){let n=typeof navigator>"u"?"pl-PL":navigator.language;return Intl.NumberFormat(n,{style:"currency",currency:t,currencyDisplay:"symbol"}).format(e/100)}var Vd=_zod2.default.object({event:_zod2.default.enum(["purchase","addToCart","customizeProduct","viewCart","removeFromCart","initiateCheckout","lead"]),step:_zod2.default.string().optional(),value:_zod2.default.number().optional(),currency:_zod2.default.string().optional(),content_name:_zod2.default.string().optional(),items:_zod2.default.array(_zod2.default.object({id:_zod2.default.string(),name:_zod2.default.string(),price:_zod2.default.number().default(0),currency:_zod2.default.string().default("PLN"),quantity:_zod2.default.number().default(1)})).optional()});function Jt(e){typeof window>"u"||(Oo(e),Uo(e),jo(e))}function Oo(e){try{typeof window.dataLayer>"u"&&(window.dataLayer=[]);let t=Mo(e);window.dataLayer.push(t)}catch(t){console.warn("cannot send google analytics event",t)}}function Mo(e){let t=_nullishCoalesce(_nullishCoalesce(e.value, () => (_optionalChain([e, 'access', _87 => _87.items, 'optionalAccess', _88 => _88.reduce, 'call', _89 => _89((a,i)=>a+(i.price||0)*(i.quantity||1),0)]))), () => (0)),n=_optionalChain([e, 'access', _90 => _90.items, 'optionalAccess', _91 => _91.map, 'call', _92 => _92(a=>({item_id:a.id,item_name:a.name||a.id,price:_((a.price||0)/100,2),quantity:a.quantity||1}))]),o={currency:e.currency||"PLN",value:_(t/100,2)};n&&n.length>0&&(o.items=n);let r;switch(e.event){case"purchase":r="purchase",o.transaction_id=e.step||`txn_${Date.now()}`;break;case"addToCart":r="add_to_cart";break;case"viewCart":r="view_cart";break;case"removeFromCart":r="remove_from_cart";break;case"initiateCheckout":r="begin_checkout";break;case"customizeProduct":r="customize_product";break;default:r=e.event}return{event:r,ecommerce:o,...e.step&&{step:e.step},...e.content_name&&{content_name:e.content_name}}}function Uo(e){if(typeof window.fbq>"u")return;let t="",n="",o={};switch(e.event){case"purchase":t="track",n="Purchase",o={category_name:e.step,...e};break;case"lead":t="track",n="Lead",o={category_name:e.step,...e};break;case"addToCart":t="track",n="Add to Cart",o={category_name:e.step,...e};break;case"customizeProduct":t="track",n="Customize Product",o={category_name:e.step,...e};break;case"viewCart":t="track",n="View Cart",o={category_name:e.step,...e};break;case"removeFromCart":t="track",n="Remove from Cart",o={category_name:e.step,...e};break;case"initiateCheckout":t="track",n="Initiate Checkout",o={category_name:e.step,...e};break;default:break}window.location.search.includes("analytics")&&console.log("Pushing FB event",t,n,o),window.fbq(t,n,o)}function jo(e){try{if(typeof window.ttq>"u")return;let t=_o(e);if(!t)return;window.location.search.includes("analytics")&&console.log("Pushing TikTok event",t.eventName,t.eventPayload),window.ttq.track(t.eventName,t.eventPayload)}catch(t){console.warn("cannot send tiktok analytics event",t)}}function _o(e){let t=_nullishCoalesce(_nullishCoalesce(e.value, () => (_optionalChain([e, 'access', _93 => _93.items, 'optionalAccess', _94 => _94.reduce, 'call', _95 => _95((a,i)=>a+(i.price||0)*(i.quantity||1),0)]))), () => (0)),n=_optionalChain([e, 'access', _96 => _96.items, 'optionalAccess', _97 => _97.map, 'call', _98 => _98(a=>({content_id:a.id,content_type:"product",content_name:a.name||a.id,quantity:a.quantity||1,price:_((a.price||0)/100,2)}))])||[];n.length===0&&e.content_name&&n.push({content_id:e.step||"unknown",content_type:"product",content_name:e.content_name,quantity:1,price:_(t/100,2)});let o={currency:e.currency||"PLN",value:_(t/100,2)};n.length>0&&(o.contents=n);let r=null;switch(e.event){case"purchase":r="Purchase";break;case"addToCart":r="AddToCart";break;case"initiateCheckout":r="InitiateCheckout";break;case"customizeProduct":r="CustomizeProduct";break;case"viewCart":return;case"removeFromCart":return;case"lead":return;default:return null}return{eventName:r,eventPayload:o}}function Ir(e){let{items:t,googlePayConfig:n,checkout:o,result:r,cartRequiresShipping:a}=e,i=_nullishCoalesce(e.locale, () => (_chunkAWG5OAK7js.m.call(void 0, )));if(r.totalAmount==null)return;let c=[];return a&&(c.push("SHIPPING_ADDRESS"),c.push("SHIPPING_OPTION")),{apiVersion:2,apiVersionMinor:0,callbackIntents:c,allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:["MASTERCARD","VISA"]},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:n.gateway,gatewayMerchantId:n.gatewayId}}}],emailRequired:!0,shippingAddressParameters:{phoneNumberRequired:a},shippingAddressRequired:a,shippingOptionRequired:a,shippingOptionParameters:a?{shippingOptions:r.methods.slice(0,5).map(l=>({id:l.id,label:l.name+` - ${Nr(l.amount,r.currency)}`,description:_nullishCoalesce(l.description, () => (""))})),defaultSelectedOptionId:r.selectedDeliveryMethod}:void 0,merchantInfo:{merchantId:n.merchantId+"",merchantName:n.merchantName},transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:_chunkAWG5OAK7js.j.call(void 0, "paymentForCart",i,e.texts),totalPrice:`${_(r.totalAmount/100,2)}`,currencyCode:r.currency,countryCode:r.country,checkoutOption:"COMPLETE_IMMEDIATE_PURCHASE",displayItems:zo(t,r.methods,_nullishCoalesce(r.selectedDeliveryMethod, () => ((r.methods.length>0?r.methods[0].id:void 0))),o.couponCode,r.couponValue,_chunkAWG5OAK7js.j.call(void 0, "coupon",i,e.texts))}}}function zo(e,t,n,o,r,a="Coupon"){let i=[],c=0;for(let l of e){if(l.details==null)continue;let m=_nullishCoalesce(_optionalChain([l, 'access', _99 => _99.details, 'access', _100 => _100.pricing, 'optionalAccess', _101 => _101.effectivePrice]), () => (l.details.price));c+=m*l.quantity,i.push({label:l.details.name+" x "+l.quantity,price:`${_(m/100,2)}`,type:"LINE_ITEM",status:"FINAL"})}let d=t.find(l=>l.id===n);return d!=null&&i.push({label:d.name,price:`${_(d.amount/100,2)}`,type:"SHIPPING_OPTION",status:"FINAL"}),o!=null&&r!=null&&i.push({label:`${a} ${o}`,price:`${_(r/100,2)}`,type:"DISCOUNT",status:"FINAL"}),c>0&&i.push({label:"Subtotal",price:`${_(c/100,2)}`,type:"SUBTOTAL",status:"FINAL"}),i}function Fe(e,t){return`${_chunkAWG5OAK7js.f}/api/integrations/${e}/public-commerce${t}`}function ke(e){return typeof e=="object"&&e!=null&&"ERR"in e}function H(e,t,n){return{ERR:!0,error:e,type:t,data:n}}function Sr(e,t){return _optionalChain([t, 'optionalAccess', _102 => _102.find, 'call', _103 => _103(n=>n.id===e||(_nullishCoalesce(_optionalChain([n, 'access', _104 => _104.variants, 'optionalAccess', _105 => _105.some, 'call', _106 => _106(o=>o.id===e)]), () => (!1))))])}function Rr(e,t){let n=new Set(t.map(o=>o.productID));return Array.from(new Set(e.filter(o=>!n.has(o))))}function Ar(e,t){let n=_optionalChain([e, 'optionalAccess', _107 => _107.trim, 'call', _108 => _108()]);if(!(n==null||n.length===0))try{let o=new URL(n,t);return o.protocol!=="http:"&&o.protocol!=="https:"?void 0:o.href}catch (e6){return}}var _zustand = require('zustand');var Be=_zustand.create.call(void 0, e=>({isCartVisible:!1,notice:void 0,setNotice:t=>e(n=>({...n,notice:t})),numberOfProductsInCart:0,showCart:()=>e(t=>({...t,isCartVisible:!0})),hideCart:()=>e(t=>({...t,isCartVisible:!1})),setNumberOfProductsInCart:t=>e(n=>({...n,numberOfProductsInCart:t}))}));var vt=_react3.createContext.call(void 0, {});function sl({texts:e,locale:t,children:n}){let o=_react3.useMemo.call(void 0, ()=>({texts:e,locale:t}),[e,t]);return _jsxruntime.jsx.call(void 0, vt.Provider,{value:o,children:n})}function Dr(){return _react3.useContext.call(void 0, vt)}function cl(e){let{texts:t,locale:n}=_react3.useContext.call(void 0, vt);return _chunkAWG5OAK7js.j.call(void 0, e,_nullishCoalesce(n, () => (_chunkAWG5OAK7js.m.call(void 0, ))),t)}function dl(){let{texts:e,locale:t}=_react3.useContext.call(void 0, vt),n=_nullishCoalesce(t, () => (_chunkAWG5OAK7js.m.call(void 0, )));return _react3.useMemo.call(void 0, ()=>o=>_chunkAWG5OAK7js.j.call(void 0, o,n,e),[n,e])}var Xt="bitsnap-pending-order";function Or(e,t){let n=new Map;for(let r of t)n.set(r.id,(_nullishCoalesce(n.get(r.id), () => (0)))+r.quantity);let o=[];for(let r of e){let a=n.get(r.id);a==null?o.push(r):r.quantity>a&&o.push({...r,quantity:r.quantity-a})}return o}var Ho=60*1e3;function Mr(e,t=Date.now,n=Ho){let o;return r=>{let a=`${r.orderId}:${r.ts}`,i=t();return _optionalChain([o, 'optionalAccess', _109 => _109.key])===a&&i-o.at<n?Promise.reject(new Error("pending order was asked about recently")):(o={key:a,at:i},e(r))}}function $o(e){if(!(e==null||e.length===0))try{let t=new URL(e,"https://bitsnap.invalid").pathname,n=/\/payment\/common\/([^/]+)\/([^/]+)\/?$/.exec(t);return n==null?void 0:{projectId:decodeURIComponent(n[1]),orderId:decodeURIComponent(n[2])}}catch (e7){return}}function Go(e){if(e==null||e.length===0)return!1;try{let t=new URL(e,"https://bitsnap.invalid").pathname;return/\/payment\/manualPayment\/[^/]+\/[^/]+\/?$/.test(t)}catch (e8){return!1}}function Vo(e,t=Date.now(),n={}){if(Go(e.url))return;let o=$o(e.url),r=_nullishCoalesce(Lr(e.orderId), () => (_optionalChain([o, 'optionalAccess', _110 => _110.orderId]))),a=_nullishCoalesce(Lr(e.projectId), () => (_optionalChain([o, 'optionalAccess', _111 => _111.projectId])));if(!(r==null||a==null))return{orderId:r,projectId:a,...n.cartProjectId!=null?{cartProjectId:n.cartProjectId}:{},lines:_nullishCoalesce(n.lines, () => ([])),ts:t}}function ml(e,t={}){let n=Vo(e,t.now,t);return n!=null&&Ko(n,t.storage)}function Lr(e){return e!=null&&e.length>0?e:void 0}function wt(){try{return typeof localStorage>"u"?void 0:localStorage}catch (e9){return}}function Ko(e,t=wt()){try{return _optionalChain([t, 'optionalAccess', _112 => _112.setItem, 'call', _113 => _113(Xt,JSON.stringify(e))]),t!=null}catch (e10){return!1}}function Er(e=wt()){try{let t=_optionalChain([e, 'optionalAccess', _114 => _114.getItem, 'call', _115 => _115(Xt)]);if(t==null)return;let n=JSON.parse(t);if(typeof n=="object"&&n!=null&&typeof n.orderId=="string"&&typeof n.projectId=="string"&&typeof n.ts=="number"&&n.orderId.length>0){let{orderId:o,projectId:r,cartProjectId:a,ts:i,lines:c}=n;return{orderId:o,projectId:r,...typeof a=="string"?{cartProjectId:a}:{},lines:Array.isArray(c)?c.filter(d=>typeof _optionalChain([d, 'optionalAccess', _116 => _116.id])=="string"&&typeof d.quantity=="number"):[],ts:i}}}catch (e11){}Qt(e)}function Qt(e=wt()){try{_optionalChain([e, 'optionalAccess', _117 => _117.removeItem, 'call', _118 => _118(Xt)])}catch (e12){}}function Ur(e){let t=_nullishCoalesce(_optionalChain([e, 'access', _119 => _119.details, 'optionalAccess', _120 => _120.status]), () => (Wo(_optionalChain([e, 'access', _121 => _121.details, 'optionalAccess', _122 => _122.$unknown]))));return t==="created"||t==="placed"||t==="paid"||t==="canceled"?t:"unknown"}function Wo(e){if(Array.isArray(e)){for(let t of e)if(_optionalChain([t, 'optionalAccess', _123 => _123.no])===3&&t.wireType===2&&t.data instanceof Uint8Array){let n=0,o=0;for(let r=0;o<t.data.length&&r<35;r+=7){let a=t.data[o++];if(n|=(a&127)<<r,!(a&128))break}if(o+n!==t.data.length)return;try{return new TextDecoder().decode(t.data.subarray(o))}catch (e13){return}}}}async function jr(e){let t=_nullishCoalesce(e.storage, () => (wt())),n=Er(t);if(n==null)return"none";if((_nullishCoalesce(e.now, () => (Date.now)))()-n.ts>864e5)return Qt(t),"expired";if(e.projectId!=null&&n.cartProjectId!=null&&n.cartProjectId!==e.projectId)return"pending";let r;try{r=await e.fetchStatus(n)}catch (e14){return"pending"}let a=Er(t);if(_optionalChain([a, 'optionalAccess', _124 => _124.orderId])!==n.orderId||a.ts!==n.ts)return"pending";if(r==="paid"||r==="placed"){try{await e.removeLines(n.lines)}catch (e15){return"pending"}return Qt(t),"paid"}return"pending"}var ei="__m_a",Hr=_react3.createContext.call(void 0, void 0),rn= exports.M =void 0;function zl(e){_chunk5DDLYVBGjs.a.call(void 0, {projectID:e}),rn= exports.M =e,typeof window<"u"&&_chunk5DDLYVBGjs.g.call(void 0, [window.location.origin])}function Ge(){return _nullishCoalesce(_nullishCoalesce(rn, () => (_optionalChain([document, 'access', _125 => _125.querySelector, 'call', _126 => _126('script[data-id][data-name="internal-cart"]'), 'optionalAccess', _127 => _127.getAttribute, 'call', _128 => _128("data-id")]))), () => (void 0))}function ti(){return _nullishCoalesce(_optionalChain([document, 'access', _129 => _129.querySelector, 'call', _130 => _130('script[data-id][data-name="internal-cart"]'), 'optionalAccess', _131 => _131.getAttribute, 'call', _132 => _132("data-custom-host")]), () => (void 0))}var ni=({children:e,locale:t})=>{let[n]=_react3.useState.call(void 0, ()=>new _reactquery.QueryClient),o=Dr();_react3.useEffect.call(void 0, ()=>{$e()},[]);let r=Ge();if(_react3.useEffect.call(void 0, ()=>{if(r==null)return;let i=()=>{oi(r).then(d=>{d==="paid"&&n.invalidateQueries({queryKey:["cart"]})})},c=()=>{document.visibilityState==="visible"&&i()};return i(),window.addEventListener("pageshow",i),document.addEventListener("visibilitychange",c),()=>{window.removeEventListener("pageshow",i),document.removeEventListener("visibilitychange",c)}},[r,n]),r==null)return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{});let a=on(r,_nullishCoalesce(t, () => (o.locale)),o.texts);return _jsxruntime.jsx.call(void 0, _reactquery.QueryClientProvider,{client:n,children:_jsxruntime.jsx.call(void 0, Hr.Provider,{value:a,children:e})})},en,ri=Mr(async e=>Ur(await le.get(_chunkAWG5OAK7js.f).getOrder({id:e.orderId,projectId:e.projectId})));function ql(){let{country:e,couponCode:t,selectedDeliveryMethod:n,postalCode:o}=_nullishCoalesce(L(), () => (kt));return{country:e,couponCode:t,selectedDeliveryMethod:n,postalCode:o}}function Fl(){return(_nullishCoalesce(_optionalChain([L, 'call', _133 => _133(), 'optionalAccess', _134 => _134.products]), () => ([]))).map(e=>({id:e.id,quantity:e.quantity}))}function ai(e){let t=L();Q({...t,products:Or(_nullishCoalesce(_optionalChain([t, 'optionalAccess', _135 => _135.products]), () => ([])),e)}),$e()}function oi(e){return en??=jr({projectId:e,fetchStatus:ri,removeLines:ai}).catch(t=>{console.warn("cannot check the pending order",t)}).finally(()=>{en=void 0}),en}var He=async(e,t)=>{let n=[];_optionalChain([t, 'optionalAccess', _136 => _136.items])!=null&&t.items.length>0?n=t.items:n=_nullishCoalesce(_optionalChain([L, 'call', _137 => _137(), 'optionalAccess', _138 => _138.products]), () => ([]));let o=Array.from(new Set(n.map(i=>i.productID)));if(o.length===0)return[];let r=new URLSearchParams;r.set("ids",o.join(",")),r.set("locale",_nullishCoalesce(_optionalChain([t, 'optionalAccess', _139 => _139.locale]), () => (_chunkAWG5OAK7js.m.call(void 0, ))));let a;try{let i=await fetch(_chunkAWG5OAK7js.c.call(void 0, Fe(e,`/products?${r.toString()}`)),{method:"GET"});if(i.status!=200)return H("products-load-failed","internal");a=await i.json()}catch(i){return console.warn("cannot load the products of the cart",i),H("products-load-failed","internal")}return n.flatMap(i=>{let c=Sr(i.productID,a.result);return c==null?[]:[{...i,details:ui(i.productID,c),catalogProductID:c.id}]})},Bl= exports.S =()=>{let e=_react3.useContext.call(void 0, Hr);if(e===void 0)throw new Error("useCartProvider must be used within a CartProvider");return e},Hl= exports.T =ni,ii=_zod2.default.object({isAvailable:_zod2.default.boolean(),merchantId:_zod2.default.string(),merchantName:_zod2.default.string(),gateway:_zod2.default.string(),gatewayId:_zod2.default.string()}),si=_zod2.default.object({id:_zod2.default.string(),productID:_zod2.default.string(),quantity:_zod2.default.number(),priceVersion:_zod2.default.string().optional(),metadata:_zod2.default.record(_zod2.default.string(),_zod2.default.string().optional()).optional(),url:_zod2.default.string().optional()}),ci=_zod2.default.object({country:_zod2.default.string().optional(),couponCode:_zod2.default.string().optional(),selectedDeliveryMethod:_zod2.default.string().optional(),postalCode:_zod2.default.string().optional(),email:_zod2.default.string().optional(),products:_zod2.default.array(si).optional(),googlePayConfig:ii.optional()}),kt={country:void 0,couponCode:void 0,email:void 0,selectedDeliveryMethod:void 0,postalCode:void 0,products:[],googlePayConfig:void 0},$r="checkout";function L(){try{let e=localStorage.getItem($r);return e==null?kt:ci.parse(JSON.parse(e))}catch (e16){return kt}}async function zr(e,t){let n=await He(e,{items:t.map((a,i)=>({...a,id:`price-check-${i}`}))});if(ke(n))return n;let o=Rr(t.map(a=>a.productID),n);if(o.length>0)return H("item-ids-not-found","notFound",o);let r=L();r.products==null&&(r.products=[]),r.products.push(...t.map(a=>({id:Math.random().toString(36).substring(7),productID:a.productID,quantity:a.quantity,priceVersion:_optionalChain([n, 'access', _140 => _140.find, 'call', _141 => _141(i=>i.productID===a.productID), 'optionalAccess', _142 => _142.details, 'optionalAccess', _143 => _143.pricing, 'optionalAccess', _144 => _144.priceVersion]),metadata:a.metadata,url:Ar(a.url,typeof window<"u"?window.location.href:void 0)}))),di(t,n),Jt({event:"addToCart",currency:"PLN",items:t.map(a=>({id:a.productID,name:_nullishCoalesce(a.name, () => ("")),price:_nullishCoalesce(a.price, () => (0)),quantity:a.quantity,currency:_nullishCoalesce(a.currency, () => ("PLN"))}))}),Q(r),$e()}function di(e,t){for(let n of e)try{let o=t.find(c=>c.productID===n.productID),r=_nullishCoalesce(_nullishCoalesce(_optionalChain([o, 'optionalAccess', _145 => _145.details, 'optionalAccess', _146 => _146.pricing, 'optionalAccess', _147 => _147.effectivePrice]), () => (_optionalChain([o, 'optionalAccess', _148 => _148.details, 'optionalAccess', _149 => _149.price]))), () => (n.price)),a=_nullishCoalesce(_optionalChain([o, 'optionalAccess', _150 => _150.details, 'optionalAccess', _151 => _151.currency]), () => (n.currency));if(r==null||a==null)continue;let i=_nullishCoalesce(_optionalChain([o, 'optionalAccess', _152 => _152.catalogProductID]), () => (n.productID));(_nullishCoalesce(n.analytics, () => (_chunk3N2VK426js.o.call(void 0, )))).track("add_to_cart",{qty:n.quantity,value_minor:Math.round(r*n.quantity),currency:a},{product_id:i,variant_id:i!==n.productID?n.productID:null})}catch (e17){}}function qr(e){let t=L(),n={...t,products:_optionalChain([t, 'optionalAccess', _153 => _153.products, 'optionalAccess', _154 => _154.filter, 'call', _155 => _155(o=>!e.includes(o.productID)&&!e.includes(o.id))])};Jt({event:"removeFromCart",items:e.map(o=>({id:o,name:"",price:0,quantity:1,currency:"PLN"}))}),Q(n),$e()}function Q(e){localStorage.setItem($r,JSON.stringify(e))}function Fr(e,t){if(e.products==null||e.products.length==0)return;let n=e.products.reduce((o,r)=>(r.metadata!=null&&Object.keys(r.metadata).forEach(a=>{let i=_optionalChain([r, 'access', _156 => _156.metadata, 'optionalAccess', _157 => _157[a]]);i!=null&&(o[a]=i)}),o),{});return{items:e.products.map(o=>({id:o.productID,quantity:o.quantity,priceVersion:o.priceVersion})),askForNote:!0,countries:e.country?[e.country]:void 0,metadata:n,locale:t}}var on=(e,t=_chunkAWG5OAK7js.m.call(void 0, ),n)=>{let o=ti();return o!=null&&_chunkAWG5OAK7js.g.call(void 0, o),{async checkIfApplePayIsAvailable(){if(typeof window>"u"||typeof document>"u"||!("ApplePaySession"in window))return!1;try{return(await le.get(_chunkAWG5OAK7js.f).isOneClickPaymentAvailable({projectId:e})).applePay}catch(r){return console.error("Error checking if Apple Pay is available",r),!1}},async getGooglePayConfiguration(r){if(typeof window>"u"||typeof document>"u")return{isAvailable:!1};try{let a=await li(e);if(_optionalChain([a, 'optionalAccess', _158 => _158.isAvailable])!=!0)return{isAvailable:!1};let i=L();if(i==null)return console.log("checkout is null"),{isAvailable:!1};let c=await He(e,{locale:t,items:r.items.map(g=>({id:Math.random().toString(36).substring(7),quantity:g.quantity,metadata:g.metadata,productID:g.productID}))});if(ke(c))return{isAvailable:!1};let d=await le.get(_chunkAWG5OAK7js.f).getPreOrderDetails({items:c.map(g=>_protobuf.create.call(void 0, _chunk7SYNGA3Rjs.c,{id:g.productID,quantity:g.quantity})),projectId:e,postCode:i.postalCode,couponCode:i.couponCode,countryCode:i.country,selectedDeliveryMethod:i.selectedDeliveryMethod});if(d.totalAmount==null)return{isAvailable:!1};let l=c.find(g=>_optionalChain([g, 'access', _159 => _159.details, 'optionalAccess', _160 => _160.isDeliverable])==!0)!=null,m=await Ir({items:c,googlePayConfig:a,checkout:i,cartRequiresShipping:l,result:d,locale:t,texts:n});return m==null?{isAvailable:!1}:{isAvailable:!0,config:m}}catch(a){return console.error("Error resolving Google Pay configuration",a),{isAvailable:!1}}},async clearCart(){let r=structuredClone(kt);r.country=_optionalChain([L, 'call', _161 => _161(), 'optionalAccess', _162 => _162.country]),Q(r),$e()},async getAvailableCountries(){let r=await fetch(_chunkAWG5OAK7js.c.call(void 0, Fe(e,"/countries")),{method:"GET"});if(r.status!=200)return[];try{return _zod2.default.array(_zod2.default.object({name:_zod2.default.string(),code:_zod2.default.string()})).parse(await r.json())}catch(a){return H(a.toString(),"internal")}},async getCountry(){let r=_optionalChain([L, 'call', _163 => _163(), 'optionalAccess', _164 => _164.country]);if(r==null){r="PL";let a=L();a.country=r,Q(a)}return r},async getNumberOfElementsInCart(){return _nullishCoalesce(_optionalChain([L, 'call', _165 => _165(), 'optionalAccess', _166 => _166.products, 'optionalAccess', _167 => _167.reduce, 'call', _168 => _168((r,a)=>r+a.quantity,0)]), () => (0))},async getProducts(){return await He(e,{locale:t})},async removeProductFromCart(r){return qr([r.id])},async setCountry(r){let a=L();a.country=r,Q(a)},async setCouponCodeIfPossible(r){let a=L();a.couponCode=r,Q(a)},async setPostalCode(r){let a=L();a.postalCode=r,Q(a)},async setDeliveryMethod(r){let a=L();a.selectedDeliveryMethod=r,Q(a)},async setEmail(r){let a=L();a.email=r,Q(a)},async addProduct(r){return await zr(e,[r])},async updateQuantity(r){let a=L();a.products=_optionalChain([a, 'access', _169 => _169.products, 'optionalAccess', _170 => _170.map, 'call', _171 => _171(i=>(i.id===r.id&&(i.quantity=r.quantity),i))]),Q(a),$e()},async getPaymentMethodChoice(){let r=Fr(L(),t);return r==null?null:Br(r)},async redirectToNextStep(r){let a=Fr(L(),t);if(a==null)return H("cart-is-empty","badInput");_optionalChain([r, 'optionalAccess', _172 => _172.paymentMethod])!=null&&(a.paymentMethod=r.paymentMethod);let i=await nn(a);return ke(i)?(console.warn("cannot create payment URL",i.error),i):{url:i.url,...i.orderId!=null?{orderId:i.orderId}:{},...i.projectId!=null?{projectId:i.projectId}:{}}},async justRedirectToPayment(r){let a={items:[{id:r.productID,quantity:1}],askForNote:!1,details:r.email||r.name?{name:r.name,email:r.email}:void 0,locale:_nullishCoalesce(r.locale, () => (t))};a=an(a),r.country==null&&(r.country="pl"),a.details==null&&(a.details={}),a.details.address==null&&(a.details.address={}),a.details.address.country=r.country,r.marketingAgreement===!0&&(a.additionalAgreements=[{id:ei,name:"",required:!0,answer:!0}]);let i=await nn(a);return ke(i)?i:{url:i.url}},async getApplePayPreview(r){let a=L();try{let i=await le.get(_chunkAWG5OAK7js.f).getPreOrderDetails({items:r.items.map(c=>_protobuf.create.call(void 0, _chunk7SYNGA3Rjs.c,{id:c.productID,quantity:c.quantity})),projectId:e,postCode:a.postalCode,couponCode:a.couponCode,countryCode:a.country,selectedDeliveryMethod:a.selectedDeliveryMethod});return i.totalAmount==null||i.currency.length===0?H("pre-order-unavailable","internal"):{countryCode:i.country||a.country||"PL",currencyCode:i.currency,totalAmount:`${_(i.totalAmount/100,2)}`}}catch(i){return console.warn("cannot load the Apple Pay preview",i),H("pre-order-unavailable","internal")}},async completeApplePayPayment(r){let a=L();if(a==null)return H("Checkout not found");let i=await He(e,{locale:t});if(ke(i))return i;try{let c=_optionalChain([r, 'access', _173 => _173.shippingContact, 'optionalAccess', _174 => _174.givenName]);_optionalChain([r, 'access', _175 => _175.shippingContact, 'optionalAccess', _176 => _176.familyName])!=null?c+=" "+_optionalChain([r, 'access', _177 => _177.shippingContact, 'optionalAccess', _178 => _178.familyName]):_optionalChain([r, 'access', _179 => _179.billingContact, 'optionalAccess', _180 => _180.familyName])!=null&&(c+=" "+_optionalChain([r, 'access', _181 => _181.billingContact, 'optionalAccess', _182 => _182.familyName]));let d={},l=xt();l!=null&&(d.ref=l);let m=await le.get(_chunkAWG5OAK7js.f).authorizeOneClickPayment({gateway:0,paymentData:JSON.stringify(r.token.paymentData),paymentMethod:JSON.stringify(r.token.paymentMethod),transactionIdentifier:r.token.transactionIdentifier,order:_protobuf.create.call(void 0, _chunk7SYNGA3Rjs.d,{items:i.map(g=>({id:g.productID,quantity:g.quantity})),couponCode:a.couponCode,email:_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([r, 'access', _183 => _183.shippingContact, 'optionalAccess', _184 => _184.emailAddress]), () => (_optionalChain([r, 'access', _185 => _185.billingContact, 'optionalAccess', _186 => _186.emailAddress]))), () => (a.email)), () => (void 0)),phone:_nullishCoalesce(_nullishCoalesce(_optionalChain([r, 'access', _187 => _187.shippingContact, 'optionalAccess', _188 => _188.phoneNumber]), () => (_optionalChain([r, 'access', _189 => _189.billingContact, 'optionalAccess', _190 => _190.phoneNumber]))), () => (void 0)),selectedDeliveryMethod:a.selectedDeliveryMethod,postCode:a.postalCode,projectId:e}),shippingAddress:_protobuf.create.call(void 0, _chunk7SYNGA3Rjs.a,{line1:_nullishCoalesce(_optionalChain([r, 'access', _191 => _191.shippingContact, 'optionalAccess', _192 => _192.addressLines, 'optionalAccess', _193 => _193[0]]), () => ("")),city:_nullishCoalesce(_optionalChain([r, 'access', _194 => _194.shippingContact, 'optionalAccess', _195 => _195.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([r, 'access', _196 => _196.shippingContact, 'optionalAccess', _197 => _197.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([r, 'access', _198 => _198.shippingContact, 'optionalAccess', _199 => _199.postalCode]), () => ("")),name:c}),billingAddress:_protobuf.create.call(void 0, _chunk7SYNGA3Rjs.b,{name:_nullishCoalesce(_optionalChain([r, 'access', _200 => _200.billingContact, 'optionalAccess', _201 => _201.givenName]), () => (" "+(_nullishCoalesce(_optionalChain([r, 'access', _202 => _202.billingContact, 'optionalAccess', _203 => _203.familyName]), () => (""))))),line1:_nullishCoalesce(_optionalChain([r, 'access', _204 => _204.billingContact, 'optionalAccess', _205 => _205.addressLines, 'optionalAccess', _206 => _206[0]]), () => ("")),city:_nullishCoalesce(_optionalChain([r, 'access', _207 => _207.billingContact, 'optionalAccess', _208 => _208.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([r, 'access', _209 => _209.billingContact, 'optionalAccess', _210 => _210.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([r, 'access', _211 => _211.billingContact, 'optionalAccess', _212 => _212.postalCode]), () => (""))}),metadata:Object.keys(d).length>0?JSON.stringify(d):void 0});return{isSuccess:m.isSuccess,redirectURL:m.redirectUrl}}catch(c){return console.error(c),H("Failed to authorize payment")}},async completeGooglePayPayment(r){let a=L();if(a==null)return H("Checkout not found");let i=await He(e,{locale:t});if(ke(i))return i;try{let c=_optionalChain([r, 'access', _213 => _213.paymentData, 'access', _214 => _214.shippingAddress, 'optionalAccess', _215 => _215.name]),d={},l=xt();l!=null&&(d.ref=l);let m=await le.get(_chunkAWG5OAK7js.f).authorizeOneClickPayment({gateway:1,paymentData:r.paymentData.paymentMethodData.tokenizationData.token,paymentMethod:r.paymentData.paymentMethodData.type,transactionIdentifier:"",order:_protobuf.create.call(void 0, _chunk7SYNGA3Rjs.d,{items:i.map(g=>({id:g.productID,quantity:g.quantity})),couponCode:a.couponCode,email:_nullishCoalesce(r.paymentData.email, () => (void 0)),phone:_nullishCoalesce(_optionalChain([r, 'access', _216 => _216.paymentData, 'access', _217 => _217.shippingAddress, 'optionalAccess', _218 => _218.phoneNumber]), () => (void 0)),selectedDeliveryMethod:_nullishCoalesce(_optionalChain([r, 'access', _219 => _219.paymentData, 'access', _220 => _220.shippingOptionData, 'optionalAccess', _221 => _221.id]), () => (a.selectedDeliveryMethod)),postCode:_optionalChain([r, 'access', _222 => _222.paymentData, 'access', _223 => _223.shippingAddress, 'optionalAccess', _224 => _224.postalCode]),projectId:e}),shippingAddress:_protobuf.create.call(void 0, _chunk7SYNGA3Rjs.a,{line1:_nullishCoalesce(_optionalChain([r, 'access', _225 => _225.paymentData, 'access', _226 => _226.shippingAddress, 'optionalAccess', _227 => _227.address1]), () => ("")),city:_nullishCoalesce(_optionalChain([r, 'access', _228 => _228.paymentData, 'access', _229 => _229.shippingAddress, 'optionalAccess', _230 => _230.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([r, 'access', _231 => _231.paymentData, 'access', _232 => _232.shippingAddress, 'optionalAccess', _233 => _233.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([r, 'access', _234 => _234.paymentData, 'access', _235 => _235.shippingAddress, 'optionalAccess', _236 => _236.postalCode]), () => ("")),name:c}),billingAddress:_protobuf.create.call(void 0, _chunk7SYNGA3Rjs.b,{name:_optionalChain([r, 'access', _237 => _237.paymentData, 'access', _238 => _238.paymentMethodData, 'access', _239 => _239.info, 'optionalAccess', _240 => _240.billingAddress, 'optionalAccess', _241 => _241.name]),line1:_nullishCoalesce(_optionalChain([r, 'access', _242 => _242.paymentData, 'access', _243 => _243.paymentMethodData, 'access', _244 => _244.info, 'optionalAccess', _245 => _245.billingAddress, 'optionalAccess', _246 => _246.address1]), () => ("")),city:_nullishCoalesce(_optionalChain([r, 'access', _247 => _247.paymentData, 'access', _248 => _248.paymentMethodData, 'access', _249 => _249.info, 'optionalAccess', _250 => _250.billingAddress, 'optionalAccess', _251 => _251.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([r, 'access', _252 => _252.paymentData, 'access', _253 => _253.paymentMethodData, 'access', _254 => _254.info, 'optionalAccess', _255 => _255.billingAddress, 'optionalAccess', _256 => _256.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([r, 'access', _257 => _257.paymentData, 'access', _258 => _258.paymentMethodData, 'access', _259 => _259.info, 'optionalAccess', _260 => _260.billingAddress, 'optionalAccess', _261 => _261.postalCode]), () => (""))}),metadata:Object.keys(d).length>0?JSON.stringify(d):void 0});return{isSuccess:m.isSuccess,redirectURL:m.redirectUrl}}catch(c){return console.error(c),H("Failed to authorize payment")}return{isSuccess:!0}},async getApplePayPaymentRequest(r){let a=L();if(a==null)return H("Checkout not found");r&&r.expectedItems!=null&&r.expectedItems.length>0&&(a.products&&qr(a.products.map(l=>l.productID)),await zr(e,r.expectedItems));let i=await He(e,{locale:t});if(ke(i))return i;let c=await le.get(_chunkAWG5OAK7js.f).getPreOrderDetails({items:i.map(l=>_protobuf.create.call(void 0, _chunk7SYNGA3Rjs.c,{id:l.productID,quantity:l.quantity})),projectId:e,postCode:a.postalCode,couponCode:a.couponCode,countryCode:a.country,selectedDeliveryMethod:a.selectedDeliveryMethod}),d=i.map(l=>({amount:`${_(l.quantity*(_nullishCoalesce(_nullishCoalesce(_optionalChain([l, 'access', _262 => _262.details, 'optionalAccess', _263 => _263.pricing, 'optionalAccess', _264 => _264.effectivePrice]), () => (_optionalChain([l, 'access', _265 => _265.details, 'optionalAccess', _266 => _266.price]))), () => (0)))/100,2)}`,label:_optionalChain([l, 'access', _267 => _267.details, 'optionalAccess', _268 => _268.name])+" - "+l.quantity,type:"final"}));if(c.selectedDeliveryMethod!=null){let l=c.methods.find(m=>m.id==c.selectedDeliveryMethod);l!=null&&d.push({amount:`${_(l.amount/100,2)}`,label:l.name,type:"final"})}return c.couponCode!=null&&c.couponValue!=null&&d.push({amount:`-${_(c.couponValue/100,2)}`,label:c.couponCode,type:"final"}),{countryCode:c.country||a.country||"PL",merchantCapabilities:["supports3DS","supportsCredit","supportsDebit"],supportedNetworks:["visa","masterCard"],total:{amount:`${_((_nullishCoalesce(c.totalAmount, () => (0)))/100,2)}`,label:_chunkAWG5OAK7js.j.call(void 0, "paymentForCart",t,n),type:"final"},shippingMethods:c.methods.map(l=>({amount:`${_(l.amount/100,2)}`,detail:_nullishCoalesce(l.description, () => ("")),identifier:l.id,label:l.name,dateComponentsRange:{startDateComponents:{days:_nullishCoalesce(l.minDays, () => (1)),hours:0,months:0,years:0},endDateComponents:{days:_nullishCoalesce(l.maxDays, () => (14)),hours:0,months:0,years:0}}})),lineItems:d,currencyCode:c.currency||_optionalChain([i, 'access', _269 => _269[0], 'optionalAccess', _270 => _270.details, 'optionalAccess', _271 => _271.currency])||"PLN"}}}};async function li(e){let t=L();if(_optionalChain([t, 'access', _272 => _272.googlePayConfig, 'optionalAccess', _273 => _273.isAvailable])!=!0){let n=await le.get(_chunkAWG5OAK7js.f).isOneClickPaymentAvailable({projectId:e});n.googlePay==!0&&n.googlePayConfig!=null?t.googlePayConfig={isAvailable:!0,gateway:n.googlePayConfig.gateway,gatewayId:n.googlePayConfig.gatewayMerchantId,merchantName:n.googlePayConfig.merchantName,merchantId:n.googlePayConfig.merchantId}:t.googlePayConfig={isAvailable:!1,gateway:"",gatewayId:"",merchantName:"",merchantId:""}}return Q(t),t.googlePayConfig}function ui(e,t){if(e==t.id){let o=_optionalChain([t, 'access', _274 => _274.variants, 'optionalAccess', _275 => _275.findIndex, 'call', _276 => _276(r=>r.id===e)]);if(o!=null&&o!=-1){let r=t.variants[o];return{...t,availableQuantity:r.availableQuantity,isDeliverable:r.isDeliverable,images:_nullishCoalesce(r.images, () => (t.images)),name:t.name+" "+r.name,baseName:t.name,variantName:r.name,price:r.price,currency:r.currency,pricing:r.pricing}}return t}let n=_optionalChain([t, 'access', _277 => _277.variants, 'optionalAccess', _278 => _278.find, 'call', _279 => _279(o=>o.id===e)]);return n==null?t:{...t,id:n.id,name:t.name+" "+n.name,baseName:t.name,variantName:n.name,price:n.price,currency:n.currency,pricing:n.pricing,metadata:t.metadata,availableQuantity:n.availableQuantity,isDeliverable:n.isDeliverable,images:_nullishCoalesce(n.images, () => (t.images))}}function $e(){let e=L(),t=0;if(e==null){Be.setState(n=>({...n,numberOfProductsInCart:t}));return}t=_nullishCoalesce(_optionalChain([e, 'access', _280 => _280.products, 'optionalAccess', _281 => _281.reduce, 'call', _282 => _282((n,o)=>n+o.quantity,0)]), () => (0)),Be.setState(n=>({...n,numberOfProductsInCart:t}))}var pi=200,fi= exports.v ="item-ids-not-found",at="internal-error",Gr={"no-payment-gateway":"noPaymentGateway","gateway-not-configured":"gatewayNotConfigured","shipping-not-configured":"shippingNotConfigured","mixed-recurring":"mixedRecurring","currency-unsupported":"currencyUnsupported","price-changed":"priceChanged","product-not-found":"unavailableProducts","product-not-available":"unavailableProducts"},gi=new Set(["internal","invalid-request"]),yi=new Set(["product-not-available","product-not-found"]);function hi(e){return typeof e=="string"&&Object.hasOwn(Gr,e)?Gr[e]:void 0}function Pi(e){return/<\/?[a-z!?][^>]*>/i.test(e)}function bi(e){return/^[A-Za-z][A-Za-z0-9]*(?:[-_.:][A-Za-z0-9]+)*$/.test(e)&&!/^[A-Z][a-z]+$/.test(e)||/^\[object \w+\]$|^(?:undefined|null)$/.test(e)}function vi(e){return/Error:/.test(e)||/\n\s+at /.test(e)}function sn(e){let t=e.trim();if(!(t.length===0||t.length>pi||/[\r\n]/.test(t)||Pi(t)||bi(t)||vi(t)))return t}var wi=3;function Ct(e,t=0){if(typeof e=="object"&&e!=null){if(Array.isArray(e)||t>=wi)return{};let n=e,o=Ct(n.error,t+1);if(o.message==null&&n.message!=null){let r=Ct(n.message,t+1);o={...r,code:_nullishCoalesce(o.code, () => (r.code))}}return typeof n.code=="string"&&n.code.length>0&&(o.code=n.code),o}if(typeof e!="string")return{};try{let n=JSON.parse(e);return typeof n=="object"&&n!=null?Ct(n,t+1):{}}catch (e18){}return{message:sn(e)}}function xi(e){let t;try{t=JSON.parse(e)}catch (e19){return{code:at,message:sn(e)}}if(typeof t=="string")return{code:at,message:sn(t)};if(typeof t!="object"||t==null)return{code:at};let n=t,{message:o,code:r}=Ct(n.error),a={code:typeof n.code=="string"&&n.code.length>0?n.code:_nullishCoalesce(r, () => (at)),message:o};return Array.isArray(n.itemIds)&&(a.itemIds=n.itemIds.filter(i=>typeof i=="string")),a}function cn(e,t){let{code:n,message:o,itemIds:r}=xi(t),a=r!=null&&r.length>0;if(a&&(n===at||yi.has(n)))return H(fi,"badInput",r);let i={message:o};return a&&(i.itemIds=r),H(n,e>=500?"internal":"badInput",i)}function Wl(e,t){let n=hi(e.error);if(n!=null)return t(n);if(e.type==="internal"||typeof e.error=="string"&&gi.has(e.error))return t("checkoutFailed");let o=_optionalChain([e, 'access', _283 => _283.data, 'optionalAccess', _284 => _284.message]);return typeof o=="string"&&o.length>0?o:t("checkoutFailed")}var ki=["online","manual","cod"],Ci=["bankTransfer","blik"];function Vr(e,t){if(!Array.isArray(e))return[];let n=[];for(let o of e)t.includes(o)&&!n.includes(o)&&n.push(o);return n}function Ni(e){if(typeof e!="object"||e==null)return null;let t=e.choice;if(typeof t!="object"||t==null)return null;let n=Vr(t.methods,ki);return n.length<2?null:{methods:n,manualAccountTypes:Vr(t.manualAccountTypes,Ci)}}function Jl(e){if(e==null)return null;let t=e.methods.filter(n=>n!=="cod");return t.length<2?null:{...e,methods:t}}function Yl(e,t){return t!=null&&e.methods.includes(t)?t:e.methods[0]}function Ql(e){let t=e.includes("bankTransfer"),n=e.includes("blik");return n&&!t?"paymentMethodManualBlik":t&&!n?"paymentMethodManualTransfer":"paymentMethodManualBoth"}async function Kr(e,t,n=5e3){let o=typeof AbortController>"u"?void 0:new AbortController,r=setTimeout(()=>_optionalChain([o, 'optionalAccess', _285 => _285.abort, 'call', _286 => _286()]),n);try{let a=await fetch(e,{method:"POST",headers:t.headers,body:t.body,signal:_optionalChain([o, 'optionalAccess', _287 => _287.signal])});return a.ok?Ni(await a.json()):null}catch (e20){return null}finally{clearTimeout(r)}}var Ii;(o=>{async function e(r,a=1,i,c){let d=Ge();if(d==null)throw new Error("No project ID found");let m=await on(d).addProduct({productID:r,quantity:a,metadata:i,...c});if(m!=null)return m}o.addProductToCart=e;function t(){Be.setState({isCartVisible:!0})}o.showCart=t;function n(){Be.setState({isCartVisible:!1})}o.hideCart=n})(Ii = exports.B||={});async function Wr(e){try{return await e.text()}catch (e21){return""}}function Zr(e,t){return t=an(t),t.locale??=_chunkAWG5OAK7js.m.call(void 0, ),{headers:{..._chunkAWG5OAK7js.a,..._chunk3N2VK426js.h.call(void 0, e),"Content-Type":"application/json"},body:JSON.stringify(t)}}async function Br(e){let t=Ge();return t==null?null:Kr(Fe(t,"/payment-methods"),Zr(t,e))}async function nn(e){let t=Ge();if(t==null)throw new Error("No project ID found");let n=await fetch(Fe(t,"/buy"),{method:"POST",...Zr(t,e)});if(n.status!=200){let r=cn(n.status,await Wr(n));return console.warn("cannot create payment URL",n.status,r.error),r}let o=await n.json();return{url:o.url,...o.orderId!=null?{orderId:o.orderId}:{},...o.projectId!=null?{projectId:o.projectId}:{}}}async function cu(e){let t=Ge();if(t==null)throw new Error("No project ID found");let n={..._chunkAWG5OAK7js.a,..._chunk3N2VK426js.h.call(void 0, t),"Content-Type":"application/json",...e.apiKey!=null?{Authorization:`Bearer ${e.apiKey}`}:{}},o=e.testMode?`/api/payment/link/auto/${t}/test`:`/api/payment/link/auto/${t}`;delete e.apiKey,delete e.testMode,e.locale??=_chunkAWG5OAK7js.m.call(void 0, );let r=await fetch(_chunkAWG5OAK7js.f+o,{method:"POST",headers:n,body:JSON.stringify(e)});return r.ok?{status:"ok",redirectURL:(await r.json()).url}:{...cn(r.status,await Wr(r)),status:"error"}}function xt(){if(typeof localStorage>"u")return;let e=localStorage.getItem("bitsnap-ref");if(e!=null)return e}function an(e){let t=xt();return t==null||(e.metadata==null&&(e.metadata={}),e.metadata.ref=t),e}exports.a = le; exports.b = ue; exports.c = be; exports.d = ve; exports.e = Mt; exports.f = me; exports.g = On; exports.h = Ut; exports.i = Se; exports.j = Qe; exports.k = Xe; exports.l = Me; exports.m = Ue; exports.n = ya; exports.o = Fn; exports.p = Zt; exports.q = Do; exports.r = _; exports.s = Nr; exports.t = Jt; exports.u = ke; exports.v = fi; exports.w = Wl; exports.x = Jl; exports.y = Yl; exports.z = Ql; exports.A = Be; exports.B = Ii; exports.C = Br; exports.D = nn; exports.E = cu; exports.F = xt; exports.G = an; exports.H = sl; exports.I = cl; exports.J = dl; exports.K = ml; exports.L = ei; exports.M = rn; exports.N = zl; exports.O = Ge; exports.P = ql; exports.Q = Fl; exports.R = oi; exports.S = Bl; exports.T = Hl; exports.U = on;
4
- //# sourceMappingURL=chunk-R2M6W4LD.js.map
3
+ </a>`,n)))}})};var _protobuf = require('@bufbuild/protobuf');var _hlsjs = require('hls.js'); var _hlsjs2 = _interopRequireDefault(_hlsjs);function Qn(){typeof navigator>"u"||typeof navigator.mediaSession>"u"||(navigator.mediaSession.playbackState="playing")}function Xn(){typeof navigator>"u"||typeof navigator.mediaSession>"u"||(navigator.mediaSession.playbackState="paused")}function er(e,t){typeof navigator>"u"||typeof navigator.mediaSession>"u"||e!=null&&isNaN(e)||t!=null&&isNaN(t)||navigator.mediaSession.setPositionState({playbackRate:1,duration:e,position:t})}function tr(e){typeof navigator>"u"||typeof navigator.mediaSession>"u"||(navigator.mediaSession.metadata=new MediaMetadata({title:e.title,artwork:e.artwork?[{type:"image/png",src:e.artwork}]:void 0}),navigator.mediaSession.setActionHandler("play",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("pause",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("stop",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("seekbackward",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("seekforward",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("seekto",t=>{e.action(t)}))}function nr(){navigator.mediaSession.metadata=null}var Za=_react3.forwardRef.call(void 0, ({chapters:e,styles:t,updateCurrentTime:n,setCurrentTimeHandler:o,title:r,imageURL:a,uniqueProductID:i,onChapterChange:c},d)=>{let l;(G=>(G[G.Playing=0]="Playing",G[G.Paused=1]="Paused"))(l||={});let[m,g]=_react3.useState.call(void 0, 1);_react3.useEffect.call(void 0, ()=>{switch(m){case 0:Qn();break;case 1:Xn();break}},[m]),_react3.useImperativeHandle.call(void 0, d,()=>({selectChapter:f=>{Ke(f)}}));let[k,u]=_react3.useState.call(void 0, void 0),[v,C]=_react3.useState.call(void 0, void 0),s=_react3.useRef.call(void 0, null),P=_react3.useRef.call(void 0, void 0),R=_react3.useRef.call(void 0, void 0),q=_react3.useRef.call(void 0, null),F=_react3.useRef.call(void 0, null),[A,E]=_react3.useState.call(void 0, !0),[z,D]=_react3.useState.call(void 0, !1),[$,ge]=_react3.useState.call(void 0, !Ja());function M(f){f<10||localStorage.setItem(`__player__${i}_${_optionalChain([F, 'access', _22 => _22.current, 'optionalAccess', _23 => _23.id])}`,`${f}`)}function X(){let f=localStorage.getItem(`__player__${i}_${_optionalChain([F, 'access', _24 => _24.current, 'optionalAccess', _25 => _25.id])}`);if(f!=null)try{let U=parseInt(f);return isNaN(U)||U<0?void 0:U}catch (e5){return}}function ye(){let f=localStorage.getItem(`__player__${i}_last_chapter`);if(f!=null)return f}function Ce(f){localStorage.setItem(`__player__${i}_last_chapter`,f)}function re(f){localStorage.removeItem(`__player__${i}_${f}`)}function h(){s.current!=null&&(s.current.onloadeddata=()=>{if(s.current!=null){if(s.current.readyState<2&&ge(!0),s.current.readyState>=2&&ge(!1),!z){let f=X();f!=null&&it(f),D(!0)}if(A){E(!1);try{Nt()}catch(f){console.log("play error",f)}}}},s.current.onplay=()=>{},s.current.onseeked=()=>{},s.current.onseeking=()=>{},s.current.onpause=()=>{},s.current.onended=()=>{ae()},tr({title:_nullishCoalesce(r, () => ("")),artwork:a,action:f=>{switch(f.action){case"play":Nt();break;case"pause":It();break;case"seekbackward":ot(-15);break;case"seekforward":ot(15);break;case"seekto":f.seekTime&&it(f.seekTime);break;case"stop":It();break;default:break}}}),Ne())}function ae(){if(e==null||e.length==0)return;let f=e.findIndex(G=>G.id==_optionalChain([F, 'access', _26 => _26.current, 'optionalAccess', _27 => _27.id]));f==-1||(re(e[f].id),f+1>=e.length)||Ke(e[f+1])}function Ne(){Re(),R.current==null&&(R.current=setTimeout(()=>{Re(),R.current=void 0,Ne()},500))}function Ve(){R.current!=null&&clearTimeout(R.current)}function Re(){s.current!=null&&(g(s.current.paused?1:0),C(s.current.duration),u(s.current.currentTime),M(s.current.currentTime),er(s.current.duration,s.current.currentTime),s.current.networkState===s.current.NETWORK_LOADING&&s.current.readyState<=s.current.HAVE_FUTURE_DATA?ge(!0):ge(!1),n&&n(s.current.currentTime))}function Nt(){_optionalChain([s, 'access', _28 => _28.current, 'optionalAccess', _29 => _29.play, 'call', _30 => _30(), 'access', _31 => _31.then, 'call', _32 => _32(), 'access', _33 => _33.catch, 'call', _34 => _34()]),Re()}function It(){_optionalChain([s, 'access', _35 => _35.current, 'optionalAccess', _36 => _36.pause, 'call', _37 => _37()]),Re()}function Jr(){if(m===0){It();return}Nt()}function ot(f){if(s.current==null)return;let U=s.current.currentTime+f;if(U<0){s.current.currentTime=0;return}if(U>s.current.duration){s.current.currentTime=s.current.duration;return}s.current.currentTime+=f}function it(f){if(s.current!=null){if(u(f),f<0){s.current.currentTime=0;return}if(f>s.current.duration){s.current.currentTime=s.current.duration;return}s.current.currentTime=f}}function Yr(){s.current!=null&&(s.current.onplay=null,s.current.onseeked=null,s.current.onseeking=null,s.current.onpause=null,s.current.onended=null,s.current.src="",_optionalChain([P, 'access', _38 => _38.current, 'optionalAccess', _39 => _39.destroy, 'call', _40 => _40()]))}function dn(f){if(f.length==0)return;let U=ye();if(U==null){Ke(f[0]);return}let G=f.find(Ae=>Ae.id==U);if(G==null){Ke(f[0]);return}Ke(G)}function Ke(f){D(!1),E(!0),F.current=f,Qr(f.publicUrl),_optionalChain([c, 'optionalCall', _41 => _41(f)]),Ce(f.id)}function Qr(f){s.current!=null&&(s.current.canPlayType("application/vnd.apple.mpegurl")?s.current.src=f:_hlsjs2.default.isSupported()&&(P.current==null&&(P.current=new _hlsjs2.default,_optionalChain([P, 'access', _42 => _42.current, 'optionalAccess', _43 => _43.attachMedia, 'call', _44 => _44(s.current)])),_optionalChain([P, 'access', _45 => _45.current, 'optionalAccess', _46 => _46.loadSource, 'call', _47 => _47(f)])))}_react3.useEffect.call(void 0, ()=>{s.current!=null&&(h(),dn(e))},[s.current]),_react3.useEffect.call(void 0, ()=>{dn(e)},[e]),_react3.useEffect.call(void 0, ()=>(_optionalChain([o, 'optionalCall', _48 => _48(it)]),()=>{u(void 0),_optionalChain([s, 'access', _49 => _49.current, 'optionalAccess', _50 => _50.pause, 'call', _51 => _51()]),Yr(),nr()}),[]);let ln=f=>{let U=Math.floor(f/3600),G=Math.floor(f/60)%60,Ae=Math.floor(f%60),ea=U>0?U<10?`0${U}:`:`${U}:`:"",ta=Ae<10?`0${Ae}`:`${Ae}`;return isNaN(Ae)||isNaN(G)||isNaN(U)?"":`${ea}${G}:${ta}`},Xr=f=>{let U=parseFloat(f.value)/parseFloat(f.max)*100;q.current.style.setProperty("--seek-before-width",U+"%");let G=v*U/100;it(G)};return _jsxruntime.jsxs.call(void 0, "div",{id:"audio-player-container",className:"flex flex-col",style:t,ref:q,children:[_jsxruntime.jsx.call(void 0, "video",{ref:s,className:"hidden",poster:a,title:r}),_jsxruntime.jsx.call(void 0, "input",{type:"range",min:"0",max:v!=null?Math.floor(v).toString():100,value:_nullishCoalesce(k, () => (0)),onChange:f=>Xr(f.target),className:"w-full"}),_jsxruntime.jsxs.call(void 0, "section",{className:"flex w-full items-center justify-between text-sm font-medium",children:[_jsxruntime.jsx.call(void 0, "span",{id:"current-time",children:ln(k)}),_jsxruntime.jsx.call(void 0, "span",{id:"duration",children:ln(v)})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-6 flex items-center justify-center gap-x-12",children:[_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{variant:"outline",onClick:()=>ot(-10),"aria-label":"Rewind 10 Seconds",children:"-10"}),_jsxruntime.jsxs.call(void 0, _chunkFGB5FJCIjs.q,{variant:"outline",onClick:Jr,"aria-label":"Play Or Pause",children:[m===1&&_jsxruntime.jsx.call(void 0, _lucidereact.Play,{className:"h-5 w-5"}),m===0&&_jsxruntime.jsx.call(void 0, _lucidereact.Pause,{className:"h-5 w-5"})]}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{variant:"outline",onClick:()=>ot(10),"aria-label":"Fast Forward 10 Seconds",children:"+10"})]}),$&&_jsxruntime.jsx.call(void 0, "div",{className:"mt-2 flex w-full justify-center",children:_jsxruntime.jsx.call(void 0, Z,{})})]})});function Ja(){return navigator.userAgent.toLowerCase().indexOf("safari/")>-1}var ar=Za;var Ya={pl:{returnsNavLabel:"Zwroty",openCourse:"Otw\xF3rz kurs"},en:{returnsNavLabel:"Returns",openCourse:"Open the course"}};function nt(e=_chunkDY2S42Q6js.m.call(void 0, )){return _chunkDY2S42Q6js.h.call(void 0, Ya,e)}function ir(){let[e,t]=ft.useState(13);return ft.useEffect(()=>{let n=setTimeout(()=>t(66),500);return()=>clearTimeout(n)},[]),_jsxruntime.jsx.call(void 0, "div",{className:"w-[60%] h-2 bg-gray-200 rounded-full overflow-hidden",children:_jsxruntime.jsx.call(void 0, "div",{className:"h-full bg-blue-600 transition-all duration-300",style:{width:`${e}%`}})})}function pe(e,...t){console.warn(e,...t)}function $t(e){console.error(e)}var eo=({accessToken:e,product:t,styles:n,reveal:o,onOpenCourse:r})=>{let a=t.productType,i=_chunkMG6VV5J2js.m.call(void 0, ),c=()=>i.track("panel_download",{},{product_id:t.productId.length<=64?t.productId:null}),d=_react3.useRef.call(void 0, null),[l]=_react.useAutoAnimate.call(void 0, ),[m,g]=_react3.useState.call(void 0, null),{mutateAsync:k,isPending:u}=_chunkFGB5FJCIjs.l.call(void 0, _chunkFGB5FJCIjs.j.publicApi.userPanelGetFileDetails),v=_react3.useRef.call(void 0, void 0),[C,s]=_react3.useState.call(void 0, null),[P,R]=_react3.useState.call(void 0, null),[q,F]=_react3.useState.call(void 0, !1),{mutateAsync:A,isPending:E}=_chunkFGB5FJCIjs.l.call(void 0, _chunkFGB5FJCIjs.j.publicApi.userPanelGetAudiobookDetails),{mutateAsync:z,isPending:D}=_chunkFGB5FJCIjs.l.call(void 0, _chunkFGB5FJCIjs.j.publicApi.userPanelGetAudiobookDetailsDownloadURLs),[$,ge]=_react3.useState.call(void 0, null),[M,X]=_react3.useState.call(void 0, null);async function ye(){try{let h=await k({accessId:t.accessId,accessToken:e});if(h.result.case==="success"){g(h.result.value.files);return}else pe("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),pe("Kod b\u0142\u0119du: ",h.result.value)}catch(h){pe("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),$t("B\u0142\u0105d podczas pobierania danych:"+h)}}async function Ce(){try{let h=await A({accessId:t.accessId,accessToken:e});if(h.result.case==="audiobook"){s(h.result.value);return}else pe("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),pe("Kod b\u0142\u0119du: ",h.result.value)}catch(h){pe("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),$t("B\u0142\u0105d podczas pobierania danych:"+h)}}async function re(){try{let h=await z({accessId:t.accessId,accessToken:e,isBrowser:!0});if(h.result.case==="success"){R(h.result.value.audiobookDownloadDetails),F(h.result.value.isAvailableToDownloadInMobileApp===!0);return}else pe("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),pe("Kod b\u0142\u0119du: ",h.result.value)}catch(h){pe("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),$t("B\u0142\u0105d podczas pobierania danych:"+h)}}return _react3.useEffect.call(void 0, ()=>{a===1&&(Ce().then().catch(),re().then().catch())},[]),_react3.useEffect.call(void 0, ()=>{if(C!=null&&P!=null){let h=C.chapters;if(!h)return;let ae=h.map(Ne=>{let Ve=_optionalChain([P, 'optionalAccess', _52 => _52.find, 'call', _53 => _53(Re=>Re.chapterId===Ne.id)]);if(Ve!=null)return{...Ne,publicUrl:Ve.publicUrl,downloadableUrl:Ve.downloadableUrl,duration:Ve.duration}}).filter(Ne=>Ne!=null);ae!=null&&ae.length>0&&X(ae)}},[C,P]),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "div",{className:"mb-3 space-y-4 rounded bg-white p-4 dark:bg-black",children:_jsxruntime.jsxs.call(void 0, _chunkFGB5FJCIjs.q,{onClick:()=>o(),variant:"ghost",className:"w-fit",children:[_jsxruntime.jsx.call(void 0, _lucidereact.ChevronLeft,{className:"h-6 w-6"}),_jsxruntime.jsx.call(void 0, "span",{className:"font-inter text-sm font-medium",children:"Wr\xF3\u0107"})]})}),_jsxruntime.jsxs.call(void 0, "main",{className:"grid grid-cols-1 justify-center gap-6 sm:justify-start lg:grid-cols-2",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full max-w-xl flex-col gap-6",children:[a===2&&_jsxruntime.jsxs.call(void 0, "div",{ref:l,className:"flex flex-col space-y-4 rounded bg-white p-6 drop-shadow-xl dark:border dark:border-neutral-700 dark:bg-neutral-800 dark:drop-shadow-none",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between gap-x-4",children:[_jsxruntime.jsx.call(void 0, "h4",{className:"text-xl font-semibold",children:"Twoje pliki"}),(m==null||m.length==0)&&_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{onClick:ye,"aria-label":"Download Product",className:"text-sm font-medium transition-opacity duration-300 ease-in-out hover:opacity-80 active:opacity-80",style:n,children:u?_jsxruntime.jsx.call(void 0, Z,{}):"Wy\u015Bwietl"})]}),u&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col items-start gap-2",children:[_jsxruntime.jsx.call(void 0, ir,{}),_jsxruntime.jsx.call(void 0, "p",{className:"font-bold transition hover:text-blue-600",children:"Trwa przygotowanie plik\xF3w..."})]}),m!=null&&m.length>0&&_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col items-start justify-start gap-2",children:m.map((h,ae)=>_jsxruntime.jsxs.call(void 0, "a",{target:"_blank",className:"flex w-fit items-center gap-2 rounded-md bg-neutral-800 px-3 py-2 text-neutral-200 dark:bg-neutral-200 dark:text-neutral-800",href:h,download:!0,onClick:c,children:[`Plik numer ${ae+1}`,_jsxruntime.jsx.call(void 0, _lucidereact.Download,{width:14,height:14})]},ae))})]}),a===4&&_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col items-center justify-center rounded-xl bg-white p-6 drop-shadow-xl dark:bg-neutral-900 dark:drop-shadow-none",children:_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{onClick:()=>r(t.accessId),className:"text-sm font-medium transition-opacity duration-300 ease-in-out hover:opacity-80 active:opacity-80",style:n,children:nt().openCourse})}),a===1&&_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col space-y-6 rounded-xl bg-white p-3 drop-shadow-xl dark:bg-neutral-900 dark:drop-shadow-none",children:[_jsxruntime.jsx.call(void 0, "h4",{className:"text-xl font-semibold",children:_nullishCoalesce(_optionalChain([$, 'optionalAccess', _54 => _54.name]), () => ("Odtwarzacz"))}),_optionalChain([$, 'optionalAccess', _55 => _55.description])&&_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",children:_optionalChain([$, 'optionalAccess', _56 => _56.description])}),_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:E?_jsxruntime.jsxs.call(void 0, "div",{className:"flex gap-2",children:[_jsxruntime.jsx.call(void 0, Z,{}),_jsxruntime.jsx.call(void 0, "p",{className:"text-xl font-semibold",children:"Trwa pobierania audiobooka..."})]}):_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:M!=null?_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:_jsxruntime.jsx.call(void 0, ar,{ref:d,chapters:M,title:_nullishCoalesce(_nullishCoalesce(_optionalChain([C, 'optionalAccess', _57 => _57.name]), () => (t.productName)), () => (void 0)),imageURL:_nullishCoalesce(_nullishCoalesce(_optionalChain([C, 'optionalAccess', _58 => _58.coverImage]), () => (t.productImageUrl)), () => (void 0)),styles:n,setCurrentTimeHandler:h=>{v.current=h},uniqueProductID:t.productId,onChapterChange:h=>{ge(h)}})}):_jsxruntime.jsx.call(void 0, "p",{className:"mt-2",children:"Wybierz rozdzia\u0142, kt\xF3ry ci\u0119 interesuje."})})}),_jsxruntime.jsxs.call(void 0, "div",{className:"rounded-xl bg-neutral-100 p-3 dark:bg-neutral-800",children:[_jsxruntime.jsx.call(void 0, "p",{className:"mt-3 mb-3 text-xs",children:q?"Mo\u017Cesz s\u0142ucha\u0107 tego audiobooka w aplikacji r\xF3wnie\u017C bez dost\u0119pu do internetu.":"Mo\u017Cesz s\u0142ucha\u0107 tego audiobooka w aplikacji."}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex gap-3",children:[_jsxruntime.jsx.call(void 0, "a",{href:"https://apps.apple.com/us/app/bitsnap/id6741902807",children:_jsxruntime.jsx.call(void 0, "img",{width:"100",src:"https://bitsnap.pl/appstore.svg",alt:"Pobierz aplikacje z AppStore"})}),_jsxruntime.jsx.call(void 0, "a",{href:"https://docs.bitsnap.pl/guides/audiobook",children:_jsxruntime.jsx.call(void 0, "img",{width:"100",src:"https://bitsnap.pl/playstore.svg",alt:"Pobierz aplikacj\u0119 z GooglePlay"})})]})]})]})}),_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center justify-center rounded-xl bg-white p-3 drop-shadow-xl dark:bg-neutral-900 dark:drop-shadow-none",children:a===1&&_jsxruntime.jsx.call(void 0, "div",{className:"max-h-96 w-full overflow-y-auto",children:E?_jsxruntime.jsxs.call(void 0, "div",{className:"jusitfy-center flex flex-col items-center gap-2",children:[_jsxruntime.jsx.call(void 0, Z,{}),_jsxruntime.jsx.call(void 0, "p",{children:"\u0141adowanie rozdzia\u0142\xF3w..."})]}):_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "h2",{className:"mb-3 text-xl font-semibold",children:"Rozdzia\u0142y"}),M==null?_jsxruntime.jsx.call(void 0, "p",{children:"Brak rozdzia\u0142\xF3w do wy\u015Bwietlenia."}):_jsxruntime.jsx.call(void 0, "ul",{className:"flex w-full flex-col gap-2",children:M.map((h,ae)=>_jsxruntime.jsxs.call(void 0, "li",{className:"flex items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "button",{className:_chunkDY2S42Q6js.d.call(void 0, "w-full rounded-lg p-2 text-left transition hover:bg-neutral-200 active:bg-neutral-200 dark:hover:bg-neutral-700 dark:active:bg-neutral-700",_optionalChain([$, 'optionalAccess', _59 => _59.id])==h.id?"bg-neutral-200 dark:bg-neutral-700":"bg-neutral-100 dark:bg-neutral-800 dark:text-neutral-300"),onClick:()=>{d.current.selectChapter(h)},children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-medium",children:h.name}),h.duration&&_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs text-neutral-500",children:[Math.floor(h.duration/60),":",String(Math.floor(h.duration%60)).padStart(2,"0")]})]}),h.description&&_jsxruntime.jsx.call(void 0, "p",{className:"mt-3 text-xs",children:h.description})]}),C&&C.isDownloadable&&h.downloadableUrl&&_jsxruntime.jsx.call(void 0, "a",{href:h.downloadableUrl,onClick:c,children:_jsxruntime.jsx.call(void 0, _lucidereact.Download,{width:14,height:14})})]},ae))})]})})})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"w-full max-w-3xl space-y-6 rounded-xl bg-white p-6 drop-shadow-xl dark:bg-neutral-900 dark:drop-shadow-none",children:[_jsxruntime.jsx.call(void 0, "h2",{className:"text-3xl font-semibold",children:t.productName}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-normal text-neutral-600 dark:text-neutral-300",children:t.productDescription}),_jsxruntime.jsx.call(void 0, "img",{src:t.productImageUrl,alt:"Product Photo",width:384,height:384,className:"max-h-sm max-w-sm",draggable:!1})]})]})]})},lr=eo;var ao=({accessToken:e,projectID:t,loginURL:n,styles:o,activeScreen:r,params:a,setParams:i,openCourse:c})=>{let{data:d,isLoading:l}=_chunkFGB5FJCIjs.k.call(void 0, _chunkFGB5FJCIjs.j.publicApi.userPanelGetProducts,{accessToken:e});if(l)return _jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2 bg-white p-2 dark:bg-black",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-dark font-inter font-medium dark:text-white",children:"\u0141adowanie..."}),_jsxruntime.jsx.call(void 0, Z,{})]});if(d&&d.result.case==="failure")return console.warn("error:",`Kod b\u0142\u0119du: ${d.result.value}`),_chunk7DG4UPWEjs.n.call(void 0, t),window.location.href=n,null;let m=d&&d.result.case==="success"?d.result.value.products:[];return _jsxruntime.jsx.call(void 0, oo,{accessToken:e,products:m,styles:o,loginURL:n,activeScreen:r,params:a,setParams:i,openCourse:c})},ur=ao,oo=({accessToken:e,products:t,styles:n,loginURL:o,activeScreen:r,params:a,setParams:i,openCourse:c})=>{if(t.length===0)return window.location.href=o,null;let[d,l]=_react3.useState.call(void 0, a.product?_protobuf.fromJsonString.call(void 0, _chunkFGB5FJCIjs.e,a.product):void 0),m=u=>{u==null?(l(void 0),i({product:void 0,state:"products"})):i({product:_protobuf.toJsonString.call(void 0, _chunkFGB5FJCIjs.e,u),state:"products"})};function g(u){switch(u){case 1:return"Audio";case 2:return"Plik";case 3:return"Bilet";case 4:return"Kurs";default:return}}function k(u){if(u.productType===4){c(u.accessId);return}l(u),m(u)}return r==="products"&&d!=null?_jsxruntime.jsx.call(void 0, lr,{accessToken:e,product:d,styles:n,reveal:m,onOpenCourse:c}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Hej \u{1F44B}"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:"Poni\u017Cej znajdziesz swoje produkty"}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 flex flex-wrap items-center justify-center gap-9 sm:justify-start",children:_optionalChain([t, 'optionalAccess', _60 => _60.map, 'call', _61 => _61((u,v)=>_jsxruntime.jsxs.call(void 0, "section",{onClick:()=>k(u),className:"w-full max-w-xs cursor-pointer rounded drop-shadow-xl dark:border dark:border-slate-600 dark:drop-shadow-none",children:[_jsxruntime.jsxs.call(void 0, "section",{className:"flex flex-col items-center space-y-2 rounded bg-slate-100 p-4 dark:bg-neutral-900",children:[u.productType&&_jsxruntime.jsx.call(void 0, "div",{className:"w-fit self-end rounded bg-red-900 px-4 py-1",children:_jsxruntime.jsx.call(void 0, "span",{className:"text-sm font-medium text-white dark:text-slate-100",children:g(u.productType)})}),_jsxruntime.jsx.call(void 0, "div",{className:"jusitfy-center flex max-h-40 items-center",children:_jsxruntime.jsx.call(void 0, "img",{src:u.productImageUrl,alt:`Product ${v} Photo`,draggable:!1,className:"aspect-auto max-h-40"})})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-4 rounded bg-white p-4 dark:bg-black",children:[_jsxruntime.jsx.call(void 0, "h2",{className:"text-xl font-semibold",children:u.productName}),_jsxruntime.jsx.call(void 0, "p",{title:u.productDescription,className:"line-clamp-3 text-sm font-normal text-neutral-600 dark:text-neutral-300",children:Yn(u.productDescription)}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{onClick:C=>{C.stopPropagation(),k(u)},className:"w-full text-sm font-medium transition-opacity duration-300 ease-in-out hover:opacity-80 active:opacity-80",style:n,children:"Zobacz"})]})]},v))])})]})};function uo({activeScreen:e,setActiveScreen:t,setParams:n,styles:o,theme:r,logout:a}){return _jsxruntime.jsxs.call(void 0, "header",{className:"md:border-r-neutral-150 md:bg-beige-50 fixed right-0 bottom-0 left-0 z-10 flex h-12 w-full items-center bg-neutral-800 md:static md:z-0 md:min-h-screen md:w-auto md:border-r dark:md:border-r-neutral-900",children:[_jsxruntime.jsx.call(void 0, mo,{activeScreen:e,setActiveScreen:t,setParams:n}),_jsxruntime.jsx.call(void 0, po,{activeScreen:e,setActiveScreen:t,setParams:n,theme:r,logout:a})]})}var fr=uo;function mo({activeScreen:e,setActiveScreen:t,setParams:n}){let{returnsNavLabel:o}=nt();return _jsxruntime.jsxs.call(void 0, "nav",{className:"flex w-full items-center justify-evenly gap-4 md:hidden",children:[_jsxruntime.jsx.call(void 0, yt,{panelScreen:"products",label:"Produkty",imageURL:"/icons/bitsnap-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n}),_jsxruntime.jsx.call(void 0, yt,{panelScreen:"orders",label:"Faktury",imageURL:"/icons/category-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n}),_jsxruntime.jsx.call(void 0, yt,{panelScreen:"returns",label:o,icon:_jsxruntime.jsx.call(void 0, _lucidereact.Undo2,{className:"h-5 w-5 text-white","aria-hidden":!0}),activeScreen:e,setActiveScreen:t,setParams:n}),_jsxruntime.jsx.call(void 0, yt,{panelScreen:"profile",label:"Profil",imageURL:"/icons/profile-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n})]})}function yt({panelScreen:e,label:t,imageURL:n,icon:o,activeScreen:r,setActiveScreen:a,setParams:i}){return _jsxruntime.jsxs.call(void 0, _chunkFGB5FJCIjs.q,{onClick:()=>{a(e),i({product:void 0,state:e})},"aria-label":t,variant:null,className:_chunkDY2S42Q6js.d.call(void 0, "flex flex-col gap-0",r===e?"opacity-100":"opacity-50"),children:[_nullishCoalesce(o, () => (_jsxruntime.jsx.call(void 0, "img",{src:n,alt:t,className:"scale-75"}))),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs font-normal text-white",children:t})]})}function ht({panelScreen:e,label:t,imageURL:n,darkImageURL:o,icon:r,activeScreen:a,setActiveScreen:i,setParams:c,isExpanded:d}){return _jsxruntime.jsxs.call(void 0, _chunkFGB5FJCIjs.q,{onClick:()=>{i(e),c({product:void 0,state:e})},variant:a===e?"secondary":"ghost",className:"justify-start",children:[r!=null?_jsxruntime.jsx.call(void 0, "span",{className:_chunkDY2S42Q6js.d.call(void 0, "inline-flex h-5 w-5 items-center justify-center",d?"mr-4":"mr-2"),children:r}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "img",{src:n,alt:t,className:_chunkDY2S42Q6js.d.call(void 0, "aspect-auto h-5 w-5 dark:hidden",d?"mr-4":"mr-2")}),_jsxruntime.jsx.call(void 0, "img",{src:o,alt:t,className:_chunkDY2S42Q6js.d.call(void 0, "hidden aspect-auto h-5 w-5 dark:inline",d?"mr-4":"mr-2")})]}),d&&_jsxruntime.jsx.call(void 0, "span",{className:"md:text-medium hidden md:inline",children:t})]})}function po({activeScreen:e,setActiveScreen:t,setParams:n,theme:o,logout:r}){let[a]=_react.useAutoAnimate.call(void 0, ),[i,c]=_react3.useState.call(void 0, !0),{returnsNavLabel:d}=nt();return _jsxruntime.jsxs.call(void 0, "div",{ref:a,className:_chunkDY2S42Q6js.d.call(void 0, "hidden px-4 pt-4 pb-12 md:flex md:h-full md:flex-col dark:bg-neutral-900",i?"md:w-52":"md:w-16"),children:[_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center justify-between",children:_jsxruntime.jsx.call(void 0, fo,{theme:o,isExpanded:i})}),_jsxruntime.jsx.call(void 0, mr,{className:"my-6"}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-1 flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, ht,{panelScreen:"products",label:"Produkty",imageURL:"/icons/bitsnap-dark-24x24.svg",darkImageURL:"/icons/bitsnap-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i}),_jsxruntime.jsx.call(void 0, ht,{panelScreen:"orders",label:"Zam\xF3wienia",imageURL:"/icons/category-dark-24x24.svg",darkImageURL:"/icons/category-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i}),_jsxruntime.jsx.call(void 0, ht,{panelScreen:"returns",label:d,icon:_jsxruntime.jsx.call(void 0, _lucidereact.Undo2,{className:"h-5 w-5","aria-hidden":!0}),activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i}),_jsxruntime.jsx.call(void 0, ht,{panelScreen:"profile",label:"Profil",imageURL:"/icons/profile-dark-24x24.svg",darkImageURL:"/icons/profile-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i})]}),_jsxruntime.jsx.call(void 0, mr,{className:"mb-6"}),_jsxruntime.jsxs.call(void 0, _chunkFGB5FJCIjs.q,{onClick:r,children:[_jsxruntime.jsx.call(void 0, _lucidereact.LogOut,{className:"mr-2",width:16,height:16}),i&&_jsxruntime.jsx.call(void 0, "p",{className:"md:text-medium hidden md:inline md:text-center",children:"Wyloguj si\u0119"})]})]})}function mr({className:e}){return _jsxruntime.jsxs.call(void 0, "div",{className:_chunkDY2S42Q6js.d.call(void 0, "relative h-px w-full bg-neutral-300",e),children:[_jsxruntime.jsx.call(void 0, "div",{className:"absolute -top-px left-0 h-1 w-1 rounded-full bg-neutral-500"}),_jsxruntime.jsx.call(void 0, "div",{className:"absolute -top-px right-0 h-1 w-1 rounded-full bg-neutral-500"})]})}function fo({theme:e,isExpanded:t}){return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[e==null&&_jsxruntime.jsx.call(void 0, "p",{className:"text-xl tracking-wider md:inline dark:text-neutral-200",children:"bitsnap."}),(_optionalChain([e, 'optionalAccess', _62 => _62.logoDarkURL])||_optionalChain([e, 'optionalAccess', _63 => _63.logoURL]))&&_jsxruntime.jsx.call(void 0, "img",{src:_nullishCoalesce(e.logoDarkURL, () => (e.logoURL)),alt:"Company Logo",className:"hidden h-6 w-6 dark:inline",draggable:!1}),_optionalChain([e, 'optionalAccess', _64 => _64.logoURL])&&_jsxruntime.jsx.call(void 0, "img",{src:e.logoURL,alt:"Company Logo",className:"h-6 w-6 dark:hidden",draggable:!1})]})}function yo({email:e,logout:t}){return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Profil"}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-6 flex-1 md:flex-none",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-sm text-neutral-500",children:"Email"}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-2 text-base",children:e||"Brak danych"})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex w-full flex-col items-center space-y-2",children:_jsxruntime.jsxs.call(void 0, _chunkFGB5FJCIjs.q,{onClick:t,className:"max-w-64 md:hidden",children:[_jsxruntime.jsx.call(void 0, _lucidereact.LogOut,{className:"mr-2",width:16,height:16}),_jsxruntime.jsx.call(void 0, "p",{className:"text-medium inline text-center",children:"Wyloguj si\u0119"})]})})]})}var yr=yo;var vo=_react3.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./course.js"))).then(e=>({default:e.PanelCourse})));function Vt(e){return _jsxruntime.jsx.call(void 0, _react3.Suspense,{fallback:_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center gap-2 p-2",role:"status",children:_jsxruntime.jsx.call(void 0, Z,{})}),children:_jsxruntime.jsx.call(void 0, vo,{...e})})}function Co({status:e}){let t={created:{color:"bg-neutral-100 text-neutral-700",icon:null},paid:{color:"bg-green-100 text-green-700",icon:_lucidereact.CheckCircle2},completed:{color:"bg-blue-100 text-blue-700",icon:_lucidereact.CheckCircle2},canceled:{color:"bg-red-100 text-red-700",icon:_lucidereact.AlertCircle},sent:{color:"bg-purple-100 text-purple-700",icon:_lucidereact.Truck},processing:{color:"bg-yellow-100 text-yellow-700",icon:_lucidereact.Loader2}},n=t[e]||t.created,o=n.icon,r={created:"Utworzone",paid:"Op\u0142acone",completed:"Zako\u0144czone",canceled:"Anulowane",sent:"Wys\u0142ane",processing:"Przetwarzane"};return _jsxruntime.jsxs.call(void 0, "span",{className:`inline-flex items-center gap-1 rounded-full px-3 py-1 text-sm font-medium ${n.color}`,children:[o&&_jsxruntime.jsx.call(void 0, o,{className:"h-4 w-4"}),r[e]||e]})}function No({orderID:e,email:t}){let[n,o]=_react3.useState.call(void 0, ""),r=_chunkFGB5FJCIjs.l.call(void 0, _chunkFGB5FJCIjs.j.publicApi.addPublicOrderComment);return _jsxruntime.jsxs.call(void 0, "form",{onSubmit:async i=>{if(i.preventDefault(),!!n.trim())try{await r.mutateAsync({projectId:"",orderId:e,message:n.trim(),accessToken:t}),o("")}catch(c){console.error("Failed to add comment:",c)}},className:"mt-4 space-y-2",children:[_jsxruntime.jsx.call(void 0, _chunkH4WAQQVOjs.a,{htmlFor:"comment",children:"Dodaj komentarz"}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.v,{id:"comment",value:n,onChange:i=>o(i.target.value),placeholder:"Wpisz komentarz...",rows:3,disabled:r.isPending}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{type:"submit",disabled:!n.trim()||r.isPending,children:r.isPending?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _lucidereact.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Wysy\u0142anie..."]}):"Dodaj komentarz"})]})}function br(e){return e?new Date(Number(e.seconds)*1e3).toLocaleDateString("pl-PL",{year:"numeric",month:"long",day:"numeric"}):"N/A"}function vr(e,t){return new Intl.NumberFormat("pl-PL",{style:"currency",currency:t.toUpperCase()}).format(e/100)}function Io({orderID:e,initialEmail:t,onBack:n,accessToken:o,analytics:r}){let{theme:a,projectID:i}=_chunk7DG4UPWEjs.j.call(void 0, ),c=_chunkMG6VV5J2js.n.call(void 0, i,r,"order"),[d,l]=_react3.useState.call(void 0, t||""),[m,g]=_react3.useState.call(void 0, !1),{data:k,isLoading:u,error:v,refetch:C}=_chunkFGB5FJCIjs.k.call(void 0, _chunkFGB5FJCIjs.j.publicApi.getPublicOrderDetails,{projectId:_nullishCoalesce(i, () => ("")),orderId:e,email:d||void 0,accessToken:o},{enabled:!!e}),s=_optionalChain([k, 'optionalAccess', _65 => _65.result, 'access', _66 => _66.case])==="order"?k.result.value:null,P=_nullishCoalesce(_optionalChain([s, 'optionalAccess', _67 => _67.isVerified]), () => (!1)),R=s!=null;_react3.useEffect.call(void 0, ()=>{R&&c.track("panel_order_viewed",{},{order_ref:null})},[c,R]);let q=()=>{C(),g(!1)},F={"--button-background-color":_nullishCoalesce(_optionalChain([a, 'optionalAccess', _68 => _68.colors, 'optionalAccess', _69 => _69.brand]), () => ("#000000")),"--button-background-color-dark":_nullishCoalesce(_optionalChain([a, 'optionalAccess', _70 => _70.colors, 'optionalAccess', _71 => _71.brandDark]), () => ("#ffffff")),"--button-text-color":_nullishCoalesce(_optionalChain([a, 'optionalAccess', _72 => _72.colors, 'optionalAccess', _73 => _73.brandDark]), () => ("#000000")),"--button-text-color-dark":_nullishCoalesce(_optionalChain([a, 'optionalAccess', _74 => _74.colors, 'optionalAccess', _75 => _75.brand]), () => ("#000000"))};return u?_jsxruntime.jsx.call(void 0, "div",{className:"flex min-h-screen items-center justify-center",children:_jsxruntime.jsxs.call(void 0, "div",{className:"text-center",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Loader2,{className:"mx-auto h-8 w-8 animate-spin text-neutral-400"}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"\u0141adowanie zam\xF3wienia..."})]})}):v||!s?_jsxruntime.jsx.call(void 0, "div",{className:"flex min-h-screen items-center justify-center",children:_jsxruntime.jsx.call(void 0, ue,{className:"w-full max-w-md",children:_jsxruntime.jsx.call(void 0, me,{className:"pt-6",children:_jsxruntime.jsxs.call(void 0, "div",{className:"text-center",children:[_jsxruntime.jsx.call(void 0, _lucidereact.AlertCircle,{className:"mx-auto h-12 w-12 text-red-500"}),_jsxruntime.jsx.call(void 0, "h2",{className:"mt-4 text-xl font-semibold",children:"Zam\xF3wienie nie znalezione"}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"Nie znaleziono zam\xF3wienia o podanym numerze."})]})})})}):_jsxruntime.jsx.call(void 0, "div",{className:"w-full bg-white py-8 dark:bg-black",style:F,children:_jsxruntime.jsxs.call(void 0, "div",{className:"w-full px-4",children:[n&&_jsxruntime.jsxs.call(void 0, _chunkFGB5FJCIjs.q,{onClick:n,variant:"ghost",className:"mb-4 w-fit",children:[_jsxruntime.jsx.call(void 0, _lucidereact.ChevronLeft,{className:"h-4 w-4"}),"Wr\xF3\u0107 do historii zam\xF3wie\u0144"]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mb-6 flex items-center gap-4",children:[_optionalChain([a, 'optionalAccess', _76 => _76.logoURL])&&_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "img",{src:a.logoURL,alt:"Project logo",className:`h-12 w-auto ${a.logoDarkURL?"dark:hidden":""}`}),a.logoDarkURL&&_jsxruntime.jsx.call(void 0, "img",{src:a.logoDarkURL,alt:"Project logo",className:"hidden h-12 w-auto dark:block"})]}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "h1",{className:"text-3xl font-bold",children:"Zam\xF3wienie"}),_jsxruntime.jsxs.call(void 0, "p",{className:"text-neutral-600 dark:text-neutral-400",children:["Numer zam\xF3wienia: #",s.orderId]})]})]}),_jsxruntime.jsxs.call(void 0, ue,{className:"mb-6",children:[_jsxruntime.jsx.call(void 0, be,{children:_jsxruntime.jsxs.call(void 0, ve,{className:"flex items-center",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Package,{className:"mr-2 h-5 w-5"}),"Status zam\xF3wienia"]})}),_jsxruntime.jsxs.call(void 0, me,{className:"space-y-6",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, Co,{status:s.status}),s.processingStatus&&_jsxruntime.jsxs.call(void 0, "span",{className:"text-sm text-neutral-600",children:["\xB7 ",s.processingStatus]})]}),_jsxruntime.jsxs.call(void 0, "p",{className:"mt-2 text-sm text-neutral-600",children:["Zam\xF3wienie z\u0142o\u017Cone ",br(s.createdAt)]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"border-t pt-4",children:[_jsxruntime.jsx.call(void 0, "h3",{className:"mb-3 font-semibold",children:"Dane klienta"}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Imi\u0119 i nazwisko:"})," ",_jsxruntime.jsx.call(void 0, "span",{className:P?"":"text-neutral-500",children:s.customerName})]}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Email:"})," ",_jsxruntime.jsx.call(void 0, "span",{className:P?"":"text-neutral-500",children:s.customerEmail})]}),s.customerPhone&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Telefon:"})," ",_jsxruntime.jsx.call(void 0, "span",{className:P?"":"text-neutral-500",children:s.customerPhone})]})]})]}),!P&&_jsxruntime.jsx.call(void 0, "div",{className:"border-t pt-4",children:_jsxruntime.jsxs.call(void 0, _chunkFGB5FJCIjs.q,{onClick:()=>g(!0),variant:"outline",className:"w-full",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Lock,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),_jsxruntime.jsxs.call(void 0, ue,{className:"mb-6",children:[_jsxruntime.jsx.call(void 0, be,{children:_jsxruntime.jsx.call(void 0, ve,{children:"Produkty"})}),_jsxruntime.jsxs.call(void 0, me,{className:"space-y-6",children:[_jsxruntime.jsx.call(void 0, "div",{className:"space-y-4",children:s.items.map((A,E)=>_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-4",children:[A.imageUrl&&_jsxruntime.jsx.call(void 0, "img",{src:A.imageUrl,alt:A.name,className:"h-16 w-16 rounded object-cover"}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex-1",children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-medium",children:A.name}),_jsxruntime.jsxs.call(void 0, "p",{className:"text-sm text-neutral-600",children:["Ilo\u015B\u0107: ",A.quantity]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"text-right",children:_jsxruntime.jsx.call(void 0, "p",{className:"font-medium",children:vr(Number(A.price),A.currency)})})]},E))}),(s.deliveryAddress||s.deliveryMethod)&&_jsxruntime.jsxs.call(void 0, "div",{className:"border-t pt-4",children:[_jsxruntime.jsxs.call(void 0, "h3",{className:"mb-3 flex items-center font-semibold",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Truck,{className:"mr-2 h-5 w-5"}),"Informacje o dostawie"]}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2",children:[s.deliveryAddress&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Adres:"})," ",_jsxruntime.jsx.call(void 0, "span",{className:P?"":"text-neutral-500",children:s.deliveryAddress})]}),s.deliveryMethod&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Metoda:"})," ",s.deliveryMethod]}),s.trackingNumber&&P&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Tracking:"})," ",s.trackingNumber]})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"border-t pt-4",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between text-lg font-bold",children:[_jsxruntime.jsx.call(void 0, "span",{children:"Suma:"}),_jsxruntime.jsx.call(void 0, "span",{children:vr(Number(s.totalAmount),s.currency)})]})})]})]}),_jsxruntime.jsxs.call(void 0, ue,{children:[_jsxruntime.jsx.call(void 0, be,{children:_jsxruntime.jsxs.call(void 0, ve,{children:["Komentarze ",s.commentCount>0&&`(${s.commentCount})`]})}),_jsxruntime.jsxs.call(void 0, me,{children:[s.comments.length>0?_jsxruntime.jsx.call(void 0, "div",{className:"space-y-4",children:s.comments.map(A=>_jsxruntime.jsxs.call(void 0, "div",{className:"border-b pb-4 last:border-b-0",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"mb-1 flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:A.authorName||"System"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs text-neutral-500",children:br(A.createdAt)}),A.authorType==="admin"&&_jsxruntime.jsx.call(void 0, "span",{className:"rounded bg-blue-100 px-2 py-0.5 text-xs text-blue-700",children:"Admin"})]}),_jsxruntime.jsx.call(void 0, "p",{className:P?"":"text-neutral-500",children:A.message})]},A.id))}):_jsxruntime.jsx.call(void 0, "p",{className:"text-neutral-600",children:"Brak komentarzy."}),P?_jsxruntime.jsx.call(void 0, No,{orderID:s.orderId,email:d}):_jsxruntime.jsx.call(void 0, "div",{className:"mt-4",children:_jsxruntime.jsxs.call(void 0, _chunkFGB5FJCIjs.q,{onClick:()=>g(!0),variant:"outline",className:"w-full",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Lock,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),m&&_jsxruntime.jsx.call(void 0, "div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:_jsxruntime.jsxs.call(void 0, ue,{className:"w-full max-w-md",children:[_jsxruntime.jsx.call(void 0, be,{children:_jsxruntime.jsx.call(void 0, ve,{children:"Zweryfikuj sw\xF3j email"})}),_jsxruntime.jsxs.call(void 0, me,{className:"space-y-4",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-700",children:"Podaj adres email u\u017Cyty przy sk\u0142adaniu zam\xF3wienia."}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2",children:[_jsxruntime.jsx.call(void 0, _chunkH4WAQQVOjs.a,{htmlFor:"verify-email",children:"Adres email"}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.r,{id:"verify-email",type:"email",placeholder:"twoj@email.com",value:d,onChange:A=>l(A.target.value)})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex gap-2",children:[_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{variant:"outline",onClick:()=>g(!1),className:"flex-1",children:"Anuluj"}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{onClick:q,className:"flex-1",children:"Zweryfikuj"})]})]})]})})]})})}function So(e){return _jsxruntime.jsx.call(void 0, Io,{...e})}var Zt=So;var To=({returnsAppearance:e,returnsTexts:t,analytics:n}={})=>{let{projectID:o,theme:r,loginURL:a,host:i}=_chunk7DG4UPWEjs.j.call(void 0, ),c=_chunkMG6VV5J2js.n.call(void 0, o,n,"panel"),d=_chunk7DG4UPWEjs.k.call(void 0, o,i),l=_chunk7DG4UPWEjs.m.call(void 0, o,i),{mutateAsync:m}=_chunkFGB5FJCIjs.l.call(void 0, _chunkFGB5FJCIjs.j.publicApi.userPanelLogout);async function g(){d&&await m({accessToken:d}),typeof window<"u"&&(_chunk7DG4UPWEjs.n.call(void 0, o,i),window.location.reload())}let[k]=_react.useAutoAnimate.call(void 0, ),u=D=>["products","notifications","profile","plans","orders","order-details","returns","return-details","course"].includes(D),[v,C]=_n({product:void 0,state:"products",orderId:void 0,returnId:void 0,course:void 0,item:void 0}),[s,P]=_react3.useState.call(void 0, u(v.state)?v.state:"products"),R=D=>{C({state:"order-details",orderId:D}),P("order-details")},q=()=>{C({state:"orders",orderId:void 0}),P("orders")},F=D=>C({orderId:void 0,returnId:void 0,course:void 0,item:void 0,...D}),A=D=>{C({state:"course",course:D,item:void 0,product:void 0}),P("course")},E=()=>{C({state:"products",course:void 0,item:void 0,product:void 0}),P("products")};_react3.useEffect.call(void 0, ()=>{u(v.state)&&(v.state==="course"||s==="course")&&P(v.state)},[v.state]);let z={"--button-background-color":_nullishCoalesce(_optionalChain([r, 'optionalAccess', _77 => _77.colors, 'optionalAccess', _78 => _78.brand]), () => ("#000000")),"--button-background-color-dark":_nullishCoalesce(_optionalChain([r, 'optionalAccess', _79 => _79.colors, 'optionalAccess', _80 => _80.brandDark]), () => ("#ffffff")),"--button-text-color":_nullishCoalesce(_optionalChain([r, 'optionalAccess', _81 => _81.colors, 'optionalAccess', _82 => _82.brandDark]), () => ("#000000")),"--button-text-color-dark":_nullishCoalesce(_optionalChain([r, 'optionalAccess', _83 => _83.colors, 'optionalAccess', _84 => _84.brand]), () => ("#000000"))};return _react3.useEffect.call(void 0, ()=>{if(d==null||d.length===0){window.location.href=_nullishCoalesce(a, () => ("/panel/login"));return}},[]),_react3.useEffect.call(void 0, ()=>{if(d==null||d.length===0){window.location.href=_nullishCoalesce(a, () => ("/panel/login"));return}},[s]),_react3.useEffect.call(void 0, ()=>{if(typeof window>"u"||window.parent!==window||!d)return;let D=Qe(window.location.search);D&&Xe(D);let $=_nullishCoalesce(D, () => (Me()));$&&(window.location.href=Ue($,d))},[d]),_jsxruntime.jsx.call(void 0, _chunkMG6VV5J2js.l,{value:c,children:_jsxruntime.jsxs.call(void 0, "div",{ref:k,className:"font-inter relative min-h-screen w-screen bg-beige-100 text-black dark:bg-black dark:text-white md:flex",children:[_jsxruntime.jsx.call(void 0, fr,{activeScreen:s,setActiveScreen:P,setParams:F,styles:z,theme:r,logout:g}),_jsxruntime.jsxs.call(void 0, "main",{className:"flex h-[calc(100vh-80px)] flex-col overflow-y-auto w-full p-5 md:h-screen",children:[s==="products"&&_jsxruntime.jsx.call(void 0, ur,{projectID:_nullishCoalesce(o, () => ("")),accessToken:d,loginURL:_nullishCoalesce(a, () => ("/panel/login")),styles:z,activeScreen:s,params:v,setParams:C,openCourse:A}),s==="course"&&v.course&&d&&_jsxruntime.jsx.call(void 0, Vt,{accessId:v.course,accessToken:d,theme:r,itemId:v.item,onItemChange:D=>C({item:D}),onBack:E}),s==="notifications"&&_jsxruntime.jsx.call(void 0, Bn,{}),s==="plans"&&_jsxruntime.jsx.call(void 0, Jn,{projectID:_nullishCoalesce(o, () => (""))}),s==="orders"&&_jsxruntime.jsx.call(void 0, Kn,{projectID:_nullishCoalesce(o, () => ("")),accessToken:_nullishCoalesce(d, () => ("")),openOrderDetails:R}),s==="order-details"&&v.orderId&&_jsxruntime.jsx.call(void 0, Zt,{orderID:v.orderId,onBack:q}),(s==="returns"||s==="return-details")&&d&&_jsxruntime.jsx.call(void 0, Ht,{projectID:_nullishCoalesce(o, () => ("")),host:i,accessToken:d,loginURL:_nullishCoalesce(a, () => ("/panel/login")),appearance:zn(e,_optionalChain([r, 'optionalAccess', _85 => _85.colors, 'optionalAccess', _86 => _86.brand])),texts:t,screen:s,params:v,setParams:C,setActiveScreen:P}),s==="profile"&&_jsxruntime.jsx.call(void 0, yr,{email:l,logout:g})]})]})})},Do= exports.q =To;var _reactquery = require('@tanstack/react-query');var _connect = require('@connectrpc/connect');var _connectweb = require('@connectrpc/connect-web');var le;(o=>{function e(r){return _connect.createClient.call(void 0, _chunkFGB5FJCIjs.f,n(r))}o.get=e;let t=new Map;function n(r){let a=t.get(r);return a==null&&(a=_connectweb.createConnectTransport.call(void 0, {useBinaryFormat:!0,baseUrl:r+"/api/rpc",interceptors:[_chunkDY2S42Q6js.b]}),t.set(r,a)),a}})(le = exports.a||={});var _zod = require('zod'); var _zod2 = _interopRequireDefault(_zod);function _(e,t=2){return+(Math.round(+(e+"e+"+t))+"e-"+t)}function Nr(e,t){let n=typeof navigator>"u"?"pl-PL":navigator.language;return Intl.NumberFormat(n,{style:"currency",currency:t,currencyDisplay:"symbol"}).format(e/100)}var Vd=_zod2.default.object({event:_zod2.default.enum(["purchase","addToCart","customizeProduct","viewCart","removeFromCart","initiateCheckout","lead"]),step:_zod2.default.string().optional(),value:_zod2.default.number().optional(),currency:_zod2.default.string().optional(),content_name:_zod2.default.string().optional(),items:_zod2.default.array(_zod2.default.object({id:_zod2.default.string(),name:_zod2.default.string(),price:_zod2.default.number().default(0),currency:_zod2.default.string().default("PLN"),quantity:_zod2.default.number().default(1)})).optional()});function Jt(e){typeof window>"u"||(Oo(e),Uo(e),jo(e))}function Oo(e){try{typeof window.dataLayer>"u"&&(window.dataLayer=[]);let t=Mo(e);window.dataLayer.push(t)}catch(t){console.warn("cannot send google analytics event",t)}}function Mo(e){let t=_nullishCoalesce(_nullishCoalesce(e.value, () => (_optionalChain([e, 'access', _87 => _87.items, 'optionalAccess', _88 => _88.reduce, 'call', _89 => _89((a,i)=>a+(i.price||0)*(i.quantity||1),0)]))), () => (0)),n=_optionalChain([e, 'access', _90 => _90.items, 'optionalAccess', _91 => _91.map, 'call', _92 => _92(a=>({item_id:a.id,item_name:a.name||a.id,price:_((a.price||0)/100,2),quantity:a.quantity||1}))]),o={currency:e.currency||"PLN",value:_(t/100,2)};n&&n.length>0&&(o.items=n);let r;switch(e.event){case"purchase":r="purchase",o.transaction_id=e.step||`txn_${Date.now()}`;break;case"addToCart":r="add_to_cart";break;case"viewCart":r="view_cart";break;case"removeFromCart":r="remove_from_cart";break;case"initiateCheckout":r="begin_checkout";break;case"customizeProduct":r="customize_product";break;default:r=e.event}return{event:r,ecommerce:o,...e.step&&{step:e.step},...e.content_name&&{content_name:e.content_name}}}function Uo(e){if(typeof window.fbq>"u")return;let t="",n="",o={};switch(e.event){case"purchase":t="track",n="Purchase",o={category_name:e.step,...e};break;case"lead":t="track",n="Lead",o={category_name:e.step,...e};break;case"addToCart":t="track",n="Add to Cart",o={category_name:e.step,...e};break;case"customizeProduct":t="track",n="Customize Product",o={category_name:e.step,...e};break;case"viewCart":t="track",n="View Cart",o={category_name:e.step,...e};break;case"removeFromCart":t="track",n="Remove from Cart",o={category_name:e.step,...e};break;case"initiateCheckout":t="track",n="Initiate Checkout",o={category_name:e.step,...e};break;default:break}window.location.search.includes("analytics")&&console.log("Pushing FB event",t,n,o),window.fbq(t,n,o)}function jo(e){try{if(typeof window.ttq>"u")return;let t=_o(e);if(!t)return;window.location.search.includes("analytics")&&console.log("Pushing TikTok event",t.eventName,t.eventPayload),window.ttq.track(t.eventName,t.eventPayload)}catch(t){console.warn("cannot send tiktok analytics event",t)}}function _o(e){let t=_nullishCoalesce(_nullishCoalesce(e.value, () => (_optionalChain([e, 'access', _93 => _93.items, 'optionalAccess', _94 => _94.reduce, 'call', _95 => _95((a,i)=>a+(i.price||0)*(i.quantity||1),0)]))), () => (0)),n=_optionalChain([e, 'access', _96 => _96.items, 'optionalAccess', _97 => _97.map, 'call', _98 => _98(a=>({content_id:a.id,content_type:"product",content_name:a.name||a.id,quantity:a.quantity||1,price:_((a.price||0)/100,2)}))])||[];n.length===0&&e.content_name&&n.push({content_id:e.step||"unknown",content_type:"product",content_name:e.content_name,quantity:1,price:_(t/100,2)});let o={currency:e.currency||"PLN",value:_(t/100,2)};n.length>0&&(o.contents=n);let r=null;switch(e.event){case"purchase":r="Purchase";break;case"addToCart":r="AddToCart";break;case"initiateCheckout":r="InitiateCheckout";break;case"customizeProduct":r="CustomizeProduct";break;case"viewCart":return;case"removeFromCart":return;case"lead":return;default:return null}return{eventName:r,eventPayload:o}}function Ir(e){let{items:t,googlePayConfig:n,checkout:o,result:r,cartRequiresShipping:a}=e,i=_nullishCoalesce(e.locale, () => (_chunkDY2S42Q6js.m.call(void 0, )));if(r.totalAmount==null)return;let c=[];return a&&(c.push("SHIPPING_ADDRESS"),c.push("SHIPPING_OPTION")),{apiVersion:2,apiVersionMinor:0,callbackIntents:c,allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:["MASTERCARD","VISA"]},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:n.gateway,gatewayMerchantId:n.gatewayId}}}],emailRequired:!0,shippingAddressParameters:{phoneNumberRequired:a},shippingAddressRequired:a,shippingOptionRequired:a,shippingOptionParameters:a?{shippingOptions:r.methods.slice(0,5).map(l=>({id:l.id,label:l.name+` - ${Nr(l.amount,r.currency)}`,description:_nullishCoalesce(l.description, () => (""))})),defaultSelectedOptionId:r.selectedDeliveryMethod}:void 0,merchantInfo:{merchantId:n.merchantId+"",merchantName:n.merchantName},transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:_chunkDY2S42Q6js.j.call(void 0, "paymentForCart",i,e.texts),totalPrice:`${_(r.totalAmount/100,2)}`,currencyCode:r.currency,countryCode:r.country,checkoutOption:"COMPLETE_IMMEDIATE_PURCHASE",displayItems:zo(t,r.methods,_nullishCoalesce(r.selectedDeliveryMethod, () => ((r.methods.length>0?r.methods[0].id:void 0))),o.couponCode,r.couponValue,_chunkDY2S42Q6js.j.call(void 0, "coupon",i,e.texts))}}}function zo(e,t,n,o,r,a="Coupon"){let i=[],c=0;for(let l of e){if(l.details==null)continue;let m=_nullishCoalesce(_optionalChain([l, 'access', _99 => _99.details, 'access', _100 => _100.pricing, 'optionalAccess', _101 => _101.effectivePrice]), () => (l.details.price));c+=m*l.quantity,i.push({label:l.details.name+" x "+l.quantity,price:`${_(m/100,2)}`,type:"LINE_ITEM",status:"FINAL"})}let d=t.find(l=>l.id===n);return d!=null&&i.push({label:d.name,price:`${_(d.amount/100,2)}`,type:"SHIPPING_OPTION",status:"FINAL"}),o!=null&&r!=null&&i.push({label:`${a} ${o}`,price:`${_(r/100,2)}`,type:"DISCOUNT",status:"FINAL"}),c>0&&i.push({label:"Subtotal",price:`${_(c/100,2)}`,type:"SUBTOTAL",status:"FINAL"}),i}function Fe(e,t){return`${_chunkDY2S42Q6js.f}/api/integrations/${e}/public-commerce${t}`}function ke(e){return typeof e=="object"&&e!=null&&"ERR"in e}function H(e,t,n){return{ERR:!0,error:e,type:t,data:n}}function Sr(e,t){return _optionalChain([t, 'optionalAccess', _102 => _102.find, 'call', _103 => _103(n=>n.id===e||(_nullishCoalesce(_optionalChain([n, 'access', _104 => _104.variants, 'optionalAccess', _105 => _105.some, 'call', _106 => _106(o=>o.id===e)]), () => (!1))))])}function Rr(e,t){let n=new Set(t.map(o=>o.productID));return Array.from(new Set(e.filter(o=>!n.has(o))))}function Ar(e,t){let n=_optionalChain([e, 'optionalAccess', _107 => _107.trim, 'call', _108 => _108()]);if(!(n==null||n.length===0))try{let o=new URL(n,t);return o.protocol!=="http:"&&o.protocol!=="https:"?void 0:o.href}catch (e6){return}}var _zustand = require('zustand');var Be=_zustand.create.call(void 0, e=>({isCartVisible:!1,notice:void 0,setNotice:t=>e(n=>({...n,notice:t})),numberOfProductsInCart:0,showCart:()=>e(t=>({...t,isCartVisible:!0})),hideCart:()=>e(t=>({...t,isCartVisible:!1})),setNumberOfProductsInCart:t=>e(n=>({...n,numberOfProductsInCart:t}))}));var vt=_react3.createContext.call(void 0, {});function sl({texts:e,locale:t,children:n}){let o=_react3.useMemo.call(void 0, ()=>({texts:e,locale:t}),[e,t]);return _jsxruntime.jsx.call(void 0, vt.Provider,{value:o,children:n})}function Dr(){return _react3.useContext.call(void 0, vt)}function cl(e){let{texts:t,locale:n}=_react3.useContext.call(void 0, vt);return _chunkDY2S42Q6js.j.call(void 0, e,_nullishCoalesce(n, () => (_chunkDY2S42Q6js.m.call(void 0, ))),t)}function dl(){let{texts:e,locale:t}=_react3.useContext.call(void 0, vt),n=_nullishCoalesce(t, () => (_chunkDY2S42Q6js.m.call(void 0, )));return _react3.useMemo.call(void 0, ()=>o=>_chunkDY2S42Q6js.j.call(void 0, o,n,e),[n,e])}var Xt="bitsnap-pending-order";function Or(e,t){let n=new Map;for(let r of t)n.set(r.id,(_nullishCoalesce(n.get(r.id), () => (0)))+r.quantity);let o=[];for(let r of e){let a=n.get(r.id);a==null?o.push(r):r.quantity>a&&o.push({...r,quantity:r.quantity-a})}return o}var Ho=60*1e3;function Mr(e,t=Date.now,n=Ho){let o;return r=>{let a=`${r.orderId}:${r.ts}`,i=t();return _optionalChain([o, 'optionalAccess', _109 => _109.key])===a&&i-o.at<n?Promise.reject(new Error("pending order was asked about recently")):(o={key:a,at:i},e(r))}}function $o(e){if(!(e==null||e.length===0))try{let t=new URL(e,"https://bitsnap.invalid").pathname,n=/\/payment\/common\/([^/]+)\/([^/]+)\/?$/.exec(t);return n==null?void 0:{projectId:decodeURIComponent(n[1]),orderId:decodeURIComponent(n[2])}}catch (e7){return}}function Go(e){if(e==null||e.length===0)return!1;try{let t=new URL(e,"https://bitsnap.invalid").pathname;return/\/payment\/manualPayment\/[^/]+\/[^/]+\/?$/.test(t)}catch (e8){return!1}}function Vo(e,t=Date.now(),n={}){if(Go(e.url))return;let o=$o(e.url),r=_nullishCoalesce(Lr(e.orderId), () => (_optionalChain([o, 'optionalAccess', _110 => _110.orderId]))),a=_nullishCoalesce(Lr(e.projectId), () => (_optionalChain([o, 'optionalAccess', _111 => _111.projectId])));if(!(r==null||a==null))return{orderId:r,projectId:a,...n.cartProjectId!=null?{cartProjectId:n.cartProjectId}:{},lines:_nullishCoalesce(n.lines, () => ([])),ts:t}}function ml(e,t={}){let n=Vo(e,t.now,t);return n!=null&&Ko(n,t.storage)}function Lr(e){return e!=null&&e.length>0?e:void 0}function wt(){try{return typeof localStorage>"u"?void 0:localStorage}catch (e9){return}}function Ko(e,t=wt()){try{return _optionalChain([t, 'optionalAccess', _112 => _112.setItem, 'call', _113 => _113(Xt,JSON.stringify(e))]),t!=null}catch (e10){return!1}}function Er(e=wt()){try{let t=_optionalChain([e, 'optionalAccess', _114 => _114.getItem, 'call', _115 => _115(Xt)]);if(t==null)return;let n=JSON.parse(t);if(typeof n=="object"&&n!=null&&typeof n.orderId=="string"&&typeof n.projectId=="string"&&typeof n.ts=="number"&&n.orderId.length>0){let{orderId:o,projectId:r,cartProjectId:a,ts:i,lines:c}=n;return{orderId:o,projectId:r,...typeof a=="string"?{cartProjectId:a}:{},lines:Array.isArray(c)?c.filter(d=>typeof _optionalChain([d, 'optionalAccess', _116 => _116.id])=="string"&&typeof d.quantity=="number"):[],ts:i}}}catch (e11){}Qt(e)}function Qt(e=wt()){try{_optionalChain([e, 'optionalAccess', _117 => _117.removeItem, 'call', _118 => _118(Xt)])}catch (e12){}}function Ur(e){let t=_nullishCoalesce(_optionalChain([e, 'access', _119 => _119.details, 'optionalAccess', _120 => _120.status]), () => (Wo(_optionalChain([e, 'access', _121 => _121.details, 'optionalAccess', _122 => _122.$unknown]))));return t==="created"||t==="placed"||t==="paid"||t==="canceled"?t:"unknown"}function Wo(e){if(Array.isArray(e)){for(let t of e)if(_optionalChain([t, 'optionalAccess', _123 => _123.no])===3&&t.wireType===2&&t.data instanceof Uint8Array){let n=0,o=0;for(let r=0;o<t.data.length&&r<35;r+=7){let a=t.data[o++];if(n|=(a&127)<<r,!(a&128))break}if(o+n!==t.data.length)return;try{return new TextDecoder().decode(t.data.subarray(o))}catch (e13){return}}}}async function jr(e){let t=_nullishCoalesce(e.storage, () => (wt())),n=Er(t);if(n==null)return"none";if((_nullishCoalesce(e.now, () => (Date.now)))()-n.ts>864e5)return Qt(t),"expired";if(e.projectId!=null&&n.cartProjectId!=null&&n.cartProjectId!==e.projectId)return"pending";let r;try{r=await e.fetchStatus(n)}catch (e14){return"pending"}let a=Er(t);if(_optionalChain([a, 'optionalAccess', _124 => _124.orderId])!==n.orderId||a.ts!==n.ts)return"pending";if(r==="paid"||r==="placed"){try{await e.removeLines(n.lines)}catch (e15){return"pending"}return Qt(t),"paid"}return"pending"}var ei="__m_a",Hr=_react3.createContext.call(void 0, void 0),rn= exports.M =void 0;function zl(e){_chunk7DG4UPWEjs.a.call(void 0, {projectID:e}),rn= exports.M =e,typeof window<"u"&&_chunk7DG4UPWEjs.g.call(void 0, [window.location.origin])}function Ge(){return _nullishCoalesce(_nullishCoalesce(rn, () => (_optionalChain([document, 'access', _125 => _125.querySelector, 'call', _126 => _126('script[data-id][data-name="internal-cart"]'), 'optionalAccess', _127 => _127.getAttribute, 'call', _128 => _128("data-id")]))), () => (void 0))}function ti(){return _nullishCoalesce(_optionalChain([document, 'access', _129 => _129.querySelector, 'call', _130 => _130('script[data-id][data-name="internal-cart"]'), 'optionalAccess', _131 => _131.getAttribute, 'call', _132 => _132("data-custom-host")]), () => (void 0))}var ni=({children:e,locale:t})=>{let[n]=_react3.useState.call(void 0, ()=>new _reactquery.QueryClient),o=Dr();_react3.useEffect.call(void 0, ()=>{$e()},[]);let r=Ge();if(_react3.useEffect.call(void 0, ()=>{if(r==null)return;let i=()=>{oi(r).then(d=>{d==="paid"&&n.invalidateQueries({queryKey:["cart"]})})},c=()=>{document.visibilityState==="visible"&&i()};return i(),window.addEventListener("pageshow",i),document.addEventListener("visibilitychange",c),()=>{window.removeEventListener("pageshow",i),document.removeEventListener("visibilitychange",c)}},[r,n]),r==null)return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{});let a=on(r,_nullishCoalesce(t, () => (o.locale)),o.texts);return _jsxruntime.jsx.call(void 0, _reactquery.QueryClientProvider,{client:n,children:_jsxruntime.jsx.call(void 0, Hr.Provider,{value:a,children:e})})},en,ri=Mr(async e=>Ur(await le.get(_chunkDY2S42Q6js.f).getOrder({id:e.orderId,projectId:e.projectId})));function ql(){let{country:e,couponCode:t,selectedDeliveryMethod:n,postalCode:o}=_nullishCoalesce(L(), () => (kt));return{country:e,couponCode:t,selectedDeliveryMethod:n,postalCode:o}}function Fl(){return(_nullishCoalesce(_optionalChain([L, 'call', _133 => _133(), 'optionalAccess', _134 => _134.products]), () => ([]))).map(e=>({id:e.id,quantity:e.quantity}))}function ai(e){let t=L();Q({...t,products:Or(_nullishCoalesce(_optionalChain([t, 'optionalAccess', _135 => _135.products]), () => ([])),e)}),$e()}function oi(e){return en??=jr({projectId:e,fetchStatus:ri,removeLines:ai}).catch(t=>{console.warn("cannot check the pending order",t)}).finally(()=>{en=void 0}),en}var He=async(e,t)=>{let n=[];_optionalChain([t, 'optionalAccess', _136 => _136.items])!=null&&t.items.length>0?n=t.items:n=_nullishCoalesce(_optionalChain([L, 'call', _137 => _137(), 'optionalAccess', _138 => _138.products]), () => ([]));let o=Array.from(new Set(n.map(i=>i.productID)));if(o.length===0)return[];let r=new URLSearchParams;r.set("ids",o.join(",")),r.set("locale",_nullishCoalesce(_optionalChain([t, 'optionalAccess', _139 => _139.locale]), () => (_chunkDY2S42Q6js.m.call(void 0, ))));let a;try{let i=await fetch(_chunkDY2S42Q6js.c.call(void 0, Fe(e,`/products?${r.toString()}`)),{method:"GET"});if(i.status!=200)return H("products-load-failed","internal");a=await i.json()}catch(i){return console.warn("cannot load the products of the cart",i),H("products-load-failed","internal")}return n.flatMap(i=>{let c=Sr(i.productID,a.result);return c==null?[]:[{...i,details:ui(i.productID,c),catalogProductID:c.id}]})},Bl= exports.S =()=>{let e=_react3.useContext.call(void 0, Hr);if(e===void 0)throw new Error("useCartProvider must be used within a CartProvider");return e},Hl= exports.T =ni,ii=_zod2.default.object({isAvailable:_zod2.default.boolean(),merchantId:_zod2.default.string(),merchantName:_zod2.default.string(),gateway:_zod2.default.string(),gatewayId:_zod2.default.string()}),si=_zod2.default.object({id:_zod2.default.string(),productID:_zod2.default.string(),quantity:_zod2.default.number(),priceVersion:_zod2.default.string().optional(),metadata:_zod2.default.record(_zod2.default.string(),_zod2.default.string().optional()).optional(),url:_zod2.default.string().optional()}),ci=_zod2.default.object({country:_zod2.default.string().optional(),couponCode:_zod2.default.string().optional(),selectedDeliveryMethod:_zod2.default.string().optional(),postalCode:_zod2.default.string().optional(),email:_zod2.default.string().optional(),products:_zod2.default.array(si).optional(),googlePayConfig:ii.optional()}),kt={country:void 0,couponCode:void 0,email:void 0,selectedDeliveryMethod:void 0,postalCode:void 0,products:[],googlePayConfig:void 0},$r="checkout";function L(){try{let e=localStorage.getItem($r);return e==null?kt:ci.parse(JSON.parse(e))}catch (e16){return kt}}async function zr(e,t){let n=await He(e,{items:t.map((a,i)=>({...a,id:`price-check-${i}`}))});if(ke(n))return n;let o=Rr(t.map(a=>a.productID),n);if(o.length>0)return H("item-ids-not-found","notFound",o);let r=L();r.products==null&&(r.products=[]),r.products.push(...t.map(a=>({id:Math.random().toString(36).substring(7),productID:a.productID,quantity:a.quantity,priceVersion:_optionalChain([n, 'access', _140 => _140.find, 'call', _141 => _141(i=>i.productID===a.productID), 'optionalAccess', _142 => _142.details, 'optionalAccess', _143 => _143.pricing, 'optionalAccess', _144 => _144.priceVersion]),metadata:a.metadata,url:Ar(a.url,typeof window<"u"?window.location.href:void 0)}))),di(t,n),Jt({event:"addToCart",currency:"PLN",items:t.map(a=>({id:a.productID,name:_nullishCoalesce(a.name, () => ("")),price:_nullishCoalesce(a.price, () => (0)),quantity:a.quantity,currency:_nullishCoalesce(a.currency, () => ("PLN"))}))}),Q(r),$e()}function di(e,t){for(let n of e)try{let o=t.find(c=>c.productID===n.productID),r=_nullishCoalesce(_nullishCoalesce(_optionalChain([o, 'optionalAccess', _145 => _145.details, 'optionalAccess', _146 => _146.pricing, 'optionalAccess', _147 => _147.effectivePrice]), () => (_optionalChain([o, 'optionalAccess', _148 => _148.details, 'optionalAccess', _149 => _149.price]))), () => (n.price)),a=_nullishCoalesce(_optionalChain([o, 'optionalAccess', _150 => _150.details, 'optionalAccess', _151 => _151.currency]), () => (n.currency));if(r==null||a==null)continue;let i=_nullishCoalesce(_optionalChain([o, 'optionalAccess', _152 => _152.catalogProductID]), () => (n.productID));(_nullishCoalesce(n.analytics, () => (_chunkMG6VV5J2js.o.call(void 0, )))).track("add_to_cart",{qty:n.quantity,value_minor:Math.round(r*n.quantity),currency:a},{product_id:i,variant_id:i!==n.productID?n.productID:null})}catch (e17){}}function qr(e){let t=L(),n={...t,products:_optionalChain([t, 'optionalAccess', _153 => _153.products, 'optionalAccess', _154 => _154.filter, 'call', _155 => _155(o=>!e.includes(o.productID)&&!e.includes(o.id))])};Jt({event:"removeFromCart",items:e.map(o=>({id:o,name:"",price:0,quantity:1,currency:"PLN"}))}),Q(n),$e()}function Q(e){localStorage.setItem($r,JSON.stringify(e))}function Fr(e,t){if(e.products==null||e.products.length==0)return;let n=e.products.reduce((o,r)=>(r.metadata!=null&&Object.keys(r.metadata).forEach(a=>{let i=_optionalChain([r, 'access', _156 => _156.metadata, 'optionalAccess', _157 => _157[a]]);i!=null&&(o[a]=i)}),o),{});return{items:e.products.map(o=>({id:o.productID,quantity:o.quantity,priceVersion:o.priceVersion})),askForNote:!0,countries:e.country?[e.country]:void 0,metadata:n,locale:t}}var on=(e,t=_chunkDY2S42Q6js.m.call(void 0, ),n)=>{let o=ti();return o!=null&&_chunkDY2S42Q6js.g.call(void 0, o),{async checkIfApplePayIsAvailable(){if(typeof window>"u"||typeof document>"u"||!("ApplePaySession"in window))return!1;try{return(await le.get(_chunkDY2S42Q6js.f).isOneClickPaymentAvailable({projectId:e})).applePay}catch(r){return console.error("Error checking if Apple Pay is available",r),!1}},async getGooglePayConfiguration(r){if(typeof window>"u"||typeof document>"u")return{isAvailable:!1};try{let a=await li(e);if(_optionalChain([a, 'optionalAccess', _158 => _158.isAvailable])!=!0)return{isAvailable:!1};let i=L();if(i==null)return console.log("checkout is null"),{isAvailable:!1};let c=await He(e,{locale:t,items:r.items.map(g=>({id:Math.random().toString(36).substring(7),quantity:g.quantity,metadata:g.metadata,productID:g.productID}))});if(ke(c))return{isAvailable:!1};let d=await le.get(_chunkDY2S42Q6js.f).getPreOrderDetails({items:c.map(g=>_protobuf.create.call(void 0, _chunkFGB5FJCIjs.c,{id:g.productID,quantity:g.quantity})),projectId:e,postCode:i.postalCode,couponCode:i.couponCode,countryCode:i.country,selectedDeliveryMethod:i.selectedDeliveryMethod});if(d.totalAmount==null)return{isAvailable:!1};let l=c.find(g=>_optionalChain([g, 'access', _159 => _159.details, 'optionalAccess', _160 => _160.isDeliverable])==!0)!=null,m=await Ir({items:c,googlePayConfig:a,checkout:i,cartRequiresShipping:l,result:d,locale:t,texts:n});return m==null?{isAvailable:!1}:{isAvailable:!0,config:m}}catch(a){return console.error("Error resolving Google Pay configuration",a),{isAvailable:!1}}},async clearCart(){let r=structuredClone(kt);r.country=_optionalChain([L, 'call', _161 => _161(), 'optionalAccess', _162 => _162.country]),Q(r),$e()},async getAvailableCountries(){let r=await fetch(_chunkDY2S42Q6js.c.call(void 0, Fe(e,"/countries")),{method:"GET"});if(r.status!=200)return[];try{return _zod2.default.array(_zod2.default.object({name:_zod2.default.string(),code:_zod2.default.string()})).parse(await r.json())}catch(a){return H(a.toString(),"internal")}},async getCountry(){let r=_optionalChain([L, 'call', _163 => _163(), 'optionalAccess', _164 => _164.country]);if(r==null){r="PL";let a=L();a.country=r,Q(a)}return r},async getNumberOfElementsInCart(){return _nullishCoalesce(_optionalChain([L, 'call', _165 => _165(), 'optionalAccess', _166 => _166.products, 'optionalAccess', _167 => _167.reduce, 'call', _168 => _168((r,a)=>r+a.quantity,0)]), () => (0))},async getProducts(){return await He(e,{locale:t})},async removeProductFromCart(r){return qr([r.id])},async setCountry(r){let a=L();a.country=r,Q(a)},async setCouponCodeIfPossible(r){let a=L();a.couponCode=r,Q(a)},async setPostalCode(r){let a=L();a.postalCode=r,Q(a)},async setDeliveryMethod(r){let a=L();a.selectedDeliveryMethod=r,Q(a)},async setEmail(r){let a=L();a.email=r,Q(a)},async addProduct(r){return await zr(e,[r])},async updateQuantity(r){let a=L();a.products=_optionalChain([a, 'access', _169 => _169.products, 'optionalAccess', _170 => _170.map, 'call', _171 => _171(i=>(i.id===r.id&&(i.quantity=r.quantity),i))]),Q(a),$e()},async getPaymentMethodChoice(){let r=Fr(L(),t);return r==null?null:Br(r)},async redirectToNextStep(r){let a=Fr(L(),t);if(a==null)return H("cart-is-empty","badInput");_optionalChain([r, 'optionalAccess', _172 => _172.paymentMethod])!=null&&(a.paymentMethod=r.paymentMethod);let i=await nn(a);return ke(i)?(console.warn("cannot create payment URL",i.error),i):{url:i.url,...i.orderId!=null?{orderId:i.orderId}:{},...i.projectId!=null?{projectId:i.projectId}:{}}},async justRedirectToPayment(r){let a={items:[{id:r.productID,quantity:1}],askForNote:!1,details:r.email||r.name?{name:r.name,email:r.email}:void 0,locale:_nullishCoalesce(r.locale, () => (t))};a=an(a),r.country==null&&(r.country="pl"),a.details==null&&(a.details={}),a.details.address==null&&(a.details.address={}),a.details.address.country=r.country,r.marketingAgreement===!0&&(a.additionalAgreements=[{id:ei,name:"",required:!0,answer:!0}]);let i=await nn(a);return ke(i)?i:{url:i.url}},async getApplePayPreview(r){let a=L();try{let i=await le.get(_chunkDY2S42Q6js.f).getPreOrderDetails({items:r.items.map(c=>_protobuf.create.call(void 0, _chunkFGB5FJCIjs.c,{id:c.productID,quantity:c.quantity})),projectId:e,postCode:a.postalCode,couponCode:a.couponCode,countryCode:a.country,selectedDeliveryMethod:a.selectedDeliveryMethod});return i.totalAmount==null||i.currency.length===0?H("pre-order-unavailable","internal"):{countryCode:i.country||a.country||"PL",currencyCode:i.currency,totalAmount:`${_(i.totalAmount/100,2)}`}}catch(i){return console.warn("cannot load the Apple Pay preview",i),H("pre-order-unavailable","internal")}},async completeApplePayPayment(r){let a=L();if(a==null)return H("Checkout not found");let i=await He(e,{locale:t});if(ke(i))return i;try{let c=_optionalChain([r, 'access', _173 => _173.shippingContact, 'optionalAccess', _174 => _174.givenName]);_optionalChain([r, 'access', _175 => _175.shippingContact, 'optionalAccess', _176 => _176.familyName])!=null?c+=" "+_optionalChain([r, 'access', _177 => _177.shippingContact, 'optionalAccess', _178 => _178.familyName]):_optionalChain([r, 'access', _179 => _179.billingContact, 'optionalAccess', _180 => _180.familyName])!=null&&(c+=" "+_optionalChain([r, 'access', _181 => _181.billingContact, 'optionalAccess', _182 => _182.familyName]));let d={},l=xt();l!=null&&(d.ref=l);let m=await le.get(_chunkDY2S42Q6js.f).authorizeOneClickPayment({gateway:0,paymentData:JSON.stringify(r.token.paymentData),paymentMethod:JSON.stringify(r.token.paymentMethod),transactionIdentifier:r.token.transactionIdentifier,order:_protobuf.create.call(void 0, _chunkFGB5FJCIjs.d,{items:i.map(g=>({id:g.productID,quantity:g.quantity})),couponCode:a.couponCode,email:_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([r, 'access', _183 => _183.shippingContact, 'optionalAccess', _184 => _184.emailAddress]), () => (_optionalChain([r, 'access', _185 => _185.billingContact, 'optionalAccess', _186 => _186.emailAddress]))), () => (a.email)), () => (void 0)),phone:_nullishCoalesce(_nullishCoalesce(_optionalChain([r, 'access', _187 => _187.shippingContact, 'optionalAccess', _188 => _188.phoneNumber]), () => (_optionalChain([r, 'access', _189 => _189.billingContact, 'optionalAccess', _190 => _190.phoneNumber]))), () => (void 0)),selectedDeliveryMethod:a.selectedDeliveryMethod,postCode:a.postalCode,projectId:e}),shippingAddress:_protobuf.create.call(void 0, _chunkFGB5FJCIjs.a,{line1:_nullishCoalesce(_optionalChain([r, 'access', _191 => _191.shippingContact, 'optionalAccess', _192 => _192.addressLines, 'optionalAccess', _193 => _193[0]]), () => ("")),city:_nullishCoalesce(_optionalChain([r, 'access', _194 => _194.shippingContact, 'optionalAccess', _195 => _195.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([r, 'access', _196 => _196.shippingContact, 'optionalAccess', _197 => _197.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([r, 'access', _198 => _198.shippingContact, 'optionalAccess', _199 => _199.postalCode]), () => ("")),name:c}),billingAddress:_protobuf.create.call(void 0, _chunkFGB5FJCIjs.b,{name:_nullishCoalesce(_optionalChain([r, 'access', _200 => _200.billingContact, 'optionalAccess', _201 => _201.givenName]), () => (" "+(_nullishCoalesce(_optionalChain([r, 'access', _202 => _202.billingContact, 'optionalAccess', _203 => _203.familyName]), () => (""))))),line1:_nullishCoalesce(_optionalChain([r, 'access', _204 => _204.billingContact, 'optionalAccess', _205 => _205.addressLines, 'optionalAccess', _206 => _206[0]]), () => ("")),city:_nullishCoalesce(_optionalChain([r, 'access', _207 => _207.billingContact, 'optionalAccess', _208 => _208.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([r, 'access', _209 => _209.billingContact, 'optionalAccess', _210 => _210.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([r, 'access', _211 => _211.billingContact, 'optionalAccess', _212 => _212.postalCode]), () => (""))}),metadata:Object.keys(d).length>0?JSON.stringify(d):void 0});return{isSuccess:m.isSuccess,redirectURL:m.redirectUrl}}catch(c){return console.error(c),H("Failed to authorize payment")}},async completeGooglePayPayment(r){let a=L();if(a==null)return H("Checkout not found");let i=await He(e,{locale:t});if(ke(i))return i;try{let c=_optionalChain([r, 'access', _213 => _213.paymentData, 'access', _214 => _214.shippingAddress, 'optionalAccess', _215 => _215.name]),d={},l=xt();l!=null&&(d.ref=l);let m=await le.get(_chunkDY2S42Q6js.f).authorizeOneClickPayment({gateway:1,paymentData:r.paymentData.paymentMethodData.tokenizationData.token,paymentMethod:r.paymentData.paymentMethodData.type,transactionIdentifier:"",order:_protobuf.create.call(void 0, _chunkFGB5FJCIjs.d,{items:i.map(g=>({id:g.productID,quantity:g.quantity})),couponCode:a.couponCode,email:_nullishCoalesce(r.paymentData.email, () => (void 0)),phone:_nullishCoalesce(_optionalChain([r, 'access', _216 => _216.paymentData, 'access', _217 => _217.shippingAddress, 'optionalAccess', _218 => _218.phoneNumber]), () => (void 0)),selectedDeliveryMethod:_nullishCoalesce(_optionalChain([r, 'access', _219 => _219.paymentData, 'access', _220 => _220.shippingOptionData, 'optionalAccess', _221 => _221.id]), () => (a.selectedDeliveryMethod)),postCode:_optionalChain([r, 'access', _222 => _222.paymentData, 'access', _223 => _223.shippingAddress, 'optionalAccess', _224 => _224.postalCode]),projectId:e}),shippingAddress:_protobuf.create.call(void 0, _chunkFGB5FJCIjs.a,{line1:_nullishCoalesce(_optionalChain([r, 'access', _225 => _225.paymentData, 'access', _226 => _226.shippingAddress, 'optionalAccess', _227 => _227.address1]), () => ("")),city:_nullishCoalesce(_optionalChain([r, 'access', _228 => _228.paymentData, 'access', _229 => _229.shippingAddress, 'optionalAccess', _230 => _230.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([r, 'access', _231 => _231.paymentData, 'access', _232 => _232.shippingAddress, 'optionalAccess', _233 => _233.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([r, 'access', _234 => _234.paymentData, 'access', _235 => _235.shippingAddress, 'optionalAccess', _236 => _236.postalCode]), () => ("")),name:c}),billingAddress:_protobuf.create.call(void 0, _chunkFGB5FJCIjs.b,{name:_optionalChain([r, 'access', _237 => _237.paymentData, 'access', _238 => _238.paymentMethodData, 'access', _239 => _239.info, 'optionalAccess', _240 => _240.billingAddress, 'optionalAccess', _241 => _241.name]),line1:_nullishCoalesce(_optionalChain([r, 'access', _242 => _242.paymentData, 'access', _243 => _243.paymentMethodData, 'access', _244 => _244.info, 'optionalAccess', _245 => _245.billingAddress, 'optionalAccess', _246 => _246.address1]), () => ("")),city:_nullishCoalesce(_optionalChain([r, 'access', _247 => _247.paymentData, 'access', _248 => _248.paymentMethodData, 'access', _249 => _249.info, 'optionalAccess', _250 => _250.billingAddress, 'optionalAccess', _251 => _251.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([r, 'access', _252 => _252.paymentData, 'access', _253 => _253.paymentMethodData, 'access', _254 => _254.info, 'optionalAccess', _255 => _255.billingAddress, 'optionalAccess', _256 => _256.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([r, 'access', _257 => _257.paymentData, 'access', _258 => _258.paymentMethodData, 'access', _259 => _259.info, 'optionalAccess', _260 => _260.billingAddress, 'optionalAccess', _261 => _261.postalCode]), () => (""))}),metadata:Object.keys(d).length>0?JSON.stringify(d):void 0});return{isSuccess:m.isSuccess,redirectURL:m.redirectUrl}}catch(c){return console.error(c),H("Failed to authorize payment")}return{isSuccess:!0}},async getApplePayPaymentRequest(r){let a=L();if(a==null)return H("Checkout not found");r&&r.expectedItems!=null&&r.expectedItems.length>0&&(a.products&&qr(a.products.map(l=>l.productID)),await zr(e,r.expectedItems));let i=await He(e,{locale:t});if(ke(i))return i;let c=await le.get(_chunkDY2S42Q6js.f).getPreOrderDetails({items:i.map(l=>_protobuf.create.call(void 0, _chunkFGB5FJCIjs.c,{id:l.productID,quantity:l.quantity})),projectId:e,postCode:a.postalCode,couponCode:a.couponCode,countryCode:a.country,selectedDeliveryMethod:a.selectedDeliveryMethod}),d=i.map(l=>({amount:`${_(l.quantity*(_nullishCoalesce(_nullishCoalesce(_optionalChain([l, 'access', _262 => _262.details, 'optionalAccess', _263 => _263.pricing, 'optionalAccess', _264 => _264.effectivePrice]), () => (_optionalChain([l, 'access', _265 => _265.details, 'optionalAccess', _266 => _266.price]))), () => (0)))/100,2)}`,label:_optionalChain([l, 'access', _267 => _267.details, 'optionalAccess', _268 => _268.name])+" - "+l.quantity,type:"final"}));if(c.selectedDeliveryMethod!=null){let l=c.methods.find(m=>m.id==c.selectedDeliveryMethod);l!=null&&d.push({amount:`${_(l.amount/100,2)}`,label:l.name,type:"final"})}return c.couponCode!=null&&c.couponValue!=null&&d.push({amount:`-${_(c.couponValue/100,2)}`,label:c.couponCode,type:"final"}),{countryCode:c.country||a.country||"PL",merchantCapabilities:["supports3DS","supportsCredit","supportsDebit"],supportedNetworks:["visa","masterCard"],total:{amount:`${_((_nullishCoalesce(c.totalAmount, () => (0)))/100,2)}`,label:_chunkDY2S42Q6js.j.call(void 0, "paymentForCart",t,n),type:"final"},shippingMethods:c.methods.map(l=>({amount:`${_(l.amount/100,2)}`,detail:_nullishCoalesce(l.description, () => ("")),identifier:l.id,label:l.name,dateComponentsRange:{startDateComponents:{days:_nullishCoalesce(l.minDays, () => (1)),hours:0,months:0,years:0},endDateComponents:{days:_nullishCoalesce(l.maxDays, () => (14)),hours:0,months:0,years:0}}})),lineItems:d,currencyCode:c.currency||_optionalChain([i, 'access', _269 => _269[0], 'optionalAccess', _270 => _270.details, 'optionalAccess', _271 => _271.currency])||"PLN"}}}};async function li(e){let t=L();if(_optionalChain([t, 'access', _272 => _272.googlePayConfig, 'optionalAccess', _273 => _273.isAvailable])!=!0){let n=await le.get(_chunkDY2S42Q6js.f).isOneClickPaymentAvailable({projectId:e});n.googlePay==!0&&n.googlePayConfig!=null?t.googlePayConfig={isAvailable:!0,gateway:n.googlePayConfig.gateway,gatewayId:n.googlePayConfig.gatewayMerchantId,merchantName:n.googlePayConfig.merchantName,merchantId:n.googlePayConfig.merchantId}:t.googlePayConfig={isAvailable:!1,gateway:"",gatewayId:"",merchantName:"",merchantId:""}}return Q(t),t.googlePayConfig}function ui(e,t){if(e==t.id){let o=_optionalChain([t, 'access', _274 => _274.variants, 'optionalAccess', _275 => _275.findIndex, 'call', _276 => _276(r=>r.id===e)]);if(o!=null&&o!=-1){let r=t.variants[o];return{...t,availableQuantity:r.availableQuantity,isDeliverable:r.isDeliverable,images:_nullishCoalesce(r.images, () => (t.images)),name:t.name+" "+r.name,baseName:t.name,variantName:r.name,price:r.price,currency:r.currency,pricing:r.pricing}}return t}let n=_optionalChain([t, 'access', _277 => _277.variants, 'optionalAccess', _278 => _278.find, 'call', _279 => _279(o=>o.id===e)]);return n==null?t:{...t,id:n.id,name:t.name+" "+n.name,baseName:t.name,variantName:n.name,price:n.price,currency:n.currency,pricing:n.pricing,metadata:t.metadata,availableQuantity:n.availableQuantity,isDeliverable:n.isDeliverable,images:_nullishCoalesce(n.images, () => (t.images))}}function $e(){let e=L(),t=0;if(e==null){Be.setState(n=>({...n,numberOfProductsInCart:t}));return}t=_nullishCoalesce(_optionalChain([e, 'access', _280 => _280.products, 'optionalAccess', _281 => _281.reduce, 'call', _282 => _282((n,o)=>n+o.quantity,0)]), () => (0)),Be.setState(n=>({...n,numberOfProductsInCart:t}))}var pi=200,fi= exports.v ="item-ids-not-found",at="internal-error",Gr={"no-payment-gateway":"noPaymentGateway","gateway-not-configured":"gatewayNotConfigured","shipping-not-configured":"shippingNotConfigured","mixed-recurring":"mixedRecurring","currency-unsupported":"currencyUnsupported","price-changed":"priceChanged","product-not-found":"unavailableProducts","product-not-available":"unavailableProducts"},gi=new Set(["internal","invalid-request"]),yi=new Set(["product-not-available","product-not-found"]);function hi(e){return typeof e=="string"&&Object.hasOwn(Gr,e)?Gr[e]:void 0}function Pi(e){return/<\/?[a-z!?][^>]*>/i.test(e)}function bi(e){return/^[A-Za-z][A-Za-z0-9]*(?:[-_.:][A-Za-z0-9]+)*$/.test(e)&&!/^[A-Z][a-z]+$/.test(e)||/^\[object \w+\]$|^(?:undefined|null)$/.test(e)}function vi(e){return/Error:/.test(e)||/\n\s+at /.test(e)}function sn(e){let t=e.trim();if(!(t.length===0||t.length>pi||/[\r\n]/.test(t)||Pi(t)||bi(t)||vi(t)))return t}var wi=3;function Ct(e,t=0){if(typeof e=="object"&&e!=null){if(Array.isArray(e)||t>=wi)return{};let n=e,o=Ct(n.error,t+1);if(o.message==null&&n.message!=null){let r=Ct(n.message,t+1);o={...r,code:_nullishCoalesce(o.code, () => (r.code))}}return typeof n.code=="string"&&n.code.length>0&&(o.code=n.code),o}if(typeof e!="string")return{};try{let n=JSON.parse(e);return typeof n=="object"&&n!=null?Ct(n,t+1):{}}catch (e18){}return{message:sn(e)}}function xi(e){let t;try{t=JSON.parse(e)}catch (e19){return{code:at,message:sn(e)}}if(typeof t=="string")return{code:at,message:sn(t)};if(typeof t!="object"||t==null)return{code:at};let n=t,{message:o,code:r}=Ct(n.error),a={code:typeof n.code=="string"&&n.code.length>0?n.code:_nullishCoalesce(r, () => (at)),message:o};return Array.isArray(n.itemIds)&&(a.itemIds=n.itemIds.filter(i=>typeof i=="string")),a}function cn(e,t){let{code:n,message:o,itemIds:r}=xi(t),a=r!=null&&r.length>0;if(a&&(n===at||yi.has(n)))return H(fi,"badInput",r);let i={message:o};return a&&(i.itemIds=r),H(n,e>=500?"internal":"badInput",i)}function Wl(e,t){let n=hi(e.error);if(n!=null)return t(n);if(e.type==="internal"||typeof e.error=="string"&&gi.has(e.error))return t("checkoutFailed");let o=_optionalChain([e, 'access', _283 => _283.data, 'optionalAccess', _284 => _284.message]);return typeof o=="string"&&o.length>0?o:t("checkoutFailed")}var ki=["online","manual","cod"],Ci=["bankTransfer","blik"];function Vr(e,t){if(!Array.isArray(e))return[];let n=[];for(let o of e)t.includes(o)&&!n.includes(o)&&n.push(o);return n}function Ni(e){if(typeof e!="object"||e==null)return null;let t=e.choice;if(typeof t!="object"||t==null)return null;let n=Vr(t.methods,ki);return n.length<2?null:{methods:n,manualAccountTypes:Vr(t.manualAccountTypes,Ci)}}function Jl(e){if(e==null)return null;let t=e.methods.filter(n=>n!=="cod");return t.length<2?null:{...e,methods:t}}function Yl(e,t){return t!=null&&e.methods.includes(t)?t:e.methods[0]}function Ql(e){let t=e.includes("bankTransfer"),n=e.includes("blik");return n&&!t?"paymentMethodManualBlik":t&&!n?"paymentMethodManualTransfer":"paymentMethodManualBoth"}async function Kr(e,t,n=5e3){let o=typeof AbortController>"u"?void 0:new AbortController,r=setTimeout(()=>_optionalChain([o, 'optionalAccess', _285 => _285.abort, 'call', _286 => _286()]),n);try{let a=await fetch(e,{method:"POST",headers:t.headers,body:t.body,signal:_optionalChain([o, 'optionalAccess', _287 => _287.signal])});return a.ok?Ni(await a.json()):null}catch (e20){return null}finally{clearTimeout(r)}}var Ii;(o=>{async function e(r,a=1,i,c){let d=Ge();if(d==null)throw new Error("No project ID found");let m=await on(d).addProduct({productID:r,quantity:a,metadata:i,...c});if(m!=null)return m}o.addProductToCart=e;function t(){Be.setState({isCartVisible:!0})}o.showCart=t;function n(){Be.setState({isCartVisible:!1})}o.hideCart=n})(Ii = exports.B||={});async function Wr(e){try{return await e.text()}catch (e21){return""}}function Zr(e,t){return t=an(t),t.locale??=_chunkDY2S42Q6js.m.call(void 0, ),{headers:{..._chunkDY2S42Q6js.a,..._chunkMG6VV5J2js.h.call(void 0, e),"Content-Type":"application/json"},body:JSON.stringify(t)}}async function Br(e){let t=Ge();return t==null?null:Kr(Fe(t,"/payment-methods"),Zr(t,e))}async function nn(e){let t=Ge();if(t==null)throw new Error("No project ID found");let n=await fetch(Fe(t,"/buy"),{method:"POST",...Zr(t,e)});if(n.status!=200){let r=cn(n.status,await Wr(n));return console.warn("cannot create payment URL",n.status,r.error),r}let o=await n.json();return{url:o.url,...o.orderId!=null?{orderId:o.orderId}:{},...o.projectId!=null?{projectId:o.projectId}:{}}}async function cu(e){let t=Ge();if(t==null)throw new Error("No project ID found");let n={..._chunkDY2S42Q6js.a,..._chunkMG6VV5J2js.h.call(void 0, t),"Content-Type":"application/json",...e.apiKey!=null?{Authorization:`Bearer ${e.apiKey}`}:{}},o=e.testMode?`/api/payment/link/auto/${t}/test`:`/api/payment/link/auto/${t}`;delete e.apiKey,delete e.testMode,e.locale??=_chunkDY2S42Q6js.m.call(void 0, );let r=await fetch(_chunkDY2S42Q6js.f+o,{method:"POST",headers:n,body:JSON.stringify(e)});return r.ok?{status:"ok",redirectURL:(await r.json()).url}:{...cn(r.status,await Wr(r)),status:"error"}}function xt(){if(typeof localStorage>"u")return;let e=localStorage.getItem("bitsnap-ref");if(e!=null)return e}function an(e){let t=xt();return t==null||(e.metadata==null&&(e.metadata={}),e.metadata.ref=t),e}exports.a = le; exports.b = ue; exports.c = be; exports.d = ve; exports.e = Mt; exports.f = me; exports.g = On; exports.h = Ut; exports.i = Se; exports.j = Qe; exports.k = Xe; exports.l = Me; exports.m = Ue; exports.n = ya; exports.o = Fn; exports.p = Zt; exports.q = Do; exports.r = _; exports.s = Nr; exports.t = Jt; exports.u = ke; exports.v = fi; exports.w = Wl; exports.x = Jl; exports.y = Yl; exports.z = Ql; exports.A = Be; exports.B = Ii; exports.C = Br; exports.D = nn; exports.E = cu; exports.F = xt; exports.G = an; exports.H = sl; exports.I = cl; exports.J = dl; exports.K = ml; exports.L = ei; exports.M = rn; exports.N = zl; exports.O = Ge; exports.P = ql; exports.Q = Fl; exports.R = oi; exports.S = Bl; exports.T = Hl; exports.U = on;
4
+ //# sourceMappingURL=chunk-VY6CZVVA.js.map