@piedata/pieui 2.0.4 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/PieBaseRoot/index.d.ts +11 -0
- package/dist/components/PieBaseRoot/index.d.ts.map +1 -1
- package/dist/components/PieBaseRoot/types/index.d.ts +6 -0
- package/dist/components/PieBaseRoot/types/index.d.ts.map +1 -1
- package/dist/components/PieCard/index.d.ts +18 -0
- package/dist/components/PieCard/index.d.ts.map +1 -1
- package/dist/components/PieCard/types/index.d.ts +36 -0
- package/dist/components/PieCard/types/index.d.ts.map +1 -1
- package/dist/components/PieMaxRoot/index.d.ts +12 -0
- package/dist/components/PieMaxRoot/index.d.ts.map +1 -1
- package/dist/components/PieRoot/index.d.ts +17 -0
- package/dist/components/PieRoot/index.d.ts.map +1 -1
- package/dist/components/PieRoot/types/index.d.ts +31 -0
- package/dist/components/PieRoot/types/index.d.ts.map +1 -1
- package/dist/components/PieTelegramRoot/index.d.ts +13 -0
- package/dist/components/PieTelegramRoot/index.d.ts.map +1 -1
- package/dist/components/index.esm.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.js +2 -2
- package/dist/util/ajaxCommonUtils.d.ts +48 -1
- package/dist/util/ajaxCommonUtils.d.ts.map +1 -1
- package/dist/util/centrifuge.d.ts +22 -0
- package/dist/util/centrifuge.d.ts.map +1 -1
- package/dist/util/fallback.d.ts +6 -0
- package/dist/util/fallback.d.ts.map +1 -1
- package/dist/util/globalForm.d.ts +8 -0
- package/dist/util/globalForm.d.ts.map +1 -1
- package/dist/util/lazy.d.ts +25 -0
- package/dist/util/lazy.d.ts.map +1 -1
- package/dist/util/mitt.d.ts +37 -0
- package/dist/util/mitt.d.ts.map +1 -1
- package/dist/util/navigate.d.ts +11 -0
- package/dist/util/navigate.d.ts.map +1 -1
- package/dist/util/pieConfig.d.ts +35 -0
- package/dist/util/pieConfig.d.ts.map +1 -1
- package/dist/util/pieName.d.ts +12 -0
- package/dist/util/pieName.d.ts.map +1 -1
- package/dist/util/piecache.d.ts +15 -0
- package/dist/util/piecache.d.ts.map +1 -1
- package/dist/util/registry.d.ts +49 -0
- package/dist/util/registry.d.ts.map +1 -1
- package/dist/util/socket.d.ts +22 -0
- package/dist/util/socket.d.ts.map +1 -1
- package/dist/util/tailwindCommonUtils.d.ts +14 -0
- package/dist/util/tailwindCommonUtils.d.ts.map +1 -1
- package/dist/util/uiRenderer.d.ts +14 -0
- package/dist/util/uiRenderer.d.ts.map +1 -1
- package/dist/util/useIsSupported.d.ts +18 -0
- package/dist/util/useIsSupported.d.ts.map +1 -1
- package/dist/util/useMaxWebApp.d.ts +27 -0
- package/dist/util/useMaxWebApp.d.ts.map +1 -1
- package/dist/util/useOpenAIWebRTC.d.ts +44 -0
- package/dist/util/useOpenAIWebRTC.d.ts.map +1 -1
- package/dist/util/useWebApp.d.ts +21 -0
- package/dist/util/useWebApp.d.ts.map +1 -1
- package/dist/util/webrtcClient.d.ts +61 -0
- package/dist/util/webrtcClient.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import { PieBaseRootProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Base PieUI root that sets up every context required by PieUI components
|
|
4
|
+
* (QueryClient, Mitt emitter, Socket.IO, Centrifuge, Fallback, Navigate,
|
|
5
|
+
* PieConfig) around its `children`.
|
|
6
|
+
*
|
|
7
|
+
* Unlike {@link PieRoot}, `PieBaseRoot` does not fetch a UI configuration
|
|
8
|
+
* from the server — callers render whatever they want inside and can use
|
|
9
|
+
* the PieUI utilities (`usePieEmit`, `PieCard`, Ajax helpers, …) within
|
|
10
|
+
* that tree. Use this when you want full control over what is rendered or
|
|
11
|
+
* when combining a PieUI widget with a non-PieUI application shell.
|
|
12
|
+
*/
|
|
2
13
|
declare const PieBaseRoot: (props: PieBaseRootProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
14
|
export default PieBaseRoot;
|
|
4
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PieBaseRoot/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAwD1C,QAAA,MAAM,WAAW,GAAI,OAAO,gBAAgB,4CAY3C,CAAA;AAED,eAAe,WAAW,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PieBaseRoot/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAwD1C;;;;;;;;;;GAUG;AACH,QAAA,MAAM,WAAW,GAAI,OAAO,gBAAgB,4CAY3C,CAAA;AAED,eAAe,WAAW,CAAA"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { PieRootProps } from '../../PieRoot/types';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Props accepted by {@link PieBaseRoot}. Extends {@link PieRootProps} with
|
|
5
|
+
* a `children` slot — PieBaseRoot does not fetch a UI configuration on its
|
|
6
|
+
* own, so the caller is responsible for rendering whatever should live
|
|
7
|
+
* inside the PieUI providers.
|
|
8
|
+
*/
|
|
3
9
|
export type PieBaseRootProps = PieRootProps & {
|
|
4
10
|
children?: ReactNode;
|
|
5
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/PieBaseRoot/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG;IAC1C,QAAQ,CAAC,EAAE,SAAS,CAAA;CACvB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/PieBaseRoot/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG;IAC1C,QAAQ,CAAC,EAAE,SAAS,CAAA;CACvB,CAAA"}
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import { PieCardProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a rendered card so it can participate in PieUI realtime messaging.
|
|
4
|
+
*
|
|
5
|
+
* `PieCard` does not render any UI of its own — it simply returns its
|
|
6
|
+
* children — but on mount it subscribes the supplied `methods` map to
|
|
7
|
+
* whichever transports have been enabled:
|
|
8
|
+
*
|
|
9
|
+
* - **Socket.IO**: listens for `pie{methodName}_{data.name}` events.
|
|
10
|
+
* - **Centrifuge**: subscribes to channels of the form
|
|
11
|
+
* `pie{methodName}_{data.name}_{centrifugeChannel}`.
|
|
12
|
+
* - **Mitt**: listens for `pie{methodName}_{data.name}` events on the
|
|
13
|
+
* in-process emitter (used by `usePieEmit`).
|
|
14
|
+
*
|
|
15
|
+
* The `methods` map is accessed via a ref so callers may hand in freshly
|
|
16
|
+
* recreated closures on every render without triggering re-subscriptions.
|
|
17
|
+
* Cleanup runs automatically on unmount or when `data.name`/the support
|
|
18
|
+
* flags change.
|
|
19
|
+
*/
|
|
2
20
|
declare const PieCard: ({ card, data, children, useSocketioSupport, useCentrifugeSupport, useMittSupport, centrifugeChannel, methods, }: PieCardProps) => import("react").ReactNode;
|
|
3
21
|
export default PieCard;
|
|
4
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PieCard/index.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEtC,QAAA,MAAM,OAAO,GAAI,iHASd,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PieCard/index.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEtC;;;;;;;;;;;;;;;;;GAiBG;AACH,QAAA,MAAM,OAAO,GAAI,iHASd,YAAY,8BAoLd,CAAA;AAED,eAAe,OAAO,CAAA"}
|
|
@@ -1,16 +1,52 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Data object backing a single {@link PieCard}.
|
|
4
|
+
*
|
|
5
|
+
* The `name` field is mandatory because it is used to build realtime event
|
|
6
|
+
* channel names (`pie{methodName}_{name}`). Any other fields are treated as
|
|
7
|
+
* free-form props passed to the underlying card component.
|
|
8
|
+
*/
|
|
2
9
|
export interface PieCardData {
|
|
10
|
+
/** Unique identifier of the card within the UI tree. */
|
|
3
11
|
name: string;
|
|
12
|
+
/** Arbitrary, card-specific props. */
|
|
4
13
|
[key: string]: any;
|
|
5
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Props accepted by {@link PieCard}.
|
|
17
|
+
*/
|
|
6
18
|
export interface PieCardProps {
|
|
19
|
+
/** Registered name of the card component to render. */
|
|
7
20
|
card: string;
|
|
21
|
+
/** Card data; must include a `name` used for event routing. */
|
|
8
22
|
data: PieCardData;
|
|
23
|
+
/** Rendered children. PieCard does not mount any UI of its own. */
|
|
9
24
|
children: ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* Subscribe the card's `methods` to Socket.IO events of the form
|
|
27
|
+
* `pie{methodName}_{data.name}`.
|
|
28
|
+
*/
|
|
10
29
|
useSocketioSupport?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Subscribe the card's `methods` to Centrifuge channels of the form
|
|
32
|
+
* `pie{methodName}_{data.name}_{centrifugeChannel}`. Requires
|
|
33
|
+
* {@link centrifugeChannel}.
|
|
34
|
+
*/
|
|
11
35
|
useCentrifugeSupport?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Subscribe the card's `methods` to Mitt events of the form
|
|
38
|
+
* `pie{methodName}_{data.name}`. Used for in-process notifications
|
|
39
|
+
* dispatched via `usePieEmit`.
|
|
40
|
+
*/
|
|
12
41
|
useMittSupport?: boolean;
|
|
42
|
+
/** Channel suffix appended to Centrifuge subscriptions. */
|
|
13
43
|
centrifugeChannel?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Map of method name → handler. Keys become part of the realtime event
|
|
46
|
+
* names the card listens for; the handler receives the event payload.
|
|
47
|
+
* Handlers are accessed via a ref so updating the map between renders
|
|
48
|
+
* does not trigger re-subscription.
|
|
49
|
+
*/
|
|
14
50
|
methods?: Record<string, (data: any) => void>;
|
|
15
51
|
}
|
|
16
52
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/PieCard/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACrB;AAED,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,WAAW,CAAA;IACjB,QAAQ,EAAE,SAAS,CAAA;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC,CAAA;CAChD"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/PieCard/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IACxB,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAA;IACZ,sCAAsC;IACtC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAA;IACZ,+DAA+D;IAC/D,IAAI,EAAE,WAAW,CAAA;IACjB,mEAAmE;IACnE,QAAQ,EAAE,SAAS,CAAA;IACnB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,2DAA2D;IAC3D,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC,CAAA;CAChD"}
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { PieRootProps } from '../PieRoot/types';
|
|
3
|
+
/**
|
|
4
|
+
* PieUI root for MAX (VK Messenger) mini-apps.
|
|
5
|
+
*
|
|
6
|
+
* Behaves like {@link PieRoot} but waits for `window.WebApp` to be ready
|
|
7
|
+
* via {@link useMaxWebApp}, forwards `initData` to the backend as a query
|
|
8
|
+
* parameter, and identifies itself to the server with `__pieroot=max` so
|
|
9
|
+
* the UI configuration can be tailored to the MAX host.
|
|
10
|
+
*
|
|
11
|
+
* Throws when `apiServer` is missing because MAX mini-apps cannot fall
|
|
12
|
+
* back to SSR-style static rendering. Use `fallback`/`piecache` to show a
|
|
13
|
+
* loading shell while MAX finishes initialising.
|
|
14
|
+
*/
|
|
3
15
|
declare const PieMaxRoot: React.FC<PieRootProps>;
|
|
4
16
|
export default PieMaxRoot;
|
|
5
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PieMaxRoot/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkB,MAAM,OAAO,CAAA;AAOtC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AA8K/C,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAYtC,CAAA;AAED,eAAe,UAAU,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PieMaxRoot/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkB,MAAM,OAAO,CAAA;AAOtC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AA8K/C;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAYtC,CAAA;AAED,eAAe,UAAU,CAAA"}
|
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
import { PieRootProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Main PieUI root for regular web applications.
|
|
4
|
+
*
|
|
5
|
+
* Fetches a `UIConfigType` from `api/content{pathname}{search}` via
|
|
6
|
+
* react-query, renders it through the internal `UI` component, and wraps
|
|
7
|
+
* everything in the standard PieUI providers (QueryClient, Mitt, Socket.IO,
|
|
8
|
+
* Centrifuge, Fallback, Navigate, PieConfig).
|
|
9
|
+
*
|
|
10
|
+
* While the request is pending — or when `apiServer` has not been
|
|
11
|
+
* configured — the component renders the `piecache` shell (if any) or the
|
|
12
|
+
* caller-supplied `fallback`. On error it invokes `onError` and shows the
|
|
13
|
+
* same fallback UI.
|
|
14
|
+
*
|
|
15
|
+
* The UI configuration request is memoized forever by default
|
|
16
|
+
* (`staleTime: Infinity`); supply `queryOptions` to override the
|
|
17
|
+
* react-query behaviour.
|
|
18
|
+
*/
|
|
2
19
|
declare const PieRoot: (props: PieRootProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
20
|
export default PieRoot;
|
|
4
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PieRoot/index.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AA8KtC,QAAA,MAAM,OAAO,GAAI,OAAO,YAAY,4CAYnC,CAAA;AAED,eAAe,OAAO,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PieRoot/index.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AA8KtC;;;;;;;;;;;;;;;;GAgBG;AACH,QAAA,MAAM,OAAO,GAAI,OAAO,YAAY,4CAYnC,CAAA;AAED,eAAe,OAAO,CAAA"}
|
|
@@ -2,17 +2,48 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
import { PieConfig, UIConfigType } from '../../../types';
|
|
3
3
|
import { UseQueryOptions } from '@tanstack/react-query';
|
|
4
4
|
import { AxiosError } from 'axios';
|
|
5
|
+
/**
|
|
6
|
+
* Extra options merged into the internal `useQuery` call that fetches the
|
|
7
|
+
* UI configuration. `queryKey`, `queryFn` and `enabled` are managed by
|
|
8
|
+
* PieRoot itself and cannot be overridden.
|
|
9
|
+
*/
|
|
5
10
|
export type PieQueryOptions = Omit<UseQueryOptions<UIConfigType, AxiosError>, 'queryKey' | 'queryFn' | 'enabled'>;
|
|
11
|
+
/**
|
|
12
|
+
* Props common to every `Pie*Root` component.
|
|
13
|
+
*/
|
|
6
14
|
export interface PieRootProps {
|
|
15
|
+
/**
|
|
16
|
+
* Current route, typically forwarded from the host router
|
|
17
|
+
* (`window.location`, Next.js `usePathname`, React Router `useLocation`,
|
|
18
|
+
* etc.). Used to build the `api/content{pathname}{search}` request and
|
|
19
|
+
* as part of the react-query key.
|
|
20
|
+
*/
|
|
7
21
|
location: {
|
|
8
22
|
pathname: string;
|
|
9
23
|
search: string;
|
|
10
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Fallback node rendered while the UI configuration is loading or when
|
|
27
|
+
* the fetch fails. Overridden per-pathname by {@link piecache}.
|
|
28
|
+
*/
|
|
11
29
|
fallback?: ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* Optional snapshot of known `UIConfigType`s keyed by pathname. When a
|
|
32
|
+
* cache entry exists for the current route the cached shell is rendered
|
|
33
|
+
* via `UILoading` instead of the plain `fallback`.
|
|
34
|
+
*/
|
|
12
35
|
piecache?: Record<string, UIConfigType>;
|
|
36
|
+
/** Invoked when the UI configuration request throws. */
|
|
13
37
|
onError?: () => void;
|
|
38
|
+
/**
|
|
39
|
+
* Navigation handler forwarded through `NavigateContext` so PieUI
|
|
40
|
+
* components can route via the host application (Next.js router,
|
|
41
|
+
* React Router, Telegram navigation, …) instead of reloading the page.
|
|
42
|
+
*/
|
|
14
43
|
onNavigate?: (url: string) => void;
|
|
44
|
+
/** Runtime configuration (API URLs, logging, page processor, …). */
|
|
15
45
|
config: PieConfig;
|
|
46
|
+
/** Optional react-query overrides; see {@link PieQueryOptions}. */
|
|
16
47
|
queryOptions?: PieQueryOptions;
|
|
17
48
|
}
|
|
18
49
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/PieRoot/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAElC,MAAM,MAAM,eAAe,GAAG,IAAI,CAC9B,eAAe,CAAC,YAAY,EAAE,UAAU,CAAC,EACzC,UAAU,GAAG,SAAS,GAAG,SAAS,CACrC,CAAA;AAED,MAAM,WAAW,YAAY;IACzB,QAAQ,EAAE;QACN,QAAQ,EAAE,MAAM,CAAA;QAChB,MAAM,EAAE,MAAM,CAAA;KACjB,CAAA;IACD,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;IACvC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC,MAAM,EAAE,SAAS,CAAA;IACjB,YAAY,CAAC,EAAE,eAAe,CAAA;CACjC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/PieRoot/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAElC;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,IAAI,CAC9B,eAAe,CAAC,YAAY,EAAE,UAAU,CAAC,EACzC,UAAU,GAAG,SAAS,GAAG,SAAS,CACrC,CAAA;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB;;;;;OAKG;IACH,QAAQ,EAAE;QACN,QAAQ,EAAE,MAAM,CAAA;QAChB,MAAM,EAAE,MAAM,CAAA;KACjB,CAAA;IACD;;;OAGG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;IACvC,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC,oEAAoE;IACpE,MAAM,EAAE,SAAS,CAAA;IACjB,mEAAmE;IACnE,YAAY,CAAC,EAAE,eAAe,CAAA;CACjC"}
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { PieRootProps } from '../PieRoot/types';
|
|
3
|
+
/**
|
|
4
|
+
* PieUI root for Telegram Mini Apps.
|
|
5
|
+
*
|
|
6
|
+
* Behaves like {@link PieRoot} but waits for `window.Telegram.WebApp` via
|
|
7
|
+
* {@link useWebApp}, forwards the Telegram `initData` payload to the
|
|
8
|
+
* backend as a query parameter, and identifies itself to the server with
|
|
9
|
+
* `__pieroot=telegram`. Handles `ready()`/optional `expand()` based on the
|
|
10
|
+
* configured `pageProcessor`, so iOS/Android clients render full-screen
|
|
11
|
+
* when `pageProcessor === 'telegram_expanded'`.
|
|
12
|
+
*
|
|
13
|
+
* Throws when `apiServer` is missing. Errors raised inside `wApp.ready()`
|
|
14
|
+
* are forwarded to `onError`.
|
|
15
|
+
*/
|
|
3
16
|
declare const PieTelegramRoot: React.FC<PieRootProps>;
|
|
4
17
|
export default PieTelegramRoot;
|
|
5
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PieTelegramRoot/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkB,MAAM,OAAO,CAAA;AAOtC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAgL/C,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAY3C,CAAA;AAED,eAAe,eAAe,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PieTelegramRoot/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkB,MAAM,OAAO,CAAA;AAOtC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAgL/C;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAY3C,CAAA;AAED,eAAe,eAAe,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{useContext as $,useEffect as E,useRef as Io}from"react";import{createContext as po,useContext as fo}from"react";var lo=po(null),uo=()=>{let o=fo(lo);if(!o)throw new Error("usePieConfig must be used within PieConfigProvider");return o};var R=()=>{let{enableRenderingLog:o}=uo();return o},G=R;import{createContext as go}from"react";import{Centrifuge as Ht}from"centrifuge";var Co=go(null),J=Co;import{io as Bt}from"socket.io-client";import{createContext as yo}from"react";var xo=yo(null),X=xo;import Gt from"mitt";import{createContext as Uo}from"react";var Po=Uo(null),T=Po;var bo=({card:o,data:t,children:r,useSocketioSupport:e=!1,useCentrifugeSupport:n=!1,useMittSupport:s=!1,centrifugeChannel:a=void 0,methods:l=void 0})=>{let c=G(),m=Io(l);if(E(()=>{m.current=l},[l]),c)console.log("[PieCard] Rendering card:",o),console.log("[PieCard] Card data:",t),console.log("[PieCard] Component name:",t?.name),console.log("[PieCard] Real-time support:",{socketio:e,centrifuge:n,mitt:s,centrifugeChannel:a}),console.log("[PieCard] Methods:",l?Object.keys(l):"none"),console.log("[PieCard] Has children:",!!r);let U=$(X),f=$(J),u=$(T);if(E(()=>{if(!U||!e||!m.current||!t.name){if(c&&e)console.log("[PieCard] Socket.IO setup skipped:",{hasSocket:!!U,useSocketioSupport:e,hasMethods:!!m.current,hasDataName:!!t?.name});return}let p=Object.keys(m.current??{});return p.forEach((i)=>{let d=`pie${i}_${t.name}`;if(c)console.log(`[PieCard] Socket.IO registering event: ${d}`);U.on(d,(y)=>{m.current?.[i]?.(y)})}),()=>{p.forEach((i)=>{let d=`pie${i}_${t.name}`;if(c)console.log(`[PieCard] Socket.IO unregistering event: ${d}`);U.off(d)})}},[U,t.name,e]),E(()=>{if(!f||!n||!a||!t.name){if(c&&n)console.log("[PieCard] Centrifuge setup skipped:",{hasCentrifuge:!!f,useCentrifugeSupport:n,hasCentrifugeChannel:!!a,hasMethods:!!m.current,hasDataName:!!t?.name});return}let i=Object.keys(m.current??{}).map((d)=>{let y=`pie${d}_${t.name}_${a}`;if(c)console.log(`[PieCard] Centrifuge subscribing to channel: ${y}`);let I=f.newSubscription(y);return I.on("publication",(k)=>{if(c)console.log(`[PieCard] Centrifuge received data on ${y}:`,k.data);m.current?.[d]?.(k.data)}),I.subscribe(),I});return()=>{i.forEach((d)=>{if(c)console.log("[PieCard] Centrifuge unsubscribing from channel");d.unsubscribe(),f.removeSubscription(d)})}},[f,a,t.name,n]),E(()=>{if(!u||!s||!t.name){if(c&&s)console.log("[PieCard] Mitt setup skipped:",{hasMitt:!!u,useMittSupport:s,hasMethods:!!m.current,hasDataName:!!t?.name});return}let p=Object.keys(m.current??{}),i={};return p.forEach((d)=>{let y=`pie${d}_${t.name}`,I=(k)=>{if(c)console.log(`[PieCard] Mitt registering event: ${y}`);m.current?.[d]?.(k)};i[y]=I,u.on(y,I)}),()=>{Object.entries(i).forEach(([d,y])=>{if(c)console.log(`[PieCard] Mitt unregistering event: ${d}`);u.off(d,y)})}},[u,t.name,s]),c)console.log("[PieCard] Rendering complete, returning children");return r},x=bo;import{lazy as ho}from"react";var M=new Map;function Q(o,t){return ho(()=>{if(M.has(t))return M.get(t);let r=o().then((e)=>e);return M.set(t,r),r})}var Y=new Map,ko=(o)=>{if(!o.name)throw new Error("Component registration requires a name");if(!o.component&&!o.loader)throw new Error(`Component "${o.name}" requires component or loader`);let t={name:o.name,component:o.component,loader:o.loader,metadata:o.metadata,fallback:o.fallback,isLazy:!1};if(!t.component&&t.loader)t.component=Q(t.loader,o.name),t.loader=void 0,t.isLazy=!0;return t};function C(o){let t=ko(o);return Y.set(t.name,t),t.component}var L=(o)=>{return Y.get(o)};import{Suspense as Lo,useContext as Ao,memo as No}from"react";import{createContext as wo}from"react";import{jsx as Eo,Fragment as To}from"react/jsx-runtime";var Ro=wo(Eo(To,{})),h=Ro;import{jsx as O}from"react/jsx-runtime";function zo({uiConfig:o,setUiAjaxConfiguration:t}){let r=Ao(h),e=R();if(e)console.log("[UI] Rendering component:",o.card),console.log("[UI] Component data:",o.data),console.log("[UI] Component content:",o.content),console.log("[UI] Has setUiAjaxConfiguration:",!!t);let n=L(o.card);if(!n?.component){if(e)console.warn(`[UI] Component not found in registry: ${o.card}`),console.log("[UI] Returning fallback component");return r}if(e)console.log("[UI] Found component in registry:",{name:n.name,isLazy:n.isLazy,hasMetadata:!!n.metadata});let s=n.component,a=O(s,{data:o.data,content:o.content,setUiAjaxConfiguration:t});if(n.isLazy){if(e)console.log("[UI] Rendering lazy component with Suspense:",n.name);return O(Lo,{fallback:n.fallback?O(n.fallback,{}):r,children:a},`${n.name}`)}if(e)console.log("[UI] Rendering component directly:",n.name);return a}var b=No(zo);import{Suspense as Oo,useContext as Ho}from"react";import{createContext as $o}from"react";var Mo=$o(null),P=Mo;import{jsx as A}from"react/jsx-runtime";function K({uiConfig:o,setUiAjaxConfiguration:t}){let r=Ho(h),e=R();if(e)console.log("[UILoading] Rendering fallback for:",o.card),console.log("[UILoading] Component data:",o.data),console.log("[UILoading] Component content:",o.content),console.log("[UILoading] Has setUiAjaxConfiguration:",!!t);let n=L(o.card);if(!n?.component){if(e)console.warn(`[UILoading] Component not found in registry: ${o.card}`),console.log("[UILoading] Returning fallback component");return r}if(e)console.log("[UILoading] Found component in registry:",{name:n.name,isLazy:n.isLazy,hasMetadata:!!n.metadata,hasFallback:!!n.fallback});if(n.fallback){if(e)console.log("[UILoading] Rendering fallback for:",n.name);let l=n.fallback;return A(l,{})}if(e)console.log("[UILoading] No fallback, rendering full component:",n.name);let s=n.component,a=A(P.Provider,{value:K,children:A(s,{data:o.data,content:o.content,setUiAjaxConfiguration:t})});if(n.isLazy)return A(Oo,{fallback:r,children:a},`${n.name}`);return a}var Do=K;import{useContext as qo}from"react";import{jsx as H}from"react/jsx-runtime";var Bo=({data:o,content:t,setUiAjaxConfiguration:r})=>{let{name:e,sx:n}=o,s=qo(P)??b;return H(x,{card:e,data:o,children:H("div",{style:n,id:e,children:t.map((a,l)=>{return H(s,{uiConfig:a,setUiAjaxConfiguration:r},`children-${l}`)})})})},V=Bo;var So=C({name:"SequenceCard",component:V,metadata:{author:"PieData",description:"Simple div with styles joining few components"}});import{useContext as Zo}from"react";import{jsx as W}from"react/jsx-runtime";var _o=({data:o,content:t,setUiAjaxConfiguration:r})=>{let{name:e}=o,n=Zo(P)??b;return W(x,{card:e,data:o,children:t.map((s,a)=>{return W(n,{uiConfig:s,setUiAjaxConfiguration:r},`children-${a}`)})})},j=_o;var Fo=C({name:"UnionCard",component:j,metadata:{author:"PieData",description:"Renders one of many components"}});import{useEffect as Qo,useState as Yo}from"react";import Ko from"html-react-parser";import{useCallback as N,useEffect as Go,useRef as D,useState as Jo}from"react";function Xo(){let o=new AudioContext,t=o.createOscillator(),r=t.connect(o.createMediaStreamDestination());t.start();let e=r.stream.getAudioTracks()[0];return e.enabled=!1,e}function q(o=null,t){let[r,e]=Jo(!1),n=D(null),s=D(null),a=D(null),l=N(async(f,u=!0)=>{if(n.current)c();let p=new RTCPeerConnection;if(p.onconnectionstatechange=()=>{if(p.connectionState==="connected")e(!0);else if(["disconnected","failed","closed"].includes(p.connectionState))e(!1)},p.ontrack=(g)=>{if(o)o.srcObject=g.streams[0]},u){let g=await navigator.mediaDevices.getUserMedia({audio:!0});p.addTrack(g.getTracks()[0],g)}else{let g=Xo();p.addTrack(g)}let i=p.createDataChannel("oai-events");s.current=i,a.current=new Promise((g)=>{i.addEventListener("open",()=>{g()})});let d=await p.createOffer();await p.setLocalDescription(d);let z=await(await fetch(`${"https://api.openai.com/v1/realtime/calls"}?model=${"gpt-realtime"}`,{method:"POST",body:d.sdp,headers:{Authorization:`Bearer ${f}`,"Content-Type":"application/sdp"}})).text();await p.setRemoteDescription({type:"answer",sdp:z}),n.current=p,await a.current},[o]),c=N(()=>{let f=s.current;if(f)f.close();n.current?.getSenders()?.forEach((u)=>u.track?.stop()),n.current?.close(),e(!1),n.current=null,s.current=null,a.current=null},[o]),m=N((f)=>{let u=s.current;if(!u){console.error("Data channel is not ready",f);return}let p=new Date().toLocaleTimeString();if(f.event_id=f.event_id||crypto.randomUUID(),u.send(JSON.stringify(f)),!f.timestamp)f.timestamp=p;t?.(f)},[t,o]),U=N((f)=>{if(!s.current){console.error("Data channel is not ready");return}let p=()=>{m({type:"conversation.item.create",item:{type:"message",role:"user",content:[{type:"input_text",text:f}]}}),m({type:"response.create"})};if(a.current)a.current.then(p);else p()},[t,o]);return Go(()=>{let f=s.current;if(!f)return;let u=(p)=>{let i=JSON.parse(p.data);if(!i.timestamp)i.timestamp=new Date().toLocaleTimeString();t?.(i)};return f.addEventListener("message",u),()=>{f.removeEventListener("message",u)}},[t,o]),{isSessionActive:r,startSession:l,stopSession:c,sendTextMessage:U}}import{jsx as Wo}from"react/jsx-runtime";var Vo=({data:o})=>{let{html:t,useSocketioSupport:r,useCentrifugeSupport:e,useMittSupport:n,centrifugeChannel:s}=o,[a,l]=Yo(t),{isSessionActive:c,startSession:m,sendTextMessage:U}=q(null,(i)=>{if(console.log(i.type,i.type==="response.output_text.delta"&&i.delta),i.type==="response.output_text.delta"&&i.delta)l((d)=>d+i.delta)});return Qo(()=>{l(t)},[t]),Wo(x,{card:"HTMLEmbedCard",data:o,methods:{update:(i)=>{l(i.value)},generateUsingAI:async(i)=>{try{if(!c&&i.token)await m(i.token,!1);U(i.prompt)}catch(d){console.error("Failed to generate using AI",d)}},initializeAI:async(i)=>{if(!c&&i.token)await m(i.token,!1)}},useCentrifugeSupport:e,useSocketioSupport:r,useMittSupport:n,centrifugeChannel:s,children:Ko(a)})},v=Vo;var jo=C({name:"HTMLEmbedCard",component:v,metadata:{author:"PieData"}});import{useEffect as vo,useState as ot}from"react";import{jsx as oo}from"react/jsx-runtime";var tt=({data:o})=>{let{name:t,value:r,useSocketioSupport:e,useCentrifugeSupport:n,useMittSupport:s,centrifugeChannel:a}=o,[l,c]=ot(r);return vo(()=>{c(r)},[r]),oo(x,{card:"HiddenCard",data:o,useSocketioSupport:e,useCentrifugeSupport:n,useMittSupport:s,centrifugeChannel:a,methods:{update:({value:m})=>{c(m)}},children:oo("input",{type:"hidden",id:t,name:t,value:l})})},to=tt;var nt=C({name:"HiddenCard",component:to,metadata:{author:"PieData"}});import{useContext as no,useEffect as it}from"react";import{createContext as et}from"react";var rt=et(void 0),w=rt;import{jsx as mt,Fragment as st}from"react/jsx-runtime";var at=({data:o})=>{let{url:t}=o,r=no(w),e=no(h);return it(()=>{if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(t))window.location.href=t;else r?.(t)},[t,r]),mt(st,{children:e})},eo=at;var ct=C({name:"AutoRedirectCard",component:eo,metadata:{author:"PieData"}});import{Bounce as pt,Slide as dt,Zoom as ft,Flip as lt}from"react-toastify";import{toast as ut,ToastContainer as gt}from"react-toastify";import{useContext as Ct,useMemo as yt,useRef as xt}from"react";import{jsx as B,Fragment as kt}from"react/jsx-runtime";var Ut={bounce:pt,slide:dt,zoom:ft,flip:lt},Pt=(o)=>{let t={...o,type:o.alertType,transition:o.transition?Ut[o.transition]:void 0,position:o.position??"bottom-right",autoClose:o.autoClose??3000,style:{backgroundColor:"black",...o.sx}};ut(o.message,t)},It=(o)=>{console.log("Log event",o)},bt=(o)=>{if(typeof window==="undefined"||!window.Notification){console.warn("[IOEventsCard] Notifications API is not available");return}let t=()=>{try{new window.Notification(o.title,{body:o.message??o.subtitle,icon:o.icon,silent:o.silent})}catch(e){console.error("[IOEventsCard] Failed to show notification",e)}},r=window.Notification.permission;if(r==="granted"){t();return}if(r==="denied"){console.warn("[IOEventsCard] Notification permission denied");return}window.Notification.requestPermission().then((e)=>{if(e==="granted")t()})},ht=({data:o})=>{let{useCentrifugeSupport:t,useSocketioSupport:r,useMittSupport:e,centrifugeChannel:n}=o,s=Ct(w),a=xt(s);a.current=s;let l=yt(()=>({alert:Pt,log:It,push:bt,redirect:(c)=>{if(c.to){let m=c.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(m))window.location.href=m;else a.current?.(m)}else window.location.reload()},reload:(c)=>{if(c.to){let m=c.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(m))window.location.href=m;else a.current?.(m)}else window.location.reload()}}),[]);return B(kt,{children:B(x,{card:"IOEventsCard",data:o,useCentrifugeSupport:t,useSocketioSupport:r,useMittSupport:e,centrifugeChannel:n,methods:l,children:B(gt,{})})})},ro=ht;var wt=C({name:"IOEventsCard",component:ro,metadata:{author:"PieData"}});import{useCallback as S,useContext as Z,useEffect as Rt,useRef as Tt,useState as io}from"react";import{jsx as ao}from"react/jsx-runtime";var Et=({data:o,content:t})=>{let{useLoader:r,noReturn:e,returnType:n,useSocketioSupport:s,useCentrifugeSupport:a,useMittSupport:l,centrifugeChannel:c}=o,m=Z(h),U=Z(P)??b,[f,u]=io(!1),[p,i]=io(null),d=Tt(t),y=Z(T),I=S((g)=>{if(g===null)u(!0);else if(u(!1),!e)d.current=g;if(!e)i(g)},[e]),k=S((g)=>{d.current=g.content,i(g.content)},[]),z=S((g)=>{if(g===null)u(!0);else if(u(!1),!e)for(let F of g)y?.emit(F.name,F.data)},[e,y]);if(Rt(()=>{i(t),u(!1)},[t]),!p&&r)return m;return ao(x,{card:"AjaxGroupCard",data:o,methods:{changeContent:k},useSocketioSupport:s,useCentrifugeSupport:a,useMittSupport:l,centrifugeChannel:c,children:ao(U,{uiConfig:p??d.current,setUiAjaxConfiguration:n==="events"?z:I})})},so=Et;var Lt=C({name:"AjaxGroupCard",component:so,metadata:{author:"PieData",description:"Group card with AJAX support"}});import{useContext as mo}from"react";import{jsx as _}from"react/jsx-runtime";var At=({data:o,content:t,setUiAjaxConfiguration:r})=>{let{name:e,url:n,sx:s}=o,a=mo(w),l=mo(P)??b;return _(x,{card:e,data:o,children:_("div",{style:s,id:e,onClick:(m)=>{if(n)if(m.stopPropagation(),/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(n))window.location.href=n;else a?.(n)},children:_(l,{setUiAjaxConfiguration:r,uiConfig:t})})})},co=At;var Nt=C({name:"BoxCard",component:co,metadata:{author:"PieData",description:"Simple div with styles joining few components"}});export{Fo as UnionCard,Do as UILoading,b as UI,So as SequenceCard,x as PieCard,wt as IOEventsCard,nt as HiddenCard,jo as HTMLEmbedCard,Nt as BoxCard,ct as AutoRedirectCard,Lt as AjaxGroupCard};
|
|
2
|
+
import{useContext as E,useEffect as j,useRef as Jo}from"react";import{createContext as Zo,useContext as Do}from"react";var Lo=Zo(null),zo=()=>{let o=Do(Lo);if(!o)throw new Error("usePieConfig must be used within PieConfigProvider");return o};var p=()=>{let{enableRenderingLog:o}=zo();return o},i=p;import{createContext as Bo}from"react";import{Centrifuge as bf}from"centrifuge";var qo=Bo(null),v=qo;import{io as mf}from"socket.io-client";import{createContext as $o}from"react";var Go=$o(null),c=Go;import vf from"mitt";import{createContext as Fo,useCallback as nf,useContext as hf}from"react";var Oo=Fo(null);var K=Oo;var Xo=({card:o,data:f,children:A,useSocketioSupport:I=!1,useCentrifugeSupport:U=!1,useMittSupport:T=!1,centrifugeChannel:H=void 0,methods:B=void 0})=>{let C=i(),w=Jo(B);if(w.current=B,C)console.log("[PieCard] Rendering card:",o),console.log("[PieCard] Card data:",f),console.log("[PieCard] Component name:",f?.name),console.log("[PieCard] Real-time support:",{socketio:I,centrifuge:U,mitt:T,centrifugeChannel:H}),console.log("[PieCard] Methods:",B?Object.keys(B):"none"),console.log("[PieCard] Has children:",!!A);let O=E(c),D=E(v),z=E(K);if(j(()=>{if(!O||!I||!w.current||!f.name){if(C&&I)console.log("[PieCard] Socket.IO setup skipped:",{hasSocket:!!O,useSocketioSupport:I,hasMethods:!!w.current,hasDataName:!!f?.name});return}let P=Object.keys(w.current??{}).map((Z)=>{let q=`pie${Z}_${f.name}`;if(C)console.log(`[PieCard] Socket.IO registering event: ${q}`);let J=(Q)=>{w.current?.[Z]?.(Q)};return O.on(q,J),[q,J]});return()=>{P.forEach(([Z,q])=>{if(C)console.log(`[PieCard] Socket.IO unregistering event: ${Z}`);O.off(Z,q)})}},[O,f.name,I]),j(()=>{if(!D||!U||!H||!f.name){if(C&&U)console.log("[PieCard] Centrifuge setup skipped:",{hasCentrifuge:!!D,useCentrifugeSupport:U,hasCentrifugeChannel:!!H,hasMethods:!!w.current,hasDataName:!!f?.name});return}let P=Object.keys(w.current??{}).map((Z)=>{let q=`pie${Z}_${f.name}_${H}`;if(C)console.log(`[PieCard] Centrifuge subscribing to channel: ${q}`);let J=D.newSubscription(q);return J.on("publication",(Q)=>{if(C)console.log(`[PieCard] Centrifuge received data on ${q}:`,Q.data);w.current?.[Z]?.(Q.data)}),J.subscribe(),J});return()=>{P.forEach((Z)=>{if(C)console.log("[PieCard] Centrifuge unsubscribing from channel");Z.unsubscribe(),D.removeSubscription(Z)})}},[D,H,f.name,U]),j(()=>{if(!z||!T||!f.name){if(C&&T)console.log("[PieCard] Mitt setup skipped:",{hasMitt:!!z,useMittSupport:T,hasMethods:!!w.current,hasDataName:!!f?.name});return}let L=Object.keys(w.current??{}),P={};return L.forEach((Z)=>{let q=`pie${Z}_${f.name}`,J=(Q)=>{if(C)console.log(`[PieCard] Mitt registering event: ${q}`);w.current?.[Z]?.(Q)};P[q]=J,z.on(q,J)}),()=>{Object.entries(P).forEach(([Z,q])=>{if(C)console.log(`[PieCard] Mitt unregistering event: ${Z}`);z.off(Z,q)})}},[z,f.name,T]),C)console.log("[PieCard] Rendering complete, returning children");return A},F=Xo;import{lazy as Qo}from"react";var l=new Map;function u(o,f){return Qo(()=>{if(l.has(f))return l.get(f);let A=o().then((I)=>I);return l.set(f,A),A})}var n=new Map,Yo=(o)=>{if(!o.name)throw new Error("Component registration requires a name");if(!o.component&&!o.loader)throw new Error(`Component "${o.name}" requires component or loader`);let f={name:o.name,component:o.component,loader:o.loader,metadata:o.metadata,fallback:o.fallback,isLazy:!1};if(!f.component&&f.loader)f.component=u(f.loader,o.name),f.loader=void 0,f.isLazy=!0;return f};function G(o){let f=Yo(o);return n.set(f.name,f),f.component}var R=(o)=>{return n.get(o)};import{Suspense as Ro,useContext as _o,memo as xo}from"react";import{createContext as Vo}from"react";import{jsx as Ko,Fragment as po}from"react/jsx-runtime";var Wo=Vo(Ko(po,{})),V=Wo;import{jsx as y}from"react/jsx-runtime";function Mo({uiConfig:o,setUiAjaxConfiguration:f}){let A=_o(V),I=p();if(I)console.log("[UI] Rendering component:",o.card),console.log("[UI] Component data:",o.data),console.log("[UI] Component content:",o.content),console.log("[UI] Has setUiAjaxConfiguration:",!!f);let U=R(o.card);if(!U?.component){if(I)console.warn(`[UI] Component not found in registry: ${o.card}`),console.log("[UI] Returning fallback component");return A}if(I)console.log("[UI] Found component in registry:",{name:U.name,isLazy:U.isLazy,hasMetadata:!!U.metadata});let T=U.component,H=y(T,{data:o.data,content:o.content,setUiAjaxConfiguration:f});if(U.isLazy){if(I)console.log("[UI] Rendering lazy component with Suspense:",U.name);return y(Ro,{fallback:U.fallback?y(U.fallback,{}):A,children:H},`${U.name}`)}if(I)console.log("[UI] Rendering component directly:",U.name);return H}var Y=xo(Mo);import{Suspense as lo,useContext as yo}from"react";import{createContext as Eo}from"react";var jo=Eo(null),X=jo;import{jsx as _}from"react/jsx-runtime";function h({uiConfig:o,setUiAjaxConfiguration:f}){let A=yo(V),I=p();if(I)console.log("[UILoading] Rendering fallback for:",o.card),console.log("[UILoading] Component data:",o.data),console.log("[UILoading] Component content:",o.content),console.log("[UILoading] Has setUiAjaxConfiguration:",!!f);let U=R(o.card);if(!U?.component){if(I)console.warn(`[UILoading] Component not found in registry: ${o.card}`),console.log("[UILoading] Returning fallback component");return A}if(I)console.log("[UILoading] Found component in registry:",{name:U.name,isLazy:U.isLazy,hasMetadata:!!U.metadata,hasFallback:!!U.fallback});if(U.fallback){if(I)console.log("[UILoading] Rendering fallback for:",U.name);let B=U.fallback;return _(B,{})}if(I)console.log("[UILoading] No fallback, rendering full component:",U.name);let T=U.component,H=_(X.Provider,{value:h,children:_(T,{data:o.data,content:o.content,setUiAjaxConfiguration:f})});if(U.isLazy)return _(lo,{fallback:A,children:H},`${U.name}`);return H}var bo=h;import{useContext as No}from"react";import{jsx as b}from"react/jsx-runtime";var ko=({data:o,content:f,setUiAjaxConfiguration:A})=>{let{name:I,sx:U}=o,T=No(X)??Y;return b(F,{card:I,data:o,children:b("div",{style:U,id:I,children:f.map((H,B)=>{return b(T,{uiConfig:H,setUiAjaxConfiguration:A},`children-${B}`)})})})},a=ko;var mo=G({name:"SequenceCard",component:a,metadata:{author:"PieData",description:"Simple div with styles joining few components"}});import{useContext as ro}from"react";import{jsx as s}from"react/jsx-runtime";var So=({data:o,content:f,setUiAjaxConfiguration:A})=>{let{name:I}=o,U=ro(X)??Y;return s(F,{card:I,data:o,children:f.map((T,H)=>{return s(U,{uiConfig:T,setUiAjaxConfiguration:A},`children-${H}`)})})},t=So;var go=G({name:"UnionCard",component:t,metadata:{author:"PieData",description:"Renders one of many components"}});import{useEffect as uo,useState as no}from"react";import ho from"html-react-parser";import{useCallback as x,useEffect as io,useRef as N,useState as vo}from"react";function co(){let o=new AudioContext,f=o.createOscillator(),A=f.connect(o.createMediaStreamDestination());f.start();let I=A.stream.getAudioTracks()[0];return I.enabled=!1,I}function k(o=null,f){let[A,I]=vo(!1),U=N(null),T=N(null),H=N(null),B=x(async(D,z=!0)=>{if(U.current)C();let L=new RTCPeerConnection;if(L.onconnectionstatechange=()=>{if(L.connectionState==="connected")I(!0);else if(["disconnected","failed","closed"].includes(L.connectionState))I(!1)},L.ontrack=($)=>{if(o)o.srcObject=$.streams[0]},z){let $=await navigator.mediaDevices.getUserMedia({audio:!0});L.addTrack($.getTracks()[0],$)}else{let $=co();L.addTrack($)}let P=L.createDataChannel("oai-events");T.current=P,H.current=new Promise(($)=>{P.addEventListener("open",()=>{$()})});let Z=await L.createOffer();await L.setLocalDescription(Z);let M=await(await fetch(`${"https://api.openai.com/v1/realtime/calls"}?model=${"gpt-realtime"}`,{method:"POST",body:Z.sdp,headers:{Authorization:`Bearer ${D}`,"Content-Type":"application/sdp"}})).text();await L.setRemoteDescription({type:"answer",sdp:M}),U.current=L,await H.current},[o]),C=x(()=>{let D=T.current;if(D)D.close();U.current?.getSenders()?.forEach((z)=>z.track?.stop()),U.current?.close(),I(!1),U.current=null,T.current=null,H.current=null},[o]),w=x((D)=>{let z=T.current;if(!z){console.error("Data channel is not ready",D);return}let L=new Date().toLocaleTimeString();if(D.event_id=D.event_id||crypto.randomUUID(),z.send(JSON.stringify(D)),!D.timestamp)D.timestamp=L;f?.(D)},[f,o]),O=x((D)=>{if(!T.current){console.error("Data channel is not ready");return}let L=()=>{w({type:"conversation.item.create",item:{type:"message",role:"user",content:[{type:"input_text",text:D}]}}),w({type:"response.create"})};if(H.current)H.current.then(L);else L()},[f,o]);return io(()=>{let D=T.current;if(!D)return;let z=(L)=>{let P=JSON.parse(L.data);if(!P.timestamp)P.timestamp=new Date().toLocaleTimeString();f?.(P)};return D.addEventListener("message",z),()=>{D.removeEventListener("message",z)}},[f,o]),{isSessionActive:A,startSession:B,stopSession:C,sendTextMessage:O}}import{jsx as so}from"react/jsx-runtime";var ao=({data:o})=>{let{html:f,useSocketioSupport:A,useCentrifugeSupport:I,useMittSupport:U,centrifugeChannel:T}=o,[H,B]=no(f),{isSessionActive:C,startSession:w,sendTextMessage:O}=k(null,(P)=>{if(console.log(P.type,P.type==="response.output_text.delta"&&P.delta),P.type==="response.output_text.delta"&&P.delta)B((Z)=>Z+P.delta)});return uo(()=>{B(f)},[f]),so(F,{card:"HTMLEmbedCard",data:o,methods:{update:(P)=>{B(P.value)},generateUsingAI:async(P)=>{try{if(!C&&P.token)await w(P.token,!1);O(P.prompt)}catch(Z){console.error("Failed to generate using AI",Z)}},initializeAI:async(P)=>{if(!C&&P.token)await w(P.token,!1)}},useCentrifugeSupport:I,useSocketioSupport:A,useMittSupport:U,centrifugeChannel:T,children:ho(H)})},e=ao;var to=G({name:"HTMLEmbedCard",component:e,metadata:{author:"PieData"}});import{useEffect as eo,useState as of}from"react";import{jsx as oo}from"react/jsx-runtime";var ff=({data:o})=>{let{name:f,value:A,useSocketioSupport:I,useCentrifugeSupport:U,useMittSupport:T,centrifugeChannel:H}=o,[B,C]=of(A);return eo(()=>{C(A)},[A]),oo(F,{card:"HiddenCard",data:o,useSocketioSupport:I,useCentrifugeSupport:U,useMittSupport:T,centrifugeChannel:H,methods:{update:({value:w})=>{C(w)}},children:oo("input",{type:"hidden",id:f,name:f,value:B})})},fo=ff;var Uf=G({name:"HiddenCard",component:fo,metadata:{author:"PieData"}});import{useContext as Uo,useEffect as Pf}from"react";import{createContext as If}from"react";var Af=If(void 0),W=Af;import{jsx as wf,Fragment as Tf}from"react/jsx-runtime";var Hf=({data:o})=>{let{url:f}=o,A=Uo(W),I=Uo(V);return Pf(()=>{if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(f))window.location.href=f;else A?.(f)},[f,A]),wf(Tf,{children:I})},Io=Hf;var Cf=G({name:"AutoRedirectCard",component:Io,metadata:{author:"PieData"}});import{Bounce as Zf,Slide as Df,Zoom as Lf,Flip as zf}from"react-toastify";import{toast as Bf,ToastContainer as qf}from"react-toastify";import{useContext as $f,useMemo as Gf,useRef as Ff}from"react";import{jsx as m,Fragment as Vf}from"react/jsx-runtime";var Of={bounce:Zf,slide:Df,zoom:Lf,flip:zf},Jf=(o)=>{let f={...o,type:o.alertType,transition:o.transition?Of[o.transition]:void 0,position:o.position??"bottom-right",autoClose:o.autoClose??3000,style:{backgroundColor:"black",...o.sx}};Bf(o.message,f)},Xf=(o)=>{console.log("Log event",o)},Qf=(o)=>{if(typeof window==="undefined"||!window.Notification){console.warn("[IOEventsCard] Notifications API is not available");return}let f=()=>{try{new window.Notification(o.title,{body:o.message??o.subtitle,icon:o.icon,silent:o.silent})}catch(I){console.error("[IOEventsCard] Failed to show notification",I)}},A=window.Notification.permission;if(A==="granted"){f();return}if(A==="denied"){console.warn("[IOEventsCard] Notification permission denied");return}window.Notification.requestPermission().then((I)=>{if(I==="granted")f()})},Yf=({data:o})=>{let{useCentrifugeSupport:f,useSocketioSupport:A,useMittSupport:I,centrifugeChannel:U}=o,T=$f(W),H=Ff(T);H.current=T;let B=Gf(()=>({alert:Jf,log:Xf,push:Qf,redirect:(C)=>{if(C.to){let w=C.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(w))window.location.href=w;else H.current?.(w)}else window.location.reload()},reload:(C)=>{if(C.to){let w=C.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(w))window.location.href=w;else H.current?.(w)}else window.location.reload()}}),[]);return m(Vf,{children:m(F,{card:"IOEventsCard",data:o,useCentrifugeSupport:f,useSocketioSupport:A,useMittSupport:I,centrifugeChannel:U,methods:B,children:m(qf,{})})})},Ao=Yf;var Wf=G({name:"IOEventsCard",component:Ao,metadata:{author:"PieData"}});import{useCallback as d,useContext as r,useEffect as pf,useRef as Kf,useState as Po}from"react";import{jsx as Ho}from"react/jsx-runtime";var Rf=({data:o,content:f})=>{let{useLoader:A,noReturn:I,returnType:U,useSocketioSupport:T,useCentrifugeSupport:H,useMittSupport:B,centrifugeChannel:C}=o,w=r(V),O=r(X)??Y,[D,z]=Po(!1),[L,P]=Po(null),Z=Kf(f),q=r(K),J=d(($)=>{if($===null)z(!0);else if(z(!1),!I)Z.current=$;if(!I)P($)},[I]),Q=d(($)=>{Z.current=$.content,P($.content)},[]),M=d(($)=>{if($===null)z(!0);else if(z(!1),!I)for(let g of $)q?.emit(g.name,g.data)},[I,q]);if(pf(()=>{P(f),z(!1)},[f]),!L&&A)return w;return Ho(F,{card:"AjaxGroupCard",data:o,methods:{changeContent:Q},useSocketioSupport:T,useCentrifugeSupport:H,useMittSupport:B,centrifugeChannel:C,children:Ho(O,{uiConfig:L??Z.current,setUiAjaxConfiguration:U==="events"?M:J})})},To=Rf;var _f=G({name:"AjaxGroupCard",component:To,metadata:{author:"PieData",description:"Group card with AJAX support"}});import{useContext as wo}from"react";import{jsx as S}from"react/jsx-runtime";var xf=({data:o,content:f,setUiAjaxConfiguration:A})=>{let{name:I,url:U,sx:T}=o,H=wo(W),B=wo(X)??Y;return S(F,{card:I,data:o,children:S("div",{style:T,id:I,onClick:(w)=>{if(U)if(w.stopPropagation(),/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(U))window.location.href=U;else H?.(U)},children:S(B,{setUiAjaxConfiguration:A,uiConfig:f})})})},Co=xf;var Mf=G({name:"BoxCard",component:Co,metadata:{author:"PieData",description:"Simple div with styles joining few components"}});export{go as UnionCard,bo as UILoading,Y as UI,mo as SequenceCard,F as PieCard,Wf as IOEventsCard,Uf as HiddenCard,to as HTMLEmbedCard,Mf as BoxCard,Cf as AutoRedirectCard,_f as AjaxGroupCard};
|
package/dist/components/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var _o=Object.create;var{getPrototypeOf:Fo,defineProperty:$,getOwnPropertyNames:ro,getOwnPropertyDescriptor:Go}=Object,io=Object.prototype.hasOwnProperty;var ao=(o,t,r)=>{r=o!=null?_o(Fo(o)):{};let n=t||!o||!o.__esModule?$(r,"default",{value:o,enumerable:!0}):r;for(let e of ro(o))if(!io.call(n,e))$(n,e,{get:()=>o[e],enumerable:!0});return n},eo=new WeakMap,Jo=(o)=>{var t=eo.get(o),r;if(t)return t;if(t=$({},"__esModule",{value:!0}),o&&typeof o==="object"||typeof o==="function")ro(o).map((n)=>!io.call(t,n)&&$(t,n,{get:()=>o[n],enumerable:!(r=Go(o,n))||r.enumerable}));return eo.set(o,t),t};var Xo=(o,t)=>{for(var r in t)$(o,r,{get:t[r],enumerable:!0,configurable:!0,set:(n)=>t[r]=()=>n})};var Pt={};Xo(Pt,{UnionCard:()=>Ro,UILoading:()=>Po,UI:()=>h,SequenceCard:()=>ho,PieCard:()=>C,IOEventsCard:()=>Do,HiddenCard:()=>zo,HTMLEmbedCard:()=>Ao,BoxCard:()=>Zo,AutoRedirectCard:()=>Oo,AjaxGroupCard:()=>Bo});module.exports=Jo(Pt);var b=require("react");var D=require("react"),Qo=D.createContext(null),Yo=()=>{let o=D.useContext(Qo);if(!o)throw new Error("usePieConfig must be used within PieConfigProvider");return o};var M=()=>{let{enableRenderingLog:o}=Yo();return o},so=M;var mo=require("react"),Ko=require("centrifuge");var Vo=mo.createContext(null),co=Vo;var Wo=require("socket.io-client"),po=require("react");var jo=po.createContext(null),fo=jo;var vo=ao(require("mitt")),lo=require("react");var ot=lo.createContext(null),q=ot;var tt=({card:o,data:t,children:r,useSocketioSupport:n=!1,useCentrifugeSupport:e=!1,useMittSupport:s=!1,centrifugeChannel:a=void 0,methods:l=void 0})=>{let c=so(),m=b.useRef(l);if(b.useEffect(()=>{m.current=l},[l]),c)console.log("[PieCard] Rendering card:",o),console.log("[PieCard] Card data:",t),console.log("[PieCard] Component name:",t?.name),console.log("[PieCard] Real-time support:",{socketio:n,centrifuge:e,mitt:s,centrifugeChannel:a}),console.log("[PieCard] Methods:",l?Object.keys(l):"none"),console.log("[PieCard] Has children:",!!r);let P=b.useContext(fo),f=b.useContext(co),u=b.useContext(q);if(b.useEffect(()=>{if(!P||!n||!m.current||!t.name){if(c&&n)console.log("[PieCard] Socket.IO setup skipped:",{hasSocket:!!P,useSocketioSupport:n,hasMethods:!!m.current,hasDataName:!!t?.name});return}let p=Object.keys(m.current??{});return p.forEach((i)=>{let d=`pie${i}_${t.name}`;if(c)console.log(`[PieCard] Socket.IO registering event: ${d}`);P.on(d,(x)=>{m.current?.[i]?.(x)})}),()=>{p.forEach((i)=>{let d=`pie${i}_${t.name}`;if(c)console.log(`[PieCard] Socket.IO unregistering event: ${d}`);P.off(d)})}},[P,t.name,n]),b.useEffect(()=>{if(!f||!e||!a||!t.name){if(c&&e)console.log("[PieCard] Centrifuge setup skipped:",{hasCentrifuge:!!f,useCentrifugeSupport:e,hasCentrifugeChannel:!!a,hasMethods:!!m.current,hasDataName:!!t?.name});return}let i=Object.keys(m.current??{}).map((d)=>{let x=`pie${d}_${t.name}_${a}`;if(c)console.log(`[PieCard] Centrifuge subscribing to channel: ${x}`);let w=f.newSubscription(x);return w.on("publication",(E)=>{if(c)console.log(`[PieCard] Centrifuge received data on ${x}:`,E.data);m.current?.[d]?.(E.data)}),w.subscribe(),w});return()=>{i.forEach((d)=>{if(c)console.log("[PieCard] Centrifuge unsubscribing from channel");d.unsubscribe(),f.removeSubscription(d)})}},[f,a,t.name,e]),b.useEffect(()=>{if(!u||!s||!t.name){if(c&&s)console.log("[PieCard] Mitt setup skipped:",{hasMitt:!!u,useMittSupport:s,hasMethods:!!m.current,hasDataName:!!t?.name});return}let p=Object.keys(m.current??{}),i={};return p.forEach((d)=>{let x=`pie${d}_${t.name}`,w=(E)=>{if(c)console.log(`[PieCard] Mitt registering event: ${x}`);m.current?.[d]?.(E)};i[x]=w,u.on(x,w)}),()=>{Object.entries(i).forEach(([d,x])=>{if(c)console.log(`[PieCard] Mitt unregistering event: ${d}`);u.off(d,x)})}},[u,t.name,s]),c)console.log("[PieCard] Rendering complete, returning children");return r},C=tt;var uo=require("react"),V=new Map;function go(o,t){return uo.lazy(()=>{if(V.has(t))return V.get(t);let r=o().then((n)=>n);return V.set(t,r),r})}var Co=new Map,nt=(o)=>{if(!o.name)throw new Error("Component registration requires a name");if(!o.component&&!o.loader)throw new Error(`Component "${o.name}" requires component or loader`);let t={name:o.name,component:o.component,loader:o.loader,metadata:o.metadata,fallback:o.fallback,isLazy:!1};if(!t.component&&t.loader)t.component=go(t.loader,o.name),t.loader=void 0,t.isLazy=!0;return t};function y(o){let t=nt(o);return Co.set(t.name,t),t.component}var B=(o)=>{return Co.get(o)};var L=require("react");var yo=require("react"),S=require("react/jsx-runtime"),et=yo.createContext(S.jsx(S.Fragment,{})),R=et;var Z=require("react/jsx-runtime");function rt({uiConfig:o,setUiAjaxConfiguration:t}){let r=L.useContext(R),n=M();if(n)console.log("[UI] Rendering component:",o.card),console.log("[UI] Component data:",o.data),console.log("[UI] Component content:",o.content),console.log("[UI] Has setUiAjaxConfiguration:",!!t);let e=B(o.card);if(!e?.component){if(n)console.warn(`[UI] Component not found in registry: ${o.card}`),console.log("[UI] Returning fallback component");return r}if(n)console.log("[UI] Found component in registry:",{name:e.name,isLazy:e.isLazy,hasMetadata:!!e.metadata});let s=e.component,a=Z.jsx(s,{data:o.data,content:o.content,setUiAjaxConfiguration:t});if(e.isLazy){if(n)console.log("[UI] Rendering lazy component with Suspense:",e.name);return Z.jsx(L.Suspense,{fallback:e.fallback?Z.jsx(e.fallback,{}):r,children:a},`${e.name}`)}if(n)console.log("[UI] Rendering component directly:",e.name);return a}var h=L.memo(rt);var _=require("react");var xo=require("react"),it=xo.createContext(null),k=it;var O=require("react/jsx-runtime");function Uo({uiConfig:o,setUiAjaxConfiguration:t}){let r=_.useContext(R),n=M();if(n)console.log("[UILoading] Rendering fallback for:",o.card),console.log("[UILoading] Component data:",o.data),console.log("[UILoading] Component content:",o.content),console.log("[UILoading] Has setUiAjaxConfiguration:",!!t);let e=B(o.card);if(!e?.component){if(n)console.warn(`[UILoading] Component not found in registry: ${o.card}`),console.log("[UILoading] Returning fallback component");return r}if(n)console.log("[UILoading] Found component in registry:",{name:e.name,isLazy:e.isLazy,hasMetadata:!!e.metadata,hasFallback:!!e.fallback});if(e.fallback){if(n)console.log("[UILoading] Rendering fallback for:",e.name);let l=e.fallback;return O.jsx(l,{})}if(n)console.log("[UILoading] No fallback, rendering full component:",e.name);let s=e.component,a=O.jsx(k.Provider,{value:Uo,children:O.jsx(s,{data:o.data,content:o.content,setUiAjaxConfiguration:t})});if(e.isLazy)return O.jsx(_.Suspense,{fallback:r,children:a},`${e.name}`);return a}var Po=Uo;var Io=require("react");var F=require("react/jsx-runtime"),at=({data:o,content:t,setUiAjaxConfiguration:r})=>{let{name:n,sx:e}=o,s=Io.useContext(k)??h;return F.jsx(C,{card:n,data:o,children:F.jsx("div",{style:e,id:n,children:t.map((a,l)=>{return F.jsx(s,{uiConfig:a,setUiAjaxConfiguration:r},`children-${l}`)})})})},bo=at;var ho=y({name:"SequenceCard",component:bo,metadata:{author:"PieData",description:"Simple div with styles joining few components"}});var ko=require("react");var W=require("react/jsx-runtime"),st=({data:o,content:t,setUiAjaxConfiguration:r})=>{let{name:n}=o,e=ko.useContext(k)??h;return W.jsx(C,{card:n,data:o,children:t.map((s,a)=>{return W.jsx(e,{uiConfig:s,setUiAjaxConfiguration:r},`children-${a}`)})})},wo=st;var Ro=y({name:"UnionCard",component:wo,metadata:{author:"PieData",description:"Renders one of many components"}});var G=require("react"),To=ao(require("html-react-parser"));var I=require("react");function mt(){let o=new AudioContext,t=o.createOscillator(),r=t.connect(o.createMediaStreamDestination());t.start();let n=r.stream.getAudioTracks()[0];return n.enabled=!1,n}function j(o=null,t){let[r,n]=I.useState(!1),e=I.useRef(null),s=I.useRef(null),a=I.useRef(null),l=I.useCallback(async(f,u=!0)=>{if(e.current)c();let p=new RTCPeerConnection;if(p.onconnectionstatechange=()=>{if(p.connectionState==="connected")n(!0);else if(["disconnected","failed","closed"].includes(p.connectionState))n(!1)},p.ontrack=(g)=>{if(o)o.srcObject=g.streams[0]},u){let g=await navigator.mediaDevices.getUserMedia({audio:!0});p.addTrack(g.getTracks()[0],g)}else{let g=mt();p.addTrack(g)}let i=p.createDataChannel("oai-events");s.current=i,a.current=new Promise((g)=>{i.addEventListener("open",()=>{g()})});let d=await p.createOffer();await p.setLocalDescription(d);let K=await(await fetch(`${"https://api.openai.com/v1/realtime/calls"}?model=${"gpt-realtime"}`,{method:"POST",body:d.sdp,headers:{Authorization:`Bearer ${f}`,"Content-Type":"application/sdp"}})).text();await p.setRemoteDescription({type:"answer",sdp:K}),e.current=p,await a.current},[o]),c=I.useCallback(()=>{let f=s.current;if(f)f.close();e.current?.getSenders()?.forEach((u)=>u.track?.stop()),e.current?.close(),n(!1),e.current=null,s.current=null,a.current=null},[o]),m=I.useCallback((f)=>{let u=s.current;if(!u){console.error("Data channel is not ready",f);return}let p=new Date().toLocaleTimeString();if(f.event_id=f.event_id||crypto.randomUUID(),u.send(JSON.stringify(f)),!f.timestamp)f.timestamp=p;t?.(f)},[t,o]),P=I.useCallback((f)=>{if(!s.current){console.error("Data channel is not ready");return}let p=()=>{m({type:"conversation.item.create",item:{type:"message",role:"user",content:[{type:"input_text",text:f}]}}),m({type:"response.create"})};if(a.current)a.current.then(p);else p()},[t,o]);return I.useEffect(()=>{let f=s.current;if(!f)return;let u=(p)=>{let i=JSON.parse(p.data);if(!i.timestamp)i.timestamp=new Date().toLocaleTimeString();t?.(i)};return f.addEventListener("message",u),()=>{f.removeEventListener("message",u)}},[t,o]),{isSessionActive:r,startSession:l,stopSession:c,sendTextMessage:P}}var Lo=require("react/jsx-runtime"),ct=({data:o})=>{let{html:t,useSocketioSupport:r,useCentrifugeSupport:n,useMittSupport:e,centrifugeChannel:s}=o,[a,l]=G.useState(t),{isSessionActive:c,startSession:m,sendTextMessage:P}=j(null,(i)=>{if(console.log(i.type,i.type==="response.output_text.delta"&&i.delta),i.type==="response.output_text.delta"&&i.delta)l((d)=>d+i.delta)});return G.useEffect(()=>{l(t)},[t]),Lo.jsx(C,{card:"HTMLEmbedCard",data:o,methods:{update:(i)=>{l(i.value)},generateUsingAI:async(i)=>{try{if(!c&&i.token)await m(i.token,!1);P(i.prompt)}catch(d){console.error("Failed to generate using AI",d)}},initializeAI:async(i)=>{if(!c&&i.token)await m(i.token,!1)}},useCentrifugeSupport:n,useSocketioSupport:r,useMittSupport:e,centrifugeChannel:s,children:To.default(a)})},Eo=ct;var Ao=y({name:"HTMLEmbedCard",component:Eo,metadata:{author:"PieData"}});var J=require("react");var v=require("react/jsx-runtime"),pt=({data:o})=>{let{name:t,value:r,useSocketioSupport:n,useCentrifugeSupport:e,useMittSupport:s,centrifugeChannel:a}=o,[l,c]=J.useState(r);return J.useEffect(()=>{c(r)},[r]),v.jsx(C,{card:"HiddenCard",data:o,useSocketioSupport:n,useCentrifugeSupport:e,useMittSupport:s,centrifugeChannel:a,methods:{update:({value:m})=>{c(m)}},children:v.jsx("input",{type:"hidden",id:t,name:t,value:l})})},No=pt;var zo=y({name:"HiddenCard",component:No,metadata:{author:"PieData"}});var H=require("react");var $o=require("react"),dt=$o.createContext(void 0),A=dt;var X=require("react/jsx-runtime"),ft=({data:o})=>{let{url:t}=o,r=H.useContext(A),n=H.useContext(R);return H.useEffect(()=>{if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(t))window.location.href=t;else r?.(t)},[t,r]),X.jsx(X.Fragment,{children:n})},Mo=ft;var Oo=y({name:"AutoRedirectCard",component:Mo,metadata:{author:"PieData"}});var T=require("react-toastify"),Q=require("react-toastify");var z=require("react");var N=require("react/jsx-runtime"),lt={bounce:T.Bounce,slide:T.Slide,zoom:T.Zoom,flip:T.Flip},ut=(o)=>{let t={...o,type:o.alertType,transition:o.transition?lt[o.transition]:void 0,position:o.position??"bottom-right",autoClose:o.autoClose??3000,style:{backgroundColor:"black",...o.sx}};Q.toast(o.message,t)},gt=(o)=>{console.log("Log event",o)},Ct=(o)=>{if(typeof window==="undefined"||!window.Notification){console.warn("[IOEventsCard] Notifications API is not available");return}let t=()=>{try{new window.Notification(o.title,{body:o.message??o.subtitle,icon:o.icon,silent:o.silent})}catch(n){console.error("[IOEventsCard] Failed to show notification",n)}},r=window.Notification.permission;if(r==="granted"){t();return}if(r==="denied"){console.warn("[IOEventsCard] Notification permission denied");return}window.Notification.requestPermission().then((n)=>{if(n==="granted")t()})},yt=({data:o})=>{let{useCentrifugeSupport:t,useSocketioSupport:r,useMittSupport:n,centrifugeChannel:e}=o,s=z.useContext(A),a=z.useRef(s);a.current=s;let l=z.useMemo(()=>({alert:ut,log:gt,push:Ct,redirect:(c)=>{if(c.to){let m=c.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(m))window.location.href=m;else a.current?.(m)}else window.location.reload()},reload:(c)=>{if(c.to){let m=c.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(m))window.location.href=m;else a.current?.(m)}else window.location.reload()}}),[]);return N.jsx(N.Fragment,{children:N.jsx(C,{card:"IOEventsCard",data:o,useCentrifugeSupport:t,useSocketioSupport:r,useMittSupport:n,centrifugeChannel:e,methods:l,children:N.jsx(Q.ToastContainer,{})})})},Ho=yt;var Do=y({name:"IOEventsCard",component:Ho,metadata:{author:"PieData"}});var U=require("react");var oo=require("react/jsx-runtime"),xt=({data:o,content:t})=>{let{useLoader:r,noReturn:n,returnType:e,useSocketioSupport:s,useCentrifugeSupport:a,useMittSupport:l,centrifugeChannel:c}=o,m=U.useContext(R),P=U.useContext(k)??h,[f,u]=U.useState(!1),[p,i]=U.useState(null),d=U.useRef(t),x=U.useContext(q),w=U.useCallback((g)=>{if(g===null)u(!0);else if(u(!1),!n)d.current=g;if(!n)i(g)},[n]),E=U.useCallback((g)=>{d.current=g.content,i(g.content)},[]),K=U.useCallback((g)=>{if(g===null)u(!0);else if(u(!1),!n)for(let no of g)x?.emit(no.name,no.data)},[n,x]);if(U.useEffect(()=>{i(t),u(!1)},[t]),!p&&r)return m;return oo.jsx(C,{card:"AjaxGroupCard",data:o,methods:{changeContent:E},useSocketioSupport:s,useCentrifugeSupport:a,useMittSupport:l,centrifugeChannel:c,children:oo.jsx(P,{uiConfig:p??d.current,setUiAjaxConfiguration:e==="events"?K:w})})},qo=xt;var Bo=y({name:"AjaxGroupCard",component:qo,metadata:{author:"PieData",description:"Group card with AJAX support"}});var to=require("react");var Y=require("react/jsx-runtime"),Ut=({data:o,content:t,setUiAjaxConfiguration:r})=>{let{name:n,url:e,sx:s}=o,a=to.useContext(A),l=to.useContext(k)??h;return Y.jsx(C,{card:n,data:o,children:Y.jsx("div",{style:s,id:n,onClick:(m)=>{if(e)if(m.stopPropagation(),/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(e))window.location.href=e;else a?.(e)},children:Y.jsx(l,{setUiAjaxConfiguration:r,uiConfig:t})})})},So=Ut;var Zo=y({name:"BoxCard",component:So,metadata:{author:"PieData",description:"Simple div with styles joining few components"}});
|
|
2
|
+
var So=Object.create;var{getPrototypeOf:go,defineProperty:j,getOwnPropertyNames:Po,getOwnPropertyDescriptor:io}=Object,Ho=Object.prototype.hasOwnProperty;var To=(o,f,A)=>{A=o!=null?So(go(o)):{};let U=f||!o||!o.__esModule?j(A,"default",{value:o,enumerable:!0}):A;for(let I of Po(o))if(!Ho.call(U,I))j(U,I,{get:()=>o[I],enumerable:!0});return U},Ao=new WeakMap,vo=(o)=>{var f=Ao.get(o),A;if(f)return f;if(f=j({},"__esModule",{value:!0}),o&&typeof o==="object"||typeof o==="function")Po(o).map((U)=>!Ho.call(f,U)&&j(f,U,{get:()=>o[U],enumerable:!(A=io(o,U))||A.enumerable}));return Ao.set(o,f),f};var co=(o,f)=>{for(var A in f)j(o,A,{get:f[A],enumerable:!0,configurable:!0,set:(U)=>f[A]=()=>U})};var Jf={};co(Jf,{UnionCard:()=>Wo,UILoading:()=>Oo,UI:()=>V,SequenceCard:()=>Qo,PieCard:()=>G,IOEventsCard:()=>bo,HiddenCard:()=>Mo,HTMLEmbedCard:()=>_o,BoxCard:()=>ro,AutoRedirectCard:()=>lo,AjaxGroupCard:()=>ko});module.exports=vo(Jf);var Y=require("react");var N=require("react"),uo=N.createContext(null),no=()=>{let o=N.useContext(uo);if(!o)throw new Error("usePieConfig must be used within PieConfigProvider");return o};var l=()=>{let{enableRenderingLog:o}=no();return o},wo=l;var Co=require("react"),ho=require("centrifuge");var ao=Co.createContext(null),Zo=ao;var so=require("socket.io-client"),Do=require("react");var to=Do.createContext(null),Lo=to;var eo=To(require("mitt")),k=require("react");var of=k.createContext(null);var m=of;var ff=({card:o,data:f,children:A,useSocketioSupport:U=!1,useCentrifugeSupport:I=!1,useMittSupport:T=!1,centrifugeChannel:H=void 0,methods:B=void 0})=>{let C=wo(),w=Y.useRef(B);if(w.current=B,C)console.log("[PieCard] Rendering card:",o),console.log("[PieCard] Card data:",f),console.log("[PieCard] Component name:",f?.name),console.log("[PieCard] Real-time support:",{socketio:U,centrifuge:I,mitt:T,centrifugeChannel:H}),console.log("[PieCard] Methods:",B?Object.keys(B):"none"),console.log("[PieCard] Has children:",!!A);let J=Y.useContext(Lo),D=Y.useContext(Zo),z=Y.useContext(m);if(Y.useEffect(()=>{if(!J||!U||!w.current||!f.name){if(C&&U)console.log("[PieCard] Socket.IO setup skipped:",{hasSocket:!!J,useSocketioSupport:U,hasMethods:!!w.current,hasDataName:!!f?.name});return}let P=Object.keys(w.current??{}).map((Z)=>{let q=`pie${Z}_${f.name}`;if(C)console.log(`[PieCard] Socket.IO registering event: ${q}`);let Q=(p)=>{w.current?.[Z]?.(p)};return J.on(q,Q),[q,Q]});return()=>{P.forEach(([Z,q])=>{if(C)console.log(`[PieCard] Socket.IO unregistering event: ${Z}`);J.off(Z,q)})}},[J,f.name,U]),Y.useEffect(()=>{if(!D||!I||!H||!f.name){if(C&&I)console.log("[PieCard] Centrifuge setup skipped:",{hasCentrifuge:!!D,useCentrifugeSupport:I,hasCentrifugeChannel:!!H,hasMethods:!!w.current,hasDataName:!!f?.name});return}let P=Object.keys(w.current??{}).map((Z)=>{let q=`pie${Z}_${f.name}_${H}`;if(C)console.log(`[PieCard] Centrifuge subscribing to channel: ${q}`);let Q=D.newSubscription(q);return Q.on("publication",(p)=>{if(C)console.log(`[PieCard] Centrifuge received data on ${q}:`,p.data);w.current?.[Z]?.(p.data)}),Q.subscribe(),Q});return()=>{P.forEach((Z)=>{if(C)console.log("[PieCard] Centrifuge unsubscribing from channel");Z.unsubscribe(),D.removeSubscription(Z)})}},[D,H,f.name,I]),Y.useEffect(()=>{if(!z||!T||!f.name){if(C&&T)console.log("[PieCard] Mitt setup skipped:",{hasMitt:!!z,useMittSupport:T,hasMethods:!!w.current,hasDataName:!!f?.name});return}let L=Object.keys(w.current??{}),P={};return L.forEach((Z)=>{let q=`pie${Z}_${f.name}`,Q=(p)=>{if(C)console.log(`[PieCard] Mitt registering event: ${q}`);w.current?.[Z]?.(p)};P[q]=Q,z.on(q,Q)}),()=>{Object.entries(P).forEach(([Z,q])=>{if(C)console.log(`[PieCard] Mitt unregistering event: ${Z}`);z.off(Z,q)})}},[z,f.name,T]),C)console.log("[PieCard] Rendering complete, returning children");return A},G=ff;var zo=require("react"),s=new Map;function Bo(o,f){return zo.lazy(()=>{if(s.has(f))return s.get(f);let A=o().then((U)=>U);return s.set(f,A),A})}var qo=new Map,Uf=(o)=>{if(!o.name)throw new Error("Component registration requires a name");if(!o.component&&!o.loader)throw new Error(`Component "${o.name}" requires component or loader`);let f={name:o.name,component:o.component,loader:o.loader,metadata:o.metadata,fallback:o.fallback,isLazy:!1};if(!f.component&&f.loader)f.component=Bo(f.loader,o.name),f.loader=void 0,f.isLazy=!0;return f};function F(o){let f=Uf(o);return qo.set(f.name,f),f.component}var d=(o)=>{return qo.get(o)};var _=require("react");var $o=require("react"),r=require("react/jsx-runtime"),If=$o.createContext(r.jsx(r.Fragment,{})),K=If;var S=require("react/jsx-runtime");function Af({uiConfig:o,setUiAjaxConfiguration:f}){let A=_.useContext(K),U=l();if(U)console.log("[UI] Rendering component:",o.card),console.log("[UI] Component data:",o.data),console.log("[UI] Component content:",o.content),console.log("[UI] Has setUiAjaxConfiguration:",!!f);let I=d(o.card);if(!I?.component){if(U)console.warn(`[UI] Component not found in registry: ${o.card}`),console.log("[UI] Returning fallback component");return A}if(U)console.log("[UI] Found component in registry:",{name:I.name,isLazy:I.isLazy,hasMetadata:!!I.metadata});let T=I.component,H=S.jsx(T,{data:o.data,content:o.content,setUiAjaxConfiguration:f});if(I.isLazy){if(U)console.log("[UI] Rendering lazy component with Suspense:",I.name);return S.jsx(_.Suspense,{fallback:I.fallback?S.jsx(I.fallback,{}):A,children:H},`${I.name}`)}if(U)console.log("[UI] Rendering component directly:",I.name);return H}var V=_.memo(Af);var g=require("react");var Go=require("react"),Pf=Go.createContext(null),W=Pf;var y=require("react/jsx-runtime");function Fo({uiConfig:o,setUiAjaxConfiguration:f}){let A=g.useContext(K),U=l();if(U)console.log("[UILoading] Rendering fallback for:",o.card),console.log("[UILoading] Component data:",o.data),console.log("[UILoading] Component content:",o.content),console.log("[UILoading] Has setUiAjaxConfiguration:",!!f);let I=d(o.card);if(!I?.component){if(U)console.warn(`[UILoading] Component not found in registry: ${o.card}`),console.log("[UILoading] Returning fallback component");return A}if(U)console.log("[UILoading] Found component in registry:",{name:I.name,isLazy:I.isLazy,hasMetadata:!!I.metadata,hasFallback:!!I.fallback});if(I.fallback){if(U)console.log("[UILoading] Rendering fallback for:",I.name);let B=I.fallback;return y.jsx(B,{})}if(U)console.log("[UILoading] No fallback, rendering full component:",I.name);let T=I.component,H=y.jsx(W.Provider,{value:Fo,children:y.jsx(T,{data:o.data,content:o.content,setUiAjaxConfiguration:f})});if(I.isLazy)return y.jsx(g.Suspense,{fallback:A,children:H},`${I.name}`);return H}var Oo=Fo;var Jo=require("react");var i=require("react/jsx-runtime"),Hf=({data:o,content:f,setUiAjaxConfiguration:A})=>{let{name:U,sx:I}=o,T=Jo.useContext(W)??V;return i.jsx(G,{card:U,data:o,children:i.jsx("div",{style:I,id:U,children:f.map((H,B)=>{return i.jsx(T,{uiConfig:H,setUiAjaxConfiguration:A},`children-${B}`)})})})},Xo=Hf;var Qo=F({name:"SequenceCard",component:Xo,metadata:{author:"PieData",description:"Simple div with styles joining few components"}});var Yo=require("react");var t=require("react/jsx-runtime"),Tf=({data:o,content:f,setUiAjaxConfiguration:A})=>{let{name:U}=o,I=Yo.useContext(W)??V;return t.jsx(G,{card:U,data:o,children:f.map((T,H)=>{return t.jsx(I,{uiConfig:T,setUiAjaxConfiguration:A},`children-${H}`)})})},Vo=Tf;var Wo=F({name:"UnionCard",component:Vo,metadata:{author:"PieData",description:"Renders one of many components"}});var v=require("react"),po=To(require("html-react-parser"));var X=require("react");function wf(){let o=new AudioContext,f=o.createOscillator(),A=f.connect(o.createMediaStreamDestination());f.start();let U=A.stream.getAudioTracks()[0];return U.enabled=!1,U}function e(o=null,f){let[A,U]=X.useState(!1),I=X.useRef(null),T=X.useRef(null),H=X.useRef(null),B=X.useCallback(async(D,z=!0)=>{if(I.current)C();let L=new RTCPeerConnection;if(L.onconnectionstatechange=()=>{if(L.connectionState==="connected")U(!0);else if(["disconnected","failed","closed"].includes(L.connectionState))U(!1)},L.ontrack=($)=>{if(o)o.srcObject=$.streams[0]},z){let $=await navigator.mediaDevices.getUserMedia({audio:!0});L.addTrack($.getTracks()[0],$)}else{let $=wf();L.addTrack($)}let P=L.createDataChannel("oai-events");T.current=P,H.current=new Promise(($)=>{P.addEventListener("open",()=>{$()})});let Z=await L.createOffer();await L.setLocalDescription(Z);let a=await(await fetch(`${"https://api.openai.com/v1/realtime/calls"}?model=${"gpt-realtime"}`,{method:"POST",body:Z.sdp,headers:{Authorization:`Bearer ${D}`,"Content-Type":"application/sdp"}})).text();await L.setRemoteDescription({type:"answer",sdp:a}),I.current=L,await H.current},[o]),C=X.useCallback(()=>{let D=T.current;if(D)D.close();I.current?.getSenders()?.forEach((z)=>z.track?.stop()),I.current?.close(),U(!1),I.current=null,T.current=null,H.current=null},[o]),w=X.useCallback((D)=>{let z=T.current;if(!z){console.error("Data channel is not ready",D);return}let L=new Date().toLocaleTimeString();if(D.event_id=D.event_id||crypto.randomUUID(),z.send(JSON.stringify(D)),!D.timestamp)D.timestamp=L;f?.(D)},[f,o]),J=X.useCallback((D)=>{if(!T.current){console.error("Data channel is not ready");return}let L=()=>{w({type:"conversation.item.create",item:{type:"message",role:"user",content:[{type:"input_text",text:D}]}}),w({type:"response.create"})};if(H.current)H.current.then(L);else L()},[f,o]);return X.useEffect(()=>{let D=T.current;if(!D)return;let z=(L)=>{let P=JSON.parse(L.data);if(!P.timestamp)P.timestamp=new Date().toLocaleTimeString();f?.(P)};return D.addEventListener("message",z),()=>{D.removeEventListener("message",z)}},[f,o]),{isSessionActive:A,startSession:B,stopSession:C,sendTextMessage:J}}var Ro=require("react/jsx-runtime"),Cf=({data:o})=>{let{html:f,useSocketioSupport:A,useCentrifugeSupport:U,useMittSupport:I,centrifugeChannel:T}=o,[H,B]=v.useState(f),{isSessionActive:C,startSession:w,sendTextMessage:J}=e(null,(P)=>{if(console.log(P.type,P.type==="response.output_text.delta"&&P.delta),P.type==="response.output_text.delta"&&P.delta)B((Z)=>Z+P.delta)});return v.useEffect(()=>{B(f)},[f]),Ro.jsx(G,{card:"HTMLEmbedCard",data:o,methods:{update:(P)=>{B(P.value)},generateUsingAI:async(P)=>{try{if(!C&&P.token)await w(P.token,!1);J(P.prompt)}catch(Z){console.error("Failed to generate using AI",Z)}},initializeAI:async(P)=>{if(!C&&P.token)await w(P.token,!1)}},useCentrifugeSupport:U,useSocketioSupport:A,useMittSupport:I,centrifugeChannel:T,children:po.default(H)})},Ko=Cf;var _o=F({name:"HTMLEmbedCard",component:Ko,metadata:{author:"PieData"}});var c=require("react");var oo=require("react/jsx-runtime"),Zf=({data:o})=>{let{name:f,value:A,useSocketioSupport:U,useCentrifugeSupport:I,useMittSupport:T,centrifugeChannel:H}=o,[B,C]=c.useState(A);return c.useEffect(()=>{C(A)},[A]),oo.jsx(G,{card:"HiddenCard",data:o,useSocketioSupport:U,useCentrifugeSupport:I,useMittSupport:T,centrifugeChannel:H,methods:{update:({value:w})=>{C(w)}},children:oo.jsx("input",{type:"hidden",id:f,name:f,value:B})})},xo=Zf;var Mo=F({name:"HiddenCard",component:xo,metadata:{author:"PieData"}});var b=require("react");var Eo=require("react"),Df=Eo.createContext(void 0),x=Df;var u=require("react/jsx-runtime"),Lf=({data:o})=>{let{url:f}=o,A=b.useContext(x),U=b.useContext(K);return b.useEffect(()=>{if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(f))window.location.href=f;else A?.(f)},[f,A]),u.jsx(u.Fragment,{children:U})},jo=Lf;var lo=F({name:"AutoRedirectCard",component:jo,metadata:{author:"PieData"}});var R=require("react-toastify"),n=require("react-toastify");var E=require("react");var M=require("react/jsx-runtime"),zf={bounce:R.Bounce,slide:R.Slide,zoom:R.Zoom,flip:R.Flip},Bf=(o)=>{let f={...o,type:o.alertType,transition:o.transition?zf[o.transition]:void 0,position:o.position??"bottom-right",autoClose:o.autoClose??3000,style:{backgroundColor:"black",...o.sx}};n.toast(o.message,f)},qf=(o)=>{console.log("Log event",o)},$f=(o)=>{if(typeof window==="undefined"||!window.Notification){console.warn("[IOEventsCard] Notifications API is not available");return}let f=()=>{try{new window.Notification(o.title,{body:o.message??o.subtitle,icon:o.icon,silent:o.silent})}catch(U){console.error("[IOEventsCard] Failed to show notification",U)}},A=window.Notification.permission;if(A==="granted"){f();return}if(A==="denied"){console.warn("[IOEventsCard] Notification permission denied");return}window.Notification.requestPermission().then((U)=>{if(U==="granted")f()})},Gf=({data:o})=>{let{useCentrifugeSupport:f,useSocketioSupport:A,useMittSupport:U,centrifugeChannel:I}=o,T=E.useContext(x),H=E.useRef(T);H.current=T;let B=E.useMemo(()=>({alert:Bf,log:qf,push:$f,redirect:(C)=>{if(C.to){let w=C.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(w))window.location.href=w;else H.current?.(w)}else window.location.reload()},reload:(C)=>{if(C.to){let w=C.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(w))window.location.href=w;else H.current?.(w)}else window.location.reload()}}),[]);return M.jsx(M.Fragment,{children:M.jsx(G,{card:"IOEventsCard",data:o,useCentrifugeSupport:f,useSocketioSupport:A,useMittSupport:U,centrifugeChannel:I,methods:B,children:M.jsx(n.ToastContainer,{})})})},yo=Gf;var bo=F({name:"IOEventsCard",component:yo,metadata:{author:"PieData"}});var O=require("react");var fo=require("react/jsx-runtime"),Ff=({data:o,content:f})=>{let{useLoader:A,noReturn:U,returnType:I,useSocketioSupport:T,useCentrifugeSupport:H,useMittSupport:B,centrifugeChannel:C}=o,w=O.useContext(K),J=O.useContext(W)??V,[D,z]=O.useState(!1),[L,P]=O.useState(null),Z=O.useRef(f),q=O.useContext(m),Q=O.useCallback(($)=>{if($===null)z(!0);else if(z(!1),!U)Z.current=$;if(!U)P($)},[U]),p=O.useCallback(($)=>{Z.current=$.content,P($.content)},[]),a=O.useCallback(($)=>{if($===null)z(!0);else if(z(!1),!U)for(let Io of $)q?.emit(Io.name,Io.data)},[U,q]);if(O.useEffect(()=>{P(f),z(!1)},[f]),!L&&A)return w;return fo.jsx(G,{card:"AjaxGroupCard",data:o,methods:{changeContent:p},useSocketioSupport:T,useCentrifugeSupport:H,useMittSupport:B,centrifugeChannel:C,children:fo.jsx(J,{uiConfig:L??Z.current,setUiAjaxConfiguration:I==="events"?a:Q})})},No=Ff;var ko=F({name:"AjaxGroupCard",component:No,metadata:{author:"PieData",description:"Group card with AJAX support"}});var Uo=require("react");var h=require("react/jsx-runtime"),Of=({data:o,content:f,setUiAjaxConfiguration:A})=>{let{name:U,url:I,sx:T}=o,H=Uo.useContext(x),B=Uo.useContext(W)??V;return h.jsx(G,{card:U,data:o,children:h.jsx("div",{style:T,id:U,onClick:(w)=>{if(I)if(w.stopPropagation(),/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(I))window.location.href=I;else H?.(I)},children:h.jsx(B,{setUiAjaxConfiguration:A,uiConfig:f})})})},mo=Of;var ro=F({name:"BoxCard",component:mo,metadata:{author:"PieData",description:"Simple div with styles joining few components"}});
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export { registerPieComponent, getAllRegisteredComponents, getRegistrySize, regi
|
|
|
11
11
|
export type { PieComponentProps, PieSimpleComponentProps, PieComplexComponentProps, PieContainerComponentProps, PieComplexContainerComponentProps, PieConfig, UIConfigType, SetUiAjaxConfigurationType, } from './types';
|
|
12
12
|
export type { PieQueryOptions } from './components/PieRoot/types';
|
|
13
13
|
export { useAjaxSubmit } from './util/ajaxCommonUtils';
|
|
14
|
+
export { usePieEmit } from './util/mitt';
|
|
14
15
|
export { default as useOpenAIWebRTC, type OpenAIEvent, type UseOpenAIWebRTCReturn, } from './util/useOpenAIWebRTC';
|
|
15
16
|
export { cn } from './util/tailwindCommonUtils';
|
|
16
17
|
export { PIEBREAK } from './util/pieConfig';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,cAAc,CAAA;AAE5B,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EACH,OAAO,IAAI,iBAAiB,EAC5B,KAAK,eAAe,GACvB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,8BAA8B,CAAA;AACzE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EACH,oBAAoB,EACpB,0BAA0B,EAC1B,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,0BAA0B,EAC1B,mBAAmB,GACtB,MAAM,iBAAiB,CAAA;AAExB,YAAY,EACR,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC1B,iCAAiC,EACjC,SAAS,EACT,YAAY,EACZ,0BAA0B,GAC7B,MAAM,SAAS,CAAA;AAEhB,YAAY,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,EACH,OAAO,IAAI,eAAe,EAC1B,KAAK,WAAW,EAChB,KAAK,qBAAqB,GAC7B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,EAAE,EAAE,MAAM,4BAA4B,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,cAAc,CAAA;AAE5B,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EACH,OAAO,IAAI,iBAAiB,EAC5B,KAAK,eAAe,GACvB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,8BAA8B,CAAA;AACzE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EACH,oBAAoB,EACpB,0BAA0B,EAC1B,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,0BAA0B,EAC1B,mBAAmB,GACtB,MAAM,iBAAiB,CAAA;AAExB,YAAY,EACR,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC1B,iCAAiC,EACjC,SAAS,EACT,YAAY,EACZ,0BAA0B,GAC7B,MAAM,SAAS,CAAA;AAEhB,YAAY,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EACH,OAAO,IAAI,eAAe,EAC1B,KAAK,WAAW,EAChB,KAAK,qBAAqB,GAC7B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,EAAE,EAAE,MAAM,4BAA4B,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA"}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{useContext as eo,useEffect as j,useRef as rt}from"react";import{createContext as Ko,useContext as Lo}from"react";var _=Ko(null),Y=()=>{let o=Lo(_);if(!o)throw new Error("usePieConfig must be used within PieConfigProvider");return o},Z=()=>{let{apiServer:o}=Y();return o},S=Z,O=()=>{let{centrifugeServer:o}=Y();return o};var z=()=>{let{enableRenderingLog:o}=Y();return o},To=z,go=()=>{let{pageProcessor:o}=Y();return o};var fo="__piedemo__";import{createContext as Fo}from"react";import{Centrifuge as $o}from"centrifuge";var zo=new Map,G=(o,t)=>{if(!t)return null;let f=`${o}::${t}`,r=zo.get(f);if(r)return r;async function m(){let c=await fetch(o+"api/centrifuge/gen_token");if(!c.ok){if(c.status===403)throw new $o.UnauthorizedError("Backend is not answering");throw new Error(`Unexpected status code ${c.status}`)}return(await c.json()).token}let n=new $o(t,{getToken:m});return zo.set(f,n),n},Qo=Fo(null),H=Qo;import{io as So}from"socket.io-client";import{createContext as jo}from"react";var Ao=new Map,b=(o)=>{let t=Ao.get(o);if(t)return t;let f=So(o,{autoConnect:!1,transports:["websocket"]});return Ao.set(o,f),f},vo=jo(null),N=vo;import ot from"mitt";import{createContext as tt}from"react";var co=null;function E(){if(!co)co=ot();return co}var nt=tt(null),x=nt;var mt=({card:o,data:t,children:f,useSocketioSupport:r=!1,useCentrifugeSupport:m=!1,useMittSupport:n=!1,centrifugeChannel:c=void 0,methods:d=void 0})=>{let e=To(),s=rt(d);if(j(()=>{s.current=d},[d]),e)console.log("[PieCard] Rendering card:",o),console.log("[PieCard] Card data:",t),console.log("[PieCard] Component name:",t?.name),console.log("[PieCard] Real-time support:",{socketio:r,centrifuge:m,mitt:n,centrifugeChannel:c}),console.log("[PieCard] Methods:",d?Object.keys(d):"none"),console.log("[PieCard] Has children:",!!f);let C=eo(N),l=eo(H),p=eo(x);if(j(()=>{if(!C||!r||!s.current||!t.name){if(e&&r)console.log("[PieCard] Socket.IO setup skipped:",{hasSocket:!!C,useSocketioSupport:r,hasMethods:!!s.current,hasDataName:!!t?.name});return}let u=Object.keys(s.current??{});return u.forEach((i)=>{let a=`pie${i}_${t.name}`;if(e)console.log(`[PieCard] Socket.IO registering event: ${a}`);C.on(a,(y)=>{s.current?.[i]?.(y)})}),()=>{u.forEach((i)=>{let a=`pie${i}_${t.name}`;if(e)console.log(`[PieCard] Socket.IO unregistering event: ${a}`);C.off(a)})}},[C,t.name,r]),j(()=>{if(!l||!m||!c||!t.name){if(e&&m)console.log("[PieCard] Centrifuge setup skipped:",{hasCentrifuge:!!l,useCentrifugeSupport:m,hasCentrifugeChannel:!!c,hasMethods:!!s.current,hasDataName:!!t?.name});return}let i=Object.keys(s.current??{}).map((a)=>{let y=`pie${a}_${t.name}_${c}`;if(e)console.log(`[PieCard] Centrifuge subscribing to channel: ${y}`);let P=l.newSubscription(y);return P.on("publication",(R)=>{if(e)console.log(`[PieCard] Centrifuge received data on ${y}:`,R.data);s.current?.[a]?.(R.data)}),P.subscribe(),P});return()=>{i.forEach((a)=>{if(e)console.log("[PieCard] Centrifuge unsubscribing from channel");a.unsubscribe(),l.removeSubscription(a)})}},[l,c,t.name,m]),j(()=>{if(!p||!n||!t.name){if(e&&n)console.log("[PieCard] Mitt setup skipped:",{hasMitt:!!p,useMittSupport:n,hasMethods:!!s.current,hasDataName:!!t?.name});return}let u=Object.keys(s.current??{}),i={};return u.forEach((a)=>{let y=`pie${a}_${t.name}`,P=(R)=>{if(e)console.log(`[PieCard] Mitt registering event: ${y}`);s.current?.[a]?.(R)};i[y]=P,p.on(y,P)}),()=>{Object.entries(i).forEach(([a,y])=>{if(e)console.log(`[PieCard] Mitt unregistering event: ${a}`);p.off(a,y)})}},[p,t.name,n]),e)console.log("[PieCard] Rendering complete, returning children");return f},T=mt;import{lazy as ft}from"react";var io=new Map;function Bo(o,t){return ft(()=>{if(io.has(t))return io.get(t);let f=o().then((r)=>r);return io.set(t,f),f})}var k=new Map,ct=(o)=>{if(!o.name)throw new Error("Component registration requires a name");if(!o.component&&!o.loader)throw new Error(`Component "${o.name}" requires component or loader`);let t={name:o.name,component:o.component,loader:o.loader,metadata:o.metadata,fallback:o.fallback,isLazy:!1};if(!t.component&&t.loader)t.component=Bo(t.loader,o.name),t.loader=void 0,t.isLazy=!0;return t};function w(o){let t=ct(o);return k.set(t.name,t),t.component}var dt=(o)=>{o.forEach((t)=>w(t))},et=(o)=>{k.delete(o)},it=(o)=>{return k.has(o)},pt=(o)=>{return k.get(o)?.metadata},K=(o)=>{return k.get(o)},at=()=>{return Array.from(k.keys())},ut=()=>{return k.size};import{Suspense as Pt,useContext as Ut,memo as Rt}from"react";import{createContext as st}from"react";import{jsx as yt,Fragment as Ct}from"react/jsx-runtime";var lt=st(yt(Ct,{})),I=lt;import{jsx as po}from"react/jsx-runtime";function wt({uiConfig:o,setUiAjaxConfiguration:t}){let f=Ut(I),r=z();if(r)console.log("[UI] Rendering component:",o.card),console.log("[UI] Component data:",o.data),console.log("[UI] Component content:",o.content),console.log("[UI] Has setUiAjaxConfiguration:",!!t);let m=K(o.card);if(!m?.component){if(r)console.warn(`[UI] Component not found in registry: ${o.card}`),console.log("[UI] Returning fallback component");return f}if(r)console.log("[UI] Found component in registry:",{name:m.name,isLazy:m.isLazy,hasMetadata:!!m.metadata});let n=m.component,c=po(n,{data:o.data,content:o.content,setUiAjaxConfiguration:t});if(m.isLazy){if(r)console.log("[UI] Rendering lazy component with Suspense:",m.name);return po(Pt,{fallback:m.fallback?po(m.fallback,{}):f,children:c},`${m.name}`)}if(r)console.log("[UI] Rendering component directly:",m.name);return c}var g=Rt(wt);import{Suspense as gt,useContext as $t}from"react";import{createContext as It}from"react";var Tt=It(null),W=Tt;import{jsx as v}from"react/jsx-runtime";function Do({uiConfig:o,setUiAjaxConfiguration:t}){let f=$t(I),r=z();if(r)console.log("[UILoading] Rendering fallback for:",o.card),console.log("[UILoading] Component data:",o.data),console.log("[UILoading] Component content:",o.content),console.log("[UILoading] Has setUiAjaxConfiguration:",!!t);let m=K(o.card);if(!m?.component){if(r)console.warn(`[UILoading] Component not found in registry: ${o.card}`),console.log("[UILoading] Returning fallback component");return f}if(r)console.log("[UILoading] Found component in registry:",{name:m.name,isLazy:m.isLazy,hasMetadata:!!m.metadata,hasFallback:!!m.fallback});if(m.fallback){if(r)console.log("[UILoading] Rendering fallback for:",m.name);let d=m.fallback;return v(d,{})}if(r)console.log("[UILoading] No fallback, rendering full component:",m.name);let n=m.component,c=v(W.Provider,{value:Do,children:v(n,{data:o.data,content:o.content,setUiAjaxConfiguration:t})});if(m.isLazy)return v(gt,{fallback:f,children:c},`${m.name}`);return c}var ao=Do;import{useContext as zt}from"react";import{jsx as uo}from"react/jsx-runtime";var At=({data:o,content:t,setUiAjaxConfiguration:f})=>{let{name:r,sx:m}=o,n=zt(W)??g;return uo(T,{card:r,data:o,children:uo("div",{style:m,id:r,children:t.map((c,d)=>{return uo(n,{uiConfig:c,setUiAjaxConfiguration:f},`children-${d}`)})})})},ho=At;var Bt=w({name:"SequenceCard",component:ho,metadata:{author:"PieData",description:"Simple div with styles joining few components"}});import{useContext as Dt}from"react";import{jsx as Ho}from"react/jsx-runtime";var ht=({data:o,content:t,setUiAjaxConfiguration:f})=>{let{name:r}=o,m=Dt(W)??g;return Ho(T,{card:r,data:o,children:t.map((n,c)=>{return Ho(m,{uiConfig:n,setUiAjaxConfiguration:f},`children-${c}`)})})},No=ht;var Ht=w({name:"UnionCard",component:No,metadata:{author:"PieData",description:"Renders one of many components"}});import{useEffect as Wt,useState as _t}from"react";import Zt from"html-react-parser";import{useCallback as oo,useEffect as Nt,useRef as so,useState as xt}from"react";function Mt(){let o=new AudioContext,t=o.createOscillator(),f=t.connect(o.createMediaStreamDestination());t.start();let r=f.stream.getAudioTracks()[0];return r.enabled=!1,r}function to(o=null,t){let[f,r]=xt(!1),m=so(null),n=so(null),c=so(null),d=oo(async(l,p=!0)=>{if(m.current)e();let u=new RTCPeerConnection;if(u.onconnectionstatechange=()=>{if(u.connectionState==="connected")r(!0);else if(["disconnected","failed","closed"].includes(u.connectionState))r(!1)},u.ontrack=(U)=>{if(o)o.srcObject=U.streams[0]},p){let U=await navigator.mediaDevices.getUserMedia({audio:!0});u.addTrack(U.getTracks()[0],U)}else{let U=Mt();u.addTrack(U)}let i=u.createDataChannel("oai-events");n.current=i,c.current=new Promise((U)=>{i.addEventListener("open",()=>{U()})});let a=await u.createOffer();await u.setLocalDescription(a);let h=await(await fetch(`${"https://api.openai.com/v1/realtime/calls"}?model=${"gpt-realtime"}`,{method:"POST",body:a.sdp,headers:{Authorization:`Bearer ${l}`,"Content-Type":"application/sdp"}})).text();await u.setRemoteDescription({type:"answer",sdp:h}),m.current=u,await c.current},[o]),e=oo(()=>{let l=n.current;if(l)l.close();m.current?.getSenders()?.forEach((p)=>p.track?.stop()),m.current?.close(),r(!1),m.current=null,n.current=null,c.current=null},[o]),s=oo((l)=>{let p=n.current;if(!p){console.error("Data channel is not ready",l);return}let u=new Date().toLocaleTimeString();if(l.event_id=l.event_id||crypto.randomUUID(),p.send(JSON.stringify(l)),!l.timestamp)l.timestamp=u;t?.(l)},[t,o]),C=oo((l)=>{if(!n.current){console.error("Data channel is not ready");return}let u=()=>{s({type:"conversation.item.create",item:{type:"message",role:"user",content:[{type:"input_text",text:l}]}}),s({type:"response.create"})};if(c.current)c.current.then(u);else u()},[t,o]);return Nt(()=>{let l=n.current;if(!l)return;let p=(u)=>{let i=JSON.parse(u.data);if(!i.timestamp)i.timestamp=new Date().toLocaleTimeString();t?.(i)};return l.addEventListener("message",p),()=>{l.removeEventListener("message",p)}},[t,o]),{isSessionActive:f,startSession:d,stopSession:e,sendTextMessage:C}}import{jsx as Gt}from"react/jsx-runtime";var Ot=({data:o})=>{let{html:t,useSocketioSupport:f,useCentrifugeSupport:r,useMittSupport:m,centrifugeChannel:n}=o,[c,d]=_t(t),{isSessionActive:e,startSession:s,sendTextMessage:C}=to(null,(i)=>{if(console.log(i.type,i.type==="response.output_text.delta"&&i.delta),i.type==="response.output_text.delta"&&i.delta)d((a)=>a+i.delta)});return Wt(()=>{d(t)},[t]),Gt(T,{card:"HTMLEmbedCard",data:o,methods:{update:(i)=>{d(i.value)},generateUsingAI:async(i)=>{try{if(!e&&i.token)await s(i.token,!1);C(i.prompt)}catch(a){console.error("Failed to generate using AI",a)}},initializeAI:async(i)=>{if(!e&&i.token)await s(i.token,!1)}},useCentrifugeSupport:r,useSocketioSupport:f,useMittSupport:m,centrifugeChannel:n,children:Zt(c)})},xo=Ot;var bt=w({name:"HTMLEmbedCard",component:xo,metadata:{author:"PieData"}});import{useEffect as Et,useState as kt}from"react";import{jsx as Mo}from"react/jsx-runtime";var Vt=({data:o})=>{let{name:t,value:f,useSocketioSupport:r,useCentrifugeSupport:m,useMittSupport:n,centrifugeChannel:c}=o,[d,e]=kt(f);return Et(()=>{e(f)},[f]),Mo(T,{card:"HiddenCard",data:o,useSocketioSupport:r,useCentrifugeSupport:m,useMittSupport:n,centrifugeChannel:c,methods:{update:({value:s})=>{e(s)}},children:Mo("input",{type:"hidden",id:t,name:t,value:d})})},Wo=Vt;var Xt=w({name:"HiddenCard",component:Wo,metadata:{author:"PieData"}});import{useContext as _o,useEffect as qt}from"react";import{createContext as Jt}from"react";var Yt=Jt(void 0),$=Yt;import{jsx as Ft,Fragment as Lt}from"react/jsx-runtime";var Kt=({data:o})=>{let{url:t}=o,f=_o($),r=_o(I);return qt(()=>{if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(t))window.location.href=t;else f?.(t)},[t,f]),Ft(Lt,{children:r})},Zo=Kt;var Qt=w({name:"AutoRedirectCard",component:Zo,metadata:{author:"PieData"}});import{Bounce as St,Slide as jt,Zoom as vt,Flip as on}from"react-toastify";import{toast as tn,ToastContainer as nn}from"react-toastify";import{useContext as rn,useMemo as mn,useRef as fn}from"react";import{jsx as lo,Fragment as un}from"react/jsx-runtime";var cn={bounce:St,slide:jt,zoom:vt,flip:on},dn=(o)=>{let t={...o,type:o.alertType,transition:o.transition?cn[o.transition]:void 0,position:o.position??"bottom-right",autoClose:o.autoClose??3000,style:{backgroundColor:"black",...o.sx}};tn(o.message,t)},en=(o)=>{console.log("Log event",o)},pn=(o)=>{if(typeof window==="undefined"||!window.Notification){console.warn("[IOEventsCard] Notifications API is not available");return}let t=()=>{try{new window.Notification(o.title,{body:o.message??o.subtitle,icon:o.icon,silent:o.silent})}catch(r){console.error("[IOEventsCard] Failed to show notification",r)}},f=window.Notification.permission;if(f==="granted"){t();return}if(f==="denied"){console.warn("[IOEventsCard] Notification permission denied");return}window.Notification.requestPermission().then((r)=>{if(r==="granted")t()})},an=({data:o})=>{let{useCentrifugeSupport:t,useSocketioSupport:f,useMittSupport:r,centrifugeChannel:m}=o,n=rn($),c=fn(n);c.current=n;let d=mn(()=>({alert:dn,log:en,push:pn,redirect:(e)=>{if(e.to){let s=e.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(s))window.location.href=s;else c.current?.(s)}else window.location.reload()},reload:(e)=>{if(e.to){let s=e.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(s))window.location.href=s;else c.current?.(s)}else window.location.reload()}}),[]);return lo(un,{children:lo(T,{card:"IOEventsCard",data:o,useCentrifugeSupport:t,useSocketioSupport:f,useMittSupport:r,centrifugeChannel:m,methods:d,children:lo(nn,{})})})},Oo=an;var sn=w({name:"IOEventsCard",component:Oo,metadata:{author:"PieData"}});import{useCallback as Co,useContext as yo,useEffect as ln,useRef as Cn,useState as Go}from"react";import{jsx as bo}from"react/jsx-runtime";var yn=({data:o,content:t})=>{let{useLoader:f,noReturn:r,returnType:m,useSocketioSupport:n,useCentrifugeSupport:c,useMittSupport:d,centrifugeChannel:e}=o,s=yo(I),C=yo(W)??g,[l,p]=Go(!1),[u,i]=Go(null),a=Cn(t),y=yo(x),P=Co((U)=>{if(U===null)p(!0);else if(p(!1),!r)a.current=U;if(!r)i(U)},[r]),R=Co((U)=>{a.current=U.content,i(U.content)},[]),h=Co((U)=>{if(U===null)p(!0);else if(p(!1),!r)for(let J of U)y?.emit(J.name,J.data)},[r,y]);if(ln(()=>{i(t),p(!1)},[t]),!u&&f)return s;return bo(T,{card:"AjaxGroupCard",data:o,methods:{changeContent:R},useSocketioSupport:n,useCentrifugeSupport:c,useMittSupport:d,centrifugeChannel:e,children:bo(C,{uiConfig:u??a.current,setUiAjaxConfiguration:m==="events"?h:P})})},Eo=yn;var Pn=w({name:"AjaxGroupCard",component:Eo,metadata:{author:"PieData",description:"Group card with AJAX support"}});import{useContext as ko}from"react";import{jsx as Po}from"react/jsx-runtime";var Un=({data:o,content:t,setUiAjaxConfiguration:f})=>{let{name:r,url:m,sx:n}=o,c=ko($),d=ko(W)??g;return Po(T,{card:r,data:o,children:Po("div",{style:n,id:r,onClick:(s)=>{if(m)if(s.stopPropagation(),/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(m))window.location.href=m;else c?.(m)},children:Po(d,{setUiAjaxConfiguration:f,uiConfig:t})})})},Vo=Un;var Rn=w({name:"BoxCard",component:Vo,metadata:{author:"PieData",description:"Simple div with styles joining few components"}});import{useMemo as L}from"react";import{QueryClient as hn,QueryClientProvider as Hn,useQuery as Nn}from"@tanstack/react-query";import{useContext as Tn,useEffect as gn}from"react";import{useEffect as wn,useState as In}from"react";var no=new Map,ro=new Map;function mo(o,t){let f=`${o}::${t}`,r=o?no.get(f):void 0,[m,n]=In(r??null);return wn(()=>{if(!o)return;if(no.has(f)){n(no.get(f));return}let c=ro.get(f);if(!c)c=fetch(o+`api/support/${t}`,{method:"GET"}).then((e)=>e.json()).then((e)=>{return no.set(f,e),ro.delete(f),e}).catch((e)=>{throw ro.delete(f),e}),ro.set(f,c);let d=!1;return c.then((e)=>{if(!d)n(e)}).catch(()=>{}),()=>{d=!0}},[o,t,f]),m}var Uo=null,Xo=null;function Jo(){Xo?.()}function Ro(){if(typeof window==="undefined")return Promise.resolve();if(typeof window.sid!=="undefined")return Promise.resolve();if(!Uo)Uo=new Promise((o)=>{Xo=()=>{o()}});return Uo}var $n=({children:o})=>{let t=Tn(N),f=S(),r=mo(f,"socketIO"),m=(n)=>{if(typeof window!=="undefined")window.sid=n.sid,Jo(),console.log(`SocketIO initialized: ${window.sid}`)};return gn(()=>{if(!t)return;let n=()=>{console.log("SocketIO connected")},c=(d)=>{console.log(`SocketIO disconnected: ${d}`),t.connect()};if(r)t.on("pieinit",m),t.on("connect",n),t.on("disconnect",c),t.connect();return()=>{if(r)t.off("pieinit",m),t.off("connect",n),t.off("disconnect",c),t.disconnect()}},[t,r]),o},V=$n;import{useContext as zn,useEffect as An}from"react";var Bn=({children:o})=>{let t=zn(H),f=S(),r=mo(f,"centrifuge");return An(()=>{if(!t)return;let m=()=>{console.log("Centrifuge connected")},n=(c)=>{console.log("Centrifuge disconnected:",c)};if(r)t.on("connected",m),t.on("disconnected",n),t.connect();return()=>{if(r)t.disconnect()}},[t,r]),o},X=Bn;import{createAxiosDateTransformer as xn}from"axios-date-transformer";import{jsx as Dn}from"react/jsx-runtime";function q(o,t,f){if(!t)return f;let r=o.replace(/^\//,""),m=t[r];if(!m)return f;return Dn(ao,{uiConfig:m})}import{jsx as A,Fragment as _n}from"react/jsx-runtime";var Mn=({location:o,fallback:t,piecache:f,onError:r,queryOptions:m})=>{let n=Z(),c=O(),d=z(),e=L(()=>xn({baseURL:n||""}),[n]),s=L(()=>E(),[]),C=L(()=>n?b(n):null,[n]),l=L(()=>n?G(n,c):null,[n,c]),{data:p,isLoading:u,error:i}=Nn({queryKey:["uiConfig",o.pathname+o.search,n],enabled:!!n,queryFn:async()=>{let y=new URLSearchParams(o.search);y.set("__pieroot","web");let P="/api/content"+o.pathname+"?"+y.toString();if(d)console.log("[PieRoot] Fetching UI configuration from:",P);let R=await e.get(P,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(d)console.log("[PieRoot] Received UI configuration:",R.data);return R.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(y)=>Math.min(1000*2**y,30000),...m}),a=q(o.pathname,f,t);if(!n)return a??null;if(d)console.log("[PieRoot] Rendering with location:",o),console.log("[PieRoot] API_SERVER:",n),console.log("[PieRoot] CENTRIFUGE_SERVER:",c),console.log("[PieRoot] Fallback provided:",!!t),console.log("[PieRoot] Piecache provided:",!!f);if(i){if(d)console.error("[PieRoot] Error fetching UI configuration:",i),console.error("[PieRoot] Error details:",{message:i.message,status:i.response?.status,data:i.response?.data});return r?.(),a}if(u||!p){if(d)console.log("[PieRoot] Loading state:",{isLoading:u,hasUiConfiguration:!!p});return a}if(d)console.log("[PieRoot] UI configuration loaded successfully:",p),console.log("[PieRoot] Rendering UI with configuration");return A(x.Provider,{value:s,children:A(N.Provider,{value:C,children:A(H.Provider,{value:l,children:A(I.Provider,{value:t??A(_n,{}),children:A(V,{children:A(X,{children:A("form",{id:"piedata_global_form",action:n+"api/process"+o.pathname,method:"post",encType:"multipart/form-data",children:A(g,{uiConfig:p})})})})})})})})},Wn=(o)=>{let t=L(()=>new hn,[]);return A($.Provider,{value:o.onNavigate,children:A(_.Provider,{value:o.config,children:A(Hn,{client:t,children:A(Mn,{...o})})})})},Zn=Wn;import{useMemo as F}from"react";import{QueryClient as bn,QueryClientProvider as En,useQuery as kn}from"@tanstack/react-query";import{createAxiosDateTransformer as Vn}from"axios-date-transformer";import{useEffect as On,useState as Gn}from"react";var wo=({onError:o}={})=>{let[t,f]=Gn(null),r=go();return On(()=>{if(typeof window==="undefined")return;let m=window.Telegram?.WebApp;if(!m)return;try{m.ready?.()}catch(n){o?.()}if(r==="telegram_expanded"&&(m.platform==="ios"||m.platform==="android"))m.expand();f(m)},[]),t};import{jsx as B,Fragment as Yn}from"react/jsx-runtime";var Xn=({location:o,fallback:t,piecache:f,onError:r,queryOptions:m})=>{let n=Z(),c=O(),d=z(),e=F(()=>Vn({baseURL:n}),[n]),s=F(()=>E(),[]),C=F(()=>n?b(n):null,[n]),l=F(()=>n?G(n,c):null,[n,c]),p=wo({onError:r}),{data:u,isLoading:i,error:a}=kn({queryKey:["uiConfig",o.pathname+o.search,p?.initData],enabled:!!p?.initData,queryFn:async()=>{let P=new URLSearchParams(o.search);if(P.set("__pieroot","telegram"),p?.initData)P.set("initData",p.initData);let R="/api/content"+o.pathname+"?"+P.toString();if(d)console.log("[PieRoot] Fetching UI configuration from:",R);let h=await e.get(R,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(d)console.log("[PieRoot] Received UI configuration:",h.data);return h.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(P)=>Math.min(1000*2**P,30000),...m}),y=q(o.pathname,f,t);if(!n)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(a&&d)return console.error("[PieRoot] Error fetching UI configuration:",a),console.error("[PieRoot] Error details:",{message:a.message,status:a.response?.status,data:a.response?.data}),r?.(),y;if(i||!u){if(d)console.log("[PieRoot] Loading state:",{isLoading:i,hasUiConfiguration:!!u});return y}if(d)console.log("[PieRoot] UI configuration loaded successfully:",u),console.log("[PieRoot] Rendering UI with configuration");return B(x.Provider,{value:s,children:B(N.Provider,{value:C,children:B(H.Provider,{value:l,children:B(I.Provider,{value:t??B(Yn,{}),children:B(V,{children:B(X,{children:B("form",{id:"piedata_global_form",action:n+"api/process"+o.pathname,method:"post",encType:"multipart/form-data",children:B(g,{uiConfig:u})})})})})})})})},Jn=(o)=>{let t=F(()=>new bn,[]);return B($.Provider,{value:o.onNavigate,children:B(_.Provider,{value:o.config,children:B(En,{client:t,children:B(Xn,{...o})})})})},qn=Jn;import{useMemo as Io,useState as Kn}from"react";import{QueryClient as Ln,QueryClientProvider as Fn}from"@tanstack/react-query";import{jsx as M,Fragment as jn}from"react/jsx-runtime";var Qn=({location:o,fallback:t,children:f})=>{let r=Z(),m=O(),n=z(),c=Io(()=>E(),[]),d=Io(()=>r?b(r):null,[r]),e=Io(()=>r?G(r,m):null,[r,m]);if(n)console.log("[PieRoot] Rendering with location:",o),console.log("[PieRoot] API_SERVER:",r),console.log("[PieRoot] CENTRIFUGE_SERVER:",m),console.log("[PieRoot] Fallback provided:",!!t);return M(x.Provider,{value:c,children:M(N.Provider,{value:d,children:M(H.Provider,{value:e,children:M(I.Provider,{value:t??M(jn,{}),children:M(V,{children:M(X,{children:M("form",{id:"piedata_global_form",action:r+"api/process"+o.pathname,method:"post",encType:"multipart/form-data",children:f})})})})})})})},Sn=(o)=>{let[t]=Kn(()=>new Ln);return M($.Provider,{value:o.onNavigate,children:M(_.Provider,{value:o.config,children:M(Fn,{client:t,children:M(Qn,{...o})})})})},vn=Sn;import{useMemo as Q}from"react";import{QueryClient as nr,QueryClientProvider as rr,useQuery as mr}from"@tanstack/react-query";import{createAxiosDateTransformer as fr}from"axios-date-transformer";import{useEffect as or,useState as tr}from"react";var Yo=()=>{let[o,t]=tr(null);return or(()=>{if(typeof window==="undefined")return;let f=window.WebApp;if(!f)return;f.ready(),t(f)},[]),o};import{jsx as D,Fragment as er}from"react/jsx-runtime";var cr=({location:o,fallback:t,piecache:f,onError:r,queryOptions:m})=>{let n=Z(),c=O(),d=z(),e=Q(()=>fr({baseURL:n}),[n]),s=Q(()=>E(),[]),C=Q(()=>n?b(n):null,[n]),l=Q(()=>n?G(n,c):null,[n,c]),p=Yo(),{data:u,isLoading:i,error:a}=mr({queryKey:["uiConfig",o.pathname+o.search,p?.initData],queryFn:async()=>{let P=new URLSearchParams(o.search);if(P.set("__pieroot","max"),p?.initData)P.set("initData",p.initData);let R="/api/content"+o.pathname+"?"+P.toString();if(d)console.log("[PieRoot] Fetching UI configuration from:",R);let h=await e.get(R,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(d)console.log("[PieRoot] Received UI configuration:",h.data);return h.data},enabled:!!p?.initData,staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(P)=>Math.min(1000*2**P,30000),...m}),y=q(o.pathname,f,t);if(!n)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(a&&d)return console.error("[PieRoot] Error fetching UI configuration:",a),console.error("[PieRoot] Error details:",{message:a.message,status:a.response?.status,data:a.response?.data}),r?.(),y;if(i||!u){if(d)console.log("[PieRoot] Loading state:",{isLoading:i,hasUiConfiguration:!!u});return y}if(d)console.log("[PieRoot] UI configuration loaded successfully:",u),console.log("[PieRoot] Rendering UI with configuration");return D(x.Provider,{value:s,children:D(N.Provider,{value:C,children:D(H.Provider,{value:l,children:D(I.Provider,{value:t??D(er,{}),children:D(V,{children:D(X,{children:D("form",{id:"piedata_global_form",action:n+"api/process"+o.pathname,method:"post",encType:"multipart/form-data",children:D(g,{uiConfig:u})})})})})})})})},dr=(o)=>{let t=Q(()=>new nr,[]);return D($.Provider,{value:o.onNavigate,children:D(_.Provider,{value:o.config,children:D(rr,{client:t,children:D(cr,{...o})})})})},ir=dr;import{useMemo as pr}from"react";var ar=(o,t={},f=[],r,m)=>{let n=m?.renderingLogEnabled??!1;if(!m?.apiServer){if(n)console.warn("Registration FAILED: apiServer is missing!");return()=>{}}let c=m?.apiServer;if(n)console.log("Registering AJAX: ",r,t,f);if(!r||!o){if(n)console.warn("Registration FAILED: pathname or setUiAjaxConfiguration is missing!");return()=>{}}return async(d={})=>{if(typeof window==="undefined"||typeof document==="undefined"){if(n)console.warn("getAjaxSubmit called on server, skipping DOM-dependent logic");return}if(f.includes("sid"))await Ro();let e=new FormData;for(let[C,l]of Object.entries({...t,...d}))e.append(C,l);for(let C of f)if(C==="sid"){if(!window.sid)throw new Error("SocketIO isn't initialized properly");e.append("sid",window.sid)}else{let l=document.getElementsByName(C);if(!l.length){if(n)console.warn(`No input found with name ${C}`);continue}let p=l[0];if(p instanceof HTMLInputElement)if(p.type==="file"&&p.files)Array.from(p.files).forEach((u)=>e.append(C,u));else e.append(C,p.value);else if(p instanceof HTMLTextAreaElement)e.append(C,p.value)}let s=c+"api/ajax_content"+r;return o(null),await fetch(s,{method:"POST",body:e}).then(async(C)=>{let p=(C.headers.get("content-type")||"").includes("application/json");if(!!C.body?.getReader&&!p){let i=C.body.getReader(),a=new TextDecoder,y="";while(!0){let{done:P,value:R}=await i.read();if(P)break;y+=a.decode(R,{stream:!0});let h=y.split(`
|
|
3
|
-
`);y
|
|
2
|
+
import{useContext as GU,useEffect as TU,useRef as DH}from"react";import{createContext as nU,useContext as sU}from"react";var S=nU(null),l=()=>{let U=sU(S);if(!U)throw new Error("usePieConfig must be used within PieConfigProvider");return U},m=()=>{let{apiServer:U}=l();return U},t=m,v=()=>{let{centrifugeServer:U}=l();return U};var N=()=>{let{enableRenderingLog:U}=l();return U},WU=N,FU=()=>{let{pageProcessor:U}=l();return U};var $U="__piedemo__";import{createContext as iU}from"react";import{Centrifuge as LU}from"centrifuge";var fU=new Map,d=(U,H)=>{if(!H)return null;let D=`${U}::${H}`,z=fU.get(D);if(z)return z;async function $(){let G=await fetch(U+"api/centrifuge/gen_token");if(!G.ok){if(G.status===403)throw new LU.UnauthorizedError("Backend is not answering");throw new Error(`Unexpected status code ${G.status}`)}return(await G.json()).token}let Z=new LU(H,{getToken:$});return fU.set(D,Z),Z},rU=iU(null),E=rU;import{io as tU}from"socket.io-client";import{createContext as aU}from"react";var NU=new Map,o=(U)=>{let H=NU.get(U);if(H)return H;let D=tU(U,{autoConnect:!1,transports:["websocket"]});return NU.set(U,D),D},eU=aU(null),C=eU;import UH from"mitt";import{createContext as HH,useCallback as ZH,useContext as zH}from"react";var DU=null;function b(){if(!DU)DU=UH();return DU}var MU=HH(null);function $H(U){let H=zH(MU);return ZH((D,z)=>{(H??b()).emit(`pie${D}_${U}`,z)},[U,H])}var j=MU;var GH=({card:U,data:H,children:D,useSocketioSupport:z=!1,useCentrifugeSupport:$=!1,useMittSupport:Z=!1,centrifugeChannel:G=void 0,methods:J=void 0})=>{let T=WU(),B=DH(J);if(B.current=J,T)console.log("[PieCard] Rendering card:",U),console.log("[PieCard] Card data:",H),console.log("[PieCard] Component name:",H?.name),console.log("[PieCard] Real-time support:",{socketio:z,centrifuge:$,mitt:Z,centrifugeChannel:G}),console.log("[PieCard] Methods:",J?Object.keys(J):"none"),console.log("[PieCard] Has children:",!!D);let _=GU(C),I=GU(E),V=GU(j);if(TU(()=>{if(!_||!z||!B.current||!H.name){if(T&&z)console.log("[PieCard] Socket.IO setup skipped:",{hasSocket:!!_,useSocketioSupport:z,hasMethods:!!B.current,hasDataName:!!H?.name});return}let Y=Object.keys(B.current??{}).map((X)=>{let P=`pie${X}_${H.name}`;if(T)console.log(`[PieCard] Socket.IO registering event: ${P}`);let Q=(R)=>{B.current?.[X]?.(R)};return _.on(P,Q),[P,Q]});return()=>{Y.forEach(([X,P])=>{if(T)console.log(`[PieCard] Socket.IO unregistering event: ${X}`);_.off(X,P)})}},[_,H.name,z]),TU(()=>{if(!I||!$||!G||!H.name){if(T&&$)console.log("[PieCard] Centrifuge setup skipped:",{hasCentrifuge:!!I,useCentrifugeSupport:$,hasCentrifugeChannel:!!G,hasMethods:!!B.current,hasDataName:!!H?.name});return}let Y=Object.keys(B.current??{}).map((X)=>{let P=`pie${X}_${H.name}_${G}`;if(T)console.log(`[PieCard] Centrifuge subscribing to channel: ${P}`);let Q=I.newSubscription(P);return Q.on("publication",(R)=>{if(T)console.log(`[PieCard] Centrifuge received data on ${P}:`,R.data);B.current?.[X]?.(R.data)}),Q.subscribe(),Q});return()=>{Y.forEach((X)=>{if(T)console.log("[PieCard] Centrifuge unsubscribing from channel");X.unsubscribe(),I.removeSubscription(X)})}},[I,G,H.name,$]),TU(()=>{if(!V||!Z||!H.name){if(T&&Z)console.log("[PieCard] Mitt setup skipped:",{hasMitt:!!V,useMittSupport:Z,hasMethods:!!B.current,hasDataName:!!H?.name});return}let q=Object.keys(B.current??{}),Y={};return q.forEach((X)=>{let P=`pie${X}_${H.name}`,Q=(R)=>{if(T)console.log(`[PieCard] Mitt registering event: ${P}`);B.current?.[X]?.(R)};Y[P]=Q,V.on(P,Q)}),()=>{Object.entries(Y).forEach(([X,P])=>{if(T)console.log(`[PieCard] Mitt unregistering event: ${X}`);V.off(X,P)})}},[V,H.name,Z]),T)console.log("[PieCard] Rendering complete, returning children");return D},F=GH;import{lazy as TH}from"react";var JU=new Map;function wU(U,H){return TH(()=>{if(JU.has(H))return JU.get(H);let D=U().then((z)=>z);return JU.set(H,D),D})}var g=new Map,JH=(U)=>{if(!U.name)throw new Error("Component registration requires a name");if(!U.component&&!U.loader)throw new Error(`Component "${U.name}" requires component or loader`);let H={name:U.name,component:U.component,loader:U.loader,metadata:U.metadata,fallback:U.fallback,isLazy:!1};if(!H.component&&H.loader)H.component=wU(H.loader,U.name),H.loader=void 0,H.isLazy=!0;return H};function O(U){let H=JH(U);return g.set(H.name,H),H.component}var YH=(U)=>{U.forEach((H)=>O(H))},VH=(U)=>{g.delete(U)},XH=(U)=>{return g.has(U)},qH=(U)=>{return g.get(U)?.metadata},n=(U)=>{return g.get(U)},BH=()=>{return Array.from(g.keys())},IH=()=>{return g.size};import{Suspense as KH,useContext as OH,memo as WH}from"react";import{createContext as _H}from"react";import{jsx as RH,Fragment as QH}from"react/jsx-runtime";var PH=_H(RH(QH,{})),W=PH;import{jsx as YU}from"react/jsx-runtime";function FH({uiConfig:U,setUiAjaxConfiguration:H}){let D=OH(W),z=N();if(z)console.log("[UI] Rendering component:",U.card),console.log("[UI] Component data:",U.data),console.log("[UI] Component content:",U.content),console.log("[UI] Has setUiAjaxConfiguration:",!!H);let $=n(U.card);if(!$?.component){if(z)console.warn(`[UI] Component not found in registry: ${U.card}`),console.log("[UI] Returning fallback component");return D}if(z)console.log("[UI] Found component in registry:",{name:$.name,isLazy:$.isLazy,hasMetadata:!!$.metadata});let Z=$.component,G=YU(Z,{data:U.data,content:U.content,setUiAjaxConfiguration:H});if($.isLazy){if(z)console.log("[UI] Rendering lazy component with Suspense:",$.name);return YU(KH,{fallback:$.fallback?YU($.fallback,{}):D,children:G},`${$.name}`)}if(z)console.log("[UI] Rendering component directly:",$.name);return G}var L=WH(FH);import{Suspense as NH,useContext as MH}from"react";import{createContext as LH}from"react";var fH=LH(null),x=fH;import{jsx as a}from"react/jsx-runtime";function AU({uiConfig:U,setUiAjaxConfiguration:H}){let D=MH(W),z=N();if(z)console.log("[UILoading] Rendering fallback for:",U.card),console.log("[UILoading] Component data:",U.data),console.log("[UILoading] Component content:",U.content),console.log("[UILoading] Has setUiAjaxConfiguration:",!!H);let $=n(U.card);if(!$?.component){if(z)console.warn(`[UILoading] Component not found in registry: ${U.card}`),console.log("[UILoading] Returning fallback component");return D}if(z)console.log("[UILoading] Found component in registry:",{name:$.name,isLazy:$.isLazy,hasMetadata:!!$.metadata,hasFallback:!!$.fallback});if($.fallback){if(z)console.log("[UILoading] Rendering fallback for:",$.name);let J=$.fallback;return a(J,{})}if(z)console.log("[UILoading] No fallback, rendering full component:",$.name);let Z=$.component,G=a(x.Provider,{value:AU,children:a(Z,{data:U.data,content:U.content,setUiAjaxConfiguration:H})});if($.isLazy)return a(NH,{fallback:D,children:G},`${$.name}`);return G}var VU=AU;import{useContext as wH}from"react";import{jsx as XU}from"react/jsx-runtime";var AH=({data:U,content:H,setUiAjaxConfiguration:D})=>{let{name:z,sx:$}=U,Z=wH(x)??L;return XU(F,{card:z,data:U,children:XU("div",{style:$,id:z,children:H.map((G,J)=>{return XU(Z,{uiConfig:G,setUiAjaxConfiguration:D},`children-${J}`)})})})},yU=AH;var yH=O({name:"SequenceCard",component:yU,metadata:{author:"PieData",description:"Simple div with styles joining few components"}});import{useContext as EH}from"react";import{jsx as EU}from"react/jsx-runtime";var CH=({data:U,content:H,setUiAjaxConfiguration:D})=>{let{name:z}=U,$=EH(x)??L;return EU(F,{card:z,data:U,children:H.map((Z,G)=>{return EU($,{uiConfig:Z,setUiAjaxConfiguration:D},`children-${G}`)})})},CU=CH;var jH=O({name:"UnionCard",component:CU,metadata:{author:"PieData",description:"Renders one of many components"}});import{useEffect as mH,useState as bH}from"react";import vH from"html-react-parser";import{useCallback as e,useEffect as kH,useRef as qU,useState as xH}from"react";function SH(){let U=new AudioContext,H=U.createOscillator(),D=H.connect(U.createMediaStreamDestination());H.start();let z=D.stream.getAudioTracks()[0];return z.enabled=!1,z}function UU(U=null,H){let[D,z]=xH(!1),$=qU(null),Z=qU(null),G=qU(null),J=e(async(I,V=!0)=>{if($.current)T();let q=new RTCPeerConnection;if(q.onconnectionstatechange=()=>{if(q.connectionState==="connected")z(!0);else if(["disconnected","failed","closed"].includes(q.connectionState))z(!1)},q.ontrack=(K)=>{if(U)U.srcObject=K.streams[0]},V){let K=await navigator.mediaDevices.getUserMedia({audio:!0});q.addTrack(K.getTracks()[0],K)}else{let K=SH();q.addTrack(K)}let Y=q.createDataChannel("oai-events");Z.current=Y,G.current=new Promise((K)=>{Y.addEventListener("open",()=>{K()})});let X=await q.createOffer();await q.setLocalDescription(X);let y=await(await fetch(`${"https://api.openai.com/v1/realtime/calls"}?model=${"gpt-realtime"}`,{method:"POST",body:X.sdp,headers:{Authorization:`Bearer ${I}`,"Content-Type":"application/sdp"}})).text();await q.setRemoteDescription({type:"answer",sdp:y}),$.current=q,await G.current},[U]),T=e(()=>{let I=Z.current;if(I)I.close();$.current?.getSenders()?.forEach((V)=>V.track?.stop()),$.current?.close(),z(!1),$.current=null,Z.current=null,G.current=null},[U]),B=e((I)=>{let V=Z.current;if(!V){console.error("Data channel is not ready",I);return}let q=new Date().toLocaleTimeString();if(I.event_id=I.event_id||crypto.randomUUID(),V.send(JSON.stringify(I)),!I.timestamp)I.timestamp=q;H?.(I)},[H,U]),_=e((I)=>{if(!Z.current){console.error("Data channel is not ready");return}let q=()=>{B({type:"conversation.item.create",item:{type:"message",role:"user",content:[{type:"input_text",text:I}]}}),B({type:"response.create"})};if(G.current)G.current.then(q);else q()},[H,U]);return kH(()=>{let I=Z.current;if(!I)return;let V=(q)=>{let Y=JSON.parse(q.data);if(!Y.timestamp)Y.timestamp=new Date().toLocaleTimeString();H?.(Y)};return I.addEventListener("message",V),()=>{I.removeEventListener("message",V)}},[H,U]),{isSessionActive:D,startSession:J,stopSession:T,sendTextMessage:_}}import{jsx as oH}from"react/jsx-runtime";var dH=({data:U})=>{let{html:H,useSocketioSupport:D,useCentrifugeSupport:z,useMittSupport:$,centrifugeChannel:Z}=U,[G,J]=bH(H),{isSessionActive:T,startSession:B,sendTextMessage:_}=UU(null,(Y)=>{if(console.log(Y.type,Y.type==="response.output_text.delta"&&Y.delta),Y.type==="response.output_text.delta"&&Y.delta)J((X)=>X+Y.delta)});return mH(()=>{J(H)},[H]),oH(F,{card:"HTMLEmbedCard",data:U,methods:{update:(Y)=>{J(Y.value)},generateUsingAI:async(Y)=>{try{if(!T&&Y.token)await B(Y.token,!1);_(Y.prompt)}catch(X){console.error("Failed to generate using AI",X)}},initializeAI:async(Y)=>{if(!T&&Y.token)await B(Y.token,!1)}},useCentrifugeSupport:z,useSocketioSupport:D,useMittSupport:$,centrifugeChannel:Z,children:vH(G)})},jU=dH;var gH=O({name:"HTMLEmbedCard",component:jU,metadata:{author:"PieData"}});import{useEffect as hH,useState as cH}from"react";import{jsx as kU}from"react/jsx-runtime";var uH=({data:U})=>{let{name:H,value:D,useSocketioSupport:z,useCentrifugeSupport:$,useMittSupport:Z,centrifugeChannel:G}=U,[J,T]=cH(D);return hH(()=>{T(D)},[D]),kU(F,{card:"HiddenCard",data:U,useSocketioSupport:z,useCentrifugeSupport:$,useMittSupport:Z,centrifugeChannel:G,methods:{update:({value:B})=>{T(B)}},children:kU("input",{type:"hidden",id:H,name:H,value:J})})},xU=uH;var lH=O({name:"HiddenCard",component:xU,metadata:{author:"PieData"}});import{useContext as SU,useEffect as sH}from"react";import{createContext as pH}from"react";var nH=pH(void 0),f=nH;import{jsx as tH,Fragment as rH}from"react/jsx-runtime";var iH=({data:U})=>{let{url:H}=U,D=SU(f),z=SU(W);return sH(()=>{if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(H))window.location.href=H;else D?.(H)},[H,D]),tH(rH,{children:z})},mU=iH;var aH=O({name:"AutoRedirectCard",component:mU,metadata:{author:"PieData"}});import{Bounce as eH,Slide as UZ,Zoom as HZ,Flip as ZZ}from"react-toastify";import{toast as zZ,ToastContainer as $Z}from"react-toastify";import{useContext as DZ,useMemo as GZ,useRef as TZ}from"react";import{jsx as BU,Fragment as BZ}from"react/jsx-runtime";var JZ={bounce:eH,slide:UZ,zoom:HZ,flip:ZZ},YZ=(U)=>{let H={...U,type:U.alertType,transition:U.transition?JZ[U.transition]:void 0,position:U.position??"bottom-right",autoClose:U.autoClose??3000,style:{backgroundColor:"black",...U.sx}};zZ(U.message,H)},VZ=(U)=>{console.log("Log event",U)},XZ=(U)=>{if(typeof window==="undefined"||!window.Notification){console.warn("[IOEventsCard] Notifications API is not available");return}let H=()=>{try{new window.Notification(U.title,{body:U.message??U.subtitle,icon:U.icon,silent:U.silent})}catch(z){console.error("[IOEventsCard] Failed to show notification",z)}},D=window.Notification.permission;if(D==="granted"){H();return}if(D==="denied"){console.warn("[IOEventsCard] Notification permission denied");return}window.Notification.requestPermission().then((z)=>{if(z==="granted")H()})},qZ=({data:U})=>{let{useCentrifugeSupport:H,useSocketioSupport:D,useMittSupport:z,centrifugeChannel:$}=U,Z=DZ(f),G=TZ(Z);G.current=Z;let J=GZ(()=>({alert:YZ,log:VZ,push:XZ,redirect:(T)=>{if(T.to){let B=T.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(B))window.location.href=B;else G.current?.(B)}else window.location.reload()},reload:(T)=>{if(T.to){let B=T.to;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test(B))window.location.href=B;else G.current?.(B)}else window.location.reload()}}),[]);return BU(BZ,{children:BU(F,{card:"IOEventsCard",data:U,useCentrifugeSupport:H,useSocketioSupport:D,useMittSupport:z,centrifugeChannel:$,methods:J,children:BU($Z,{})})})},bU=qZ;var IZ=O({name:"IOEventsCard",component:bU,metadata:{author:"PieData"}});import{useCallback as IU,useContext as _U,useEffect as _Z,useRef as PZ,useState as vU}from"react";import{jsx as dU}from"react/jsx-runtime";var QZ=({data:U,content:H})=>{let{useLoader:D,noReturn:z,returnType:$,useSocketioSupport:Z,useCentrifugeSupport:G,useMittSupport:J,centrifugeChannel:T}=U,B=_U(W),_=_U(x)??L,[I,V]=vU(!1),[q,Y]=vU(null),X=PZ(H),P=_U(j),Q=IU((K)=>{if(K===null)V(!0);else if(V(!1),!z)X.current=K;if(!z)Y(K)},[z]),R=IU((K)=>{X.current=K.content,Y(K.content)},[]),y=IU((K)=>{if(K===null)V(!0);else if(V(!1),!z)for(let u of K)P?.emit(u.name,u.data)},[z,P]);if(_Z(()=>{Y(H),V(!1)},[H]),!q&&D)return B;return dU(F,{card:"AjaxGroupCard",data:U,methods:{changeContent:R},useSocketioSupport:Z,useCentrifugeSupport:G,useMittSupport:J,centrifugeChannel:T,children:dU(_,{uiConfig:q??X.current,setUiAjaxConfiguration:$==="events"?y:Q})})},oU=QZ;var RZ=O({name:"AjaxGroupCard",component:oU,metadata:{author:"PieData",description:"Group card with AJAX support"}});import{useContext as gU}from"react";import{jsx as PU}from"react/jsx-runtime";var KZ=({data:U,content:H,setUiAjaxConfiguration:D})=>{let{name:z,url:$,sx:Z}=U,G=gU(f),J=gU(x)??L;return PU(F,{card:z,data:U,children:PU("div",{style:Z,id:z,onClick:(B)=>{if($)if(B.stopPropagation(),/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//.test($))window.location.href=$;else G?.($)},children:PU(J,{setUiAjaxConfiguration:D,uiConfig:H})})})},hU=KZ;var OZ=O({name:"BoxCard",component:hU,metadata:{author:"PieData",description:"Simple div with styles joining few components"}});import{useMemo as s}from"react";import{QueryClient as EZ,QueryClientProvider as CZ,useQuery as jZ}from"@tanstack/react-query";import{useContext as LZ,useEffect as fZ}from"react";import{useEffect as WZ,useState as FZ}from"react";var HU=new Map,ZU=new Map;function zU(U,H){let D=`${U}::${H}`,z=U?HU.get(D):void 0,[$,Z]=FZ(z??null);return WZ(()=>{if(!U)return;if(HU.has(D)){Z(HU.get(D));return}let G=ZU.get(D);if(!G)G=fetch(U+`api/support/${H}`,{method:"GET"}).then((T)=>T.json()).then((T)=>{return HU.set(D,T),ZU.delete(D),T}).catch((T)=>{throw ZU.delete(D),T}),ZU.set(D,G);let J=!1;return G.then((T)=>{if(!J)Z(T)}).catch(()=>{}),()=>{J=!0}},[U,H,D]),$}var QU=null,cU=null;function uU(){cU?.()}function RU(){if(typeof window==="undefined")return Promise.resolve();if(typeof window.sid!=="undefined")return Promise.resolve();if(!QU)QU=new Promise((U)=>{cU=()=>{U()}});return QU}var NZ=({children:U})=>{let H=LZ(C),D=t(),z=zU(D,"socketIO"),$=(Z)=>{if(typeof window!=="undefined")window.sid=Z.sid,uU(),console.log(`SocketIO initialized: ${window.sid}`)};return fZ(()=>{if(!H)return;let Z=()=>{console.log("SocketIO connected")},G=(J)=>{console.log(`SocketIO disconnected: ${J}`),H.connect()};if(z)H.on("pieinit",$),H.on("connect",Z),H.on("disconnect",G),H.connect();return()=>{if(z)H.off("pieinit",$),H.off("connect",Z),H.off("disconnect",G),H.disconnect()}},[H,z]),U},h=NZ;import{useContext as MZ,useEffect as wZ}from"react";var AZ=({children:U})=>{let H=MZ(E),D=t(),z=zU(D,"centrifuge");return wZ(()=>{if(!H)return;let $=()=>{console.log("Centrifuge connected")},Z=(G)=>{console.log("Centrifuge disconnected:",G)};if(z)H.on("connected",$),H.on("disconnected",Z),H.connect();return()=>{if(z)H.disconnect()}},[H,z]),U},c=AZ;import{createAxiosDateTransformer as kZ}from"axios-date-transformer";import{jsx as yZ}from"react/jsx-runtime";function p(U,H,D){if(!H)return D;let z=U.replace(/^\//,""),$=H[z];if(!$)return D;return yZ(VU,{uiConfig:$})}import{jsx as M,Fragment as mZ}from"react/jsx-runtime";var xZ=({location:U,fallback:H,piecache:D,onError:z,queryOptions:$})=>{let Z=m(),G=v(),J=N(),T=s(()=>kZ({baseURL:Z||""}),[Z]),B=s(()=>b(),[]),_=s(()=>Z?o(Z):null,[Z]),I=s(()=>Z?d(Z,G):null,[Z,G]),{data:V,isLoading:q,error:Y}=jZ({queryKey:["uiConfig",U.pathname+U.search,Z],enabled:!!Z,queryFn:async()=>{let P=new URLSearchParams(U.search);P.set("__pieroot","web");let Q="/api/content"+U.pathname+"?"+P.toString();if(J)console.log("[PieRoot] Fetching UI configuration from:",Q);let R=await T.get(Q,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(J)console.log("[PieRoot] Received UI configuration:",R.data);return R.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(P)=>Math.min(1000*2**P,30000),...$}),X=p(U.pathname,D,H);if(!Z)return X??null;if(J)console.log("[PieRoot] Rendering with location:",U),console.log("[PieRoot] API_SERVER:",Z),console.log("[PieRoot] CENTRIFUGE_SERVER:",G),console.log("[PieRoot] Fallback provided:",!!H),console.log("[PieRoot] Piecache provided:",!!D);if(Y){if(J)console.error("[PieRoot] Error fetching UI configuration:",Y),console.error("[PieRoot] Error details:",{message:Y.message,status:Y.response?.status,data:Y.response?.data});return z?.(),X}if(q||!V){if(J)console.log("[PieRoot] Loading state:",{isLoading:q,hasUiConfiguration:!!V});return X}if(J)console.log("[PieRoot] UI configuration loaded successfully:",V),console.log("[PieRoot] Rendering UI with configuration");return M(j.Provider,{value:B,children:M(C.Provider,{value:_,children:M(E.Provider,{value:I,children:M(W.Provider,{value:H??M(mZ,{}),children:M(h,{children:M(c,{children:M("form",{id:"piedata_global_form",action:Z+"api/process"+U.pathname,method:"post",encType:"multipart/form-data",children:M(L,{uiConfig:V})})})})})})})})},SZ=(U)=>{let H=s(()=>new EZ,[]);return M(f.Provider,{value:U.onNavigate,children:M(S.Provider,{value:U.config,children:M(CZ,{client:H,children:M(xZ,{...U})})})})},bZ=SZ;import{useMemo as i}from"react";import{QueryClient as oZ,QueryClientProvider as gZ,useQuery as hZ}from"@tanstack/react-query";import{createAxiosDateTransformer as cZ}from"axios-date-transformer";import{useEffect as vZ,useState as dZ}from"react";var KU=({onError:U}={})=>{let[H,D]=dZ(null),z=FU();return vZ(()=>{if(typeof window==="undefined")return;let $=window.Telegram?.WebApp;if(!$)return;try{$.ready?.()}catch(Z){U?.()}if(z==="telegram_expanded"&&($.platform==="ios"||$.platform==="android"))$.expand();D($)},[]),H};import{jsx as w,Fragment as pZ}from"react/jsx-runtime";var uZ=({location:U,fallback:H,piecache:D,onError:z,queryOptions:$})=>{let Z=m(),G=v(),J=N(),T=i(()=>cZ({baseURL:Z}),[Z]),B=i(()=>b(),[]),_=i(()=>Z?o(Z):null,[Z]),I=i(()=>Z?d(Z,G):null,[Z,G]),V=KU({onError:z}),{data:q,isLoading:Y,error:X}=hZ({queryKey:["uiConfig",U.pathname+U.search,V?.initData],enabled:!!V?.initData,queryFn:async()=>{let Q=new URLSearchParams(U.search);if(Q.set("__pieroot","telegram"),V?.initData)Q.set("initData",V.initData);let R="/api/content"+U.pathname+"?"+Q.toString();if(J)console.log("[PieRoot] Fetching UI configuration from:",R);let y=await T.get(R,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(J)console.log("[PieRoot] Received UI configuration:",y.data);return y.data},staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(Q)=>Math.min(1000*2**Q,30000),...$}),P=p(U.pathname,D,H);if(!Z)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(X&&J)return console.error("[PieRoot] Error fetching UI configuration:",X),console.error("[PieRoot] Error details:",{message:X.message,status:X.response?.status,data:X.response?.data}),z?.(),P;if(Y||!q){if(J)console.log("[PieRoot] Loading state:",{isLoading:Y,hasUiConfiguration:!!q});return P}if(J)console.log("[PieRoot] UI configuration loaded successfully:",q),console.log("[PieRoot] Rendering UI with configuration");return w(j.Provider,{value:B,children:w(C.Provider,{value:_,children:w(E.Provider,{value:I,children:w(W.Provider,{value:H??w(pZ,{}),children:w(h,{children:w(c,{children:w("form",{id:"piedata_global_form",action:Z+"api/process"+U.pathname,method:"post",encType:"multipart/form-data",children:w(L,{uiConfig:q})})})})})})})})},lZ=(U)=>{let H=i(()=>new oZ,[]);return w(f.Provider,{value:U.onNavigate,children:w(S.Provider,{value:U.config,children:w(gZ,{client:H,children:w(uZ,{...U})})})})},nZ=lZ;import{useMemo as OU,useState as sZ}from"react";import{QueryClient as iZ,QueryClientProvider as rZ}from"@tanstack/react-query";import{jsx as k,Fragment as eZ}from"react/jsx-runtime";var tZ=({location:U,fallback:H,children:D})=>{let z=m(),$=v(),Z=N(),G=OU(()=>b(),[]),J=OU(()=>z?o(z):null,[z]),T=OU(()=>z?d(z,$):null,[z,$]);if(Z)console.log("[PieRoot] Rendering with location:",U),console.log("[PieRoot] API_SERVER:",z),console.log("[PieRoot] CENTRIFUGE_SERVER:",$),console.log("[PieRoot] Fallback provided:",!!H);return k(j.Provider,{value:G,children:k(C.Provider,{value:J,children:k(E.Provider,{value:T,children:k(W.Provider,{value:H??k(eZ,{}),children:k(h,{children:k(c,{children:k("form",{id:"piedata_global_form",action:z+"api/process"+U.pathname,method:"post",encType:"multipart/form-data",children:D})})})})})})})},aZ=(U)=>{let[H]=sZ(()=>new iZ);return k(f.Provider,{value:U.onNavigate,children:k(S.Provider,{value:U.config,children:k(rZ,{client:H,children:k(tZ,{...U})})})})},Uz=aZ;import{useMemo as r}from"react";import{QueryClient as zz,QueryClientProvider as $z,useQuery as Dz}from"@tanstack/react-query";import{createAxiosDateTransformer as Gz}from"axios-date-transformer";import{useEffect as Hz,useState as Zz}from"react";var lU=()=>{let[U,H]=Zz(null);return Hz(()=>{if(typeof window==="undefined")return;let D=window.WebApp;if(!D)return;D.ready(),H(D)},[]),U};import{jsx as A,Fragment as Yz}from"react/jsx-runtime";var Tz=({location:U,fallback:H,piecache:D,onError:z,queryOptions:$})=>{let Z=m(),G=v(),J=N(),T=r(()=>Gz({baseURL:Z}),[Z]),B=r(()=>b(),[]),_=r(()=>Z?o(Z):null,[Z]),I=r(()=>Z?d(Z,G):null,[Z,G]),V=lU(),{data:q,isLoading:Y,error:X}=Dz({queryKey:["uiConfig",U.pathname+U.search,V?.initData],queryFn:async()=>{let Q=new URLSearchParams(U.search);if(Q.set("__pieroot","max"),V?.initData)Q.set("initData",V.initData);let R="/api/content"+U.pathname+"?"+Q.toString();if(J)console.log("[PieRoot] Fetching UI configuration from:",R);let y=await T.get(R,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,PUT,POST,DELETE,PATCH,OPTIONS","Content-type":"application/json"},withCredentials:!0});if(J)console.log("[PieRoot] Received UI configuration:",y.data);return y.data},enabled:!!V?.initData,staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,retry:!0,retryDelay:(Q)=>Math.min(1000*2**Q,30000),...$}),P=p(U.pathname,D,H);if(!Z)throw Error("Set PIE_API_SERVER and PIE_CENTRIFUGE_SERVER");if(X&&J)return console.error("[PieRoot] Error fetching UI configuration:",X),console.error("[PieRoot] Error details:",{message:X.message,status:X.response?.status,data:X.response?.data}),z?.(),P;if(Y||!q){if(J)console.log("[PieRoot] Loading state:",{isLoading:Y,hasUiConfiguration:!!q});return P}if(J)console.log("[PieRoot] UI configuration loaded successfully:",q),console.log("[PieRoot] Rendering UI with configuration");return A(j.Provider,{value:B,children:A(C.Provider,{value:_,children:A(E.Provider,{value:I,children:A(W.Provider,{value:H??A(Yz,{}),children:A(h,{children:A(c,{children:A("form",{id:"piedata_global_form",action:Z+"api/process"+U.pathname,method:"post",encType:"multipart/form-data",children:A(L,{uiConfig:q})})})})})})})})},Jz=(U)=>{let H=r(()=>new zz,[]);return A(f.Provider,{value:U.onNavigate,children:A(S.Provider,{value:U.config,children:A($z,{client:H,children:A(Tz,{...U})})})})},Vz=Jz;import{useMemo as Xz}from"react";var qz=(U,H={},D=[],z,$)=>{let Z=$?.renderingLogEnabled??!1;if(!$?.apiServer){if(Z)console.warn("Registration FAILED: apiServer is missing!");return()=>{}}let G=$?.apiServer;if(Z)console.log("Registering AJAX: ",z,H,D);if(!z||!U){if(Z)console.warn("Registration FAILED: pathname or setUiAjaxConfiguration is missing!");return()=>{}}return async(J={})=>{if(typeof window==="undefined"||typeof document==="undefined"){if(Z)console.warn("getAjaxSubmit called on server, skipping DOM-dependent logic");return}if(D.includes("sid"))await RU();let T=new FormData;for(let[_,I]of Object.entries({...H,...J}))T.append(_,I);for(let _ of D)if(_==="sid"){if(!window.sid)throw new Error("SocketIO isn't initialized properly");T.append("sid",window.sid)}else{let I=document.getElementsByName(_);if(!I.length){if(Z)console.warn(`No input found with name ${_}`);continue}let V=I[0];if(V instanceof HTMLInputElement)if(V.type==="file"&&V.files)Array.from(V.files).forEach((q)=>T.append(_,q));else T.append(_,V.value);else if(V instanceof HTMLTextAreaElement)T.append(_,V.value)}let B=G+"api/ajax_content"+z;return U(null),await fetch(B,{method:"POST",body:T}).then(async(_)=>{let V=(_.headers.get("content-type")||"").includes("application/json");if(!!_.body?.getReader&&!V){let Y=_.body.getReader(),X=new TextDecoder,P="";while(!0){let{done:Q,value:R}=await Y.read();if(Q)break;P+=X.decode(R,{stream:!0});let y=P.split(`
|
|
3
|
+
`);P=y.pop()??"";for(let K of y){let u=K.trim();if(!u)continue;try{let pU=JSON.parse(u);U([pU])}catch{if(Z)console.warn("Failed to parse streamed line:",u)}}}if(P.trim())try{let Q=JSON.parse(P);U([Q])}catch{if(Z)console.warn("Failed to parse final streamed line:",P)}return{}}else{let Y=await _.json();return U(Y),Y}}).catch((_)=>{if(Z)console.error("AJAX request failed:",_);return U(null),_})}},Bz=(U,H={},D=[],z)=>{let{apiServer:$,enableRenderingLog:Z}=l(),G=JSON.stringify(H),J=JSON.stringify(D);return Xz(()=>qz(U,H,D,z,{apiServer:$,renderingLogEnabled:Z}),[U,G,J,z,$,Z])};import{clsx as Iz}from"clsx";import{twMerge as _z}from"tailwind-merge";function Pz(...U){return _z(Iz(U))}var Qz=()=>{if(typeof document==="undefined")return;let U=document.getElementById("piedata_global_form");U&&U.submit()};var Rz=(U,H)=>`${U}${$U}${H}`;export{KU as useWebApp,$H as usePieEmit,UU as useOpenAIWebRTC,Bz as useAjaxSubmit,VH as unregisterComponent,Qz as submitGlobalForm,g as registry,O as registerPieComponent,YH as registerMultipleComponents,Rz as pieName,XH as hasComponent,IH as getRegistrySize,n as getRegistryEntry,qH as getComponentMeta,BH as getAllRegisteredComponents,Pz as cn,jH as UnionCard,x as UIRendererContext,VU as UILoading,L as UI,yH as SequenceCard,nZ as PieTelegramRoot,bZ as PieRoot,Vz as PieMaxRoot,F as PieCard,Uz as PieBaseRoot,$U as PIEBREAK,IZ as IOEventsCard,lH as HiddenCard,gH as HTMLEmbedCard,OZ as BoxCard,aH as AutoRedirectCard,RZ as AjaxGroupCard};
|