bitsnap-react 1.10.0 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -1
- package/dist/CartProvider-QY2DMNCC.js +2 -0
- package/dist/CartProvider-QY2DMNCC.js.map +1 -0
- package/dist/CartProvider-XMHPQRWC.mjs +2 -0
- package/dist/analytics.js +1 -1
- package/dist/analytics.js.map +1 -1
- package/dist/analytics.mjs +1 -1
- package/dist/catalog.js +1 -1
- package/dist/catalog.js.map +1 -1
- package/dist/catalog.mjs +1 -1
- package/dist/{chunk-JXCHRSPW.mjs → chunk-2PK36NGB.mjs} +3 -3
- package/dist/chunk-2PK36NGB.mjs.map +1 -0
- package/dist/{chunk-6D3OORMK.mjs → chunk-2X32DDUM.mjs} +2 -2
- package/dist/{chunk-F6GQLKA6.js → chunk-3IVLQILF.js} +2 -2
- package/dist/chunk-3IVLQILF.js.map +1 -0
- package/dist/{chunk-T2OUOO4X.mjs → chunk-DWRBPP32.mjs} +2 -2
- package/dist/{chunk-YXFJG4MF.mjs → chunk-ETGHIHWR.mjs} +2 -2
- package/dist/{chunk-DPKT6ITB.js → chunk-FBTYZHXM.js} +3 -3
- package/dist/chunk-FBTYZHXM.js.map +1 -0
- package/dist/chunk-G2UOTVS5.mjs +2 -0
- package/dist/chunk-G2UOTVS5.mjs.map +1 -0
- package/dist/{chunk-DDY7IBMG.mjs → chunk-HWQNT6XU.mjs} +2 -2
- package/dist/{chunk-RLEC25JI.mjs → chunk-IJLHU2MA.mjs} +2 -2
- package/dist/{chunk-RLEC25JI.mjs.map → chunk-IJLHU2MA.mjs.map} +1 -1
- package/dist/chunk-JSDGZ4NY.js.map +1 -1
- package/dist/{chunk-ZPTHK4OX.mjs → chunk-JUDR4EZA.mjs} +2 -2
- package/dist/chunk-KOYBZORL.js.map +1 -1
- package/dist/chunk-Q25D7OAO.js +2 -0
- package/dist/chunk-Q25D7OAO.js.map +1 -0
- package/dist/{chunk-RVILRUW3.js → chunk-UCL4Y7L3.js} +2 -2
- package/dist/chunk-UCL4Y7L3.js.map +1 -0
- package/dist/{chunk-AJNULBC3.js → chunk-UFIOJGJZ.js} +2 -2
- package/dist/chunk-UFIOJGJZ.js.map +1 -0
- package/dist/{chunk-F46RJVWC.js → chunk-VPBFEAFQ.js} +2 -2
- package/dist/chunk-VPBFEAFQ.js.map +1 -0
- package/dist/{chunk-B32ACCW2.js → chunk-WGJTXDIS.js} +2 -2
- package/dist/chunk-WGJTXDIS.js.map +1 -0
- package/dist/chunk-XIHGWNTS.js.map +1 -1
- package/dist/{chunk-3Z6VNXBP.js → chunk-YBGAYEJQ.js} +2 -2
- package/dist/chunk-YBGAYEJQ.js.map +1 -0
- package/dist/consent.js +30 -15
- package/dist/consent.js.map +1 -1
- package/dist/consent.mjs +30 -15
- package/dist/consent.mjs.map +1 -1
- package/dist/course.js +1 -1
- package/dist/course.js.map +1 -1
- package/dist/course.mjs +1 -1
- package/dist/embed/analytics.js +1 -1
- package/dist/embed/consent.js +30 -15
- package/dist/errors.js.map +1 -1
- package/dist/index.d.mts +37 -5
- package/dist/index.d.ts +37 -5
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/internal.js.map +1 -1
- package/dist/methods-ALO22YWQ.mjs +2 -0
- package/dist/methods-ZBX4BTDE.js +2 -0
- package/dist/methods-ZBX4BTDE.js.map +1 -0
- package/dist/models.js.map +1 -1
- package/dist/returns.js +1 -1
- package/dist/returns.js.map +1 -1
- package/dist/returns.mjs +1 -1
- package/package.json +2 -2
- package/dist/CartProvider-HXLGQ4EX.mjs +0 -2
- package/dist/CartProvider-OHHYOMSG.js +0 -2
- package/dist/CartProvider-OHHYOMSG.js.map +0 -1
- package/dist/chunk-3Z6VNXBP.js.map +0 -1
- package/dist/chunk-43IIYJ6J.mjs +0 -2
- package/dist/chunk-43IIYJ6J.mjs.map +0 -1
- package/dist/chunk-AJNULBC3.js.map +0 -1
- package/dist/chunk-B32ACCW2.js.map +0 -1
- package/dist/chunk-DPKT6ITB.js.map +0 -1
- package/dist/chunk-F46RJVWC.js.map +0 -1
- package/dist/chunk-F6GQLKA6.js.map +0 -1
- package/dist/chunk-JXCHRSPW.mjs.map +0 -1
- package/dist/chunk-RVILRUW3.js.map +0 -1
- package/dist/chunk-VIII45AC.js +0 -2
- package/dist/chunk-VIII45AC.js.map +0 -1
- package/dist/methods-A5KGZBAM.js +0 -2
- package/dist/methods-A5KGZBAM.js.map +0 -1
- package/dist/methods-AOHKV7IN.mjs +0 -2
- /package/dist/{CartProvider-HXLGQ4EX.mjs.map → CartProvider-XMHPQRWC.mjs.map} +0 -0
- /package/dist/{chunk-6D3OORMK.mjs.map → chunk-2X32DDUM.mjs.map} +0 -0
- /package/dist/{chunk-T2OUOO4X.mjs.map → chunk-DWRBPP32.mjs.map} +0 -0
- /package/dist/{chunk-YXFJG4MF.mjs.map → chunk-ETGHIHWR.mjs.map} +0 -0
- /package/dist/{chunk-DDY7IBMG.mjs.map → chunk-HWQNT6XU.mjs.map} +0 -0
- /package/dist/{chunk-ZPTHK4OX.mjs.map → chunk-JUDR4EZA.mjs.map} +0 -0
- /package/dist/{methods-AOHKV7IN.mjs.map → methods-ALO22YWQ.mjs.map} +0 -0
package/README.md
CHANGED
|
@@ -353,7 +353,22 @@ copy per language, pass a different object.
|
|
|
353
353
|
```
|
|
354
354
|
|
|
355
355
|
Checkout keys (`CheckoutTexts`): `cart`, `emptyCart`, `total`, `delivery`,
|
|
356
|
-
`chooseCountry`, `nextStep`, `unavailableProducts
|
|
356
|
+
`chooseCountry`, `nextStep`, `unavailableProducts`, `checkoutFailed`,
|
|
357
|
+
`noPaymentGateway`, `gatewayNotConfigured`, `shippingNotConfigured`,
|
|
358
|
+
`mixedRecurring`, `currencyUnsupported`, `priceChanged`.
|
|
359
|
+
|
|
360
|
+
When "Next step" fails, the cart shows the text of the backend error code
|
|
361
|
+
(`noPaymentGateway`, `gatewayNotConfigured`, `shippingNotConfigured`,
|
|
362
|
+
`mixedRecurring`, `currencyUnsupported`, `priceChanged`; `unavailableProducts`
|
|
363
|
+
for `product-not-found`). Server errors (5xx, `internal`) and `invalid-request`
|
|
364
|
+
show `checkoutFailed`. For any other 4xx code the cart shows the message sent
|
|
365
|
+
by the server, else `checkoutFailed`. It never shows the bare code, and never
|
|
366
|
+
a message that is HTML, multi-line, longer than 200 characters or a stack
|
|
367
|
+
trace.
|
|
368
|
+
|
|
369
|
+
These keys were added in 1.11.0. If you type your own language
|
|
370
|
+
objects, use `Partial<CheckoutTexts>` (the `texts` prop already accepts it) so
|
|
371
|
+
that they keep compiling when new keys appear.
|
|
357
372
|
|
|
358
373
|
Returns keys (`ReturnsTexts`) cover each step (`emailStepTitle`,
|
|
359
374
|
`codeStepDescription`, `ordersEmpty`, `confirmationSubmit`, `successTitle`,
|
|
@@ -763,6 +778,40 @@ async function handleCheckout() {
|
|
|
763
778
|
}
|
|
764
779
|
```
|
|
765
780
|
|
|
781
|
+
On success `createCheckout` returns `{ status: "ok", redirectURL }`. A failed
|
|
782
|
+
response no longer throws and no longer yields an undefined `redirectURL`: it
|
|
783
|
+
returns an `Err` with `status: "error"` instead (`result.ERR === true`), typed
|
|
784
|
+
as `CreateCheckoutResult`. Check `result.status === "ok"` before reading
|
|
785
|
+
`redirectURL`. `result.error` is the backend code (`invalid-request`,
|
|
786
|
+
`product-not-available`, `product-not-found`, `no-payment-gateway`,
|
|
787
|
+
`gateway-not-configured`, `shipping-not-configured`, `mixed-recurring`,
|
|
788
|
+
`currency-unsupported`, `price-changed`, `internal`). New backends send
|
|
789
|
+
`internal` for their own failures; `internal-error` is what the library uses
|
|
790
|
+
when an older backend sent no code. `result.data` is a `BuyErrorData`
|
|
791
|
+
(`{ message?, itemIds? }`), except for `item-ids-not-found`
|
|
792
|
+
(`ITEM_IDS_NOT_FOUND`), where it is the array of ids; both are exported.
|
|
793
|
+
`message` is the reason sent by the server, when it was usable. `result.type`
|
|
794
|
+
is `internal` for 5xx and `badInput` for 4xx.
|
|
795
|
+
|
|
796
|
+
```tsx
|
|
797
|
+
import { ITEM_IDS_NOT_FOUND, type BuyErrorData } from "bitsnap-react";
|
|
798
|
+
|
|
799
|
+
if (result.status === "error") {
|
|
800
|
+
if (result.error === ITEM_IDS_NOT_FOUND) {
|
|
801
|
+
const ids = result.data as string[];
|
|
802
|
+
} else {
|
|
803
|
+
const { message } = (result.data ?? {}) as BuyErrorData;
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
```
|
|
807
|
+
|
|
808
|
+
`createPaymentURL` returns the same errors: the backend code in `error`,
|
|
809
|
+
`type: "badInput"` for 4xx (`"internal"` for 5xx) and `data: { message }`.
|
|
810
|
+
When the backend lists unavailable products (`itemIds`) under
|
|
811
|
+
`product-not-available` or `product-not-found` (or sends no code), the error is
|
|
812
|
+
`item-ids-not-found` and `data` is the array of ids. With any other code the
|
|
813
|
+
code is kept and the ids are in `data.itemIds`.
|
|
814
|
+
|
|
766
815
|
6. Webhook Handler:
|
|
767
816
|
|
|
768
817
|
```tsx
|
|
@@ -1194,6 +1243,13 @@ The cookie only follows a banner that speaks for the project: a project-scope ba
|
|
|
1194
1243
|
|
|
1195
1244
|
Declare the cookie in your banner's cookie list (category `analytics`, purpose "shop statistics: recognising returning visitors", lifetime 13 months): add `{ name: "Bitsnap statistics", category: "analytics", cookies: ["bs_vid_<projectKey>"] }` to `services` in the banner config, with your exact bare project key, which also lets the banner delete it on withdrawal from pages that run no tracker. Do not use a `bs_vid_*` prefix: the banner deletes every cookie that matches it, which on a site shared by several merchants (bitsnap.pl) would wipe other projects' ids too.
|
|
1196
1245
|
|
|
1246
|
+
### Release notes (1.11.0)
|
|
1247
|
+
|
|
1248
|
+
- **The cart shows why it cannot continue to payment.** When `/buy` fails, the cart shows a localized text for the backend code (no payment gateway, delivery not configured, changed price, mixed subscription cart, unsupported currency), else the server's reason, else `checkoutFailed`. It never shows a bare code such as `internal-error`. Older bitsnap.pl responses are read too.
|
|
1249
|
+
- **`createCheckout` returns an error instead of a broken success.** A failed response returns an `Err` with `status: "error"` (typed `CreateCheckoutResult`) instead of `{ status: "ok", redirectURL: undefined }` or a thrown error. Check `result.status === "ok"` before reading `redirectURL`.
|
|
1250
|
+
- **`createPaymentURL` errors carry the backend code** in `error` (`badInput` for 4xx, `internal` for 5xx) and `data: { message }`, instead of always `internal-error`.
|
|
1251
|
+
- **New checkout text keys** (`checkoutFailed`, `noPaymentGateway`, `gatewayNotConfigured`, `shippingNotConfigured`, `mixedRecurring`, `currencyUnsupported`, `priceChanged`). Type your language objects as `Partial<CheckoutTexts>`.
|
|
1252
|
+
|
|
1197
1253
|
### Release notes (1.10.0)
|
|
1198
1254
|
|
|
1199
1255
|
- **Requires bitsnap.pl with `X-Bitsnap-Visitor` support.** The cart's `/buy` and `/api/payment/link/auto` requests now send that header while analytics is granted, and a server whose CORS preflight does not allow it makes those checkouts fail in the browser. Deploy bitsnap.pl first, then publish and install this version.
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkFBTYZHXMjs = require('./chunk-FBTYZHXM.js');require('./chunk-UCL4Y7L3.js');require('./chunk-KOYBZORL.js');require('./chunk-3IVLQILF.js');require('./chunk-UFIOJGJZ.js');var _chunkQ25D7OAOjs = require('./chunk-Q25D7OAO.js');require('./chunk-WGJTXDIS.js');require('./chunk-XIHGWNTS.js');require('./chunk-JSDGZ4NY.js');exports.MARKETING_AGREEMENT_ID = _chunkFBTYZHXMjs.D; exports.bitsnapProjectID = _chunkFBTYZHXMjs.E; exports.default = _chunkFBTYZHXMjs.I; exports.getCheckoutMethods = _chunkFBTYZHXMjs.J; exports.getLocale = _chunkQ25D7OAOjs.m; exports.getProjectID = _chunkFBTYZHXMjs.G; exports.setLocale = _chunkQ25D7OAOjs.l; exports.setProjectID = _chunkFBTYZHXMjs.F; exports.useCartProvider = _chunkFBTYZHXMjs.H;
|
|
2
|
+
//# sourceMappingURL=CartProvider-QY2DMNCC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/CartProvider-QY2DMNCC.js"],"names":[],"mappings":"AAAA,+HAAiF,+BAA4B,+BAA4B,+BAA4B,+BAA4B,sDAA+C,+BAA4B,+BAA4B,+BAA4B,8YAAsL","file":"/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/CartProvider-QY2DMNCC.js"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{D as c,E as d,F as e,G as f,H as g,I as h,J as i}from"./chunk-2PK36NGB.mjs";import"./chunk-HWQNT6XU.mjs";import"./chunk-KOVKUJAW.mjs";import"./chunk-ETGHIHWR.mjs";import"./chunk-DWRBPP32.mjs";import{l as a,m as b}from"./chunk-G2UOTVS5.mjs";import"./chunk-IJLHU2MA.mjs";import"./chunk-ADYVTMGH.mjs";import"./chunk-U6FLIRIV.mjs";export{c as MARKETING_AGREEMENT_ID,d as bitsnapProjectID,h as default,i as getCheckoutMethods,b as getLocale,f as getProjectID,a as setLocale,e as setProjectID,g as useCartProvider};
|
|
2
|
+
//# sourceMappingURL=CartProvider-XMHPQRWC.mjs.map
|
package/dist/analytics.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkWGJTXDISjs = require('./chunk-WGJTXDIS.js');require('./chunk-XIHGWNTS.js');require('./chunk-JSDGZ4NY.js');exports.BitsnapAnalyticsProvider = _chunkWGJTXDISjs.i; exports.DEFAULT_ENDPOINT = _chunkWGJTXDISjs.c; exports.InstrumentProvider = _chunkWGJTXDISjs.l; exports.createTracker = _chunkWGJTXDISjs.d; exports.getTracker = _chunkWGJTXDISjs.f; exports.initTracker = _chunkWGJTXDISjs.e; exports.noopInstrument = _chunkWGJTXDISjs.k; exports.resetTracker = _chunkWGJTXDISjs.g; exports.scoreBucket = _chunkWGJTXDISjs.r; exports.startAutoPageViews = _chunkWGJTXDISjs.b; exports.useAnalytics = _chunkWGJTXDISjs.j; exports.useInstrument = _chunkWGJTXDISjs.n; exports.useInstrumentContext = _chunkWGJTXDISjs.m;
|
|
2
2
|
//# sourceMappingURL=analytics.js.map
|
package/dist/analytics.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/emems
|
|
1
|
+
{"version":3,"sources":["/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/analytics.js"],"names":[],"mappings":"AAAA,+HAAsH,+BAA4B,+BAA4B,klBAAsR","file":"/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/analytics.js"}
|
package/dist/analytics.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as e,c as t,d as r,e as n,f as o,g as a,i as s,j as p,k as c,l as i,m,n as u,r as v}from"./chunk-
|
|
1
|
+
import{b as e,c as t,d as r,e as n,f as o,g as a,i as s,j as p,k as c,l as i,m,n as u,r as v}from"./chunk-IJLHU2MA.mjs";import"./chunk-ADYVTMGH.mjs";import"./chunk-U6FLIRIV.mjs";export{s as BitsnapAnalyticsProvider,t as DEFAULT_ENDPOINT,i as InstrumentProvider,r as createTracker,o as getTracker,n as initTracker,c as noopInstrument,a as resetTracker,v as scoreBucket,e as startAutoPageViews,p as useAnalytics,u as useInstrument,m as useInstrumentContext};
|
|
2
2
|
//# sourceMappingURL=analytics.mjs.map
|
package/dist/catalog.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkYBGAYEJQjs = require('./chunk-YBGAYEJQ.js');require('./chunk-KOYBZORL.js');require('./chunk-Q25D7OAO.js');require('./chunk-WGJTXDIS.js');require('./chunk-XIHGWNTS.js');require('./chunk-JSDGZ4NY.js');exports.PRODUCT_LIST_SLOT_NAMES = _chunkYBGAYEJQjs.a; exports.ProductList = _chunkYBGAYEJQjs.d; exports.formatProductPrice = _chunkYBGAYEJQjs.b; exports.useProducts = _chunkYBGAYEJQjs.c;
|
|
2
2
|
//# sourceMappingURL=catalog.js.map
|
package/dist/catalog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/emems
|
|
1
|
+
{"version":3,"sources":["/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/catalog.js"],"names":[],"mappings":"AAAA,+HAA4D,+BAA4B,+BAA4B,+BAA4B,+BAA4B,+BAA4B,0LAA+F","file":"/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/catalog.js"}
|
package/dist/catalog.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as o,b as r,c as e,d as f}from"./chunk-
|
|
1
|
+
import{a as o,b as r,c as e,d as f}from"./chunk-2X32DDUM.mjs";import"./chunk-KOVKUJAW.mjs";import"./chunk-G2UOTVS5.mjs";import"./chunk-IJLHU2MA.mjs";import"./chunk-ADYVTMGH.mjs";import"./chunk-U6FLIRIV.mjs";export{o as PRODUCT_LIST_SLOT_NAMES,f as ProductList,r as formatProductPrice,e as useProducts};
|
|
2
2
|
//# sourceMappingURL=catalog.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as wn,a as Ne,g as cn,h as dn,i as mn,j as pn,k as fn,s as gn,v as yn,w as Pn,x as bn,y as hn,z as vn}from"./chunk-DDY7IBMG.mjs";import{a as Rt,g as Ge,h as $e,j as ge,k as Ve,l as an,m as on,n as Te}from"./chunk-YXFJG4MF.mjs";import{a as xt,b as kt,c as Ct,d as Nt,e as St,f as en,j as B,k as De,l as Y,p as rn,q as I,r as st,t as sn,u as Le,v as ln}from"./chunk-T2OUOO4X.mjs";import{a as vt,b as Xt,c as wt,d as w,f as Q,g as nn,h as un,m as ce}from"./chunk-43IIYJ6J.mjs";import{h as It,l as ot,m as it,n as Ae,o as tn}from"./chunk-RLEC25JI.mjs";import{useAutoAnimate as Mr}from"@formkit/auto-animate/react";import{useEffect as Sn,useState as ae}from"react";import{jsx as We}from"react/jsx-runtime";function de({className:e,...t}){return We("div",{"data-slot":"card",className:w("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...t})}function ye({className:e,...t}){return We("div",{"data-slot":"card-header",className:w("@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 Pe({className:e,...t}){return We("div",{"data-slot":"card-title",className:w("leading-none font-semibold",e),...t})}function At({className:e,...t}){return We("div",{"data-slot":"card-description",className:w("text-muted-foreground text-sm",e),...t})}function ue({className:e,...t}){return We("div",{"data-slot":"card-content",className:w("px-6",e),...t})}import*as xn from"react";import{OTPInput as Rr,OTPInputContext as Ar}from"input-otp";import{MinusIcon as Dr}from"lucide-react";import{jsx as Ee,jsxs as Tr}from"react/jsx-runtime";function kn({className:e,containerClassName:t,...r}){return Ee(Rr,{"data-slot":"input-otp",containerClassName:w("flex items-center gap-2 has-disabled:opacity-50",t),className:w("disabled:cursor-not-allowed",e),...r})}function Dt({className:e,...t}){return Ee("div",{"data-slot":"input-otp-group",className:w("flex items-center",e),...t})}function Se({index:e,className:t,...r}){let n=xn.useContext(Ar),{char:a,hasFakeCaret:o,isActive:i}=n?.slots[e]??{};return Tr("div",{"data-slot":"input-otp-slot","data-active":i,className:w("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),...r,children:[a,o&&Ee("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:Ee("div",{className:"animate-caret-blink bg-foreground h-4 w-px duration-1000"})})]})}function Cn({...e}){return Ee("div",{"data-slot":"input-otp-separator",role:"separator",...e,children:Ee(Dr,{})})}import{REGEXP_ONLY_DIGITS as jr}from"input-otp";import{jsx as Tt,jsxs as Er}from"react/jsx-runtime";function Lr(){return Er("div",{className:"flex items-center gap-2",children:[Tt("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.3s]"}),Tt("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.15s]"}),Tt("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current"})]})}var V=Lr;var Ur="return_url",Lt="__return_url",zr="accessToken";function Ze(e){let t=new URLSearchParams(e).get(Ur);return t?Nn(t):null}function Je(e){typeof window>"u"||(e?window.sessionStorage.setItem(Lt,e):window.sessionStorage.removeItem(Lt))}function Ue(){if(typeof window>"u")return null;let e=window.sessionStorage.getItem(Lt);return e?Nn(e):null}function Or(e,t){return t.some(r=>{if(e===r)return!0;let n=new URL(r).hostname,a=new URL(e).hostname;return a.endsWith(`.${n}`)||a===n})}function Nn(e){try{let t=new URL(e);return t.protocol!=="https:"&&t.protocol!=="http:"||!Or(t.origin,$e())?null:t.toString()}catch{return null}}function ze(e,t){let r=new URL(e);return r.searchParams.set(zr,t),r.toString()}import{jsx as v,jsxs as E}from"react/jsx-runtime";if(typeof window<"u"){let t=[window.location.origin,"https://bitsnap.pl","https://kursy.bitsnap.pl"];$e().length===0&&Ge(Array.from(new Set(t)))}var _r=({projectID:e,host:t,reveal:r,email:n,setEmail:a,loginUser:o,isLoginLoading:i,errMsg:c})=>{let{projectID:s,host:y}=ge();if(typeof window<"u"&&Ve(e??s,t??y)!=null)return window.location.href=window.location.href.replaceAll("login",""),null;let[d,x]=ae(!1),k=l=>/^(([^<>()\[\]\\.,;:\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(l.trim())?x(!0):x(!1),u=l=>{let{value:P}=l.target;k(P),a(P)};function h(){r()}function C(l){l.preventDefault(),o()}return v("main",{className:"mx-auto flex max-w-sm flex-1 flex-col justify-center space-y-12",children:v("div",{className:w("flex min-w-sm flex-col gap-6"),children:E(de,{children:[E(ye,{children:[v(Pe,{className:"text-2xl",children:"Zaloguj si\u0119"}),v(At,{children:"Wy\u015Blemy do Ciebie kod na maila, dzi\u0119ki kt\xF3remu si\u0119 zalogujesz."})]}),v(ue,{children:E("form",{onSubmit:C,children:[E("div",{className:"flex flex-col gap-6",children:[E("div",{className:"grid gap-2",children:[v(Ne,{htmlFor:"email",children:"Email"}),v(st,{id:"email",onChange:u,type:"email",placeholder:"m@example.com",required:!0}),v("span",{className:w(!d&&n.length>0?"font-bold text-red-500":"text-neutral-700 dark:text-neutral-400","text-xs"),children:!d&&n.length>0?"Nieprawid\u0142owy adres email":"Wpisz sw\xF3j adres email"})]}),E("div",{children:[E(I,{type:"submit",disabled:i,className:"relative w-full",onClick:o,children:[i&&v("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:v(V,{})}),"Zaloguj si\u0119"]}),c.length>0&&v("p",{className:"text-xs font-medium text-red-500",children:c})]})]}),E("div",{className:"mt-4 text-center text-sm",children:["Masz ju\u017C kod?"," ",v("button",{type:"button",onClick:h,className:"underline underline-offset-4",children:"Mam ju\u017C kod"})]})]})})]})})})},Fr=({projectID:e,host:t,email:r,reveal:n,setEmail:a,isLoginLoading:o,loginUserResponse:i,setLoginUserResponse:c,setResponseStatus:s,errMsg:y})=>{let d=it(),{mutateAsync:x,isPending:k}=Y(B.publicApi.userPanelLoginWithCode),[u,h]=ae(""),[C,l]=ae(!1),[P,R]=ae(!1),[F,q]=ae(0),A=U=>/^\d+$/.test(U.trim())?l(!0):l(!1),L=U=>{A(U),h(U)};async function _(){if(R(!0),u.length==0){l(!1);return}let U=parseInt(u),K=await x({code:U}),fe,ke,ne;if(K.result.case==="accessToken"?(l(!0),fe="ok",ke=void 0,ne=K.result.value):(l(!1),fe="error",ke=K.result.value,ne=void 0),fe==="error"&&(l(!1),console.warn("error:",`Kod b\u0142\u0119du: ${ke}`),console.warn("Nieprawid\u0142owy kod, spr\xF3buj ponownie.")),fe==="ok"){d.track("panel_login",{}),ne&&an(e,ne,r,t);let g=typeof window<"u"?Ue():null;setTimeout(()=>{if(ne&&g){window.location.href=ze(g,ne);return}window.location.reload()},100)}}function D(){let U=setInterval(()=>{q(K=>K>0?K-1:(clearInterval(U),0))},1e3);return()=>{clearInterval(U)}}Sn(()=>{i?.status==="ok"&&i?.retryIn>0&&(q(i.retryIn),D())},[i]);function H(){a(""),c(null),s("default"),n()}function pe(U){U.preventDefault(),_()}return v("main",{className:"mx-auto flex max-w-md flex-1 flex-col justify-center space-y-8",children:v("div",{className:w("flex min-w-sm flex-col gap-6"),children:E(de,{children:[E(ye,{children:[v(Pe,{className:"text-2xl",children:"Wpisz kod z maila"}),v(At,{children:"Sprawd\u017A czy przypadkiem nie wyl\u0105dowa\u0142 w spamie."})]}),E(ue,{children:[E("form",{onSubmit:pe,className:"flex flex-col gap-6",children:[v("div",{className:"grid gap-2",children:v("div",{className:"my-5 flex w-full items-center justify-center",children:E("div",{className:"flex flex-col gap-2",children:[E(kn,{id:"verify-code",maxLength:6,pattern:jr,onChange:U=>{L(U)},children:[E(Dt,{children:[v(Se,{index:0}),v(Se,{index:1}),v(Se,{index:2})]}),v(Cn,{}),E(Dt,{children:[v(Se,{index:3}),v(Se,{index:4}),v(Se,{index:5})]})]}),v("span",{className:w(!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"})]})})}),E("div",{children:[E(I,{type:"submit",disabled:o||k,className:"relative w-full",children:[(o||k)&&v("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:v(V,{})}),"Zaloguj si\u0119"]}),y.length>0&&v("p",{className:"text-xs font-medium text-red-500",children:y})]})]}),E("div",{className:"mt-4 text-center text-sm",children:["Nie masz kodu?"," ",v("button",{type:"button",onClick:H,className:"underline underline-offset-4",children:"Wr\xF3\u0107"})]})]})]})})})},qr=({analytics:e})=>{let{theme:t,allowedReturnOrigins:r,projectID:n,host:a}=ge(),o=Ae(n,e,"panel"),i={"--button-background-color":t?.colors?.brand??"#FFFFFF","--button-background-color-dark":t?.colors?.brandDark??"#000000","--button-text-color":t?.colors?.brandDark??"#000000","--button-text-color-dark":t?.colors?.brand??"#FFFFFF"},[c,s]=ae("login"),[y]=Mr({duration:300,easing:"ease-in-out",disrespectUserMotionPreference:!1}),d=()=>s(L=>L==="login"?"verifyCode":"login"),[x,k]=ae(""),[u,h]=ae("default"),[C,l]=ae(null),{mutateAsync:P,isPending:R}=Y(B.publicApi.userPanelLogin),[F,q]=ae("");Sn(()=>{if(typeof window>"u"||window.parent!==window)return;let L=Ze(window.location.search);L&&Je(L);let _=L??Ue();if(!_)return;let D=Ve(n,a);D&&(window.location.href=ze(_,D))},[r,n,a]);async function A(){q(""),h("default");let L=await P({email:x}),_=L.result.case==="success"?"ok":"error",D=0,H;L.result.case==="success"&&(D=L.result.value.retryIn),_==="error"&&(H="Nieprawid\u0142owy adres email, spr\xF3buj ponownie."),l({status:_,retryIn:D,message:H}),_==="ok"&&c==="login"?d():_==="ok"&&c==="verifyCode"?h("success"):_==="error"&&q(H??"Nieprawid\u0142owy adres email, spr\xF3buj ponownie.")}return v(ot,{value:o,children:v("div",{className:"bg-white text-black dark:bg-black dark:text-white",children:E("div",{className:"font-inter flex h-screen w-screen flex-col p-4",style:i,ref:y,children:[E("header",{children:[t?.logoDarkURL&&v("img",{src:t?.logoDarkURL,className:"hidden dark:inline",alt:"Company Logo",draggable:!1}),t?.logoURL&&v("img",{src:t?.logoURL,className:"dark:hidden",alt:"Company Logo",draggable:!1})]}),c==="login"&&v(_r,{projectID:n,host:a,reveal:d,email:x,setEmail:k,loginUser:A,isLoginLoading:R,errMsg:F}),c==="verifyCode"&&v(Fr,{projectID:n,host:a,email:x,reveal:d,setEmail:k,loginUser:A,isLoginLoading:R,loginUserResponse:C,setLoginUserResponse:l,responseStatus:u,setResponseStatus:h,errMsg:F})]})})})},Br=({analytics:e}={})=>v(qr,{analytics:e});import{useAutoAnimate as Xa}from"@formkit/auto-animate/react";import{useEffect as yt,useState as eo}from"react";import{useState as Hr,useCallback as Gr,useEffect as $r}from"react";function In(e){let[t,r]=Hr(()=>{if(typeof window>"u")return e;let a=new URLSearchParams(window.location.search),o={};return Object.keys(e).forEach(i=>{let c=a.get(i);if(c!==null)try{o[i]=JSON.parse(c)}catch{o[i]=c}}),{...e,...o}}),n=Gr(a=>{r(o=>{let i={...o,...a};if(typeof window<"u"){let c=new URLSearchParams;Object.keys(i).forEach(y=>{let d=i[y];d!=null&&c.set(y,JSON.stringify(d))});let s=`${window.location.pathname}?${c.toString()}`;window.history.pushState({},"",s)}return i})},[]);return $r(()=>{let a=()=>{let o=new URLSearchParams(window.location.search),i={};Object.keys(e).forEach(c=>{let s=o.get(c);if(s!==null)try{i[c]=JSON.parse(s)}catch{i[c]=s}}),r({...e,...i})};return window.addEventListener("popstate",a),()=>window.removeEventListener("popstate",a)},[e]),[t,n]}function Rn(e,t){if(e!=null)return e;let r=t?.trim();if(!(r==null||r===""))return{tokens:sn(r)}}import*as lt from"@radix-ui/react-switch";import{jsx as An}from"react/jsx-runtime";function Dn({className:e,...t}){return An(lt.Root,{"data-slot":"switch",className:w("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:An(lt.Thumb,{"data-slot":"switch-thumb",className:w("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")})})}import{useState as Vr}from"react";import{Fragment as Zr,jsx as Ke,jsxs as Et}from"react/jsx-runtime";function Wr({}){let[e,t]=Vr({disableAll:!1});return Et(Zr,{children:[Ke("h3",{className:"text-2xl",children:"Powiadomienia"}),Ke("p",{className:"text-sm text-neutral-500",children:"Zarz\u0105dzaj swoimi powiadomieniami"}),Ke("div",{className:"mt-6",children:Et("div",{className:"flex items-center space-x-2",children:[Ke(Dn,{id:"disable-all-notifications",checked:e.disableAll,onCheckedChange:r=>t(n=>({...n,disableAll:r}))}),Et(Ne,{htmlFor:"disable-all-notifications",className:"flex flex-col gap-1 text-base",children:["Wszystkie powiadomienia",Ke("span",{className:"text-xs font-normal text-neutral-500 md:text-sm",children:"Ten przycisk mo\u017Ce wy\u0142\u0105czy\u0107 wszystkie powiadomienia"})]})]})})]})}var Tn=Wr;import{ChevronLeftIcon as Jr,ChevronRightIcon as Kr,MoreHorizontalIcon as Qr}from"lucide-react";import{jsx as oe,jsxs as zt}from"react/jsx-runtime";function Ln({className:e,...t}){return oe("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:w("mx-auto flex w-full justify-center",e),...t})}function En({className:e,...t}){return oe("ul",{"data-slot":"pagination-content",className:w("flex flex-row items-center gap-1",e),...t})}function be({...e}){return oe("li",{"data-slot":"pagination-item",...e})}function Oe({className:e,isActive:t,size:r="icon",...n}){return oe("a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:w(rn({variant:t?"outline":"ghost",size:r}),e),...n})}function Un({className:e,...t}){return zt(Oe,{"aria-label":"Go to previous page",size:"default",className:w("gap-1 px-2.5 sm:pl-2.5",e),...t,children:[oe(Jr,{}),oe("span",{className:"hidden sm:block",children:"Previous"})]})}function zn({className:e,...t}){return zt(Oe,{"aria-label":"Go to next page",size:"default",className:w("gap-1 px-2.5 sm:pr-2.5",e),...t,children:[oe("span",{className:"hidden sm:block",children:"Next"}),oe(Kr,{})]})}function Ut({className:e,...t}){return zt("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:w("flex size-9 items-center justify-center",e),...t,children:[oe(Qr,{className:"size-4"}),oe("span",{className:"sr-only",children:"More pages"})]})}import{useState as Yr}from"react";import{Fragment as aa,jsx as N,jsxs as W}from"react/jsx-runtime";var Xr=e=>new Date(e*1e3).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),ea=(e,t)=>new Intl.NumberFormat("en-US",{style:"currency",currency:t.toUpperCase()}).format(e/100),ta={draft:"Szkic",unpaid:"Nieop\u0142acona",paid:"Op\u0142acona",overdue:"Zaleg\u0142a",cancelled:"Anulowana",completed:"Zako\u0144czone",processing:"Przetwarzane",refunded:"Zwr\xF3cone"},na={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 ra({openOrderDetails:e,projectID:t,accessToken:r}){let[n,a]=Yr(0),o=20,{data:i,isFetching:c}=De(B.publicApi.getOrders,{projectId:t,accessToken:r,offset:n,limit:o}),s=i?.orders??[],y=i?.totalCount??0,d=Math.floor(n/o)+1,x=Math.ceil(y/o),k=u=>{a(u)};return W(aa,{children:[N("h3",{className:"text-2xl",children:"Historia zam\xF3wie\u0144"}),N("p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:"Twoje zam\xF3wienia"}),c?N("div",{className:"mt-6 flex w-full flex-col gap-3",children:[...Array(5)].map((u,h)=>W("div",{className:"rounded-xl bg-white p-4 shadow-sm dark:bg-neutral-800",children:[W("div",{className:"flex items-center justify-between",children:[W("div",{className:"space-y-2",children:[N(Le,{className:"h-4 w-24"}),N(Le,{className:"h-3 w-32"})]}),W("div",{className:"space-y-2 text-right",children:[N(Le,{className:"ml-auto h-4 w-16"}),N(Le,{className:"ml-auto h-3 w-12"})]})]}),N("div",{className:"mt-3",children:N(Le,{className:"h-3 w-40"})})]},h))}):s.length===0?N("div",{className:"mt-6 text-sm text-neutral-400",children:"Brak zam\xF3wie\u0144."}):W("div",{children:[N("div",{className:"mt-6 flex w-full flex-col gap-3",children:s.map(u=>W("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:[W("div",{className:"flex items-center justify-between",children:[W("div",{children:[W("p",{className:"font-medium",children:["Zam\xF3wienie #",u.id]}),N("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:u.customerName||"Klient"})]}),W("div",{className:"text-right",children:[N("p",{className:"font-semibold",children:ea(u.totalAmount,u.currency)}),N("p",{className:`text-xs font-medium ${na[u.status]??"text-neutral-400"}`,children:ta[u.status]??u.status})]})]}),N("div",{className:"mt-2 flex items-center justify-between text-xs text-neutral-500 dark:text-neutral-400",children:W("span",{children:["Data:"," ",u.createdAt?Xr(Number(u.createdAt.seconds)):"-"]})})]},u.id))}),x>1&&!c&&N("div",{className:"mt-4 flex justify-center",children:N(Ln,{children:W(En,{children:[d>1&&N(be,{children:N(Un,{onClick:()=>k(n-o)})}),d>2&&N(be,{children:N(Oe,{onClick:()=>k(0),children:"1"})}),d>3&&N(be,{children:N(Ut,{})}),[d-1,d,d+1].filter(u=>u>0&&u<=x).map(u=>N(be,{children:N(Oe,{onClick:()=>k((u-1)*o),isActive:d===u,children:u})},u)),d<x-2&&N(be,{children:N(Ut,{})}),d<x&&N(be,{children:N(Oe,{onClick:()=>k((x-1)*o),children:x})}),d<x&&N(be,{children:N(zn,{onClick:()=>k(n+o)})})]})})})]})]})}var On=ra;import{useState as Mn}from"react";import{Fragment as la,jsx as X,jsxs as he}from"react/jsx-runtime";var jn=e=>new Date(e*1e3).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),oa={active:"Aktywny",cancelled:"Anulowany",paused:"Wstrzymany"},ia={active:"text-green-600",cancelled:"text-red-500",paused:"text-yellow-500"};function sa({projectID:e}){let[t,r]=Mn([]),[n,a]=Mn(!0);return he(la,{children:[X("h3",{className:"text-2xl",children:"Plany"}),X("p",{className:"text-sm text-neutral-500",children:"Twoje aktywne subskrypcje"}),n?X("div",{className:"mt-6 text-sm text-neutral-400",children:"\u0141adowanie..."}):t.length===0?X("div",{className:"mt-6 text-sm text-neutral-400",children:"Brak aktywnych plan\xF3w."}):X("div",{className:"mt-6 flex flex-col gap-4",children:t.map(o=>he("div",{className:"rounded-xl bg-white p-5 shadow-sm dark:bg-neutral-800",children:[he("div",{className:"flex items-start justify-between",children:[he("div",{children:[X("p",{className:"font-semibold",children:o.tierName}),o.configName&&X("p",{className:"text-sm text-neutral-500",children:o.configName})]}),X("span",{className:`text-sm font-medium ${ia[o.status]??"text-neutral-500"}`,children:oa[o.status]??o.status})]}),he("div",{className:"mt-3 grid grid-cols-2 gap-2 text-sm text-neutral-600 dark:text-neutral-400",children:[he("div",{children:[X("span",{className:"font-medium",children:"Dzie\u0144 rozliczenia:"})," ",o.billingDay]}),he("div",{children:[X("span",{className:"font-medium",children:"Data startu:"})," ",jn(o.startDate)]}),o.endDate&&he("div",{children:[X("span",{className:"font-medium",children:"Data zako\u0144czenia:"})," ",jn(o.endDate)]})]})]},o.id))})]})}var _n=sa;import{useEffect as ca,useState as Ot}from"react";import{jsx as ee,jsxs as ma}from"react/jsx-runtime";function da(e,t,r,n){typeof window>"u"||(t&&Te(r,n),window.location.href=e)}function ua({projectID:e,host:t,loginURL:r,screen:n,params:a,setParams:o,setActiveScreen:i}){let{status:c,exchangeError:s}=pn("PanelReturns"),y=mn(),d=c==="anonymous"&&(s==null||cn(s));ca(()=>{d&&da(r,s!=null,e,t)},[d,r,s,e,t]);let[x,k]=Ot("orders"),[u,h]=Ot({items:[],note:""}),[C,l]=Ot();if(c==="anonymous"&&!d)return ma("div",{role:"alert",className:"flex flex-col items-start gap-3",children:[ee("p",{className:"text-sm",children:y(dn(s))}),ee(I,{type:"button",onClick:()=>window.location.reload(),children:y("errorRetry")})]});if(c!=="authenticated")return ee(gn,{});let P=R=>{k(R),o({state:"returns",orderId:void 0,returnId:void 0}),i("returns")};if(n==="return-details"&&a.returnId)return ee(wn,{returnId:a.returnId,onBack:()=>P("myReturns")});if(x==="myReturns")return ee(vn,{onBack:()=>P("orders"),onSelectReturn:R=>{o({state:"return-details",returnId:R,orderId:void 0}),i("return-details")}});if(x==="result"&&C!=null)return ee(hn,{returnId:C,onContinue:()=>P("orders"),onOpenMyReturns:()=>P("myReturns")});if(a.orderId){let R=a.orderId;return x==="confirmation"?ee(bn,{orderId:R,items:u.items,note:u.note,onBack:()=>k("orders"),onSubmitted:F=>{l(F),h({items:[],note:""}),k("result"),o({orderId:void 0})}}):ee(Pn,{orderId:R,initialItems:u.items.length>0?u.items:void 0,initialNote:u.note,onBack:()=>{h({items:[],note:""}),o({orderId:void 0})},onContinue:F=>{h(F),k("confirmation")}})}return ee(yn,{showLogout:!1,onSelectOrder:R=>{h({items:[],note:""}),k("orders"),o({orderId:R})},onOpenMyReturns:()=>P("myReturns")})}function Mt({accessToken:e,appearance:t,texts:r,...n}){return ee(fn,{projectID:n.projectID,host:n.host,appearance:t,texts:r,panelAccessToken:e,children:ee(ua,{...n})})}import{useState as Ia}from"react";import{jsx as ya}from"react/jsx-runtime";var pa=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g,fa=e=>[...e.matchAll(pa)].map(r=>({url:r[0],startIndex:r.index,endIndex:r.index+r[0].length-1})),ga=(e,t)=>{let r="",n=0;t.sort((a,o)=>a.startIndex-o.startIndex);for(let{startIndex:a,endIndex:o,replacementText:i}of t)r+=e.slice(n,a),r+=i,n=o+1;return r+=e.slice(n),r},Fn=e=>{let t=fa(e);return ya("p",{dangerouslySetInnerHTML:{__html:ga(e,t.map(r=>(r.replacementText=`<a key=${r.url} href=${r.url} style="text-decoration: underline;" target="_blank">
|
|
1
|
+
import{A as Nn,a as Ne,g as pn,h as fn,i as yn,j as bn,k as Pn,s as hn,v as vn,w as wn,x as kn,y as xn,z as Cn}from"./chunk-HWQNT6XU.mjs";import{a as Dt,g as Ge,h as $e,j as ge,k as Ve,l as cn,m as dn,n as Te}from"./chunk-ETGHIHWR.mjs";import{a as Ct,b as Nt,c as St,d as It,e as Rt,f as an,j as B,k as De,l as Y,p as ln,q as I,r as lt,t as un,u as Le,v as mn}from"./chunk-DWRBPP32.mjs";import{a as kt,b as rn,c as xt,d as w,f as Q,g as sn,h as gn,m as ce}from"./chunk-G2UOTVS5.mjs";import{h as At,l as it,m as st,n as Ae,o as on}from"./chunk-IJLHU2MA.mjs";import{useAutoAnimate as Hr}from"@formkit/auto-animate/react";import{useEffect as Dn,useState as ae}from"react";import{jsx as We}from"react/jsx-runtime";function de({className:e,...t}){return We("div",{"data-slot":"card",className:w("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...t})}function ye({className:e,...t}){return We("div",{"data-slot":"card-header",className:w("@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 be({className:e,...t}){return We("div",{"data-slot":"card-title",className:w("leading-none font-semibold",e),...t})}function Tt({className:e,...t}){return We("div",{"data-slot":"card-description",className:w("text-muted-foreground text-sm",e),...t})}function ue({className:e,...t}){return We("div",{"data-slot":"card-content",className:w("px-6",e),...t})}import*as Sn from"react";import{OTPInput as Ur,OTPInputContext as Or}from"input-otp";import{MinusIcon as zr}from"lucide-react";import{jsx as Ee,jsxs as Mr}from"react/jsx-runtime";function In({className:e,containerClassName:t,...r}){return Ee(Ur,{"data-slot":"input-otp",containerClassName:w("flex items-center gap-2 has-disabled:opacity-50",t),className:w("disabled:cursor-not-allowed",e),...r})}function Lt({className:e,...t}){return Ee("div",{"data-slot":"input-otp-group",className:w("flex items-center",e),...t})}function Se({index:e,className:t,...r}){let n=Sn.useContext(Or),{char:a,hasFakeCaret:o,isActive:i}=n?.slots[e]??{};return Mr("div",{"data-slot":"input-otp-slot","data-active":i,className:w("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),...r,children:[a,o&&Ee("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:Ee("div",{className:"animate-caret-blink bg-foreground h-4 w-px duration-1000"})})]})}function Rn({...e}){return Ee("div",{"data-slot":"input-otp-separator",role:"separator",...e,children:Ee(zr,{})})}import{REGEXP_ONLY_DIGITS as Gr}from"input-otp";import{jsx as Et,jsxs as jr}from"react/jsx-runtime";function _r(){return jr("div",{className:"flex items-center gap-2",children:[Et("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.3s]"}),Et("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.15s]"}),Et("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current"})]})}var V=_r;var Fr="return_url",Ut="__return_url",qr="accessToken";function Ze(e){let t=new URLSearchParams(e).get(Fr);return t?An(t):null}function Je(e){typeof window>"u"||(e?window.sessionStorage.setItem(Ut,e):window.sessionStorage.removeItem(Ut))}function Ue(){if(typeof window>"u")return null;let e=window.sessionStorage.getItem(Ut);return e?An(e):null}function Br(e,t){return t.some(r=>{if(e===r)return!0;let n=new URL(r).hostname,a=new URL(e).hostname;return a.endsWith(`.${n}`)||a===n})}function An(e){try{let t=new URL(e);return t.protocol!=="https:"&&t.protocol!=="http:"||!Br(t.origin,$e())?null:t.toString()}catch{return null}}function Oe(e,t){let r=new URL(e);return r.searchParams.set(qr,t),r.toString()}import{jsx as v,jsxs as E}from"react/jsx-runtime";if(typeof window<"u"){let t=[window.location.origin,"https://bitsnap.pl","https://kursy.bitsnap.pl"];$e().length===0&&Ge(Array.from(new Set(t)))}var $r=({projectID:e,host:t,reveal:r,email:n,setEmail:a,loginUser:o,isLoginLoading:i,errMsg:c})=>{let{projectID:s,host:y}=ge();if(typeof window<"u"&&Ve(e??s,t??y)!=null)return window.location.href=window.location.href.replaceAll("login",""),null;let[d,k]=ae(!1),x=l=>/^(([^<>()\[\]\\.,;:\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(l.trim())?k(!0):k(!1),u=l=>{let{value:b}=l.target;x(b),a(b)};function h(){r()}function C(l){l.preventDefault(),o()}return v("main",{className:"mx-auto flex max-w-sm flex-1 flex-col justify-center space-y-12",children:v("div",{className:w("flex min-w-sm flex-col gap-6"),children:E(de,{children:[E(ye,{children:[v(be,{className:"text-2xl",children:"Zaloguj si\u0119"}),v(Tt,{children:"Wy\u015Blemy do Ciebie kod na maila, dzi\u0119ki kt\xF3remu si\u0119 zalogujesz."})]}),v(ue,{children:E("form",{onSubmit:C,children:[E("div",{className:"flex flex-col gap-6",children:[E("div",{className:"grid gap-2",children:[v(Ne,{htmlFor:"email",children:"Email"}),v(lt,{id:"email",onChange:u,type:"email",placeholder:"m@example.com",required:!0}),v("span",{className:w(!d&&n.length>0?"font-bold text-red-500":"text-neutral-700 dark:text-neutral-400","text-xs"),children:!d&&n.length>0?"Nieprawid\u0142owy adres email":"Wpisz sw\xF3j adres email"})]}),E("div",{children:[E(I,{type:"submit",disabled:i,className:"relative w-full",onClick:o,children:[i&&v("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:v(V,{})}),"Zaloguj si\u0119"]}),c.length>0&&v("p",{className:"text-xs font-medium text-red-500",children:c})]})]}),E("div",{className:"mt-4 text-center text-sm",children:["Masz ju\u017C kod?"," ",v("button",{type:"button",onClick:h,className:"underline underline-offset-4",children:"Mam ju\u017C kod"})]})]})})]})})})},Vr=({projectID:e,host:t,email:r,reveal:n,setEmail:a,isLoginLoading:o,loginUserResponse:i,setLoginUserResponse:c,setResponseStatus:s,errMsg:y})=>{let d=st(),{mutateAsync:k,isPending:x}=Y(B.publicApi.userPanelLoginWithCode),[u,h]=ae(""),[C,l]=ae(!1),[b,R]=ae(!1),[F,q]=ae(0),A=U=>/^\d+$/.test(U.trim())?l(!0):l(!1),L=U=>{A(U),h(U)};async function j(){if(R(!0),u.length==0){l(!1);return}let U=parseInt(u),K=await k({code:U}),fe,xe,ne;if(K.result.case==="accessToken"?(l(!0),fe="ok",xe=void 0,ne=K.result.value):(l(!1),fe="error",xe=K.result.value,ne=void 0),fe==="error"&&(l(!1),console.warn("error:",`Kod b\u0142\u0119du: ${xe}`),console.warn("Nieprawid\u0142owy kod, spr\xF3buj ponownie.")),fe==="ok"){d.track("panel_login",{}),ne&&cn(e,ne,r,t);let g=typeof window<"u"?Ue():null;setTimeout(()=>{if(ne&&g){window.location.href=Oe(g,ne);return}window.location.reload()},100)}}function D(){let U=setInterval(()=>{q(K=>K>0?K-1:(clearInterval(U),0))},1e3);return()=>{clearInterval(U)}}Dn(()=>{i?.status==="ok"&&i?.retryIn>0&&(q(i.retryIn),D())},[i]);function H(){a(""),c(null),s("default"),n()}function pe(U){U.preventDefault(),j()}return v("main",{className:"mx-auto flex max-w-md flex-1 flex-col justify-center space-y-8",children:v("div",{className:w("flex min-w-sm flex-col gap-6"),children:E(de,{children:[E(ye,{children:[v(be,{className:"text-2xl",children:"Wpisz kod z maila"}),v(Tt,{children:"Sprawd\u017A czy przypadkiem nie wyl\u0105dowa\u0142 w spamie."})]}),E(ue,{children:[E("form",{onSubmit:pe,className:"flex flex-col gap-6",children:[v("div",{className:"grid gap-2",children:v("div",{className:"my-5 flex w-full items-center justify-center",children:E("div",{className:"flex flex-col gap-2",children:[E(In,{id:"verify-code",maxLength:6,pattern:Gr,onChange:U=>{L(U)},children:[E(Lt,{children:[v(Se,{index:0}),v(Se,{index:1}),v(Se,{index:2})]}),v(Rn,{}),E(Lt,{children:[v(Se,{index:3}),v(Se,{index:4}),v(Se,{index:5})]})]}),v("span",{className:w(!C&&b?"text-red-500":"text-neutral-700 dark:text-neutral-400","text-xs"),children:!C&&b?u.length==0?"Kod nie mo\u017Ce by\u0107 pusty":"Kod musi sk\u0142ada\u0107 si\u0119 z cyfr":"Wpisz kod z maila"})]})})}),E("div",{children:[E(I,{type:"submit",disabled:o||x,className:"relative w-full",children:[(o||x)&&v("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:v(V,{})}),"Zaloguj si\u0119"]}),y.length>0&&v("p",{className:"text-xs font-medium text-red-500",children:y})]})]}),E("div",{className:"mt-4 text-center text-sm",children:["Nie masz kodu?"," ",v("button",{type:"button",onClick:H,className:"underline underline-offset-4",children:"Wr\xF3\u0107"})]})]})]})})})},Wr=({analytics:e})=>{let{theme:t,allowedReturnOrigins:r,projectID:n,host:a}=ge(),o=Ae(n,e,"panel"),i={"--button-background-color":t?.colors?.brand??"#FFFFFF","--button-background-color-dark":t?.colors?.brandDark??"#000000","--button-text-color":t?.colors?.brandDark??"#000000","--button-text-color-dark":t?.colors?.brand??"#FFFFFF"},[c,s]=ae("login"),[y]=Hr({duration:300,easing:"ease-in-out",disrespectUserMotionPreference:!1}),d=()=>s(L=>L==="login"?"verifyCode":"login"),[k,x]=ae(""),[u,h]=ae("default"),[C,l]=ae(null),{mutateAsync:b,isPending:R}=Y(B.publicApi.userPanelLogin),[F,q]=ae("");Dn(()=>{if(typeof window>"u"||window.parent!==window)return;let L=Ze(window.location.search);L&&Je(L);let j=L??Ue();if(!j)return;let D=Ve(n,a);D&&(window.location.href=Oe(j,D))},[r,n,a]);async function A(){q(""),h("default");let L=await b({email:k}),j=L.result.case==="success"?"ok":"error",D=0,H;L.result.case==="success"&&(D=L.result.value.retryIn),j==="error"&&(H="Nieprawid\u0142owy adres email, spr\xF3buj ponownie."),l({status:j,retryIn:D,message:H}),j==="ok"&&c==="login"?d():j==="ok"&&c==="verifyCode"?h("success"):j==="error"&&q(H??"Nieprawid\u0142owy adres email, spr\xF3buj ponownie.")}return v(it,{value:o,children:v("div",{className:"bg-white text-black dark:bg-black dark:text-white",children:E("div",{className:"font-inter flex h-screen w-screen flex-col p-4",style:i,ref:y,children:[E("header",{children:[t?.logoDarkURL&&v("img",{src:t?.logoDarkURL,className:"hidden dark:inline",alt:"Company Logo",draggable:!1}),t?.logoURL&&v("img",{src:t?.logoURL,className:"dark:hidden",alt:"Company Logo",draggable:!1})]}),c==="login"&&v($r,{projectID:n,host:a,reveal:d,email:k,setEmail:x,loginUser:A,isLoginLoading:R,errMsg:F}),c==="verifyCode"&&v(Vr,{projectID:n,host:a,email:k,reveal:d,setEmail:x,loginUser:A,isLoginLoading:R,loginUserResponse:C,setLoginUserResponse:l,responseStatus:u,setResponseStatus:h,errMsg:F})]})})})},Zr=({analytics:e}={})=>v(Wr,{analytics:e});import{useAutoAnimate as oo}from"@formkit/auto-animate/react";import{useEffect as bt,useState as io}from"react";import{useState as Jr,useCallback as Kr,useEffect as Qr}from"react";function Tn(e){let[t,r]=Jr(()=>{if(typeof window>"u")return e;let a=new URLSearchParams(window.location.search),o={};return Object.keys(e).forEach(i=>{let c=a.get(i);if(c!==null)try{o[i]=JSON.parse(c)}catch{o[i]=c}}),{...e,...o}}),n=Kr(a=>{r(o=>{let i={...o,...a};if(typeof window<"u"){let c=new URLSearchParams;Object.keys(i).forEach(y=>{let d=i[y];d!=null&&c.set(y,JSON.stringify(d))});let s=`${window.location.pathname}?${c.toString()}`;window.history.pushState({},"",s)}return i})},[]);return Qr(()=>{let a=()=>{let o=new URLSearchParams(window.location.search),i={};Object.keys(e).forEach(c=>{let s=o.get(c);if(s!==null)try{i[c]=JSON.parse(s)}catch{i[c]=s}}),r({...e,...i})};return window.addEventListener("popstate",a),()=>window.removeEventListener("popstate",a)},[e]),[t,n]}function Ln(e,t){if(e!=null)return e;let r=t?.trim();if(!(r==null||r===""))return{tokens:un(r)}}import*as ct from"@radix-ui/react-switch";import{jsx as En}from"react/jsx-runtime";function Un({className:e,...t}){return En(ct.Root,{"data-slot":"switch",className:w("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:En(ct.Thumb,{"data-slot":"switch-thumb",className:w("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")})})}import{useState as Yr}from"react";import{Fragment as ea,jsx as Ke,jsxs as Ot}from"react/jsx-runtime";function Xr({}){let[e,t]=Yr({disableAll:!1});return Ot(ea,{children:[Ke("h3",{className:"text-2xl",children:"Powiadomienia"}),Ke("p",{className:"text-sm text-neutral-500",children:"Zarz\u0105dzaj swoimi powiadomieniami"}),Ke("div",{className:"mt-6",children:Ot("div",{className:"flex items-center space-x-2",children:[Ke(Un,{id:"disable-all-notifications",checked:e.disableAll,onCheckedChange:r=>t(n=>({...n,disableAll:r}))}),Ot(Ne,{htmlFor:"disable-all-notifications",className:"flex flex-col gap-1 text-base",children:["Wszystkie powiadomienia",Ke("span",{className:"text-xs font-normal text-neutral-500 md:text-sm",children:"Ten przycisk mo\u017Ce wy\u0142\u0105czy\u0107 wszystkie powiadomienia"})]})]})})]})}var On=Xr;import{ChevronLeftIcon as ta,ChevronRightIcon as na,MoreHorizontalIcon as ra}from"lucide-react";import{jsx as oe,jsxs as Mt}from"react/jsx-runtime";function zn({className:e,...t}){return oe("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:w("mx-auto flex w-full justify-center",e),...t})}function Mn({className:e,...t}){return oe("ul",{"data-slot":"pagination-content",className:w("flex flex-row items-center gap-1",e),...t})}function Pe({...e}){return oe("li",{"data-slot":"pagination-item",...e})}function ze({className:e,isActive:t,size:r="icon",...n}){return oe("a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:w(ln({variant:t?"outline":"ghost",size:r}),e),...n})}function _n({className:e,...t}){return Mt(ze,{"aria-label":"Go to previous page",size:"default",className:w("gap-1 px-2.5 sm:pl-2.5",e),...t,children:[oe(ta,{}),oe("span",{className:"hidden sm:block",children:"Previous"})]})}function jn({className:e,...t}){return Mt(ze,{"aria-label":"Go to next page",size:"default",className:w("gap-1 px-2.5 sm:pr-2.5",e),...t,children:[oe("span",{className:"hidden sm:block",children:"Next"}),oe(na,{})]})}function zt({className:e,...t}){return Mt("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:w("flex size-9 items-center justify-center",e),...t,children:[oe(ra,{className:"size-4"}),oe("span",{className:"sr-only",children:"More pages"})]})}import{useState as aa}from"react";import{Fragment as da,jsx as N,jsxs as W}from"react/jsx-runtime";var oa=e=>new Date(e*1e3).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),ia=(e,t)=>new Intl.NumberFormat("en-US",{style:"currency",currency:t.toUpperCase()}).format(e/100),sa={draft:"Szkic",unpaid:"Nieop\u0142acona",paid:"Op\u0142acona",overdue:"Zaleg\u0142a",cancelled:"Anulowana",completed:"Zako\u0144czone",processing:"Przetwarzane",refunded:"Zwr\xF3cone"},la={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 ca({openOrderDetails:e,projectID:t,accessToken:r}){let[n,a]=aa(0),o=20,{data:i,isFetching:c}=De(B.publicApi.getOrders,{projectId:t,accessToken:r,offset:n,limit:o}),s=i?.orders??[],y=i?.totalCount??0,d=Math.floor(n/o)+1,k=Math.ceil(y/o),x=u=>{a(u)};return W(da,{children:[N("h3",{className:"text-2xl",children:"Historia zam\xF3wie\u0144"}),N("p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:"Twoje zam\xF3wienia"}),c?N("div",{className:"mt-6 flex w-full flex-col gap-3",children:[...Array(5)].map((u,h)=>W("div",{className:"rounded-xl bg-white p-4 shadow-sm dark:bg-neutral-800",children:[W("div",{className:"flex items-center justify-between",children:[W("div",{className:"space-y-2",children:[N(Le,{className:"h-4 w-24"}),N(Le,{className:"h-3 w-32"})]}),W("div",{className:"space-y-2 text-right",children:[N(Le,{className:"ml-auto h-4 w-16"}),N(Le,{className:"ml-auto h-3 w-12"})]})]}),N("div",{className:"mt-3",children:N(Le,{className:"h-3 w-40"})})]},h))}):s.length===0?N("div",{className:"mt-6 text-sm text-neutral-400",children:"Brak zam\xF3wie\u0144."}):W("div",{children:[N("div",{className:"mt-6 flex w-full flex-col gap-3",children:s.map(u=>W("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:[W("div",{className:"flex items-center justify-between",children:[W("div",{children:[W("p",{className:"font-medium",children:["Zam\xF3wienie #",u.id]}),N("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:u.customerName||"Klient"})]}),W("div",{className:"text-right",children:[N("p",{className:"font-semibold",children:ia(u.totalAmount,u.currency)}),N("p",{className:`text-xs font-medium ${la[u.status]??"text-neutral-400"}`,children:sa[u.status]??u.status})]})]}),N("div",{className:"mt-2 flex items-center justify-between text-xs text-neutral-500 dark:text-neutral-400",children:W("span",{children:["Data:"," ",u.createdAt?oa(Number(u.createdAt.seconds)):"-"]})})]},u.id))}),k>1&&!c&&N("div",{className:"mt-4 flex justify-center",children:N(zn,{children:W(Mn,{children:[d>1&&N(Pe,{children:N(_n,{onClick:()=>x(n-o)})}),d>2&&N(Pe,{children:N(ze,{onClick:()=>x(0),children:"1"})}),d>3&&N(Pe,{children:N(zt,{})}),[d-1,d,d+1].filter(u=>u>0&&u<=k).map(u=>N(Pe,{children:N(ze,{onClick:()=>x((u-1)*o),isActive:d===u,children:u})},u)),d<k-2&&N(Pe,{children:N(zt,{})}),d<k&&N(Pe,{children:N(ze,{onClick:()=>x((k-1)*o),children:k})}),d<k&&N(Pe,{children:N(jn,{onClick:()=>x(n+o)})})]})})})]})]})}var Fn=ca;import{useState as qn}from"react";import{Fragment as fa,jsx as X,jsxs as he}from"react/jsx-runtime";var Bn=e=>new Date(e*1e3).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),ua={active:"Aktywny",cancelled:"Anulowany",paused:"Wstrzymany"},ma={active:"text-green-600",cancelled:"text-red-500",paused:"text-yellow-500"};function pa({projectID:e}){let[t,r]=qn([]),[n,a]=qn(!0);return he(fa,{children:[X("h3",{className:"text-2xl",children:"Plany"}),X("p",{className:"text-sm text-neutral-500",children:"Twoje aktywne subskrypcje"}),n?X("div",{className:"mt-6 text-sm text-neutral-400",children:"\u0141adowanie..."}):t.length===0?X("div",{className:"mt-6 text-sm text-neutral-400",children:"Brak aktywnych plan\xF3w."}):X("div",{className:"mt-6 flex flex-col gap-4",children:t.map(o=>he("div",{className:"rounded-xl bg-white p-5 shadow-sm dark:bg-neutral-800",children:[he("div",{className:"flex items-start justify-between",children:[he("div",{children:[X("p",{className:"font-semibold",children:o.tierName}),o.configName&&X("p",{className:"text-sm text-neutral-500",children:o.configName})]}),X("span",{className:`text-sm font-medium ${ma[o.status]??"text-neutral-500"}`,children:ua[o.status]??o.status})]}),he("div",{className:"mt-3 grid grid-cols-2 gap-2 text-sm text-neutral-600 dark:text-neutral-400",children:[he("div",{children:[X("span",{className:"font-medium",children:"Dzie\u0144 rozliczenia:"})," ",o.billingDay]}),he("div",{children:[X("span",{className:"font-medium",children:"Data startu:"})," ",Bn(o.startDate)]}),o.endDate&&he("div",{children:[X("span",{className:"font-medium",children:"Data zako\u0144czenia:"})," ",Bn(o.endDate)]})]})]},o.id))})]})}var Hn=pa;import{useEffect as ga,useState as _t}from"react";import{jsx as ee,jsxs as Pa}from"react/jsx-runtime";function ya(e,t,r,n){typeof window>"u"||(t&&Te(r,n),window.location.href=e)}function ba({projectID:e,host:t,loginURL:r,screen:n,params:a,setParams:o,setActiveScreen:i}){let{status:c,exchangeError:s}=bn("PanelReturns"),y=yn(),d=c==="anonymous"&&(s==null||pn(s));ga(()=>{d&&ya(r,s!=null,e,t)},[d,r,s,e,t]);let[k,x]=_t("orders"),[u,h]=_t({items:[],note:""}),[C,l]=_t();if(c==="anonymous"&&!d)return Pa("div",{role:"alert",className:"flex flex-col items-start gap-3",children:[ee("p",{className:"text-sm",children:y(fn(s))}),ee(I,{type:"button",onClick:()=>window.location.reload(),children:y("errorRetry")})]});if(c!=="authenticated")return ee(hn,{});let b=R=>{x(R),o({state:"returns",orderId:void 0,returnId:void 0}),i("returns")};if(n==="return-details"&&a.returnId)return ee(Nn,{returnId:a.returnId,onBack:()=>b("myReturns")});if(k==="myReturns")return ee(Cn,{onBack:()=>b("orders"),onSelectReturn:R=>{o({state:"return-details",returnId:R,orderId:void 0}),i("return-details")}});if(k==="result"&&C!=null)return ee(xn,{returnId:C,onContinue:()=>b("orders"),onOpenMyReturns:()=>b("myReturns")});if(a.orderId){let R=a.orderId;return k==="confirmation"?ee(kn,{orderId:R,items:u.items,note:u.note,onBack:()=>x("orders"),onSubmitted:F=>{l(F),h({items:[],note:""}),x("result"),o({orderId:void 0})}}):ee(wn,{orderId:R,initialItems:u.items.length>0?u.items:void 0,initialNote:u.note,onBack:()=>{h({items:[],note:""}),o({orderId:void 0})},onContinue:F=>{h(F),x("confirmation")}})}return ee(vn,{showLogout:!1,onSelectOrder:R=>{h({items:[],note:""}),x("orders"),o({orderId:R})},onOpenMyReturns:()=>b("myReturns")})}function jt({accessToken:e,appearance:t,texts:r,...n}){return ee(Pn,{projectID:n.projectID,host:n.host,appearance:t,texts:r,panelAccessToken:e,children:ee(ba,{...n})})}import{useState as Ea}from"react";import{jsx as ka}from"react/jsx-runtime";var ha=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g,va=e=>[...e.matchAll(ha)].map(r=>({url:r[0],startIndex:r.index,endIndex:r.index+r[0].length-1})),wa=(e,t)=>{let r="",n=0;t.sort((a,o)=>a.startIndex-o.startIndex);for(let{startIndex:a,endIndex:o,replacementText:i}of t)r+=e.slice(n,a),r+=i,n=o+1;return r+=e.slice(n),r},Gn=e=>{let t=va(e);return ka("p",{dangerouslySetInnerHTML:{__html:wa(e,t.map(r=>(r.replacementText=`<a key=${r.url} href=${r.url} style="text-decoration: underline;" target="_blank">
|
|
2
2
|
${r.url}
|
|
3
|
-
</a>`,r)))}})};import{fromJsonString as Ra,toJsonString as Aa}from"@bufbuild/protobuf";import{useAutoAnimate as Ca}from"@formkit/auto-animate/react";import{ChevronLeft as Na,Download as Kn}from"lucide-react";import{useEffect as Qn,useRef as Yn,useState as je}from"react";import Vn from"hls.js";import{Pause as Pa,Play as ba}from"lucide-react";import{forwardRef as ha,useEffect as ct,useImperativeHandle as va,useRef as Qe,useState as Me}from"react";function qn(){typeof navigator>"u"||typeof navigator.mediaSession>"u"||(navigator.mediaSession.playbackState="playing")}function Bn(){typeof navigator>"u"||typeof navigator.mediaSession>"u"||(navigator.mediaSession.playbackState="paused")}function Hn(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 Gn(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 $n(){navigator.mediaSession.metadata=null}import{jsx as ie,jsxs as dt}from"react/jsx-runtime";var wa=ha(({chapters:e,styles:t,updateCurrentTime:r,setCurrentTimeHandler:n,title:a,imageURL:o,uniqueProductID:i,onChapterChange:c},s)=>{let y;(G=>(G[G.Playing=0]="Playing",G[G.Paused=1]="Paused"))(y||={});let[d,x]=Me(1);ct(()=>{switch(d){case 0:qn();break;case 1:Bn();break}},[d]),va(s,()=>({selectChapter:p=>{He(p)}}));let[k,u]=Me(void 0),[h,C]=Me(void 0),l=Qe(null),P=Qe(void 0),R=Qe(void 0),F=Qe(null),q=Qe(null),[A,L]=Me(!0),[_,D]=Me(!1),[H,pe]=Me(!xa());function U(p){p<10||localStorage.setItem(`__player__${i}_${q.current?.id}`,`${p}`)}function K(){let p=localStorage.getItem(`__player__${i}_${q.current?.id}`);if(p!=null)try{let z=parseInt(p);return isNaN(z)||z<0?void 0:z}catch{return}}function fe(){let p=localStorage.getItem(`__player__${i}_last_chapter`);if(p!=null)return p}function ke(p){localStorage.setItem(`__player__${i}_last_chapter`,p)}function ne(p){localStorage.removeItem(`__player__${i}_${p}`)}function g(){l.current!=null&&(l.current.onloadeddata=()=>{if(l.current!=null){if(l.current.readyState<2&&pe(!0),l.current.readyState>=2&&pe(!1),!_){let p=K();p!=null&&at(p),D(!0)}if(A){L(!1);try{bt()}catch(p){console.log("play error",p)}}}},l.current.onplay=()=>{},l.current.onseeked=()=>{},l.current.onseeking=()=>{},l.current.onpause=()=>{},l.current.onended=()=>{re()},Gn({title:a??"",artwork:o,action:p=>{switch(p.action){case"play":bt();break;case"pause":ht();break;case"seekbackward":rt(-15);break;case"seekforward":rt(15);break;case"seekto":p.seekTime&&at(p.seekTime);break;case"stop":ht();break;default:break}}}),Ce())}function re(){if(e==null||e.length==0)return;let p=e.findIndex(G=>G.id==q.current?.id);p==-1||(ne(e[p].id),p+1>=e.length)||He(e[p+1])}function Ce(){Ie(),R.current==null&&(R.current=setTimeout(()=>{Ie(),R.current=void 0,Ce()},500))}function Be(){R.current!=null&&clearTimeout(R.current)}function Ie(){l.current!=null&&(x(l.current.paused?1:0),C(l.current.duration),u(l.current.currentTime),U(l.current.currentTime),Hn(l.current.duration,l.current.currentTime),l.current.networkState===l.current.NETWORK_LOADING&&l.current.readyState<=l.current.HAVE_FUTURE_DATA?pe(!0):pe(!1),r&&r(l.current.currentTime))}function bt(){l.current?.play().then().catch(),Ie()}function ht(){l.current?.pause(),Ie()}function xr(){if(d===0){ht();return}bt()}function rt(p){if(l.current==null)return;let z=l.current.currentTime+p;if(z<0){l.current.currentTime=0;return}if(z>l.current.duration){l.current.currentTime=l.current.duration;return}l.current.currentTime+=p}function at(p){if(l.current!=null){if(u(p),p<0){l.current.currentTime=0;return}if(p>l.current.duration){l.current.currentTime=l.current.duration;return}l.current.currentTime=p}}function kr(){l.current!=null&&(l.current.onplay=null,l.current.onseeked=null,l.current.onseeking=null,l.current.onpause=null,l.current.onended=null,l.current.src="",P.current?.destroy())}function Qt(p){if(p.length==0)return;let z=fe();if(z==null){He(p[0]);return}let G=p.find(Re=>Re.id==z);if(G==null){He(p[0]);return}He(G)}function He(p){D(!1),L(!0),q.current=p,Cr(p.publicUrl),c?.(p),ke(p.id)}function Cr(p){l.current!=null&&(l.current.canPlayType("application/vnd.apple.mpegurl")?l.current.src=p:Vn.isSupported()&&(P.current==null&&(P.current=new Vn,P.current?.attachMedia(l.current)),P.current?.loadSource(p)))}ct(()=>{l.current!=null&&(g(),Qt(e))},[l.current]),ct(()=>{Qt(e)},[e]),ct(()=>(n?.(at),()=>{u(void 0),l.current?.pause(),kr(),$n()}),[]);let Yt=p=>{let z=Math.floor(p/3600),G=Math.floor(p/60)%60,Re=Math.floor(p%60),Sr=z>0?z<10?`0${z}:`:`${z}:`:"",Ir=Re<10?`0${Re}`:`${Re}`;return isNaN(Re)||isNaN(G)||isNaN(z)?"":`${Sr}${G}:${Ir}`},Nr=p=>{let z=parseFloat(p.value)/parseFloat(p.max)*100;F.current.style.setProperty("--seek-before-width",z+"%");let G=h*z/100;at(G)};return dt("div",{id:"audio-player-container",className:"flex flex-col",style:t,ref:F,children:[ie("video",{ref:l,className:"hidden",poster:o,title:a}),ie("input",{type:"range",min:"0",max:h!=null?Math.floor(h).toString():100,value:k??0,onChange:p=>Nr(p.target),className:"w-full"}),dt("section",{className:"flex w-full items-center justify-between text-sm font-medium",children:[ie("span",{id:"current-time",children:Yt(k)}),ie("span",{id:"duration",children:Yt(h)})]}),dt("div",{className:"mt-6 flex items-center justify-center gap-x-12",children:[ie(I,{variant:"outline",onClick:()=>rt(-10),"aria-label":"Rewind 10 Seconds",children:"-10"}),dt(I,{variant:"outline",onClick:xr,"aria-label":"Play Or Pause",children:[d===1&&ie(ba,{className:"h-5 w-5"}),d===0&&ie(Pa,{className:"h-5 w-5"})]}),ie(I,{variant:"outline",onClick:()=>rt(10),"aria-label":"Fast Forward 10 Seconds",children:"+10"})]}),H&&ie("div",{className:"mt-2 flex w-full justify-center",children:ie(V,{})})]})});function xa(){return navigator.userAgent.toLowerCase().indexOf("safari/")>-1}var Wn=wa;var ka={pl:{returnsNavLabel:"Zwroty",openCourse:"Otw\xF3rz kurs"},en:{returnsNavLabel:"Returns",openCourse:"Open the course"}};function Ye(e=ce()){return un(ka,e)}import*as ut from"react";import{jsx as Zn}from"react/jsx-runtime";function Jn(){let[e,t]=ut.useState(13);return ut.useEffect(()=>{let r=setTimeout(()=>t(66),500);return()=>clearTimeout(r)},[]),Zn("div",{className:"w-[60%] h-2 bg-gray-200 rounded-full overflow-hidden",children:Zn("div",{className:"h-full bg-blue-600 transition-all duration-300",style:{width:`${e}%`}})})}import{Fragment as mt,jsx as b,jsxs as M}from"react/jsx-runtime";function me(e,...t){console.warn(e,...t)}function jt(e){console.error(e)}var Sa=({accessToken:e,product:t,styles:r,reveal:n,onOpenCourse:a})=>{let o=t.productType,i=it(),c=()=>i.track("panel_download",{},{product_id:t.productId.length<=64?t.productId:null}),s=Yn(null),[y]=Ca(),[d,x]=je(null),{mutateAsync:k,isPending:u}=Y(B.publicApi.userPanelGetFileDetails),h=Yn(void 0),[C,l]=je(null),[P,R]=je(null),[F,q]=je(!1),{mutateAsync:A,isPending:L}=Y(B.publicApi.userPanelGetAudiobookDetails),{mutateAsync:_,isPending:D}=Y(B.publicApi.userPanelGetAudiobookDetailsDownloadURLs),[H,pe]=je(null),[U,K]=je(null);async function fe(){try{let g=await k({accessId:t.accessId,accessToken:e});if(g.result.case==="success"){x(g.result.value.files);return}else me("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),me("Kod b\u0142\u0119du: ",g.result.value)}catch(g){me("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),jt("B\u0142\u0105d podczas pobierania danych:"+g)}}async function ke(){try{let g=await A({accessId:t.accessId,accessToken:e});if(g.result.case==="audiobook"){l(g.result.value);return}else me("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),me("Kod b\u0142\u0119du: ",g.result.value)}catch(g){me("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),jt("B\u0142\u0105d podczas pobierania danych:"+g)}}async function ne(){try{let g=await _({accessId:t.accessId,accessToken:e,isBrowser:!0});if(g.result.case==="success"){R(g.result.value.audiobookDownloadDetails),q(g.result.value.isAvailableToDownloadInMobileApp===!0);return}else me("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),me("Kod b\u0142\u0119du: ",g.result.value)}catch(g){me("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),jt("B\u0142\u0105d podczas pobierania danych:"+g)}}return Qn(()=>{o===1&&(ke().then().catch(),ne().then().catch())},[]),Qn(()=>{if(C!=null&&P!=null){let g=C.chapters;if(!g)return;let re=g.map(Ce=>{let Be=P?.find(Ie=>Ie.chapterId===Ce.id);if(Be!=null)return{...Ce,publicUrl:Be.publicUrl,downloadableUrl:Be.downloadableUrl,duration:Be.duration}}).filter(Ce=>Ce!=null);re!=null&&re.length>0&&K(re)}},[C,P]),M("div",{children:[b("div",{className:"mb-3 space-y-4 rounded bg-white p-4 dark:bg-black",children:M(I,{onClick:()=>n(),variant:"ghost",className:"w-fit",children:[b(Na,{className:"h-6 w-6"}),b("span",{className:"font-inter text-sm font-medium",children:"Wr\xF3\u0107"})]})}),M("main",{className:"grid grid-cols-1 justify-center gap-6 sm:justify-start lg:grid-cols-2",children:[M("div",{className:"flex w-full max-w-xl flex-col gap-6",children:[o===2&&M("div",{ref:y,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:[M("div",{className:"flex items-center justify-between gap-x-4",children:[b("h4",{className:"text-xl font-semibold",children:"Twoje pliki"}),(d==null||d.length==0)&&b(I,{onClick:fe,"aria-label":"Download Product",className:"text-sm font-medium transition-opacity duration-300 ease-in-out hover:opacity-80 active:opacity-80",style:r,children:u?b(V,{}):"Wy\u015Bwietl"})]}),u&&M("div",{className:"flex flex-col items-start gap-2",children:[b(Jn,{}),b("p",{className:"font-bold transition hover:text-blue-600",children:"Trwa przygotowanie plik\xF3w..."})]}),d!=null&&d.length>0&&b("div",{className:"flex flex-col items-start justify-start gap-2",children:d.map((g,re)=>M("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:g,download:!0,onClick:c,children:[`Plik numer ${re+1}`,b(Kn,{width:14,height:14})]},re))})]}),o===4&&b("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:b(I,{onClick:()=>a(t.accessId),className:"text-sm font-medium transition-opacity duration-300 ease-in-out hover:opacity-80 active:opacity-80",style:r,children:Ye().openCourse})}),o===1&&b(mt,{children:M("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:[b("h4",{className:"text-xl font-semibold",children:H?.name??"Odtwarzacz"}),H?.description&&b("p",{className:"text-sm",children:H?.description}),b(mt,{children:L?M("div",{className:"flex gap-2",children:[b(V,{}),b("p",{className:"text-xl font-semibold",children:"Trwa pobierania audiobooka..."})]}):b(mt,{children:U!=null?b(mt,{children:b(Wn,{ref:s,chapters:U,title:C?.name??t.productName??void 0,imageURL:C?.coverImage??t.productImageUrl??void 0,styles:r,setCurrentTimeHandler:g=>{h.current=g},uniqueProductID:t.productId,onChapterChange:g=>{pe(g)}})}):b("p",{className:"mt-2",children:"Wybierz rozdzia\u0142, kt\xF3ry ci\u0119 interesuje."})})}),M("div",{className:"rounded-xl bg-neutral-100 p-3 dark:bg-neutral-800",children:[b("p",{className:"mt-3 mb-3 text-xs",children:F?"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."}),M("div",{className:"flex gap-3",children:[b("a",{href:"https://apps.apple.com/us/app/bitsnap/id6741902807",children:b("img",{width:"100",src:"https://bitsnap.pl/appstore.svg",alt:"Pobierz aplikacje z AppStore"})}),b("a",{href:"https://docs.bitsnap.pl/guides/audiobook",children:b("img",{width:"100",src:"https://bitsnap.pl/playstore.svg",alt:"Pobierz aplikacj\u0119 z GooglePlay"})})]})]})]})}),b("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:o===1&&b("div",{className:"max-h-96 w-full overflow-y-auto",children:L?M("div",{className:"jusitfy-center flex flex-col items-center gap-2",children:[b(V,{}),b("p",{children:"\u0141adowanie rozdzia\u0142\xF3w..."})]}):M("div",{children:[b("h2",{className:"mb-3 text-xl font-semibold",children:"Rozdzia\u0142y"}),U==null?b("p",{children:"Brak rozdzia\u0142\xF3w do wy\u015Bwietlenia."}):b("ul",{className:"flex w-full flex-col gap-2",children:U.map((g,re)=>M("li",{className:"flex items-center justify-between",children:[M("button",{className:w("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",H?.id==g.id?"bg-neutral-200 dark:bg-neutral-700":"bg-neutral-100 dark:bg-neutral-800 dark:text-neutral-300"),onClick:()=>{s.current.selectChapter(g)},children:[M("div",{className:"flex items-center justify-between",children:[b("p",{className:"text-sm font-medium",children:g.name}),g.duration&&M("span",{className:"text-xs text-neutral-500",children:[Math.floor(g.duration/60),":",String(Math.floor(g.duration%60)).padStart(2,"0")]})]}),g.description&&b("p",{className:"mt-3 text-xs",children:g.description})]}),C&&C.isDownloadable&&g.downloadableUrl&&b("a",{href:g.downloadableUrl,onClick:c,children:b(Kn,{width:14,height:14})})]},re))})]})})})]}),M("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:[b("h2",{className:"text-3xl font-semibold",children:t.productName}),b("p",{className:"text-sm font-normal text-neutral-600 dark:text-neutral-300",children:t.productDescription}),b("img",{src:t.productImageUrl,alt:"Product Photo",width:384,height:384,className:"max-h-sm max-w-sm",draggable:!1})]})]})]})},Xn=Sa;import{Fragment as La,jsx as $,jsxs as Xe}from"react/jsx-runtime";var Da=({accessToken:e,projectID:t,loginURL:r,styles:n,activeScreen:a,params:o,setParams:i,openCourse:c})=>{let{data:s,isLoading:y}=De(B.publicApi.userPanelGetProducts,{accessToken:e});if(y)return Xe("div",{className:"flex items-center gap-2 bg-white p-2 dark:bg-black",children:[$("p",{className:"text-dark font-inter font-medium dark:text-white",children:"\u0141adowanie..."}),$(V,{})]});if(s&&s.result.case==="failure")return console.warn("error:",`Kod b\u0142\u0119du: ${s.result.value}`),Te(t),window.location.href=r,null;let d=s&&s.result.case==="success"?s.result.value.products:[];return $(Ta,{accessToken:e,products:d,styles:n,loginURL:r,activeScreen:a,params:o,setParams:i,openCourse:c})},er=Da,Ta=({accessToken:e,products:t,styles:r,loginURL:n,activeScreen:a,params:o,setParams:i,openCourse:c})=>{if(t.length===0)return window.location.href=n,null;let[s,y]=Ia(o.product?Ra(St,o.product):void 0),d=u=>{u==null?(y(void 0),i({product:void 0,state:"products"})):i({product:Aa(St,u),state:"products"})};function x(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}y(u),d(u)}return a==="products"&&s!=null?$(Xn,{accessToken:e,product:s,styles:r,reveal:d,onOpenCourse:c}):Xe(La,{children:[$("h3",{className:"text-2xl",children:"Hej \u{1F44B}"}),$("p",{className:"text-sm text-neutral-500",children:"Poni\u017Cej znajdziesz swoje produkty"}),$("div",{className:"mt-6 flex flex-wrap items-center justify-center gap-9 sm:justify-start",children:t?.map((u,h)=>Xe("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:[Xe("section",{className:"flex flex-col items-center space-y-2 rounded bg-slate-100 p-4 dark:bg-neutral-900",children:[u.productType&&$("div",{className:"w-fit self-end rounded bg-red-900 px-4 py-1",children:$("span",{className:"text-sm font-medium text-white dark:text-slate-100",children:x(u.productType)})}),$("div",{className:"jusitfy-center flex max-h-40 items-center",children:$("img",{src:u.productImageUrl,alt:`Product ${h} Photo`,draggable:!1,className:"aspect-auto max-h-40"})})]}),Xe("div",{className:"space-y-4 rounded bg-white p-4 dark:bg-black",children:[$("h2",{className:"text-xl font-semibold",children:u.productName}),$("p",{title:u.productDescription,className:"line-clamp-3 text-sm font-normal text-neutral-600 dark:text-neutral-300",children:Fn(u.productDescription)}),$(I,{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:r,children:"Zobacz"})]})]},h))})]})};import{useAutoAnimate as Ea}from"@formkit/auto-animate/react";import{LogOut as Ua,Undo2 as nr}from"lucide-react";import{useState as za}from"react";import{Fragment as ar,jsx as S,jsxs as se}from"react/jsx-runtime";function Oa({activeScreen:e,setActiveScreen:t,setParams:r,styles:n,theme:a,logout:o}){return se("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:[S(Ma,{activeScreen:e,setActiveScreen:t,setParams:r}),S(ja,{activeScreen:e,setActiveScreen:t,setParams:r,theme:a,logout:o})]})}var rr=Oa;function Ma({activeScreen:e,setActiveScreen:t,setParams:r}){let{returnsNavLabel:n}=Ye();return se("nav",{className:"flex w-full items-center justify-evenly gap-4 md:hidden",children:[S(pt,{panelScreen:"products",label:"Produkty",imageURL:"/icons/bitsnap-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:r}),S(pt,{panelScreen:"orders",label:"Faktury",imageURL:"/icons/category-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:r}),S(pt,{panelScreen:"returns",label:n,icon:S(nr,{className:"h-5 w-5 text-white","aria-hidden":!0}),activeScreen:e,setActiveScreen:t,setParams:r}),S(pt,{panelScreen:"profile",label:"Profil",imageURL:"/icons/profile-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:r})]})}function pt({panelScreen:e,label:t,imageURL:r,icon:n,activeScreen:a,setActiveScreen:o,setParams:i}){return se(I,{onClick:()=>{o(e),i({product:void 0,state:e})},"aria-label":t,variant:null,className:w("flex flex-col gap-0",a===e?"opacity-100":"opacity-50"),children:[n??S("img",{src:r,alt:t,className:"scale-75"}),S("span",{className:"text-xs font-normal text-white",children:t})]})}function ft({panelScreen:e,label:t,imageURL:r,darkImageURL:n,icon:a,activeScreen:o,setActiveScreen:i,setParams:c,isExpanded:s}){return se(I,{onClick:()=>{i(e),c({product:void 0,state:e})},variant:o===e?"secondary":"ghost",className:"justify-start",children:[a!=null?S("span",{className:w("inline-flex h-5 w-5 items-center justify-center",s?"mr-4":"mr-2"),children:a}):se(ar,{children:[S("img",{src:r,alt:t,className:w("aspect-auto h-5 w-5 dark:hidden",s?"mr-4":"mr-2")}),S("img",{src:n,alt:t,className:w("hidden aspect-auto h-5 w-5 dark:inline",s?"mr-4":"mr-2")})]}),s&&S("span",{className:"md:text-medium hidden md:inline",children:t})]})}function ja({activeScreen:e,setActiveScreen:t,setParams:r,theme:n,logout:a}){let[o]=Ea(),[i,c]=za(!0),{returnsNavLabel:s}=Ye();return se("div",{ref:o,className:w("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:[S("div",{className:"flex items-center justify-between",children:S(_a,{theme:n,isExpanded:i})}),S(tr,{className:"my-6"}),se("div",{className:"flex flex-1 flex-col gap-2",children:[S(ft,{panelScreen:"products",label:"Produkty",imageURL:"/icons/bitsnap-dark-24x24.svg",darkImageURL:"/icons/bitsnap-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:r,isExpanded:i}),S(ft,{panelScreen:"orders",label:"Zam\xF3wienia",imageURL:"/icons/category-dark-24x24.svg",darkImageURL:"/icons/category-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:r,isExpanded:i}),S(ft,{panelScreen:"returns",label:s,icon:S(nr,{className:"h-5 w-5","aria-hidden":!0}),activeScreen:e,setActiveScreen:t,setParams:r,isExpanded:i}),S(ft,{panelScreen:"profile",label:"Profil",imageURL:"/icons/profile-dark-24x24.svg",darkImageURL:"/icons/profile-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:r,isExpanded:i})]}),S(tr,{className:"mb-6"}),se(I,{onClick:a,children:[S(Ua,{className:"mr-2",width:16,height:16}),i&&S("p",{className:"md:text-medium hidden md:inline md:text-center",children:"Wyloguj si\u0119"})]})]})}function tr({className:e}){return se("div",{className:w("relative h-px w-full bg-neutral-300",e),children:[S("div",{className:"absolute -top-px left-0 h-1 w-1 rounded-full bg-neutral-500"}),S("div",{className:"absolute -top-px right-0 h-1 w-1 rounded-full bg-neutral-500"})]})}function _a({theme:e,isExpanded:t}){return se(ar,{children:[e==null&&S("p",{className:"text-xl tracking-wider md:inline dark:text-neutral-200",children:"bitsnap."}),(e?.logoDarkURL||e?.logoURL)&&S("img",{src:e.logoDarkURL??e.logoURL,alt:"Company Logo",className:"hidden h-6 w-6 dark:inline",draggable:!1}),e?.logoURL&&S("img",{src:e.logoURL,alt:"Company Logo",className:"h-6 w-6 dark:hidden",draggable:!1})]})}import{LogOut as Fa}from"lucide-react";import{Fragment as Ba,jsx as _e,jsxs as _t}from"react/jsx-runtime";function qa({email:e,logout:t}){return _t(Ba,{children:[_e("h3",{className:"text-2xl",children:"Profil"}),_t("div",{className:"mt-6 flex-1 md:flex-none",children:[_e("span",{className:"text-sm text-neutral-500",children:"Email"}),_e("p",{className:"mt-2 text-base",children:e||"Brak danych"})]}),_e("div",{className:"flex w-full flex-col items-center space-y-2",children:_t(I,{onClick:t,className:"max-w-64 md:hidden",children:[_e(Fa,{className:"mr-2",width:16,height:16}),_e("p",{className:"text-medium inline text-center",children:"Wyloguj si\u0119"})]})})]})}var or=qa;import{lazy as Ha,Suspense as Ga}from"react";import{jsx as gt}from"react/jsx-runtime";var $a=Ha(()=>import("./course.mjs").then(e=>({default:e.PanelCourse})));function Ft(e){return gt(Ga,{fallback:gt("div",{className:"flex items-center gap-2 p-2",role:"status",children:gt(V,{})}),children:gt($a,{...e})})}import{AlertCircle as dr,CheckCircle2 as ir,ChevronLeft as Va,Loader2 as Bt,Lock as sr,Package as Wa,Truck as ur}from"lucide-react";import{useEffect as Za,useState as qt}from"react";import{Fragment as mr,jsx as m,jsxs as f}from"react/jsx-runtime";function Ja({status:e}){let t={created:{color:"bg-neutral-100 text-neutral-700",icon:null},paid:{color:"bg-green-100 text-green-700",icon:ir},completed:{color:"bg-blue-100 text-blue-700",icon:ir},canceled:{color:"bg-red-100 text-red-700",icon:dr},sent:{color:"bg-purple-100 text-purple-700",icon:ur},processing:{color:"bg-yellow-100 text-yellow-700",icon:Bt}},r=t[e]||t.created,n=r.icon,a={created:"Utworzone",paid:"Op\u0142acone",completed:"Zako\u0144czone",canceled:"Anulowane",sent:"Wys\u0142ane",processing:"Przetwarzane"};return f("span",{className:`inline-flex items-center gap-1 rounded-full px-3 py-1 text-sm font-medium ${r.color}`,children:[n&&m(n,{className:"h-4 w-4"}),a[e]||e]})}function Ka({orderID:e,email:t}){let[r,n]=qt(""),a=Y(B.publicApi.addPublicOrderComment);return f("form",{onSubmit:async i=>{if(i.preventDefault(),!!r.trim())try{await a.mutateAsync({projectId:"",orderId:e,message:r.trim(),accessToken:t}),n("")}catch(c){console.error("Failed to add comment:",c)}},className:"mt-4 space-y-2",children:[m(Ne,{htmlFor:"comment",children:"Dodaj komentarz"}),m(ln,{id:"comment",value:r,onChange:i=>n(i.target.value),placeholder:"Wpisz komentarz...",rows:3,disabled:a.isPending}),m(I,{type:"submit",disabled:!r.trim()||a.isPending,children:a.isPending?f(mr,{children:[m(Bt,{className:"mr-2 h-4 w-4 animate-spin"}),"Wysy\u0142anie..."]}):"Dodaj komentarz"})]})}function lr(e){return e?new Date(Number(e.seconds)*1e3).toLocaleDateString("pl-PL",{year:"numeric",month:"long",day:"numeric"}):"N/A"}function cr(e,t){return new Intl.NumberFormat("pl-PL",{style:"currency",currency:t.toUpperCase()}).format(e/100)}function Qa({orderID:e,initialEmail:t,onBack:r,accessToken:n,analytics:a}){let{theme:o,projectID:i}=ge(),c=Ae(i,a,"order"),[s,y]=qt(t||""),[d,x]=qt(!1),{data:k,isLoading:u,error:h,refetch:C}=De(B.publicApi.getPublicOrderDetails,{projectId:i??"",orderId:e,email:s||void 0,accessToken:n},{enabled:!!e}),l=k?.result.case==="order"?k.result.value:null,P=l?.isVerified??!1,R=l!=null;Za(()=>{R&&c.track("panel_order_viewed",{},{order_ref:null})},[c,R]);let F=()=>{C(),x(!1)},q={"--button-background-color":o?.colors?.brand??"#000000","--button-background-color-dark":o?.colors?.brandDark??"#ffffff","--button-text-color":o?.colors?.brandDark??"#000000","--button-text-color-dark":o?.colors?.brand??"#000000"};return u?m("div",{className:"flex min-h-screen items-center justify-center",children:f("div",{className:"text-center",children:[m(Bt,{className:"mx-auto h-8 w-8 animate-spin text-neutral-400"}),m("p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"\u0141adowanie zam\xF3wienia..."})]})}):h||!l?m("div",{className:"flex min-h-screen items-center justify-center",children:m(de,{className:"w-full max-w-md",children:m(ue,{className:"pt-6",children:f("div",{className:"text-center",children:[m(dr,{className:"mx-auto h-12 w-12 text-red-500"}),m("h2",{className:"mt-4 text-xl font-semibold",children:"Zam\xF3wienie nie znalezione"}),m("p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"Nie znaleziono zam\xF3wienia o podanym numerze."})]})})})}):m("div",{className:"w-full bg-white py-8 dark:bg-black",style:q,children:f("div",{className:"w-full px-4",children:[r&&f(I,{onClick:r,variant:"ghost",className:"mb-4 w-fit",children:[m(Va,{className:"h-4 w-4"}),"Wr\xF3\u0107 do historii zam\xF3wie\u0144"]}),f("div",{className:"mb-6 flex items-center gap-4",children:[o?.logoURL&&f(mr,{children:[m("img",{src:o.logoURL,alt:"Project logo",className:`h-12 w-auto ${o.logoDarkURL?"dark:hidden":""}`}),o.logoDarkURL&&m("img",{src:o.logoDarkURL,alt:"Project logo",className:"hidden h-12 w-auto dark:block"})]}),f("div",{children:[m("h1",{className:"text-3xl font-bold",children:"Zam\xF3wienie"}),f("p",{className:"text-neutral-600 dark:text-neutral-400",children:["Numer zam\xF3wienia: #",l.orderId]})]})]}),f(de,{className:"mb-6",children:[m(ye,{children:f(Pe,{className:"flex items-center",children:[m(Wa,{className:"mr-2 h-5 w-5"}),"Status zam\xF3wienia"]})}),f(ue,{className:"space-y-6",children:[f("div",{children:[f("div",{className:"flex items-center gap-2",children:[m(Ja,{status:l.status}),l.processingStatus&&f("span",{className:"text-sm text-neutral-600",children:["\xB7 ",l.processingStatus]})]}),f("p",{className:"mt-2 text-sm text-neutral-600",children:["Zam\xF3wienie z\u0142o\u017Cone ",lr(l.createdAt)]})]}),f("div",{className:"border-t pt-4",children:[m("h3",{className:"mb-3 font-semibold",children:"Dane klienta"}),f("div",{className:"space-y-2",children:[f("div",{children:[m("span",{className:"font-medium",children:"Imi\u0119 i nazwisko:"})," ",m("span",{className:P?"":"text-neutral-500",children:l.customerName})]}),f("div",{children:[m("span",{className:"font-medium",children:"Email:"})," ",m("span",{className:P?"":"text-neutral-500",children:l.customerEmail})]}),l.customerPhone&&f("div",{children:[m("span",{className:"font-medium",children:"Telefon:"})," ",m("span",{className:P?"":"text-neutral-500",children:l.customerPhone})]})]})]}),!P&&m("div",{className:"border-t pt-4",children:f(I,{onClick:()=>x(!0),variant:"outline",className:"w-full",children:[m(sr,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),f(de,{className:"mb-6",children:[m(ye,{children:m(Pe,{children:"Produkty"})}),f(ue,{className:"space-y-6",children:[m("div",{className:"space-y-4",children:l.items.map((A,L)=>f("div",{className:"flex items-center gap-4",children:[A.imageUrl&&m("img",{src:A.imageUrl,alt:A.name,className:"h-16 w-16 rounded object-cover"}),f("div",{className:"flex-1",children:[m("p",{className:"font-medium",children:A.name}),f("p",{className:"text-sm text-neutral-600",children:["Ilo\u015B\u0107: ",A.quantity]})]}),m("div",{className:"text-right",children:m("p",{className:"font-medium",children:cr(Number(A.price),A.currency)})})]},L))}),(l.deliveryAddress||l.deliveryMethod)&&f("div",{className:"border-t pt-4",children:[f("h3",{className:"mb-3 flex items-center font-semibold",children:[m(ur,{className:"mr-2 h-5 w-5"}),"Informacje o dostawie"]}),f("div",{className:"space-y-2",children:[l.deliveryAddress&&f("div",{children:[m("span",{className:"font-medium",children:"Adres:"})," ",m("span",{className:P?"":"text-neutral-500",children:l.deliveryAddress})]}),l.deliveryMethod&&f("div",{children:[m("span",{className:"font-medium",children:"Metoda:"})," ",l.deliveryMethod]}),l.trackingNumber&&P&&f("div",{children:[m("span",{className:"font-medium",children:"Tracking:"})," ",l.trackingNumber]})]})]}),m("div",{className:"border-t pt-4",children:f("div",{className:"flex justify-between text-lg font-bold",children:[m("span",{children:"Suma:"}),m("span",{children:cr(Number(l.totalAmount),l.currency)})]})})]})]}),f(de,{children:[m(ye,{children:f(Pe,{children:["Komentarze ",l.commentCount>0&&`(${l.commentCount})`]})}),f(ue,{children:[l.comments.length>0?m("div",{className:"space-y-4",children:l.comments.map(A=>f("div",{className:"border-b pb-4 last:border-b-0",children:[f("div",{className:"mb-1 flex items-center gap-2",children:[m("span",{className:"font-medium",children:A.authorName||"System"}),m("span",{className:"text-xs text-neutral-500",children:lr(A.createdAt)}),A.authorType==="admin"&&m("span",{className:"rounded bg-blue-100 px-2 py-0.5 text-xs text-blue-700",children:"Admin"})]}),m("p",{className:P?"":"text-neutral-500",children:A.message})]},A.id))}):m("p",{className:"text-neutral-600",children:"Brak komentarzy."}),P?m(Ka,{orderID:l.orderId,email:s}):m("div",{className:"mt-4",children:f(I,{onClick:()=>x(!0),variant:"outline",className:"w-full",children:[m(sr,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),d&&m("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:f(de,{className:"w-full max-w-md",children:[m(ye,{children:m(Pe,{children:"Zweryfikuj sw\xF3j email"})}),f(ue,{className:"space-y-4",children:[m("p",{className:"text-sm text-neutral-700",children:"Podaj adres email u\u017Cyty przy sk\u0142adaniu zam\xF3wienia."}),f("div",{className:"space-y-2",children:[m(Ne,{htmlFor:"verify-email",children:"Adres email"}),m(st,{id:"verify-email",type:"email",placeholder:"twoj@email.com",value:s,onChange:A=>y(A.target.value)})]}),f("div",{className:"flex gap-2",children:[m(I,{variant:"outline",onClick:()=>x(!1),className:"flex-1",children:"Anuluj"}),m(I,{onClick:F,className:"flex-1",children:"Zweryfikuj"})]})]})]})})]})})}function Ya(e){return m(Qa,{...e})}var Ht=Ya;import{jsx as le,jsxs as pr}from"react/jsx-runtime";var to=({returnsAppearance:e,returnsTexts:t,analytics:r}={})=>{let{projectID:n,theme:a,loginURL:o,host:i}=ge(),c=Ae(n,r,"panel"),s=Ve(n,i),y=on(n,i),{mutateAsync:d}=Y(B.publicApi.userPanelLogout);async function x(){s&&await d({accessToken:s}),typeof window<"u"&&(Te(n,i),window.location.reload())}let[k]=Xa(),u=D=>["products","notifications","profile","plans","orders","order-details","returns","return-details","course"].includes(D),[h,C]=In({product:void 0,state:"products",orderId:void 0,returnId:void 0,course:void 0,item:void 0}),[l,P]=eo(u(h.state)?h.state:"products"),R=D=>{C({state:"order-details",orderId:D}),P("order-details")},F=()=>{C({state:"orders",orderId:void 0}),P("orders")},q=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")},L=()=>{C({state:"products",course:void 0,item:void 0,product:void 0}),P("products")};yt(()=>{u(h.state)&&(h.state==="course"||l==="course")&&P(h.state)},[h.state]);let _={"--button-background-color":a?.colors?.brand??"#000000","--button-background-color-dark":a?.colors?.brandDark??"#ffffff","--button-text-color":a?.colors?.brandDark??"#000000","--button-text-color-dark":a?.colors?.brand??"#000000"};return yt(()=>{if(s==null||s.length===0){window.location.href=o??"/panel/login";return}},[]),yt(()=>{if(s==null||s.length===0){window.location.href=o??"/panel/login";return}},[l]),yt(()=>{if(typeof window>"u"||window.parent!==window||!s)return;let D=Ze(window.location.search);D&&Je(D);let H=D??Ue();H&&(window.location.href=ze(H,s))},[s]),le(ot,{value:c,children:pr("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:[le(rr,{activeScreen:l,setActiveScreen:P,setParams:q,styles:_,theme:a,logout:x}),pr("main",{className:"flex h-[calc(100vh-80px)] flex-col overflow-y-auto w-full p-5 md:h-screen",children:[l==="products"&&le(er,{projectID:n??"",accessToken:s,loginURL:o??"/panel/login",styles:_,activeScreen:l,params:h,setParams:C,openCourse:A}),l==="course"&&h.course&&s&&le(Ft,{accessId:h.course,accessToken:s,theme:a,itemId:h.item,onItemChange:D=>C({item:D}),onBack:L}),l==="notifications"&&le(Tn,{}),l==="plans"&&le(_n,{projectID:n??""}),l==="orders"&&le(On,{projectID:n??"",accessToken:s??"",openOrderDetails:R}),l==="order-details"&&h.orderId&&le(Ht,{orderID:h.orderId,onBack:F}),(l==="returns"||l==="return-details")&&s&&le(Mt,{projectID:n??"",host:i,accessToken:s,loginURL:o??"/panel/login",appearance:Rn(e,a?.colors?.brand),texts:t,screen:l,params:h,setParams:C,setActiveScreen:P}),l==="profile"&&le(or,{email:y,logout:x})]})]})})},no=to;import{create as xe}from"@bufbuild/protobuf";import{QueryClient as po,QueryClientProvider as fo}from"@tanstack/react-query";import{createContext as go,useContext as yo,useEffect as Po}from"react";import{createClient as ro}from"@connectrpc/connect";import{createConnectTransport as ao}from"@connectrpc/connect-web";var ve;(n=>{function e(a){return ro(en,r(a))}n.get=e;let t=new Map;function r(a){let o=t.get(a);return o==null&&(o=ao({useBinaryFormat:!0,baseUrl:a+"/api/rpc",interceptors:[Xt]}),t.set(a,o)),o}})(ve||={});import T from"zod";import Z from"zod";function j(e,t=2){return+(Math.round(+(e+"e+"+t))+"e-"+t)}function fr(e,t){let r=typeof navigator>"u"?"pl-PL":navigator.language;return Intl.NumberFormat(r,{style:"currency",currency:t,currencyDisplay:"symbol"}).format(e/100)}var Zl=Z.object({event:Z.enum(["purchase","addToCart","customizeProduct","viewCart","removeFromCart","initiateCheckout","lead"]),step:Z.string().optional(),value:Z.number().optional(),currency:Z.string().optional(),content_name:Z.string().optional(),items:Z.array(Z.object({id:Z.string(),name:Z.string(),price:Z.number().default(0),currency:Z.string().default("PLN"),quantity:Z.number().default(1)})).optional()});function Gt(e){typeof window>"u"||(oo(e),so(e),lo(e))}function oo(e){try{typeof window.dataLayer>"u"&&(window.dataLayer=[]);let t=io(e);window.dataLayer.push(t)}catch(t){console.warn("cannot send google analytics event",t)}}function io(e){let t=e.value??e.items?.reduce((o,i)=>o+(i.price||0)*(i.quantity||1),0)??0,r=e.items?.map(o=>({item_id:o.id,item_name:o.name||o.id,price:j((o.price||0)/100,2),quantity:o.quantity||1})),n={currency:e.currency||"PLN",value:j(t/100,2)};r&&r.length>0&&(n.items=r);let a;switch(e.event){case"purchase":a="purchase",n.transaction_id=e.step||`txn_${Date.now()}`;break;case"addToCart":a="add_to_cart";break;case"viewCart":a="view_cart";break;case"removeFromCart":a="remove_from_cart";break;case"initiateCheckout":a="begin_checkout";break;case"customizeProduct":a="customize_product";break;default:a=e.event}return{event:a,ecommerce:n,...e.step&&{step:e.step},...e.content_name&&{content_name:e.content_name}}}function so(e){if(typeof window.fbq>"u")return;let t="",r="",n={};switch(e.event){case"purchase":t="track",r="Purchase",n={category_name:e.step,...e};break;case"lead":t="track",r="Lead",n={category_name:e.step,...e};break;case"addToCart":t="track",r="Add to Cart",n={category_name:e.step,...e};break;case"customizeProduct":t="track",r="Customize Product",n={category_name:e.step,...e};break;case"viewCart":t="track",r="View Cart",n={category_name:e.step,...e};break;case"removeFromCart":t="track",r="Remove from Cart",n={category_name:e.step,...e};break;case"initiateCheckout":t="track",r="Initiate Checkout",n={category_name:e.step,...e};break;default:break}window.location.search.includes("analytics")&&console.log("Pushing FB event",t,r,n),window.fbq(t,r,n)}function lo(e){try{if(typeof window.ttq>"u")return;let t=co(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 co(e){let t=e.value??e.items?.reduce((o,i)=>o+(i.price||0)*(i.quantity||1),0)??0,r=e.items?.map(o=>({content_id:o.id,content_type:"product",content_name:o.name||o.id,quantity:o.quantity||1,price:j((o.price||0)/100,2)}))||[];r.length===0&&e.content_name&&r.push({content_id:e.step||"unknown",content_type:"product",content_name:e.content_name,quantity:1,price:j(t/100,2)});let n={currency:e.currency||"PLN",value:j(t/100,2)};r.length>0&&(n.contents=r);let a=null;switch(e.event){case"purchase":a="Purchase";break;case"addToCart":a="AddToCart";break;case"initiateCheckout":a="InitiateCheckout";break;case"customizeProduct":a="CustomizeProduct";break;case"viewCart":return;case"removeFromCart":return;case"lead":return;default:return null}return{eventName:a,eventPayload:n}}function gr(e){let{items:t,googlePayConfig:r,checkout:n,result:a,cartRequiresShipping:o}=e;if(a.totalAmount==null)return;let i=[];return o&&(i.push("SHIPPING_ADDRESS"),i.push("SHIPPING_OPTION")),{apiVersion:2,apiVersionMinor:0,callbackIntents:i,allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:["MASTERCARD","VISA"]},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:r.gateway,gatewayMerchantId:r.gatewayId}}}],emailRequired:!0,shippingAddressParameters:{phoneNumberRequired:o},shippingAddressRequired:o,shippingOptionRequired:o,shippingOptionParameters:o?{shippingOptions:a.methods.slice(0,5).map(s=>({id:s.id,label:s.name+` - ${fr(s.amount,a.currency)}`,description:s.description??""})),defaultSelectedOptionId:a.selectedDeliveryMethod}:void 0,merchantInfo:{merchantId:r.merchantId+"",merchantName:r.merchantName},transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:"P\u0142atno\u015B\u0107 za koszyk",totalPrice:`${j(a.totalAmount/100,2)}`,currencyCode:a.currency,countryCode:a.country,checkoutOption:"COMPLETE_IMMEDIATE_PURCHASE",displayItems:uo(t,a.methods,a.selectedDeliveryMethod??(a.methods.length>0?a.methods[0].id:void 0),n.couponCode,a.couponValue)}}}function uo(e,t,r,n,a){let o=[],i=0;for(let s of e)s.details!=null&&(i+=s.details.price*s.quantity,o.push({label:s.details.name+" x "+s.quantity,price:`${j(s.details.price/100,2)}`,type:"LINE_ITEM",status:"FINAL"}));let c=t.find(s=>s.id===r);return c!=null&&o.push({label:c.name,price:`${j(c.amount/100,2)}`,type:"SHIPPING_OPTION",status:"FINAL"}),n!=null&&a!=null&&o.push({label:`Kupon ${n}`,price:`${j(a/100,2)}`,type:"DISCOUNT",status:"FINAL"}),i>0&&o.push({label:"Subtotal",price:`${j(i/100,2)}`,type:"SUBTOTAL",status:"FINAL"}),o}function et(e,t){return`${Q}/api/integrations/${e}/public-commerce${t}`}function we(e){return typeof e=="object"&&e!=null&&"ERR"in e}function J(e,t,r){return{ERR:!0,error:e,type:t,data:r}}function yr(e,t){return t?.find(r=>r.id===e||(r.variants?.some(n=>n.id===e)??!1))}function Pr(e,t){let r=new Set(t.map(n=>n.productID));return Array.from(new Set(e.filter(n=>!r.has(n))))}import{create as mo}from"zustand";var Fe=mo(e=>({isCartVisible:!1,numberOfProductsInCart:0,showCart:()=>e(t=>({...t,isCartVisible:!0})),hideCart:()=>e(t=>({...t,isCartVisible:!1})),setNumberOfProductsInCart:t=>e(r=>({...r,numberOfProductsInCart:t}))}));import{Fragment as Io,jsx as $t}from"react/jsx-runtime";var bo="__m_a",vr=go(void 0),Wt=void 0;function Sc(e){Rt({projectID:e}),Wt=e,typeof window<"u"&&Ge([window.location.origin])}function nt(){return Wt??document.querySelector('script[data-id][data-name="internal-cart"]')?.getAttribute("data-id")??void 0}function ho(){return document.querySelector('script[data-id][data-name="internal-cart"]')?.getAttribute("data-custom-host")??void 0}var vo=({children:e,locale:t})=>{let r=new po;Po(()=>{tt()},[]);let n=nt();if(n==null)return $t(Io,{});let a=Kt(n,t);return $t(fo,{client:r,children:$t(vr.Provider,{value:a,children:e})})},qe=async(e,t)=>{let r=[];t?.items!=null&&t.items.length>0?r=t.items:r=O()?.products??[];let n=Array.from(new Set(r.map(c=>c.productID))),a=new URLSearchParams;a.set("ids",n.join(",")),a.set("locale",t?.locale??ce());let o=await fetch(wt(et(e,`/products?${a.toString()}`)),{method:"GET"});if(o.status!=200)return[];let i=await o.json();return r.flatMap(c=>{let s=yr(c.productID,i.result);return s==null?[]:[{...c,details:So(c.productID,s),catalogProductID:s.id}]})},Ic=()=>{let e=yo(vr);if(e===void 0)throw new Error("useCartProvider must be used within a CartProvider");return e},Rc=vo,wo=T.object({isAvailable:T.boolean(),merchantId:T.string(),merchantName:T.string(),gateway:T.string(),gatewayId:T.string()}),xo=T.object({id:T.string(),productID:T.string(),quantity:T.number(),priceVersion:T.string().optional(),metadata:T.record(T.string(),T.string().optional()).optional()}),ko=T.object({country:T.string().optional(),couponCode:T.string().optional(),selectedDeliveryMethod:T.string().optional(),postalCode:T.string().optional(),email:T.string().optional(),products:T.array(xo).optional(),googlePayConfig:wo.optional()}),Zt={country:void 0,couponCode:void 0,email:void 0,selectedDeliveryMethod:void 0,postalCode:void 0,products:[],googlePayConfig:void 0},wr="checkout";function O(){try{let e=localStorage.getItem(wr);return e==null?Zt:ko.parse(JSON.parse(e))}catch{return Zt}}async function br(e,t){let r=await qe(e,{items:t.map((o,i)=>({...o,id:`price-check-${i}`}))});if(we(r))return r;let n=Pr(t.map(o=>o.productID),r);if(n.length>0)return J("item-ids-not-found","notFound",n);let a=O();a.products==null&&(a.products=[]),a.products.push(...t.map(o=>({id:Math.random().toString(36).substring(7),productID:o.productID,quantity:o.quantity,priceVersion:r.find(i=>i.productID===o.productID)?.details?.pricing?.priceVersion,metadata:o.metadata}))),Co(t,r),Gt({event:"addToCart",currency:"PLN",items:t.map(o=>({id:o.productID,name:o.name??"",price:o.price??0,quantity:o.quantity,currency:o.currency??"PLN"}))}),te(a),tt()}function Co(e,t){for(let r of e)try{let n=t.find(c=>c.productID===r.productID),a=n?.details?.pricing?.effectivePrice??n?.details?.price??r.price,o=n?.details?.currency??r.currency;if(a==null||o==null)continue;let i=n?.catalogProductID??r.productID;(r.analytics??tn()).track("add_to_cart",{qty:r.quantity,value_minor:Math.round(a*r.quantity),currency:o},{product_id:i,variant_id:i!==r.productID?r.productID:null})}catch{}}function hr(e){let t=O(),r={...t,products:t?.products?.filter(n=>!e.includes(n.productID)&&!e.includes(n.id))};Gt({event:"removeFromCart",items:e.map(n=>({id:n,name:"",price:0,quantity:1,currency:"PLN"}))}),te(r),tt()}function te(e){localStorage.setItem(wr,JSON.stringify(e))}var Kt=(e,t=ce())=>{let r=ho();return r!=null&&nn(r),{async checkIfApplePayIsAvailable(){if(typeof window>"u"||typeof document>"u"||!("ApplePaySession"in window))return!1;try{return(await ve.get(Q).isOneClickPaymentAvailable({projectId:e})).applePay}catch(n){return console.error("Error checking if Apple Pay is available",n),!1}},async getGooglePayConfiguration(n){if(typeof window>"u"||typeof document>"u")return{isAvailable:!1};try{let a=await No(e);if(a?.isAvailable!=!0)return{isAvailable:!1};let o=O();if(o==null)return console.log("checkout is null"),{isAvailable:!1};let i=await qe(e,{locale:t,items:n.items.map(d=>({id:Math.random().toString(36).substring(7),quantity:d.quantity,metadata:d.metadata,productID:d.productID}))});if(we(i))return{isAvailable:!1};let c=await ve.get(Q).getPreOrderDetails({items:i.map(d=>xe(Ct,{id:d.productID,quantity:d.quantity})),projectId:e,postCode:o.postalCode,couponCode:o.couponCode,countryCode:o.country,selectedDeliveryMethod:o.selectedDeliveryMethod});if(c.totalAmount==null)return{isAvailable:!1};let s=i.find(d=>d.details?.isDeliverable==!0)!=null,y=await gr({items:i,googlePayConfig:a,checkout:o,cartRequiresShipping:s,result:c});return y==null?{isAvailable:!1}:{isAvailable:!0,config:y}}catch(a){return console.error("Error resolving Google Pay configuration",a),{isAvailable:!1}}},async clearCart(){let n=structuredClone(Zt);n.country=O()?.country,te(n),tt()},async getAvailableCountries(){let n=await fetch(wt(et(e,"/countries")),{method:"GET"});if(n.status!=200)return[];try{return T.array(T.object({name:T.string(),code:T.string()})).parse(await n.json())}catch(a){return J(a.toString(),"internal")}},async getCountry(){let n=O()?.country;if(n==null){n="PL";let a=O();a.country=n,te(a)}return n},async getNumberOfElementsInCart(){return O()?.products?.reduce((n,a)=>n+a.quantity,0)??0},async getProducts(){return await qe(e,{locale:t})},async removeProductFromCart(n){return hr([n.id])},async setCountry(n){let a=O();a.country=n,te(a)},async setCouponCodeIfPossible(n){let a=O();a.couponCode=n,te(a)},async setPostalCode(n){let a=O();a.postalCode=n,te(a)},async setDeliveryMethod(n){let a=O();a.selectedDeliveryMethod=n,te(a)},async setEmail(n){let a=O();a.email=n,te(a)},async addProduct(n){return await br(e,[n])},async updateQuantity(n){let a=O();a.products=a.products?.map(o=>(o.id===n.id&&(o.quantity=n.quantity),o)),te(a),tt()},async redirectToNextStep(){let n=O();if(n.products==null||n.products.length==0)return J("cart-is-empty","badInput");let a=n.products.reduce((c,s)=>(s.metadata!=null&&Object.keys(s.metadata).forEach(y=>{let d=s.metadata?.[y];d!=null&&(c[y]=d)}),c),{}),o={items:n.products.map(c=>({id:c.productID,quantity:c.quantity,priceVersion:c.priceVersion})),askForNote:!0,countries:n.country?[n.country]:void 0,metadata:a,locale:t},i=await Vt(o);return we(i)?(console.warn("cannot create payment URL",i.error),i):{url:i.url}},async justRedirectToPayment(n){let a={items:[{id:n.productID,quantity:1}],askForNote:!1,details:n.email||n.name?{name:n.name,email:n.email}:void 0,locale:n.locale??t};a=Jt(a),n.country==null&&(n.country="pl"),a.details==null&&(a.details={}),a.details.address==null&&(a.details.address={}),a.details.address.country=n.country,n.marketingAgreement===!0&&(a.additionalAgreements=[{id:bo,name:"",required:!0,answer:!0}]);let o=await Vt(a);return we(o)?o:{url:o.url}},async completeApplePayPayment(n){let a=O();if(a==null)return J("Checkout not found");let o=await qe(e,{locale:t});if(we(o))return o;try{let i=n.shippingContact?.givenName;n.shippingContact?.familyName!=null?i+=" "+n.shippingContact?.familyName:n.billingContact?.familyName!=null&&(i+=" "+n.billingContact?.familyName);let c={},s=Pt();s!=null&&(c.ref=s);let y=await ve.get(Q).authorizeOneClickPayment({gateway:0,paymentData:JSON.stringify(n.token.paymentData),paymentMethod:JSON.stringify(n.token.paymentMethod),transactionIdentifier:n.token.transactionIdentifier,order:xe(Nt,{items:o.map(d=>({id:d.productID,quantity:d.quantity})),couponCode:a.couponCode,email:n.shippingContact?.emailAddress??n.billingContact?.emailAddress??a.email??void 0,phone:n.shippingContact?.phoneNumber??n.billingContact?.phoneNumber??void 0,selectedDeliveryMethod:a.selectedDeliveryMethod,postCode:a.postalCode,projectId:e}),shippingAddress:xe(xt,{line1:n.shippingContact?.addressLines?.[0]??"",city:n.shippingContact?.locality??"",country:n.shippingContact?.countryCode??"",zipCode:n.shippingContact?.postalCode??"",name:i}),billingAddress:xe(kt,{name:n.billingContact?.givenName??" "+(n.billingContact?.familyName??""),line1:n.billingContact?.addressLines?.[0]??"",city:n.billingContact?.locality??"",country:n.billingContact?.countryCode??"",zipCode:n.billingContact?.postalCode??""}),metadata:Object.keys(c).length>0?JSON.stringify(c):void 0});return{isSuccess:y.isSuccess,redirectURL:y.redirectUrl}}catch(i){return console.error(i),J("Failed to authorize payment")}},async completeGooglePayPayment(n){let a=O();if(a==null)return J("Checkout not found");let o=await qe(e,{locale:t});if(we(o))return o;try{let i=n.paymentData.shippingAddress?.name,c={},s=Pt();s!=null&&(c.ref=s);let y=await ve.get(Q).authorizeOneClickPayment({gateway:1,paymentData:n.paymentData.paymentMethodData.tokenizationData.token,paymentMethod:n.paymentData.paymentMethodData.type,transactionIdentifier:"",order:xe(Nt,{items:o.map(d=>({id:d.productID,quantity:d.quantity})),couponCode:a.couponCode,email:n.paymentData.email??void 0,phone:n.paymentData.shippingAddress?.phoneNumber??void 0,selectedDeliveryMethod:n.paymentData.shippingOptionData?.id??a.selectedDeliveryMethod,postCode:n.paymentData.shippingAddress?.postalCode,projectId:e}),shippingAddress:xe(xt,{line1:n.paymentData.shippingAddress?.address1??"",city:n.paymentData.shippingAddress?.locality??"",country:n.paymentData.shippingAddress?.countryCode??"",zipCode:n.paymentData.shippingAddress?.postalCode??"",name:i}),billingAddress:xe(kt,{name:n.paymentData.paymentMethodData.info?.billingAddress?.name,line1:n.paymentData.paymentMethodData.info?.billingAddress?.address1??"",city:n.paymentData.paymentMethodData.info?.billingAddress?.locality??"",country:n.paymentData.paymentMethodData.info?.billingAddress?.countryCode??"",zipCode:n.paymentData.paymentMethodData.info?.billingAddress?.postalCode??""}),metadata:Object.keys(c).length>0?JSON.stringify(c):void 0});return{isSuccess:y.isSuccess,redirectURL:y.redirectUrl}}catch(i){return console.error(i),J("Failed to authorize payment")}return{isSuccess:!0}},async getApplePayPaymentRequest(n){let a=O();if(a==null)return J("Checkout not found");n&&n.expectedItems!=null&&n.expectedItems.length>0&&(a.products&&hr(a.products.map(s=>s.productID)),await br(e,n.expectedItems));let o=await qe(e,{locale:t});if(we(o))return o;let i=await ve.get(Q).getPreOrderDetails({items:o.map(s=>xe(Ct,{id:s.productID,quantity:s.quantity})),projectId:e,postCode:a.postalCode,couponCode:a.couponCode,countryCode:a.country,selectedDeliveryMethod:a.selectedDeliveryMethod}),c=o.map(s=>({amount:`${j(s.quantity*(s.details?.price??0)/100,2)}`,label:s.details?.name+" - "+s.quantity,type:"final"}));if(i.selectedDeliveryMethod!=null){let s=i.methods.find(y=>y.id==i.selectedDeliveryMethod);s!=null&&c.push({amount:`${j(s.amount/100,2)}`,label:s.name,type:"final"})}return i.couponCode!=null&&i.couponValue!=null&&c.push({amount:`-${j(i.couponValue/100,2)}`,label:i.couponCode,type:"final"}),{countryCode:a.country??"PL",merchantCapabilities:["supports3DS","supportsCredit","supportsDebit"],supportedNetworks:["visa","masterCard"],total:{amount:`${j((i.totalAmount??0)/100,2)}`,label:"P\u0142atno\u015B\u0107 za koszyk",type:"final"},shippingMethods:i.methods.map(s=>({amount:`${j(s.amount/100,2)}`,detail:s.description??"",identifier:s.id,label:s.name,dateComponentsRange:{startDateComponents:{days:s.minDays??1,hours:0,months:0,years:0},endDateComponents:{days:s.maxDays??14,hours:0,months:0,years:0}}})),lineItems:c,currencyCode:"PLN"}}}};async function No(e){let t=O();if(t.googlePayConfig?.isAvailable!=!0){let r=await ve.get(Q).isOneClickPaymentAvailable({projectId:e});r.googlePay==!0&&r.googlePayConfig!=null?t.googlePayConfig={isAvailable:!0,gateway:r.googlePayConfig.gateway,gatewayId:r.googlePayConfig.gatewayMerchantId,merchantName:r.googlePayConfig.merchantName,merchantId:r.googlePayConfig.merchantId}:t.googlePayConfig={isAvailable:!1,gateway:"",gatewayId:"",merchantName:"",merchantId:""}}return te(t),t.googlePayConfig}function So(e,t){if(e==t.id){let n=t.variants?.findIndex(a=>a.id===e);if(n!=null&&n!=-1){let a=t.variants[n];return{...t,availableQuantity:a.availableQuantity,isDeliverable:a.isDeliverable,images:a.images??t.images,name:t.name+" "+a.name,price:a.price,currency:a.currency,pricing:a.pricing}}return t}let r=t.variants?.find(n=>n.id===e);return r==null?t:{...t,id:r.id,name:t.name+" "+r.name,price:r.price,currency:r.currency,pricing:r.pricing,metadata:t.metadata,availableQuantity:r.availableQuantity,isDeliverable:r.isDeliverable,images:r.images??t.images}}function tt(){let e=O(),t=0;if(e==null){Fe.setState(r=>({...r,numberOfProductsInCart:t}));return}t=e.products?.reduce((r,n)=>r+n.quantity,0)??0,Fe.setState(r=>({...r,numberOfProductsInCart:t}))}var Ro;(n=>{async function e(a,o=1,i,c){let s=nt();if(s==null)throw new Error("No project ID found");let d=await Kt(s).addProduct({productID:a,quantity:o,metadata:i,...c});if(d!=null)return d}n.addProductToCart=e;function t(){Fe.setState({isCartVisible:!0})}n.showCart=t;function r(){Fe.setState({isCartVisible:!1})}n.hideCart=r})(Ro||={});async function Vt(e){let t=nt();if(t==null)throw new Error("No project ID found");e=Jt(e),e.locale??=ce();let r=await fetch(et(t,"/buy"),{method:"POST",headers:{...vt,...It(t),"Content-Type":"application/json"},body:JSON.stringify(e)});if(r.status!=200){if(r.headers.get("Content-Type")?.includes("application/json")){try{let a=await r.json();if("itemIds"in a&&Array.isArray(a.itemIds)){let o=a.itemIds;return J("item-ids-not-found","badInput",o)}}catch{}return J("internal-error","internal")}else console.warn("result",await r.text(),r.status,r.statusText);return J("internal-error","internal")}return{url:(await r.json()).url}}async function _c(e){let t=nt();if(t==null)throw new Error("No project ID found");let r={...vt,...It(t),"Content-Type":"application/json",...e.apiKey!=null?{Authorization:`Bearer ${e.apiKey}`}:{}},n=e.testMode?`/api/payment/link/auto/${t}/test`:`/api/payment/link/auto/${t}`;return delete e.apiKey,delete e.testMode,e.locale??=ce(),{status:"ok",redirectURL:(await(await fetch(Q+n,{method:"POST",headers:r,body:JSON.stringify(e)})).json()).url}}function Pt(){if(typeof localStorage>"u")return;let e=localStorage.getItem("bitsnap-ref");if(e!=null)return e}function Jt(e){let t=Pt();return t==null||(e.metadata==null&&(e.metadata={}),e.metadata.ref=t),e}export{ve as a,de as b,ye as c,Pe as d,At as e,ue as f,kn as g,Dt as h,Se as i,Ze as j,Je as k,Ue as l,ze as m,Br as n,Dn as o,Ht as p,no as q,j as r,fr as s,Gt as t,we as u,Fe as v,Ro as w,Vt as x,_c as y,Pt as z,Jt as A,bo as B,Wt as C,Sc as D,nt as E,Ic as F,Rc as G,Kt as H};
|
|
4
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
</a>`,r)))}})};import{fromJsonString as Ua,toJsonString as Oa}from"@bufbuild/protobuf";import{useAutoAnimate as Da}from"@formkit/auto-animate/react";import{ChevronLeft as Ta,Download as er}from"lucide-react";import{useEffect as tr,useRef as nr,useState as _e}from"react";import Kn from"hls.js";import{Pause as xa,Play as Ca}from"lucide-react";import{forwardRef as Na,useEffect as dt,useImperativeHandle as Sa,useRef as Qe,useState as Me}from"react";function $n(){typeof navigator>"u"||typeof navigator.mediaSession>"u"||(navigator.mediaSession.playbackState="playing")}function Vn(){typeof navigator>"u"||typeof navigator.mediaSession>"u"||(navigator.mediaSession.playbackState="paused")}function Wn(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 Zn(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 Jn(){navigator.mediaSession.metadata=null}import{jsx as ie,jsxs as ut}from"react/jsx-runtime";var Ia=Na(({chapters:e,styles:t,updateCurrentTime:r,setCurrentTimeHandler:n,title:a,imageURL:o,uniqueProductID:i,onChapterChange:c},s)=>{let y;(G=>(G[G.Playing=0]="Playing",G[G.Paused=1]="Paused"))(y||={});let[d,k]=Me(1);dt(()=>{switch(d){case 0:$n();break;case 1:Vn();break}},[d]),Sa(s,()=>({selectChapter:p=>{He(p)}}));let[x,u]=Me(void 0),[h,C]=Me(void 0),l=Qe(null),b=Qe(void 0),R=Qe(void 0),F=Qe(null),q=Qe(null),[A,L]=Me(!0),[j,D]=Me(!1),[H,pe]=Me(!Ra());function U(p){p<10||localStorage.setItem(`__player__${i}_${q.current?.id}`,`${p}`)}function K(){let p=localStorage.getItem(`__player__${i}_${q.current?.id}`);if(p!=null)try{let O=parseInt(p);return isNaN(O)||O<0?void 0:O}catch{return}}function fe(){let p=localStorage.getItem(`__player__${i}_last_chapter`);if(p!=null)return p}function xe(p){localStorage.setItem(`__player__${i}_last_chapter`,p)}function ne(p){localStorage.removeItem(`__player__${i}_${p}`)}function g(){l.current!=null&&(l.current.onloadeddata=()=>{if(l.current!=null){if(l.current.readyState<2&&pe(!0),l.current.readyState>=2&&pe(!1),!j){let p=K();p!=null&&ot(p),D(!0)}if(A){L(!1);try{vt()}catch(p){console.log("play error",p)}}}},l.current.onplay=()=>{},l.current.onseeked=()=>{},l.current.onseeking=()=>{},l.current.onpause=()=>{},l.current.onended=()=>{re()},Zn({title:a??"",artwork:o,action:p=>{switch(p.action){case"play":vt();break;case"pause":wt();break;case"seekbackward":at(-15);break;case"seekforward":at(15);break;case"seekto":p.seekTime&&ot(p.seekTime);break;case"stop":wt();break;default:break}}}),Ce())}function re(){if(e==null||e.length==0)return;let p=e.findIndex(G=>G.id==q.current?.id);p==-1||(ne(e[p].id),p+1>=e.length)||He(e[p+1])}function Ce(){Ie(),R.current==null&&(R.current=setTimeout(()=>{Ie(),R.current=void 0,Ce()},500))}function Be(){R.current!=null&&clearTimeout(R.current)}function Ie(){l.current!=null&&(k(l.current.paused?1:0),C(l.current.duration),u(l.current.currentTime),U(l.current.currentTime),Wn(l.current.duration,l.current.currentTime),l.current.networkState===l.current.NETWORK_LOADING&&l.current.readyState<=l.current.HAVE_FUTURE_DATA?pe(!0):pe(!1),r&&r(l.current.currentTime))}function vt(){l.current?.play().then().catch(),Ie()}function wt(){l.current?.pause(),Ie()}function Rr(){if(d===0){wt();return}vt()}function at(p){if(l.current==null)return;let O=l.current.currentTime+p;if(O<0){l.current.currentTime=0;return}if(O>l.current.duration){l.current.currentTime=l.current.duration;return}l.current.currentTime+=p}function ot(p){if(l.current!=null){if(u(p),p<0){l.current.currentTime=0;return}if(p>l.current.duration){l.current.currentTime=l.current.duration;return}l.current.currentTime=p}}function Ar(){l.current!=null&&(l.current.onplay=null,l.current.onseeked=null,l.current.onseeking=null,l.current.onpause=null,l.current.onended=null,l.current.src="",b.current?.destroy())}function tn(p){if(p.length==0)return;let O=fe();if(O==null){He(p[0]);return}let G=p.find(Re=>Re.id==O);if(G==null){He(p[0]);return}He(G)}function He(p){D(!1),L(!0),q.current=p,Dr(p.publicUrl),c?.(p),xe(p.id)}function Dr(p){l.current!=null&&(l.current.canPlayType("application/vnd.apple.mpegurl")?l.current.src=p:Kn.isSupported()&&(b.current==null&&(b.current=new Kn,b.current?.attachMedia(l.current)),b.current?.loadSource(p)))}dt(()=>{l.current!=null&&(g(),tn(e))},[l.current]),dt(()=>{tn(e)},[e]),dt(()=>(n?.(ot),()=>{u(void 0),l.current?.pause(),Ar(),Jn()}),[]);let nn=p=>{let O=Math.floor(p/3600),G=Math.floor(p/60)%60,Re=Math.floor(p%60),Lr=O>0?O<10?`0${O}:`:`${O}:`:"",Er=Re<10?`0${Re}`:`${Re}`;return isNaN(Re)||isNaN(G)||isNaN(O)?"":`${Lr}${G}:${Er}`},Tr=p=>{let O=parseFloat(p.value)/parseFloat(p.max)*100;F.current.style.setProperty("--seek-before-width",O+"%");let G=h*O/100;ot(G)};return ut("div",{id:"audio-player-container",className:"flex flex-col",style:t,ref:F,children:[ie("video",{ref:l,className:"hidden",poster:o,title:a}),ie("input",{type:"range",min:"0",max:h!=null?Math.floor(h).toString():100,value:x??0,onChange:p=>Tr(p.target),className:"w-full"}),ut("section",{className:"flex w-full items-center justify-between text-sm font-medium",children:[ie("span",{id:"current-time",children:nn(x)}),ie("span",{id:"duration",children:nn(h)})]}),ut("div",{className:"mt-6 flex items-center justify-center gap-x-12",children:[ie(I,{variant:"outline",onClick:()=>at(-10),"aria-label":"Rewind 10 Seconds",children:"-10"}),ut(I,{variant:"outline",onClick:Rr,"aria-label":"Play Or Pause",children:[d===1&&ie(Ca,{className:"h-5 w-5"}),d===0&&ie(xa,{className:"h-5 w-5"})]}),ie(I,{variant:"outline",onClick:()=>at(10),"aria-label":"Fast Forward 10 Seconds",children:"+10"})]}),H&&ie("div",{className:"mt-2 flex w-full justify-center",children:ie(V,{})})]})});function Ra(){return navigator.userAgent.toLowerCase().indexOf("safari/")>-1}var Qn=Ia;var Aa={pl:{returnsNavLabel:"Zwroty",openCourse:"Otw\xF3rz kurs"},en:{returnsNavLabel:"Returns",openCourse:"Open the course"}};function Ye(e=ce()){return gn(Aa,e)}import*as mt from"react";import{jsx as Yn}from"react/jsx-runtime";function Xn(){let[e,t]=mt.useState(13);return mt.useEffect(()=>{let r=setTimeout(()=>t(66),500);return()=>clearTimeout(r)},[]),Yn("div",{className:"w-[60%] h-2 bg-gray-200 rounded-full overflow-hidden",children:Yn("div",{className:"h-full bg-blue-600 transition-all duration-300",style:{width:`${e}%`}})})}import{Fragment as pt,jsx as P,jsxs as M}from"react/jsx-runtime";function me(e,...t){console.warn(e,...t)}function Ft(e){console.error(e)}var La=({accessToken:e,product:t,styles:r,reveal:n,onOpenCourse:a})=>{let o=t.productType,i=st(),c=()=>i.track("panel_download",{},{product_id:t.productId.length<=64?t.productId:null}),s=nr(null),[y]=Da(),[d,k]=_e(null),{mutateAsync:x,isPending:u}=Y(B.publicApi.userPanelGetFileDetails),h=nr(void 0),[C,l]=_e(null),[b,R]=_e(null),[F,q]=_e(!1),{mutateAsync:A,isPending:L}=Y(B.publicApi.userPanelGetAudiobookDetails),{mutateAsync:j,isPending:D}=Y(B.publicApi.userPanelGetAudiobookDetailsDownloadURLs),[H,pe]=_e(null),[U,K]=_e(null);async function fe(){try{let g=await x({accessId:t.accessId,accessToken:e});if(g.result.case==="success"){k(g.result.value.files);return}else me("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),me("Kod b\u0142\u0119du: ",g.result.value)}catch(g){me("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),Ft("B\u0142\u0105d podczas pobierania danych:"+g)}}async function xe(){try{let g=await A({accessId:t.accessId,accessToken:e});if(g.result.case==="audiobook"){l(g.result.value);return}else me("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),me("Kod b\u0142\u0119du: ",g.result.value)}catch(g){me("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),Ft("B\u0142\u0105d podczas pobierania danych:"+g)}}async function ne(){try{let g=await j({accessId:t.accessId,accessToken:e,isBrowser:!0});if(g.result.case==="success"){R(g.result.value.audiobookDownloadDetails),q(g.result.value.isAvailableToDownloadInMobileApp===!0);return}else me("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),me("Kod b\u0142\u0119du: ",g.result.value)}catch(g){me("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),Ft("B\u0142\u0105d podczas pobierania danych:"+g)}}return tr(()=>{o===1&&(xe().then().catch(),ne().then().catch())},[]),tr(()=>{if(C!=null&&b!=null){let g=C.chapters;if(!g)return;let re=g.map(Ce=>{let Be=b?.find(Ie=>Ie.chapterId===Ce.id);if(Be!=null)return{...Ce,publicUrl:Be.publicUrl,downloadableUrl:Be.downloadableUrl,duration:Be.duration}}).filter(Ce=>Ce!=null);re!=null&&re.length>0&&K(re)}},[C,b]),M("div",{children:[P("div",{className:"mb-3 space-y-4 rounded bg-white p-4 dark:bg-black",children:M(I,{onClick:()=>n(),variant:"ghost",className:"w-fit",children:[P(Ta,{className:"h-6 w-6"}),P("span",{className:"font-inter text-sm font-medium",children:"Wr\xF3\u0107"})]})}),M("main",{className:"grid grid-cols-1 justify-center gap-6 sm:justify-start lg:grid-cols-2",children:[M("div",{className:"flex w-full max-w-xl flex-col gap-6",children:[o===2&&M("div",{ref:y,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:[M("div",{className:"flex items-center justify-between gap-x-4",children:[P("h4",{className:"text-xl font-semibold",children:"Twoje pliki"}),(d==null||d.length==0)&&P(I,{onClick:fe,"aria-label":"Download Product",className:"text-sm font-medium transition-opacity duration-300 ease-in-out hover:opacity-80 active:opacity-80",style:r,children:u?P(V,{}):"Wy\u015Bwietl"})]}),u&&M("div",{className:"flex flex-col items-start gap-2",children:[P(Xn,{}),P("p",{className:"font-bold transition hover:text-blue-600",children:"Trwa przygotowanie plik\xF3w..."})]}),d!=null&&d.length>0&&P("div",{className:"flex flex-col items-start justify-start gap-2",children:d.map((g,re)=>M("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:g,download:!0,onClick:c,children:[`Plik numer ${re+1}`,P(er,{width:14,height:14})]},re))})]}),o===4&&P("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:P(I,{onClick:()=>a(t.accessId),className:"text-sm font-medium transition-opacity duration-300 ease-in-out hover:opacity-80 active:opacity-80",style:r,children:Ye().openCourse})}),o===1&&P(pt,{children:M("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:[P("h4",{className:"text-xl font-semibold",children:H?.name??"Odtwarzacz"}),H?.description&&P("p",{className:"text-sm",children:H?.description}),P(pt,{children:L?M("div",{className:"flex gap-2",children:[P(V,{}),P("p",{className:"text-xl font-semibold",children:"Trwa pobierania audiobooka..."})]}):P(pt,{children:U!=null?P(pt,{children:P(Qn,{ref:s,chapters:U,title:C?.name??t.productName??void 0,imageURL:C?.coverImage??t.productImageUrl??void 0,styles:r,setCurrentTimeHandler:g=>{h.current=g},uniqueProductID:t.productId,onChapterChange:g=>{pe(g)}})}):P("p",{className:"mt-2",children:"Wybierz rozdzia\u0142, kt\xF3ry ci\u0119 interesuje."})})}),M("div",{className:"rounded-xl bg-neutral-100 p-3 dark:bg-neutral-800",children:[P("p",{className:"mt-3 mb-3 text-xs",children:F?"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."}),M("div",{className:"flex gap-3",children:[P("a",{href:"https://apps.apple.com/us/app/bitsnap/id6741902807",children:P("img",{width:"100",src:"https://bitsnap.pl/appstore.svg",alt:"Pobierz aplikacje z AppStore"})}),P("a",{href:"https://docs.bitsnap.pl/guides/audiobook",children:P("img",{width:"100",src:"https://bitsnap.pl/playstore.svg",alt:"Pobierz aplikacj\u0119 z GooglePlay"})})]})]})]})}),P("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:o===1&&P("div",{className:"max-h-96 w-full overflow-y-auto",children:L?M("div",{className:"jusitfy-center flex flex-col items-center gap-2",children:[P(V,{}),P("p",{children:"\u0141adowanie rozdzia\u0142\xF3w..."})]}):M("div",{children:[P("h2",{className:"mb-3 text-xl font-semibold",children:"Rozdzia\u0142y"}),U==null?P("p",{children:"Brak rozdzia\u0142\xF3w do wy\u015Bwietlenia."}):P("ul",{className:"flex w-full flex-col gap-2",children:U.map((g,re)=>M("li",{className:"flex items-center justify-between",children:[M("button",{className:w("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",H?.id==g.id?"bg-neutral-200 dark:bg-neutral-700":"bg-neutral-100 dark:bg-neutral-800 dark:text-neutral-300"),onClick:()=>{s.current.selectChapter(g)},children:[M("div",{className:"flex items-center justify-between",children:[P("p",{className:"text-sm font-medium",children:g.name}),g.duration&&M("span",{className:"text-xs text-neutral-500",children:[Math.floor(g.duration/60),":",String(Math.floor(g.duration%60)).padStart(2,"0")]})]}),g.description&&P("p",{className:"mt-3 text-xs",children:g.description})]}),C&&C.isDownloadable&&g.downloadableUrl&&P("a",{href:g.downloadableUrl,onClick:c,children:P(er,{width:14,height:14})})]},re))})]})})})]}),M("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:[P("h2",{className:"text-3xl font-semibold",children:t.productName}),P("p",{className:"text-sm font-normal text-neutral-600 dark:text-neutral-300",children:t.productDescription}),P("img",{src:t.productImageUrl,alt:"Product Photo",width:384,height:384,className:"max-h-sm max-w-sm",draggable:!1})]})]})]})},rr=La;import{Fragment as _a,jsx as $,jsxs as Xe}from"react/jsx-runtime";var za=({accessToken:e,projectID:t,loginURL:r,styles:n,activeScreen:a,params:o,setParams:i,openCourse:c})=>{let{data:s,isLoading:y}=De(B.publicApi.userPanelGetProducts,{accessToken:e});if(y)return Xe("div",{className:"flex items-center gap-2 bg-white p-2 dark:bg-black",children:[$("p",{className:"text-dark font-inter font-medium dark:text-white",children:"\u0141adowanie..."}),$(V,{})]});if(s&&s.result.case==="failure")return console.warn("error:",`Kod b\u0142\u0119du: ${s.result.value}`),Te(t),window.location.href=r,null;let d=s&&s.result.case==="success"?s.result.value.products:[];return $(Ma,{accessToken:e,products:d,styles:n,loginURL:r,activeScreen:a,params:o,setParams:i,openCourse:c})},ar=za,Ma=({accessToken:e,products:t,styles:r,loginURL:n,activeScreen:a,params:o,setParams:i,openCourse:c})=>{if(t.length===0)return window.location.href=n,null;let[s,y]=Ea(o.product?Ua(Rt,o.product):void 0),d=u=>{u==null?(y(void 0),i({product:void 0,state:"products"})):i({product:Oa(Rt,u),state:"products"})};function k(u){switch(u){case 1:return"Audio";case 2:return"Plik";case 3:return"Bilet";case 4:return"Kurs";default:return}}function x(u){if(u.productType===4){c(u.accessId);return}y(u),d(u)}return a==="products"&&s!=null?$(rr,{accessToken:e,product:s,styles:r,reveal:d,onOpenCourse:c}):Xe(_a,{children:[$("h3",{className:"text-2xl",children:"Hej \u{1F44B}"}),$("p",{className:"text-sm text-neutral-500",children:"Poni\u017Cej znajdziesz swoje produkty"}),$("div",{className:"mt-6 flex flex-wrap items-center justify-center gap-9 sm:justify-start",children:t?.map((u,h)=>Xe("section",{onClick:()=>x(u),className:"w-full max-w-xs cursor-pointer rounded drop-shadow-xl dark:border dark:border-slate-600 dark:drop-shadow-none",children:[Xe("section",{className:"flex flex-col items-center space-y-2 rounded bg-slate-100 p-4 dark:bg-neutral-900",children:[u.productType&&$("div",{className:"w-fit self-end rounded bg-red-900 px-4 py-1",children:$("span",{className:"text-sm font-medium text-white dark:text-slate-100",children:k(u.productType)})}),$("div",{className:"jusitfy-center flex max-h-40 items-center",children:$("img",{src:u.productImageUrl,alt:`Product ${h} Photo`,draggable:!1,className:"aspect-auto max-h-40"})})]}),Xe("div",{className:"space-y-4 rounded bg-white p-4 dark:bg-black",children:[$("h2",{className:"text-xl font-semibold",children:u.productName}),$("p",{title:u.productDescription,className:"line-clamp-3 text-sm font-normal text-neutral-600 dark:text-neutral-300",children:Gn(u.productDescription)}),$(I,{onClick:C=>{C.stopPropagation(),x(u)},className:"w-full text-sm font-medium transition-opacity duration-300 ease-in-out hover:opacity-80 active:opacity-80",style:r,children:"Zobacz"})]})]},h))})]})};import{useAutoAnimate as ja}from"@formkit/auto-animate/react";import{LogOut as Fa,Undo2 as ir}from"lucide-react";import{useState as qa}from"react";import{Fragment as lr,jsx as S,jsxs as se}from"react/jsx-runtime";function Ba({activeScreen:e,setActiveScreen:t,setParams:r,styles:n,theme:a,logout:o}){return se("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:[S(Ha,{activeScreen:e,setActiveScreen:t,setParams:r}),S(Ga,{activeScreen:e,setActiveScreen:t,setParams:r,theme:a,logout:o})]})}var sr=Ba;function Ha({activeScreen:e,setActiveScreen:t,setParams:r}){let{returnsNavLabel:n}=Ye();return se("nav",{className:"flex w-full items-center justify-evenly gap-4 md:hidden",children:[S(ft,{panelScreen:"products",label:"Produkty",imageURL:"/icons/bitsnap-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:r}),S(ft,{panelScreen:"orders",label:"Faktury",imageURL:"/icons/category-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:r}),S(ft,{panelScreen:"returns",label:n,icon:S(ir,{className:"h-5 w-5 text-white","aria-hidden":!0}),activeScreen:e,setActiveScreen:t,setParams:r}),S(ft,{panelScreen:"profile",label:"Profil",imageURL:"/icons/profile-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:r})]})}function ft({panelScreen:e,label:t,imageURL:r,icon:n,activeScreen:a,setActiveScreen:o,setParams:i}){return se(I,{onClick:()=>{o(e),i({product:void 0,state:e})},"aria-label":t,variant:null,className:w("flex flex-col gap-0",a===e?"opacity-100":"opacity-50"),children:[n??S("img",{src:r,alt:t,className:"scale-75"}),S("span",{className:"text-xs font-normal text-white",children:t})]})}function gt({panelScreen:e,label:t,imageURL:r,darkImageURL:n,icon:a,activeScreen:o,setActiveScreen:i,setParams:c,isExpanded:s}){return se(I,{onClick:()=>{i(e),c({product:void 0,state:e})},variant:o===e?"secondary":"ghost",className:"justify-start",children:[a!=null?S("span",{className:w("inline-flex h-5 w-5 items-center justify-center",s?"mr-4":"mr-2"),children:a}):se(lr,{children:[S("img",{src:r,alt:t,className:w("aspect-auto h-5 w-5 dark:hidden",s?"mr-4":"mr-2")}),S("img",{src:n,alt:t,className:w("hidden aspect-auto h-5 w-5 dark:inline",s?"mr-4":"mr-2")})]}),s&&S("span",{className:"md:text-medium hidden md:inline",children:t})]})}function Ga({activeScreen:e,setActiveScreen:t,setParams:r,theme:n,logout:a}){let[o]=ja(),[i,c]=qa(!0),{returnsNavLabel:s}=Ye();return se("div",{ref:o,className:w("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:[S("div",{className:"flex items-center justify-between",children:S($a,{theme:n,isExpanded:i})}),S(or,{className:"my-6"}),se("div",{className:"flex flex-1 flex-col gap-2",children:[S(gt,{panelScreen:"products",label:"Produkty",imageURL:"/icons/bitsnap-dark-24x24.svg",darkImageURL:"/icons/bitsnap-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:r,isExpanded:i}),S(gt,{panelScreen:"orders",label:"Zam\xF3wienia",imageURL:"/icons/category-dark-24x24.svg",darkImageURL:"/icons/category-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:r,isExpanded:i}),S(gt,{panelScreen:"returns",label:s,icon:S(ir,{className:"h-5 w-5","aria-hidden":!0}),activeScreen:e,setActiveScreen:t,setParams:r,isExpanded:i}),S(gt,{panelScreen:"profile",label:"Profil",imageURL:"/icons/profile-dark-24x24.svg",darkImageURL:"/icons/profile-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:r,isExpanded:i})]}),S(or,{className:"mb-6"}),se(I,{onClick:a,children:[S(Fa,{className:"mr-2",width:16,height:16}),i&&S("p",{className:"md:text-medium hidden md:inline md:text-center",children:"Wyloguj si\u0119"})]})]})}function or({className:e}){return se("div",{className:w("relative h-px w-full bg-neutral-300",e),children:[S("div",{className:"absolute -top-px left-0 h-1 w-1 rounded-full bg-neutral-500"}),S("div",{className:"absolute -top-px right-0 h-1 w-1 rounded-full bg-neutral-500"})]})}function $a({theme:e,isExpanded:t}){return se(lr,{children:[e==null&&S("p",{className:"text-xl tracking-wider md:inline dark:text-neutral-200",children:"bitsnap."}),(e?.logoDarkURL||e?.logoURL)&&S("img",{src:e.logoDarkURL??e.logoURL,alt:"Company Logo",className:"hidden h-6 w-6 dark:inline",draggable:!1}),e?.logoURL&&S("img",{src:e.logoURL,alt:"Company Logo",className:"h-6 w-6 dark:hidden",draggable:!1})]})}import{LogOut as Va}from"lucide-react";import{Fragment as Za,jsx as je,jsxs as qt}from"react/jsx-runtime";function Wa({email:e,logout:t}){return qt(Za,{children:[je("h3",{className:"text-2xl",children:"Profil"}),qt("div",{className:"mt-6 flex-1 md:flex-none",children:[je("span",{className:"text-sm text-neutral-500",children:"Email"}),je("p",{className:"mt-2 text-base",children:e||"Brak danych"})]}),je("div",{className:"flex w-full flex-col items-center space-y-2",children:qt(I,{onClick:t,className:"max-w-64 md:hidden",children:[je(Va,{className:"mr-2",width:16,height:16}),je("p",{className:"text-medium inline text-center",children:"Wyloguj si\u0119"})]})})]})}var cr=Wa;import{lazy as Ja,Suspense as Ka}from"react";import{jsx as yt}from"react/jsx-runtime";var Qa=Ja(()=>import("./course.mjs").then(e=>({default:e.PanelCourse})));function Bt(e){return yt(Ka,{fallback:yt("div",{className:"flex items-center gap-2 p-2",role:"status",children:yt(V,{})}),children:yt(Qa,{...e})})}import{AlertCircle as fr,CheckCircle2 as dr,ChevronLeft as Ya,Loader2 as Gt,Lock as ur,Package as Xa,Truck as gr}from"lucide-react";import{useEffect as eo,useState as Ht}from"react";import{Fragment as yr,jsx as m,jsxs as f}from"react/jsx-runtime";function to({status:e}){let t={created:{color:"bg-neutral-100 text-neutral-700",icon:null},paid:{color:"bg-green-100 text-green-700",icon:dr},completed:{color:"bg-blue-100 text-blue-700",icon:dr},canceled:{color:"bg-red-100 text-red-700",icon:fr},sent:{color:"bg-purple-100 text-purple-700",icon:gr},processing:{color:"bg-yellow-100 text-yellow-700",icon:Gt}},r=t[e]||t.created,n=r.icon,a={created:"Utworzone",paid:"Op\u0142acone",completed:"Zako\u0144czone",canceled:"Anulowane",sent:"Wys\u0142ane",processing:"Przetwarzane"};return f("span",{className:`inline-flex items-center gap-1 rounded-full px-3 py-1 text-sm font-medium ${r.color}`,children:[n&&m(n,{className:"h-4 w-4"}),a[e]||e]})}function no({orderID:e,email:t}){let[r,n]=Ht(""),a=Y(B.publicApi.addPublicOrderComment);return f("form",{onSubmit:async i=>{if(i.preventDefault(),!!r.trim())try{await a.mutateAsync({projectId:"",orderId:e,message:r.trim(),accessToken:t}),n("")}catch(c){console.error("Failed to add comment:",c)}},className:"mt-4 space-y-2",children:[m(Ne,{htmlFor:"comment",children:"Dodaj komentarz"}),m(mn,{id:"comment",value:r,onChange:i=>n(i.target.value),placeholder:"Wpisz komentarz...",rows:3,disabled:a.isPending}),m(I,{type:"submit",disabled:!r.trim()||a.isPending,children:a.isPending?f(yr,{children:[m(Gt,{className:"mr-2 h-4 w-4 animate-spin"}),"Wysy\u0142anie..."]}):"Dodaj komentarz"})]})}function mr(e){return e?new Date(Number(e.seconds)*1e3).toLocaleDateString("pl-PL",{year:"numeric",month:"long",day:"numeric"}):"N/A"}function pr(e,t){return new Intl.NumberFormat("pl-PL",{style:"currency",currency:t.toUpperCase()}).format(e/100)}function ro({orderID:e,initialEmail:t,onBack:r,accessToken:n,analytics:a}){let{theme:o,projectID:i}=ge(),c=Ae(i,a,"order"),[s,y]=Ht(t||""),[d,k]=Ht(!1),{data:x,isLoading:u,error:h,refetch:C}=De(B.publicApi.getPublicOrderDetails,{projectId:i??"",orderId:e,email:s||void 0,accessToken:n},{enabled:!!e}),l=x?.result.case==="order"?x.result.value:null,b=l?.isVerified??!1,R=l!=null;eo(()=>{R&&c.track("panel_order_viewed",{},{order_ref:null})},[c,R]);let F=()=>{C(),k(!1)},q={"--button-background-color":o?.colors?.brand??"#000000","--button-background-color-dark":o?.colors?.brandDark??"#ffffff","--button-text-color":o?.colors?.brandDark??"#000000","--button-text-color-dark":o?.colors?.brand??"#000000"};return u?m("div",{className:"flex min-h-screen items-center justify-center",children:f("div",{className:"text-center",children:[m(Gt,{className:"mx-auto h-8 w-8 animate-spin text-neutral-400"}),m("p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"\u0141adowanie zam\xF3wienia..."})]})}):h||!l?m("div",{className:"flex min-h-screen items-center justify-center",children:m(de,{className:"w-full max-w-md",children:m(ue,{className:"pt-6",children:f("div",{className:"text-center",children:[m(fr,{className:"mx-auto h-12 w-12 text-red-500"}),m("h2",{className:"mt-4 text-xl font-semibold",children:"Zam\xF3wienie nie znalezione"}),m("p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"Nie znaleziono zam\xF3wienia o podanym numerze."})]})})})}):m("div",{className:"w-full bg-white py-8 dark:bg-black",style:q,children:f("div",{className:"w-full px-4",children:[r&&f(I,{onClick:r,variant:"ghost",className:"mb-4 w-fit",children:[m(Ya,{className:"h-4 w-4"}),"Wr\xF3\u0107 do historii zam\xF3wie\u0144"]}),f("div",{className:"mb-6 flex items-center gap-4",children:[o?.logoURL&&f(yr,{children:[m("img",{src:o.logoURL,alt:"Project logo",className:`h-12 w-auto ${o.logoDarkURL?"dark:hidden":""}`}),o.logoDarkURL&&m("img",{src:o.logoDarkURL,alt:"Project logo",className:"hidden h-12 w-auto dark:block"})]}),f("div",{children:[m("h1",{className:"text-3xl font-bold",children:"Zam\xF3wienie"}),f("p",{className:"text-neutral-600 dark:text-neutral-400",children:["Numer zam\xF3wienia: #",l.orderId]})]})]}),f(de,{className:"mb-6",children:[m(ye,{children:f(be,{className:"flex items-center",children:[m(Xa,{className:"mr-2 h-5 w-5"}),"Status zam\xF3wienia"]})}),f(ue,{className:"space-y-6",children:[f("div",{children:[f("div",{className:"flex items-center gap-2",children:[m(to,{status:l.status}),l.processingStatus&&f("span",{className:"text-sm text-neutral-600",children:["\xB7 ",l.processingStatus]})]}),f("p",{className:"mt-2 text-sm text-neutral-600",children:["Zam\xF3wienie z\u0142o\u017Cone ",mr(l.createdAt)]})]}),f("div",{className:"border-t pt-4",children:[m("h3",{className:"mb-3 font-semibold",children:"Dane klienta"}),f("div",{className:"space-y-2",children:[f("div",{children:[m("span",{className:"font-medium",children:"Imi\u0119 i nazwisko:"})," ",m("span",{className:b?"":"text-neutral-500",children:l.customerName})]}),f("div",{children:[m("span",{className:"font-medium",children:"Email:"})," ",m("span",{className:b?"":"text-neutral-500",children:l.customerEmail})]}),l.customerPhone&&f("div",{children:[m("span",{className:"font-medium",children:"Telefon:"})," ",m("span",{className:b?"":"text-neutral-500",children:l.customerPhone})]})]})]}),!b&&m("div",{className:"border-t pt-4",children:f(I,{onClick:()=>k(!0),variant:"outline",className:"w-full",children:[m(ur,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),f(de,{className:"mb-6",children:[m(ye,{children:m(be,{children:"Produkty"})}),f(ue,{className:"space-y-6",children:[m("div",{className:"space-y-4",children:l.items.map((A,L)=>f("div",{className:"flex items-center gap-4",children:[A.imageUrl&&m("img",{src:A.imageUrl,alt:A.name,className:"h-16 w-16 rounded object-cover"}),f("div",{className:"flex-1",children:[m("p",{className:"font-medium",children:A.name}),f("p",{className:"text-sm text-neutral-600",children:["Ilo\u015B\u0107: ",A.quantity]})]}),m("div",{className:"text-right",children:m("p",{className:"font-medium",children:pr(Number(A.price),A.currency)})})]},L))}),(l.deliveryAddress||l.deliveryMethod)&&f("div",{className:"border-t pt-4",children:[f("h3",{className:"mb-3 flex items-center font-semibold",children:[m(gr,{className:"mr-2 h-5 w-5"}),"Informacje o dostawie"]}),f("div",{className:"space-y-2",children:[l.deliveryAddress&&f("div",{children:[m("span",{className:"font-medium",children:"Adres:"})," ",m("span",{className:b?"":"text-neutral-500",children:l.deliveryAddress})]}),l.deliveryMethod&&f("div",{children:[m("span",{className:"font-medium",children:"Metoda:"})," ",l.deliveryMethod]}),l.trackingNumber&&b&&f("div",{children:[m("span",{className:"font-medium",children:"Tracking:"})," ",l.trackingNumber]})]})]}),m("div",{className:"border-t pt-4",children:f("div",{className:"flex justify-between text-lg font-bold",children:[m("span",{children:"Suma:"}),m("span",{children:pr(Number(l.totalAmount),l.currency)})]})})]})]}),f(de,{children:[m(ye,{children:f(be,{children:["Komentarze ",l.commentCount>0&&`(${l.commentCount})`]})}),f(ue,{children:[l.comments.length>0?m("div",{className:"space-y-4",children:l.comments.map(A=>f("div",{className:"border-b pb-4 last:border-b-0",children:[f("div",{className:"mb-1 flex items-center gap-2",children:[m("span",{className:"font-medium",children:A.authorName||"System"}),m("span",{className:"text-xs text-neutral-500",children:mr(A.createdAt)}),A.authorType==="admin"&&m("span",{className:"rounded bg-blue-100 px-2 py-0.5 text-xs text-blue-700",children:"Admin"})]}),m("p",{className:b?"":"text-neutral-500",children:A.message})]},A.id))}):m("p",{className:"text-neutral-600",children:"Brak komentarzy."}),b?m(no,{orderID:l.orderId,email:s}):m("div",{className:"mt-4",children:f(I,{onClick:()=>k(!0),variant:"outline",className:"w-full",children:[m(ur,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),d&&m("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:f(de,{className:"w-full max-w-md",children:[m(ye,{children:m(be,{children:"Zweryfikuj sw\xF3j email"})}),f(ue,{className:"space-y-4",children:[m("p",{className:"text-sm text-neutral-700",children:"Podaj adres email u\u017Cyty przy sk\u0142adaniu zam\xF3wienia."}),f("div",{className:"space-y-2",children:[m(Ne,{htmlFor:"verify-email",children:"Adres email"}),m(lt,{id:"verify-email",type:"email",placeholder:"twoj@email.com",value:s,onChange:A=>y(A.target.value)})]}),f("div",{className:"flex gap-2",children:[m(I,{variant:"outline",onClick:()=>k(!1),className:"flex-1",children:"Anuluj"}),m(I,{onClick:F,className:"flex-1",children:"Zweryfikuj"})]})]})]})})]})})}function ao(e){return m(ro,{...e})}var $t=ao;import{jsx as le,jsxs as br}from"react/jsx-runtime";var so=({returnsAppearance:e,returnsTexts:t,analytics:r}={})=>{let{projectID:n,theme:a,loginURL:o,host:i}=ge(),c=Ae(n,r,"panel"),s=Ve(n,i),y=dn(n,i),{mutateAsync:d}=Y(B.publicApi.userPanelLogout);async function k(){s&&await d({accessToken:s}),typeof window<"u"&&(Te(n,i),window.location.reload())}let[x]=oo(),u=D=>["products","notifications","profile","plans","orders","order-details","returns","return-details","course"].includes(D),[h,C]=Tn({product:void 0,state:"products",orderId:void 0,returnId:void 0,course:void 0,item:void 0}),[l,b]=io(u(h.state)?h.state:"products"),R=D=>{C({state:"order-details",orderId:D}),b("order-details")},F=()=>{C({state:"orders",orderId:void 0}),b("orders")},q=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}),b("course")},L=()=>{C({state:"products",course:void 0,item:void 0,product:void 0}),b("products")};bt(()=>{u(h.state)&&(h.state==="course"||l==="course")&&b(h.state)},[h.state]);let j={"--button-background-color":a?.colors?.brand??"#000000","--button-background-color-dark":a?.colors?.brandDark??"#ffffff","--button-text-color":a?.colors?.brandDark??"#000000","--button-text-color-dark":a?.colors?.brand??"#000000"};return bt(()=>{if(s==null||s.length===0){window.location.href=o??"/panel/login";return}},[]),bt(()=>{if(s==null||s.length===0){window.location.href=o??"/panel/login";return}},[l]),bt(()=>{if(typeof window>"u"||window.parent!==window||!s)return;let D=Ze(window.location.search);D&&Je(D);let H=D??Ue();H&&(window.location.href=Oe(H,s))},[s]),le(it,{value:c,children:br("div",{ref:x,className:"font-inter relative min-h-screen w-screen bg-beige-100 text-black dark:bg-black dark:text-white md:flex",children:[le(sr,{activeScreen:l,setActiveScreen:b,setParams:q,styles:j,theme:a,logout:k}),br("main",{className:"flex h-[calc(100vh-80px)] flex-col overflow-y-auto w-full p-5 md:h-screen",children:[l==="products"&&le(ar,{projectID:n??"",accessToken:s,loginURL:o??"/panel/login",styles:j,activeScreen:l,params:h,setParams:C,openCourse:A}),l==="course"&&h.course&&s&&le(Bt,{accessId:h.course,accessToken:s,theme:a,itemId:h.item,onItemChange:D=>C({item:D}),onBack:L}),l==="notifications"&&le(On,{}),l==="plans"&&le(Hn,{projectID:n??""}),l==="orders"&&le(Fn,{projectID:n??"",accessToken:s??"",openOrderDetails:R}),l==="order-details"&&h.orderId&&le($t,{orderID:h.orderId,onBack:F}),(l==="returns"||l==="return-details")&&s&&le(jt,{projectID:n??"",host:i,accessToken:s,loginURL:o??"/panel/login",appearance:Ln(e,a?.colors?.brand),texts:t,screen:l,params:h,setParams:C,setActiveScreen:b}),l==="profile"&&le(cr,{email:y,logout:k})]})]})})},lo=so;import{create as ke}from"@bufbuild/protobuf";import{QueryClient as ho,QueryClientProvider as vo}from"@tanstack/react-query";import{createContext as wo,useContext as ko,useEffect as xo}from"react";import{createClient as co}from"@connectrpc/connect";import{createConnectTransport as uo}from"@connectrpc/connect-web";var ve;(n=>{function e(a){return co(an,r(a))}n.get=e;let t=new Map;function r(a){let o=t.get(a);return o==null&&(o=uo({useBinaryFormat:!0,baseUrl:a+"/api/rpc",interceptors:[rn]}),t.set(a,o)),o}})(ve||={});import T from"zod";import Z from"zod";function _(e,t=2){return+(Math.round(+(e+"e+"+t))+"e-"+t)}function Pr(e,t){let r=typeof navigator>"u"?"pl-PL":navigator.language;return Intl.NumberFormat(r,{style:"currency",currency:t,currencyDisplay:"symbol"}).format(e/100)}var dc=Z.object({event:Z.enum(["purchase","addToCart","customizeProduct","viewCart","removeFromCart","initiateCheckout","lead"]),step:Z.string().optional(),value:Z.number().optional(),currency:Z.string().optional(),content_name:Z.string().optional(),items:Z.array(Z.object({id:Z.string(),name:Z.string(),price:Z.number().default(0),currency:Z.string().default("PLN"),quantity:Z.number().default(1)})).optional()});function Vt(e){typeof window>"u"||(mo(e),fo(e),go(e))}function mo(e){try{typeof window.dataLayer>"u"&&(window.dataLayer=[]);let t=po(e);window.dataLayer.push(t)}catch(t){console.warn("cannot send google analytics event",t)}}function po(e){let t=e.value??e.items?.reduce((o,i)=>o+(i.price||0)*(i.quantity||1),0)??0,r=e.items?.map(o=>({item_id:o.id,item_name:o.name||o.id,price:_((o.price||0)/100,2),quantity:o.quantity||1})),n={currency:e.currency||"PLN",value:_(t/100,2)};r&&r.length>0&&(n.items=r);let a;switch(e.event){case"purchase":a="purchase",n.transaction_id=e.step||`txn_${Date.now()}`;break;case"addToCart":a="add_to_cart";break;case"viewCart":a="view_cart";break;case"removeFromCart":a="remove_from_cart";break;case"initiateCheckout":a="begin_checkout";break;case"customizeProduct":a="customize_product";break;default:a=e.event}return{event:a,ecommerce:n,...e.step&&{step:e.step},...e.content_name&&{content_name:e.content_name}}}function fo(e){if(typeof window.fbq>"u")return;let t="",r="",n={};switch(e.event){case"purchase":t="track",r="Purchase",n={category_name:e.step,...e};break;case"lead":t="track",r="Lead",n={category_name:e.step,...e};break;case"addToCart":t="track",r="Add to Cart",n={category_name:e.step,...e};break;case"customizeProduct":t="track",r="Customize Product",n={category_name:e.step,...e};break;case"viewCart":t="track",r="View Cart",n={category_name:e.step,...e};break;case"removeFromCart":t="track",r="Remove from Cart",n={category_name:e.step,...e};break;case"initiateCheckout":t="track",r="Initiate Checkout",n={category_name:e.step,...e};break;default:break}window.location.search.includes("analytics")&&console.log("Pushing FB event",t,r,n),window.fbq(t,r,n)}function go(e){try{if(typeof window.ttq>"u")return;let t=yo(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 yo(e){let t=e.value??e.items?.reduce((o,i)=>o+(i.price||0)*(i.quantity||1),0)??0,r=e.items?.map(o=>({content_id:o.id,content_type:"product",content_name:o.name||o.id,quantity:o.quantity||1,price:_((o.price||0)/100,2)}))||[];r.length===0&&e.content_name&&r.push({content_id:e.step||"unknown",content_type:"product",content_name:e.content_name,quantity:1,price:_(t/100,2)});let n={currency:e.currency||"PLN",value:_(t/100,2)};r.length>0&&(n.contents=r);let a=null;switch(e.event){case"purchase":a="Purchase";break;case"addToCart":a="AddToCart";break;case"initiateCheckout":a="InitiateCheckout";break;case"customizeProduct":a="CustomizeProduct";break;case"viewCart":return;case"removeFromCart":return;case"lead":return;default:return null}return{eventName:a,eventPayload:n}}function hr(e){let{items:t,googlePayConfig:r,checkout:n,result:a,cartRequiresShipping:o}=e;if(a.totalAmount==null)return;let i=[];return o&&(i.push("SHIPPING_ADDRESS"),i.push("SHIPPING_OPTION")),{apiVersion:2,apiVersionMinor:0,callbackIntents:i,allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:["MASTERCARD","VISA"]},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:r.gateway,gatewayMerchantId:r.gatewayId}}}],emailRequired:!0,shippingAddressParameters:{phoneNumberRequired:o},shippingAddressRequired:o,shippingOptionRequired:o,shippingOptionParameters:o?{shippingOptions:a.methods.slice(0,5).map(s=>({id:s.id,label:s.name+` - ${Pr(s.amount,a.currency)}`,description:s.description??""})),defaultSelectedOptionId:a.selectedDeliveryMethod}:void 0,merchantInfo:{merchantId:r.merchantId+"",merchantName:r.merchantName},transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:"P\u0142atno\u015B\u0107 za koszyk",totalPrice:`${_(a.totalAmount/100,2)}`,currencyCode:a.currency,countryCode:a.country,checkoutOption:"COMPLETE_IMMEDIATE_PURCHASE",displayItems:bo(t,a.methods,a.selectedDeliveryMethod??(a.methods.length>0?a.methods[0].id:void 0),n.couponCode,a.couponValue)}}}function bo(e,t,r,n,a){let o=[],i=0;for(let s of e)s.details!=null&&(i+=s.details.price*s.quantity,o.push({label:s.details.name+" x "+s.quantity,price:`${_(s.details.price/100,2)}`,type:"LINE_ITEM",status:"FINAL"}));let c=t.find(s=>s.id===r);return c!=null&&o.push({label:c.name,price:`${_(c.amount/100,2)}`,type:"SHIPPING_OPTION",status:"FINAL"}),n!=null&&a!=null&&o.push({label:`Kupon ${n}`,price:`${_(a/100,2)}`,type:"DISCOUNT",status:"FINAL"}),i>0&&o.push({label:"Subtotal",price:`${_(i/100,2)}`,type:"SUBTOTAL",status:"FINAL"}),o}function et(e,t){return`${Q}/api/integrations/${e}/public-commerce${t}`}function we(e){return typeof e=="object"&&e!=null&&"ERR"in e}function J(e,t,r){return{ERR:!0,error:e,type:t,data:r}}function vr(e,t){return t?.find(r=>r.id===e||(r.variants?.some(n=>n.id===e)??!1))}function wr(e,t){let r=new Set(t.map(n=>n.productID));return Array.from(new Set(e.filter(n=>!r.has(n))))}import{create as Po}from"zustand";var Fe=Po(e=>({isCartVisible:!1,numberOfProductsInCart:0,showCart:()=>e(t=>({...t,isCartVisible:!0})),hideCart:()=>e(t=>({...t,isCartVisible:!1})),setNumberOfProductsInCart:t=>e(r=>({...r,numberOfProductsInCart:t}))}));import{Fragment as Eo,jsx as Wt}from"react/jsx-runtime";var Co="__m_a",Cr=wo(void 0),Jt=void 0;function Bc(e){Dt({projectID:e}),Jt=e,typeof window<"u"&&Ge([window.location.origin])}function nt(){return Jt??document.querySelector('script[data-id][data-name="internal-cart"]')?.getAttribute("data-id")??void 0}function No(){return document.querySelector('script[data-id][data-name="internal-cart"]')?.getAttribute("data-custom-host")??void 0}var So=({children:e,locale:t})=>{let r=new ho;xo(()=>{tt()},[]);let n=nt();if(n==null)return Wt(Eo,{});let a=Yt(n,t);return Wt(vo,{client:r,children:Wt(Cr.Provider,{value:a,children:e})})},qe=async(e,t)=>{let r=[];t?.items!=null&&t.items.length>0?r=t.items:r=z()?.products??[];let n=Array.from(new Set(r.map(c=>c.productID))),a=new URLSearchParams;a.set("ids",n.join(",")),a.set("locale",t?.locale??ce());let o=await fetch(xt(et(e,`/products?${a.toString()}`)),{method:"GET"});if(o.status!=200)return[];let i=await o.json();return r.flatMap(c=>{let s=vr(c.productID,i.result);return s==null?[]:[{...c,details:Lo(c.productID,s),catalogProductID:s.id}]})},Hc=()=>{let e=ko(Cr);if(e===void 0)throw new Error("useCartProvider must be used within a CartProvider");return e},Gc=So,Io=T.object({isAvailable:T.boolean(),merchantId:T.string(),merchantName:T.string(),gateway:T.string(),gatewayId:T.string()}),Ro=T.object({id:T.string(),productID:T.string(),quantity:T.number(),priceVersion:T.string().optional(),metadata:T.record(T.string(),T.string().optional()).optional()}),Ao=T.object({country:T.string().optional(),couponCode:T.string().optional(),selectedDeliveryMethod:T.string().optional(),postalCode:T.string().optional(),email:T.string().optional(),products:T.array(Ro).optional(),googlePayConfig:Io.optional()}),Kt={country:void 0,couponCode:void 0,email:void 0,selectedDeliveryMethod:void 0,postalCode:void 0,products:[],googlePayConfig:void 0},Nr="checkout";function z(){try{let e=localStorage.getItem(Nr);return e==null?Kt:Ao.parse(JSON.parse(e))}catch{return Kt}}async function kr(e,t){let r=await qe(e,{items:t.map((o,i)=>({...o,id:`price-check-${i}`}))});if(we(r))return r;let n=wr(t.map(o=>o.productID),r);if(n.length>0)return J("item-ids-not-found","notFound",n);let a=z();a.products==null&&(a.products=[]),a.products.push(...t.map(o=>({id:Math.random().toString(36).substring(7),productID:o.productID,quantity:o.quantity,priceVersion:r.find(i=>i.productID===o.productID)?.details?.pricing?.priceVersion,metadata:o.metadata}))),Do(t,r),Vt({event:"addToCart",currency:"PLN",items:t.map(o=>({id:o.productID,name:o.name??"",price:o.price??0,quantity:o.quantity,currency:o.currency??"PLN"}))}),te(a),tt()}function Do(e,t){for(let r of e)try{let n=t.find(c=>c.productID===r.productID),a=n?.details?.pricing?.effectivePrice??n?.details?.price??r.price,o=n?.details?.currency??r.currency;if(a==null||o==null)continue;let i=n?.catalogProductID??r.productID;(r.analytics??on()).track("add_to_cart",{qty:r.quantity,value_minor:Math.round(a*r.quantity),currency:o},{product_id:i,variant_id:i!==r.productID?r.productID:null})}catch{}}function xr(e){let t=z(),r={...t,products:t?.products?.filter(n=>!e.includes(n.productID)&&!e.includes(n.id))};Vt({event:"removeFromCart",items:e.map(n=>({id:n,name:"",price:0,quantity:1,currency:"PLN"}))}),te(r),tt()}function te(e){localStorage.setItem(Nr,JSON.stringify(e))}var Yt=(e,t=ce())=>{let r=No();return r!=null&&sn(r),{async checkIfApplePayIsAvailable(){if(typeof window>"u"||typeof document>"u"||!("ApplePaySession"in window))return!1;try{return(await ve.get(Q).isOneClickPaymentAvailable({projectId:e})).applePay}catch(n){return console.error("Error checking if Apple Pay is available",n),!1}},async getGooglePayConfiguration(n){if(typeof window>"u"||typeof document>"u")return{isAvailable:!1};try{let a=await To(e);if(a?.isAvailable!=!0)return{isAvailable:!1};let o=z();if(o==null)return console.log("checkout is null"),{isAvailable:!1};let i=await qe(e,{locale:t,items:n.items.map(d=>({id:Math.random().toString(36).substring(7),quantity:d.quantity,metadata:d.metadata,productID:d.productID}))});if(we(i))return{isAvailable:!1};let c=await ve.get(Q).getPreOrderDetails({items:i.map(d=>ke(St,{id:d.productID,quantity:d.quantity})),projectId:e,postCode:o.postalCode,couponCode:o.couponCode,countryCode:o.country,selectedDeliveryMethod:o.selectedDeliveryMethod});if(c.totalAmount==null)return{isAvailable:!1};let s=i.find(d=>d.details?.isDeliverable==!0)!=null,y=await hr({items:i,googlePayConfig:a,checkout:o,cartRequiresShipping:s,result:c});return y==null?{isAvailable:!1}:{isAvailable:!0,config:y}}catch(a){return console.error("Error resolving Google Pay configuration",a),{isAvailable:!1}}},async clearCart(){let n=structuredClone(Kt);n.country=z()?.country,te(n),tt()},async getAvailableCountries(){let n=await fetch(xt(et(e,"/countries")),{method:"GET"});if(n.status!=200)return[];try{return T.array(T.object({name:T.string(),code:T.string()})).parse(await n.json())}catch(a){return J(a.toString(),"internal")}},async getCountry(){let n=z()?.country;if(n==null){n="PL";let a=z();a.country=n,te(a)}return n},async getNumberOfElementsInCart(){return z()?.products?.reduce((n,a)=>n+a.quantity,0)??0},async getProducts(){return await qe(e,{locale:t})},async removeProductFromCart(n){return xr([n.id])},async setCountry(n){let a=z();a.country=n,te(a)},async setCouponCodeIfPossible(n){let a=z();a.couponCode=n,te(a)},async setPostalCode(n){let a=z();a.postalCode=n,te(a)},async setDeliveryMethod(n){let a=z();a.selectedDeliveryMethod=n,te(a)},async setEmail(n){let a=z();a.email=n,te(a)},async addProduct(n){return await kr(e,[n])},async updateQuantity(n){let a=z();a.products=a.products?.map(o=>(o.id===n.id&&(o.quantity=n.quantity),o)),te(a),tt()},async redirectToNextStep(){let n=z();if(n.products==null||n.products.length==0)return J("cart-is-empty","badInput");let a=n.products.reduce((c,s)=>(s.metadata!=null&&Object.keys(s.metadata).forEach(y=>{let d=s.metadata?.[y];d!=null&&(c[y]=d)}),c),{}),o={items:n.products.map(c=>({id:c.productID,quantity:c.quantity,priceVersion:c.priceVersion})),askForNote:!0,countries:n.country?[n.country]:void 0,metadata:a,locale:t},i=await Zt(o);return we(i)?(console.warn("cannot create payment URL",i.error),i):{url:i.url}},async justRedirectToPayment(n){let a={items:[{id:n.productID,quantity:1}],askForNote:!1,details:n.email||n.name?{name:n.name,email:n.email}:void 0,locale:n.locale??t};a=Qt(a),n.country==null&&(n.country="pl"),a.details==null&&(a.details={}),a.details.address==null&&(a.details.address={}),a.details.address.country=n.country,n.marketingAgreement===!0&&(a.additionalAgreements=[{id:Co,name:"",required:!0,answer:!0}]);let o=await Zt(a);return we(o)?o:{url:o.url}},async completeApplePayPayment(n){let a=z();if(a==null)return J("Checkout not found");let o=await qe(e,{locale:t});if(we(o))return o;try{let i=n.shippingContact?.givenName;n.shippingContact?.familyName!=null?i+=" "+n.shippingContact?.familyName:n.billingContact?.familyName!=null&&(i+=" "+n.billingContact?.familyName);let c={},s=Pt();s!=null&&(c.ref=s);let y=await ve.get(Q).authorizeOneClickPayment({gateway:0,paymentData:JSON.stringify(n.token.paymentData),paymentMethod:JSON.stringify(n.token.paymentMethod),transactionIdentifier:n.token.transactionIdentifier,order:ke(It,{items:o.map(d=>({id:d.productID,quantity:d.quantity})),couponCode:a.couponCode,email:n.shippingContact?.emailAddress??n.billingContact?.emailAddress??a.email??void 0,phone:n.shippingContact?.phoneNumber??n.billingContact?.phoneNumber??void 0,selectedDeliveryMethod:a.selectedDeliveryMethod,postCode:a.postalCode,projectId:e}),shippingAddress:ke(Ct,{line1:n.shippingContact?.addressLines?.[0]??"",city:n.shippingContact?.locality??"",country:n.shippingContact?.countryCode??"",zipCode:n.shippingContact?.postalCode??"",name:i}),billingAddress:ke(Nt,{name:n.billingContact?.givenName??" "+(n.billingContact?.familyName??""),line1:n.billingContact?.addressLines?.[0]??"",city:n.billingContact?.locality??"",country:n.billingContact?.countryCode??"",zipCode:n.billingContact?.postalCode??""}),metadata:Object.keys(c).length>0?JSON.stringify(c):void 0});return{isSuccess:y.isSuccess,redirectURL:y.redirectUrl}}catch(i){return console.error(i),J("Failed to authorize payment")}},async completeGooglePayPayment(n){let a=z();if(a==null)return J("Checkout not found");let o=await qe(e,{locale:t});if(we(o))return o;try{let i=n.paymentData.shippingAddress?.name,c={},s=Pt();s!=null&&(c.ref=s);let y=await ve.get(Q).authorizeOneClickPayment({gateway:1,paymentData:n.paymentData.paymentMethodData.tokenizationData.token,paymentMethod:n.paymentData.paymentMethodData.type,transactionIdentifier:"",order:ke(It,{items:o.map(d=>({id:d.productID,quantity:d.quantity})),couponCode:a.couponCode,email:n.paymentData.email??void 0,phone:n.paymentData.shippingAddress?.phoneNumber??void 0,selectedDeliveryMethod:n.paymentData.shippingOptionData?.id??a.selectedDeliveryMethod,postCode:n.paymentData.shippingAddress?.postalCode,projectId:e}),shippingAddress:ke(Ct,{line1:n.paymentData.shippingAddress?.address1??"",city:n.paymentData.shippingAddress?.locality??"",country:n.paymentData.shippingAddress?.countryCode??"",zipCode:n.paymentData.shippingAddress?.postalCode??"",name:i}),billingAddress:ke(Nt,{name:n.paymentData.paymentMethodData.info?.billingAddress?.name,line1:n.paymentData.paymentMethodData.info?.billingAddress?.address1??"",city:n.paymentData.paymentMethodData.info?.billingAddress?.locality??"",country:n.paymentData.paymentMethodData.info?.billingAddress?.countryCode??"",zipCode:n.paymentData.paymentMethodData.info?.billingAddress?.postalCode??""}),metadata:Object.keys(c).length>0?JSON.stringify(c):void 0});return{isSuccess:y.isSuccess,redirectURL:y.redirectUrl}}catch(i){return console.error(i),J("Failed to authorize payment")}return{isSuccess:!0}},async getApplePayPaymentRequest(n){let a=z();if(a==null)return J("Checkout not found");n&&n.expectedItems!=null&&n.expectedItems.length>0&&(a.products&&xr(a.products.map(s=>s.productID)),await kr(e,n.expectedItems));let o=await qe(e,{locale:t});if(we(o))return o;let i=await ve.get(Q).getPreOrderDetails({items:o.map(s=>ke(St,{id:s.productID,quantity:s.quantity})),projectId:e,postCode:a.postalCode,couponCode:a.couponCode,countryCode:a.country,selectedDeliveryMethod:a.selectedDeliveryMethod}),c=o.map(s=>({amount:`${_(s.quantity*(s.details?.price??0)/100,2)}`,label:s.details?.name+" - "+s.quantity,type:"final"}));if(i.selectedDeliveryMethod!=null){let s=i.methods.find(y=>y.id==i.selectedDeliveryMethod);s!=null&&c.push({amount:`${_(s.amount/100,2)}`,label:s.name,type:"final"})}return i.couponCode!=null&&i.couponValue!=null&&c.push({amount:`-${_(i.couponValue/100,2)}`,label:i.couponCode,type:"final"}),{countryCode:a.country??"PL",merchantCapabilities:["supports3DS","supportsCredit","supportsDebit"],supportedNetworks:["visa","masterCard"],total:{amount:`${_((i.totalAmount??0)/100,2)}`,label:"P\u0142atno\u015B\u0107 za koszyk",type:"final"},shippingMethods:i.methods.map(s=>({amount:`${_(s.amount/100,2)}`,detail:s.description??"",identifier:s.id,label:s.name,dateComponentsRange:{startDateComponents:{days:s.minDays??1,hours:0,months:0,years:0},endDateComponents:{days:s.maxDays??14,hours:0,months:0,years:0}}})),lineItems:c,currencyCode:"PLN"}}}};async function To(e){let t=z();if(t.googlePayConfig?.isAvailable!=!0){let r=await ve.get(Q).isOneClickPaymentAvailable({projectId:e});r.googlePay==!0&&r.googlePayConfig!=null?t.googlePayConfig={isAvailable:!0,gateway:r.googlePayConfig.gateway,gatewayId:r.googlePayConfig.gatewayMerchantId,merchantName:r.googlePayConfig.merchantName,merchantId:r.googlePayConfig.merchantId}:t.googlePayConfig={isAvailable:!1,gateway:"",gatewayId:"",merchantName:"",merchantId:""}}return te(t),t.googlePayConfig}function Lo(e,t){if(e==t.id){let n=t.variants?.findIndex(a=>a.id===e);if(n!=null&&n!=-1){let a=t.variants[n];return{...t,availableQuantity:a.availableQuantity,isDeliverable:a.isDeliverable,images:a.images??t.images,name:t.name+" "+a.name,price:a.price,currency:a.currency,pricing:a.pricing}}return t}let r=t.variants?.find(n=>n.id===e);return r==null?t:{...t,id:r.id,name:t.name+" "+r.name,price:r.price,currency:r.currency,pricing:r.pricing,metadata:t.metadata,availableQuantity:r.availableQuantity,isDeliverable:r.isDeliverable,images:r.images??t.images}}function tt(){let e=z(),t=0;if(e==null){Fe.setState(r=>({...r,numberOfProductsInCart:t}));return}t=e.products?.reduce((r,n)=>r+n.quantity,0)??0,Fe.setState(r=>({...r,numberOfProductsInCart:t}))}var Uo=200,Oo="item-ids-not-found",rt="internal-error",Sr={"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"},zo=new Set(["internal","invalid-request"]),Mo=new Set(["product-not-available","product-not-found"]);function _o(e){return typeof e=="string"&&Object.hasOwn(Sr,e)?Sr[e]:void 0}function jo(e){return/<\/?[a-z!?][^>]*>/i.test(e)}function Fo(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 qo(e){return/Error:/.test(e)||/\n\s+at /.test(e)}function Xt(e){let t=e.trim();if(!(t.length===0||t.length>Uo||/[\r\n]/.test(t)||jo(t)||Fo(t)||qo(t)))return t}var Bo=3;function ht(e,t=0){if(typeof e=="object"&&e!=null){if(Array.isArray(e)||t>=Bo)return{};let r=e,n=ht(r.error,t+1);if(n.message==null&&r.message!=null){let a=ht(r.message,t+1);n={...a,code:n.code??a.code}}return typeof r.code=="string"&&r.code.length>0&&(n.code=r.code),n}if(typeof e!="string")return{};try{let r=JSON.parse(e);return typeof r=="object"&&r!=null?ht(r,t+1):{}}catch{}return{message:Xt(e)}}function Ho(e){let t;try{t=JSON.parse(e)}catch{return{code:rt,message:Xt(e)}}if(typeof t=="string")return{code:rt,message:Xt(t)};if(typeof t!="object"||t==null)return{code:rt};let r=t,{message:n,code:a}=ht(r.error),o={code:typeof r.code=="string"&&r.code.length>0?r.code:a??rt,message:n};return Array.isArray(r.itemIds)&&(o.itemIds=r.itemIds.filter(i=>typeof i=="string")),o}function en(e,t){let{code:r,message:n,itemIds:a}=Ho(t),o=a!=null&&a.length>0;if(o&&(r===rt||Mo.has(r)))return J(Oo,"badInput",a);let i={message:n};return o&&(i.itemIds=a),J(r,e>=500?"internal":"badInput",i)}function Jc(e,t){let r=_o(e.error);if(r!=null)return t(r);if(e.type==="internal"||typeof e.error=="string"&&zo.has(e.error))return t("checkoutFailed");let n=e.data?.message;return typeof n=="string"&&n.length>0?n:t("checkoutFailed")}var Go;(n=>{async function e(a,o=1,i,c){let s=nt();if(s==null)throw new Error("No project ID found");let d=await Yt(s).addProduct({productID:a,quantity:o,metadata:i,...c});if(d!=null)return d}n.addProductToCart=e;function t(){Fe.setState({isCartVisible:!0})}n.showCart=t;function r(){Fe.setState({isCartVisible:!1})}n.hideCart=r})(Go||={});async function Ir(e){try{return await e.text()}catch{return""}}async function Zt(e){let t=nt();if(t==null)throw new Error("No project ID found");e=Qt(e),e.locale??=ce();let r=await fetch(et(t,"/buy"),{method:"POST",headers:{...kt,...At(t),"Content-Type":"application/json"},body:JSON.stringify(e)});if(r.status!=200){let a=en(r.status,await Ir(r));return console.warn("cannot create payment URL",r.status,a.error),a}return{url:(await r.json()).url}}async function ad(e){let t=nt();if(t==null)throw new Error("No project ID found");let r={...kt,...At(t),"Content-Type":"application/json",...e.apiKey!=null?{Authorization:`Bearer ${e.apiKey}`}:{}},n=e.testMode?`/api/payment/link/auto/${t}/test`:`/api/payment/link/auto/${t}`;delete e.apiKey,delete e.testMode,e.locale??=ce();let a=await fetch(Q+n,{method:"POST",headers:r,body:JSON.stringify(e)});return a.ok?{status:"ok",redirectURL:(await a.json()).url}:{...en(a.status,await Ir(a)),status:"error"}}function Pt(){if(typeof localStorage>"u")return;let e=localStorage.getItem("bitsnap-ref");if(e!=null)return e}function Qt(e){let t=Pt();return t==null||(e.metadata==null&&(e.metadata={}),e.metadata.ref=t),e}export{ve as a,de as b,ye as c,be as d,Tt as e,ue as f,In as g,Lt as h,Se as i,Ze as j,Je as k,Ue as l,Oe as m,Zr as n,Un as o,$t as p,lo as q,_ as r,Pr as s,Vt as t,we as u,Oo as v,Jc as w,Fe as x,Go as y,Zt as z,ad as A,Pt as B,Qt as C,Co as D,Jt as E,Bc as F,nt as G,Hc as H,Gc as I,Yt as J};
|
|
4
|
+
//# sourceMappingURL=chunk-2PK36NGB.mjs.map
|