@opencx/widget 3.0.69 → 3.0.71
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/designs.cjs +43 -32
- package/dist/designs.cjs.map +1 -1
- package/dist/designs.js +9388 -9285
- package/dist/designs.js.map +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +19 -17
- package/dist/src/designs/react/WidgetPopoverAnchor.d.ts +2 -0
- package/dist/src/designs/react/WidgetPopoverContent.d.ts +2 -0
- package/dist/src/designs/react/WidgetPopoverTrigger.d.ts +1 -3
- package/dist/src/designs/react/components/lib/button.d.ts +2 -2
- package/dist/src/designs/react/hooks/useIsSmallScreen.d.ts +3 -0
- package/dist/src/{headless → designs}/react/hooks/useTheme.d.ts +11 -5
- package/dist/src/designs/react/index.d.ts +1 -1
- package/dist/src/headless/core/types/widget-config.d.ts +17 -6
- package/dist/src/headless/react/hooks/useWidgetTrigger.d.ts +10 -0
- package/dist/src/headless/react/index.d.ts +1 -0
- package/dist/{useUploadFiles-DH1k_nBL.cjs → useWidgetTrigger-DhYRJ5kj.cjs} +4 -4
- package/dist/useWidgetTrigger-DhYRJ5kj.cjs.map +1 -0
- package/dist/{useUploadFiles-CoBUxfoW.js → useWidgetTrigger-vh6E1XGL.js} +282 -275
- package/dist/useWidgetTrigger-vh6E1XGL.js.map +1 -0
- package/dist-embed/script.js +189 -178
- package/dist-embed/script.js.map +1 -1
- package/package.json +2 -2
- package/dist/useUploadFiles-CoBUxfoW.js.map +0 -1
- package/dist/useUploadFiles-DH1k_nBL.cjs.map +0 -1
package/dist/react.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useWidgetTrigger-DhYRJ5kj.cjs");function g(t,i,s){const{widgetCtx:{api:u}}=e.useWidget();return e._default(async r=>u.vote({action:r==="up"?"upvote":"downvote",messagePublicId:t,sessionId:i}).then(s),[u,t,i,s])}exports.WidgetProvider=e.WidgetProvider;exports.WidgetTriggerProvider=e.WidgetTriggerProvider;exports.useConfig=e.useConfig;exports.useContact=e.useContact;exports.useIsAwaitingBotReply=e.useIsAwaitingBotReply;exports.useMessages=e.useMessages;exports.usePreludeData=e.usePreludeData;exports.usePrimitiveState=e.usePrimitiveState;exports.useSessions=e.useSessions;exports.useUploadFiles=e.useUploadFiles;exports.useWidget=e.useWidget;exports.useWidgetRouter=e.useWidgetRouter;exports.useWidgetTrigger=e.useWidgetTrigger;exports.useVote=g;
|
|
2
2
|
//# sourceMappingURL=react.cjs.map
|
package/dist/react.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.cjs","sources":["../src/headless/react/hooks/useVote.ts"],"sourcesContent":["import useAsyncFn from 'react-use/lib/useAsyncFn';\nimport { useWidget } from '../WidgetProvider';\n\n/**\n * @param id\n * @param onSuccess\n * @returns\n */\nexport function useVote(id: string, sessionId: string, onSuccess?: () => void) {\n const {\n widgetCtx: { api },\n } = useWidget();\n return useAsyncFn(\n async (action: 'up' | 'down') => {\n return api\n .vote({\n action: action === 'up' ? 'upvote' : 'downvote',\n messagePublicId: id,\n sessionId,\n })\n .then(onSuccess);\n },\n [api, id, sessionId, onSuccess],\n );\n}\n\n/**\n * @param id\n * @param onSuccess\n * @deprecated use useVote instead\n */\nexport function useUpvote(\n id: string,\n sessionId: string,\n onSuccess?: () => void,\n) {\n const {\n widgetCtx: { api },\n } = useWidget();\n return useAsyncFn(\n async () =>\n api\n .vote({ action: 'upvote', messagePublicId: id, sessionId })\n .then(onSuccess),\n [api, id, sessionId, onSuccess],\n );\n}\n\n/**\n * @param id\n * @param onSuccess\n * @deprecated use useVote instead\n */\nexport function useDownvote(\n id: string,\n sessionId: string,\n onSuccess?: () => void,\n) {\n const {\n widgetCtx: { api },\n } = useWidget();\n return useAsyncFn(\n async () =>\n api\n .vote({ action: 'downvote', messagePublicId: id, sessionId })\n .then(onSuccess),\n [api, id, sessionId, onSuccess],\n );\n}\n"],"names":["useVote","id","sessionId","onSuccess","api","useWidget","useAsyncFn","action"],"mappings":"
|
|
1
|
+
{"version":3,"file":"react.cjs","sources":["../src/headless/react/hooks/useVote.ts"],"sourcesContent":["import useAsyncFn from 'react-use/lib/useAsyncFn';\nimport { useWidget } from '../WidgetProvider';\n\n/**\n * @param id\n * @param onSuccess\n * @returns\n */\nexport function useVote(id: string, sessionId: string, onSuccess?: () => void) {\n const {\n widgetCtx: { api },\n } = useWidget();\n return useAsyncFn(\n async (action: 'up' | 'down') => {\n return api\n .vote({\n action: action === 'up' ? 'upvote' : 'downvote',\n messagePublicId: id,\n sessionId,\n })\n .then(onSuccess);\n },\n [api, id, sessionId, onSuccess],\n );\n}\n\n/**\n * @param id\n * @param onSuccess\n * @deprecated use useVote instead\n */\nexport function useUpvote(\n id: string,\n sessionId: string,\n onSuccess?: () => void,\n) {\n const {\n widgetCtx: { api },\n } = useWidget();\n return useAsyncFn(\n async () =>\n api\n .vote({ action: 'upvote', messagePublicId: id, sessionId })\n .then(onSuccess),\n [api, id, sessionId, onSuccess],\n );\n}\n\n/**\n * @param id\n * @param onSuccess\n * @deprecated use useVote instead\n */\nexport function useDownvote(\n id: string,\n sessionId: string,\n onSuccess?: () => void,\n) {\n const {\n widgetCtx: { api },\n } = useWidget();\n return useAsyncFn(\n async () =>\n api\n .vote({ action: 'downvote', messagePublicId: id, sessionId })\n .then(onSuccess),\n [api, id, sessionId, onSuccess],\n );\n}\n"],"names":["useVote","id","sessionId","onSuccess","api","useWidget","useAsyncFn","action"],"mappings":"mIAQgB,SAAAA,EAAQC,EAAYC,EAAmBC,EAAwB,CACvE,KAAA,CACJ,UAAW,CAAE,IAAAC,CAAI,GACfC,EAAU,UAAA,EACP,OAAAC,EAAA,SACL,MAAOC,GACEH,EACJ,KAAK,CACJ,OAAQG,IAAW,KAAO,SAAW,WACrC,gBAAiBN,EACjB,UAAAC,CAAA,CACD,EACA,KAAKC,CAAS,EAEnB,CAACC,EAAKH,EAAIC,EAAWC,CAAS,CAAA,CAElC"}
|
package/dist/react.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { u
|
|
2
|
-
import { W as p,
|
|
3
|
-
function
|
|
1
|
+
import { u, _ as r } from "./useWidgetTrigger-vh6E1XGL.js";
|
|
2
|
+
import { W as p, k as f, a as l, b as v, c as W, d as c, e as m, f as P, g as w, i as x, h as C, j as b } from "./useWidgetTrigger-vh6E1XGL.js";
|
|
3
|
+
function g(e, s, t) {
|
|
4
4
|
const {
|
|
5
5
|
widgetCtx: { api: a }
|
|
6
|
-
} =
|
|
7
|
-
return
|
|
8
|
-
async (
|
|
9
|
-
action:
|
|
6
|
+
} = u();
|
|
7
|
+
return r(
|
|
8
|
+
async (i) => a.vote({
|
|
9
|
+
action: i === "up" ? "upvote" : "downvote",
|
|
10
10
|
messagePublicId: e,
|
|
11
11
|
sessionId: s
|
|
12
12
|
}).then(t),
|
|
@@ -15,16 +15,18 @@ function n(e, s, t) {
|
|
|
15
15
|
}
|
|
16
16
|
export {
|
|
17
17
|
p as WidgetProvider,
|
|
18
|
-
f as
|
|
19
|
-
l as
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
f as WidgetTriggerProvider,
|
|
19
|
+
l as useConfig,
|
|
20
|
+
v as useContact,
|
|
21
|
+
W as useIsAwaitingBotReply,
|
|
22
|
+
c as useMessages,
|
|
23
|
+
m as usePreludeData,
|
|
23
24
|
P as usePrimitiveState,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
w as useSessions,
|
|
26
|
+
x as useUploadFiles,
|
|
27
|
+
g as useVote,
|
|
28
|
+
u as useWidget,
|
|
29
|
+
C as useWidgetRouter,
|
|
30
|
+
b as useWidgetTrigger
|
|
29
31
|
};
|
|
30
32
|
//# sourceMappingURL=react.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { VariantProps } from 'class-variance-authority';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
declare const buttonVariants: (props?: ({
|
|
4
|
-
variant?: "default" | "link" | "
|
|
5
|
-
size?: "default" | "
|
|
4
|
+
variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
|
|
5
|
+
size?: "default" | "sm" | "lg" | "icon" | "fit" | "free" | "selfless" | null | undefined;
|
|
6
6
|
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
7
7
|
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
8
8
|
asChild?: boolean;
|
|
@@ -6,17 +6,23 @@ export declare function useTheme(): {
|
|
|
6
6
|
theme: {
|
|
7
7
|
primaryColor: string;
|
|
8
8
|
widgetTrigger: {
|
|
9
|
+
zIndex: number;
|
|
9
10
|
offset: {
|
|
10
|
-
bottom:
|
|
11
|
-
right:
|
|
11
|
+
bottom: number;
|
|
12
|
+
right: number;
|
|
12
13
|
};
|
|
13
14
|
size: {
|
|
14
|
-
button:
|
|
15
|
-
icon:
|
|
15
|
+
button: number;
|
|
16
|
+
icon: number;
|
|
16
17
|
};
|
|
17
18
|
};
|
|
18
19
|
widgetContentContainer: {
|
|
19
|
-
|
|
20
|
+
borderRadius: string;
|
|
21
|
+
zIndex: number;
|
|
22
|
+
offset: {
|
|
23
|
+
side: number;
|
|
24
|
+
align: number;
|
|
25
|
+
};
|
|
20
26
|
};
|
|
21
27
|
screens: {
|
|
22
28
|
welcome: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { WidgetComponentType } from '../../headless/react';
|
|
3
2
|
import { WidgetConfig } from '../../headless/core';
|
|
3
|
+
import { WidgetComponentType } from '../../headless/react';
|
|
4
4
|
declare function WidgetWrapper({ options, components, }: {
|
|
5
5
|
options: WidgetConfig;
|
|
6
6
|
components?: WidgetComponentType[];
|
|
@@ -38,18 +38,29 @@ export interface WidgetConfig {
|
|
|
38
38
|
theme?: {
|
|
39
39
|
primaryColor?: string;
|
|
40
40
|
widgetTrigger?: {
|
|
41
|
+
zIndex?: number;
|
|
41
42
|
offset?: {
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
/** number in pixels */
|
|
44
|
+
right?: number;
|
|
45
|
+
/** number in pixels */
|
|
46
|
+
bottom?: number;
|
|
44
47
|
};
|
|
45
48
|
size?: {
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
/** number in pixels */
|
|
50
|
+
button?: number;
|
|
51
|
+
/** number in pixels */
|
|
52
|
+
icon?: number;
|
|
48
53
|
};
|
|
49
54
|
};
|
|
50
55
|
widgetContentContainer?: {
|
|
51
|
-
|
|
52
|
-
|
|
56
|
+
borderRadius?: string;
|
|
57
|
+
zIndex?: number;
|
|
58
|
+
offset?: {
|
|
59
|
+
/** number in pixels */
|
|
60
|
+
side?: number;
|
|
61
|
+
/** number in pixels */
|
|
62
|
+
align?: number;
|
|
63
|
+
};
|
|
53
64
|
};
|
|
54
65
|
screens?: {
|
|
55
66
|
welcome?: {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { default as React, Dispatch, ReactNode, SetStateAction } from 'react';
|
|
2
|
+
type WidgetTriggerCtx = {
|
|
3
|
+
isOpen: boolean;
|
|
4
|
+
setIsOpen: Dispatch<SetStateAction<boolean>>;
|
|
5
|
+
};
|
|
6
|
+
export declare const useWidgetTrigger: () => WidgetTriggerCtx, SafeProvider: React.Provider<WidgetTriggerCtx>;
|
|
7
|
+
export declare function WidgetTriggerProvider({ children }: {
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}): React.JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -10,3 +10,4 @@ export { useSessions } from './hooks/useSessions';
|
|
|
10
10
|
export { useWidgetRouter } from './hooks/useWidgetRouter';
|
|
11
11
|
export { useVote } from './hooks/useVote';
|
|
12
12
|
export { type FileWithProgress, useUploadFiles } from './hooks/useUploadFiles';
|
|
13
|
+
export { useWidgetTrigger, WidgetTriggerProvider, } from './hooks/useWidgetTrigger';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const _=require("react"),Ze=require("react/jsx-runtime"),$t=require("./widget.ctx-DUaeXkNb.cjs"),Gt=require("uuid");class Ht{constructor(t){this.components=[];const{components:n}=t;if(n&&n.forEach(r=>this.register(r)),this.components.length===0)throw new Error("No components registered");if(!this.get("fallback"))throw new Error("No fallback component registered")}register(t){const n=this.components.findIndex(r=>r.key===t.key);return n!==-1?this.components[n]=t:this.components.push(t),this}get(t){const n=this.components.find(r=>r.key.toUpperCase()===t.toUpperCase());return n||null}getComponent(t){var n;return(n=this.get(t))==null?void 0:n.component}}function et(e){const t=_.createContext({});return[()=>{const r=_.useContext(t);if(r===void 0)throw new Error("useSafeContext must be used within a Provider");return r},t.Provider]}const Kt="3.0.71",[K,zt]=et();function kt({options:e,children:t,components:n,storage:r}){const o=_.useRef(!1),[s,i]=_.useState(null),d=_.useMemo(()=>new Ht({components:n}),[n]);return _.useEffect(()=>{o.current||(o.current=!0,$t.WidgetCtx.initialize({config:e,storage:r}).then(i))},[]),s?Ze.jsx(zt,{value:{widgetCtx:s,components:n,componentStore:d,version:Kt,theme:e.theme},children:t}):null}function Yt(){const{widgetCtx:e}=K();return e.config}function ee(e){return _.useSyncExternalStore(e.subscribe,e.get,e.get)}function Jt(){const{widgetCtx:e}=K();return{contactState:ee(e.contactCtx.state),createUnverifiedContact:e.contactCtx.createUnverifiedContact}}function tt(){const{widgetCtx:e}=K();return{messagesState:ee(e.messageCtx.state),sendMessage:e.messageCtx.sendMessage}}function nt(){const{widgetCtx:e}=K(),t=ee(e.sessionCtx.sessionState),n=ee(e.sessionCtx.sessionsState);return{sessionState:t,sessionsState:n,loadMoreSessions:e.sessionCtx.loadMoreSessions}}function Xt(){var i;const{sessionState:e}=nt(),{messagesState:t}=tt(),n=((i=e.session)==null?void 0:i.assignee.kind)==="ai",r=t.messages.length>0?t.messages[t.messages.length-1]:null,o=(r==null?void 0:r.type)==="FROM_USER";return{isAwaitingBotReply:(n||e.isCreatingSession)&&(t.isSendingMessage||o)}}var Qt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Zt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function en(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var n=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,o.get?o:{enumerable:!0,get:function(){return e[r]}})}),n}var Re={exports:{}},_e={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* use-sync-external-store-shim.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var Ke;function tn(){if(Ke)return
|
|
9
|
+
*/var Ke;function tn(){if(Ke)return _e;Ke=1;var e=_;function t(u,l){return u===l&&(u!==0||1/u===1/l)||u!==u&&l!==l}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,o=e.useEffect,s=e.useLayoutEffect,i=e.useDebugValue;function d(u,l){var c=l(),y=r({inst:{value:c,getSnapshot:l}}),g=y[0].inst,T=y[1];return s(function(){g.value=c,g.getSnapshot=l,h(g)&&T({inst:g})},[u,c,l]),o(function(){return h(g)&&T({inst:g}),u(function(){h(g)&&T({inst:g})})},[u]),i(c),c}function h(u){var l=u.getSnapshot;u=u.value;try{var c=l();return!n(u,c)}catch{return!0}}function f(u,l){return l()}var a=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:d;return _e.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:a,_e}var ve={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* use-sync-external-store-shim.development.js
|
|
12
12
|
*
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var ze;function nn(){return ze||(ze=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=g,t=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function n(R){{for(var v=arguments.length,w=new Array(v>1?v-1:0),S=1;S<v;S++)w[S-1]=arguments[S];r("error",R,w)}}function r(R,v,w){{var S=t.ReactDebugCurrentFrame,I=S.getStackAddendum();I!==""&&(v+="%s",w=w.concat([I]));var m=w.map(function(D){return String(D)});m.unshift("Warning: "+v),Function.prototype.apply.call(console[R],console,m)}}function o(R,v){return R===v&&(R!==0||1/R===1/v)||R!==R&&v!==v}var s=typeof Object.is=="function"?Object.is:o,i=e.useState,d=e.useEffect,h=e.useLayoutEffect,f=e.useDebugValue,a=!1,u=!1;function l(R,v,w){a||e.startTransition!==void 0&&(a=!0,n("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var S=v();if(!u){var I=v();s(S,I)||(n("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}var m=i({inst:{value:S,getSnapshot:v}}),D=m[0].inst,P=m[1];return h(function(){D.value=S,D.getSnapshot=v,c(D)&&P({inst:D})},[R,S,v]),d(function(){c(D)&&P({inst:D});var B=function(){c(D)&&P({inst:D})};return R(B)},[R]),f(S),S}function c(R){var v=R.getSnapshot,w=R.value;try{var S=v();return!s(w,S)}catch{return!0}}function _(R,v,w){return v()}var y=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",T=!y,p=T?_:l,k=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p;Ee.useSyncExternalStore=k,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),Ee}process.env.NODE_ENV==="production"?Re.exports=tn():Re.exports=nn();var rn=Re.exports;const H=()=>{},L=H(),ve=Object,E=e=>e===L,N=e=>typeof e=="function",$=(e,t)=>({...e,...t}),on=e=>N(e.then),ue=new WeakMap;let sn=0;const oe=e=>{const t=typeof e,n=e&&e.constructor,r=n==Date;let o,s;if(ve(e)===e&&!r&&n!=RegExp){if(o=ue.get(e),o)return o;if(o=++sn+"~",ue.set(e,o),n==Array){for(o="@",s=0;s<e.length;s++)o+=oe(e[s])+",";ue.set(e,o)}if(n==ve){o="#";const i=ve.keys(e).sort();for(;!E(s=i.pop());)E(e[s])||(o+=s+":"+oe(e[s])+",");ue.set(e,o)}}else o=r?e.toJSON():t=="symbol"?e.toString():t=="string"?JSON.stringify(e):""+e;return o},q=new WeakMap,Se={},ce={},Le="undefined",pe=typeof window!=Le,Ce=typeof document!=Le,an=()=>pe&&typeof window.requestAnimationFrame!=Le,tt=(e,t)=>{const n=q.get(e);return[()=>!E(t)&&e.get(t)||Se,r=>{if(!E(t)){const o=e.get(t);t in ce||(ce[t]=o),n[5](t,$(o,r),o||Se)}},n[6],()=>!E(t)&&t in ce?ce[t]:!E(t)&&e.get(t)||Se]};let Te=!0;const un=()=>Te,[De,Ae]=pe&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[H,H],cn=()=>{const e=Ce&&document.visibilityState;return E(e)||e!=="hidden"},fn=e=>(Ce&&document.addEventListener("visibilitychange",e),De("focus",e),()=>{Ce&&document.removeEventListener("visibilitychange",e),Ae("focus",e)}),ln=e=>{const t=()=>{Te=!0,e()},n=()=>{Te=!1};return De("online",t),De("offline",n),()=>{Ae("online",t),Ae("offline",n)}},dn={isOnline:un,isVisible:cn},pn={initFocus:fn,initReconnect:ln},ke=!g.useId,se=!pe||"Deno"in window,hn=e=>an()?window.requestAnimationFrame(e):setTimeout(e,1),we=se?g.useEffect:g.useLayoutEffect,me=typeof navigator<"u"&&navigator.connection,Ye=!se&&me&&(["slow-2g","2g"].includes(me.effectiveType)||me.saveData),Ie=e=>{if(N(e))try{e=e()}catch{e=""}const t=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?oe(e):"",[e,t]};let yn=0;const xe=()=>++yn,nt=0,rt=1,ot=2,_n=3;var re={__proto__:null,ERROR_REVALIDATE_EVENT:_n,FOCUS_EVENT:nt,MUTATE_EVENT:ot,RECONNECT_EVENT:rt};async function st(...e){const[t,n,r,o]=e,s=$({populateCache:!0,throwOnError:!0},typeof o=="boolean"?{revalidate:o}:o||{});let i=s.populateCache;const d=s.rollbackOnError;let h=s.optimisticData;const f=l=>typeof d=="function"?d(l):d!==!1,a=s.throwOnError;if(N(n)){const l=n,c=[],_=t.keys();for(const y of _)!/^\$(inf|sub)\$/.test(y)&&l(t.get(y)._k)&&c.push(y);return Promise.all(c.map(u))}return u(n);async function u(l){const[c]=Ie(l);if(!c)return;const[_,y]=tt(t,c),[T,p,k,R]=q.get(t),v=()=>{const M=T[c];return(N(s.revalidate)?s.revalidate(_().data,l):s.revalidate!==!1)&&(delete k[c],delete R[c],M&&M[0])?M[0](ot).then(()=>_().data):_().data};if(e.length<3)return v();let w=r,S;const I=xe();p[c]=[I,0];const m=!E(h),D=_(),P=D.data,B=D._c,z=E(B)?P:B;if(m&&(h=N(h)?h(z,P):h,y({data:h,_c:z})),N(w))try{w=w(z)}catch(M){S=M}if(w&&on(w))if(w=await w.catch(M=>{S=M}),I!==p[c][0]){if(S)throw S;return w}else S&&m&&f(S)&&(i=!0,y({data:z,_c:L}));if(i&&!S)if(N(i)){const M=i(w,z);y({data:M,error:L,_c:L})}else y({data:w,error:L,_c:L});if(p[c][1]=xe(),Promise.resolve(v()).then(()=>{y({_c:L})}),S){if(a)throw S;return}return w}}const Je=(e,t)=>{for(const n in e)e[n][0]&&e[n][0](t)},gn=(e,t)=>{if(!q.has(e)){const n=$(pn,t),r={},o=st.bind(L,e);let s=H;const i={},d=(a,u)=>{const l=i[a]||[];return i[a]=l,l.push(u),()=>l.splice(l.indexOf(u),1)},h=(a,u,l)=>{e.set(a,u);const c=i[a];if(c)for(const _ of c)_(u,l)},f=()=>{if(!q.has(e)&&(q.set(e,[r,{},{},{},o,h,d]),!se)){const a=n.initFocus(setTimeout.bind(L,Je.bind(L,r,nt))),u=n.initReconnect(setTimeout.bind(L,Je.bind(L,r,rt)));s=()=>{a&&a(),u&&u(),q.delete(e)}}};return f(),[e,o,f,s]}return[e,q.get(e)[4]]},En=(e,t,n,r,o)=>{const s=n.errorRetryCount,i=o.retryCount,d=~~((Math.random()+.5)*(1<<(i<8?i:8)))*n.errorRetryInterval;!E(s)&&i>s||setTimeout(r,d,o)},vn=(e,t)=>oe(e)==oe(t),[it,Sn]=gn(new Map),wn=$({onLoadingSlow:H,onSuccess:H,onError:H,onErrorRetry:En,onDiscarded:H,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:Ye?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:Ye?5e3:3e3,compare:vn,isPaused:()=>!1,cache:it,mutate:Sn,fallback:{}},dn),mn=(e,t)=>{const n=$(e,t);if(t){const{use:r,fallback:o}=e,{use:s,fallback:i}=t;r&&s&&(n.use=r.concat(s)),o&&i&&(n.fallback=$(o,i))}return n},bn=g.createContext({}),On="$inf$",at=pe&&window.__SWR_DEVTOOLS_USE__,Rn=at?window.__SWR_DEVTOOLS_USE__:[],Cn=()=>{at&&(window.__SWR_DEVTOOLS_REACT__=g)},Tn=e=>N(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],Dn=()=>$(wn,g.useContext(bn)),An=e=>(t,n,r)=>e(t,n&&((...s)=>{const[i]=Ie(t),[,,,d]=q.get(it);if(i.startsWith(On))return n(...s);const h=d[i];return E(h)?n(...s):(delete d[i],h)}),r),xn=Rn.concat(An),jn=e=>function(...n){const r=Dn(),[o,s,i]=Tn(n),d=mn(r,i);let h=e;const{use:f}=d,a=(f||[]).concat(xn);for(let u=a.length;u--;)h=a[u](h);return h(o,s||d.fetcher||null,d)},Pn=(e,t,n)=>{const r=t[e]||(t[e]=[]);return r.push(n),()=>{const o=r.indexOf(n);o>=0&&(r[o]=r[r.length-1],r.pop())}};Cn();const Xe=g.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e)}),be={dedupe:!0},Ln=(e,t,n)=>{const{cache:r,compare:o,suspense:s,fallbackData:i,revalidateOnMount:d,revalidateIfStale:h,refreshInterval:f,refreshWhenHidden:a,refreshWhenOffline:u,keepPreviousData:l}=n,[c,_,y,T]=q.get(r),[p,k]=Ie(e),R=g.useRef(!1),v=g.useRef(!1),w=g.useRef(p),S=g.useRef(t),I=g.useRef(n),m=()=>I.current,D=()=>m().isVisible()&&m().isOnline(),[P,B,z,M]=tt(r,p),Y=g.useRef({}).current,Mt=E(i)?n.fallback[p]:i,Me=(b,O)=>{for(const x in Y){const C=x;if(C==="data"){if(!o(b[C],O[C])&&(!E(b[C])||!o(ae,O[C])))return!1}else if(O[C]!==b[C])return!1}return!0},Fe=g.useMemo(()=>{const b=!p||!t?!1:E(d)?m().isPaused()||s?!1:E(h)?!0:h:d,O=j=>{const U=$(j);return delete U._k,b?{isValidating:!0,isLoading:!0,...U}:U},x=P(),C=M(),F=O(x),Z=x===C?F:O(C);let A=F;return[()=>{const j=O(P());return Me(j,A)?(A.data=j.data,A.isLoading=j.isLoading,A.isValidating=j.isValidating,A.error=j.error,A):(A=j,j)},()=>Z]},[r,p]),J=rn.useSyncExternalStore(g.useCallback(b=>z(p,(O,x)=>{Me(x,O)||b()}),[r,p]),Fe[0],Fe[1]),Ne=!R.current,Ft=c[p]&&c[p].length>0,X=J.data,Q=E(X)?Mt:X,ie=J.error,Ue=g.useRef(Q),ae=l?E(X)?Ue.current:X:Q,We=Ft&&!E(ie)?!1:Ne&&!E(d)?d:m().isPaused()?!1:s?E(Q)?!1:h:E(Q)||h,qe=!!(p&&t&&Ne&&We),Nt=E(J.isValidating)?qe:J.isValidating,Ut=E(J.isLoading)?qe:J.isLoading,ne=g.useCallback(async b=>{const O=S.current;if(!p||!O||v.current||m().isPaused())return!1;let x,C,F=!0;const Z=b||{},A=!y[p]||!Z.dedupe,j=()=>ke?!v.current&&p===w.current&&R.current:p===w.current,U={isValidating:!1,isLoading:!1},Ge=()=>{B(U)},He=()=>{const V=y[p];V&&V[1]===C&&delete y[p]},$e={isValidating:!0};E(P().data)&&($e.isLoading=!0);try{if(A&&(B($e),n.loadingTimeout&&E(P().data)&&setTimeout(()=>{F&&j()&&m().onLoadingSlow(p,n)},n.loadingTimeout),y[p]=[O(k),xe()]),[x,C]=y[p],x=await x,A&&setTimeout(He,n.dedupingInterval),!y[p]||y[p][1]!==C)return A&&j()&&m().onDiscarded(p),!1;U.error=L;const V=_[p];if(!E(V)&&(C<=V[0]||C<=V[1]||V[1]===0))return Ge(),A&&j()&&m().onDiscarded(p),!1;const W=P().data;U.data=o(W,x)?W:x,A&&j()&&m().onSuccess(x,p,n)}catch(V){He();const W=m(),{shouldRetryOnError:ye}=W;W.isPaused()||(U.error=V,A&&j()&&(W.onError(V,p,W),(ye===!0||N(ye)&&ye(V))&&(!m().revalidateOnFocus||!m().revalidateOnReconnect||D())&&W.onErrorRetry(V,p,W,Wt=>{const _e=c[p];_e&&_e[0]&&_e[0](re.ERROR_REVALIDATE_EVENT,Wt)},{retryCount:(Z.retryCount||0)+1,dedupe:!0})))}return F=!1,Ge(),!0},[p,r]),Be=g.useCallback((...b)=>st(r,w.current,...b),[]);if(we(()=>{S.current=t,I.current=n,E(X)||(Ue.current=X)}),we(()=>{if(!p)return;const b=ne.bind(L,be);let O=0;const C=Pn(p,c,(F,Z={})=>{if(F==re.FOCUS_EVENT){const A=Date.now();m().revalidateOnFocus&&A>O&&D()&&(O=A+m().focusThrottleInterval,b())}else if(F==re.RECONNECT_EVENT)m().revalidateOnReconnect&&D()&&b();else{if(F==re.MUTATE_EVENT)return ne();if(F==re.ERROR_REVALIDATE_EVENT)return ne(Z)}});return v.current=!1,w.current=p,R.current=!0,B({_k:k}),We&&(E(Q)||se?b():hn(b)),()=>{v.current=!0,C()}},[p]),we(()=>{let b;function O(){const C=N(f)?f(P().data):f;C&&b!==-1&&(b=setTimeout(x,C))}function x(){!P().error&&(a||m().isVisible())&&(u||m().isOnline())?ne(be).then(O):O()}return O(),()=>{b&&(clearTimeout(b),b=-1)}},[f,a,u,p]),g.useDebugValue(ae),s&&E(Q)&&p){if(!ke&&se)throw new Error("Fallback data is required when using suspense in SSR.");S.current=t,I.current=n,v.current=!1;const b=T[p];if(!E(b)){const O=Be(b);Xe(O)}if(E(ie)){const O=ne(be);E(ae)||(O.status="fulfilled",O.value=!0),Xe(O)}else throw ie}return{mutate:Be,get data(){return Y.data=!0,ae},get error(){return Y.error=!0,ie},get isValidating(){return Y.isValidating=!0,Nt},get isLoading(){return Y.isLoading=!0,Ut}}},In=jn(Ln);function Vn(){const{widgetCtx:e}=K();return In([e.config.token],e.api.widgetPrelude,{revalidateOnFocus:!1})}function Mn(){const{widgetCtx:e}=K();return{routerState:ee(e.routerCtx.state),toSessionsScreen:e.routerCtx.toSessionsScreen,toChatScreen:e.routerCtx.toChatScreen}}var ut={},je=function(e,t){return je=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])},je(e,t)};function ct(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");je(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var le=function(){return le=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},le.apply(this,arguments)};function ft(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function lt(e,t,n,r){var o=arguments.length,s=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(e,t,n,r);else for(var d=e.length-1;d>=0;d--)(i=e[d])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s}function dt(e,t){return function(n,r){t(n,r,e)}}function pt(e,t,n,r,o,s){function i(p){if(p!==void 0&&typeof p!="function")throw new TypeError("Function expected");return p}for(var d=r.kind,h=d==="getter"?"get":d==="setter"?"set":"value",f=!t&&e?r.static?e:e.prototype:null,a=t||(f?Object.getOwnPropertyDescriptor(f,r.name):{}),u,l=!1,c=n.length-1;c>=0;c--){var _={};for(var y in r)_[y]=y==="access"?{}:r[y];for(var y in r.access)_.access[y]=r.access[y];_.addInitializer=function(p){if(l)throw new TypeError("Cannot add initializers after decoration has completed");s.push(i(p||null))};var T=(0,n[c])(d==="accessor"?{get:a.get,set:a.set}:a[h],_);if(d==="accessor"){if(T===void 0)continue;if(T===null||typeof T!="object")throw new TypeError("Object expected");(u=i(T.get))&&(a.get=u),(u=i(T.set))&&(a.set=u),(u=i(T.init))&&o.unshift(u)}else(u=i(T))&&(d==="field"?o.unshift(u):a[h]=u)}f&&Object.defineProperty(f,r.name,a),l=!0}function ht(e,t,n){for(var r=arguments.length>2,o=0;o<t.length;o++)n=r?t[o].call(e,n):t[o].call(e);return r?n:void 0}function yt(e){return typeof e=="symbol"?e:"".concat(e)}function _t(e,t,n){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:n?"".concat(n," ",t):t})}function gt(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function Et(e,t,n,r){function o(s){return s instanceof n?s:new n(function(i){i(s)})}return new(n||(n=Promise))(function(s,i){function d(a){try{f(r.next(a))}catch(u){i(u)}}function h(a){try{f(r.throw(a))}catch(u){i(u)}}function f(a){a.done?s(a.value):o(a.value).then(d,h)}f((r=r.apply(e,t||[])).next())})}function vt(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,o,s,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=d(0),i.throw=d(1),i.return=d(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function d(f){return function(a){return h([f,a])}}function h(f){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,f[0]&&(n=0)),n;)try{if(r=1,o&&(s=f[0]&2?o.return:f[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,f[1])).done)return s;switch(o=0,s&&(f=[f[0]&2,s.value]),f[0]){case 0:case 1:s=f;break;case 4:return n.label++,{value:f[1],done:!1};case 5:n.label++,o=f[1],f=[0];continue;case 7:f=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(f[0]===6||f[0]===2)){n=0;continue}if(f[0]===3&&(!s||f[1]>s[0]&&f[1]<s[3])){n.label=f[1];break}if(f[0]===6&&n.label<s[1]){n.label=s[1],s=f;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(f);break}s[2]&&n.ops.pop(),n.trys.pop();continue}f=t.call(e,n)}catch(a){f=[6,a],o=0}finally{r=s=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}}var he=Object.create?function(e,t,n,r){r===void 0&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]};function St(e,t){for(var n in e)n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n)&&he(t,e,n)}function de(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ve(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),o,s=[],i;try{for(;(t===void 0||t-- >0)&&!(o=r.next()).done;)s.push(o.value)}catch(d){i={error:d}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return s}function wt(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Ve(arguments[t]));return e}function mt(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),o=0,t=0;t<n;t++)for(var s=arguments[t],i=0,d=s.length;i<d;i++,o++)r[o]=s[i];return r}function bt(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}function te(e){return this instanceof te?(this.v=e,this):new te(e)}function Ot(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),o,s=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),d("next"),d("throw"),d("return",i),o[Symbol.asyncIterator]=function(){return this},o;function i(c){return function(_){return Promise.resolve(_).then(c,u)}}function d(c,_){r[c]&&(o[c]=function(y){return new Promise(function(T,p){s.push([c,y,T,p])>1||h(c,y)})},_&&(o[c]=_(o[c])))}function h(c,_){try{f(r[c](_))}catch(y){l(s[0][3],y)}}function f(c){c.value instanceof te?Promise.resolve(c.value.v).then(a,u):l(s[0][2],c)}function a(c){h("next",c)}function u(c){h("throw",c)}function l(c,_){c(_),s.shift(),s.length&&h(s[0][0],s[0][1])}}function Rt(e){var t,n;return t={},r("next"),r("throw",function(o){throw o}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(o,s){t[o]=e[o]?function(i){return(n=!n)?{value:te(e[o](i)),done:!1}:s?s(i):i}:s}}function Ct(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof de=="function"?de(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=e[s]&&function(i){return new Promise(function(d,h){i=e[s](i),o(d,h,i.done,i.value)})}}function o(s,i,d,h){Promise.resolve(h).then(function(f){s({value:f,done:d})},i)}}function Tt(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var Fn=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function Dt(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)n!=="default"&&Object.prototype.hasOwnProperty.call(e,n)&&he(t,e,n);return Fn(t,e),t}function At(e){return e&&e.__esModule?e:{default:e}}function xt(e,t,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(e):r?r.value:t.get(e)}function jt(e,t,n,r,o){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?o.call(e,n):o?o.value=n:t.set(e,n),n}function Pt(e,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof e=="function"?t===e:e.has(t)}function Lt(e,t,n){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var r,o;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=t[Symbol.dispose],n&&(o=r)}if(typeof r!="function")throw new TypeError("Object not disposable.");o&&(r=function(){try{o.call(this)}catch(s){return Promise.reject(s)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t}var Nn=typeof SuppressedError=="function"?SuppressedError:function(e,t,n){var r=new Error(n);return r.name="SuppressedError",r.error=e,r.suppressed=t,r};function It(e){function t(s){e.error=e.hasError?new Nn(s,e.error,"An error was suppressed during disposal."):s,e.hasError=!0}var n,r=0;function o(){for(;n=e.stack.pop();)try{if(!n.async&&r===1)return r=0,e.stack.push(n),Promise.resolve().then(o);if(n.dispose){var s=n.dispose.call(n.value);if(n.async)return r|=2,Promise.resolve(s).then(o,function(i){return t(i),o()})}else r|=1}catch(i){t(i)}if(r===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return o()}function Vt(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(n,r,o,s,i){return r?t?".jsx":".js":o&&(!s||!i)?n:o+s+"."+i.toLowerCase()+"js"}):e}const Un={__extends:ct,__assign:le,__rest:ft,__decorate:lt,__param:dt,__esDecorate:pt,__runInitializers:ht,__propKey:yt,__setFunctionName:_t,__metadata:gt,__awaiter:Et,__generator:vt,__createBinding:he,__exportStar:St,__values:de,__read:Ve,__spread:wt,__spreadArrays:mt,__spreadArray:bt,__await:te,__asyncGenerator:Ot,__asyncDelegator:Rt,__asyncValues:Ct,__makeTemplateObject:Tt,__importStar:Dt,__importDefault:At,__classPrivateFieldGet:xt,__classPrivateFieldSet:jt,__classPrivateFieldIn:Pt,__addDisposableResource:Lt,__disposeResources:It,__rewriteRelativeImportExtension:Vt},Wn=Object.freeze(Object.defineProperty({__proto__:null,__addDisposableResource:Lt,get __assign(){return le},__asyncDelegator:Rt,__asyncGenerator:Ot,__asyncValues:Ct,__await:te,__awaiter:Et,__classPrivateFieldGet:xt,__classPrivateFieldIn:Pt,__classPrivateFieldSet:jt,__createBinding:he,__decorate:lt,__disposeResources:It,__esDecorate:pt,__exportStar:St,__extends:ct,__generator:vt,__importDefault:At,__importStar:Dt,__makeTemplateObject:Tt,__metadata:gt,__param:dt,__propKey:yt,__read:Ve,__rest:ft,__rewriteRelativeImportExtension:Vt,__runInitializers:ht,__setFunctionName:_t,__spread:wt,__spreadArray:bt,__spreadArrays:mt,__values:de,default:Un},Symbol.toStringTag,{value:"Module"})),qn=en(Wn);var fe={},Qe;function Bn(){if(Qe)return fe;Qe=1,Object.defineProperty(fe,"__esModule",{value:!0});var e=g;function t(){var n=e.useRef(!1),r=e.useCallback(function(){return n.current},[]);return e.useEffect(function(){return n.current=!0,function(){n.current=!1}},[]),r}return fe.default=t,fe}Object.defineProperty(ut,"__esModule",{value:!0});var Pe=qn,Oe=g,Gn=Pe.__importDefault(Bn());function Hn(e,t,n){t===void 0&&(t=[]),n===void 0&&(n={loading:!1});var r=Oe.useRef(0),o=Gn.default(),s=Oe.useState(n),i=s[0],d=s[1],h=Oe.useCallback(function(){for(var f=[],a=0;a<arguments.length;a++)f[a]=arguments[a];var u=++r.current;return i.loading||d(function(l){return Pe.__assign(Pe.__assign({},l),{loading:!0})}),e.apply(void 0,f).then(function(l){return o()&&u===r.current&&d({value:l,loading:!1}),l},function(l){return o()&&u===r.current&&d({error:l,loading:!1}),l})},t);return[i,h]}var $n=ut.default=Hn;const G=new Map;function Kn(){const[e,t]=g.useState([]),{widgetCtx:{api:n}}=K();function r(a){const u=a.map(l=>({file:l,id:Gt.v4(),status:"pending",progress:0}));t(l=>[...l,...u]),u.forEach(i)}function o(a,u){t(l=>l.map(c=>c.id===a?{...c,...u}:c))}function s(a){t(u=>u.filter(l=>l.id!==a))}const i=async a=>{const u=new AbortController;G.set(a.id,u);try{t(c=>c.map(_=>_.id===a.id?{..._,status:"uploading",progress:0}:_));const l=await n.uploadFile({file:a.file,abortSignal:u.signal,onProgress:c=>{o(a.id,{progress:c})}});o(a.id,{status:"success",fileUrl:l.fileUrl,progress:100})}catch(l){u.signal.aborted||o(a.id,{status:"error",error:l instanceof Error?l.message:"Upload failed",progress:0})}finally{G.delete(a.id)}},d=a=>{const u=G.get(a);u&&(u.abort(),G.delete(a)),s(a)},h=g.useMemo(()=>e.filter(a=>a.status==="success"&&a.fileUrl),[e]);function f(){G.forEach(a=>a.abort()),G.clear(),t([])}return g.useEffect(()=>()=>{G.forEach(a=>a.abort()),G.clear()},[]),{allFiles:e,appendFiles:r,handleCancelUpload:d,successFiles:h,emptyTheFiles:f,getFileById:a=>e.find(u=>u.id===a),getUploadProgress:a=>{var u;return((u=e.find(l=>l.id===a))==null?void 0:u.progress)??0},getUploadStatus:a=>{var u;return(u=e.find(l=>l.id===a))==null?void 0:u.status},hasErrors:e.some(a=>a.status==="error"),isUploading:e.some(a=>a.status==="uploading")}}exports.WidgetProvider=kt;exports._default=$n;exports.commonjsGlobal=Qt;exports.getDefaultExportFromCjs=Zt;exports.useConfig=Yt;exports.useContact=Jt;exports.useIsAwaitingBotReply=Xt;exports.useMessages=Ze;exports.usePreludeData=Vn;exports.usePrimitiveState=ee;exports.useSessions=et;exports.useUploadFiles=Kn;exports.useWidget=K;exports.useWidgetRouter=Mn;
|
|
18
|
-
//# sourceMappingURL=
|
|
17
|
+
*/var ze;function nn(){return ze||(ze=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=_,t=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function n(R){{for(var E=arguments.length,w=new Array(E>1?E-1:0),S=1;S<E;S++)w[S-1]=arguments[S];r("error",R,w)}}function r(R,E,w){{var S=t.ReactDebugCurrentFrame,I=S.getStackAddendum();I!==""&&(E+="%s",w=w.concat([I]));var m=w.map(function(D){return String(D)});m.unshift("Warning: "+E),Function.prototype.apply.call(console[R],console,m)}}function o(R,E){return R===E&&(R!==0||1/R===1/E)||R!==R&&E!==E}var s=typeof Object.is=="function"?Object.is:o,i=e.useState,d=e.useEffect,h=e.useLayoutEffect,f=e.useDebugValue,a=!1,u=!1;function l(R,E,w){a||e.startTransition!==void 0&&(a=!0,n("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var S=E();if(!u){var I=E();s(S,I)||(n("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}var m=i({inst:{value:S,getSnapshot:E}}),D=m[0].inst,j=m[1];return h(function(){D.value=S,D.getSnapshot=E,c(D)&&j({inst:D})},[R,S,E]),d(function(){c(D)&&j({inst:D});var B=function(){c(D)&&j({inst:D})};return R(B)},[R]),f(S),S}function c(R){var E=R.getSnapshot,w=R.value;try{var S=E();return!s(w,S)}catch{return!0}}function y(R,E,w){return E()}var g=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",T=!g,p=T?y:l,k=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p;ve.useSyncExternalStore=k,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),ve}process.env.NODE_ENV==="production"?Re.exports=tn():Re.exports=nn();var rn=Re.exports;const G=()=>{},L=G(),Ee=Object,v=e=>e===L,N=e=>typeof e=="function",H=(e,t)=>({...e,...t}),on=e=>N(e.then),ue=new WeakMap;let sn=0;const oe=e=>{const t=typeof e,n=e&&e.constructor,r=n==Date;let o,s;if(Ee(e)===e&&!r&&n!=RegExp){if(o=ue.get(e),o)return o;if(o=++sn+"~",ue.set(e,o),n==Array){for(o="@",s=0;s<e.length;s++)o+=oe(e[s])+",";ue.set(e,o)}if(n==Ee){o="#";const i=Ee.keys(e).sort();for(;!v(s=i.pop());)v(e[s])||(o+=s+":"+oe(e[s])+",");ue.set(e,o)}}else o=r?e.toJSON():t=="symbol"?e.toString():t=="string"?JSON.stringify(e):""+e;return o},q=new WeakMap,Se={},ce={},Le="undefined",pe=typeof window!=Le,Ce=typeof document!=Le,an=()=>pe&&typeof window.requestAnimationFrame!=Le,rt=(e,t)=>{const n=q.get(e);return[()=>!v(t)&&e.get(t)||Se,r=>{if(!v(t)){const o=e.get(t);t in ce||(ce[t]=o),n[5](t,H(o,r),o||Se)}},n[6],()=>!v(t)&&t in ce?ce[t]:!v(t)&&e.get(t)||Se]};let Te=!0;const un=()=>Te,[De,Ae]=pe&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[G,G],cn=()=>{const e=Ce&&document.visibilityState;return v(e)||e!=="hidden"},fn=e=>(Ce&&document.addEventListener("visibilitychange",e),De("focus",e),()=>{Ce&&document.removeEventListener("visibilitychange",e),Ae("focus",e)}),ln=e=>{const t=()=>{Te=!0,e()},n=()=>{Te=!1};return De("online",t),De("offline",n),()=>{Ae("online",t),Ae("offline",n)}},dn={isOnline:un,isVisible:cn},pn={initFocus:fn,initReconnect:ln},ke=!_.useId,se=!pe||"Deno"in window,hn=e=>an()?window.requestAnimationFrame(e):setTimeout(e,1),we=se?_.useEffect:_.useLayoutEffect,me=typeof navigator<"u"&&navigator.connection,Ye=!se&&me&&(["slow-2g","2g"].includes(me.effectiveType)||me.saveData),Ie=e=>{if(N(e))try{e=e()}catch{e=""}const t=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?oe(e):"",[e,t]};let gn=0;const xe=()=>++gn,ot=0,st=1,it=2,yn=3;var re={__proto__:null,ERROR_REVALIDATE_EVENT:yn,FOCUS_EVENT:ot,MUTATE_EVENT:it,RECONNECT_EVENT:st};async function at(...e){const[t,n,r,o]=e,s=H({populateCache:!0,throwOnError:!0},typeof o=="boolean"?{revalidate:o}:o||{});let i=s.populateCache;const d=s.rollbackOnError;let h=s.optimisticData;const f=l=>typeof d=="function"?d(l):d!==!1,a=s.throwOnError;if(N(n)){const l=n,c=[],y=t.keys();for(const g of y)!/^\$(inf|sub)\$/.test(g)&&l(t.get(g)._k)&&c.push(g);return Promise.all(c.map(u))}return u(n);async function u(l){const[c]=Ie(l);if(!c)return;const[y,g]=rt(t,c),[T,p,k,R]=q.get(t),E=()=>{const M=T[c];return(N(s.revalidate)?s.revalidate(y().data,l):s.revalidate!==!1)&&(delete k[c],delete R[c],M&&M[0])?M[0](it).then(()=>y().data):y().data};if(e.length<3)return E();let w=r,S;const I=xe();p[c]=[I,0];const m=!v(h),D=y(),j=D.data,B=D._c,z=v(B)?j:B;if(m&&(h=N(h)?h(z,j):h,g({data:h,_c:z})),N(w))try{w=w(z)}catch(M){S=M}if(w&&on(w))if(w=await w.catch(M=>{S=M}),I!==p[c][0]){if(S)throw S;return w}else S&&m&&f(S)&&(i=!0,g({data:z,_c:L}));if(i&&!S)if(N(i)){const M=i(w,z);g({data:M,error:L,_c:L})}else g({data:w,error:L,_c:L});if(p[c][1]=xe(),Promise.resolve(E()).then(()=>{g({_c:L})}),S){if(a)throw S;return}return w}}const Je=(e,t)=>{for(const n in e)e[n][0]&&e[n][0](t)},_n=(e,t)=>{if(!q.has(e)){const n=H(pn,t),r={},o=at.bind(L,e);let s=G;const i={},d=(a,u)=>{const l=i[a]||[];return i[a]=l,l.push(u),()=>l.splice(l.indexOf(u),1)},h=(a,u,l)=>{e.set(a,u);const c=i[a];if(c)for(const y of c)y(u,l)},f=()=>{if(!q.has(e)&&(q.set(e,[r,{},{},{},o,h,d]),!se)){const a=n.initFocus(setTimeout.bind(L,Je.bind(L,r,ot))),u=n.initReconnect(setTimeout.bind(L,Je.bind(L,r,st)));s=()=>{a&&a(),u&&u(),q.delete(e)}}};return f(),[e,o,f,s]}return[e,q.get(e)[4]]},vn=(e,t,n,r,o)=>{const s=n.errorRetryCount,i=o.retryCount,d=~~((Math.random()+.5)*(1<<(i<8?i:8)))*n.errorRetryInterval;!v(s)&&i>s||setTimeout(r,d,o)},En=(e,t)=>oe(e)==oe(t),[ut,Sn]=_n(new Map),wn=H({onLoadingSlow:G,onSuccess:G,onError:G,onErrorRetry:vn,onDiscarded:G,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:Ye?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:Ye?5e3:3e3,compare:En,isPaused:()=>!1,cache:ut,mutate:Sn,fallback:{}},dn),mn=(e,t)=>{const n=H(e,t);if(t){const{use:r,fallback:o}=e,{use:s,fallback:i}=t;r&&s&&(n.use=r.concat(s)),o&&i&&(n.fallback=H(o,i))}return n},bn=_.createContext({}),On="$inf$",ct=pe&&window.__SWR_DEVTOOLS_USE__,Rn=ct?window.__SWR_DEVTOOLS_USE__:[],Cn=()=>{ct&&(window.__SWR_DEVTOOLS_REACT__=_)},Tn=e=>N(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],Dn=()=>H(wn,_.useContext(bn)),An=e=>(t,n,r)=>e(t,n&&((...s)=>{const[i]=Ie(t),[,,,d]=q.get(ut);if(i.startsWith(On))return n(...s);const h=d[i];return v(h)?n(...s):(delete d[i],h)}),r),xn=Rn.concat(An),Pn=e=>function(...n){const r=Dn(),[o,s,i]=Tn(n),d=mn(r,i);let h=e;const{use:f}=d,a=(f||[]).concat(xn);for(let u=a.length;u--;)h=a[u](h);return h(o,s||d.fetcher||null,d)},jn=(e,t,n)=>{const r=t[e]||(t[e]=[]);return r.push(n),()=>{const o=r.indexOf(n);o>=0&&(r[o]=r[r.length-1],r.pop())}};Cn();const Xe=_.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e)}),be={dedupe:!0},Ln=(e,t,n)=>{const{cache:r,compare:o,suspense:s,fallbackData:i,revalidateOnMount:d,revalidateIfStale:h,refreshInterval:f,refreshWhenHidden:a,refreshWhenOffline:u,keepPreviousData:l}=n,[c,y,g,T]=q.get(r),[p,k]=Ie(e),R=_.useRef(!1),E=_.useRef(!1),w=_.useRef(p),S=_.useRef(t),I=_.useRef(n),m=()=>I.current,D=()=>m().isVisible()&&m().isOnline(),[j,B,z,M]=rt(r,p),Y=_.useRef({}).current,Nt=v(i)?n.fallback[p]:i,Me=(b,O)=>{for(const x in Y){const C=x;if(C==="data"){if(!o(b[C],O[C])&&(!v(b[C])||!o(ae,O[C])))return!1}else if(O[C]!==b[C])return!1}return!0},Fe=_.useMemo(()=>{const b=!p||!t?!1:v(d)?m().isPaused()||s?!1:v(h)?!0:h:d,O=P=>{const U=H(P);return delete U._k,b?{isValidating:!0,isLoading:!0,...U}:U},x=j(),C=M(),F=O(x),Z=x===C?F:O(C);let A=F;return[()=>{const P=O(j());return Me(P,A)?(A.data=P.data,A.isLoading=P.isLoading,A.isValidating=P.isValidating,A.error=P.error,A):(A=P,P)},()=>Z]},[r,p]),J=rn.useSyncExternalStore(_.useCallback(b=>z(p,(O,x)=>{Me(x,O)||b()}),[r,p]),Fe[0],Fe[1]),Ne=!R.current,Ut=c[p]&&c[p].length>0,X=J.data,Q=v(X)?Nt:X,ie=J.error,Ue=_.useRef(Q),ae=l?v(X)?Ue.current:X:Q,We=Ut&&!v(ie)?!1:Ne&&!v(d)?d:m().isPaused()?!1:s?v(Q)?!1:h:v(Q)||h,qe=!!(p&&t&&Ne&&We),Wt=v(J.isValidating)?qe:J.isValidating,qt=v(J.isLoading)?qe:J.isLoading,ne=_.useCallback(async b=>{const O=S.current;if(!p||!O||E.current||m().isPaused())return!1;let x,C,F=!0;const Z=b||{},A=!g[p]||!Z.dedupe,P=()=>ke?!E.current&&p===w.current&&R.current:p===w.current,U={isValidating:!1,isLoading:!1},$e=()=>{B(U)},Ge=()=>{const V=g[p];V&&V[1]===C&&delete g[p]},He={isValidating:!0};v(j().data)&&(He.isLoading=!0);try{if(A&&(B(He),n.loadingTimeout&&v(j().data)&&setTimeout(()=>{F&&P()&&m().onLoadingSlow(p,n)},n.loadingTimeout),g[p]=[O(k),xe()]),[x,C]=g[p],x=await x,A&&setTimeout(Ge,n.dedupingInterval),!g[p]||g[p][1]!==C)return A&&P()&&m().onDiscarded(p),!1;U.error=L;const V=y[p];if(!v(V)&&(C<=V[0]||C<=V[1]||V[1]===0))return $e(),A&&P()&&m().onDiscarded(p),!1;const W=j().data;U.data=o(W,x)?W:x,A&&P()&&m().onSuccess(x,p,n)}catch(V){Ge();const W=m(),{shouldRetryOnError:ge}=W;W.isPaused()||(U.error=V,A&&P()&&(W.onError(V,p,W),(ge===!0||N(ge)&&ge(V))&&(!m().revalidateOnFocus||!m().revalidateOnReconnect||D())&&W.onErrorRetry(V,p,W,Bt=>{const ye=c[p];ye&&ye[0]&&ye[0](re.ERROR_REVALIDATE_EVENT,Bt)},{retryCount:(Z.retryCount||0)+1,dedupe:!0})))}return F=!1,$e(),!0},[p,r]),Be=_.useCallback((...b)=>at(r,w.current,...b),[]);if(we(()=>{S.current=t,I.current=n,v(X)||(Ue.current=X)}),we(()=>{if(!p)return;const b=ne.bind(L,be);let O=0;const C=jn(p,c,(F,Z={})=>{if(F==re.FOCUS_EVENT){const A=Date.now();m().revalidateOnFocus&&A>O&&D()&&(O=A+m().focusThrottleInterval,b())}else if(F==re.RECONNECT_EVENT)m().revalidateOnReconnect&&D()&&b();else{if(F==re.MUTATE_EVENT)return ne();if(F==re.ERROR_REVALIDATE_EVENT)return ne(Z)}});return E.current=!1,w.current=p,R.current=!0,B({_k:k}),We&&(v(Q)||se?b():hn(b)),()=>{E.current=!0,C()}},[p]),we(()=>{let b;function O(){const C=N(f)?f(j().data):f;C&&b!==-1&&(b=setTimeout(x,C))}function x(){!j().error&&(a||m().isVisible())&&(u||m().isOnline())?ne(be).then(O):O()}return O(),()=>{b&&(clearTimeout(b),b=-1)}},[f,a,u,p]),_.useDebugValue(ae),s&&v(Q)&&p){if(!ke&&se)throw new Error("Fallback data is required when using suspense in SSR.");S.current=t,I.current=n,E.current=!1;const b=T[p];if(!v(b)){const O=Be(b);Xe(O)}if(v(ie)){const O=ne(be);v(ae)||(O.status="fulfilled",O.value=!0),Xe(O)}else throw ie}return{mutate:Be,get data(){return Y.data=!0,ae},get error(){return Y.error=!0,ie},get isValidating(){return Y.isValidating=!0,Wt},get isLoading(){return Y.isLoading=!0,qt}}},In=Pn(Ln);function Vn(){const{widgetCtx:e}=K();return In([e.config.token],e.api.widgetPrelude,{revalidateOnFocus:!1})}function Mn(){const{widgetCtx:e}=K();return{routerState:ee(e.routerCtx.state),toSessionsScreen:e.routerCtx.toSessionsScreen,toChatScreen:e.routerCtx.toChatScreen}}var ft={},Pe=function(e,t){return Pe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])},Pe(e,t)};function lt(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Pe(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var le=function(){return le=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},le.apply(this,arguments)};function dt(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function pt(e,t,n,r){var o=arguments.length,s=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(e,t,n,r);else for(var d=e.length-1;d>=0;d--)(i=e[d])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s}function ht(e,t){return function(n,r){t(n,r,e)}}function gt(e,t,n,r,o,s){function i(p){if(p!==void 0&&typeof p!="function")throw new TypeError("Function expected");return p}for(var d=r.kind,h=d==="getter"?"get":d==="setter"?"set":"value",f=!t&&e?r.static?e:e.prototype:null,a=t||(f?Object.getOwnPropertyDescriptor(f,r.name):{}),u,l=!1,c=n.length-1;c>=0;c--){var y={};for(var g in r)y[g]=g==="access"?{}:r[g];for(var g in r.access)y.access[g]=r.access[g];y.addInitializer=function(p){if(l)throw new TypeError("Cannot add initializers after decoration has completed");s.push(i(p||null))};var T=(0,n[c])(d==="accessor"?{get:a.get,set:a.set}:a[h],y);if(d==="accessor"){if(T===void 0)continue;if(T===null||typeof T!="object")throw new TypeError("Object expected");(u=i(T.get))&&(a.get=u),(u=i(T.set))&&(a.set=u),(u=i(T.init))&&o.unshift(u)}else(u=i(T))&&(d==="field"?o.unshift(u):a[h]=u)}f&&Object.defineProperty(f,r.name,a),l=!0}function yt(e,t,n){for(var r=arguments.length>2,o=0;o<t.length;o++)n=r?t[o].call(e,n):t[o].call(e);return r?n:void 0}function _t(e){return typeof e=="symbol"?e:"".concat(e)}function vt(e,t,n){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:n?"".concat(n," ",t):t})}function Et(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function St(e,t,n,r){function o(s){return s instanceof n?s:new n(function(i){i(s)})}return new(n||(n=Promise))(function(s,i){function d(a){try{f(r.next(a))}catch(u){i(u)}}function h(a){try{f(r.throw(a))}catch(u){i(u)}}function f(a){a.done?s(a.value):o(a.value).then(d,h)}f((r=r.apply(e,t||[])).next())})}function wt(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,o,s,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=d(0),i.throw=d(1),i.return=d(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function d(f){return function(a){return h([f,a])}}function h(f){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,f[0]&&(n=0)),n;)try{if(r=1,o&&(s=f[0]&2?o.return:f[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,f[1])).done)return s;switch(o=0,s&&(f=[f[0]&2,s.value]),f[0]){case 0:case 1:s=f;break;case 4:return n.label++,{value:f[1],done:!1};case 5:n.label++,o=f[1],f=[0];continue;case 7:f=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(f[0]===6||f[0]===2)){n=0;continue}if(f[0]===3&&(!s||f[1]>s[0]&&f[1]<s[3])){n.label=f[1];break}if(f[0]===6&&n.label<s[1]){n.label=s[1],s=f;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(f);break}s[2]&&n.ops.pop(),n.trys.pop();continue}f=t.call(e,n)}catch(a){f=[6,a],o=0}finally{r=s=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}}var he=Object.create?function(e,t,n,r){r===void 0&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]};function mt(e,t){for(var n in e)n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n)&&he(t,e,n)}function de(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ve(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),o,s=[],i;try{for(;(t===void 0||t-- >0)&&!(o=r.next()).done;)s.push(o.value)}catch(d){i={error:d}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return s}function bt(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Ve(arguments[t]));return e}function Ot(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),o=0,t=0;t<n;t++)for(var s=arguments[t],i=0,d=s.length;i<d;i++,o++)r[o]=s[i];return r}function Rt(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}function te(e){return this instanceof te?(this.v=e,this):new te(e)}function Ct(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),o,s=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),d("next"),d("throw"),d("return",i),o[Symbol.asyncIterator]=function(){return this},o;function i(c){return function(y){return Promise.resolve(y).then(c,u)}}function d(c,y){r[c]&&(o[c]=function(g){return new Promise(function(T,p){s.push([c,g,T,p])>1||h(c,g)})},y&&(o[c]=y(o[c])))}function h(c,y){try{f(r[c](y))}catch(g){l(s[0][3],g)}}function f(c){c.value instanceof te?Promise.resolve(c.value.v).then(a,u):l(s[0][2],c)}function a(c){h("next",c)}function u(c){h("throw",c)}function l(c,y){c(y),s.shift(),s.length&&h(s[0][0],s[0][1])}}function Tt(e){var t,n;return t={},r("next"),r("throw",function(o){throw o}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(o,s){t[o]=e[o]?function(i){return(n=!n)?{value:te(e[o](i)),done:!1}:s?s(i):i}:s}}function Dt(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof de=="function"?de(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=e[s]&&function(i){return new Promise(function(d,h){i=e[s](i),o(d,h,i.done,i.value)})}}function o(s,i,d,h){Promise.resolve(h).then(function(f){s({value:f,done:d})},i)}}function At(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var Fn=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function xt(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)n!=="default"&&Object.prototype.hasOwnProperty.call(e,n)&&he(t,e,n);return Fn(t,e),t}function Pt(e){return e&&e.__esModule?e:{default:e}}function jt(e,t,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(e):r?r.value:t.get(e)}function Lt(e,t,n,r,o){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?o.call(e,n):o?o.value=n:t.set(e,n),n}function It(e,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof e=="function"?t===e:e.has(t)}function Vt(e,t,n){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var r,o;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=t[Symbol.dispose],n&&(o=r)}if(typeof r!="function")throw new TypeError("Object not disposable.");o&&(r=function(){try{o.call(this)}catch(s){return Promise.reject(s)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t}var Nn=typeof SuppressedError=="function"?SuppressedError:function(e,t,n){var r=new Error(n);return r.name="SuppressedError",r.error=e,r.suppressed=t,r};function Mt(e){function t(s){e.error=e.hasError?new Nn(s,e.error,"An error was suppressed during disposal."):s,e.hasError=!0}var n,r=0;function o(){for(;n=e.stack.pop();)try{if(!n.async&&r===1)return r=0,e.stack.push(n),Promise.resolve().then(o);if(n.dispose){var s=n.dispose.call(n.value);if(n.async)return r|=2,Promise.resolve(s).then(o,function(i){return t(i),o()})}else r|=1}catch(i){t(i)}if(r===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return o()}function Ft(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(n,r,o,s,i){return r?t?".jsx":".js":o&&(!s||!i)?n:o+s+"."+i.toLowerCase()+"js"}):e}const Un={__extends:lt,__assign:le,__rest:dt,__decorate:pt,__param:ht,__esDecorate:gt,__runInitializers:yt,__propKey:_t,__setFunctionName:vt,__metadata:Et,__awaiter:St,__generator:wt,__createBinding:he,__exportStar:mt,__values:de,__read:Ve,__spread:bt,__spreadArrays:Ot,__spreadArray:Rt,__await:te,__asyncGenerator:Ct,__asyncDelegator:Tt,__asyncValues:Dt,__makeTemplateObject:At,__importStar:xt,__importDefault:Pt,__classPrivateFieldGet:jt,__classPrivateFieldSet:Lt,__classPrivateFieldIn:It,__addDisposableResource:Vt,__disposeResources:Mt,__rewriteRelativeImportExtension:Ft},Wn=Object.freeze(Object.defineProperty({__proto__:null,__addDisposableResource:Vt,get __assign(){return le},__asyncDelegator:Tt,__asyncGenerator:Ct,__asyncValues:Dt,__await:te,__awaiter:St,__classPrivateFieldGet:jt,__classPrivateFieldIn:It,__classPrivateFieldSet:Lt,__createBinding:he,__decorate:pt,__disposeResources:Mt,__esDecorate:gt,__exportStar:mt,__extends:lt,__generator:wt,__importDefault:Pt,__importStar:xt,__makeTemplateObject:At,__metadata:Et,__param:ht,__propKey:_t,__read:Ve,__rest:dt,__rewriteRelativeImportExtension:Ft,__runInitializers:yt,__setFunctionName:vt,__spread:bt,__spreadArray:Rt,__spreadArrays:Ot,__values:de,default:Un},Symbol.toStringTag,{value:"Module"})),qn=en(Wn);var fe={},Qe;function Bn(){if(Qe)return fe;Qe=1,Object.defineProperty(fe,"__esModule",{value:!0});var e=_;function t(){var n=e.useRef(!1),r=e.useCallback(function(){return n.current},[]);return e.useEffect(function(){return n.current=!0,function(){n.current=!1}},[]),r}return fe.default=t,fe}Object.defineProperty(ft,"__esModule",{value:!0});var je=qn,Oe=_,$n=je.__importDefault(Bn());function Gn(e,t,n){t===void 0&&(t=[]),n===void 0&&(n={loading:!1});var r=Oe.useRef(0),o=$n.default(),s=Oe.useState(n),i=s[0],d=s[1],h=Oe.useCallback(function(){for(var f=[],a=0;a<arguments.length;a++)f[a]=arguments[a];var u=++r.current;return i.loading||d(function(l){return je.__assign(je.__assign({},l),{loading:!0})}),e.apply(void 0,f).then(function(l){return o()&&u===r.current&&d({value:l,loading:!1}),l},function(l){return o()&&u===r.current&&d({error:l,loading:!1}),l})},t);return[i,h]}var Hn=ft.default=Gn;const $=new Map;function Kn(){const[e,t]=_.useState([]),{widgetCtx:{api:n}}=K();function r(a){const u=a.map(l=>({file:l,id:Gt.v4(),status:"pending",progress:0}));t(l=>[...l,...u]),u.forEach(i)}function o(a,u){t(l=>l.map(c=>c.id===a?{...c,...u}:c))}function s(a){t(u=>u.filter(l=>l.id!==a))}const i=async a=>{const u=new AbortController;$.set(a.id,u);try{t(c=>c.map(y=>y.id===a.id?{...y,status:"uploading",progress:0}:y));const l=await n.uploadFile({file:a.file,abortSignal:u.signal,onProgress:c=>{o(a.id,{progress:c})}});o(a.id,{status:"success",fileUrl:l.fileUrl,progress:100})}catch(l){u.signal.aborted||o(a.id,{status:"error",error:l instanceof Error?l.message:"Upload failed",progress:0})}finally{$.delete(a.id)}},d=a=>{const u=$.get(a);u&&(u.abort(),$.delete(a)),s(a)},h=_.useMemo(()=>e.filter(a=>a.status==="success"&&a.fileUrl),[e]);function f(){$.forEach(a=>a.abort()),$.clear(),t([])}return _.useEffect(()=>()=>{$.forEach(a=>a.abort()),$.clear()},[]),{allFiles:e,appendFiles:r,handleCancelUpload:d,successFiles:h,emptyTheFiles:f,getFileById:a=>e.find(u=>u.id===a),getUploadProgress:a=>{var u;return((u=e.find(l=>l.id===a))==null?void 0:u.progress)??0},getUploadStatus:a=>{var u;return(u=e.find(l=>l.id===a))==null?void 0:u.status},hasErrors:e.some(a=>a.status==="error"),isUploading:e.some(a=>a.status==="uploading")}}const[zn,kn]=et();function Yn({children:e}){const[t,n]=_.useState(!1);return Ze.jsx(kn,{value:{isOpen:t,setIsOpen:n},children:e})}exports.WidgetProvider=kt;exports.WidgetTriggerProvider=Yn;exports._default=Hn;exports.commonjsGlobal=Qt;exports.getDefaultExportFromCjs=Zt;exports.useConfig=Yt;exports.useContact=Jt;exports.useIsAwaitingBotReply=Xt;exports.useMessages=tt;exports.usePreludeData=Vn;exports.usePrimitiveState=ee;exports.useSessions=nt;exports.useUploadFiles=Kn;exports.useWidget=K;exports.useWidgetRouter=Mn;exports.useWidgetTrigger=zn;
|
|
18
|
+
//# sourceMappingURL=useWidgetTrigger-DhYRJ5kj.cjs.map
|