;
! function() {
    try {
        var e = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof global ? global : "undefined" != typeof window ? window : "undefined" != typeof self ? self : {},
            n = (new e.Error).stack;
        n && ((e._debugIds || (e._debugIds = {}))[n] = "d5e2d1f9-9a70-efb2-bd6f-da240dae7eca")
    } catch (e) {}
}();
(globalThis.TURBOPACK || (globalThis.TURBOPACK = [])).push(["object" == typeof document ? document.currentScript : void 0, 586034, 934993, e => {
    "use strict";
    var t = e.i(221628),
        r = e.i(740594),
        i = e.i(318594),
        n = e.i(397456),
        a = e.i(606231),
        o = e.i(416340),
        s = e.i(778983),
        u = e.i(502475),
        d = e.i(999061),
        l = e.i(784521),
        c = e.i(631222),
        p = e.i(921807),
        y = e.i(835893),
        f = e.i(600326),
        m = e.i(57096),
        v = e.i(668122),
        h = e.i(99417),
        g = e.i(305457),
        b = e.i(400819),
        w = e.i(249792),
        C = e.i(606572),
        x = e.i(838900),
        E = e.i(660006),
        T = e.i(196593),
        k = e.i(53950),
        P = e.i(450091),
        _ = e.i(510954),
        S = e.i(488549),
        M = e.i(772281),
        N = e.i(30704);
    let I = e => e ? e.slice(0, 8) : "",
        O = new Map;

    function F(e) {
        return "number" == typeof e && Number.isFinite(e) ? e : 0
    }

    function D() {
        return {
            current: 0,
            pending: 0,
            optimistic: 0
        }
    }
    let R = (0, o.createContext)({});

    function A(e) {
        return !!e && "object" == typeof e && "string" == typeof e.conditionId && "number" == typeof e.outcomeIndex && "number" == typeof e.size
    }

    function L(e) {
        try {
            if (!e || "object" != typeof e) return [];
            if ("order" === e.event_type || "trade" === e.event_type || "auto_redeem" === e.event_type) return [e];
            if ("order" === e.type || "trade" === e.type || "auto_redeem" === e.type) {
                let t = e.type,
                    r = e.payload ? ? e.events ? ? e.data;
                if (Array.isArray(r)) return r.map(e => ({ ...e,
                    event_type: t
                }));
                if (r && "object" == typeof r) return [{ ...r,
                    event_type: t
                }];
                return []
            }
            if (e.payload && "object" == typeof e.payload) {
                let t = e.payload;
                if ("order" === t.type || "trade" === t.type || "auto_redeem" === t.type) {
                    let e = t.type,
                        r = t.events || t.payload || t;
                    if (Array.isArray(r)) return r.map(t => ({ ...t,
                        event_type: e
                    }));
                    if (r && "object" == typeof r) return [{ ...r,
                        event_type: e
                    }]
                }
            }
            return []
        } catch {
            return []
        }
    }
    let K = () => ({
            tradeHistory: !1,
            limitOrderHistory: !1,
            marketOrderHistory: !1
        }),
        Q = e => {
            e.current && (clearTimeout(e.current), e.current = null)
        },
        H = ({
            startedAt: e,
            quietWindowMs: t,
            maxWaitMs: r
        }) => null === e ? t : Math.min(t, Math.max(0, r - (Date.now() - e)));
    e.s(["UserWsContextProvider", 0, ({
        children: e
    }) => {
        let B = (0, i.useQueryClient)(),
            q = (() => {
                let e, t, r = (0, d.c)(5);
                r[0] === Symbol.for("react.memo_cache_sentinel") ? (e = ["proxyAddress"], r[0] = e) : e = r[0];
                let {
                    proxyAddress: i
                } = (0, l.useAccountContext)(e), n = (0, p.useTransactionStore)(), a = (void 0) ? ? c.MATIC_CONFIG.chainId;
                return r[1] !== a || r[2] !== i || r[3] !== n ? (t = e => {
                    if (!i || !a) throw Error("No address or chain ID found");
                    return n.doesTransactionExist(i, a, e)
                }, r[1] = a, r[2] = i, r[3] = n, r[4] = t) : t = r[4], t
            })(),
            j = (0, y.default)(),
            {
                userOpenOrdersMutation: U
            } = (0, N.default)(),
            {
                getApiCredential: W
            } = (0, b.useClobCredentialContext)(),
            {
                proxyAddress: z
            } = (0, l.useAccountContext)(["proxyAddress"]),
            V = (0, h.useInvalidatePositions)(),
            $ = (0, p.useTransactionStore)(),
            G = (0, g.useAmplitudeAnalytics)(),
            J = (0, w.useToast)(),
            X = (0, o.useMemo)(() => {
                if (z) return W(z)
            }, [z, W]),
            Y = (0, o.useRef)(null),
            Z = (0, o.useRef)(null),
            ee = (0, o.useRef)(null),
            et = (0, o.useRef)(null),
            er = (0, o.useRef)(null),
            ei = (0, o.useRef)(null),
            en = (0, o.useRef)(K()),
            ea = (0, o.useCallback)(() => {
                z && (Q(Y), Y.current = setTimeout(() => {
                    V(z), Y.current = null
                }, 1500))
            }, [V, z]),
            eo = (0, o.useCallback)(async () => {
                await Promise.all([B.invalidateQueries({
                    queryKey: _.queryKeys[m.QueryKey.LimitOrderHistory]._def
                }), B.invalidateQueries({
                    queryKey: _.queryKeys[m.QueryKey.MarketOrderHistory]._def
                }), B.invalidateQueries({
                    queryKey: _.queryKeys[m.QueryKey.TradeHistory]._def
                })]), k.logger.debug("[UserWsContext > refreshAllQueries]", {
                    proxyAddress: z
                })
            }, [B, z]),
            es = (0, o.useCallback)(async () => {
                ei.current = null;
                let e = en.current;
                en.current = K();
                let t = [];
                e.limitOrderHistory && t.push(B.invalidateQueries({
                    queryKey: _.queryKeys[m.QueryKey.LimitOrderHistory]._def
                })), e.marketOrderHistory && t.push(B.invalidateQueries({
                    queryKey: _.queryKeys[m.QueryKey.MarketOrderHistory]._def
                })), e.tradeHistory && t.push(B.invalidateQueries({
                    queryKey: _.queryKeys[m.QueryKey.TradeHistory]._def
                })), t.length && (await Promise.all(t), k.logger.debug("[UserWsContext > flushHistoryRefreshes]", { ...e,
                    proxyAddress: z
                }))
            }, [B, z]),
            eu = (0, o.useCallback)(e => {
                let t;
                t = en.current, en.current = {
                    tradeHistory: t.tradeHistory || !0 === e.tradeHistory,
                    limitOrderHistory: t.limitOrderHistory || !0 === e.limitOrderHistory,
                    marketOrderHistory: t.marketOrderHistory || !0 === e.marketOrderHistory
                }, Q(ei), ei.current = setTimeout(() => {
                    es()
                }, 500)
            }, [es]),
            ed = (0, o.useCallback)(() => {
                eu({
                    tradeHistory: !0
                })
            }, [eu]),
            el = (0, o.useCallback)(() => {
                Z.current = null, ee.current = null, B.invalidateQueries({
                    queryKey: _.queryKeys[m.QueryKey.Notifications].clob._def
                })
            }, [B]),
            ec = (0, o.useCallback)(() => {
                null === ee.current && (ee.current = Date.now()), Q(Z), Z.current = setTimeout(() => {
                    el()
                }, H({
                    startedAt: ee.current,
                    quietWindowMs: 350,
                    maxWaitMs: 1e3
                }))
            }, [el]),
            ep = (0, o.useCallback)(() => {
                et.current = null, er.current = null, B.refetchQueries({
                    queryKey: [_.queryKeys[m.QueryKey.OpenOrderScoring]._def]
                })
            }, [B]),
            ey = (0, o.useCallback)(() => {
                null === er.current && (er.current = Date.now()), Q(et), et.current = setTimeout(() => {
                    ep()
                }, H({
                    startedAt: er.current,
                    quietWindowMs: 350,
                    maxWaitMs: 1e3
                }))
            }, [ep]),
            {
                tradesMutation: ef
            } = (0, M.useFilledOrdersMutation)({
                onTradeHistorySettled: ed
            }),
            em = (0, o.useCallback)(() => !!X ? .key && X, [X]),
            ev = (0, o.useRef)(new Map),
            eh = (0, o.useRef)(new Map);
        (0, o.useEffect)(() => {
            ev.current = new Map, eh.current = new Map, en.current = K(), ee.current = null, er.current = null, Q(Y), Q(Z), Q(et), Q(ei), k.logger.debug("[UserWsContext > resetBurstSchedulers]", {
                proxyAddress: z
            })
        }, [z]), (0, o.useEffect)(() => () => {
            ee.current = null, er.current = null, Q(Y), Q(Z), Q(et), Q(ei)
        }, []);
        let {
            sendMessage: eg,
            readyState: eb
        } = (0, a.useWebSocket)({
            url: X ? .key ? c.WEBSOCKET_USER : null,
            onOpen: e => {
                let t = em();
                if (!1 === t) return void k.logger.debug("[UserWsContext > useWebSocket > onOpen]", {
                    e,
                    apiCred: t,
                    proxyAddress: z
                });
                let r = JSON.stringify({
                        auth: {
                            apiKey: t.key ? ? "",
                            secret: t.secret ? ? "",
                            passphrase: t.passphrase ? ? ""
                        },
                        markets: [],
                        type: "user"
                    }),
                    i = eg(r);
                eo(), k.logger.debug("[UserWsContext > useWebSocket > onOpen]", {
                    e,
                    apiCred: t,
                    payload: r,
                    b: i,
                    proxyAddress: z
                })
            },
            onMessage: e => {
                let t;
                if (e ? .data && ("string" != typeof e.data || "pong" !== e.data.toLowerCase())) {
                    try {
                        let r = JSON.parse(e.data);
                        if (t = Array.isArray(r) ? r.flatMap(e => L(e)) : L(r), 0 === t.length) return
                    } catch (e) {
                        console.error(e), (0, E.handleError)(e, "[UserWsContext > onMessage > parse]", z);
                        return
                    }
                    if (k.logger.debug("[UserWsContext > message]", {
                            length: "string" == typeof e.data ? e.data.length : 0,
                            proxyAddress: z
                        }), !X || "string" != typeof X.key || !z) return void k.logger.debug("[UserWsContext > onMessage]", {
                        message: "api credential or proxy address not initialized",
                        proxyAddress: z
                    });
                    try {
                        t.forEach(e => {
                            let t = (0, S.cleanPrice)(e),
                                i = "trade" === t.event_type ? `trade-${t.id}-${t.status}-${I(t.market)}` : "auto_redeem" === t.event_type ? `auto_redeem-${I(t.txn_hash)}-${I(t.condition_id)}` : `order-${t.id}-${t.type}-${t.timestamp}-${I(t.market)}`;
                            if (k.logger.debug("[UserWsContext > onMessage]", {
                                    wsMapKey: i,
                                    parsed: e,
                                    cleaned: t,
                                    proxyAddress: z
                                }), !ev.current.has(i)) {
                                if (ev.current.set(i, !0), ev.current.size > 1e4) {
                                    let e = ev.current.keys().next().value;
                                    e && ev.current.delete(e)
                                }
                                if ("order" === t.event_type && ("CANCELLATION" === t.type || "PLACEMENT" === t.type || "UPDATE" === t.type)) {
                                    if ("CANCELLATION" === t.type && t.id && (0, x.isFallbackOrder)(t.id)) {
                                        let e = (0, x.getFallbackOrder)(t.id);
                                        (0, x.removeFallbackOrder)(t.id), G.trackEvent(v.Events.FakFallbackOrderCancelled, {
                                            order_id: t.id,
                                            market: t.market ? ? void 0,
                                            side: e ? .side ? ? void 0,
                                            amount: e ? .amount ? ? void 0,
                                            fallback_limit_price: e ? .price ? ? void 0,
                                            fallback_limit_size: e ? .size ? ? void 0
                                        }, z), J.error(new C.ToastBuilder().title("Order failed").description(e ? .question ? ? ""))
                                    }
                                    if ("UPDATE" === t.type) {
                                        let e = window.localStorage.getItem("pm.orders.ids"),
                                            r = e ? JSON.parse(e) : [];
                                        if (!r.includes(t.id)) try {
                                            window.localStorage.setItem("pm.orders.ids", JSON.stringify([...new Set([...r, t.id])]))
                                        } catch {}
                                    }
                                    U({
                                        apiKey: X.key,
                                        order: t,
                                        invalidate: !1
                                    }), ec(), ey()
                                }
                                if ("trade" === t.event_type && t) {
                                    let e, i = (e = [], "string" == typeof t.taker_order_id && e.push(t.taker_order_id), Array.isArray(t.maker_orders) && t.maker_orders.forEach(t => {
                                            t && "string" == typeof t.order_id && e.push(t.order_id)
                                        }), [...new Set(e)]),
                                        n = new Set(i.map(e => e.toLowerCase())),
                                        a = z ? $.getTransactionCacheManager().getCachedTransactions(z, c.MATIC_CONFIG.chainId) ? .txns ? ? [] : [],
                                        o = "string" == typeof t.id ? t.id.toLowerCase() : "",
                                        d = "string" == typeof t.transaction_hash ? t.transaction_hash.toLowerCase() : "",
                                        l = a.find(e => !!(o && (e.tradeIds ? .some(e => e.toLowerCase() === o) || e.txId.toLowerCase() === o) || d && (e.tradeIds ? .some(e => e.toLowerCase() === d) || e.txId.toLowerCase() === d)) || !!(n.has(e.txId.toLowerCase()) || e.tradeIds ? .some(e => n.has(e.toLowerCase())))),
                                        p = l ? .metadata ? .enqueuedAt,
                                        y = {
                                            trade_id: t.id,
                                            order_id: t.taker_order_id,
                                            status: t.status,
                                            market: t.market,
                                            side: t.side,
                                            size: t.size,
                                            price: t.price,
                                            timestamp: t.timestamp,
                                            time_since_order: "number" == typeof p ? Date.now() - p : void 0
                                        },
                                        h = (() => {
                                            if ("MINED" !== t.status && "CONFIRMED" !== t.status) return;
                                            if ("string" == typeof t.id && t.id) return t.id.toLowerCase();
                                            if ("string" == typeof t.transaction_hash && t.transaction_hash) return t.transaction_hash.toLowerCase();
                                            let e = i[0];
                                            return "string" == typeof e && e ? e.toLowerCase() : void 0
                                        })(),
                                        g = h && z ? `${z.toLowerCase()}:${h}` : void 0,
                                        b = !!(h && eh.current.has(h)),
                                        w = !!(g && O.has(g)),
                                        E = b || w;
                                    if (h && !E) {
                                        if (eh.current.set(h, !0), eh.current.size > 1e4) {
                                            let e = eh.current.keys().next().value;
                                            e && eh.current.delete(e)
                                        }
                                        if (g && (O.set(g, !0), O.size > 4e4)) {
                                            let e = O.keys().next().value;
                                            e && O.delete(e)
                                        }
                                    }
                                    let k = () => {
                                            let e, i, n = l ? .metadata;
                                            if (!l || n ? .side !== r.Side.SELL) return;
                                            let o = l.conditionId.toLowerCase(),
                                                d = n.outcomeIndex;
                                            if (!Number.isFinite(d)) return;
                                            let c = (() => {
                                                    try {
                                                        for (let [, e] of B.getQueriesData({
                                                                predicate: e => e.queryKey[0] === m.QueryKey.Positions
                                                            }))
                                                            if (e) {
                                                                if (Array.isArray(e)) {
                                                                    let t = e.find(e => A(e) && e.conditionId.toLowerCase() === o && e.outcomeIndex === d);
                                                                    if (t && A(t)) return t
                                                                }
                                                                if ("object" == typeof e && null !== e && "pages" in e) {
                                                                    let t = e.pages;
                                                                    if (!Array.isArray(t)) continue;
                                                                    for (let e of t) {
                                                                        if (!Array.isArray(e)) continue;
                                                                        let t = e.find(e => A(e) && e.conditionId.toLowerCase() === o && e.outcomeIndex === d);
                                                                        if (t && A(t)) return t
                                                                    }
                                                                }
                                                            }
                                                        return
                                                    } catch {
                                                        return
                                                    }
                                                })(),
                                                p = c ? .size,
                                                y = Number.parseFloat(t.size),
                                                v = (e = n.positionChangeData.shareQty[d], Number.isFinite(e) ? Math.abs(e) : void 0),
                                                h = Number.isFinite(y) ? Math.abs(y) : void 0,
                                                g = "number" == typeof v ? v : "number" == typeof h ? h : void 0;
                                            if ("number" != typeof g || !Number.isFinite(g)) return;
                                            let b = "number" == typeof n.positionQtyBeforeSell && Number.isFinite(n.positionQtyBeforeSell) ? n.positionQtyBeforeSell : void 0,
                                                w = (i = "number" == typeof l.metadata ? .enqueuedAt ? l.metadata.enqueuedAt : void 0, "number" != typeof i ? 0 : a.filter(e => {
                                                    if (e.txId === l.txId || e.conditionId.toLowerCase() !== o) return !1;
                                                    let t = e.metadata ? .outcomeIndex;
                                                    if (!Number.isFinite(t) || t !== d) return !1;
                                                    let r = e.metadata ? .enqueuedAt;
                                                    return "number" == typeof r && !(r <= i)
                                                }).filter(e => e.status === f.TxnStatus.MINED || e.status === f.TxnStatus.CONFIRMED).reduce((e, t) => {
                                                    let r = t.metadata ? .positionChangeData ? .shareQty ? .[d];
                                                    return "number" == typeof r && Number.isFinite(r) ? e + r : e
                                                }, 0)),
                                                C = "number" == typeof b ? b + w : void 0,
                                                x = (() => {
                                                    if (z) try {
                                                        let e = _.queryKeys[m.QueryKey.Positions].optimistic(z).queryKey,
                                                            t = B.getQueryData(e);
                                                        if (!(t instanceof Map)) return;
                                                        let r = (0, u.makeOptimisticPositionKey)({
                                                                conditionId: o,
                                                                outcomeIndex: 0 === d ? "0" : "1"
                                                            }),
                                                            i = t.get(r),
                                                            n = i ? .position,
                                                            a = n ? .trackedPositionMetadata ? .netQuantity ? .optimistic;
                                                        if ("number" == typeof a && Number.isFinite(a)) return a;
                                                        let s = n ? .trackedPositionMetadata ? .netQuantity ? .current;
                                                        if ("number" == typeof s && Number.isFinite(s)) return s;
                                                        if (!n ? .netQuantity) return;
                                                        let l = Number.parseFloat((0, T.formatUSDCUnits)(BigInt(n.netQuantity)));
                                                        return Number.isFinite(l) ? l : void 0
                                                    } catch {
                                                        return
                                                    }
                                                })(),
                                                E = "number" == typeof C ? C - g : "number" == typeof x ? x - g : "number" == typeof p && Number.isFinite(p) ? g > p + .1 ? p : p - g : void 0,
                                                k = (() => {
                                                    if ("number" == typeof E && Number.isFinite(E)) return Math.max(0, Math.round(1e6 * E))
                                                })(),
                                                S = "number" == typeof k && k <= 1e5,
                                                M = (() => {
                                                    if (!c && z) try {
                                                        let e = _.queryKeys[m.QueryKey.Positions].optimistic(z).queryKey,
                                                            t = B.getQueryData(e);
                                                        if (!(t instanceof Map)) return;
                                                        let r = (0, u.makeOptimisticPositionKey)({
                                                                conditionId: o,
                                                                outcomeIndex: 0 === d ? "0" : "1"
                                                            }),
                                                            i = t.get(r);
                                                        return i ? .position
                                                    } catch {
                                                        return
                                                    }
                                                })();
                                            if (!S && z && "number" == typeof k && Number.isFinite(g)) {
                                                if (c) try {
                                                    let e = (0, s.formatTrackedMarketPosition)({ ...c,
                                                        size: k / 1e6
                                                    });
                                                    (0, u.updateOptimisticPositions)({
                                                        queryClient: B,
                                                        positions: [e],
                                                        proxyAddress: z,
                                                        source: "UserWsContext.handleTradeSettled.partialSell"
                                                    })
                                                } catch {} else if (M ? .trackedPositionMetadata) {
                                                    let e = M.trackedPositionMetadata,
                                                        t = F(e.netQuantity.pending) + g,
                                                        r = "number" == typeof E && Number.isFinite(E) ? Math.max(E, 0) : Math.max(F(e.netQuantity.optimistic), 0),
                                                        i = Math.max(r - t, 0),
                                                        n = (0, P.getCurrentSharePrice)(M),
                                                        a = i * n,
                                                        o = t * n,
                                                        s = a + o,
                                                        d = { ...M,
                                                            isPending: Math.abs(t) > 1e-6,
                                                            netQuantity: (0, T.parseUSDCUnits)(i.toString()).toString(),
                                                            netValue: (0, T.parseUSDCUnits)(s.toString()).toString(),
                                                            trackedPositionMetadata: { ...e,
                                                                netQuantity: {
                                                                    current: i,
                                                                    pending: t,
                                                                    optimistic: r
                                                                },
                                                                netValue: {
                                                                    current: a,
                                                                    pending: o,
                                                                    optimistic: s
                                                                }
                                                            }
                                                        };
                                                    (0, u.updateOptimisticPositions)({
                                                        queryClient: B,
                                                        positions: [d],
                                                        proxyAddress: z,
                                                        source: "UserWsContext.handleTradeSettled.partialSell.fallback"
                                                    })
                                                }
                                            }
                                            if (S && z) try {
                                                let e = _.queryKeys[m.QueryKey.Positions].optimistic(z).queryKey,
                                                    t = B.getQueryData(e);
                                                if (t instanceof Map) {
                                                    let e, r = (0, u.makeOptimisticPositionKey)({
                                                            conditionId: o,
                                                            outcomeIndex: 0 === d ? "0" : "1"
                                                        }),
                                                        i = t.get(r),
                                                        a = i ? .position,
                                                        l = a ? .trackedPositionMetadata,
                                                        p = F(l ? .quantityBought.pending),
                                                        y = F(l ? .totalQuantityBought.pending),
                                                        f = F(l ? .valueBought.pending),
                                                        m = F(l ? .totalValueBought.pending),
                                                        v = !0 === n.isDelayedOrder ? F(l ? .netQuantity.pending) : F(l ? .netQuantity.pending) + g,
                                                        h = l && a ? v * (0, P.getCurrentSharePrice)(a) : 0,
                                                        b = p > 1e-6 || y > 1e-6 || f > 1e-6 || m > 1e-6 || Math.abs(v) > 1e-6,
                                                        w = a && l && b ? { ...a,
                                                            isPending: !0,
                                                            pendingSince: a.pendingSince ? ? Date.now(),
                                                            quantityBought: "0",
                                                            netQuantity: "0",
                                                            valueBought: "0",
                                                            netValue: "0",
                                                            totalQuantityBought: "0",
                                                            totalValueBought: "0",
                                                            realizedProfit: "0",
                                                            trackedPositionMetadata: { ...l,
                                                                quantityBought: {
                                                                    current: 0,
                                                                    pending: p,
                                                                    optimistic: p
                                                                },
                                                                totalQuantityBought: {
                                                                    current: 0,
                                                                    pending: y,
                                                                    optimistic: y
                                                                },
                                                                netQuantity: {
                                                                    current: 0,
                                                                    pending: v,
                                                                    optimistic: v
                                                                },
                                                                valueBought: {
                                                                    current: 0,
                                                                    pending: f,
                                                                    optimistic: f
                                                                },
                                                                totalValueBought: {
                                                                    current: 0,
                                                                    pending: m,
                                                                    optimistic: m
                                                                },
                                                                netValue: {
                                                                    current: 0,
                                                                    pending: h,
                                                                    optimistic: h
                                                                },
                                                                realizedProfit: {
                                                                    current: F(l.realizedProfit.current),
                                                                    pending: 0,
                                                                    optimistic: F(l.realizedProfit.current)
                                                                }
                                                            }
                                                        } : (e = {
                                                            quantityBought: D(),
                                                            netQuantity: D(),
                                                            valueBought: D(),
                                                            netValue: D(),
                                                            realizedProfit: D(),
                                                            totalQuantityBought: D(),
                                                            totalValueBought: D()
                                                        }, a ? { ...a,
                                                            isPending: !1,
                                                            pendingSince: void 0,
                                                            quantityBought: "0",
                                                            netQuantity: "0",
                                                            valueBought: "0",
                                                            netValue: "0",
                                                            totalQuantityBought: "0",
                                                            totalValueBought: "0",
                                                            realizedProfit: "0",
                                                            trackedPositionMetadata: e
                                                        } : c ? { ...(0, s.formatTrackedMarketPosition)({ ...c,
                                                                size: 0
                                                            }),
                                                            trackedPositionMetadata: e
                                                        } : void 0);
                                                    w && (0, u.updateOptimisticPositions)({
                                                        queryClient: B,
                                                        positions: [w],
                                                        proxyAddress: z,
                                                        source: b ? "UserWsContext.handleTradeSettled.fullSell.preservePending" : "UserWsContext.handleTradeSettled.fullSell"
                                                    })
                                                }
                                            } catch {}
                                        },
                                        S = () => {
                                            let e = l ? .metadata;
                                            if (!l || e ? .side !== r.Side.BUY) return;
                                            let t = l.conditionId.toLowerCase(),
                                                i = e.outcomeIndex;
                                            if (!Number.isFinite(i)) return;
                                            let n = e.positionChangeData.shareQty[i],
                                                a = e.positionChangeData.shareValue[i],
                                                o = "number" == typeof n && Number.isFinite(n) ? Math.abs(n) : 0,
                                                s = "number" == typeof a && Number.isFinite(a) ? Math.abs(a) : 0;
                                            if (o && z) try {
                                                let e = _.queryKeys[m.QueryKey.Positions].optimistic(z).queryKey,
                                                    r = B.getQueryData(e);
                                                if (!(r instanceof Map)) return;
                                                let n = (0, u.makeOptimisticPositionKey)({
                                                        conditionId: t,
                                                        outcomeIndex: 0 === i ? "0" : "1"
                                                    }),
                                                    a = r.get(n),
                                                    d = a ? .position,
                                                    l = d ? .trackedPositionMetadata;
                                                if (!d || !l) return;
                                                let c = F(l.quantityBought.pending),
                                                    p = Math.min(o, c);
                                                if (p <= 0) return;
                                                let y = o > 0 ? p / o * s : 0,
                                                    f = F(l.netQuantity.current) + p,
                                                    v = F(l.netQuantity.pending) - p,
                                                    h = F(l.quantityBought.current) + p,
                                                    g = Math.max(c - p, 0),
                                                    b = F(l.totalQuantityBought.current) + p,
                                                    w = Math.max(F(l.totalQuantityBought.pending) - p, 0),
                                                    C = (0, P.getCurrentSharePrice)(d),
                                                    x = f * C,
                                                    E = v * C,
                                                    T = F(l.valueBought.current) + y,
                                                    k = g * C,
                                                    S = F(l.totalValueBought.current) + y,
                                                    M = w * C,
                                                    N = { ...d,
                                                        isPending: Math.abs(v) > 1e-6 || g > 1e-6,
                                                        trackedPositionMetadata: { ...l,
                                                            quantityBought: {
                                                                current: h,
                                                                pending: g,
                                                                optimistic: h + g
                                                            },
                                                            totalQuantityBought: {
                                                                current: b,
                                                                pending: w,
                                                                optimistic: b + w
                                                            },
                                                            netQuantity: {
                                                                current: f,
                                                                pending: v,
                                                                optimistic: f + v
                                                            },
                                                            valueBought: {
                                                                current: T,
                                                                pending: k,
                                                                optimistic: T + k
                                                            },
                                                            totalValueBought: {
                                                                current: S,
                                                                pending: M,
                                                                optimistic: S + M
                                                            },
                                                            netValue: {
                                                                current: x,
                                                                pending: E,
                                                                optimistic: x + E
                                                            }
                                                        }
                                                    };
                                                (0, u.updateOptimisticPositions)({
                                                    queryClient: B,
                                                    positions: [N],
                                                    proxyAddress: z,
                                                    source: "UserWsContext.handleTradeSettled.buy"
                                                })
                                            } catch {}
                                        };
                                    if ("MATCHED" === t.status) {
                                        G.trackEvent(v.Events.OrderStatusMatched, y, z);
                                        let e = l ? .metadata,
                                            r = l ? .type === "CLOB" && e ? .isDelayedOrder === !0,
                                            i = t.taker_order_id && (0, x.isFallbackOrder)(t.taker_order_id) ? t.taker_order_id : t.maker_orders ? .find(e => e ? .order_id && (0, x.isFallbackOrder)(e.order_id)) ? .order_id;
                                        if (i) {
                                            let e = (0, x.getFallbackOrder)(i);
                                            (0, x.removeFallbackOrder)(i);
                                            let r = t.size,
                                                n = Number.parseFloat(t.size),
                                                a = Number.isNaN(n) ? void 0 : n,
                                                o = Number.parseFloat(t.price),
                                                s = "number" != typeof a || Number.isNaN(o) ? void 0 : a * o;
                                            G.trackEvent(v.Events.FakFallbackOrderMatched, {
                                                order_id: i,
                                                trade_id: t.id,
                                                market: t.market,
                                                side: e ? .side ? ? t.side,
                                                matched_shares: a,
                                                matched_shares_raw: r,
                                                matched_price: t.price,
                                                matched_notional_usdc: s,
                                                amount: e ? .amount ? ? void 0,
                                                fallback_limit_price: e ? .price ? ? void 0,
                                                fallback_limit_size: e ? .size ? ? void 0,
                                                match_source: "websocket"
                                            }, z);
                                            let u = s ? ? e ? .amount,
                                                d = a ? ? e ? .size,
                                                l = Number.isNaN(o) ? e ? Math.round(100 * e.price) : void 0 : Math.round(100 * o),
                                                c = e ? `Buy $${"number"==typeof u&&u<1?u.toFixed(2):Math.round(u??0)} on ${e.outcome}` : "Trade filled",
                                                p = "number" == typeof d && "number" == typeof l ? `${d.toFixed(2)} shares @ ${l}\xa2` : void 0,
                                                y = new C.ToastBuilder().title(c).description(e ? .question ? ? "");
                                            p && y.subtext(p), J.success(y)
                                        }
                                        ec(), ef({
                                            proxyAddress: z,
                                            apiKey: X.key,
                                            event: t
                                        }), r && !E && (k(), S(), ea(), eo()), t.id && (r && l ? j(l.txId, { ...t.transaction_hash && {
                                                hash: t.transaction_hash
                                            },
                                            status: f.TxnStatus.MINED
                                        }, void 0, t.id) : q(t.id) && j(t.id, { ...r && t.transaction_hash && {
                                                hash: t.transaction_hash
                                            },
                                            status: r ? f.TxnStatus.MINED : f.TxnStatus.MATCHED
                                        }, void 0, t.id))
                                    } else "MINED" === t.status ? (G.trackEvent(v.Events.OrderStatusMined, y, z), E || (k(), S(), ea(), eu({
                                        tradeHistory: !0,
                                        limitOrderHistory: !0,
                                        marketOrderHistory: !0
                                    })), j(t.transaction_hash, {
                                        hash: t.transaction_hash,
                                        status: f.TxnStatus.MINED
                                    }, void 0, t.id)) : "CONFIRMED" === t.status ? (G.trackEvent(v.Events.OrderStatusConfirmed, y, z), E || (k(), S(), ea(), eu({
                                        tradeHistory: !0,
                                        limitOrderHistory: !0,
                                        marketOrderHistory: !0
                                    })), j(t.transaction_hash, {
                                        status: f.TxnStatus.CONFIRMED
                                    }, void 0, t.id)) : "FAILED" === t.status && (G.trackEvent(v.Events.OrderStatusFailed, y, z), t.id && q(t.id) && j(t.id, {
                                        status: f.TxnStatus.FAILED
                                    }, void 0, t.id), i.forEach(e => {
                                        q(e) && j(e, {
                                            status: f.TxnStatus.FAILED
                                        }, void 0, t.id)
                                    }), t.transaction_hash && q(t.transaction_hash) && j(t.transaction_hash, {
                                        status: f.TxnStatus.FAILED
                                    }, void 0, t.id), z && l ? $.handleFailedTransaction(z, c.MATIC_CONFIG.chainId, l) : z && !l && ea())
                                }
                                "auto_redeem" === t.event_type && ec()
                            }
                        })
                    } catch (e) {
                        console.error(e), (0, E.handleError)(e, "[UserWsContext > onMessage]", z)
                    }
                }
            }
        }), ew = {
            [n.ReadyState.CONNECTING]: "Connecting",
            [n.ReadyState.OPEN]: "Open",
            [n.ReadyState.CLOSING]: "Closing",
            [n.ReadyState.CLOSED]: "Closed",
            [n.ReadyState.UNINSTANTIATED]: "Uninstantiated"
        }[eb];
        (0, o.useEffect)(() => {
            let e;
            return "Open" === ew ? (e && clearInterval(e), e = setInterval(() => {
                k.logger.debug("[UserWsContext > ping]", {
                    proxyAddress: z
                }), eg("PING")
            }, 3e4)) : e && clearInterval(e), () => {
                e && clearInterval(e)
            }
        }, [ew, z, eg]);
        let eC = (0, o.useMemo)(() => ({
            userConnectionStatus: ew
        }), [ew]);
        return (0, t.jsx)(R.Provider, {
            value: eC,
            children: e
        })
    }, "useUserWsContext", 0, () => (0, o.useContext)(R)], 586034);
    var B = e.i(149285),
        q = e.i(174617),
        j = e.i(78892),
        U = e.i(508785),
        W = e.i(608652),
        z = e.i(538469),
        V = e.i(112466),
        $ = e.i(169525),
        G = e.i(600317),
        J = e.i(886449),
        X = e.i(199786),
        Y = e.i(723570),
        Z = e.i(456262),
        ee = "ToastProvider",
        [et, er, ei] = (0, U.createCollection)("Toast"),
        [en, ea] = (0, W.createContextScope)("Toast", [ei]),
        [eo, es] = en(ee),
        eu = e => {
            let {
                __scopeToast: r,
                label: i = "Notification",
                duration: n = 5e3,
                swipeDirection: a = "right",
                swipeThreshold: s = 50,
                children: u
            } = e, [d, l] = o.useState(null), [c, p] = o.useState(0), y = o.useRef(!1), f = o.useRef(!1);
            return i.trim() || console.error(`Invalid prop \`label\` supplied to \`${ee}\`. Expected non-empty \`string\`.`), (0, t.jsx)(et.Provider, {
                scope: r,
                children: (0, t.jsx)(eo, {
                    scope: r,
                    label: i,
                    duration: n,
                    swipeDirection: a,
                    swipeThreshold: s,
                    toastCount: c,
                    viewport: d,
                    onViewportChange: l,
                    onToastAdd: o.useCallback(() => p(e => e + 1), []),
                    onToastRemove: o.useCallback(() => p(e => e - 1), []),
                    isFocusedToastEscapeKeyDownRef: y,
                    isClosePausedRef: f,
                    children: u
                })
            })
        };
    eu.displayName = ee;
    var ed = "ToastViewport",
        el = ["F8"],
        ec = "toast.viewportPause",
        ep = "toast.viewportResume",
        ey = o.forwardRef((e, r) => {
            let {
                __scopeToast: i,
                hotkey: n = el,
                label: a = "Notifications ({hotkey})",
                ...s
            } = e, u = es(ed, i), d = er(i), l = o.useRef(null), c = o.useRef(null), p = o.useRef(null), y = o.useRef(null), f = (0, j.useComposedRefs)(r, y, u.onViewportChange), m = n.join("+").replace(/Key/g, "").replace(/Digit/g, ""), v = u.toastCount > 0;
            o.useEffect(() => {
                let e = e => {
                    0 !== n.length && n.every(t => e[t] || e.code === t) && y.current ? .focus()
                };
                return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e)
            }, [n]), o.useEffect(() => {
                let e = l.current,
                    t = y.current;
                if (v && e && t) {
                    let r = () => {
                            if (!u.isClosePausedRef.current) {
                                let e = new CustomEvent(ec);
                                t.dispatchEvent(e), u.isClosePausedRef.current = !0
                            }
                        },
                        i = () => {
                            if (u.isClosePausedRef.current) {
                                let e = new CustomEvent(ep);
                                t.dispatchEvent(e), u.isClosePausedRef.current = !1
                            }
                        },
                        n = t => {
                            e.contains(t.relatedTarget) || i()
                        },
                        a = () => {
                            e.contains(document.activeElement) || i()
                        };
                    return e.addEventListener("focusin", r), e.addEventListener("focusout", n), e.addEventListener("pointermove", r), e.addEventListener("pointerleave", a), window.addEventListener("blur", r), window.addEventListener("focus", i), () => {
                        e.removeEventListener("focusin", r), e.removeEventListener("focusout", n), e.removeEventListener("pointermove", r), e.removeEventListener("pointerleave", a), window.removeEventListener("blur", r), window.removeEventListener("focus", i)
                    }
                }
            }, [v, u.isClosePausedRef]);
            let h = o.useCallback(({
                tabbingDirection: e
            }) => {
                let t = d().map(t => {
                    let r = t.ref.current,
                        i = [r, ... function(e) {
                            let t = [],
                                r = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, {
                                    acceptNode: e => {
                                        let t = "INPUT" === e.tagName && "hidden" === e.type;
                                        return e.disabled || e.hidden || t ? NodeFilter.FILTER_SKIP : e.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
                                    }
                                });
                            for (; r.nextNode();) t.push(r.currentNode);
                            return t
                        }(r)];
                    return "forwards" === e ? i : i.reverse()
                });
                return ("forwards" === e ? t.reverse() : t).flat()
            }, [d]);
            return o.useEffect(() => {
                let e = y.current;
                if (e) {
                    let t = t => {
                        let r = t.altKey || t.ctrlKey || t.metaKey;
                        if ("Tab" === t.key && !r) {
                            let r = document.activeElement,
                                i = t.shiftKey;
                            if (t.target === e && i) return void c.current ? .focus();
                            let n = h({
                                    tabbingDirection: i ? "backwards" : "forwards"
                                }),
                                a = n.findIndex(e => e === r);
                            eI(n.slice(a + 1)) ? t.preventDefault() : i ? c.current ? .focus() : p.current ? .focus()
                        }
                    };
                    return e.addEventListener("keydown", t), () => e.removeEventListener("keydown", t)
                }
            }, [d, h]), (0, t.jsxs)(z.Branch, {
                ref: l,
                role: "region",
                "aria-label": a.replace("{hotkey}", m),
                tabIndex: -1,
                style: {
                    pointerEvents: v ? void 0 : "none"
                },
                children: [v && (0, t.jsx)(em, {
                    ref: c,
                    onFocusFromOutsideViewport: () => {
                        eI(h({
                            tabbingDirection: "forwards"
                        }))
                    }
                }), (0, t.jsx)(et.Slot, {
                    scope: i,
                    children: (0, t.jsx)(G.Primitive.ol, {
                        tabIndex: -1,
                        ...s,
                        ref: f
                    })
                }), v && (0, t.jsx)(em, {
                    ref: p,
                    onFocusFromOutsideViewport: () => {
                        eI(h({
                            tabbingDirection: "backwards"
                        }))
                    }
                })]
            })
        });
    ey.displayName = ed;
    var ef = "ToastFocusProxy",
        em = o.forwardRef((e, r) => {
            let {
                __scopeToast: i,
                onFocusFromOutsideViewport: n,
                ...a
            } = e, o = es(ef, i);
            return (0, t.jsx)(Z.VisuallyHidden, {
                tabIndex: 0,
                ...a,
                ref: r,
                style: {
                    position: "fixed"
                },
                onFocus: e => {
                    let t = e.relatedTarget;
                    o.viewport ? .contains(t) || n()
                }
            })
        });
    em.displayName = ef;
    var ev = "Toast",
        eh = o.forwardRef((e, r) => {
            let {
                forceMount: i,
                open: n,
                defaultOpen: a,
                onOpenChange: o,
                ...s
            } = e, [u, d] = (0, X.useControllableState)({
                prop: n,
                defaultProp: a ? ? !0,
                onChange: o,
                caller: ev
            });
            return (0, t.jsx)($.Presence, {
                present: i || u,
                children: (0, t.jsx)(ew, {
                    open: u,
                    ...s,
                    ref: r,
                    onClose: () => d(!1),
                    onPause: (0, J.useCallbackRef)(e.onPause),
                    onResume: (0, J.useCallbackRef)(e.onResume),
                    onSwipeStart: (0, q.composeEventHandlers)(e.onSwipeStart, e => {
                        e.currentTarget.setAttribute("data-swipe", "start")
                    }),
                    onSwipeMove: (0, q.composeEventHandlers)(e.onSwipeMove, e => {
                        let {
                            x: t,
                            y: r
                        } = e.detail.delta;
                        e.currentTarget.setAttribute("data-swipe", "move"), e.currentTarget.style.setProperty("--radix-toast-swipe-move-x", `${t}px`), e.currentTarget.style.setProperty("--radix-toast-swipe-move-y", `${r}px`)
                    }),
                    onSwipeCancel: (0, q.composeEventHandlers)(e.onSwipeCancel, e => {
                        e.currentTarget.setAttribute("data-swipe", "cancel"), e.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"), e.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"), e.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"), e.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")
                    }),
                    onSwipeEnd: (0, q.composeEventHandlers)(e.onSwipeEnd, e => {
                        let {
                            x: t,
                            y: r
                        } = e.detail.delta;
                        e.currentTarget.setAttribute("data-swipe", "end"), e.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"), e.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"), e.currentTarget.style.setProperty("--radix-toast-swipe-end-x", `${t}px`), e.currentTarget.style.setProperty("--radix-toast-swipe-end-y", `${r}px`), d(!1)
                    })
                })
            })
        });
    eh.displayName = ev;
    var [eg, eb] = en(ev, {
        onClose() {}
    }), ew = o.forwardRef((e, r) => {
        let {
            __scopeToast: i,
            type: n = "foreground",
            duration: a,
            open: s,
            onClose: u,
            onEscapeKeyDown: d,
            onPause: l,
            onResume: c,
            onSwipeStart: p,
            onSwipeMove: y,
            onSwipeCancel: f,
            onSwipeEnd: m,
            ...v
        } = e, h = es(ev, i), [g, b] = o.useState(null), w = (0, j.useComposedRefs)(r, e => b(e)), C = o.useRef(null), x = o.useRef(null), E = a || h.duration, T = o.useRef(0), k = o.useRef(E), P = o.useRef(0), {
            onToastAdd: _,
            onToastRemove: S
        } = h, M = (0, J.useCallbackRef)(() => {
            g ? .contains(document.activeElement) && h.viewport ? .focus(), u()
        }), N = o.useCallback(e => {
            e && e !== 1 / 0 && (window.clearTimeout(P.current), T.current = new Date().getTime(), P.current = window.setTimeout(M, e))
        }, [M]);
        o.useEffect(() => {
            let e = h.viewport;
            if (e) {
                let t = () => {
                        N(k.current), c ? .()
                    },
                    r = () => {
                        let e = new Date().getTime() - T.current;
                        k.current = k.current - e, window.clearTimeout(P.current), l ? .()
                    };
                return e.addEventListener(ec, r), e.addEventListener(ep, t), () => {
                    e.removeEventListener(ec, r), e.removeEventListener(ep, t)
                }
            }
        }, [h.viewport, E, l, c, N]), o.useEffect(() => {
            s && !h.isClosePausedRef.current && N(E)
        }, [s, E, h.isClosePausedRef, N]), o.useEffect(() => (_(), () => S()), [_, S]);
        let I = o.useMemo(() => g ? function e(t) {
            let r = [];
            return Array.from(t.childNodes).forEach(t => {
                var i;
                if (t.nodeType === t.TEXT_NODE && t.textContent && r.push(t.textContent), (i = t).nodeType === i.ELEMENT_NODE) {
                    let i = t.ariaHidden || t.hidden || "none" === t.style.display,
                        n = "" === t.dataset.radixToastAnnounceExclude;
                    if (!i)
                        if (n) {
                            let e = t.dataset.radixToastAnnounceAlt;
                            e && r.push(e)
                        } else r.push(...e(t))
                }
            }), r
        }(g) : null, [g]);
        return h.viewport ? (0, t.jsxs)(t.Fragment, {
            children: [I && (0, t.jsx)(eC, {
                __scopeToast: i,
                role: "status",
                "aria-live": "foreground" === n ? "assertive" : "polite",
                children: I
            }), (0, t.jsx)(eg, {
                scope: i,
                onClose: M,
                children: B.createPortal((0, t.jsx)(et.ItemSlot, {
                    scope: i,
                    children: (0, t.jsx)(z.Root, {
                        asChild: !0,
                        onEscapeKeyDown: (0, q.composeEventHandlers)(d, () => {
                            h.isFocusedToastEscapeKeyDownRef.current || M(), h.isFocusedToastEscapeKeyDownRef.current = !1
                        }),
                        children: (0, t.jsx)(G.Primitive.li, {
                            tabIndex: 0,
                            "data-state": s ? "open" : "closed",
                            "data-swipe-direction": h.swipeDirection,
                            ...v,
                            ref: w,
                            style: {
                                userSelect: "none",
                                touchAction: "none",
                                ...e.style
                            },
                            onKeyDown: (0, q.composeEventHandlers)(e.onKeyDown, e => {
                                "Escape" === e.key && (d ? .(e.nativeEvent), e.nativeEvent.defaultPrevented || (h.isFocusedToastEscapeKeyDownRef.current = !0, M()))
                            }),
                            onPointerDown: (0, q.composeEventHandlers)(e.onPointerDown, e => {
                                0 === e.button && (C.current = {
                                    x: e.clientX,
                                    y: e.clientY
                                })
                            }),
                            onPointerMove: (0, q.composeEventHandlers)(e.onPointerMove, e => {
                                if (!C.current) return;
                                let t = e.clientX - C.current.x,
                                    r = e.clientY - C.current.y,
                                    i = !!x.current,
                                    n = ["left", "right"].includes(h.swipeDirection),
                                    a = ["left", "up"].includes(h.swipeDirection) ? Math.min : Math.max,
                                    o = n ? a(0, t) : 0,
                                    s = n ? 0 : a(0, r),
                                    u = "touch" === e.pointerType ? 10 : 2,
                                    d = {
                                        x: o,
                                        y: s
                                    },
                                    l = {
                                        originalEvent: e,
                                        delta: d
                                    };
                                i ? (x.current = d, eM("toast.swipeMove", y, l, {
                                    discrete: !1
                                })) : eN(d, h.swipeDirection, u) ? (x.current = d, eM("toast.swipeStart", p, l, {
                                    discrete: !1
                                }), e.target.setPointerCapture(e.pointerId)) : (Math.abs(t) > u || Math.abs(r) > u) && (C.current = null)
                            }),
                            onPointerUp: (0, q.composeEventHandlers)(e.onPointerUp, e => {
                                let t = x.current,
                                    r = e.target;
                                if (r.hasPointerCapture(e.pointerId) && r.releasePointerCapture(e.pointerId), x.current = null, C.current = null, t) {
                                    let r = e.currentTarget,
                                        i = {
                                            originalEvent: e,
                                            delta: t
                                        };
                                    eN(t, h.swipeDirection, h.swipeThreshold) ? eM("toast.swipeEnd", m, i, {
                                        discrete: !0
                                    }) : eM("toast.swipeCancel", f, i, {
                                        discrete: !0
                                    }), r.addEventListener("click", e => e.preventDefault(), {
                                        once: !0
                                    })
                                }
                            })
                        })
                    })
                }), h.viewport)
            })]
        }) : null
    }), eC = e => {
        let {
            __scopeToast: r,
            children: i,
            ...n
        } = e, a = es(ev, r), [s, u] = o.useState(!1), [d, l] = o.useState(!1);
        return function(e = () => {}) {
            let t = (0, J.useCallbackRef)(e);
            (0, Y.useLayoutEffect)(() => {
                let e = 0,
                    r = 0;
                return e = window.requestAnimationFrame(() => r = window.requestAnimationFrame(t)), () => {
                    window.cancelAnimationFrame(e), window.cancelAnimationFrame(r)
                }
            }, [t])
        }(() => u(!0)), o.useEffect(() => {
            let e = window.setTimeout(() => l(!0), 1e3);
            return () => window.clearTimeout(e)
        }, []), d ? null : (0, t.jsx)(V.Portal, {
            asChild: !0,
            children: (0, t.jsx)(Z.VisuallyHidden, { ...n,
                children: s && (0, t.jsxs)(t.Fragment, {
                    children: [a.label, " ", i]
                })
            })
        })
    }, ex = o.forwardRef((e, r) => {
        let {
            __scopeToast: i,
            ...n
        } = e;
        return (0, t.jsx)(G.Primitive.div, { ...n,
            ref: r
        })
    });
    ex.displayName = "ToastTitle";
    var eE = o.forwardRef((e, r) => {
        let {
            __scopeToast: i,
            ...n
        } = e;
        return (0, t.jsx)(G.Primitive.div, { ...n,
            ref: r
        })
    });
    eE.displayName = "ToastDescription";
    var eT = "ToastAction",
        ek = o.forwardRef((e, r) => {
            let {
                altText: i,
                ...n
            } = e;
            return i.trim() ? (0, t.jsx)(eS, {
                altText: i,
                asChild: !0,
                children: (0, t.jsx)(e_, { ...n,
                    ref: r
                })
            }) : (console.error(`Invalid prop \`altText\` supplied to \`${eT}\`. Expected non-empty \`string\`.`), null)
        });
    ek.displayName = eT;
    var eP = "ToastClose",
        e_ = o.forwardRef((e, r) => {
            let {
                __scopeToast: i,
                ...n
            } = e, a = eb(eP, i);
            return (0, t.jsx)(eS, {
                asChild: !0,
                children: (0, t.jsx)(G.Primitive.button, {
                    type: "button",
                    ...n,
                    ref: r,
                    onClick: (0, q.composeEventHandlers)(e.onClick, a.onClose)
                })
            })
        });
    e_.displayName = eP;
    var eS = o.forwardRef((e, r) => {
        let {
            __scopeToast: i,
            altText: n,
            ...a
        } = e;
        return (0, t.jsx)(G.Primitive.div, {
            "data-radix-toast-announce-exclude": "",
            "data-radix-toast-announce-alt": n || void 0,
            ...a,
            ref: r
        })
    });

    function eM(e, t, r, {
        discrete: i
    }) {
        let n = r.originalEvent.currentTarget,
            a = new CustomEvent(e, {
                bubbles: !0,
                cancelable: !0,
                detail: r
            });
        t && n.addEventListener(e, t, {
            once: !0
        }), i ? (0, G.dispatchDiscreteCustomEvent)(n, a) : n.dispatchEvent(a)
    }
    var eN = (e, t, r = 0) => {
        let i = Math.abs(e.x),
            n = Math.abs(e.y),
            a = i > n;
        return "left" === t || "right" === t ? a && i > r : !a && n > r
    };

    function eI(e) {
        let t = document.activeElement;
        return e.some(e => e === t || (e.focus(), document.activeElement !== t))
    }
    e.s(["Action", 0, ek, "Close", 0, e_, "Description", 0, eE, "Provider", 0, eu, "Root", 0, eh, "Title", 0, ex, "Toast", 0, eh, "ToastAction", 0, ek, "ToastClose", 0, e_, "ToastDescription", 0, eE, "ToastProvider", 0, eu, "ToastTitle", 0, ex, "ToastViewport", 0, ey, "Viewport", 0, ey, "createToastScope", 0, ea], 406450);
    var eO = e.i(406450);
    e.s(["Toast", 0, eO], 934993)
}]);

//# debugId=d5e2d1f9-9a70-efb2-bd6f-da240dae7eca