;
! 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] = "ff59efd7-4ad8-7536-5ffa-0e794bc8fb35")
    } catch (e) {}
}();
(globalThis.TURBOPACK || (globalThis.TURBOPACK = [])).push(["object" == typeof document ? document.currentScript : void 0, 140527, 871859, 519099, 944830, 438232, 129641, e => {
    "use strict";
    var t = e.i(322467);
    let s = function(e, t, s) {
        var i = -1,
            r = e.length;
        t < 0 && (t = -t > r ? 0 : r + t), (s = s > r ? r : s) < 0 && (s += r), r = t > s ? 0 : s - t >>> 0, t >>>= 0;
        for (var o = Array(r); ++i < r;) o[i] = e[i + t];
        return o
    };
    e.s(["default", 0, s], 871859);
    let i = function(e, t, i) {
        var r = e.length;
        return i = void 0 === i ? r : i, !t && i >= r ? e : s(e, t, i)
    };
    e.s(["default", 0, i], 519099);
    var r = RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");
    let o = function(e) {
        return r.test(e)
    };
    e.s(["default", 0, o], 944830);
    var a = "\\ud800-\\udfff",
        n = "[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",
        l = "\\ud83c[\\udffb-\\udfff]",
        c = "[^" + a + "]",
        u = "(?:\\ud83c[\\udde6-\\uddff]){2}",
        d = "[\\ud800-\\udbff][\\udc00-\\udfff]",
        b = "(?:" + n + "|" + l + ")?",
        k = "[\\ufe0e\\ufe0f]?",
        p = "(?:\\u200d(?:" + [c, u, d].join("|") + ")" + k + b + ")*",
        f = RegExp(l + "(?=" + l + ")|" + ("(?:" + [c + n + "?", n, u, d, "[" + a + "]"].join("|")) + ")" + (k + b + p), "g");
    let S = function(e) {
        return o(e) ? e.match(f) || [] : e.split("")
    };
    e.s(["default", 0, S], 438232);
    let y = function(e) {
        var s = o(e = (0, t.default)(e)) ? S(e) : void 0,
            r = s ? s[0] : e.charAt(0),
            a = s ? i(s, 1).join("") : e.slice(1);
        return r.toUpperCase() + a
    };
    e.s(["default", 0, y], 129641), e.s(["capitalize", 0, function(e) {
        return y((0, t.default)(e).toLowerCase())
    }], 140527)
}, 188634, e => {
    "use strict";
    var t, s = e.i(221628),
        i = e.i(999061),
        r = e.i(184612);
    let o = e => {
        let t, o, a = (0, i.c)(6),
            {
                countryCode: n,
                className: l
            } = e;
        if (a[0] !== n) t = `https://polymarket-upload.s3.us-east-2.amazonaws.com/country-flags/${n}.png`, a[0] = n, a[1] = t;
        else t = a[1];
        let c = l || "size-5 rounded-sm object-cover";
        return a[2] !== n || a[3] !== t || a[4] !== c ? (o = (0, s.jsx)(r.default, {
            src: t,
            alt: n,
            width: 20,
            height: 20,
            className: c,
            unoptimized: !0
        }), a[2] = n, a[3] = t, a[4] = c, a[5] = o) : o = a[5], o
    };
    var a = ((t = {}).AFG = "afg", t.ALB = "alb", t.DZA = "dza", t.AND = "and", t.AGO = "ago", t.ATG = "atg", t.ARG = "arg", t.ARM = "arm", t.AUS = "aus", t.AUT = "aut", t.AZE = "aze", t.BHS = "bhs", t.BHR = "bhr", t.BGD = "bgd", t.BRB = "brb", t.BLR = "blr", t.BEL = "bel", t.BLZ = "blz", t.BEN = "ben", t.BTN = "btn", t.BOL = "bol", t.BIH = "bih", t.BWA = "bwa", t.BRA = "bra", t.BRN = "brn", t.BGR = "bgr", t.BFA = "bfa", t.BDI = "bdi", t.KHM = "khm", t.CMR = "cmr", t.CAN = "can", t.CPV = "cpv", t.CAF = "caf", t.TCD = "tcd", t.CHL = "chl", t.CHN = "chn", t.COL = "col", t.COM = "com", t.COG = "cog", t.CRI = "cri", t.HRV = "hrv", t.CUB = "cub", t.CYP = "cyp", t.CZE = "cze", t.DNK = "dnk", t.DJI = "dji", t.DMA = "dma", t.DOM = "dom", t.ECU = "ecu", t.EGY = "egy", t.SLV = "slv", t.GBR = "gbr", t.GNQ = "gnq", t.ERI = "eri", t.EST = "est", t.SWZ = "swz", t.ETH = "eth", t.FJI = "fji", t.FIN = "fin", t.FRA = "fra", t.GAB = "gab", t.GMB = "gmb", t.GEO = "geo", t.DEU = "deu", t.GHA = "gha", t.GRC = "grc", t.GRD = "grd", t.GTM = "gtm", t.HKG = "hkg", t.GIN = "gin", t.GNB = "gnb", t.GUY = "guy", t.HTI = "hti", t.HND = "hnd", t.HUN = "hun", t.ISL = "isl", t.IND = "ind", t.IDN = "idn", t.IRN = "irn", t.IRQ = "irq", t.IRL = "irl", t.ISR = "isr", t.ITA = "ita", t.JAM = "jam", t.JPN = "jpn", t.JOR = "jor", t.KAZ = "kaz", t.KEN = "ken", t.KIR = "kir", t.KWT = "kwt", t.KGZ = "kgz", t.LAO = "lao", t.LVA = "lva", t.LBN = "lbn", t.LSO = "lso", t.LBR = "lbr", t.LBY = "lby", t.LIE = "lie", t.LTU = "ltu", t.LUX = "lux", t.MDG = "mdg", t.MWI = "mwi", t.MYS = "mys", t.MDV = "mdv", t.MLI = "mli", t.MLT = "mlt", t.MHL = "mhl", t.MRT = "mrt", t.MUS = "mus", t.MEX = "mex", t.FSM = "fsm", t.MDA = "mda", t.MCO = "mco", t.MNG = "mng", t.MNE = "mne", t.MAR = "mar", t.MOZ = "moz", t.MMR = "mmr", t.NAM = "nam", t.NRU = "nru", t.NPL = "npl", t.NLD = "nld", t.NZL = "nzl", t.NIC = "nic", t.NER = "ner", t.NGA = "nga", t.PRK = "prk", t.MKD = "mkd", t.NOR = "nor", t.OMN = "omn", t.PAK = "pak", t.PLW = "plw", t.PAN = "pan", t.PNG = "png", t.PRY = "pry", t.PER = "per", t.PHL = "phl", t.POL = "pol", t.PRT = "prt", t.QAT = "qat", t.ROU = "rou", t.RUS = "rus", t.RWA = "rwa", t.KNA = "kna", t.LCA = "lca", t.VCT = "vct", t.WSM = "wsm", t.SMR = "smr", t.STP = "stp", t.SAU = "sau", t.SEN = "sen", t.SRB = "srb", t.SYC = "syc", t.SLE = "sle", t.SGP = "sgp", t.SVK = "svk", t.SVN = "svn", t.SLB = "slb", t.SOM = "som", t.ZAF = "zaf", t.KOR = "kor", t.SSD = "ssd", t.ESP = "esp", t.LKA = "lka", t.SDN = "sdn", t.SUR = "sur", t.SWE = "swe", t.CHE = "che", t.SYR = "syr", t.TWN = "twn", t.TJK = "tjk", t.TZA = "tza", t.THA = "tha", t.TGO = "tgo", t.TON = "ton", t.TTO = "tto", t.TUN = "tun", t.TUR = "tur", t.TKM = "tkm", t.TUV = "tuv", t.UGA = "uga", t.UKR = "ukr", t.ARE = "are", t.USA = "usa", t.URY = "ury", t.UZB = "uzb", t.VUT = "vut", t.VEN = "ven", t.VNM = "vnm", t.WST = "wst", t.YEM = "yem", t.ZMB = "zmb", t.ZWE = "zwe", t.UN = "un", t);
    let n = {
        AF: "afg",
        AL: "alb",
        DZ: "dza",
        AD: "and",
        AO: "ago",
        AG: "atg",
        AR: "arg",
        AM: "arm",
        AU: "aus",
        AT: "aut",
        AZ: "aze",
        BS: "bhs",
        BH: "bhr",
        BD: "bgd",
        BB: "brb",
        BY: "blr",
        BE: "bel",
        BZ: "blz",
        BJ: "ben",
        BT: "btn",
        BO: "bol",
        BA: "bih",
        BW: "bwa",
        BR: "bra",
        BN: "brn",
        BG: "bgr",
        BF: "bfa",
        BI: "bdi",
        KH: "khm",
        CM: "cmr",
        CA: "can",
        CV: "cpv",
        CF: "caf",
        TD: "tcd",
        CL: "chl",
        CN: "chn",
        CO: "col",
        KM: "com",
        CG: "cog",
        CR: "cri",
        HR: "hrv",
        CU: "cub",
        CY: "cyp",
        CZ: "cze",
        DK: "dnk",
        DJ: "dji",
        DM: "dma",
        DO: "dom",
        EC: "ecu",
        EG: "egy",
        SV: "slv",
        GB: "gbr",
        GQ: "gnq",
        ER: "eri",
        EE: "est",
        SZ: "swz",
        ET: "eth",
        FJ: "fji",
        FI: "fin",
        FR: "fra",
        GA: "gab",
        GM: "gmb",
        GE: "geo",
        DE: "deu",
        GH: "gha",
        GR: "grc",
        GD: "grd",
        GT: "gtm",
        HK: "hkg",
        GN: "gin",
        GW: "gnb",
        GY: "guy",
        HT: "hti",
        HN: "hnd",
        HU: "hun",
        IS: "isl",
        IN: "ind",
        ID: "idn",
        IR: "irn",
        IQ: "irq",
        IE: "irl",
        IL: "isr",
        IT: "ita",
        JM: "jam",
        JP: "jpn",
        JO: "jor",
        KZ: "kaz",
        KE: "ken",
        KI: "kir",
        KW: "kwt",
        KG: "kgz",
        LA: "lao",
        LV: "lva",
        LB: "lbn",
        LS: "lso",
        LR: "lbr",
        LY: "lby",
        LI: "lie",
        LT: "ltu",
        LU: "lux",
        MG: "mdg",
        MW: "mwi",
        MY: "mys",
        MV: "mdv",
        ML: "mli",
        MT: "mlt",
        MH: "mhl",
        MR: "mrt",
        MU: "mus",
        MX: "mex",
        FM: "fsm",
        MD: "mda",
        MC: "mco",
        MN: "mng",
        ME: "mne",
        MA: "mar",
        MZ: "moz",
        MM: "mmr",
        NA: "nam",
        NR: "nru",
        NP: "npl",
        NL: "nld",
        NZ: "nzl",
        NI: "nic",
        NE: "ner",
        NG: "nga",
        KP: "prk",
        MK: "mkd",
        NO: "nor",
        OM: "omn",
        PK: "pak",
        PW: "plw",
        PA: "pan",
        PG: "png",
        PY: "pry",
        PE: "per",
        PH: "phl",
        PL: "pol",
        PT: "prt",
        QA: "qat",
        RO: "rou",
        RU: "rus",
        RW: "rwa",
        KN: "kna",
        LC: "lca",
        VC: "vct",
        WS: "wsm",
        SM: "smr",
        ST: "stp",
        SA: "sau",
        SN: "sen",
        RS: "srb",
        SC: "syc",
        SL: "sle",
        SG: "sgp",
        SK: "svk",
        SI: "svn",
        SB: "slb",
        SO: "som",
        ZA: "zaf",
        KR: "kor",
        SS: "ssd",
        ES: "esp",
        LK: "lka",
        SD: "sdn",
        SR: "sur",
        SE: "swe",
        CH: "che",
        SY: "syr",
        TW: "twn",
        TJ: "tjk",
        TZ: "tza",
        TH: "tha",
        TG: "tgo",
        TO: "ton",
        TT: "tto",
        TN: "tun",
        TR: "tur",
        TM: "tkm",
        TV: "tuv",
        UG: "uga",
        UA: "ukr",
        AE: "are",
        US: "usa",
        UY: "ury",
        UZ: "uzb",
        VU: "vut",
        VE: "ven",
        VN: "vnm",
        YE: "yem",
        ZM: "zmb",
        ZW: "zwe"
    };
    e.s(["CountryCode", () => a, "Flag", 0, e => t => (0, s.jsx)(o, {
        countryCode: e,
        ...t
    }), "FlagIcon", 0, o, "getCountryCodeFromIso2", 0, e => e ? n[e.toUpperCase()] : void 0])
}, 966413, (e, t, s) => {
    "use strict";
    var i = e.r(416340),
        r = "function" == typeof Object.is ? Object.is : function(e, t) {
            return e === t && (0 !== e || 1 / e == 1 / t) || e != e && t != t
        },
        o = i.useState,
        a = i.useEffect,
        n = i.useLayoutEffect,
        l = i.useDebugValue;

    function c(e) {
        var t = e.getSnapshot;
        e = e.value;
        try {
            var s = t();
            return !r(e, s)
        } catch (e) {
            return !0
        }
    }
    var u = "u" < typeof window || void 0 === window.document || void 0 === window.document.createElement ? function(e, t) {
        return t()
    } : function(e, t) {
        var s = t(),
            i = o({
                inst: {
                    value: s,
                    getSnapshot: t
                }
            }),
            r = i[0].inst,
            u = i[1];
        return n(function() {
            r.value = s, r.getSnapshot = t, c(r) && u({
                inst: r
            })
        }, [e, s, t]), a(function() {
            return c(r) && u({
                inst: r
            }), e(function() {
                c(r) && u({
                    inst: r
                })
            })
        }, [e]), l(s), s
    };
    s.useSyncExternalStore = void 0 !== i.useSyncExternalStore ? i.useSyncExternalStore : u
}, 999977, (e, t, s) => {
    "use strict";
    t.exports = e.r(966413)
}, 439952, (e, t, s) => {
    "use strict";
    var i = e.r(416340),
        r = e.r(999977),
        o = "function" == typeof Object.is ? Object.is : function(e, t) {
            return e === t && (0 !== e || 1 / e == 1 / t) || e != e && t != t
        },
        a = r.useSyncExternalStore,
        n = i.useRef,
        l = i.useEffect,
        c = i.useMemo,
        u = i.useDebugValue;
    s.useSyncExternalStoreWithSelector = function(e, t, s, i, r) {
        var d = n(null);
        if (null === d.current) {
            var b = {
                hasValue: !1,
                value: null
            };
            d.current = b
        } else b = d.current;
        var k = a(e, (d = c(function() {
            function e(e) {
                if (!l) {
                    if (l = !0, a = e, e = i(e), void 0 !== r && b.hasValue) {
                        var t = b.value;
                        if (r(t, e)) return n = t
                    }
                    return n = e
                }
                if (t = n, o(a, e)) return t;
                var s = i(e);
                return void 0 !== r && r(t, s) ? (a = e, t) : (a = e, n = s)
            }
            var a, n, l = !1,
                c = void 0 === s ? null : s;
            return [function() {
                return e(t())
            }, null === c ? void 0 : function() {
                return e(c())
            }]
        }, [t, s, i, r]))[0], d[1]);
        return l(function() {
            b.hasValue = !0, b.value = k
        }, [k]), u(k), k
    }
}, 670907, (e, t, s) => {
    "use strict";
    t.exports = e.r(439952)
}, 575339, e => {
    "use strict";
    var t = e.i(416340),
        s = e.i(670907),
        i = e.i(26328);
    let {
        useSyncExternalStoreWithSelector: r
    } = s.default, o = e => e;

    function a(e, s = o, i) {
        let n = r(e.subscribe, e.getState, e.getInitialState, s, i);
        return t.default.useDebugValue(n), n
    }
    let n = (e, t) => {
        let s = (0, i.createStore)(e),
            r = (e, i = t) => a(s, e, i);
        return Object.assign(r, s), r
    };
    e.s(["createWithEqualityFn", 0, (e, t) => e ? n(e, t) : n, "useStoreWithEqualityFn", 0, a])
}, 233522, e => {
    "use strict";
    let t = (e, t) => {
        let s = e instanceof Map ? e : new Map(e.entries()),
            i = t instanceof Map ? t : new Map(t.entries());
        if (s.size !== i.size) return !1;
        for (let [e, t] of s)
            if (!i.has(e) || !Object.is(t, i.get(e))) return !1;
        return !0
    };
    e.s(["shallow", 0, function(e, s) {
        if (Object.is(e, s)) return !0;
        if ("object" != typeof e || null === e || "object" != typeof s || null === s || Object.getPrototypeOf(e) !== Object.getPrototypeOf(s)) return !1;
        if (Symbol.iterator in e && Symbol.iterator in s) {
            if ("entries" in e && "entries" in s) return t(e, s);
            let i = e[Symbol.iterator](),
                r = s[Symbol.iterator](),
                o = i.next(),
                a = r.next();
            for (; !o.done && !a.done;) {
                if (!Object.is(o.value, a.value)) return !1;
                o = i.next(), a = r.next()
            }
            return !!o.done && !!a.done
        }
        return t({
            entries: () => Object.entries(e)
        }, {
            entries: () => Object.entries(s)
        })
    }])
}, 567692, 239768, e => {
    "use strict";
    var t = e.i(221628),
        s = e.i(999061),
        i = e.i(416340),
        r = e.i(575339),
        o = e.i(322324),
        a = e.i(165974),
        n = e.i(429694),
        l = e.i(455872),
        c = Object.prototype.hasOwnProperty;

    function u(e, t, s) {
        for (s of e.keys())
            if (d(s, t)) return s
    }

    function d(e, t) {
        var s, i, r;
        if (e === t) return !0;
        if (e && t && (s = e.constructor) === t.constructor) {
            if (s === Date) return e.getTime() === t.getTime();
            if (s === RegExp) return e.toString() === t.toString();
            if (s === Array) {
                if ((i = e.length) === t.length)
                    for (; i-- && d(e[i], t[i]););
                return -1 === i
            }
            if (s === Set) {
                if (e.size !== t.size) return !1;
                for (i of e)
                    if ((r = i) && "object" == typeof r && !(r = u(t, r)) || !t.has(r)) return !1;
                return !0
            }
            if (s === Map) {
                if (e.size !== t.size) return !1;
                for (i of e)
                    if ((r = i[0]) && "object" == typeof r && !(r = u(t, r)) || !d(i[1], t.get(r))) return !1;
                return !0
            }
            if (s === ArrayBuffer) e = new Uint8Array(e), t = new Uint8Array(t);
            else if (s === DataView) {
                if ((i = e.byteLength) === t.byteLength)
                    for (; i-- && e.getInt8(i) === t.getInt8(i););
                return -1 === i
            }
            if (ArrayBuffer.isView(e)) {
                if ((i = e.byteLength) === t.byteLength)
                    for (; i-- && e[i] === t[i];);
                return -1 === i
            }
            if (!s || "object" == typeof e) {
                for (s in i = 0, e)
                    if (c.call(e, s) && ++i && !c.call(t, s) || !(s in t) || !d(e[s], t[s])) return !1;
                return Object.keys(t).length === i
            }
        }
        return e != e && t != t
    }
    e.s(["dequal", 0, d], 239768);
    let b = (e, t, s, i) => {
            if (s < i) return (0, n.getBucketForPrice)(e, t, s, i);
            let r = (0, l.getPrecisionFromTickSize)(i);
            return parseFloat(e).toFixed(r)
        },
        k = ({
            state: e,
            assetId: t,
            view: s,
            book: i,
            side: r,
            event: o
        }) => {
            let a = e.byAsset[t] ? .views[s] ? .[i][r] ? .rows;
            if (!a) return;
            let n = "asks" === r ? "sell" : "buy",
                l = "zero" === i ? n : "sell" === n ? "buy" : "sell",
                c = o.changed.filter(e => e.side === l).map(s => {
                    if ("zero" === i) {
                        let i = b(s.price, "asks" === r ? "ask" : "bid", e.byAsset[t].tickSizes.market, e.byAsset[t].tickSizes.active);
                        return { ...s,
                            side: "sell" === s.side ? "buy" : "sell",
                            price: i
                        }
                    }
                    let o = b(`${1-parseFloat(s.price)}`, "asks" === r ? "ask" : "bid", e.byAsset[t].tickSizes.market, e.byAsset[t].tickSizes.active);
                    return { ...s,
                        side: "sell" === s.side ? "buy" : "sell",
                        price: o
                    }
                }),
                u = new Map(a.map(e => [e.price, e]));
            c.forEach(e => {
                let t = u.get(e.price),
                    s = t ? .includedLevels ? ? [];
                if (t) {
                    if (0 === e.size) {
                        let t = a.findIndex(t => t.price === e.price); - 1 !== t && a.splice(t, 1)
                    } else t.size = e.size, t.value = e.size * parseFloat(e.price);
                    return
                }
                if (0 === e.size) return;
                let i = (() => {
                    let t = parseFloat(String(e.price));
                    if ("asks" === r) {
                        for (let e = 0; e < a.length; e++)
                            if (parseFloat(a[e].price) > t) return e;
                        return a.length
                    }
                    for (let e = 0; e < a.length; e++)
                        if (parseFloat(a[e].price) < t) return e;
                    return a.length
                })();
                a.splice(i, 0, {
                    price: e.price,
                    size: e.size,
                    value: parseFloat(e.price) * e.size,
                    netSize: 0,
                    netValue: 0,
                    includedLevels: s
                })
            });
            let d = 0,
                k = 0;
            for (let e = 0; e < a.length; e++) d += a[e].size, k += a[e].value, a[e].netSize = d, a[e].netValue = k;
            let p = e.byAsset[t].views[s][i][r];
            p.totalSize = d, p.totalValue = k, p.hasLiquidity = a.length > 0, p.bestPrice = a[0] ? .price
        },
        p = ({
            curr: e,
            next: t,
            side: s
        }) => {
            d(e[s].rows, t[s].rows) || (e[s].rows = t[s].rows), e[s].bestPrice !== t[s].bestPrice && (e[s].bestPrice = t[s].bestPrice), e[s].hasLiquidity !== t[s].hasLiquidity && (e[s].hasLiquidity = t[s].hasLiquidity), e[s].totalSize !== t[s].totalSize && (e[s].totalSize = t[s].totalSize), e[s].totalValue !== t[s].totalValue && (e[s].totalValue = t[s].totalValue), e.midpoint !== t.midpoint && (e.midpoint = t.midpoint), e.spread !== t.spread && (e.spread = t.spread)
        },
        f = ({
            state: e,
            assetId: t,
            tickSize: s,
            origin: i
        }) => {
            "user" === i ? (({
                state: e,
                assetId: t,
                tickSize: s
            }) => {
                if (e.byAsset[t]) {
                    if (s > e.byAsset[t].tickSizes.market) {
                        e.byAsset[t].tickSizes.user = s, e.byAsset[t].tickSizes.active = s;
                        return
                    }
                    e.byAsset[t].tickSizes.user = void 0, e.byAsset[t].tickSizes.active = e.byAsset[t].tickSizes.market
                }
            })({
                state: e,
                assetId: t,
                tickSize: s
            }) : "market" === i && (({
                state: e,
                assetId: t,
                tickSize: s
            }) => {
                e.byAsset[t] || (e.byAsset[t] = {
                    views: {},
                    tickSizes: {
                        market: s,
                        active: s
                    },
                    fetchStatus: {
                        book: "idle",
                        lastPrice: "idle"
                    },
                    lastUpdatedAt: Date.now()
                }), e.byAsset[t].tickSizes.market = s;
                let i = e.byAsset[t].tickSizes.user,
                    r = e.byAsset[t].tickSizes.active;
                if (!i) {
                    e.byAsset[t].tickSizes.active = s;
                    return
                }
                i < s && (e.byAsset[t].tickSizes.user = void 0), r < s && (e.byAsset[t].tickSizes.active = s)
            })({
                state: e,
                assetId: t,
                tickSize: s
            })
        },
        S = ({
            state: e,
            assetId: t,
            snapshot: s,
            type: i,
            updateTickSize: r = !0
        }) => {
            let o = String(s.tickSize);
            e.byAsset[t] || (e.byAsset[t] = {
                views: {},
                tickSizes: {
                    market: s.tickSize,
                    active: s.tickSize
                },
                fetchStatus: {
                    book: "idle",
                    lastPrice: "idle"
                },
                lastUpdatedAt: Date.now()
            }), e.byAsset[t].views || (e.byAsset[t].views = {}), r && f({
                state: e,
                assetId: t,
                tickSize: s.tickSize,
                origin: "market"
            });
            let a = e.byAsset[t].views[o];
            if (!a) {
                if (e.byAsset[t].views[o] = s, "minified" === i) {
                    let s = e.byAsset[t].views[o];
                    s.minimized = !0, s.minimizedAt = Date.now()
                }
                return
            }
            p({
                curr: a.zero,
                next: s.zero,
                side: "asks"
            }), p({
                curr: a.zero,
                next: s.zero,
                side: "bids"
            }), p({
                curr: a.one,
                next: s.one,
                side: "asks"
            }), p({
                curr: a.one,
                next: s.one,
                side: "bids"
            }), "minified" === i ? (a.minimized = !0, a.minimizedAt = Date.now()) : (a.minimized = !1, a.minimizedAt = void 0), ((e, t) => {
                let s = t["~zero"];
                if (s) {
                    let t = e["~zero"];
                    t && t.buy === s.buy && t.sell === s.sell || (e["~zero"] = {
                        buy: s.buy,
                        sell: s.sell
                    })
                }
                let i = t["~one"];
                if (i) {
                    let t = e["~one"];
                    t && t.buy === i.buy && t.sell === i.sell || (e["~one"] = {
                        buy: i.buy,
                        sell: i.sell
                    })
                }
            })(a.bestPrices, s.bestPrices), a.ts !== s.ts && (a.ts = s.ts)
        },
        y = ({
            state: e,
            assetId: t,
            event: s
        }) => {
            let i = String(s.tickSize);
            !e.byAsset[t] || e.byAsset[t].views[i] && (k({
                state: e,
                assetId: t,
                view: i,
                side: "asks",
                book: "zero",
                event: s
            }), k({
                state: e,
                assetId: t,
                view: i,
                side: "bids",
                book: "zero",
                event: s
            }), k({
                state: e,
                assetId: t,
                view: i,
                side: "asks",
                book: "one",
                event: s
            }), k({
                state: e,
                assetId: t,
                view: i,
                side: "bids",
                book: "one",
                event: s
            }), (({
                state: e,
                assetId: t,
                view: s,
                bests: i
            }) => {
                let r = e.byAsset[t].views[s];
                i && (i.bestAskZero && (r.zero.asks.bestPrice = i.bestAskZero), i.bestBidZero && (r.zero.bids.bestPrice = i.bestBidZero), i.bestAskOne && (r.one.asks.bestPrice = i.bestAskOne), i.bestBidOne && (r.one.bids.bestPrice = i.bestBidOne));
                let o = r.zero.asks.bestPrice ? ? r.zero.asks.rows[0] ? .price,
                    a = r.zero.bids.bestPrice ? ? r.zero.bids.rows[0] ? .price,
                    n = r.one.asks.bestPrice ? ? r.one.asks.rows[0] ? .price,
                    l = r.one.bids.bestPrice ? ? r.one.bids.rows[0] ? .price;
                r.bestPrices = {
                    "~zero": {
                        buy: o ? ? "0",
                        sell: a ? ? "0"
                    },
                    "~one": {
                        buy: n ? ? "0",
                        sell: l ? ? "0"
                    }
                }
            })({
                state: e,
                assetId: t,
                view: i,
                bests: {
                    bestAskZero: s.bestAskZero,
                    bestBidZero: s.bestBidZero,
                    bestAskOne: s.bestAskOne,
                    bestBidOne: s.bestBidOne
                }
            }), "number" == typeof s.spreadZero && (e.byAsset[t].views[i].zero.spread = s.spreadZero), "number" == typeof s.spreadOne && (e.byAsset[t].views[i].one.spread = s.spreadOne))
        },
        m = ({
            state: e,
            assetId: t,
            event: s
        }) => {
            if (s.snapshot) {
                S({
                    state: e,
                    assetId: t,
                    snapshot: s.snapshot,
                    type: "snapshot",
                    updateTickSize: !1
                }), f({
                    state: e,
                    assetId: t,
                    tickSize: s.newTickSize,
                    origin: s.origin
                });
                return
            }
            e.byAsset[t] || (e.byAsset[t] = {
                views: {},
                tickSizes: {
                    market: s.newTickSize,
                    active: s.newTickSize
                },
                fetchStatus: {
                    book: "idle",
                    lastPrice: "idle"
                },
                lastUpdatedAt: Date.now()
            }), f({
                state: e,
                assetId: t,
                tickSize: s.newTickSize,
                origin: s.origin
            })
        },
        v = ({
            state: e,
            assetId: t,
            last: s
        }) => {
            e.byAsset[t] || (e.byAsset[t] = {
                views: {},
                tickSizes: {
                    market: s.tickSize,
                    active: s.tickSize
                },
                fetchStatus: {
                    book: "idle",
                    lastPrice: "idle"
                },
                lastUpdatedAt: Date.now()
            }), e.byAsset[t].lastPrice = s
        },
        A = i.default.createContext({}),
        g = () => {
            let e = i.default.useContext(A);
            if (!e) throw Error("useBoundBooksStore must be used within a BooksStoreProvider");
            return e
        };
    e.s(["BooksStoreProvider", 0, e => {
        let r, n, l = (0, s.c)(5),
            {
                children: c,
                initialState: u
            } = e;
        l[0] !== u ? (r = () => (0, o.create)()((0, a.immer)((e, t) => ({
            byAsset: u ? .byAsset ? ? {},
            fetchStatus: u ? .fetchStatus ? ? {},
            connectionStatus: u ? .connectionStatus ? ? {},
            initializedBookAssetTimestamps: u ? .initializedBookAssetTimestamps ? ? {},
            initializedBookEventTimestamps: u ? .initializedBookEventTimestamps ? ? {},
            initializedLastPriceAssetTimestamps: u ? .initializedLastPriceAssetTimestamps ? ? {},
            initializedLastPriceEventTimestamps: u ? .initializedLastPriceEventTimestamps ? ? {},
            applySnapshot: (t, s, i) => {
                e(e => {
                    S({
                        state: e,
                        assetId: t,
                        snapshot: s,
                        type: i
                    })
                })
            },
            applyDelta: (t, s) => {
                e(e => {
                    y({
                        state: e,
                        assetId: t,
                        event: s
                    })
                })
            },
            applyTickSizeChange: (t, s) => {
                e(e => {
                    m({
                        state: e,
                        assetId: t,
                        event: s
                    })
                })
            },
            applyLastPriceChange: (t, s) => {
                e(e => {
                    v({
                        state: e,
                        assetId: t,
                        last: s
                    })
                })
            },
            applyEvents: t => {
                e(e => {
                    t.forEach(t => {
                        "snapshot" === t.type ? (S({
                            state: e,
                            assetId: t.assetId,
                            snapshot: t.data,
                            type: t.type
                        }), e.connectionStatus[t.assetId] = "connected", e.byAsset[t.assetId].lastUpdatedAt = Date.now()) : "delta" === t.type ? (y({
                            state: e,
                            assetId: t.assetId,
                            event: t
                        }), e.byAsset[t.assetId].lastUpdatedAt = Date.now()) : "tick-size-change" === t.type ? (m({
                            state: e,
                            assetId: t.assetId,
                            event: t
                        }), e.byAsset[t.assetId].lastUpdatedAt = Date.now()) : "last-trade-price" === t.type ? (v({
                            state: e,
                            assetId: t.assetId,
                            last: t
                        }), e.byAsset[t.assetId].lastUpdatedAt = Date.now()) : "minified" === t.type && (S({
                            state: e,
                            assetId: t.assetId,
                            snapshot: t.data,
                            type: t.type
                        }), e.byAsset[t.assetId].lastUpdatedAt = Date.now())
                    })
                })
            },
            applyFetchStatusChanges: t => {
                e(e => {
                    t.forEach(t => {
                        e.fetchStatus[t.assetId] || (e.fetchStatus[t.assetId] = {
                            book: "idle",
                            lastPrice: "idle",
                            polling: !1
                        }), e.fetchStatus[t.assetId].book = t.book, e.fetchStatus[t.assetId].lastPrice = t.lastPrice, e.fetchStatus[t.assetId].polling = t.polling
                    })
                })
            },
            applyConnectionStatusChanges: t => {
                e(e => {
                    t.forEach(t => {
                        e.connectionStatus[t.assetId] = t.status
                    })
                })
            },
            ensureView: (t, s) => {
                e(e => {
                    e.byAsset[t] || (e.byAsset[t] = {
                        views: {},
                        tickSizes: {
                            market: s,
                            active: s
                        },
                        fetchStatus: {
                            book: "idle",
                            lastPrice: "idle"
                        },
                        lastUpdatedAt: Date.now()
                    })
                })
            },
            setUserTickSize: (t, s) => {
                e(e => {
                    e.byAsset[t] && (e.byAsset[t].tickSizes.user = s, e.byAsset[t].tickSizes.active = s ? ? e.byAsset[t].tickSizes.market)
                })
            },
            getBestPrices: e => {
                let s = t().byAsset[e];
                if (!s) return;
                let i = s.views[String(s.tickSizes.active)];
                return i ? .bestPrices
            },
            garbageCollect: ({
                purge: t,
                keep: s,
                maxAgeMs: i = 0
            }) => {
                e(e => {
                    ("assets" === t.type ? t.assets : Object.keys(e.byAsset).map(e => ({
                        id: e,
                        view: t.view ? ? "all",
                        maxAgeMs: i ? ? 0
                    }))).filter(({
                        id: e
                    }) => !s.includes(e)).forEach(({
                        id: t,
                        view: s = "all"
                    }) => {
                        if (e.byAsset[t]) {
                            let r = e.byAsset[t].lastUpdatedAt,
                                o = Date.now() - (r ? ? 0) > i;
                            "all" === s && o && delete e.byAsset[t], "all" !== s && o && e.byAsset[t].views[s] && delete e.byAsset[t].views[s]
                        }
                    })
                })
            },
            minimizeViews: t => {
                e(e => {
                    (t ? ? []).forEach(t => {
                        e.byAsset[t] && Object.keys(e.byAsset[t].views).forEach(s => {
                            let i = e.byAsset[t].views[s].zero.bids.rows.length,
                                r = e.byAsset[t].views[s].one.bids.rows.length;
                            e.byAsset[t].views[s].zero.asks.rows.length > 0 && (e.byAsset[t].views[s].zero.asks.rows = e.byAsset[t].views[s].zero.asks.rows.slice(0, Math.max(5, 10 - i))), e.byAsset[t].views[s].zero.bids.rows.length > 0 && (e.byAsset[t].views[s].zero.bids.rows = e.byAsset[t].views[s].zero.bids.rows.slice(0, Math.max(5, 10 - e.byAsset[t].views[s].zero.asks.rows.length))), e.byAsset[t].views[s].one.asks.rows.length > 0 && (e.byAsset[t].views[s].one.asks.rows = e.byAsset[t].views[s].one.asks.rows.slice(0, Math.max(5, 10 - r))), e.byAsset[t].views[s].one.bids.rows.length > 0 && (e.byAsset[t].views[s].one.bids.rows = e.byAsset[t].views[s].one.bids.rows.slice(0, Math.max(5, 10 - e.byAsset[t].views[s].one.asks.rows.length))), e.byAsset[t].views[s].minimized = !0, e.byAsset[t].views[s].minimizedAt = Date.now()
                        })
                    })
                })
            },
            initializeEntity: (t, s, i, r) => {
                e(e => {
                    let o = [];
                    "asset" === t ? (("book" === s || "all" === s) && o.push("initializedBookAssetTimestamps"), ("last-price" === s || "all" === s) && o.push("initializedLastPriceAssetTimestamps")) : "event" === t && (("book" === s || "all" === s) && o.push("initializedBookEventTimestamps"), ("last-price" === s || "all" === s) && o.push("initializedLastPriceEventTimestamps")), o.forEach(t => {
                        e[t][i] = r
                    })
                })
            },
            shouldInitializeEntity: (e, s, i, r) => {
                let o = t(),
                    a = Date.now();
                if ("asset" === e) {
                    let e = o.initializedBookAssetTimestamps[i],
                        t = o.initializedLastPriceAssetTimestamps[i],
                        n = !e,
                        l = !t;
                    return ("book" === s || "all" === s) && e && (n = !r || a - e > r), ("last-price" === s || "all" === s) && t && (l = !r || a - t > r), {
                        book: n,
                        last: l
                    }
                }
                if ("event" === e) {
                    let e = o.initializedBookEventTimestamps[i],
                        t = o.initializedLastPriceEventTimestamps[i];
                    return {
                        book: !e,
                        last: !t,
                        ...("book" === s || "all" === s) && !!e && {
                            book: !!r && Date.now() - e > r
                        },
                        ...("last-price" === s || "all" === s) && !!t && {
                            last: !!r && Date.now() - t > r
                        }
                    }
                }
                return {
                    book: !0,
                    last: !0
                }
            }
        }))), l[0] = u, l[1] = r) : r = l[1];
        let [d] = i.default.useState(r);
        return l[2] !== c || l[3] !== d ? (n = (0, t.jsx)(A.Provider, {
            value: d,
            children: c
        }), l[2] = c, l[3] = d, l[4] = n) : n = l[4], n
    }, "useBooksStore", 0, (e, t) => {
        let s = g();
        return (0, r.useStoreWithEqualityFn)(s, e, t)
    }, "useBoundBookStore", 0, g], 567692)
}, 913424, e => {
    "use strict";
    let t = e => ({
        price: e,
        size: 0,
        value: 0,
        netSize: 0,
        netValue: 0,
        includedLevels: [e]
    });
    e.s(["getRowsForPrice", 0, (e, s, i) => {
        if (!e || !s || "number" != typeof i) return [t("0"), t("0"), t("0")];
        let r = [...s].sort((e, t) => parseFloat(e.price) - parseFloat(t.price)),
            o = parseFloat(`0.${e}`).toString(),
            a = r.find(e => e.price === o) ? ? t(o),
            n = r.find(e => parseFloat(e.price) > parseFloat(o)) ? ? t("0.9".padEnd(i + 2, "9"));
        return [r.toReversed().find(e => parseFloat(e.price) < parseFloat(o)) ? ? t("0.0".padEnd(i + 2, "0")), a, n]
    }])
}, 3643, 723823, e => {
    "use strict";
    var t = e.i(999061),
        s = e.i(573346),
        i = e.i(429694),
        r = e.i(455872),
        o = e.i(416340),
        a = e.i(233522),
        n = e.i(913424),
        l = e.i(567692);
    let c = (e, s) => {
            let i, r = (0, t.c)(3);
            r[0] !== e.clobTokenIds ? .[0] || r[1] !== s ? (i = t => {
                let i = e.clobTokenIds ? .[0] ? .toLowerCase ? .() ? ? "",
                    r = t.byAsset[i] ? .tickSizes.active;
                return r ? t.byAsset[i] ? .views[String(r)] ? .[0 === s ? "zero" : "one"] ? .bids : void 0
            }, r[0] = e.clobTokenIds ? .[0], r[1] = s, r[2] = i) : i = r[2];
            let o = i;
            return (0, l.useBooksStore)(o, a.shallow)
        },
        u = (e, t, s) => {
            let i = e.byAsset[t] ? .tickSizes.active;
            return i ? e.byAsset[t] ? .views[String(i)] ? .[0 === s ? "zero" : "one"] ? .asks : void 0
        },
        d = (e, s) => {
            let i, r = (0, t.c)(3);
            r[0] !== e.clobTokenIds ? .[0] || r[1] !== s ? (i = t => u(t, e.clobTokenIds ? .[0] ? .toLowerCase ? .() ? ? "", s), r[0] = e.clobTokenIds ? .[0], r[1] = s, r[2] = i) : i = r[2];
            let o = i;
            return (0, l.useBooksStore)(o, a.shallow)
        },
        b = e => {
            let s, i = (0, t.c)(3),
                o = (e => {
                    let s, i = (0, t.c)(38);
                    if (i[0] !== e) {
                        e: {
                            if (!e || !Array.isArray(e.outcomes) || e.outcomes.length < 2) {
                                s = void 0;
                                break e
                            }
                            let t = (0, r.getPrecisionFromTickSize)(e.orderPriceMinTickSize ? ? .01);
                            if (e.bestAsk || e.bestBid) {
                                let r, o, a, n = null,
                                    l = null,
                                    c = null,
                                    u = null;
                                e.bestAsk && (n = e.bestAsk), e.bestBid && (l = e.bestBid), n && (u = 1 - n), l && (c = 1 - l);
                                let d = null !== n ? `${n.toFixed(t)}` : null,
                                    b = null !== l ? `${l.toFixed(t)}` : null;
                                i[2] !== d || i[3] !== b ? (r = {
                                    buy: d,
                                    sell: b
                                }, i[2] = d, i[3] = b, i[4] = r) : r = i[4];
                                let k = null !== c ? `${c.toFixed(t)}` : null,
                                    p = null !== u ? `${u.toFixed(t)}` : null;
                                i[5] !== k || i[6] !== p ? (o = {
                                    buy: k,
                                    sell: p
                                }, i[5] = k, i[6] = p, i[7] = o) : o = i[7], i[8] !== r || i[9] !== o ? (a = {
                                    "~zero": r,
                                    "~one": o
                                }, i[8] = r, i[9] = o, i[10] = a) : a = i[10], s = a;
                                break e
                            }
                            if (Array.isArray(e.outcomePrices) && 2 === e.outcomePrices.length) {
                                let r, o, a, n = parseFloat(e.outcomePrices[0]),
                                    l = parseFloat(e.outcomePrices[1]);
                                if (1 === n) {
                                    let e, r, o, a = `${1..toFixed(t)}`,
                                        n = `${0..toFixed(t)}`;
                                    i[11] !== a || i[12] !== n ? (e = {
                                        buy: a,
                                        sell: n
                                    }, i[11] = a, i[12] = n, i[13] = e) : e = i[13];
                                    let l = `${0..toFixed(t)}`,
                                        c = `${1..toFixed(t)}`;
                                    i[14] !== l || i[15] !== c ? (r = {
                                        buy: l,
                                        sell: c
                                    }, i[14] = l, i[15] = c, i[16] = r) : r = i[16], i[17] !== e || i[18] !== r ? (o = {
                                        "~zero": e,
                                        "~one": r
                                    }, i[17] = e, i[18] = r, i[19] = o) : o = i[19], s = o;
                                    break e
                                }
                                if (1 === l) {
                                    let e, r, o, a = `${0..toFixed(t)}`,
                                        n = `${1..toFixed(t)}`;
                                    i[20] !== a || i[21] !== n ? (e = {
                                        buy: a,
                                        sell: n
                                    }, i[20] = a, i[21] = n, i[22] = e) : e = i[22];
                                    let l = `${1..toFixed(t)}`,
                                        c = `${0..toFixed(t)}`;
                                    i[23] !== l || i[24] !== c ? (r = {
                                        buy: l,
                                        sell: c
                                    }, i[23] = l, i[24] = c, i[25] = r) : r = i[25], i[26] !== e || i[27] !== r ? (o = {
                                        "~zero": e,
                                        "~one": r
                                    }, i[26] = e, i[27] = r, i[28] = o) : o = i[28], s = o;
                                    break e
                                }
                                let c = n,
                                    u = Math.max(c - .01, 0);
                                e.spread && (c += e.spread / 2, u = c - e.spread);
                                let d = 1 - u,
                                    b = 1 - c,
                                    k = `${c.toFixed(t)}`,
                                    p = `${u.toFixed(t)}`;
                                i[29] !== k || i[30] !== p ? (r = {
                                    buy: k,
                                    sell: p
                                }, i[29] = k, i[30] = p, i[31] = r) : r = i[31];
                                let f = `${d.toFixed(t)}`,
                                    S = `${b.toFixed(t)}`;
                                i[32] !== f || i[33] !== S ? (o = {
                                    buy: f,
                                    sell: S
                                }, i[32] = f, i[33] = S, i[34] = o) : o = i[34], i[35] !== r || i[36] !== o ? (a = {
                                    "~zero": r,
                                    "~one": o
                                }, i[35] = r, i[36] = o, i[37] = a) : a = i[37], s = a;
                                break e
                            }
                            s = void 0
                        }
                        i[0] = e,
                        i[1] = s
                    }
                    else s = i[1];
                    return s
                })(e);
            i[0] !== o || i[1] !== e ? (s = t => {
                if (!e) return;
                let s = e.clobTokenIds ? .[0] ? .toLowerCase ? .() ? ? "",
                    i = t.byAsset[s] ? .tickSizes.active,
                    r = i ? t.byAsset[s] ? .views[String(i)] ? .bestPrices : void 0;
                return r || (r = t.byAsset[s] ? .views[String(.01 === i ? .001 : .01)] ? .bestPrices), r ? ? o
            }, i[0] = o, i[1] = e, i[2] = s) : s = i[2];
            let n = s;
            return (0, l.useBooksStore)(n, a.shallow)
        },
        k = (e, t) => {
            let s = b(e);
            return s ? .[0 === t ? "~zero" : "~one"]
        },
        p = (e, s, i) => {
            let r, o = (0, t.c)(3),
                a = k(e, s);
            e: {
                let e, t = a ? .["ask" === i ? "buy" : "sell"];
                if (!t) {
                    let e;
                    o[0] === Symbol.for("react.memo_cache_sentinel") ? (e = {
                        value: 0,
                        valid: !1
                    }, o[0] = e) : e = o[0], r = e;
                    break e
                }
                let s = parseFloat(t);o[1] !== s ? (e = {
                    value: s,
                    valid: !0
                }, o[1] = s, o[2] = e) : e = o[2],
                r = e
            }
            return r
        },
        f = (e, s) => {
            let i, r = (0, t.c)(3);
            r[0] !== e.clobTokenIds ? .[0] || r[1] !== s ? (i = t => {
                let i = e.clobTokenIds ? .[0] ? .toLowerCase ? .() ? ? "",
                    r = t.byAsset[i] ? .tickSizes.active,
                    o = r ? t.byAsset[i] ? .views[String(r)] ? .[0 === s ? "zero" : "one"] : void 0;
                return o && o.spread ? {
                    value: o.spread,
                    valid: !0
                } : {
                    value: 0,
                    valid: !1
                }
            }, r[0] = e.clobTokenIds ? .[0], r[1] = s, r[2] = i) : i = r[2];
            let o = i;
            return (0, l.useBooksStore)(o, a.shallow)
        },
        S = (e, o) => {
            let n, c = (0, t.c)(4),
                u = ((e, i) => {
                    let o, a = (0, t.c)(12);
                    e: {
                        let t;
                        if (e ? .lastTradePrice) {
                            let t, n, l, c, u;
                            if (a[0] !== e.lastTradePrice || a[1] !== e.orderPriceMinTickSize || a[2] !== i) {
                                let s = (0, r.getPrecisionFromTickSize)(e.orderPriceMinTickSize);
                                l = 0 === i ? e.lastTradePrice : 1 - e.lastTradePrice, t = parseFloat, n = l.toFixed(s), a[0] = e.lastTradePrice, a[1] = e.orderPriceMinTickSize, a[2] = i, a[3] = t, a[4] = n, a[5] = l
                            } else t = a[3], n = a[4], l = a[5];
                            let d = t(n);
                            a[6] !== l ? (c = l.toString(), a[6] = l, a[7] = c) : c = a[7], a[8] !== d || a[9] !== c ? (u = {
                                price: d,
                                rawPrice: c,
                                side: s.Side.BUY,
                                valid: !0
                            }, a[8] = d, a[9] = c, a[10] = u) : u = a[10], o = u;
                            break e
                        }
                        a[11] === Symbol.for("react.memo_cache_sentinel") ? (t = {
                            price: void 0,
                            rawPrice: void 0,
                            side: s.Side.BUY,
                            valid: !1
                        }, a[11] = t) : t = a[11],
                        o = t
                    }
                    return o
                })(e, o);
            c[0] !== u || c[1] !== e || c[2] !== o ? (n = t => {
                if (!e) return {
                    price: void 0,
                    rawPrice: void 0,
                    side: s.Side.BUY,
                    valid: !1
                };
                let a = (0, r.getPrecisionFromTickSize)(e.orderPriceMinTickSize),
                    n = e.clobTokenIds ? .[0] ? .toLowerCase ? .() ? ? "",
                    l = t.byAsset[n] ? .lastPrice;
                return l && l ? .price ? l && 1 === o ? {
                    price: parseFloat(parseFloat((0, i.getInversePrice)(l.price, a)).toFixed(a)),
                    rawPrice: (0, i.getInversePrice)(l.price),
                    side: l.side,
                    valid: !0
                } : {
                    price: parseFloat(parseFloat(l.price).toFixed(a)),
                    rawPrice: l.price,
                    side: l.side,
                    valid: !0
                } : u
            }, c[0] = u, c[1] = e, c[2] = o, c[3] = n) : n = c[3];
            let d = n;
            return (0, l.useBooksStore)(d, a.shallow)
        };

    function y(e) {
        return e.fetchStatus
    }

    function m(e, t) {
        let [s, i] = t;
        return "queued" === i.book ? (e.queuedBooks[s] = i.book, e.areBooksQueued || (e.areBooksQueued = !0)) : "fetching" === i.book && (e.fetchingBooks[s] = i.book, e.areBooksFetching || (e.areBooksFetching = !0)), "queued" === i.lastPrice ? (e.queuedLastPrices[s] = i.lastPrice, e.areLastPricesQueued || (e.areLastPricesQueued = !0)) : "fetching" === i.lastPrice && (e.fetchingLastPrices[s] = i.lastPrice, e.areLastPricesFetching || (e.areLastPricesFetching = !0)), i.polling && (e.pollingBooks[s] = !0, e.areBooksPolling || (e.areBooksPolling = !0)), e
    }
    e.s(["asksSelector", 0, u, "useAsks", 0, d, "useBestPrice", 0, p, "useBids", 0, c, "useBooksFetchingStatus", 0, () => {
        let e, s = (0, t.c)(2),
            i = (0, l.useBooksStore)(y, a.shallow);
        return s[0] !== i ? (e = Object.entries(i).reduce(m, {
            areBooksFetching: !1,
            areBooksQueued: !1,
            queuedBooks: {},
            fetchingBooks: {},
            areLastPricesFetching: !1,
            areLastPricesQueued: !1,
            queuedLastPrices: {},
            fetchingLastPrices: {},
            areBooksPolling: !1,
            pollingBooks: {}
        }), s[0] = i, s[1] = e) : e = s[1], e
    }, "useGetBestPrice", 0, () => {
        let e, s = (0, t.c)(2),
            i = (0, l.useBoundBookStore)();
        return s[0] !== i ? (e = (e, t, s) => {
            if (!e) return;
            let r = e.clobTokenIds ? .[0] ? .toLowerCase ? .() ? ? "",
                o = i.getState().byAsset[r] ? .tickSizes.active,
                a = o ? i.getState().byAsset[r] ? .views[String(o)] ? .[0 === t ? "zero" : "one"] ? .["ask" === s ? "asks" : "bids"] : void 0;
            return a ? .bestPrice
        }, s[0] = i, s[1] = e) : e = s[1], e
    }, "useGetBestPrices", 0, () => {
        let e, s = (0, t.c)(2),
            i = (0, l.useBoundBookStore)();
        return s[0] !== i ? (e = e => {
            if (!e) return;
            let t = e.clobTokenIds ? .[0] ? .toLowerCase ? .() ? ? "";
            return i.getState().byAsset[t] ? .views[String(e.orderPriceMinTickSize)] ? .bestPrices
        }, s[0] = i, s[1] = e) : e = s[1], e
    }, "useHasResolvedProbability", 0, function(e) {
        let s, i = (0, t.c)(4),
            r = +(e ? .resolutionData ? .proposedPrice === "0");
        i[0] !== e.clobTokenIds ? .[0] || i[1] !== e.resolutionData || i[2] !== r ? (s = t => {
            let s = u(t, e.clobTokenIds ? .[0] ? .toLowerCase ? .() ? ? "", r);
            return !!e ? .resolutionData && "69" !== e.resolutionData.proposedPrice && !!s && !s.hasLiquidity
        }, i[0] = e.clobTokenIds ? .[0], i[1] = e.resolutionData, i[2] = r, i[3] = s) : s = i[3];
        let o = s;
        return (0, l.useBooksStore)(o, a.shallow)
    }, "useIsBookFetching", 0, e => {
        let s, i, r = (0, t.c)(5);
        r[0] !== e ? (s = t => t.fetchStatus[e], r[0] = e, r[1] = s) : s = r[1];
        let o = s,
            n = (0, l.useBooksStore)(o, a.shallow),
            c = n ? .book === "fetching",
            u = n ? .lastPrice === "fetching";
        return r[2] !== c || r[3] !== u ? (i = {
            isBookFetching: c,
            isLastPriceFetching: u
        }, r[2] = c, r[3] = u, r[4] = i) : i = r[4], i
    }, "useLastTradedPrice", 0, S, "useLastTradedPrices", 0, e => {
        let s, i = (0, t.c)(4),
            r = S(e, 0),
            o = S(e, 1);
        e: {
            let e;
            if (!r.valid || !o.valid) {
                let e;
                i[0] === Symbol.for("react.memo_cache_sentinel") ? (e = [void 0, void 0], i[0] = e) : e = i[0], s = e;
                break e
            }
            i[1] !== o.price || i[2] !== r.price ? (e = [r.price, o.price], i[1] = o.price, i[2] = r.price, i[3] = e) : e = i[3],
            s = e
        }
        return s
    }, "useMarketBestPrices", 0, b, "useMatchingShares", 0, (e, t, s, i) => {
        let a = c(t, s),
            l = d(t, s);
        return o.default.useMemo(() => {
            try {
                if ("ask" === i && l) {
                    let [, s] = (0, n.getRowsForPrice)(e, l.rows, (0, r.getPrecisionFromTickSize)(t.orderPriceMinTickSize));
                    return `${s.netSize}`
                }
                if ("bid" === i && a) {
                    let [, s] = (0, n.getRowsForPrice)(e, a.rows, (0, r.getPrecisionFromTickSize)(t.orderPriceMinTickSize));
                    return `${s.netSize}`
                }
                return "0"
            } catch {
                return "0"
            }
        }, [t, s, i, e, a, l])
    }, "useMidpoint", 0, (e, s) => {
        let i, o = (0, t.c)(4);
        o[0] !== e.clobTokenIds ? .[0] || o[1] !== e.orderPriceMinTickSize || o[2] !== s ? (i = t => {
            let i = (0, r.getPrecisionFromTickSize)(e.orderPriceMinTickSize),
                o = e.clobTokenIds ? .[0] ? .toLowerCase ? .() ? ? "",
                a = t.byAsset[o] ? .tickSizes.active,
                n = a ? t.byAsset[o] ? .views[String(a)] ? .[0 === s ? "zero" : "one"] : void 0;
            return n && null !== n.midpoint ? {
                value: parseFloat(`${n.midpoint.toFixed(i)}`),
                valid: !0
            } : {
                value: 0,
                valid: !1
            }
        }, o[0] = e.clobTokenIds ? .[0], o[1] = e.orderPriceMinTickSize, o[2] = s, o[3] = i) : i = o[3];
        let n = i;
        return (0, l.useBooksStore)(n, a.shallow)
    }, "usePositionValuationPrice", 0, (e, t) => {
        let s, i = k(e, t),
            r = S(e, t);
        e: {
            let e = i ? .sell,
                t = i ? .buy,
                o = e ? parseFloat(e) : 0,
                a = t ? parseFloat(t) : 0,
                n = o > 0,
                l = a > 0;
            if (n && l) {
                s = (o + a) / 2;
                break e
            }
            if (n) {
                s = o;
                break e
            }
            if (l) {
                s = a;
                break e
            }
            if (r ? .valid && void 0 !== r.price) {
                s = r.price;
                break e
            }
            s = 0
        }
        return s
    }, "useShouldInitializeEntity", 0, (e, t, s, i, r = "", a = 12e4) => {
        let n = o.default.useRef({}),
            c = o.default.useRef({}),
            u = (0, l.useBoundBookStore)();
        return o.default.useMemo(() => {
            let o = u.getState().shouldInitializeEntity(e, t, s, a),
                l = n.current[r] ? ? 0,
                d = c.current[r] ? ? 0,
                b = !1,
                k = !1;
            return b = "always" === i.book || "never" !== i.book && ("once" === i.book ? 0 === d : "once-when-stale" === i.book ? !(d > 0) && o.book : o.book), k = "always" === i.last || "never" !== i.last && ("once" === i.last ? 0 === l : "once-when-stale" === i.last ? !(l > 0) && o.last : o.last), b && (c.current[r] = d + 1), k && (n.current[r] = l + 1), {
                book: b,
                last: k
            }
        }, [r])
    }, "useSpread", 0, f, "useTickSize", 0, e => {
        let s, i = (0, t.c)(2);
        i[0] !== e.clobTokenIds ? .[0] ? (s = t => {
            let s = e.clobTokenIds ? .[0] ? .toLowerCase ? .() ? ? "";
            return t.byAsset[s] ? .tickSizes.user
        }, i[0] = e.clobTokenIds ? .[0], i[1] = s) : s = i[1];
        let r = s;
        return (0, l.useBooksStore)(r, a.shallow)
    }], 723823);
    let v = {
            lastPriceString: void 0,
            lastPrice: void 0,
            showLastPrice: !1,
            noLastPrice: !0
        },
        A = ({
            zeroLastPrice: e,
            bestZeroAsk: t,
            bestZeroBid: s,
            zeroSpread: i,
            hasAsks: r,
            hasBids: o,
            precision: a = 2
        }) => {
            let n = a - 2;
            if (!r && !o && !e) return v;
            try {
                let l = ((e, t, s) => {
                    if (!e || !Number.isFinite(t) || !Number.isFinite(s)) return !1;
                    try {
                        let i = parseFloat(e);
                        if (Number.isFinite(i)) return i >= t && i <= s;
                        return !1
                    } catch {
                        return !1
                    }
                })(e, s, t);
                if (i > .1 && void 0 !== e && l) {
                    let t = parseFloat(e),
                        s = 100 * t,
                        r = a ? parseFloat(s.toFixed(n)) : parseInt(s.toFixed(), 10);
                    return {
                        lastPriceString: r < 1 ? "<1%" : `${r.toFixed(n)}%`,
                        lastPrice: s,
                        showLastPrice: i <= .5,
                        noLastPrice: !1
                    }
                }
                let c = r && o ? (s + (t - s) / 2) * 100 : o ? 100 * s : r ? 100 * t : void 0;
                if (void 0 === c) return v;
                let u = a ? parseFloat(c.toFixed(n)) : parseInt(c.toFixed(), 10);
                return {
                    lastPriceString: u < 1 ? "<1%" : `${u.toFixed(n)}%`,
                    lastPrice: c,
                    showLastPrice: !0,
                    noLastPrice: void 0 === e
                }
            } catch {
                return v
            }
        },
        g = (e, t) => {
            let s = Number.isFinite(e.bestAsk) ? Number(e.bestAsk) : void 0,
                i = Number.isFinite(e.bestBid) ? Number(e.bestBid) : void 0,
                r = "number" == typeof s && s > 0,
                o = "number" == typeof i && i > 0;
            if (!e.lastTradePrice && !r && !o && e.outcomePrices ? .length) {
                let t = 100 * parseFloat(e.outcomePrices[0]),
                    s = parseInt(t.toFixed(), 10);
                return {
                    lastPriceString: s < 1 ? "<1%" : `${s.toFixed()}%`,
                    lastPrice: t,
                    showLastPrice: !0,
                    noLastPrice: !1
                }
            }
            let a = e.lastTradePrice ? .toString(),
                n = r && void 0 !== s ? s : 1,
                l = o && void 0 !== i ? i : 0,
                c = 1 !== e.spread && e.spread ? e.spread : n - l;
            return A({
                zeroLastPrice: a,
                bestZeroAsk: n,
                bestZeroBid: l,
                zeroSpread: c,
                hasAsks: r,
                hasBids: o,
                precision: t
            })
        };
    e.s(["getPercentChance", 0, A, "getPercentChanceFromMarket", 0, g, "useFallbackPercentChance", 0, (e, s) => {
        let i, r = (0, t.c)(3),
            o = void 0 === s ? 2 : s;
        e: {
            let t;
            if (!e || e.closed) {
                i = v;
                break e
            }
            r[0] !== e || r[1] !== o ? (t = g(e, o), r[0] = e, r[1] = o, r[2] = t) : t = r[2],
            i = t
        }
        return i
    }, "usePercentChance", 0, (e, t = 2) => {
        let s = p(e, 0, "ask"),
            i = p(e, 0, "bid"),
            r = f(e, 0),
            a = S(e, 0);
        return o.default.useMemo(() => e.closed ? v : s.valid && i.valid ? A({
            zeroLastPrice: a.rawPrice ? .toString(),
            bestZeroAsk: s.value,
            bestZeroBid: i.value,
            zeroSpread: r.value,
            hasAsks: s.valid,
            hasBids: i.valid,
            precision: t
        }) : g(e, t), [s, i, r, a, e.closed, e.lastTradePrice, e.bestAsk, e.bestBid, t])
    }], 3643)
}, 650485, e => {
    "use strict";
    let t = (e, t, s) => "price" === s.sortBy ? Array.isArray(e.outcomePrices) ? Array.isArray(t.outcomePrices) ? parseFloat(t.outcomePrices[0]) - parseFloat(e.outcomePrices[0]) : -1 : 1 : "descending" === s.sortBy ? e.groupItemThreshold ? t.groupItemThreshold ? t.groupItemThreshold - e.groupItemThreshold : -1 : 1 : e.groupItemThreshold ? t.groupItemThreshold ? e.groupItemThreshold - t.groupItemThreshold : 1 : -1;
    e.s(["aggregatedSort", 0, (e, s, i) => {
        if ("price" === i.sortBy) return e.sortKey > s.sortKey ? -1 : +(e.sortKey < s.sortKey);
        return t(e, s, i)
    }, "sortEventMarketsByThreshold", 0, t])
}]);

//# debugId=ff59efd7-4ad8-7536-5ffa-0e794bc8fb35