{"version":3,"file":"index.cjs","sources":["../../../node_modules/.pnpm/fp-ts@2.16.11/node_modules/fp-ts/es6/function.js","../../../node_modules/.pnpm/fp-ts@2.16.11/node_modules/fp-ts/es6/internal.js","../../../node_modules/.pnpm/fp-ts@2.16.11/node_modules/fp-ts/es6/Apply.js","../../../node_modules/.pnpm/fp-ts@2.16.11/node_modules/fp-ts/es6/Functor.js","../../../node_modules/.pnpm/fp-ts@2.16.11/node_modules/fp-ts/es6/Chain.js","../../../node_modules/.pnpm/fp-ts@2.16.11/node_modules/fp-ts/es6/Either.js","../src/helpers/access.ts","../src/composables/Mountable.ts","../src/helpers/removeUndefined.ts","../src/helpers/shallowEqual.ts","../src/composables/Stateful.ts","../src/helpers/createIsSupportedSignal.ts","../../../node_modules/.pnpm/fp-ts@2.16.11/node_modules/fp-ts/es6/Option.js","../src/with-checks/throwifyWithChecksFp.ts","../../../node_modules/.pnpm/fp-ts@2.16.11/node_modules/fp-ts/es6/EitherT.js","../../../node_modules/.pnpm/fp-ts@2.16.11/node_modules/fp-ts/es6/Task.js","../../../node_modules/.pnpm/fp-ts@2.16.11/node_modules/fp-ts/es6/TaskEither.js","../src/errors.ts","../src/with-checks/withChecksFp.ts","../src/composables/Button.ts","../src/features/BackButton/BackButton.ts","../src/fn-options/sharedFeatureOptions.ts","../src/fn-options/createFnOption.ts","../src/globals/signals-registry.ts","../src/globals/postEvent.ts","../src/fn-options/withPostEvent.ts","../src/helpers/component-storage.ts","../src/helpers/navigation.ts","../src/fn-options/withStateRestore.ts","../src/globals/version.ts","../src/fn-options/withVersion.ts","../src/fn-options/buttonOptions.ts","../src/features/BackButton/instance.ts","../src/composables/AsyncMountable.ts","../src/features/Biometry/Biometry.ts","../src/globals/request.ts","../src/fn-options/withRequest.ts","../src/features/Biometry/instance.ts","../src/features/ClosingBehavior/ClosingBehavior.ts","../src/features/ClosingBehavior/instance.ts","../src/features/CloudStorage/CloudStorage.ts","../src/globals/createRequestId.ts","../src/globals/invokeCustomMethod.ts","../src/fn-options/withInvokeCustomMethod.ts","../src/features/CloudStorage/instance.ts","../src/features/DeviceStorage/DeviceStorage.ts","../src/fn-options/withCreateRequestId.ts","../src/features/DeviceStorage/instance.ts","../src/features/emoji-status/requestEmojiStatusAccess.ts","../src/features/emoji-status/setEmojiStatus.ts","../src/features/HapticFeedback/HapticFeedback.ts","../src/features/HapticFeedback/instance.ts","../src/features/home-screen/addToHomeScreen.ts","../src/features/home-screen/checkHomeScreenStatus.ts","../src/features/InitData/InitData.ts","../src/features/InitData/instance.ts","../src/features/Invoice/Invoice.ts","../src/features/Invoice/instance.ts","../src/features/links/openLink.ts","../src/features/links/openTelegramLink.ts","../src/features/links/shareURL.ts","../src/features/LocationManager/LocationManager.ts","../src/features/LocationManager/instance.ts","../src/features/MainButton/MainButton.ts","../src/helpers/css-vars.ts","../src/helpers/isColorDark.ts","../src/features/ThemeParams/ThemeParams.ts","../src/globals/themeParams.ts","../src/features/ThemeParams/instance.ts","../src/fn-options/bottomButtonOptions.ts","../src/features/MainButton/instance.ts","../src/features/MiniApp/MiniApp.ts","../src/features/MiniApp/instance.ts","../src/features/Popup/prepareParams.ts","../src/features/Popup/Popup.ts","../src/features/Popup/instance.ts","../src/features/privacy/requestPhoneAccess.ts","../src/features/privacy/requestContact.ts","../src/features/privacy/requestWriteAccess.ts","../src/features/QrScanner/QrScanner.ts","../src/features/QrScanner/instance.ts","../src/features/SecondaryButton/SecondaryButton.ts","../src/features/SecondaryButton/instance.ts","../src/features/SecureStorage/SecureStorage.ts","../src/features/SecureStorage/instance.ts","../src/features/SettingsButton/SettingsButton.ts","../src/features/SettingsButton/instance.ts","../src/features/SwipeBehavior/SwipeBehavior.ts","../src/features/SwipeBehavior/instance.ts","../src/features/uncategorized/copyTextToClipboard.ts","../src/features/uncategorized/downloadFile.ts","../src/features/uncategorized/getCurrentTime.ts","../src/features/uncategorized/hideKeyboard.ts","../src/features/uncategorized/readTextFromClipboard.ts","../src/features/uncategorized/retrieveAndroidDeviceDataFrom.ts","../src/features/uncategorized/retrieveAndroidDeviceData.ts","../src/features/uncategorized/sendData.ts","../src/features/uncategorized/shareMessage.ts","../src/features/uncategorized/shareStory.ts","../src/globals/isInlineMode.ts","../src/features/uncategorized/switchInlineQuery.ts","../src/features/Viewport/Viewport.ts","../src/features/Viewport/instance.ts","../src/init.ts"],"sourcesContent":["var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {\n    if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n        if (ar || !(i in from)) {\n            if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n            ar[i] = from[i];\n        }\n    }\n    return to.concat(ar || Array.prototype.slice.call(from));\n};\n// -------------------------------------------------------------------------------------\n// instances\n// -------------------------------------------------------------------------------------\n/**\n * @category instances\n * @since 2.10.0\n */\nexport var getBooleanAlgebra = function (B) {\n    return function () { return ({\n        meet: function (x, y) { return function (a) { return B.meet(x(a), y(a)); }; },\n        join: function (x, y) { return function (a) { return B.join(x(a), y(a)); }; },\n        zero: function () { return B.zero; },\n        one: function () { return B.one; },\n        implies: function (x, y) { return function (a) { return B.implies(x(a), y(a)); }; },\n        not: function (x) { return function (a) { return B.not(x(a)); }; }\n    }); };\n};\n/**\n * Unary functions form a semigroup as long as you can provide a semigroup for the codomain.\n *\n * @example\n * import { Predicate, getSemigroup } from 'fp-ts/function'\n * import * as B from 'fp-ts/boolean'\n *\n * const f: Predicate<number> = (n) => n <= 2\n * const g: Predicate<number> = (n) => n >= 0\n *\n * const S1 = getSemigroup(B.SemigroupAll)<number>()\n *\n * assert.deepStrictEqual(S1.concat(f, g)(1), true)\n * assert.deepStrictEqual(S1.concat(f, g)(3), false)\n *\n * const S2 = getSemigroup(B.SemigroupAny)<number>()\n *\n * assert.deepStrictEqual(S2.concat(f, g)(1), true)\n * assert.deepStrictEqual(S2.concat(f, g)(3), true)\n *\n * @category instances\n * @since 2.10.0\n */\nexport var getSemigroup = function (S) {\n    return function () { return ({\n        concat: function (f, g) { return function (a) { return S.concat(f(a), g(a)); }; }\n    }); };\n};\n/**\n * Unary functions form a monoid as long as you can provide a monoid for the codomain.\n *\n * @example\n * import { Predicate } from 'fp-ts/Predicate'\n * import { getMonoid } from 'fp-ts/function'\n * import * as B from 'fp-ts/boolean'\n *\n * const f: Predicate<number> = (n) => n <= 2\n * const g: Predicate<number> = (n) => n >= 0\n *\n * const M1 = getMonoid(B.MonoidAll)<number>()\n *\n * assert.deepStrictEqual(M1.concat(f, g)(1), true)\n * assert.deepStrictEqual(M1.concat(f, g)(3), false)\n *\n * const M2 = getMonoid(B.MonoidAny)<number>()\n *\n * assert.deepStrictEqual(M2.concat(f, g)(1), true)\n * assert.deepStrictEqual(M2.concat(f, g)(3), true)\n *\n * @category instances\n * @since 2.10.0\n */\nexport var getMonoid = function (M) {\n    var getSemigroupM = getSemigroup(M);\n    return function () { return ({\n        concat: getSemigroupM().concat,\n        empty: function () { return M.empty; }\n    }); };\n};\n/**\n * @category instances\n * @since 2.10.0\n */\nexport var getSemiring = function (S) { return ({\n    add: function (f, g) { return function (x) { return S.add(f(x), g(x)); }; },\n    zero: function () { return S.zero; },\n    mul: function (f, g) { return function (x) { return S.mul(f(x), g(x)); }; },\n    one: function () { return S.one; }\n}); };\n/**\n * @category instances\n * @since 2.10.0\n */\nexport var getRing = function (R) {\n    var S = getSemiring(R);\n    return {\n        add: S.add,\n        mul: S.mul,\n        one: S.one,\n        zero: S.zero,\n        sub: function (f, g) { return function (x) { return R.sub(f(x), g(x)); }; }\n    };\n};\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n/**\n * @since 2.11.0\n */\nexport var apply = function (a) {\n    return function (f) {\n        return f(a);\n    };\n};\n/**\n * @since 2.0.0\n */\nexport function identity(a) {\n    return a;\n}\n/**\n * @since 2.0.0\n */\nexport var unsafeCoerce = identity;\n/**\n * @since 2.0.0\n */\nexport function constant(a) {\n    return function () { return a; };\n}\n/**\n * A thunk that returns always `true`.\n *\n * @since 2.0.0\n */\nexport var constTrue = /*#__PURE__*/ constant(true);\n/**\n * A thunk that returns always `false`.\n *\n * @since 2.0.0\n */\nexport var constFalse = /*#__PURE__*/ constant(false);\n/**\n * A thunk that returns always `null`.\n *\n * @since 2.0.0\n */\nexport var constNull = /*#__PURE__*/ constant(null);\n/**\n * A thunk that returns always `undefined`.\n *\n * @since 2.0.0\n */\nexport var constUndefined = /*#__PURE__*/ constant(undefined);\n/**\n * A thunk that returns always `void`.\n *\n * @since 2.0.0\n */\nexport var constVoid = constUndefined;\nexport function flip(f) {\n    return function () {\n        var args = [];\n        for (var _i = 0; _i < arguments.length; _i++) {\n            args[_i] = arguments[_i];\n        }\n        if (args.length > 1) {\n            return f(args[1], args[0]);\n        }\n        return function (a) { return f(a)(args[0]); };\n    };\n}\nexport function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) {\n    switch (arguments.length) {\n        case 1:\n            return ab;\n        case 2:\n            return function () {\n                return bc(ab.apply(this, arguments));\n            };\n        case 3:\n            return function () {\n                return cd(bc(ab.apply(this, arguments)));\n            };\n        case 4:\n            return function () {\n                return de(cd(bc(ab.apply(this, arguments))));\n            };\n        case 5:\n            return function () {\n                return ef(de(cd(bc(ab.apply(this, arguments)))));\n            };\n        case 6:\n            return function () {\n                return fg(ef(de(cd(bc(ab.apply(this, arguments))))));\n            };\n        case 7:\n            return function () {\n                return gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))));\n            };\n        case 8:\n            return function () {\n                return hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))));\n            };\n        case 9:\n            return function () {\n                return ij(hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))));\n            };\n    }\n    return;\n}\n/**\n * @since 2.0.0\n */\nexport function tuple() {\n    var t = [];\n    for (var _i = 0; _i < arguments.length; _i++) {\n        t[_i] = arguments[_i];\n    }\n    return t;\n}\n/**\n * @since 2.0.0\n */\nexport function increment(n) {\n    return n + 1;\n}\n/**\n * @since 2.0.0\n */\nexport function decrement(n) {\n    return n - 1;\n}\n/**\n * @since 2.0.0\n */\nexport function absurd(_) {\n    throw new Error('Called `absurd` function which should be uncallable');\n}\n/**\n * Creates a tupled version of this function: instead of `n` arguments, it accepts a single tuple argument.\n *\n * @example\n * import { tupled } from 'fp-ts/function'\n *\n * const add = tupled((x: number, y: number): number => x + y)\n *\n * assert.strictEqual(add([1, 2]), 3)\n *\n * @since 2.4.0\n */\nexport function tupled(f) {\n    return function (a) { return f.apply(void 0, a); };\n}\n/**\n * Inverse function of `tupled`\n *\n * @since 2.4.0\n */\nexport function untupled(f) {\n    return function () {\n        var a = [];\n        for (var _i = 0; _i < arguments.length; _i++) {\n            a[_i] = arguments[_i];\n        }\n        return f(a);\n    };\n}\nexport function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {\n    switch (arguments.length) {\n        case 1:\n            return a;\n        case 2:\n            return ab(a);\n        case 3:\n            return bc(ab(a));\n        case 4:\n            return cd(bc(ab(a)));\n        case 5:\n            return de(cd(bc(ab(a))));\n        case 6:\n            return ef(de(cd(bc(ab(a)))));\n        case 7:\n            return fg(ef(de(cd(bc(ab(a))))));\n        case 8:\n            return gh(fg(ef(de(cd(bc(ab(a)))))));\n        case 9:\n            return hi(gh(fg(ef(de(cd(bc(ab(a))))))));\n        default: {\n            var ret = arguments[0];\n            for (var i = 1; i < arguments.length; i++) {\n                ret = arguments[i](ret);\n            }\n            return ret;\n        }\n    }\n}\n/**\n * Type hole simulation\n *\n * @since 2.7.0\n */\nexport var hole = absurd;\n/**\n * @since 2.11.0\n */\nexport var SK = function (_, b) { return b; };\n/**\n * Use `Predicate` module instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function not(predicate) {\n    return function (a) { return !predicate(a); };\n}\n/**\n * Use `Endomorphism` module instead.\n *\n * @category zone of death\n * @since 2.10.0\n * @deprecated\n */\nexport var getEndomorphismMonoid = function () { return ({\n    concat: function (first, second) { return flow(first, second); },\n    empty: identity\n}); };\n/** @internal */\nexport var dual = function (arity, body) {\n    var isDataFirst = typeof arity === 'number' ? function (args) { return args.length >= arity; } : arity;\n    return function () {\n        var args = Array.from(arguments);\n        if (isDataFirst(arguments)) {\n            return body.apply(this, args);\n        }\n        return function (self) { return body.apply(void 0, __spreadArray([self], args, false)); };\n    };\n};\n","var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {\n    if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n        if (ar || !(i in from)) {\n            if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n            ar[i] = from[i];\n        }\n    }\n    return to.concat(ar || Array.prototype.slice.call(from));\n};\nimport { dual } from './function';\n// -------------------------------------------------------------------------------------\n// Option\n// -------------------------------------------------------------------------------------\n/** @internal */\nexport var isNone = function (fa) { return fa._tag === 'None'; };\n/** @internal */\nexport var isSome = function (fa) { return fa._tag === 'Some'; };\n/** @internal */\nexport var none = { _tag: 'None' };\n/** @internal */\nexport var some = function (a) { return ({ _tag: 'Some', value: a }); };\n// -------------------------------------------------------------------------------------\n// Either\n// -------------------------------------------------------------------------------------\n/** @internal */\nexport var isLeft = function (ma) { return ma._tag === 'Left'; };\n/** @internal */\nexport var isRight = function (ma) { return ma._tag === 'Right'; };\n/** @internal */\nexport var left = function (e) { return ({ _tag: 'Left', left: e }); };\n/** @internal */\nexport var right = function (a) { return ({ _tag: 'Right', right: a }); };\n// -------------------------------------------------------------------------------------\n// ReadonlyNonEmptyArray\n// -------------------------------------------------------------------------------------\n/** @internal */\nexport var singleton = function (a) { return [a]; };\n/** @internal */\nexport var isNonEmpty = function (as) { return as.length > 0; };\n/** @internal */\nexport var head = function (as) { return as[0]; };\n/** @internal */\nexport var tail = function (as) { return as.slice(1); };\n// -------------------------------------------------------------------------------------\n// empty\n// -------------------------------------------------------------------------------------\n/** @internal */\nexport var emptyReadonlyArray = [];\n/** @internal */\nexport var emptyRecord = {};\n// -------------------------------------------------------------------------------------\n// Record\n// -------------------------------------------------------------------------------------\n/** @internal */\nexport var has = Object.prototype.hasOwnProperty;\n// -------------------------------------------------------------------------------------\n// NonEmptyArray\n// -------------------------------------------------------------------------------------\n/** @internal */\nexport var fromReadonlyNonEmptyArray = function (as) { return __spreadArray([as[0]], as.slice(1), true); };\n/** @internal */\nexport var liftNullable = function (F) {\n    return function (f, onNullable) {\n        return function () {\n            var a = [];\n            for (var _i = 0; _i < arguments.length; _i++) {\n                a[_i] = arguments[_i];\n            }\n            var o = f.apply(void 0, a);\n            return F.fromEither(o == null ? left(onNullable.apply(void 0, a)) : right(o));\n        };\n    };\n};\n/** @internal */\nexport var liftOption = function (F) {\n    return function (f, onNone) {\n        return function () {\n            var a = [];\n            for (var _i = 0; _i < arguments.length; _i++) {\n                a[_i] = arguments[_i];\n            }\n            var o = f.apply(void 0, a);\n            return F.fromEither(isNone(o) ? left(onNone.apply(void 0, a)) : right(o.value));\n        };\n    };\n};\n/** @internal */\nexport var flatMapNullable = function (F, M) {\n    return /*#__PURE__*/ dual(3, function (self, f, onNullable) {\n        return M.flatMap(self, liftNullable(F)(f, onNullable));\n    });\n};\n/** @internal */\nexport var flatMapOption = function (F, M) {\n    return /*#__PURE__*/ dual(3, function (self, f, onNone) { return M.flatMap(self, liftOption(F)(f, onNone)); });\n};\n/** @internal */\nexport var flatMapEither = function (F, M) {\n    return /*#__PURE__*/ dual(2, function (self, f) {\n        return M.flatMap(self, function (a) { return F.fromEither(f(a)); });\n    });\n};\n/** @internal */\nexport var flatMapIO = function (F, M) {\n    return /*#__PURE__*/ dual(2, function (self, f) {\n        return M.flatMap(self, function (a) { return F.fromIO(f(a)); });\n    });\n};\n/** @internal */\nexport var flatMapTask = function (F, M) {\n    return /*#__PURE__*/ dual(2, function (self, f) {\n        return M.flatMap(self, function (a) { return F.fromTask(f(a)); });\n    });\n};\n/** @internal */\nexport var flatMapReader = function (F, M) {\n    return /*#__PURE__*/ dual(2, function (self, f) {\n        return M.flatMap(self, function (a) { return F.fromReader(f(a)); });\n    });\n};\n","/**\n * The `Apply` class provides the `ap` which is used to apply a function to an argument under a type constructor.\n *\n * `Apply` can be used to lift functions of two or more arguments to work on values wrapped with the type constructor\n * `f`.\n *\n * Instances must satisfy the following law in addition to the `Functor` laws:\n *\n * 1. Associative composition: `F.ap(F.ap(F.map(fbc, bc => ab => a => bc(ab(a))), fab), fa) <-> F.ap(fbc, F.ap(fab, fa))`\n *\n * Formally, `Apply` represents a strong lax semi-monoidal endofunctor.\n *\n * @example\n * import * as O from 'fp-ts/Option'\n * import { pipe } from 'fp-ts/function'\n *\n * const f = (a: string) => (b: number) => (c: boolean) => a + String(b) + String(c)\n * const fa: O.Option<string> = O.some('s')\n * const fb: O.Option<number> = O.some(1)\n * const fc: O.Option<boolean> = O.some(true)\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     // lift a function\n *     O.some(f),\n *     // apply the first argument\n *     O.ap(fa),\n *     // apply the second argument\n *     O.ap(fb),\n *     // apply the third argument\n *     O.ap(fc)\n *   ),\n *   O.some('s1true')\n * )\n *\n * @since 2.0.0\n */\nimport { tuple } from './function';\nimport * as _ from './internal';\nexport function ap(F, G) {\n    return function (fa) {\n        return function (fab) {\n            return F.ap(F.map(fab, function (gab) { return function (ga) { return G.ap(gab, ga); }; }), fa);\n        };\n    };\n}\nexport function apFirst(A) {\n    return function (second) { return function (first) {\n        return A.ap(A.map(first, function (a) { return function () { return a; }; }), second);\n    }; };\n}\nexport function apSecond(A) {\n    return function (second) {\n        return function (first) {\n            return A.ap(A.map(first, function () { return function (b) { return b; }; }), second);\n        };\n    };\n}\nexport function apS(F) {\n    return function (name, fb) {\n        return function (fa) {\n            return F.ap(F.map(fa, function (a) { return function (b) {\n                var _a;\n                return Object.assign({}, a, (_a = {}, _a[name] = b, _a));\n            }; }), fb);\n        };\n    };\n}\nexport function getApplySemigroup(F) {\n    return function (S) { return ({\n        concat: function (first, second) {\n            return F.ap(F.map(first, function (x) { return function (y) { return S.concat(x, y); }; }), second);\n        }\n    }); };\n}\nfunction curried(f, n, acc) {\n    return function (x) {\n        var combined = Array(acc.length + 1);\n        for (var i = 0; i < acc.length; i++) {\n            combined[i] = acc[i];\n        }\n        combined[acc.length] = x;\n        return n === 0 ? f.apply(null, combined) : curried(f, n - 1, combined);\n    };\n}\nvar tupleConstructors = {\n    1: function (a) { return [a]; },\n    2: function (a) { return function (b) { return [a, b]; }; },\n    3: function (a) { return function (b) { return function (c) { return [a, b, c]; }; }; },\n    4: function (a) { return function (b) { return function (c) { return function (d) { return [a, b, c, d]; }; }; }; },\n    5: function (a) { return function (b) { return function (c) { return function (d) { return function (e) { return [a, b, c, d, e]; }; }; }; }; }\n};\nfunction getTupleConstructor(len) {\n    if (!_.has.call(tupleConstructors, len)) {\n        tupleConstructors[len] = curried(tuple, len - 1, []);\n    }\n    return tupleConstructors[len];\n}\nexport function sequenceT(F) {\n    return function () {\n        var args = [];\n        for (var _i = 0; _i < arguments.length; _i++) {\n            args[_i] = arguments[_i];\n        }\n        var len = args.length;\n        var f = getTupleConstructor(len);\n        var fas = F.map(args[0], f);\n        for (var i = 1; i < len; i++) {\n            fas = F.ap(fas, args[i]);\n        }\n        return fas;\n    };\n}\nfunction getRecordConstructor(keys) {\n    var len = keys.length;\n    switch (len) {\n        case 1:\n            return function (a) {\n                var _a;\n                return (_a = {}, _a[keys[0]] = a, _a);\n            };\n        case 2:\n            return function (a) { return function (b) {\n                var _a;\n                return (_a = {}, _a[keys[0]] = a, _a[keys[1]] = b, _a);\n            }; };\n        case 3:\n            return function (a) { return function (b) { return function (c) {\n                var _a;\n                return (_a = {}, _a[keys[0]] = a, _a[keys[1]] = b, _a[keys[2]] = c, _a);\n            }; }; };\n        case 4:\n            return function (a) { return function (b) { return function (c) { return function (d) {\n                var _a;\n                return (_a = {},\n                    _a[keys[0]] = a,\n                    _a[keys[1]] = b,\n                    _a[keys[2]] = c,\n                    _a[keys[3]] = d,\n                    _a);\n            }; }; }; };\n        case 5:\n            return function (a) { return function (b) { return function (c) { return function (d) { return function (e) {\n                var _a;\n                return (_a = {},\n                    _a[keys[0]] = a,\n                    _a[keys[1]] = b,\n                    _a[keys[2]] = c,\n                    _a[keys[3]] = d,\n                    _a[keys[4]] = e,\n                    _a);\n            }; }; }; }; };\n        default:\n            return curried(function () {\n                var args = [];\n                for (var _i = 0; _i < arguments.length; _i++) {\n                    args[_i] = arguments[_i];\n                }\n                var r = {};\n                for (var i = 0; i < len; i++) {\n                    r[keys[i]] = args[i];\n                }\n                return r;\n            }, len - 1, []);\n    }\n}\nexport function sequenceS(F) {\n    return function (r) {\n        var keys = Object.keys(r);\n        var len = keys.length;\n        var f = getRecordConstructor(keys);\n        var fr = F.map(r[keys[0]], f);\n        for (var i = 1; i < len; i++) {\n            fr = F.ap(fr, r[keys[i]]);\n        }\n        return fr;\n    };\n}\n","/**\n * A `Functor` is a type constructor which supports a mapping operation `map`.\n *\n * `map` can be used to turn functions `a -> b` into functions `f a -> f b` whose argument and return types use the type\n * constructor `f` to represent some computational context.\n *\n * Instances must satisfy the following laws:\n *\n * 1. Identity: `F.map(fa, a => a) <-> fa`\n * 2. Composition: `F.map(fa, a => bc(ab(a))) <-> F.map(F.map(fa, ab), bc)`\n *\n * @since 2.0.0\n */\nimport { pipe } from './function';\nexport function map(F, G) {\n    return function (f) { return function (fa) { return F.map(fa, function (ga) { return G.map(ga, f); }); }; };\n}\nexport function flap(F) {\n    return function (a) { return function (fab) { return F.map(fab, function (f) { return f(a); }); }; };\n}\nexport function bindTo(F) {\n    return function (name) { return function (fa) { return F.map(fa, function (a) {\n        var _a;\n        return (_a = {}, _a[name] = a, _a);\n    }); }; };\n}\nfunction let_(F) {\n    return function (name, f) { return function (fa) { return F.map(fa, function (a) {\n        var _a;\n        return Object.assign({}, a, (_a = {}, _a[name] = f(a), _a));\n    }); }; };\n}\nexport { \n/**\n * @since 2.13.0\n */\nlet_ as let };\n/** @deprecated */\nexport function getFunctorComposition(F, G) {\n    var _map = map(F, G);\n    return {\n        map: function (fga, f) { return pipe(fga, _map(f)); }\n    };\n}\n/** @internal */\nexport function as(F) {\n    return function (self, b) { return F.map(self, function () { return b; }); };\n}\n/** @internal */\nexport function asUnit(F) {\n    var asM = as(F);\n    return function (self) { return asM(self, undefined); };\n}\n","export function chainFirst(M) {\n    var tapM = tap(M);\n    return function (f) { return function (first) { return tapM(first, f); }; };\n}\n/** @internal */\nexport function tap(M) {\n    return function (first, f) { return M.chain(first, function (a) { return M.map(f(a), function () { return a; }); }); };\n}\nexport function bind(M) {\n    return function (name, f) { return function (ma) { return M.chain(ma, function (a) { return M.map(f(a), function (b) {\n        var _a;\n        return Object.assign({}, a, (_a = {}, _a[name] = b, _a));\n    }); }); }; };\n}\n","import { getApplicativeMonoid } from './Applicative';\nimport { apFirst as apFirst_, apS as apS_, apSecond as apSecond_, getApplySemigroup as getApplySemigroup_ } from './Apply';\nimport * as chainable from './Chain';\nimport { tailRec } from './ChainRec';\nimport { chainOptionK as chainOptionK_, filterOrElse as filterOrElse_, fromOption as fromOption_, fromOptionK as fromOptionK_, fromPredicate as fromPredicate_ } from './FromEither';\nimport { dual, flow, identity, pipe } from './function';\nimport { as as as_, asUnit as asUnit_, bindTo as bindTo_, flap as flap_, let as let__ } from './Functor';\nimport * as _ from './internal';\nimport { separated } from './Separated';\nimport { wiltDefault, witherDefault } from './Witherable';\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n/**\n * Constructs a new `Either` holding a `Left` value. This usually represents a failure, due to the right-bias of this\n * structure.\n *\n * @category constructors\n * @since 2.0.0\n */\nexport var left = _.left;\n/**\n * Constructs a new `Either` holding a `Right` value. This usually represents a successful value due to the right bias\n * of this structure.\n *\n * @category constructors\n * @since 2.0.0\n */\nexport var right = _.right;\n/**\n * @category sequencing\n * @since 2.14.0\n */\nexport var flatMap = /*#__PURE__*/ dual(2, function (ma, f) { return (isLeft(ma) ? ma : f(ma.right)); });\nvar _map = function (fa, f) { return pipe(fa, map(f)); };\nvar _ap = function (fab, fa) { return pipe(fab, ap(fa)); };\n/* istanbul ignore next */\nvar _reduce = function (fa, b, f) { return pipe(fa, reduce(b, f)); };\n/* istanbul ignore next */\nvar _foldMap = function (M) { return function (fa, f) {\n    var foldMapM = foldMap(M);\n    return pipe(fa, foldMapM(f));\n}; };\n/* istanbul ignore next */\nvar _reduceRight = function (fa, b, f) { return pipe(fa, reduceRight(b, f)); };\nvar _traverse = function (F) {\n    var traverseF = traverse(F);\n    return function (ta, f) { return pipe(ta, traverseF(f)); };\n};\nvar _bimap = function (fa, f, g) { return pipe(fa, bimap(f, g)); };\nvar _mapLeft = function (fa, f) { return pipe(fa, mapLeft(f)); };\n/* istanbul ignore next */\nvar _alt = function (fa, that) { return pipe(fa, alt(that)); };\n/* istanbul ignore next */\nvar _extend = function (wa, f) { return pipe(wa, extend(f)); };\nvar _chainRec = function (a, f) {\n    return tailRec(f(a), function (e) {\n        return isLeft(e) ? right(left(e.left)) : isLeft(e.right) ? left(f(e.right.left)) : right(right(e.right.right));\n    });\n};\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport var URI = 'Either';\n/**\n * @category instances\n * @since 2.0.0\n */\nexport var getShow = function (SE, SA) { return ({\n    show: function (ma) { return (isLeft(ma) ? \"left(\".concat(SE.show(ma.left), \")\") : \"right(\".concat(SA.show(ma.right), \")\")); }\n}); };\n/**\n * @category instances\n * @since 2.0.0\n */\nexport var getEq = function (EL, EA) { return ({\n    equals: function (x, y) {\n        return x === y || (isLeft(x) ? isLeft(y) && EL.equals(x.left, y.left) : isRight(y) && EA.equals(x.right, y.right));\n    }\n}); };\n/**\n * Semigroup returning the left-most non-`Left` value. If both operands are `Right`s then the inner values are\n * concatenated using the provided `Semigroup`\n *\n * @example\n * import { getSemigroup, left, right } from 'fp-ts/Either'\n * import { SemigroupSum } from 'fp-ts/number'\n *\n * const S = getSemigroup<string, number>(SemigroupSum)\n * assert.deepStrictEqual(S.concat(left('a'), left('b')), left('a'))\n * assert.deepStrictEqual(S.concat(left('a'), right(2)), right(2))\n * assert.deepStrictEqual(S.concat(right(1), left('b')), right(1))\n * assert.deepStrictEqual(S.concat(right(1), right(2)), right(3))\n *\n * @category instances\n * @since 2.0.0\n */\nexport var getSemigroup = function (S) { return ({\n    concat: function (x, y) { return (isLeft(y) ? x : isLeft(x) ? y : right(S.concat(x.right, y.right))); }\n}); };\n/**\n * Builds a `Compactable` instance for `Either` given `Monoid` for the left side.\n *\n * @category filtering\n * @since 2.10.0\n */\nexport var getCompactable = function (M) {\n    var empty = left(M.empty);\n    return {\n        URI: URI,\n        _E: undefined,\n        compact: function (ma) { return (isLeft(ma) ? ma : ma.right._tag === 'None' ? empty : right(ma.right.value)); },\n        separate: function (ma) {\n            return isLeft(ma)\n                ? separated(ma, ma)\n                : isLeft(ma.right)\n                    ? separated(right(ma.right.left), empty)\n                    : separated(empty, right(ma.right.right));\n        }\n    };\n};\n/**\n * Builds a `Filterable` instance for `Either` given `Monoid` for the left side\n *\n * @category filtering\n * @since 2.10.0\n */\nexport var getFilterable = function (M) {\n    var empty = left(M.empty);\n    var _a = getCompactable(M), compact = _a.compact, separate = _a.separate;\n    var filter = function (ma, predicate) {\n        return isLeft(ma) ? ma : predicate(ma.right) ? ma : empty;\n    };\n    var partition = function (ma, p) {\n        return isLeft(ma)\n            ? separated(ma, ma)\n            : p(ma.right)\n                ? separated(empty, right(ma.right))\n                : separated(right(ma.right), empty);\n    };\n    return {\n        URI: URI,\n        _E: undefined,\n        map: _map,\n        compact: compact,\n        separate: separate,\n        filter: filter,\n        filterMap: function (ma, f) {\n            if (isLeft(ma)) {\n                return ma;\n            }\n            var ob = f(ma.right);\n            return ob._tag === 'None' ? empty : right(ob.value);\n        },\n        partition: partition,\n        partitionMap: function (ma, f) {\n            if (isLeft(ma)) {\n                return separated(ma, ma);\n            }\n            var e = f(ma.right);\n            return isLeft(e) ? separated(right(e.left), empty) : separated(empty, right(e.right));\n        }\n    };\n};\n/**\n * Builds `Witherable` instance for `Either` given `Monoid` for the left side\n *\n * @category filtering\n * @since 2.0.0\n */\nexport var getWitherable = function (M) {\n    var F_ = getFilterable(M);\n    var C = getCompactable(M);\n    return {\n        URI: URI,\n        _E: undefined,\n        map: _map,\n        compact: F_.compact,\n        separate: F_.separate,\n        filter: F_.filter,\n        filterMap: F_.filterMap,\n        partition: F_.partition,\n        partitionMap: F_.partitionMap,\n        traverse: _traverse,\n        sequence: sequence,\n        reduce: _reduce,\n        foldMap: _foldMap,\n        reduceRight: _reduceRight,\n        wither: witherDefault(Traversable, C),\n        wilt: wiltDefault(Traversable, C)\n    };\n};\n/**\n * The default [`Applicative`](#applicative) instance returns the first error, if you want to\n * get all errors you need to provide a way to concatenate them via a `Semigroup`.\n *\n * @example\n * import * as A from 'fp-ts/Apply'\n * import * as E from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n * import * as S from 'fp-ts/Semigroup'\n * import * as string from 'fp-ts/string'\n *\n * const parseString = (u: unknown): E.Either<string, string> =>\n *   typeof u === 'string' ? E.right(u) : E.left('not a string')\n *\n * const parseNumber = (u: unknown): E.Either<string, number> =>\n *   typeof u === 'number' ? E.right(u) : E.left('not a number')\n *\n * interface Person {\n *   readonly name: string\n *   readonly age: number\n * }\n *\n * const parsePerson = (\n *   input: Record<string, unknown>\n * ): E.Either<string, Person> =>\n *   pipe(\n *     E.Do,\n *     E.apS('name', parseString(input.name)),\n *     E.apS('age', parseNumber(input.age))\n *   )\n *\n * assert.deepStrictEqual(parsePerson({}), E.left('not a string')) // <= first error\n *\n * const Applicative = E.getApplicativeValidation(\n *   pipe(string.Semigroup, S.intercalate(', '))\n * )\n *\n * const apS = A.apS(Applicative)\n *\n * const parsePersonAll = (\n *   input: Record<string, unknown>\n * ): E.Either<string, Person> =>\n *   pipe(\n *     E.Do,\n *     apS('name', parseString(input.name)),\n *     apS('age', parseNumber(input.age))\n *   )\n *\n * assert.deepStrictEqual(parsePersonAll({}), E.left('not a string, not a number')) // <= all errors\n *\n * @category error handling\n * @since 2.7.0\n */\nexport var getApplicativeValidation = function (SE) { return ({\n    URI: URI,\n    _E: undefined,\n    map: _map,\n    ap: function (fab, fa) {\n        return isLeft(fab)\n            ? isLeft(fa)\n                ? left(SE.concat(fab.left, fa.left))\n                : fab\n            : isLeft(fa)\n                ? fa\n                : right(fab.right(fa.right));\n    },\n    of: of\n}); };\n/**\n * The default [`Alt`](#alt) instance returns the last error, if you want to\n * get all errors you need to provide a way to concatenate them via a `Semigroup`.\n *\n * @example\n * import * as E from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n * import * as S from 'fp-ts/Semigroup'\n * import * as string from 'fp-ts/string'\n *\n * const parseString = (u: unknown): E.Either<string, string> =>\n *   typeof u === 'string' ? E.right(u) : E.left('not a string')\n *\n * const parseNumber = (u: unknown): E.Either<string, number> =>\n *   typeof u === 'number' ? E.right(u) : E.left('not a number')\n *\n * const parse = (u: unknown): E.Either<string, string | number> =>\n *   pipe(\n *     parseString(u),\n *     E.alt<string, string | number>(() => parseNumber(u))\n *   )\n *\n * assert.deepStrictEqual(parse(true), E.left('not a number')) // <= last error\n *\n * const Alt = E.getAltValidation(pipe(string.Semigroup, S.intercalate(', ')))\n *\n * const parseAll = (u: unknown): E.Either<string, string | number> =>\n *   Alt.alt<string | number>(parseString(u), () => parseNumber(u))\n *\n * assert.deepStrictEqual(parseAll(true), E.left('not a string, not a number')) // <= all errors\n *\n * @category error handling\n * @since 2.7.0\n */\nexport var getAltValidation = function (SE) { return ({\n    URI: URI,\n    _E: undefined,\n    map: _map,\n    alt: function (me, that) {\n        if (isRight(me)) {\n            return me;\n        }\n        var ea = that();\n        return isLeft(ea) ? left(SE.concat(me.left, ea.left)) : ea;\n    }\n}); };\n/**\n * @category mapping\n * @since 2.0.0\n */\nexport var map = function (f) { return function (fa) {\n    return isLeft(fa) ? fa : right(f(fa.right));\n}; };\n/**\n * @category instances\n * @since 2.7.0\n */\nexport var Functor = {\n    URI: URI,\n    map: _map\n};\n/**\n * Maps the `Right` value of this `Either` to the specified constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport var as = dual(2, as_(Functor));\n/**\n * Maps the `Right` value of this `Either` to the void constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport var asUnit = asUnit_(Functor);\n/**\n * @category constructors\n * @since 2.7.0\n */\nexport var of = right;\n/**\n * @category instances\n * @since 2.10.0\n */\nexport var Pointed = {\n    URI: URI,\n    of: of\n};\n/**\n * Less strict version of [`ap`](#ap).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @since 2.8.0\n */\nexport var apW = function (fa) { return function (fab) {\n    return isLeft(fab) ? fab : isLeft(fa) ? fa : right(fab.right(fa.right));\n}; };\n/**\n * @since 2.0.0\n */\nexport var ap = apW;\n/**\n * @category instances\n * @since 2.10.0\n */\nexport var Apply = {\n    URI: URI,\n    map: _map,\n    ap: _ap\n};\n/**\n * @category instances\n * @since 2.7.0\n */\nexport var Applicative = {\n    URI: URI,\n    map: _map,\n    ap: _ap,\n    of: of\n};\n/**\n * @category instances\n * @since 2.10.0\n */\nexport var Chain = {\n    URI: URI,\n    map: _map,\n    ap: _ap,\n    chain: flatMap\n};\n/**\n * @category instances\n * @since 2.7.0\n */\nexport var Monad = {\n    URI: URI,\n    map: _map,\n    ap: _ap,\n    of: of,\n    chain: flatMap\n};\n/**\n * Left-associative fold of a structure.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as E from 'fp-ts/Either'\n *\n * const startWith = 'prefix'\n * const concat = (a: string, b: string) => `${a}:${b}`\n *\n * assert.deepStrictEqual(\n *   pipe(E.right('a'), E.reduce(startWith, concat)),\n *   'prefix:a'\n * )\n *\n * assert.deepStrictEqual(\n *   pipe(E.left('e'), E.reduce(startWith, concat)),\n *   'prefix'\n * )\n *\n * @category folding\n * @since 2.0.0\n */\nexport var reduce = function (b, f) { return function (fa) {\n    return isLeft(fa) ? b : f(b, fa.right);\n}; };\n/**\n * Map each element of the structure to a monoid, and combine the results.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as E from 'fp-ts/Either'\n * import * as S from 'fp-ts/string'\n *\n * const yell = (a: string) => `${a}!`\n *\n * assert.deepStrictEqual(\n *   pipe(E.right('a'), E.foldMap(S.Monoid)(yell)),\n *   'a!'\n * )\n *\n * assert.deepStrictEqual(\n *   pipe(E.left('e'), E.foldMap(S.Monoid)(yell)),\n *   S.Monoid.empty\n * )\n *\n * @category folding\n * @since 2.0.0\n */\nexport var foldMap = function (M) { return function (f) { return function (fa) {\n    return isLeft(fa) ? M.empty : f(fa.right);\n}; }; };\n/**\n * Right-associative fold of a structure.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as E from 'fp-ts/Either'\n *\n * const startWith = 'postfix'\n * const concat = (a: string, b: string) => `${a}:${b}`\n *\n * assert.deepStrictEqual(\n *   pipe(E.right('a'), E.reduceRight(startWith, concat)),\n *   'a:postfix'\n * )\n *\n * assert.deepStrictEqual(\n *   pipe(E.left('e'), E.reduceRight(startWith, concat)),\n *   'postfix'\n * )\n *\n * @category folding\n * @since 2.0.0\n */\nexport var reduceRight = function (b, f) { return function (fa) {\n    return isLeft(fa) ? b : f(fa.right, b);\n}; };\n/**\n * @category instances\n * @since 2.7.0\n */\nexport var Foldable = {\n    URI: URI,\n    reduce: _reduce,\n    foldMap: _foldMap,\n    reduceRight: _reduceRight\n};\n/**\n * Map each element of a structure to an action, evaluate these actions from left to right, and collect the results.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as RA from 'fp-ts/ReadonlyArray'\n * import * as E from 'fp-ts/Either'\n * import * as O from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(\n *   pipe(E.right(['a']), E.traverse(O.Applicative)(RA.head)),\n *   O.some(E.right('a'))\n *  )\n *\n * assert.deepStrictEqual(\n *   pipe(E.right([]), E.traverse(O.Applicative)(RA.head)),\n *   O.none\n * )\n *\n * @category traversing\n * @since 2.6.3\n */\nexport var traverse = function (F) {\n    return function (f) {\n        return function (ta) {\n            return isLeft(ta) ? F.of(left(ta.left)) : F.map(f(ta.right), right);\n        };\n    };\n};\n/**\n * Evaluate each monadic action in the structure from left to right, and collect the results.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as E from 'fp-ts/Either'\n * import * as O from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(\n *   pipe(E.right(O.some('a')), E.sequence(O.Applicative)),\n *   O.some(E.right('a'))\n *  )\n *\n * assert.deepStrictEqual(\n *   pipe(E.right(O.none), E.sequence(O.Applicative)),\n *   O.none\n * )\n *\n * @category traversing\n * @since 2.6.3\n */\nexport var sequence = function (F) {\n    return function (ma) {\n        return isLeft(ma) ? F.of(left(ma.left)) : F.map(ma.right, right);\n    };\n};\n/**\n * @category instances\n * @since 2.7.0\n */\nexport var Traversable = {\n    URI: URI,\n    map: _map,\n    reduce: _reduce,\n    foldMap: _foldMap,\n    reduceRight: _reduceRight,\n    traverse: _traverse,\n    sequence: sequence\n};\n/**\n * Map a pair of functions over the two type arguments of the bifunctor.\n *\n * @category mapping\n * @since 2.0.0\n */\nexport var bimap = function (f, g) { return function (fa) {\n    return isLeft(fa) ? left(f(fa.left)) : right(g(fa.right));\n}; };\n/**\n * Map a function over the first type argument of a bifunctor.\n *\n * @category error handling\n * @since 2.0.0\n */\nexport var mapLeft = function (f) { return function (fa) {\n    return isLeft(fa) ? left(f(fa.left)) : fa;\n}; };\n/**\n * @category instances\n * @since 2.7.0\n */\nexport var Bifunctor = {\n    URI: URI,\n    bimap: _bimap,\n    mapLeft: _mapLeft\n};\n/**\n * Less strict version of [`alt`](#alt).\n *\n * The `W` suffix (short for **W**idening) means that the error and the return types will be merged.\n *\n * @category error handling\n * @since 2.9.0\n */\nexport var altW = function (that) { return function (fa) {\n    return isLeft(fa) ? that() : fa;\n}; };\n/**\n * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to\n * types of kind `* -> *`.\n *\n * In case of `Either` returns the left-most non-`Left` value (or the right-most `Left` value if both values are `Left`).\n *\n * | x        | y        | pipe(x, alt(() => y) |\n * | -------- | -------- | -------------------- |\n * | left(a)  | left(b)  | left(b)              |\n * | left(a)  | right(2) | right(2)             |\n * | right(1) | left(b)  | right(1)             |\n * | right(1) | right(2) | right(1)             |\n *\n * @example\n * import * as E from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     E.left('a'),\n *     E.alt(() => E.left('b'))\n *   ),\n *   E.left('b')\n * )\n * assert.deepStrictEqual(\n *   pipe(\n *     E.left('a'),\n *     E.alt(() => E.right(2))\n *   ),\n *   E.right(2)\n * )\n * assert.deepStrictEqual(\n *   pipe(\n *     E.right(1),\n *     E.alt(() => E.left('b'))\n *   ),\n *   E.right(1)\n * )\n * assert.deepStrictEqual(\n *   pipe(\n *     E.right(1),\n *     E.alt(() => E.right(2))\n *   ),\n *   E.right(1)\n * )\n *\n * @category error handling\n * @since 2.0.0\n */\nexport var alt = altW;\n/**\n * @category instances\n * @since 2.7.0\n */\nexport var Alt = {\n    URI: URI,\n    map: _map,\n    alt: _alt\n};\n/**\n * @since 2.0.0\n */\nexport var extend = function (f) { return function (wa) {\n    return isLeft(wa) ? wa : right(f(wa));\n}; };\n/**\n * @category instances\n * @since 2.7.0\n */\nexport var Extend = {\n    URI: URI,\n    map: _map,\n    extend: _extend\n};\n/**\n * @category instances\n * @since 2.7.0\n */\nexport var ChainRec = {\n    URI: URI,\n    map: _map,\n    ap: _ap,\n    chain: flatMap,\n    chainRec: _chainRec\n};\n/**\n * @since 2.6.3\n */\nexport var throwError = left;\n/**\n * @category instances\n * @since 2.7.0\n */\nexport var MonadThrow = {\n    URI: URI,\n    map: _map,\n    ap: _ap,\n    of: of,\n    chain: flatMap,\n    throwError: throwError\n};\n/**\n * @category instances\n * @since 2.10.0\n */\nexport var FromEither = {\n    URI: URI,\n    fromEither: identity\n};\n/**\n * @example\n * import { fromPredicate, left, right } from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     1,\n *     fromPredicate(\n *       (n) => n > 0,\n *       () => 'error'\n *     )\n *   ),\n *   right(1)\n * )\n * assert.deepStrictEqual(\n *   pipe(\n *     -1,\n *     fromPredicate(\n *       (n) => n > 0,\n *       () => 'error'\n *     )\n *   ),\n *   left('error')\n * )\n *\n * @category lifting\n * @since 2.0.0\n */\nexport var fromPredicate = /*#__PURE__*/ fromPredicate_(FromEither);\n// -------------------------------------------------------------------------------------\n// conversions\n// -------------------------------------------------------------------------------------\n/**\n * @example\n * import * as E from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n * import * as O from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     O.some(1),\n *     E.fromOption(() => 'error')\n *   ),\n *   E.right(1)\n * )\n * assert.deepStrictEqual(\n *   pipe(\n *     O.none,\n *     E.fromOption(() => 'error')\n *   ),\n *   E.left('error')\n * )\n *\n * @category conversions\n * @since 2.0.0\n */\nexport var fromOption = \n/*#__PURE__*/ fromOption_(FromEither);\n// -------------------------------------------------------------------------------------\n// refinements\n// -------------------------------------------------------------------------------------\n/**\n * Returns `true` if the either is an instance of `Left`, `false` otherwise.\n *\n * @category refinements\n * @since 2.0.0\n */\nexport var isLeft = _.isLeft;\n/**\n * Returns `true` if the either is an instance of `Right`, `false` otherwise.\n *\n * @category refinements\n * @since 2.0.0\n */\nexport var isRight = _.isRight;\n/**\n * Less strict version of [`match`](#match).\n *\n * The `W` suffix (short for **W**idening) means that the handler return types will be merged.\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport var matchW = function (onLeft, onRight) {\n    return function (ma) {\n        return isLeft(ma) ? onLeft(ma.left) : onRight(ma.right);\n    };\n};\n/**\n * Alias of [`matchW`](#matchw).\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport var foldW = matchW;\n/**\n * Takes two functions and an `Either` value, if the value is a `Left` the inner value is applied to the first function,\n * if the value is a `Right` the inner value is applied to the second function.\n *\n * @example\n * import { match, left, right } from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n *\n * function onLeft(errors: Array<string>): string {\n *   return `Errors: ${errors.join(', ')}`\n * }\n *\n * function onRight(value: number): string {\n *   return `Ok: ${value}`\n * }\n *\n * assert.strictEqual(\n *   pipe(\n *     right(1),\n *     match(onLeft, onRight)\n *   ),\n *   'Ok: 1'\n * )\n * assert.strictEqual(\n *   pipe(\n *     left(['error 1', 'error 2']),\n *     match(onLeft, onRight)\n *   ),\n *   'Errors: error 1, error 2'\n * )\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport var match = matchW;\n/**\n * Alias of [`match`](#match).\n *\n * @category pattern matching\n * @since 2.0.0\n */\nexport var fold = match;\n/**\n * Less strict version of [`getOrElse`](#getorelse).\n *\n * The `W` suffix (short for **W**idening) means that the handler return type will be merged.\n *\n * @category error handling\n * @since 2.6.0\n */\nexport var getOrElseW = function (onLeft) {\n    return function (ma) {\n        return isLeft(ma) ? onLeft(ma.left) : ma.right;\n    };\n};\n/**\n * Returns the wrapped value if it's a `Right` or a default value if is a `Left`.\n *\n * @example\n * import { getOrElse, left, right } from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     right(1),\n *     getOrElse(() => 0)\n *   ),\n *   1\n * )\n * assert.deepStrictEqual(\n *   pipe(\n *     left('error'),\n *     getOrElse(() => 0)\n *   ),\n *   0\n * )\n *\n * @category error handling\n * @since 2.0.0\n */\nexport var getOrElse = getOrElseW;\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport var flap = /*#__PURE__*/ flap_(Functor);\n/**\n * Combine two effectful actions, keeping only the result of the first.\n *\n * @since 2.0.0\n */\nexport var apFirst = /*#__PURE__*/ apFirst_(Apply);\n/**\n * Less strict version of [`apFirst`](#apfirst)\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @since 2.12.0\n */\nexport var apFirstW = apFirst;\n/**\n * Combine two effectful actions, keeping only the result of the second.\n *\n * @since 2.0.0\n */\nexport var apSecond = /*#__PURE__*/ apSecond_(Apply);\n/**\n * Less strict version of [`apSecond`](#apsecond)\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @since 2.12.0\n */\nexport var apSecondW = apSecond;\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.15.0\n */\nexport var tap = /*#__PURE__*/ dual(2, chainable.tap(Chain));\n/**\n * Less strict version of [`flatten`](#flatten).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category sequencing\n * @since 2.11.0\n */\nexport var flattenW = \n/*#__PURE__*/ flatMap(identity);\n/**\n * The `flatten` function is the conventional monad join operator. It is used to remove one level of monadic structure, projecting its bound argument into the outer level.\n *\n * @example\n * import * as E from 'fp-ts/Either'\n *\n * assert.deepStrictEqual(E.flatten(E.right(E.right('a'))), E.right('a'))\n * assert.deepStrictEqual(E.flatten(E.right(E.left('e'))), E.left('e'))\n * assert.deepStrictEqual(E.flatten(E.left('e')), E.left('e'))\n *\n * @category sequencing\n * @since 2.0.0\n */\nexport var flatten = flattenW;\n/**\n * @since 2.0.0\n */\nexport var duplicate = /*#__PURE__*/ extend(identity);\n/**\n * Use `liftOption`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport var fromOptionK = \n/*#__PURE__*/ fromOptionK_(FromEither);\n/**\n * Use `flatMapOption`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport var chainOptionK = /*#__PURE__*/ chainOptionK_(FromEither, Chain);\n/**\n * Use `flatMapOption`.\n *\n * @category legacy\n * @since 2.13.2\n */\nexport var chainOptionKW = chainOptionK;\n/** @internal */\nvar _FromEither = {\n    fromEither: FromEither.fromEither\n};\n/**\n * @category lifting\n * @since 2.15.0\n */\nexport var liftNullable = /*#__PURE__*/ _.liftNullable(_FromEither);\n/**\n * @category lifting\n * @since 2.15.0\n */\nexport var liftOption = /*#__PURE__*/ _.liftOption(_FromEither);\n/** @internal */\nvar _FlatMap = {\n    flatMap: flatMap\n};\n/**\n * @category sequencing\n * @since 2.15.0\n */\nexport var flatMapNullable = /*#__PURE__*/ _.flatMapNullable(_FromEither, _FlatMap);\n/**\n * @category sequencing\n * @since 2.15.0\n */\nexport var flatMapOption = /*#__PURE__*/ _.flatMapOption(_FromEither, _FlatMap);\n/**\n * @example\n * import * as E from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     E.right(1),\n *     E.filterOrElse(\n *       (n) => n > 0,\n *       () => 'error'\n *     )\n *   ),\n *   E.right(1)\n * )\n * assert.deepStrictEqual(\n *   pipe(\n *     E.right(-1),\n *     E.filterOrElse(\n *       (n) => n > 0,\n *       () => 'error'\n *     )\n *   ),\n *   E.left('error')\n * )\n * assert.deepStrictEqual(\n *   pipe(\n *     E.left('a'),\n *     E.filterOrElse(\n *       (n) => n > 0,\n *       () => 'error'\n *     )\n *   ),\n *   E.left('a')\n * )\n *\n * @category filtering\n * @since 2.0.0\n */\nexport var filterOrElse = /*#__PURE__*/ filterOrElse_(FromEither, Chain);\n/**\n * Less strict version of [`filterOrElse`](#filterorelse).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category filtering\n * @since 2.9.0\n */\nexport var filterOrElseW = filterOrElse;\n/**\n * Returns a `Right` if is a `Left` (and vice versa).\n *\n * @since 2.0.0\n */\nexport var swap = function (ma) { return (isLeft(ma) ? right(ma.left) : left(ma.right)); };\n/**\n * Less strict version of [`orElse`](#orelse).\n *\n * The `W` suffix (short for **W**idening) means that the return types will be merged.\n *\n * @category error handling\n * @since 2.10.0\n */\nexport var orElseW = function (onLeft) {\n    return function (ma) {\n        return isLeft(ma) ? onLeft(ma.left) : ma;\n    };\n};\n/**\n * Useful for recovering from errors.\n *\n * @category error handling\n * @since 2.0.0\n */\nexport var orElse = orElseW;\n/**\n * Takes a default and a nullable value, if the value is not nully, turn it into a `Right`, if the value is nully use\n * the provided default as a `Left`.\n *\n * @example\n * import { fromNullable, left, right } from 'fp-ts/Either'\n *\n * const parse = fromNullable('nully')\n *\n * assert.deepStrictEqual(parse(1), right(1))\n * assert.deepStrictEqual(parse(null), left('nully'))\n *\n * @category conversions\n * @since 2.0.0\n */\nexport var fromNullable = function (e) {\n    return function (a) {\n        return a == null ? left(e) : right(a);\n    };\n};\n/**\n * Constructs a new `Either` from a function that might throw.\n *\n * See also [`tryCatchK`](#trycatchk).\n *\n * @example\n * import * as E from 'fp-ts/Either'\n *\n * const unsafeHead = <A>(as: ReadonlyArray<A>): A => {\n *   if (as.length > 0) {\n *     return as[0]\n *   } else {\n *     throw new Error('empty array')\n *   }\n * }\n *\n * const head = <A>(as: ReadonlyArray<A>): E.Either<Error, A> =>\n *   E.tryCatch(() => unsafeHead(as), e => (e instanceof Error ? e : new Error('unknown error')))\n *\n * assert.deepStrictEqual(head([]), E.left(new Error('empty array')))\n * assert.deepStrictEqual(head([1, 2, 3]), E.right(1))\n *\n * @category interop\n * @since 2.0.0\n */\nexport var tryCatch = function (f, onThrow) {\n    try {\n        return right(f());\n    }\n    catch (e) {\n        return left(onThrow(e));\n    }\n};\n/**\n * Converts a function that may throw to one returning a `Either`.\n *\n * @category interop\n * @since 2.10.0\n */\nexport var tryCatchK = function (f, onThrow) {\n    return function () {\n        var a = [];\n        for (var _i = 0; _i < arguments.length; _i++) {\n            a[_i] = arguments[_i];\n        }\n        return tryCatch(function () { return f.apply(void 0, a); }, onThrow);\n    };\n};\n/**\n * Use `liftNullable`.\n *\n * @category legacy\n * @since 2.9.0\n */\nexport var fromNullableK = function (e) {\n    var from = fromNullable(e);\n    return function (f) { return flow(f, from); };\n};\n/**\n * Use `flatMapNullable`.\n *\n * @category legacy\n * @since 2.9.0\n */\nexport var chainNullableK = function (e) {\n    var from = fromNullableK(e);\n    return function (f) { return flatMap(from(f)); };\n};\n/**\n * @category conversions\n * @since 2.10.0\n */\nexport var toUnion = /*#__PURE__*/ foldW(identity, identity);\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n/**\n * Default value for the `onError` argument of `tryCatch`\n *\n * @since 2.0.0\n */\nexport function toError(e) {\n    try {\n        return e instanceof Error ? e : new Error(String(e));\n    }\n    catch (error) {\n        return new Error();\n    }\n}\nexport function elem(E) {\n    return function (a, ma) {\n        if (ma === undefined) {\n            var elemE_1 = elem(E);\n            return function (ma) { return elemE_1(a, ma); };\n        }\n        return isLeft(ma) ? false : E.equals(a, ma.right);\n    };\n}\n/**\n * Returns `false` if `Left` or returns the result of the application of the given predicate to the `Right` value.\n *\n * @example\n * import { exists, left, right } from 'fp-ts/Either'\n *\n * const gt2 = exists((n: number) => n > 2)\n *\n * assert.strictEqual(gt2(left('a')), false)\n * assert.strictEqual(gt2(right(1)), false)\n * assert.strictEqual(gt2(right(3)), true)\n *\n * @since 2.0.0\n */\nexport var exists = function (predicate) {\n    return function (ma) {\n        return isLeft(ma) ? false : predicate(ma.right);\n    };\n};\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n/**\n * @category do notation\n * @since 2.9.0\n */\nexport var Do = /*#__PURE__*/ of(_.emptyRecord);\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport var bindTo = /*#__PURE__*/ bindTo_(Functor);\nvar let_ = /*#__PURE__*/ let__(Functor);\nexport { \n/**\n * @category do notation\n * @since 2.13.0\n */\nlet_ as let };\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport var bind = /*#__PURE__*/ chainable.bind(Chain);\n/**\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category do notation\n * @since 2.8.0\n */\nexport var bindW = bind;\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport var apS = /*#__PURE__*/ apS_(Apply);\n/**\n * Less strict version of [`apS`](#aps).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category do notation\n * @since 2.8.0\n */\nexport var apSW = apS;\n/**\n * @since 2.11.0\n */\nexport var ApT = /*#__PURE__*/ of(_.emptyReadonlyArray);\n// -------------------------------------------------------------------------------------\n// array utils\n// -------------------------------------------------------------------------------------\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport var traverseReadonlyNonEmptyArrayWithIndex = function (f) {\n    return function (as) {\n        var e = f(0, _.head(as));\n        if (isLeft(e)) {\n            return e;\n        }\n        var out = [e.right];\n        for (var i = 1; i < as.length; i++) {\n            var e_1 = f(i, as[i]);\n            if (isLeft(e_1)) {\n                return e_1;\n            }\n            out.push(e_1.right);\n        }\n        return right(out);\n    };\n};\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport var traverseReadonlyArrayWithIndex = function (f) {\n    var g = traverseReadonlyNonEmptyArrayWithIndex(f);\n    return function (as) { return (_.isNonEmpty(as) ? g(as) : ApT); };\n};\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport var traverseArrayWithIndex = traverseReadonlyArrayWithIndex;\n/**\n * Equivalent to `ReadonlyArray#traverse(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport var traverseArray = function (f) { return traverseReadonlyArrayWithIndex(function (_, a) { return f(a); }); };\n/**\n * Equivalent to `ReadonlyArray#sequence(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport var sequenceArray = \n/*#__PURE__*/ traverseArray(identity);\n// -------------------------------------------------------------------------------------\n// legacy\n// -------------------------------------------------------------------------------------\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.6.0\n */\nexport var chainW = flatMap;\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport var chain = flatMap;\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport var chainFirst = tap;\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.8.0\n */\nexport var chainFirstW = tap;\n/**\n * Use [`parse`](./Json.ts.html#parse) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function parseJSON(s, onError) {\n    return tryCatch(function () { return JSON.parse(s); }, onError);\n}\n/**\n * Use [`stringify`](./Json.ts.html#stringify) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport var stringifyJSON = function (u, onError) {\n    return tryCatch(function () {\n        var s = JSON.stringify(u);\n        if (typeof s !== 'string') {\n            throw new Error('Converting unsupported structure to JSON');\n        }\n        return s;\n    }, onError);\n};\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `E.Functor` instead of `E.either`\n * (where `E` is from `import E from 'fp-ts/Either'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport var either = {\n    URI: URI,\n    map: _map,\n    of: of,\n    ap: _ap,\n    chain: flatMap,\n    reduce: _reduce,\n    foldMap: _foldMap,\n    reduceRight: _reduceRight,\n    traverse: _traverse,\n    sequence: sequence,\n    bimap: _bimap,\n    mapLeft: _mapLeft,\n    alt: _alt,\n    extend: _extend,\n    chainRec: _chainRec,\n    throwError: throwError\n};\n/**\n * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n *\n * Semigroup returning the left-most `Left` value. If both operands are `Right`s then the inner values\n * are concatenated using the provided `Semigroup`\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport var getApplySemigroup = \n/*#__PURE__*/ getApplySemigroup_(Apply);\n/**\n * Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport var getApplyMonoid = \n/*#__PURE__*/ getApplicativeMonoid(Applicative);\n/**\n * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport var getValidationSemigroup = function (SE, SA) {\n    return getApplySemigroup_(getApplicativeValidation(SE))(SA);\n};\n/**\n * Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport var getValidationMonoid = function (SE, MA) {\n    return getApplicativeMonoid(getApplicativeValidation(SE))(MA);\n};\n/**\n * Use [`getApplicativeValidation`](#getapplicativevalidation) and [`getAltValidation`](#getaltvalidation) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function getValidation(SE) {\n    var ap = getApplicativeValidation(SE).ap;\n    var alt = getAltValidation(SE).alt;\n    return {\n        URI: URI,\n        _E: undefined,\n        map: _map,\n        of: of,\n        chain: flatMap,\n        bimap: _bimap,\n        mapLeft: _mapLeft,\n        reduce: _reduce,\n        foldMap: _foldMap,\n        reduceRight: _reduceRight,\n        extend: _extend,\n        traverse: _traverse,\n        sequence: sequence,\n        chainRec: _chainRec,\n        throwError: throwError,\n        ap: ap,\n        alt: alt\n    };\n}\n","import type { MaybeAccessor } from '@/types.js';\n\nexport function access<T>(value: MaybeAccessor<T>): T {\n  return typeof value === 'function' ? (value as any)() as T : value;\n}\n","import { batch, computed, signal } from '@tma.js/signals';\nimport * as E from 'fp-ts/Either';\nimport { pipe } from 'fp-ts/function';\n\nimport { access } from '@/helpers/access.js';\nimport type { MaybeAccessor } from '@/types.js';\n\nexport interface MountableOptions<S, Err> {\n  /**\n   * A state to use if the `restoreState` function returned falsy value or\n   * `isPageReload` returned false.\n   */\n  initialState: S | (() => E.Either<Err, S>);\n  /**\n   * @returns True if the current page was reloaded.\n   */\n  isPageReload: MaybeAccessor<boolean>;\n  /**\n   * A function to call whenever the component was mounted.\n   * @param state - restored state.\n   */\n  onMounted?: (state: S) => void;\n  /**\n   * A function to call whenever the component was unmounted.\n   */\n  onUnmounted?: VoidFunction;\n  /**\n   * Attempts to restore previously saved component state. This function\n   * will only be called if the current page was reloaded.\n   */\n  restoreState: () => (S | undefined);\n}\n\nexport class Mountable<S extends object, Err = never> {\n  constructor({\n    onMounted,\n    restoreState,\n    initialState,\n    onUnmounted,\n    isPageReload,\n  }: MountableOptions<S, Err>) {\n    this.mount = () => {\n      if (this.isMounted()) {\n        return E.right(undefined);\n      }\n      const restored = access(isPageReload) ? restoreState() : undefined;\n      const state = restored\n        ? E.right(restored)\n        : (typeof initialState === 'function' ? initialState() : E.right(initialState));\n\n      return pipe(state, E.map(s => {\n        batch(() => {\n          this._isMounted.set(true);\n          onMounted?.(s);\n        });\n      }));\n    };\n\n    this.unmount = () => {\n      if (this._isMounted()) {\n        batch(() => {\n          this._isMounted.set(false);\n          onUnmounted?.();\n        });\n      }\n    };\n  }\n\n  private readonly _isMounted = signal(false);\n\n  /**\n   * Signal indicating if the component is mounted.\n   */\n  readonly isMounted = computed(this._isMounted);\n\n  /**\n   * Mounts the component restoring its state and calling required side effects.\n   */\n  readonly mount: () => E.Either<Err, void>;\n\n  /**\n   * Unmounts the component.\n   */\n  readonly unmount: () => void;\n}\n","import type { UnionRequiredKeys } from '@tma.js/toolkit';\n\ntype RemoveUndefined<T> = {\n  [K in UnionRequiredKeys<T>]-?: T[K]\n};\n\n/**\n * @returns Object with keys having undefined values.\n * @param value - an object to remove undefined values from.\n */\nexport function removeUndefined<T extends {}>(value: T): RemoveUndefined<T> {\n  const result = {} as RemoveUndefined<T>;\n  for (const k in value) {\n    const v = value[k];\n    v !== undefined && ((result as any)[k] = v);\n  }\n  return result;\n}\n","export function shallowEqual<T extends object>(a: T, b: T): boolean {\n  const aKeys = Object.keys(a);\n  const bKeys = Object.keys(b);\n  return aKeys.length !== bKeys.length\n    ? false\n    : aKeys.every(aKey => {\n      return Object.prototype.hasOwnProperty.call(b, aKey)\n        && (a as any)[aKey] === (b as any)[aKey];\n    });\n}\n","import { type Computed, computed, type Signal, signal } from '@tma.js/signals';\n\nimport { removeUndefined } from '@/helpers/removeUndefined.js';\nimport { shallowEqual } from '@/helpers/shallowEqual.js';\n\nexport interface StatefulOptions<S> {\n  /**\n   * The initial state.\n   */\n  initialState: S;\n  /**\n   * A function to call whenever the state changes.\n   * @param state - updated state.\n   */\n  onChange: (state: S) => void;\n}\n\nexport class Stateful<S extends object> {\n  constructor({ initialState, onChange }: StatefulOptions<S>) {\n    this._state = signal(initialState, { equals: shallowEqual });\n    this.state = computed(this._state);\n    this.state.sub(onChange);\n  }\n\n  protected readonly _state: Signal<S>;\n\n  /**\n   * The current state.\n   */\n  readonly state: Computed<S>;\n\n  /**\n   * Creates a computed signal based on the state.\n   * @param key - a state key to use as a source.\n   */\n  getter<K extends keyof S>(key: K): Computed<S[K]> {\n    return computed(() => this._state()[key]);\n  }\n\n  /**\n   * Updates the state.\n   * @param state - updates to apply.\n   */\n  readonly setState = (state: Partial<S>): void => {\n    const nextState = { ...this.state(), ...removeUndefined(state) };\n    if (!shallowEqual(nextState, this.state())) {\n      this._state.set(nextState);\n    }\n  };\n\n  /**\n   * @returns True if specified payload will update the state.\n   * @param state\n   */\n  hasDiff(state: Partial<S>): boolean {\n    return !shallowEqual({ ...this.state(), ...removeUndefined(state) }, this.state());\n  }\n}\n","import { type MethodName, supports } from '@tma.js/bridge';\nimport { type Computed, computed } from '@tma.js/signals';\nimport type { Version } from '@tma.js/types';\n\nimport { access } from '@/helpers/access.js';\nimport type { MaybeAccessor } from '@/types.js';\n\nexport function createIsSupportedSignal(\n  method: MethodName,\n  version: MaybeAccessor<Version>,\n): Computed<boolean> {\n  return computed(() => supports(method, access(version)));\n}\n","import { getApplicativeMonoid } from './Applicative';\nimport { apFirst as apFirst_, apS as apS_, apSecond as apSecond_, getApplySemigroup as getApplySemigroup_ } from './Apply';\nimport * as chainable from './Chain';\nimport { chainEitherK as chainEitherK_, fromEitherK as fromEitherK_, tapEither as tapEither_ } from './FromEither';\nimport { constNull, constUndefined, dual, flow, identity, pipe } from './function';\nimport { as as as_, asUnit as asUnit_, bindTo as bindTo_, flap as flap_, let as let__ } from './Functor';\nimport * as _ from './internal';\nimport { not } from './Predicate';\nimport { first, last } from './Semigroup';\nimport { separated } from './Separated';\nimport { wiltDefault, witherDefault } from './Witherable';\nimport { guard as guard_ } from './Zero';\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n/**\n * `None` doesn't have a constructor, instead you can use it directly as a value. Represents a missing value.\n *\n * @category constructors\n * @since 2.0.0\n */\nexport var none = _.none;\n/**\n * Constructs a `Some`. Represents an optional value that exists.\n *\n * @category constructors\n * @since 2.0.0\n */\nexport var some = _.some;\nexport function fromPredicate(predicate) {\n    return function (a) { return (predicate(a) ? some(a) : none); };\n}\n/**\n * Returns the `Left` value of an `Either` if possible.\n *\n * @example\n * import { getLeft, none, some } from 'fp-ts/Option'\n * import { right, left } from 'fp-ts/Either'\n *\n * assert.deepStrictEqual(getLeft(right(1)), none)\n * assert.deepStrictEqual(getLeft(left('a')), some('a'))\n *\n * @category constructors\n * @since 2.0.0\n */\nexport var getLeft = function (ma) { return (ma._tag === 'Right' ? none : some(ma.left)); };\n/**\n * Returns the `Right` value of an `Either` if possible.\n *\n * @example\n * import { getRight, none, some } from 'fp-ts/Option'\n * import { right, left } from 'fp-ts/Either'\n *\n * assert.deepStrictEqual(getRight(right(1)), some(1))\n * assert.deepStrictEqual(getRight(left('a')), none)\n *\n * @category constructors\n * @since 2.0.0\n */\nexport var getRight = function (ma) { return (ma._tag === 'Left' ? none : some(ma.right)); };\nvar _map = function (fa, f) { return pipe(fa, map(f)); };\nvar _ap = function (fab, fa) { return pipe(fab, ap(fa)); };\nvar _reduce = function (fa, b, f) { return pipe(fa, reduce(b, f)); };\nvar _foldMap = function (M) {\n    var foldMapM = foldMap(M);\n    return function (fa, f) { return pipe(fa, foldMapM(f)); };\n};\nvar _reduceRight = function (fa, b, f) { return pipe(fa, reduceRight(b, f)); };\nvar _traverse = function (F) {\n    var traverseF = traverse(F);\n    return function (ta, f) { return pipe(ta, traverseF(f)); };\n};\n/* istanbul ignore next */\nvar _alt = function (fa, that) { return pipe(fa, alt(that)); };\nvar _filter = function (fa, predicate) { return pipe(fa, filter(predicate)); };\n/* istanbul ignore next */\nvar _filterMap = function (fa, f) { return pipe(fa, filterMap(f)); };\n/* istanbul ignore next */\nvar _extend = function (wa, f) { return pipe(wa, extend(f)); };\n/* istanbul ignore next */\nvar _partition = function (fa, predicate) {\n    return pipe(fa, partition(predicate));\n};\n/* istanbul ignore next */\nvar _partitionMap = function (fa, f) { return pipe(fa, partitionMap(f)); };\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport var URI = 'Option';\n/**\n * @category instances\n * @since 2.0.0\n */\nexport var getShow = function (S) { return ({\n    show: function (ma) { return (isNone(ma) ? 'none' : \"some(\".concat(S.show(ma.value), \")\")); }\n}); };\n/**\n * @example\n * import { none, some, getEq } from 'fp-ts/Option'\n * import * as N from 'fp-ts/number'\n *\n * const E = getEq(N.Eq)\n * assert.strictEqual(E.equals(none, none), true)\n * assert.strictEqual(E.equals(none, some(1)), false)\n * assert.strictEqual(E.equals(some(1), none), false)\n * assert.strictEqual(E.equals(some(1), some(2)), false)\n * assert.strictEqual(E.equals(some(1), some(1)), true)\n *\n * @category instances\n * @since 2.0.0\n */\nexport var getEq = function (E) { return ({\n    equals: function (x, y) { return x === y || (isNone(x) ? isNone(y) : isNone(y) ? false : E.equals(x.value, y.value)); }\n}); };\n/**\n * The `Ord` instance allows `Option` values to be compared with\n * `compare`, whenever there is an `Ord` instance for\n * the type the `Option` contains.\n *\n * `None` is considered to be less than any `Some` value.\n *\n *\n * @example\n * import { none, some, getOrd } from 'fp-ts/Option'\n * import * as N from 'fp-ts/number'\n *\n * const O = getOrd(N.Ord)\n * assert.strictEqual(O.compare(none, none), 0)\n * assert.strictEqual(O.compare(none, some(1)), -1)\n * assert.strictEqual(O.compare(some(1), none), 1)\n * assert.strictEqual(O.compare(some(1), some(2)), -1)\n * assert.strictEqual(O.compare(some(1), some(1)), 0)\n *\n * @category instances\n * @since 2.0.0\n */\nexport var getOrd = function (O) { return ({\n    equals: getEq(O).equals,\n    compare: function (x, y) { return (x === y ? 0 : isSome(x) ? (isSome(y) ? O.compare(x.value, y.value) : 1) : isSome(y) ? -1 : 0); }\n}); };\n/**\n * Monoid returning the left-most non-`None` value. If both operands are `Some`s then the inner values are\n * concatenated using the provided `Semigroup`\n *\n * | x       | y       | concat(x, y)       |\n * | ------- | ------- | ------------------ |\n * | none    | none    | none               |\n * | some(a) | none    | some(a)            |\n * | none    | some(b) | some(b)            |\n * | some(a) | some(b) | some(concat(a, b)) |\n *\n * @example\n * import { getMonoid, some, none } from 'fp-ts/Option'\n * import { SemigroupSum } from 'fp-ts/number'\n *\n * const M = getMonoid(SemigroupSum)\n * assert.deepStrictEqual(M.concat(none, none), none)\n * assert.deepStrictEqual(M.concat(some(1), none), some(1))\n * assert.deepStrictEqual(M.concat(none, some(1)), some(1))\n * assert.deepStrictEqual(M.concat(some(1), some(2)), some(3))\n *\n * @category instances\n * @since 2.0.0\n */\nexport var getMonoid = function (S) { return ({\n    concat: function (x, y) { return (isNone(x) ? y : isNone(y) ? x : some(S.concat(x.value, y.value))); },\n    empty: none\n}); };\n/**\n * @category mapping\n * @since 2.0.0\n */\nexport var map = function (f) { return function (fa) {\n    return isNone(fa) ? none : some(f(fa.value));\n}; };\n/**\n * @category instances\n * @since 2.7.0\n */\nexport var Functor = {\n    URI: URI,\n    map: _map\n};\n/**\n * Maps the `Some` value of this `Option` to the specified constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport var as = dual(2, as_(Functor));\n/**\n * Maps the `Some` value of this `Option` to the void constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport var asUnit = asUnit_(Functor);\n/**\n * @category constructors\n * @since 2.7.0\n */\nexport var of = some;\n/**\n * @category instances\n * @since 2.10.0\n */\nexport var Pointed = {\n    URI: URI,\n    of: of\n};\n/**\n * @since 2.0.0\n */\nexport var ap = function (fa) { return function (fab) {\n    return isNone(fab) ? none : isNone(fa) ? none : some(fab.value(fa.value));\n}; };\n/**\n * @category instances\n * @since 2.10.0\n */\nexport var Apply = {\n    URI: URI,\n    map: _map,\n    ap: _ap\n};\n/**\n * @category instances\n * @since 2.7.0\n */\nexport var Applicative = {\n    URI: URI,\n    map: _map,\n    ap: _ap,\n    of: of\n};\n/**\n * @category sequencing\n * @since 2.14.0\n */\nexport var flatMap = /*#__PURE__*/ dual(2, function (ma, f) { return (isNone(ma) ? none : f(ma.value)); });\n/**\n * @category instances\n * @since 2.10.0\n */\nexport var Chain = {\n    URI: URI,\n    map: _map,\n    ap: _ap,\n    chain: flatMap\n};\n/**\n * @category instances\n * @since 2.7.0\n */\nexport var Monad = {\n    URI: URI,\n    map: _map,\n    ap: _ap,\n    of: of,\n    chain: flatMap\n};\n/**\n * @category folding\n * @since 2.0.0\n */\nexport var reduce = function (b, f) { return function (fa) {\n    return isNone(fa) ? b : f(b, fa.value);\n}; };\n/**\n * @category folding\n * @since 2.0.0\n */\nexport var foldMap = function (M) { return function (f) { return function (fa) {\n    return isNone(fa) ? M.empty : f(fa.value);\n}; }; };\n/**\n * @category folding\n * @since 2.0.0\n */\nexport var reduceRight = function (b, f) { return function (fa) {\n    return isNone(fa) ? b : f(fa.value, b);\n}; };\n/**\n * @category instances\n * @since 2.7.0\n */\nexport var Foldable = {\n    URI: URI,\n    reduce: _reduce,\n    foldMap: _foldMap,\n    reduceRight: _reduceRight\n};\n/**\n * Returns the provided `Option` `that` if `self` is `None`, otherwise returns `self`.\n *\n * @param self - The first `Option` to be checked.\n * @param that - The `Option` to return if `self` is `None`.\n *\n * @example\n * import * as O from \"fp-ts/Option\"\n *\n * assert.deepStrictEqual(O.orElse(O.none, () => O.none), O.none)\n * assert.deepStrictEqual(O.orElse(O.some(1), () => O.none), O.some(1))\n * assert.deepStrictEqual(O.orElse(O.none, () => O.some('b')), O.some('b'))\n * assert.deepStrictEqual(O.orElse(O.some(1), () => O.some('b')), O.some(1))\n *\n * @category error handling\n * @since 2.16.0\n */\nexport var orElse = dual(2, function (self, that) { return (isNone(self) ? that() : self); });\n/**\n * Alias of `orElse`.\n *\n * Less strict version of [`alt`](#alt).\n *\n * The `W` suffix (short for **W**idening) means that the return types will be merged.\n *\n * @category legacy\n * @since 2.9.0\n */\nexport var altW = orElse;\n/**\n * Alias of `orElse`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport var alt = orElse;\n/**\n * @category instances\n * @since 2.7.0\n */\nexport var Alt = {\n    URI: URI,\n    map: _map,\n    alt: _alt\n};\n/**\n * @since 2.7.0\n */\nexport var zero = function () { return none; };\n/**\n * @category instances\n * @since 2.11.0\n */\nexport var Zero = {\n    URI: URI,\n    zero: zero\n};\n/**\n * @category do notation\n * @since 2.11.0\n */\nexport var guard = /*#__PURE__*/ guard_(Zero, Pointed);\n/**\n * @category instances\n * @since 2.7.0\n */\nexport var Alternative = {\n    URI: URI,\n    map: _map,\n    ap: _ap,\n    of: of,\n    alt: _alt,\n    zero: zero\n};\n/**\n * @since 2.0.0\n */\nexport var extend = function (f) { return function (wa) {\n    return isNone(wa) ? none : some(f(wa));\n}; };\n/**\n * @category instances\n * @since 2.7.0\n */\nexport var Extend = {\n    URI: URI,\n    map: _map,\n    extend: _extend\n};\n/**\n * @category filtering\n * @since 2.0.0\n */\nexport var compact = /*#__PURE__*/ flatMap(identity);\nvar defaultSeparated = /*#__PURE__*/ separated(none, none);\n/**\n * @category filtering\n * @since 2.0.0\n */\nexport var separate = function (ma) {\n    return isNone(ma) ? defaultSeparated : separated(getLeft(ma.value), getRight(ma.value));\n};\n/**\n * @category instances\n * @since 2.7.0\n */\nexport var Compactable = {\n    URI: URI,\n    compact: compact,\n    separate: separate\n};\n/**\n * @category filtering\n * @since 2.0.0\n */\nexport var filter = function (predicate) {\n    return function (fa) {\n        return isNone(fa) ? none : predicate(fa.value) ? fa : none;\n    };\n};\n/**\n * @category filtering\n * @since 2.0.0\n */\nexport var filterMap = function (f) { return function (fa) {\n    return isNone(fa) ? none : f(fa.value);\n}; };\n/**\n * @category filtering\n * @since 2.0.0\n */\nexport var partition = function (predicate) {\n    return function (fa) {\n        return separated(_filter(fa, not(predicate)), _filter(fa, predicate));\n    };\n};\n/**\n * @category filtering\n * @since 2.0.0\n */\nexport var partitionMap = function (f) { return flow(map(f), separate); };\n/**\n * @category instances\n * @since 2.7.0\n */\nexport var Filterable = {\n    URI: URI,\n    map: _map,\n    compact: compact,\n    separate: separate,\n    filter: _filter,\n    filterMap: _filterMap,\n    partition: _partition,\n    partitionMap: _partitionMap\n};\n/**\n * @category traversing\n * @since 2.6.3\n */\nexport var traverse = function (F) {\n    return function (f) {\n        return function (ta) {\n            return isNone(ta) ? F.of(none) : F.map(f(ta.value), some);\n        };\n    };\n};\n/**\n * @category traversing\n * @since 2.6.3\n */\nexport var sequence = function (F) {\n    return function (ta) {\n        return isNone(ta) ? F.of(none) : F.map(ta.value, some);\n    };\n};\n/**\n * @category instances\n * @since 2.7.0\n */\nexport var Traversable = {\n    URI: URI,\n    map: _map,\n    reduce: _reduce,\n    foldMap: _foldMap,\n    reduceRight: _reduceRight,\n    traverse: _traverse,\n    sequence: sequence\n};\nvar _wither = /*#__PURE__*/ witherDefault(Traversable, Compactable);\nvar _wilt = /*#__PURE__*/ wiltDefault(Traversable, Compactable);\n/**\n * @category filtering\n * @since 2.6.5\n */\nexport var wither = function (F) {\n    var _witherF = _wither(F);\n    return function (f) { return function (fa) { return _witherF(fa, f); }; };\n};\n/**\n * @category filtering\n * @since 2.6.5\n */\nexport var wilt = function (F) {\n    var _wiltF = _wilt(F);\n    return function (f) { return function (fa) { return _wiltF(fa, f); }; };\n};\n/**\n * @category instances\n * @since 2.7.0\n */\nexport var Witherable = {\n    URI: URI,\n    map: _map,\n    reduce: _reduce,\n    foldMap: _foldMap,\n    reduceRight: _reduceRight,\n    traverse: _traverse,\n    sequence: sequence,\n    compact: compact,\n    separate: separate,\n    filter: _filter,\n    filterMap: _filterMap,\n    partition: _partition,\n    partitionMap: _partitionMap,\n    wither: _wither,\n    wilt: _wilt\n};\n/**\n * @since 2.7.0\n */\nexport var throwError = function () { return none; };\n/**\n * @category instances\n * @since 2.7.0\n */\nexport var MonadThrow = {\n    URI: URI,\n    map: _map,\n    ap: _ap,\n    of: of,\n    chain: flatMap,\n    throwError: throwError\n};\n/**\n * Transforms an `Either` to an `Option` discarding the error.\n *\n * Alias of [getRight](#getright)\n *\n * @category conversions\n * @since 2.0.0\n */\nexport var fromEither = getRight;\n/**\n * @category instances\n * @since 2.11.0\n */\nexport var FromEither = {\n    URI: URI,\n    fromEither: fromEither\n};\n// -------------------------------------------------------------------------------------\n// refinements\n// -------------------------------------------------------------------------------------\n/**\n * Returns `true` if the option is an instance of `Some`, `false` otherwise.\n *\n * @example\n * import { some, none, isSome } from 'fp-ts/Option'\n *\n * assert.strictEqual(isSome(some(1)), true)\n * assert.strictEqual(isSome(none), false)\n *\n * @category refinements\n * @since 2.0.0\n */\nexport var isSome = _.isSome;\n/**\n * Returns `true` if the option is `None`, `false` otherwise.\n *\n * @example\n * import { some, none, isNone } from 'fp-ts/Option'\n *\n * assert.strictEqual(isNone(some(1)), false)\n * assert.strictEqual(isNone(none), true)\n *\n * @category refinements\n * @since 2.0.0\n */\nexport var isNone = function (fa) { return fa._tag === 'None'; };\n/**\n * Less strict version of [`match`](#match).\n *\n * The `W` suffix (short for **W**idening) means that the handler return types will be merged.\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport var matchW = function (onNone, onSome) {\n    return function (ma) {\n        return isNone(ma) ? onNone() : onSome(ma.value);\n    };\n};\n/**\n * Alias of [`matchW`](#matchw).\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport var foldW = matchW;\n/**\n * Takes a (lazy) default value, a function, and an `Option` value, if the `Option` value is `None` the default value is\n * returned, otherwise the function is applied to the value inside the `Some` and the result is returned.\n *\n * @example\n * import { some, none, match } from 'fp-ts/Option'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.strictEqual(\n *   pipe(\n *     some(1),\n *     match(() => 'a none', a => `a some containing ${a}`)\n *   ),\n *   'a some containing 1'\n * )\n *\n * assert.strictEqual(\n *   pipe(\n *     none,\n *     match(() => 'a none', a => `a some containing ${a}`)\n *   ),\n *   'a none'\n * )\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport var match = matchW;\n/**\n * Alias of [`match`](#match).\n *\n * @category pattern matching\n * @since 2.0.0\n */\nexport var fold = match;\n/**\n * Less strict version of [`getOrElse`](#getorelse).\n *\n * The `W` suffix (short for **W**idening) means that the handler return type will be merged.\n *\n * @category error handling\n * @since 2.6.0\n */\nexport var getOrElseW = function (onNone) {\n    return function (ma) {\n        return isNone(ma) ? onNone() : ma.value;\n    };\n};\n/**\n * Extracts the value out of the structure, if it exists. Otherwise returns the given default value\n *\n * @example\n * import { some, none, getOrElse } from 'fp-ts/Option'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.strictEqual(\n *   pipe(\n *     some(1),\n *     getOrElse(() => 0)\n *   ),\n *   1\n * )\n * assert.strictEqual(\n *   pipe(\n *     none,\n *     getOrElse(() => 0)\n *   ),\n *   0\n * )\n *\n * @category error handling\n * @since 2.0.0\n */\nexport var getOrElse = getOrElseW;\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport var flap = /*#__PURE__*/ flap_(Functor);\n/**\n * Combine two effectful actions, keeping only the result of the first.\n *\n * @since 2.0.0\n */\nexport var apFirst = /*#__PURE__*/ apFirst_(Apply);\n/**\n * Combine two effectful actions, keeping only the result of the second.\n *\n * @since 2.0.0\n */\nexport var apSecond = /*#__PURE__*/ apSecond_(Apply);\n/**\n * @category sequencing\n * @since 2.0.0\n */\nexport var flatten = compact;\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.15.0\n */\nexport var tap = /*#__PURE__*/ dual(2, chainable.tap(Chain));\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as O from 'fp-ts/Option'\n * import * as E from 'fp-ts/Either'\n *\n * const compute = (value: number) => pipe(\n *   O.of(value),\n *   O.tapEither((value) => value > 0 ? E.right('ok') : E.left('error')),\n * )\n *\n * assert.deepStrictEqual(compute(1), O.of(1))\n * assert.deepStrictEqual(compute(-42), O.none)\n *\n * @category combinators\n * @since 2.16.0\n */\nexport var tapEither = /*#__PURE__*/ dual(2, tapEither_(FromEither, Chain));\n/**\n * @since 2.0.0\n */\nexport var duplicate = /*#__PURE__*/ extend(identity);\n/**\n * @category lifting\n * @since 2.11.0\n */\nexport var fromEitherK = /*#__PURE__*/ fromEitherK_(FromEither);\n/**\n * @category sequencing\n * @since 2.11.0\n */\nexport var chainEitherK = \n/*#__PURE__*/ chainEitherK_(FromEither, Chain);\n/**\n * Alias of `tapEither`.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport var chainFirstEitherK = tapEither;\n/**\n * Constructs a new `Option` from a nullable type. If the value is `null` or `undefined`, returns `None`, otherwise\n * returns the value wrapped in a `Some`.\n *\n * @example\n * import { none, some, fromNullable } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(fromNullable(undefined), none)\n * assert.deepStrictEqual(fromNullable(null), none)\n * assert.deepStrictEqual(fromNullable(1), some(1))\n *\n * @category conversions\n * @since 2.0.0\n */\nexport var fromNullable = function (a) { return (a == null ? none : some(a)); };\n/**\n * Transforms an exception into an `Option`. If `f` throws, returns `None`, otherwise returns the output wrapped in a\n * `Some`.\n *\n * See also [`tryCatchK`](#trycatchk).\n *\n * @example\n * import { none, some, tryCatch } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(\n *   tryCatch(() => {\n *     throw new Error()\n *   }),\n *   none\n * )\n * assert.deepStrictEqual(tryCatch(() => 1), some(1))\n *\n * @category interop\n * @since 2.0.0\n */\nexport var tryCatch = function (f) {\n    try {\n        return some(f());\n    }\n    catch (e) {\n        return none;\n    }\n};\n/**\n * Converts a function that may throw to one returning a `Option`.\n *\n * @category interop\n * @since 2.10.0\n */\nexport var tryCatchK = function (f) {\n    return function () {\n        var a = [];\n        for (var _i = 0; _i < arguments.length; _i++) {\n            a[_i] = arguments[_i];\n        }\n        return tryCatch(function () { return f.apply(void 0, a); });\n    };\n};\n/**\n * Returns a *smart constructor* from a function that returns a nullable value.\n *\n * @example\n * import { fromNullableK, none, some } from 'fp-ts/Option'\n *\n * const f = (s: string): number | undefined => {\n *   const n = parseFloat(s)\n *   return isNaN(n) ? undefined : n\n * }\n *\n * const g = fromNullableK(f)\n *\n * assert.deepStrictEqual(g('1'), some(1))\n * assert.deepStrictEqual(g('a'), none)\n *\n * @category lifting\n * @since 2.9.0\n */\nexport var fromNullableK = function (f) { return flow(f, fromNullable); };\n/**\n * This is `chain` + `fromNullable`, useful when working with optional values.\n *\n * @example\n * import { some, none, fromNullable, chainNullableK } from 'fp-ts/Option'\n * import { pipe } from 'fp-ts/function'\n *\n * interface Employee {\n *   readonly company?: {\n *     readonly address?: {\n *       readonly street?: {\n *         readonly name?: string\n *       }\n *     }\n *   }\n * }\n *\n * const employee1: Employee = { company: { address: { street: { name: 'high street' } } } }\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     fromNullable(employee1.company),\n *     chainNullableK(company => company.address),\n *     chainNullableK(address => address.street),\n *     chainNullableK(street => street.name)\n *   ),\n *   some('high street')\n * )\n *\n * const employee2: Employee = { company: { address: { street: {} } } }\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     fromNullable(employee2.company),\n *     chainNullableK(company => company.address),\n *     chainNullableK(address => address.street),\n *     chainNullableK(street => street.name)\n *   ),\n *   none\n * )\n *\n * @category sequencing\n * @since 2.9.0\n */\nexport var chainNullableK = function (f) {\n    return function (ma) {\n        return isNone(ma) ? none : fromNullable(f(ma.value));\n    };\n};\n/**\n * Extracts the value out of the structure, if it exists. Otherwise returns `null`.\n *\n * @example\n * import { some, none, toNullable } from 'fp-ts/Option'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.strictEqual(\n *   pipe(\n *     some(1),\n *     toNullable\n *   ),\n *   1\n * )\n * assert.strictEqual(\n *   pipe(\n *     none,\n *     toNullable\n *   ),\n *   null\n * )\n *\n * @category conversions\n * @since 2.0.0\n */\nexport var toNullable = /*#__PURE__*/ match(constNull, identity);\n/**\n * Extracts the value out of the structure, if it exists. Otherwise returns `undefined`.\n *\n * @example\n * import { some, none, toUndefined } from 'fp-ts/Option'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.strictEqual(\n *   pipe(\n *     some(1),\n *     toUndefined\n *   ),\n *   1\n * )\n * assert.strictEqual(\n *   pipe(\n *     none,\n *     toUndefined\n *   ),\n *   undefined\n * )\n *\n * @category conversions\n * @since 2.0.0\n */\nexport var toUndefined = /*#__PURE__*/ match(constUndefined, identity);\nexport function elem(E) {\n    return function (a, ma) {\n        if (ma === undefined) {\n            var elemE_1 = elem(E);\n            return function (ma) { return elemE_1(a, ma); };\n        }\n        return isNone(ma) ? false : E.equals(a, ma.value);\n    };\n}\n/**\n * Returns `true` if the predicate is satisfied by the wrapped value\n *\n * @example\n * import { some, none, exists } from 'fp-ts/Option'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.strictEqual(\n *   pipe(\n *     some(1),\n *     exists(n => n > 0)\n *   ),\n *   true\n * )\n * assert.strictEqual(\n *   pipe(\n *     some(1),\n *     exists(n => n > 1)\n *   ),\n *   false\n * )\n * assert.strictEqual(\n *   pipe(\n *     none,\n *     exists(n => n > 0)\n *   ),\n *   false\n * )\n *\n * @since 2.0.0\n */\nexport var exists = function (predicate) {\n    return function (ma) {\n        return isNone(ma) ? false : predicate(ma.value);\n    };\n};\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n/**\n * @category do notation\n * @since 2.9.0\n */\nexport var Do = /*#__PURE__*/ of(_.emptyRecord);\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport var bindTo = /*#__PURE__*/ bindTo_(Functor);\nvar let_ = /*#__PURE__*/ let__(Functor);\nexport { \n/**\n * @category do notation\n * @since 2.13.0\n */\nlet_ as let };\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport var bind = /*#__PURE__*/ chainable.bind(Chain);\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport var apS = /*#__PURE__*/ apS_(Apply);\n/**\n * @since 2.11.0\n */\nexport var ApT = /*#__PURE__*/ of(_.emptyReadonlyArray);\n// -------------------------------------------------------------------------------------\n// array utils\n// -------------------------------------------------------------------------------------\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport var traverseReadonlyNonEmptyArrayWithIndex = function (f) {\n    return function (as) {\n        var o = f(0, _.head(as));\n        if (isNone(o)) {\n            return none;\n        }\n        var out = [o.value];\n        for (var i = 1; i < as.length; i++) {\n            var o_1 = f(i, as[i]);\n            if (isNone(o_1)) {\n                return none;\n            }\n            out.push(o_1.value);\n        }\n        return some(out);\n    };\n};\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport var traverseReadonlyArrayWithIndex = function (f) {\n    var g = traverseReadonlyNonEmptyArrayWithIndex(f);\n    return function (as) { return (_.isNonEmpty(as) ? g(as) : ApT); };\n};\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport var traverseArrayWithIndex = traverseReadonlyArrayWithIndex;\n/**\n * Equivalent to `ReadonlyArray#traverse(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport var traverseArray = function (f) {\n    return traverseReadonlyArrayWithIndex(function (_, a) { return f(a); });\n};\n/**\n * Equivalent to `ReadonlyArray#sequence(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport var sequenceArray = \n/*#__PURE__*/ traverseArray(identity);\n// -------------------------------------------------------------------------------------\n// legacy\n// -------------------------------------------------------------------------------------\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport var chain = flatMap;\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport var chainFirst = tap;\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n/**\n * Use `Refinement` module instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function getRefinement(getOption) {\n    return function (a) { return isSome(getOption(a)); };\n}\n/**\n * Use [`chainNullableK`](#chainnullablek) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport var mapNullable = chainNullableK;\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `O.Functor` instead of `O.option`\n * (where `O` is from `import O from 'fp-ts/Option'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport var option = {\n    URI: URI,\n    map: _map,\n    of: of,\n    ap: _ap,\n    chain: flatMap,\n    reduce: _reduce,\n    foldMap: _foldMap,\n    reduceRight: _reduceRight,\n    traverse: _traverse,\n    sequence: sequence,\n    zero: zero,\n    alt: _alt,\n    extend: _extend,\n    compact: compact,\n    separate: separate,\n    filter: _filter,\n    filterMap: _filterMap,\n    partition: _partition,\n    partitionMap: _partitionMap,\n    wither: _wither,\n    wilt: _wilt,\n    throwError: throwError\n};\n/**\n * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport var getApplySemigroup = /*#__PURE__*/ getApplySemigroup_(Apply);\n/**\n * Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport var getApplyMonoid = /*#__PURE__*/ getApplicativeMonoid(Applicative);\n/**\n * Use\n *\n * ```ts\n * import { first } from 'fp-ts/Semigroup'\n * import { getMonoid } from 'fp-ts/Option'\n *\n * getMonoid(first())\n * ```\n *\n * instead.\n *\n * Monoid returning the left-most non-`None` value\n *\n * | x       | y       | concat(x, y) |\n * | ------- | ------- | ------------ |\n * | none    | none    | none         |\n * | some(a) | none    | some(a)      |\n * | none    | some(b) | some(b)      |\n * | some(a) | some(b) | some(a)      |\n *\n * @example\n * import { getFirstMonoid, some, none } from 'fp-ts/Option'\n *\n * const M = getFirstMonoid<number>()\n * assert.deepStrictEqual(M.concat(none, none), none)\n * assert.deepStrictEqual(M.concat(some(1), none), some(1))\n * assert.deepStrictEqual(M.concat(none, some(2)), some(2))\n * assert.deepStrictEqual(M.concat(some(1), some(2)), some(1))\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport var getFirstMonoid = function () { return getMonoid(first()); };\n/**\n * Use\n *\n * ```ts\n * import { last } from 'fp-ts/Semigroup'\n * import { getMonoid } from 'fp-ts/Option'\n *\n * getMonoid(last())\n * ```\n *\n * instead.\n *\n * Monoid returning the right-most non-`None` value\n *\n * | x       | y       | concat(x, y) |\n * | ------- | ------- | ------------ |\n * | none    | none    | none         |\n * | some(a) | none    | some(a)      |\n * | none    | some(b) | some(b)      |\n * | some(a) | some(b) | some(b)      |\n *\n * @example\n * import { getLastMonoid, some, none } from 'fp-ts/Option'\n *\n * const M = getLastMonoid<number>()\n * assert.deepStrictEqual(M.concat(none, none), none)\n * assert.deepStrictEqual(M.concat(some(1), none), some(1))\n * assert.deepStrictEqual(M.concat(none, some(2)), some(2))\n * assert.deepStrictEqual(M.concat(some(1), some(2)), some(2))\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport var getLastMonoid = function () { return getMonoid(last()); };\n","import { throwifyFpFn, throwifyAnyEither, type AnyFn } from '@tma.js/toolkit';\nimport * as O from 'fp-ts/Option';\nimport { pipe } from 'fp-ts/function';\n\nimport type { WithChecksFp, WithChecks } from '@/with-checks/withChecksFp.js';\n\nexport function throwifyWithChecksFp<\n  Fn extends AnyFn,\n  HasSupportCheck extends boolean,\n  SupportsMapKeySchema extends string,\n>(\n  fn: WithChecksFp<Fn, HasSupportCheck, SupportsMapKeySchema>,\n): WithChecks<Fn, HasSupportCheck, SupportsMapKeySchema> {\n  return Object.assign(throwifyFpFn(fn), {\n    ifAvailable(...args: Parameters<Fn>) {\n      return pipe(\n        fn.ifAvailable(...args),\n        O.match(\n          () => ({ ok: false }),\n          data => ({\n            ok: true,\n            data: throwifyAnyEither(data),\n          }),\n        ),\n      );\n    },\n  }) as unknown as WithChecks<Fn, HasSupportCheck, SupportsMapKeySchema>;\n}\n","import { ap as ap_ } from './Apply';\nimport * as E from './Either';\nimport { flow, pipe } from './function';\nimport { map as map_ } from './Functor';\nexport function right(F) {\n    return flow(E.right, F.of);\n}\nexport function left(F) {\n    return flow(E.left, F.of);\n}\nexport function rightF(F) {\n    return function (fa) { return F.map(fa, E.right); };\n}\nexport function leftF(F) {\n    return function (fe) { return F.map(fe, E.left); };\n}\nexport function fromNullable(F) {\n    return function (e) { return flow(E.fromNullable(e), F.of); };\n}\nexport function fromNullableK(F) {\n    var fromNullableF = fromNullable(F);\n    return function (e) {\n        var fromNullableFE = fromNullableF(e);\n        return function (f) { return flow(f, fromNullableFE); };\n    };\n}\nexport function chainNullableK(M) {\n    var chainM = chain(M);\n    var fromNullableKM = fromNullableK(M);\n    return function (e) {\n        var fromNullableKMe = fromNullableKM(e);\n        return function (f) { return chainM(fromNullableKMe(f)); };\n    };\n}\nexport function map(F) {\n    return map_(F, E.Functor);\n}\nexport function ap(F) {\n    return ap_(F, E.Apply);\n}\nexport function chain(M) {\n    var flatMapM = flatMap(M);\n    return function (f) { return function (ma) { return flatMapM(ma, f); }; };\n}\n/** @internal */\nexport function flatMap(M) {\n    return function (ma, f) { return M.chain(ma, function (e) { return (E.isLeft(e) ? M.of(e) : f(e.right)); }); };\n}\nexport function alt(M) {\n    return function (second) { return function (first) { return M.chain(first, function (e) { return (E.isLeft(e) ? second() : M.of(e)); }); }; };\n}\nexport function bimap(F) {\n    var mapBothF = mapBoth(F);\n    return function (f, g) { return function (self) { return mapBothF(self, f, g); }; };\n}\n/** @internal */\nexport function mapBoth(F) {\n    return function (self, f, g) { return F.map(self, E.bimap(f, g)); };\n}\nexport function mapLeft(F) {\n    var mapErrorF = mapError(F);\n    return function (f) { return function (self) { return mapErrorF(self, f); }; };\n}\n/** @internal */\nexport function mapError(F) {\n    return function (self, f) { return F.map(self, E.mapLeft(f)); };\n}\nexport function altValidation(M, S) {\n    return function (second) { return function (first) {\n        return M.chain(first, E.match(function (e1) {\n            return M.map(second(), E.mapLeft(function (e2) { return S.concat(e1, e2); }));\n        }, right(M)));\n    }; };\n}\nexport function match(F) {\n    return function (onLeft, onRight) { return function (ma) { return F.map(ma, E.match(onLeft, onRight)); }; };\n}\nexport function matchE(M) {\n    return function (onLeft, onRight) { return function (ma) { return M.chain(ma, E.match(onLeft, onRight)); }; };\n}\nexport function getOrElse(M) {\n    return function (onLeft) { return function (ma) { return M.chain(ma, E.match(onLeft, M.of)); }; };\n}\nexport function orElse(M) {\n    return function (onLeft) { return function (ma) { return M.chain(ma, function (e) { return (E.isLeft(e) ? onLeft(e.left) : M.of(e)); }); }; };\n}\nexport function orElseFirst(M) {\n    var tapErrorM = tapError(M);\n    return function (onLeft) { return function (ma) { return tapErrorM(ma, onLeft); }; };\n}\n/** @internal */\nexport function tapError(M) {\n    var orElseM = orElse(M);\n    return function (ma, onLeft) {\n        return pipe(ma, orElseM(function (e) { return M.map(onLeft(e), function (eb) { return (E.isLeft(eb) ? eb : E.left(e)); }); }));\n    };\n}\nexport function orLeft(M) {\n    return function (onLeft) { return function (ma) {\n        return M.chain(ma, E.match(function (e) { return M.map(onLeft(e), E.left); }, function (a) { return M.of(E.right(a)); }));\n    }; };\n}\nexport function swap(F) {\n    return function (ma) { return F.map(ma, E.swap); };\n}\nexport function toUnion(F) {\n    return function (fa) { return F.map(fa, E.toUnion); };\n}\n/** @deprecated  */\n/* istanbul ignore next */\nexport function getEitherM(M) {\n    var _ap = ap(M);\n    var _map = map(M);\n    var _chain = chain(M);\n    var _alt = alt(M);\n    var _bimap = bimap(M);\n    var _mapLeft = mapLeft(M);\n    var _fold = matchE(M);\n    var _getOrElse = getOrElse(M);\n    var _orElse = orElse(M);\n    return {\n        map: function (fa, f) { return pipe(fa, _map(f)); },\n        ap: function (fab, fa) { return pipe(fab, _ap(fa)); },\n        of: right(M),\n        chain: function (ma, f) { return pipe(ma, _chain(f)); },\n        alt: function (fa, that) { return pipe(fa, _alt(that)); },\n        bimap: function (fea, f, g) { return pipe(fea, _bimap(f, g)); },\n        mapLeft: function (fea, f) { return pipe(fea, _mapLeft(f)); },\n        fold: function (fa, onLeft, onRight) { return pipe(fa, _fold(onLeft, onRight)); },\n        getOrElse: function (fa, onLeft) { return pipe(fa, _getOrElse(onLeft)); },\n        orElse: function (fa, f) { return pipe(fa, _orElse(f)); },\n        swap: swap(M),\n        rightM: rightF(M),\n        leftM: leftF(M),\n        left: left(M)\n    };\n}\n","/**\n * ```ts\n * interface Task<A> {\n *   (): Promise<A>\n * }\n * ```\n *\n * `Task<A>` represents an asynchronous computation that yields a value of type `A` and **never fails**.\n * If you want to represent an asynchronous computation that may fail, please see `TaskEither`.\n *\n * @since 2.0.0\n */\nimport { getApplicativeMonoid } from './Applicative';\nimport { apFirst as apFirst_, apS as apS_, apSecond as apSecond_, getApplySemigroup as getApplySemigroup_ } from './Apply';\nimport * as chainable from './Chain';\nimport { fromIOK as fromIOK_, tapIO as tapIO_ } from './FromIO';\nimport { dual, identity, pipe } from './function';\nimport { as as as_, asUnit as asUnit_, bindTo as bindTo_, flap as flap_, let as let__ } from './Functor';\nimport * as _ from './internal';\n// -------------------------------------------------------------------------------------\n// conversions\n// -------------------------------------------------------------------------------------\n/**\n * @category conversions\n * @since 2.0.0\n */\nexport var fromIO = function (ma) { return function () { return Promise.resolve().then(ma); }; };\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n/**\n * Creates a task that will complete after a time delay\n *\n * @example\n * import { sequenceT } from 'fp-ts/Apply'\n * import * as T from 'fp-ts/Task'\n * import { takeRight } from 'fp-ts/Array'\n *\n * async function test() {\n *   const log: Array<string> = []\n *   const append = (message: string): T.Task<void> =>\n *     T.fromIO(() => {\n *       log.push(message)\n *     })\n *   const fa = append('a')\n *   const fb = T.delay(20)(append('b'))\n *   const fc = T.delay(10)(append('c'))\n *   const fd = append('d')\n *   await sequenceT(T.ApplyPar)(fa, fb, fc, fd)()\n *   assert.deepStrictEqual(takeRight(2)(log), ['c', 'b'])\n * }\n *\n * test()\n *\n * @since 2.0.0\n */\nexport function delay(millis) {\n    return function (ma) { return function () {\n        return new Promise(function (resolve) {\n            setTimeout(function () {\n                Promise.resolve().then(ma).then(resolve);\n            }, millis);\n        });\n    }; };\n}\nvar _map = function (fa, f) { return pipe(fa, map(f)); };\nvar _apPar = function (fab, fa) { return pipe(fab, ap(fa)); };\nvar _apSeq = function (fab, fa) { return flatMap(fab, function (f) { return pipe(fa, map(f)); }); };\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.0.0\n */\nexport var map = function (f) { return function (fa) { return function () {\n    return Promise.resolve().then(fa).then(f);\n}; }; };\n/**\n * @since 2.0.0\n */\nexport var ap = function (fa) { return function (fab) { return function () {\n    return Promise.all([Promise.resolve().then(fab), Promise.resolve().then(fa)]).then(function (_a) {\n        var f = _a[0], a = _a[1];\n        return f(a);\n    });\n}; }; };\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport var of = function (a) { return function () { return Promise.resolve(a); }; };\n/**\n * @category sequencing\n * @since 2.14.0\n */\nexport var flatMap = /*#__PURE__*/ dual(2, function (ma, f) {\n    return function () {\n        return Promise.resolve()\n            .then(ma)\n            .then(function (a) { return f(a)(); });\n    };\n});\n/**\n * @category sequencing\n * @since 2.0.0\n */\nexport var flatten = /*#__PURE__*/ flatMap(identity);\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport var URI = 'Task';\n/**\n * Monoid returning the first completed task.\n *\n * Note: uses `Promise.race` internally.\n *\n * @example\n * import * as T from 'fp-ts/Task'\n *\n * async function test() {\n *   const S = T.getRaceMonoid<string>()\n *   const fa = T.delay(20)(T.of('a'))\n *   const fb = T.delay(10)(T.of('b'))\n *   assert.deepStrictEqual(await S.concat(fa, fb)(), 'b')\n * }\n *\n * test()\n *\n * @category instances\n * @since 2.0.0\n */\nexport function getRaceMonoid() {\n    return {\n        concat: function (x, y) { return function () { return Promise.race([Promise.resolve().then(x), Promise.resolve().then(y)]); }; },\n        empty: never\n    };\n}\n/**\n * @category instances\n * @since 2.7.0\n */\nexport var Functor = {\n    URI: URI,\n    map: _map\n};\n/**\n * Maps the value to the specified constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport var as = dual(2, as_(Functor));\n/**\n * Maps the value to the void constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport var asUnit = asUnit_(Functor);\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport var flap = /*#__PURE__*/ flap_(Functor);\n/**\n * @category instances\n * @since 2.10.0\n */\nexport var Pointed = {\n    URI: URI,\n    of: of\n};\n/**\n * Runs computations in parallel.\n *\n * @category instances\n * @since 2.10.0\n */\nexport var ApplyPar = {\n    URI: URI,\n    map: _map,\n    ap: _apPar\n};\n/**\n * Combine two effectful actions, keeping only the result of the first.\n *\n * @since 2.0.0\n */\nexport var apFirst = /*#__PURE__*/ apFirst_(ApplyPar);\n/**\n * Combine two effectful actions, keeping only the result of the second.\n *\n * @since 2.0.0\n */\nexport var apSecond = /*#__PURE__*/ apSecond_(ApplyPar);\n/**\n * Runs computations in parallel.\n *\n * @category instances\n * @since 2.7.0\n */\nexport var ApplicativePar = {\n    URI: URI,\n    map: _map,\n    ap: _apPar,\n    of: of\n};\n/**\n * Runs computations sequentially.\n *\n * @category instances\n * @since 2.10.0\n */\nexport var ApplySeq = {\n    URI: URI,\n    map: _map,\n    ap: _apSeq\n};\n/**\n * Runs computations sequentially.\n *\n * @category instances\n * @since 2.7.0\n */\nexport var ApplicativeSeq = {\n    URI: URI,\n    map: _map,\n    ap: _apSeq,\n    of: of\n};\n/**\n * @category instances\n * @since 2.10.0\n */\nexport var Chain = {\n    URI: URI,\n    map: _map,\n    ap: _apPar,\n    chain: flatMap\n};\n/**\n * @category instances\n * @since 2.10.0\n */\nexport var Monad = {\n    URI: URI,\n    map: _map,\n    of: of,\n    ap: _apPar,\n    chain: flatMap\n};\n/**\n * @category instances\n * @since 2.10.0\n */\nexport var MonadIO = {\n    URI: URI,\n    map: _map,\n    of: of,\n    ap: _apPar,\n    chain: flatMap,\n    fromIO: fromIO\n};\n/**\n * @category zone of death\n * @since 2.7.0\n * @deprecated\n */\nexport var fromTask = identity;\n/**\n * @category instances\n * @since 2.10.0\n */\nexport var MonadTask = {\n    URI: URI,\n    map: _map,\n    of: of,\n    ap: _apPar,\n    chain: flatMap,\n    fromIO: fromIO,\n    fromTask: fromTask\n};\n/**\n * @category instances\n * @since 2.10.0\n */\nexport var FromIO = {\n    URI: URI,\n    fromIO: fromIO\n};\n/** @internal */\nvar _FlatMap = {\n    flatMap: flatMap\n};\n/** @internal */\nvar _FromIO = {\n    fromIO: FromIO.fromIO\n};\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport var flatMapIO = _.flatMapIO(_FromIO, _FlatMap);\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.15.0\n */\nexport var tap = /*#__PURE__*/ dual(2, chainable.tap(Chain));\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as T from 'fp-ts/Task'\n * import * as Console from 'fp-ts/Console'\n *\n * // Will produce `Hello, fp-ts` to the stdout\n * const effect = pipe(\n *   T.of('fp-ts'),\n *   T.tapIO((value) => Console.log(`Hello, ${value}`)),\n * )\n *\n * async function test() {\n *   assert.deepStrictEqual(await effect(), 'fp-ts')\n * }\n *\n * test()\n *\n * @category combinators\n * @since 2.16.0\n */\nexport var tapIO = /*#__PURE__*/ dual(2, tapIO_(FromIO, Chain));\n/**\n * @category lifting\n * @since 2.4.0\n */\nexport var fromIOK = \n/*#__PURE__*/ fromIOK_(FromIO);\n/**\n * Alias of `flatMapIO`.\n *\n * @category legacy\n * @since 2.4.0\n */\nexport var chainIOK = flatMapIO;\n/**\n * Alias of `tapIO`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport var chainFirstIOK = tapIO;\n/**\n * @category instances\n * @since 2.10.0\n */\nexport var FromTask = {\n    URI: URI,\n    fromIO: fromIO,\n    fromTask: fromTask\n};\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n/**\n * A `Task` that never completes.\n *\n * @since 2.0.0\n */\nexport var never = function () { return new Promise(function (_) { return undefined; }); };\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n/**\n * @category do notation\n * @since 2.9.0\n */\nexport var Do = /*#__PURE__*/ of(_.emptyRecord);\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport var bindTo = /*#__PURE__*/ bindTo_(Functor);\nvar let_ = /*#__PURE__*/ let__(Functor);\nexport { \n/**\n * @category do notation\n * @since 2.13.0\n */\nlet_ as let };\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport var bind = /*#__PURE__*/ chainable.bind(Chain);\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport var apS = /*#__PURE__*/ apS_(ApplyPar);\n/**\n * @since 2.11.0\n */\nexport var ApT = /*#__PURE__*/ of(_.emptyReadonlyArray);\n// -------------------------------------------------------------------------------------\n// array utils\n// -------------------------------------------------------------------------------------\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport var traverseReadonlyNonEmptyArrayWithIndex = function (f) {\n    return function (as) {\n        return function () {\n            return Promise.all(as.map(function (a, i) { return Promise.resolve().then(function () { return f(i, a)(); }); }));\n        };\n    };\n};\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativePar)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport var traverseReadonlyArrayWithIndex = function (f) {\n    var g = traverseReadonlyNonEmptyArrayWithIndex(f);\n    return function (as) { return (_.isNonEmpty(as) ? g(as) : ApT); };\n};\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport var traverseReadonlyNonEmptyArrayWithIndexSeq = function (f) {\n    return function (as) {\n        return function () {\n            return _.tail(as).reduce(function (acc, a, i) {\n                return acc.then(function (bs) {\n                    return Promise.resolve()\n                        .then(f(i + 1, a))\n                        .then(function (b) {\n                        bs.push(b);\n                        return bs;\n                    });\n                });\n            }, Promise.resolve()\n                .then(f(0, _.head(as)))\n                .then(_.singleton));\n        };\n    };\n};\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport var traverseReadonlyArrayWithIndexSeq = function (f) {\n    var g = traverseReadonlyNonEmptyArrayWithIndexSeq(f);\n    return function (as) { return (_.isNonEmpty(as) ? g(as) : ApT); };\n};\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport var traverseArrayWithIndex = traverseReadonlyArrayWithIndex;\n/**\n * Equivalent to `ReadonlyArray#traverse(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport var traverseArray = function (f) {\n    return traverseReadonlyArrayWithIndex(function (_, a) { return f(a); });\n};\n/**\n * Equivalent to `ReadonlyArray#sequence(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport var sequenceArray = \n/*#__PURE__*/ traverseArray(identity);\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport var traverseSeqArrayWithIndex = traverseReadonlyArrayWithIndexSeq;\n/**\n * Equivalent to `ReadonlyArray#traverse(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport var traverseSeqArray = function (f) {\n    return traverseReadonlyArrayWithIndexSeq(function (_, a) { return f(a); });\n};\n/**\n * Equivalent to `ReadonlyArray#sequence(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport var sequenceSeqArray = \n/*#__PURE__*/ traverseSeqArray(identity);\n// -------------------------------------------------------------------------------------\n// legacy\n// -------------------------------------------------------------------------------------\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport var chain = flatMap;\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport var chainFirst = tap;\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `T.Functor` instead of `T.task`\n * (where `T` is from `import T from 'fp-ts/Task'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport var task = {\n    URI: URI,\n    map: _map,\n    of: of,\n    ap: _apPar,\n    chain: flatMap,\n    fromIO: fromIO,\n    fromTask: fromTask\n};\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `T.Functor` instead of `T.taskSeq`\n * (where `T` is from `import T from 'fp-ts/Task'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport var taskSeq = {\n    URI: URI,\n    map: _map,\n    of: of,\n    ap: _apSeq,\n    chain: flatMap,\n    fromIO: fromIO,\n    fromTask: fromTask\n};\n/**\n * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport var getSemigroup = /*#__PURE__*/ getApplySemigroup_(ApplySeq);\n/**\n * Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n *\n * Lift a monoid into 'Task', the inner values are concatenated using the provided `Monoid`.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport var getMonoid = /*#__PURE__*/ getApplicativeMonoid(ApplicativeSeq);\n","var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n    return new (P || (P = Promise))(function (resolve, reject) {\n        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n        function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n        step((generator = generator.apply(thisArg, _arguments || [])).next());\n    });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n    return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n    function verb(n) { return function (v) { return step([n, v]); }; }\n    function step(op) {\n        if (f) throw new TypeError(\"Generator is already executing.\");\n        while (g && (g = 0, op[0] && (_ = 0)), _) try {\n            if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n            if (y = 0, t) op = [op[0] & 2, t.value];\n            switch (op[0]) {\n                case 0: case 1: t = op; break;\n                case 4: _.label++; return { value: op[1], done: false };\n                case 5: _.label++; y = op[1]; op = [0]; continue;\n                case 7: op = _.ops.pop(); _.trys.pop(); continue;\n                default:\n                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n                    if (t[2]) _.ops.pop();\n                    _.trys.pop(); continue;\n            }\n            op = body.call(thisArg, _);\n        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n    }\n};\nimport { getApplicativeMonoid } from './Applicative';\nimport { ap as ap_, apFirst as apFirst_, apS as apS_, apSecond as apSecond_, getApplySemigroup as getApplySemigroup_ } from './Apply';\nimport * as chainable from './Chain';\nimport { compact as compact_, separate as separate_ } from './Compactable';\nimport * as E from './Either';\nimport * as ET from './EitherT';\nimport { filter as filter_, filterMap as filterMap_, partition as partition_, partitionMap as partitionMap_ } from './Filterable';\nimport { chainOptionK as chainOptionK_, filterOrElse as filterOrElse_, fromEitherK as fromEitherK_, fromOption as fromOption_, fromOptionK as fromOptionK_, fromPredicate as fromPredicate_, tapEither as tapEither_ } from './FromEither';\nimport { fromIOK as fromIOK_, tapIO as tapIO_ } from './FromIO';\nimport { fromTaskK as fromTaskK_, tapTask as tapTask_ } from './FromTask';\nimport { dual, flow, identity, pipe, SK } from './function';\nimport { as as as_, asUnit as asUnit_, bindTo as bindTo_, flap as flap_, let as let__ } from './Functor';\nimport * as _ from './internal';\nimport * as T from './Task';\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport var left = /*#__PURE__*/ ET.left(T.Pointed);\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport var right = /*#__PURE__*/ ET.right(T.Pointed);\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport var rightTask = /*#__PURE__*/ ET.rightF(T.Functor);\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport var leftTask = /*#__PURE__*/ ET.leftF(T.Functor);\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport var rightIO = /*#__PURE__*/ flow(T.fromIO, rightTask);\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport var leftIO = /*#__PURE__*/ flow(T.fromIO, leftTask);\n// -------------------------------------------------------------------------------------\n// conversions\n// -------------------------------------------------------------------------------------\n/**\n * @category conversions\n * @since 2.7.0\n */\nexport var fromIO = rightIO;\n/**\n * @category conversions\n * @since 2.7.0\n */\nexport var fromTask = rightTask;\n/**\n * @category conversions\n * @since 2.0.0\n */\nexport var fromEither = T.of;\n/**\n * @category conversions\n * @since 2.0.0\n */\nexport var fromIOEither = T.fromIO;\n/**\n * @category conversions\n * @since 2.11.0\n */\nexport var fromTaskOption = function (onNone) {\n    return T.map(E.fromOption(onNone));\n};\n/**\n * @category pattern matching\n * @since 2.10.0\n */\nexport var match = \n/*#__PURE__*/ ET.match(T.Functor);\n/**\n * Less strict version of [`match`](#match).\n *\n * The `W` suffix (short for **W**idening) means that the handler return types will be merged.\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport var matchW = match;\n/**\n * The `E` suffix (short for **E**ffect) means that the handlers return an effect (`Task`).\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport var matchE = /*#__PURE__*/ ET.matchE(T.Monad);\n/**\n * Alias of [`matchE`](#matche).\n *\n * @category pattern matching\n * @since 2.0.0\n */\nexport var fold = matchE;\n/**\n * Less strict version of [`matchE`](#matche).\n *\n * The `W` suffix (short for **W**idening) means that the handler return types will be merged.\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport var matchEW = matchE;\n/**\n * Alias of [`matchEW`](#matchew).\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport var foldW = matchEW;\n/**\n * @category error handling\n * @since 2.0.0\n */\nexport var getOrElse = \n/*#__PURE__*/ ET.getOrElse(T.Monad);\n/**\n * Less strict version of [`getOrElse`](#getorelse).\n *\n * The `W` suffix (short for **W**idening) means that the handler return type will be merged.\n *\n * @category error handling\n * @since 2.6.0\n */\nexport var getOrElseW = getOrElse;\n/**\n * Transforms a `Promise` that may reject to a `Promise` that never rejects and returns an `Either` instead.\n *\n * See also [`tryCatchK`](#trycatchk).\n *\n * @example\n * import { left, right } from 'fp-ts/Either'\n * import { tryCatch } from 'fp-ts/TaskEither'\n *\n * tryCatch(() => Promise.resolve(1), String)().then(result => {\n *   assert.deepStrictEqual(result, right(1))\n * })\n * tryCatch(() => Promise.reject('error'), String)().then(result => {\n *   assert.deepStrictEqual(result, left('error'))\n * })\n *\n * @category interop\n * @since 2.0.0\n */\nexport var tryCatch = function (f, onRejected) {\n    return function () { return __awaiter(void 0, void 0, void 0, function () {\n        var reason_1;\n        return __generator(this, function (_a) {\n            switch (_a.label) {\n                case 0:\n                    _a.trys.push([0, 2, , 3]);\n                    return [4 /*yield*/, f().then(_.right)];\n                case 1: return [2 /*return*/, _a.sent()];\n                case 2:\n                    reason_1 = _a.sent();\n                    return [2 /*return*/, _.left(onRejected(reason_1))];\n                case 3: return [2 /*return*/];\n            }\n        });\n    }); };\n};\n/**\n * Converts a function returning a `Promise` to one returning a `TaskEither`.\n *\n * @category interop\n * @since 2.5.0\n */\nexport var tryCatchK = function (f, onRejected) {\n    return function () {\n        var a = [];\n        for (var _i = 0; _i < arguments.length; _i++) {\n            a[_i] = arguments[_i];\n        }\n        return tryCatch(function () { return f.apply(void 0, a); }, onRejected);\n    };\n};\n/**\n * @category conversions\n * @since 2.10.0\n */\nexport var toUnion = /*#__PURE__*/ ET.toUnion(T.Functor);\n/**\n * @category conversions\n * @since 2.12.0\n */\nexport var fromNullable = /*#__PURE__*/ ET.fromNullable(T.Pointed);\n/**\n * Use `liftNullable`.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport var fromNullableK = /*#__PURE__*/ ET.fromNullableK(T.Pointed);\n/**\n * Use `flatMapNullable`.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport var chainNullableK = \n/*#__PURE__*/ ET.chainNullableK(T.Monad);\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n/**\n * Returns `ma` if is a `Right` or the value returned by `onLeft` otherwise.\n *\n * See also [alt](#alt).\n *\n * @example\n * import * as E from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n * import * as TE from 'fp-ts/TaskEither'\n *\n * async function test() {\n *   const errorHandler = TE.orElse((error: string) => TE.right(`recovering from ${error}...`))\n *   assert.deepStrictEqual(await pipe(TE.right('ok'), errorHandler)(), E.right('ok'))\n *   assert.deepStrictEqual(await pipe(TE.left('ko'), errorHandler)(), E.right('recovering from ko...'))\n * }\n *\n * test()\n *\n * @category error handling\n * @since 2.0.0\n */\nexport var orElse = \n/*#__PURE__*/ ET.orElse(T.Monad);\n/**\n * Less strict version of [`orElse`](#orelse).\n *\n * The `W` suffix (short for **W**idening) means that the return types will be merged.\n *\n * @category error handling\n * @since 2.10.0\n */\nexport var orElseW = orElse;\n/**\n * Returns an effect that effectfully \"peeks\" at the failure of this effect.\n *\n * @category error handling\n * @since 2.15.0\n */\nexport var tapError = /*#__PURE__*/ dual(2, ET.tapError(T.Monad));\n/**\n * @category error handling\n * @since 2.12.0\n */\nexport var orElseFirstIOK = function (onLeft) { return tapError(fromIOK(onLeft)); };\n/**\n * @category error handling\n * @since 2.12.0\n */\nexport var orElseFirstTaskK = function (onLeft) { return tapError(fromTaskK(onLeft)); };\n/**\n * @category error handling\n * @since 2.11.0\n */\nexport var orLeft = \n/*#__PURE__*/ ET.orLeft(T.Monad);\n/**\n * @since 2.0.0\n */\nexport var swap = /*#__PURE__*/ ET.swap(T.Functor);\n/**\n * @category lifting\n * @since 2.11.0\n */\nexport var fromTaskOptionK = function (onNone) {\n    var from = fromTaskOption(onNone);\n    return function (f) { return flow(f, from); };\n};\n/**\n * Use `flatMapTaskOption`.\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category legacy\n * @since 2.12.3\n */\nexport var chainTaskOptionKW = function (onNone) {\n    return function (f) {\n        return function (ma) {\n            return flatMap(ma, fromTaskOptionK(onNone)(f));\n        };\n    };\n};\n/**\n * Use `flatMapTaskOption`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport var chainTaskOptionK = chainTaskOptionKW;\n/**\n * @category lifting\n * @since 2.4.0\n */\nexport var fromIOEitherK = function (f) { return flow(f, fromIOEither); };\nvar _map = function (fa, f) { return pipe(fa, map(f)); };\nvar _apPar = function (fab, fa) { return pipe(fab, ap(fa)); };\nvar _apSeq = function (fab, fa) { return flatMap(fab, function (f) { return pipe(fa, map(f)); }); };\n/* istanbul ignore next */\nvar _alt = function (fa, that) { return pipe(fa, alt(that)); };\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.0.0\n */\nexport var map = /*#__PURE__*/ ET.map(T.Functor);\n/**\n * Returns a `TaskEither` whose failure and success channels have been mapped by the specified pair of functions, `f` and `g`.\n *\n * @example\n * import * as TaskEither from 'fp-ts/TaskEither'\n * import * as Either from 'fp-ts/Either'\n *\n * const f = (s: string) => new Error(s)\n * const g = (n: number) => n * 2\n *\n * async function test() {\n *   assert.deepStrictEqual(await TaskEither.mapBoth(TaskEither.right(1), f, g)(), Either.right(2))\n *   assert.deepStrictEqual(await TaskEither.mapBoth(TaskEither.left('err'), f, g)(), Either.left(new Error('err')))\n * }\n *\n * test()\n *\n * @category error handling\n * @since 2.16.0\n */\nexport var mapBoth = /*#__PURE__*/ dual(3, ET.mapBoth(T.Functor));\n/**\n * Alias of `mapBoth`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport var bimap = mapBoth;\n/**\n * Returns a `TaskEither` with its error channel mapped using the specified function.\n *\n * @example\n * import * as TaskEither from 'fp-ts/TaskEither'\n * import * as Either from 'fp-ts/Either'\n *\n * const f = (s: string) => new Error(s)\n *\n * async function test() {\n *   assert.deepStrictEqual(await TaskEither.mapError(TaskEither.right(1), f)(), Either.right(1))\n *   assert.deepStrictEqual(await TaskEither.mapError(TaskEither.left('err'), f)(), Either.left(new Error('err')))\n * }\n *\n * test()\n *\n * @category error handling\n * @since 2.16.0\n */\nexport var mapError = /*#__PURE__*/ dual(2, ET.mapError(T.Functor));\n/**\n * Alias of `mapError`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport var mapLeft = mapError;\n/**\n * @since 2.0.0\n */\nexport var ap = \n/*#__PURE__*/ ET.ap(T.ApplyPar);\n/**\n * Less strict version of [`ap`](#ap).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @since 2.8.0\n */\nexport var apW = ap;\n/**\n * @category sequencing\n * @since 2.14.0\n */\nexport var flatMap = /*#__PURE__*/ dual(2, ET.flatMap(T.Monad));\n/**\n * Less strict version of [`flatten`](#flatten).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category sequencing\n * @since 2.11.0\n */\nexport var flattenW = \n/*#__PURE__*/ flatMap(identity);\n/**\n * @category sequencing\n * @since 2.0.0\n */\nexport var flatten = flattenW;\n/**\n * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to\n * types of kind `* -> *`.\n *\n * In case of `TaskEither` returns `fa` if is a `Right` or the value returned by `that` otherwise.\n *\n * See also [orElse](#orelse).\n *\n * @example\n * import * as E from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n * import * as TE from 'fp-ts/TaskEither'\n *\n * async function test() {\n *   assert.deepStrictEqual(\n *     await pipe(\n *       TE.right(1),\n *       TE.alt(() => TE.right(2))\n *     )(),\n *     E.right(1)\n *   )\n *   assert.deepStrictEqual(\n *     await pipe(\n *       TE.left('a'),\n *       TE.alt(() => TE.right(2))\n *     )(),\n *     E.right(2)\n *   )\n *   assert.deepStrictEqual(\n *     await pipe(\n *       TE.left('a'),\n *       TE.alt(() => TE.left('b'))\n *     )(),\n *     E.left('b')\n *   )\n * }\n *\n * test()\n *\n * @category error handling\n * @since 2.0.0\n */\nexport var alt = \n/*#__PURE__*/ ET.alt(T.Monad);\n/**\n * Less strict version of [`alt`](#alt).\n *\n * The `W` suffix (short for **W**idening) means that the error and the return types will be merged.\n *\n * @category error handling\n * @since 2.9.0\n */\nexport var altW = alt;\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport var of = right;\n/**\n * @since 2.7.0\n */\nexport var throwError = left;\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport var URI = 'TaskEither';\n/**\n * The default [`ApplicativePar`](#applicativepar) instance returns the first error, if you want to\n * get all errors you need to provide a way to concatenate them via a `Semigroup`.\n *\n * @example\n * import * as E from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n * import * as RA from 'fp-ts/ReadonlyArray'\n * import * as S from 'fp-ts/Semigroup'\n * import * as string from 'fp-ts/string'\n * import * as T from 'fp-ts/Task'\n * import * as TE from 'fp-ts/TaskEither'\n *\n * interface User {\n *   readonly id: string\n *   readonly name: string\n * }\n *\n * const remoteDatabase: ReadonlyArray<User> = [\n *   { id: 'id1', name: 'John' },\n *   { id: 'id2', name: 'Mary' },\n *   { id: 'id3', name: 'Joey' }\n * ]\n *\n * const fetchUser = (id: string): TE.TaskEither<string, User> =>\n *   pipe(\n *     remoteDatabase,\n *     RA.findFirst((user) => user.id === id),\n *     TE.fromOption(() => `${id} not found`)\n *   )\n *\n * async function test() {\n *   assert.deepStrictEqual(\n *     await pipe(['id4', 'id5'], RA.traverse(TE.ApplicativePar)(fetchUser))(),\n *     E.left('id4 not found') // <= first error\n *   )\n *\n *   const Applicative = TE.getApplicativeTaskValidation(\n *     T.ApplyPar,\n *     pipe(string.Semigroup, S.intercalate(', '))\n *   )\n *\n *   assert.deepStrictEqual(\n *     await pipe(['id4', 'id5'], RA.traverse(Applicative)(fetchUser))(),\n *     E.left('id4 not found, id5 not found') // <= all errors\n *   )\n * }\n *\n * test()\n *\n * @category error handling\n * @since 2.7.0\n */\nexport function getApplicativeTaskValidation(A, S) {\n    var ap = ap_(A, E.getApplicativeValidation(S));\n    return {\n        URI: URI,\n        _E: undefined,\n        map: _map,\n        ap: function (fab, fa) { return pipe(fab, ap(fa)); },\n        of: of\n    };\n}\n/**\n * The default [`Alt`](#alt) instance returns the last error, if you want to\n * get all errors you need to provide a way to concatenate them via a `Semigroup`.\n *\n * See [`getAltValidation`](./Either.ts.html#getaltvalidation).\n *\n * @category error handling\n * @since 2.7.0\n */\nexport function getAltTaskValidation(S) {\n    var alt = ET.altValidation(T.Monad, S);\n    return {\n        URI: URI,\n        _E: undefined,\n        map: _map,\n        alt: function (fa, that) { return pipe(fa, alt(that)); }\n    };\n}\n/**\n * @category filtering\n * @since 2.10.0\n */\nexport var getCompactable = function (M) {\n    var C = E.getCompactable(M);\n    return {\n        URI: URI,\n        _E: undefined,\n        compact: compact_(T.Functor, C),\n        separate: separate_(T.Functor, C, E.Functor)\n    };\n};\n/**\n * @category filtering\n * @since 2.1.0\n */\nexport function getFilterable(M) {\n    var F = E.getFilterable(M);\n    var C = getCompactable(M);\n    var filter = filter_(T.Functor, F);\n    var filterMap = filterMap_(T.Functor, F);\n    var partition = partition_(T.Functor, F);\n    var partitionMap = partitionMap_(T.Functor, F);\n    return {\n        URI: URI,\n        _E: undefined,\n        map: _map,\n        compact: C.compact,\n        separate: C.separate,\n        filter: function (fa, predicate) { return pipe(fa, filter(predicate)); },\n        filterMap: function (fa, f) { return pipe(fa, filterMap(f)); },\n        partition: function (fa, predicate) { return pipe(fa, partition(predicate)); },\n        partitionMap: function (fa, f) { return pipe(fa, partitionMap(f)); }\n    };\n}\n/**\n * @category instances\n * @since 2.7.0\n */\nexport var Functor = {\n    URI: URI,\n    map: _map\n};\n/**\n * Maps the `Right` value of this `TaskEither` to the specified constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport var as = dual(2, as_(Functor));\n/**\n * Maps the `Right` value of this `TaskEither` to the void constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport var asUnit = asUnit_(Functor);\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport var flap = /*#__PURE__*/ flap_(Functor);\n/**\n * @category instances\n * @since 2.10.0\n */\nexport var Pointed = {\n    URI: URI,\n    of: of\n};\n/**\n * Runs computations in parallel.\n *\n * @category instances\n * @since 2.10.0\n */\nexport var ApplyPar = {\n    URI: URI,\n    map: _map,\n    ap: _apPar\n};\n/**\n * Combine two effectful actions, keeping only the result of the first.\n *\n * @since 2.0.0\n */\nexport var apFirst = /*#__PURE__*/ apFirst_(ApplyPar);\n/**\n * Less strict version of [`apFirst`](#apfirst).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @since 2.12.0\n */\nexport var apFirstW = apFirst;\n/**\n * Combine two effectful actions, keeping only the result of the second.\n *\n * @since 2.0.0\n */\nexport var apSecond = /*#__PURE__*/ apSecond_(ApplyPar);\n/**\n * Less strict version of [`apSecond`](#apsecond).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @since 2.12.0\n */\nexport var apSecondW = apSecond;\n/**\n * Runs computations in parallel.\n *\n * @category instances\n * @since 2.7.0\n */\nexport var ApplicativePar = {\n    URI: URI,\n    map: _map,\n    ap: _apPar,\n    of: of\n};\n/**\n * Runs computations sequentially.\n *\n * @category instances\n * @since 2.10.0\n */\nexport var ApplySeq = {\n    URI: URI,\n    map: _map,\n    ap: _apSeq\n};\n/**\n * Runs computations sequentially.\n *\n * @category instances\n * @since 2.7.0\n */\nexport var ApplicativeSeq = {\n    URI: URI,\n    map: _map,\n    ap: _apSeq,\n    of: of\n};\n/**\n * @category instances\n * @since 2.10.0\n */\nexport var Chain = {\n    URI: URI,\n    map: _map,\n    ap: _apPar,\n    chain: flatMap\n};\n/**\n * @category instances\n * @since 2.10.0\n */\nexport var Monad = {\n    URI: URI,\n    map: _map,\n    ap: _apPar,\n    chain: flatMap,\n    of: of\n};\n/**\n * @category instances\n * @since 2.10.0\n */\nexport var MonadIO = {\n    URI: URI,\n    map: _map,\n    ap: _apPar,\n    chain: flatMap,\n    of: of,\n    fromIO: fromIO\n};\n/**\n * @category instances\n * @since 2.10.0\n */\nexport var MonadTask = {\n    URI: URI,\n    map: _map,\n    ap: _apPar,\n    chain: flatMap,\n    of: of,\n    fromIO: fromIO,\n    fromTask: fromTask\n};\n/**\n * @category instances\n * @since 2.10.0\n */\nexport var MonadThrow = {\n    URI: URI,\n    map: _map,\n    ap: _apPar,\n    chain: flatMap,\n    of: of,\n    throwError: throwError\n};\n/**\n * @category instances\n * @since 2.10.0\n */\nexport var FromEither = {\n    URI: URI,\n    fromEither: fromEither\n};\n/**\n * @category instances\n * @since 2.10.0\n */\nexport var FromIO = {\n    URI: URI,\n    fromIO: fromIO\n};\n/**\n * @category instances\n * @since 2.10.0\n */\nexport var FromTask = {\n    URI: URI,\n    fromIO: fromIO,\n    fromTask: fromTask\n};\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.15.0\n */\nexport var tap = /*#__PURE__*/ dual(2, chainable.tap(Chain));\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import * as E from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n * import * as TE from 'fp-ts/TaskEither'\n *\n * const checkString = (value: string) => pipe(\n *   TE.of(value),\n *   TE.tapEither(() => value.length > 0 ? E.right('ok') : E.left('error'))\n * )\n *\n * async function test() {\n *   assert.deepStrictEqual(await checkString('')(), E.left('error'))\n *   assert.deepStrictEqual(await checkString('fp-ts')(), E.right('fp-ts'))\n * }\n *\n * test()\n *\n * @category combinators\n * @since 2.16.0\n */\nexport var tapEither = /*#__PURE__*/ dual(2, tapEither_(FromEither, Chain));\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as TE from 'fp-ts/TaskEither'\n * import * as E from 'fp-ts/Either'\n * import * as Console from 'fp-ts/Console'\n *\n *\n * // Will produce `Hello, fp-ts` to the stdout\n * const effectA = TE.tapIO(\n *   TE.of(1),\n *   (value) => Console.log(`Hello, ${value}`)\n * )\n *\n * // No output to the stdout\n * const effectB = pipe(\n *   TE.left('error'),\n *   TE.tapIO((value) => Console.log(`Hello, ${value}`))\n * )\n *\n * async function test() {\n *   assert.deepStrictEqual(await effectA(), E.of(1))\n *   assert.deepStrictEqual(await effectB(), E.left('error'))\n * }\n *\n * test()\n *\n * @category combinators\n * @since 2.16.0\n */\nexport var tapIO = /*#__PURE__*/ dual(2, tapIO_(FromIO, Chain));\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import * as TE from 'fp-ts/TaskEither'\n * import * as T from 'fp-ts/Task'\n * import * as E from 'fp-ts/Either'\n *\n *\n * const effect = TE.tapIO(\n *   TE.of(1),\n *   (value) => T.of(value + 1)\n * )\n *\n * async function test() {\n *   assert.deepStrictEqual(await effect(), E.of(1))\n * }\n *\n * test()\n *\n * @category combinators\n * @since 2.16.0\n */\nexport var tapTask = /*#__PURE__*/ dual(2, tapTask_(FromTask, Chain));\n/**\n * @category instances\n * @since 2.7.0\n */\nexport var Bifunctor = {\n    URI: URI,\n    bimap: mapBoth,\n    mapLeft: mapError\n};\n/**\n * @category instances\n * @since 2.7.0\n */\nexport var Alt = {\n    URI: URI,\n    map: _map,\n    alt: _alt\n};\n/**\n * @category conversions\n * @since 2.0.0\n */\nexport var fromOption = \n/*#__PURE__*/ fromOption_(FromEither);\n/**\n * Use `liftOption`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport var fromOptionK = \n/*#__PURE__*/ fromOptionK_(FromEither);\n/**\n * Use `flatMapOption`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport var chainOptionK = /*#__PURE__*/ chainOptionK_(FromEither, Chain);\n/**\n * Use `flatMapOption`.\n *\n * @category legacy\n * @since 2.13.2\n */\nexport var chainOptionKW = chainOptionK;\n/** @internal */\nvar _FromEither = {\n    fromEither: FromEither.fromEither\n};\n/**\n * @category lifting\n * @since 2.15.0\n */\nexport var liftNullable = /*#__PURE__*/ _.liftNullable(_FromEither);\n/**\n * @category lifting\n * @since 2.15.0\n */\nexport var liftOption = /*#__PURE__*/ _.liftOption(_FromEither);\n/** @internal */\nvar _FlatMap = {\n    flatMap: flatMap\n};\n/** @internal */\nvar _FromIO = {\n    fromIO: FromIO.fromIO\n};\n/** @internal */\nvar _FromTask = {\n    fromTask: fromTask\n};\n/**\n * @category sequencing\n * @since 2.15.0\n */\nexport var flatMapNullable = /*#__PURE__*/ _.flatMapNullable(_FromEither, _FlatMap);\n/**\n * @category sequencing\n * @since 2.15.0\n */\nexport var flatMapOption = /*#__PURE__*/ _.flatMapOption(_FromEither, _FlatMap);\n/**\n * @category sequencing\n * @since 2.15.0\n */\nexport var flatMapEither = /*#__PURE__*/ _.flatMapEither(_FromEither, _FlatMap);\n/**\n * @category sequencing\n * @since 2.15.0\n */\nexport var flatMapIO = /*#__PURE__*/ _.flatMapIO(_FromIO, _FlatMap);\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport var flatMapTask = /*#__PURE__*/ _.flatMapTask(_FromTask, _FlatMap);\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport var flatMapIOEither = /*#__PURE__*/ dual(2, function (self, f) {\n    return flatMap(self, fromIOEitherK(f));\n});\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport var flatMapTaskOption = /*#__PURE__*/ dual(3, function (self, f, onNone) {\n    return flatMap(self, function (a) { return fromTaskOption(function () { return onNone(a); })(f(a)); });\n});\n/**\n * Alias of `flatMapEither`.\n *\n * @category legacy\n * @since 2.4.0\n */\nexport var chainEitherK = flatMapEither;\n/**\n * Alias of `flatMapEither`.\n *\n * @category legacy\n * @since 2.6.1\n */\nexport var chainEitherKW = flatMapEither;\n/**\n * Alias of `tapEither`.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport var chainFirstEitherK = tapEither;\n/**\n * Alias of `tapEither`.\n *\n * Less strict version of [`chainFirstEitherK`](#chainfirsteitherk).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport var chainFirstEitherKW = tapEither;\n/**\n * @category lifting\n * @since 2.0.0\n */\nexport var fromPredicate = /*#__PURE__*/ fromPredicate_(FromEither);\n/**\n * @category filtering\n * @since 2.0.0\n */\nexport var filterOrElse = /*#__PURE__*/ filterOrElse_(FromEither, Chain);\n/**\n * Less strict version of [`filterOrElse`](#filterorelse).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category filtering\n * @since 2.9.0\n */\nexport var filterOrElseW = filterOrElse;\n/**\n * @category lifting\n * @since 2.4.0\n */\nexport var fromEitherK = /*#__PURE__*/ fromEitherK_(FromEither);\n/**\n * @category lifting\n * @since 2.10.0\n */\nexport var fromIOK = /*#__PURE__*/ fromIOK_(FromIO);\n/**\n * Alias of `flatMapIO`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport var chainIOK = flatMapIO;\n/**\n * Alias of `tapIO`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport var chainFirstIOK = tapIO;\n/**\n * @category lifting\n * @since 2.10.0\n */\nexport var fromTaskK = /*#__PURE__*/ fromTaskK_(FromTask);\n/**\n * Alias of `flatMapTask`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport var chainTaskK = flatMapTask;\n/**\n * Alias of `tapTask`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport var chainFirstTaskK = tapTask;\n/**\n * Alias of `flatMapIOEither`.\n *\n * Less strict version of [`chainIOEitherK`](#chainioeitherk).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category legacy\n * @since 2.6.1\n */\nexport var chainIOEitherKW = flatMapIOEither;\n/**\n * Alias of `flatMapIOEither`.\n *\n * @category legacy\n * @since 2.4.0\n */\nexport var chainIOEitherK = flatMapIOEither;\nexport function taskify(f) {\n    return function () {\n        var args = Array.prototype.slice.call(arguments);\n        return function () {\n            return new Promise(function (resolve) {\n                var cbResolver = function (e, r) { return (e != null ? resolve(_.left(e)) : resolve(_.right(r))); };\n                f.apply(null, args.concat(cbResolver));\n            });\n        };\n    };\n}\n/**\n * Make sure that a resource is cleaned up in the event of an exception (\\*). The release action is called regardless of\n * whether the body action throws (\\*) or returns.\n *\n * (\\*) i.e. returns a `Left`\n *\n * @since 2.0.0\n */\nexport var bracket = function (acquire, use, release) { return bracketW(acquire, use, release); };\n/**\n * Less strict version of [`bracket`](#bracket).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @since 2.12.0\n */\nexport var bracketW = function (acquire, use, release) {\n    return flatMap(acquire, function (a) { return T.flatMap(use(a), function (e) { return flatMap(release(a, e), function () { return T.of(e); }); }); });\n};\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n/**\n * @category do notation\n * @since 2.9.0\n */\nexport var Do = /*#__PURE__*/ of(_.emptyRecord);\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport var bindTo = /*#__PURE__*/ bindTo_(Functor);\nvar let_ = /*#__PURE__*/ let__(Functor);\nexport { \n/**\n * @category do notation\n * @since 2.13.0\n */\nlet_ as let };\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport var bind = /*#__PURE__*/ chainable.bind(Chain);\n/**\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category do notation\n * @since 2.8.0\n */\nexport var bindW = bind;\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport var apS = /*#__PURE__*/ apS_(ApplyPar);\n/**\n * Less strict version of [`apS`](#aps).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category do notation\n * @since 2.8.0\n */\nexport var apSW = apS;\n/**\n * @since 2.11.0\n */\nexport var ApT = /*#__PURE__*/ of(_.emptyReadonlyArray);\n// -------------------------------------------------------------------------------------\n// array utils\n// -------------------------------------------------------------------------------------\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport var traverseReadonlyNonEmptyArrayWithIndex = function (f) {\n    return flow(T.traverseReadonlyNonEmptyArrayWithIndex(f), T.map(E.traverseReadonlyNonEmptyArrayWithIndex(SK)));\n};\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativePar)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport var traverseReadonlyArrayWithIndex = function (f) {\n    var g = traverseReadonlyNonEmptyArrayWithIndex(f);\n    return function (as) { return (_.isNonEmpty(as) ? g(as) : ApT); };\n};\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport var traverseReadonlyNonEmptyArrayWithIndexSeq = function (f) {\n    return function (as) {\n        return function () {\n            return _.tail(as).reduce(function (acc, a, i) {\n                return acc.then(function (ebs) {\n                    return _.isLeft(ebs)\n                        ? acc\n                        : f(i + 1, a)().then(function (eb) {\n                            if (_.isLeft(eb)) {\n                                return eb;\n                            }\n                            ebs.right.push(eb.right);\n                            return ebs;\n                        });\n                });\n            }, f(0, _.head(as))().then(E.map(_.singleton)));\n        };\n    };\n};\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport var traverseReadonlyArrayWithIndexSeq = function (f) {\n    var g = traverseReadonlyNonEmptyArrayWithIndexSeq(f);\n    return function (as) { return (_.isNonEmpty(as) ? g(as) : ApT); };\n};\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport var traverseArrayWithIndex = traverseReadonlyArrayWithIndex;\n/**\n * Equivalent to `ReadonlyArray#traverse(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport var traverseArray = function (f) { return traverseReadonlyArrayWithIndex(function (_, a) { return f(a); }); };\n/**\n * Equivalent to `ReadonlyArray#sequence(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport var sequenceArray = \n/*#__PURE__*/ traverseArray(identity);\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport var traverseSeqArrayWithIndex = traverseReadonlyArrayWithIndexSeq;\n/**\n * Equivalent to `ReadonlyArray#traverse(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport var traverseSeqArray = function (f) { return traverseReadonlyArrayWithIndexSeq(function (_, a) { return f(a); }); };\n/**\n * Equivalent to `ReadonlyArray#sequence(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport var sequenceSeqArray = \n/*#__PURE__*/ traverseSeqArray(identity);\n// -------------------------------------------------------------------------------------\n// legacy\n// -------------------------------------------------------------------------------------\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport var chain = flatMap;\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.6.0\n */\nexport var chainW = flatMap;\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport var chainFirst = tap;\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.8.0\n */\nexport var chainFirstW = tap;\n/**\n * Alias of `tapError`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport var orElseFirst = tapError;\n/**\n * Alias of `tapError`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport var orElseFirstW = tapError;\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `TE.Functor` instead of `TE.taskEither`\n * (where `TE` is from `import TE from 'fp-ts/TaskEither'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport var taskEither = {\n    URI: URI,\n    bimap: mapBoth,\n    mapLeft: mapError,\n    map: _map,\n    of: of,\n    ap: _apPar,\n    chain: flatMap,\n    alt: _alt,\n    fromIO: fromIO,\n    fromTask: fromTask,\n    throwError: throwError\n};\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `TE.Functor` instead of `TE.taskEitherSeq`\n * (where `TE` is from `import TE from 'fp-ts/TaskEither'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport var taskEitherSeq = {\n    URI: URI,\n    bimap: mapBoth,\n    mapLeft: mapError,\n    map: _map,\n    of: of,\n    ap: _apSeq,\n    chain: flatMap,\n    alt: _alt,\n    fromIO: fromIO,\n    fromTask: fromTask,\n    throwError: throwError\n};\n/**\n * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport var getApplySemigroup = \n/*#__PURE__*/ getApplySemigroup_(ApplySeq);\n/**\n * Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport var getApplyMonoid = \n/*#__PURE__*/ getApplicativeMonoid(ApplicativeSeq);\n/**\n * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport var getSemigroup = function (S) {\n    return getApplySemigroup_(T.ApplySeq)(E.getSemigroup(S));\n};\n/**\n * Use [`getApplicativeTaskValidation`](#getapplicativetaskvalidation) and [`getAltTaskValidation`](#getalttaskvalidation) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function getTaskValidation(SE) {\n    var applicativeTaskValidation = getApplicativeTaskValidation(T.ApplicativePar, SE);\n    var altTaskValidation = getAltTaskValidation(SE);\n    return {\n        URI: URI,\n        _E: undefined,\n        map: _map,\n        ap: applicativeTaskValidation.ap,\n        of: of,\n        chain: flatMap,\n        bimap: mapBoth,\n        mapLeft: mapError,\n        alt: altTaskValidation.alt,\n        fromIO: fromIO,\n        fromTask: fromTask,\n        throwError: throwError\n    };\n}\n","import { errorClass, errorClassWithData } from 'error-kid';\nimport type { BaseIssue } from 'valibot';\n\nfunction msgToTuple(message?: string): [string?] {\n  return [message];\n}\n\nexport class ValidationError extends errorClassWithData<\n  { input: unknown; issues: BaseIssue<any>[] },\n  [input: unknown, issues: BaseIssue<any>[]]\n>(\n  'ValidationError',\n  (input, issues) => ({ input, issues }),\n  'Validation error',\n) {\n}\n\nexport class CSSVarsBoundError extends errorClass(\n  'CSSVarsBoundError',\n  'CSS variables are already bound',\n) {\n}\n\nexport class DeviceStorageMethodError extends errorClassWithData<\n  { error: string },\n  [error: string]\n>('DeviceStorageMethodError', error => ({ error }), error => [error]) {\n}\n\nexport class SecureStorageMethodError extends errorClassWithData<\n  { error: string },\n  [error: string]\n>('SecureStorageMethodError', error => ({ error }), error => [error]) {\n}\n\nexport class NotAvailableError extends errorClass<[message: string]>(\n  'NotAvailableError',\n  msgToTuple,\n) {\n}\n\nexport class InvalidEnvError extends errorClass<[message?: string]>(\n  'InvalidEnvError',\n  msgToTuple,\n) {\n}\n\nexport class FunctionUnavailableError extends errorClass<[message?: string]>(\n  'FunctionNotAvailableError',\n  msgToTuple,\n) {\n}\n\nexport class InvalidArgumentsError extends errorClass<[message: string, cause?: unknown]>(\n  'InvalidArgumentsError',\n  (message, cause) => [message, { cause }],\n) {\n}\n\nexport class ConcurrentCallError extends errorClass<[message: string]>(\n  'ConcurrentCallError',\n  msgToTuple,\n) {\n}\n\nexport class SetEmojiStatusError extends errorClass<[error: string]>(\n  'SetEmojiStatusError',\n  error => [`Failed to set emoji status: ${error}`],\n) {\n}\n\nexport class AccessDeniedError extends errorClass<[message: string]>(\n  'AccessDeniedError',\n  msgToTuple,\n) {\n}\n\nexport class FullscreenFailedError extends errorClass<[message: string]>(\n  'FullscreenFailedError',\n  msgToTuple,\n) {\n}\n\nexport class ShareMessageError extends errorClass<[error: string]>(\n  'ShareMessageError',\n  msgToTuple,\n) {\n}\n\nexport class UnknownThemeParamsKeyError extends errorClass<[key: string]>(\n  'UnknownThemeParamsKeyError',\n  key => [`Unknown theme params key passed: ${key}`],\n) {\n}\n","import {\n  type MethodName,\n  supports,\n  type MethodNameWithVersionedParams,\n  type MethodVersionedParams,\n} from '@tma.js/bridge';\nimport { type Computed, computed } from '@tma.js/signals';\nimport type {\n  If,\n  IsNever,\n  AnyFnAnyEither,\n  RightOfReturn,\n  LeftOfReturn,\n  MaybeMonadReturnTypeToCommon,\n  MaybeCommonReturnTypeToMonad,\n  AnyFn,\n} from '@tma.js/toolkit';\nimport type { Version } from '@tma.js/types';\nimport * as E from 'fp-ts/Either';\nimport * as O from 'fp-ts/Option';\nimport * as TE from 'fp-ts/TaskEither';\n\nimport { FunctionUnavailableError } from '@/errors.js';\nimport { access } from '@/helpers/access.js';\nimport type { MaybeAccessor } from '@/types.js';\n\ntype IfReturnsTask<Fn extends AnyFnAnyEither, A, B> =\n  ReturnType<Fn> extends TE.TaskEither<any, any> ? A : B;\n\ntype OptionsBasedRequires<O extends WithChecksOptions<any>> = O extends { requires: any }\n  ? true : false;\n\ntype OptionsBasedSupports<O extends WithChecksOptions<any>> = O extends { supports: any }\n  ? Extract<keyof O['supports'], string> : never;\n\ntype OptionsBasedFn<Opts extends WithChecksOptions<any>> = (...args: any[]) => (\n  Opts['returns'] extends 'plain'\n    ? any\n    : Opts['returns'] extends 'promise'\n      ? PromiseLike<any>\n      : Opts['returns'] extends 'task'\n        ? TE.TaskEither<any, any>\n        : E.Either<any, any>\n);\n\n/**\n * @returns Error text if something is wrong.\n */\nexport type CustomSupportFn = () => string | undefined;\n\nexport type Require =\n  | MethodName\n  | CustomSupportFn\n  | { every: (MethodName | CustomSupportFn)[] }\n  | { some: (MethodName | CustomSupportFn)[] };\n\n/**\n * A map where the key is a method name with versioned parameters, and the value is a tuple\n * containing the method and parameter names. The third tuple value is a function accepting\n * the wrapped function arguments and returning true if support check must be applied.\n */\nexport type SupportsMap<Args extends any[]> = {\n  [OptionName: string]: {\n    [M in MethodNameWithVersionedParams]: {\n      /**\n       * Method name.\n       * @example 'web_app_set_header_color'\n       */\n      method: M;\n      /**\n       * Method version-dependent parameter.\n       * @example `color`\n       */\n      param: MethodVersionedParams<M>;\n      /**\n       * @returns True if the support function should be called.\n       * @param args - function arguments.\n       */\n      shouldCheck: (...args: Args) => boolean;\n    };\n  }[MethodNameWithVersionedParams];\n};\n\ntype WrappedFnReturnType<Fn extends AnyFn> = ReturnType<Fn> extends E.Either<any, any>\n  ? E.Either<FunctionUnavailableError | LeftOfReturn<Fn>, RightOfReturn<Fn>>\n  : ReturnType<Fn> extends TE.TaskEither<any, any>\n    ? TE.TaskEither<FunctionUnavailableError | LeftOfReturn<Fn>, RightOfReturn<Fn>>\n    : ReturnType<Fn> extends PromiseLike<infer U>\n      ? TE.TaskEither<FunctionUnavailableError, U>\n      : E.Either<FunctionUnavailableError, ReturnType<Fn>>;\n\nexport type WrappedFn<Fn extends AnyFn> = (...args: Parameters<Fn>) => WrappedFnReturnType<Fn>;\n\nexport type WithChecksFp<\n  Fn extends AnyFn,\n  HasSupportCheck extends boolean,\n  SupportsMapKeySchema extends string = never,\n> =\n  & WrappedFn<Fn>\n  & {\n  /**\n   * A signal returning `true` if the function is available in the current environment and\n   * conditions.\n   *\n   * To be more accurate, the method checks the following:\n   * 1. The current environment is Telegram Mini Apps.\n   * 2. The SDK package is initialized (if this requirement is specified).\n   * 3. If passed, the `isSupported` signal returned true.\n   * 4. If passed, the `isMounted` signal returned true.\n   *\n   * *You should use this function when possible because it provides must-have code security\n   * mechanisms and makes a developer sure that he is using the package properly.*\n   *\n   * @returns True if the function is available in the current environment.\n   * @example\n   * if (backButton.show.isAvailable()) {\n   *   backButton.show();\n   * }\n   */\n    isAvailable: Computed<boolean>;\n    /**\n   * Calls the function only in case it is available.\n   *\n   * It uses the `isAvailable` internally to check if the function is available for call.\n   * @example\n   * backButton.show.ifAvailable();\n   */\n    ifAvailable(...args: Parameters<Fn>): O.Option<MaybeCommonReturnTypeToMonad<Fn>>;\n  }\n  & If<HasSupportCheck, {\n  /**\n   * The signal returning `true` if the function is supported by the Telegram client,\n   * including some possible additional conditions.\n   *\n   * It is highly recommended to use this signal only in certain narrow cases when only the\n   * function support check is required, but not its availability.\n   *\n   * This signal is not applying additional operations like checking if the current environment\n   * is Mini Apps and the SDK is initialized.\n   *\n   * To check if the function is available for use, use the `isAvailable` signal.\n   *\n   * @returns True if this function is supported.\n   * @see isAvailable\n   * @example\n   * if (backButton.show.isSupported()) {\n   *   console.log('The method is supported');\n   * }\n   */\n    isSupported: Computed<boolean>;\n  }, {}>\n  & If<IsNever<SupportsMapKeySchema>, {}, {\n  /**\n   * A map where the key is the function-specific option name and value is a signal indicating\n   * if it is supported by the current environment.\n   * @example\n   * if (miniApp.setHeaderColor.isAvailable()) {\n   *   if (miniApp.setHeaderColor.supports('rgb')) {\n   *     miniApp.setHeaderColor('#ffaabb');\n   *   } else {\n   *     miniApp.setHeaderColor('bg_color');\n   *   }\n   * }\n   */\n    supports: (key: SupportsMapKeySchema) => boolean;\n  }>;\n\nexport type WithChecks<\n  Fn extends AnyFn,\n  HasSupportCheck extends boolean,\n  SupportsMapKeySchema extends string = never,\n> =\n  & ((...args: Parameters<Fn>) => MaybeMonadReturnTypeToCommon<Fn>)\n  & Omit<WithChecksFp<Fn, HasSupportCheck, SupportsMapKeySchema>, 'ifAvailable'>\n  & {\n  /**\n   * Calls the function only in case it is available.\n   *\n   * It uses the `isAvailable` internally to check if the function is available for call.\n   * @example\n   * backButton.show.ifAvailable();\n   */\n    ifAvailable(...args: Parameters<Fn>):\n      | { ok: true; data: MaybeMonadReturnTypeToCommon<Fn> }\n      | { ok: false };\n  };\n\nexport interface WithChecksOptions<Fn extends AnyFn> {\n  /**\n   * Signal returning true if the owning component is mounted.\n   */\n  isMounted?: () => boolean;\n  /**\n   * Signal returning true if the owning component is mounting.\n   */\n  isMounting?: () => boolean;\n  /**\n   * A value determining the function requirements. This will enable additional checks for\n   * the function before being called.\n   */\n  requires?: Require;\n  /**\n   * A signal to retrieve the current Telegram Mini Apps version or the value itself.\n   */\n  isTma: MaybeAccessor<boolean>;\n  /**\n   * A map where the key is a method name with versioned parameters, and the value is a tuple\n   * containing the method and parameter names. The third tuple value is a function accepting\n   * the wrapped function arguments and returning true if support check must be applied.\n   */\n  supports?: SupportsMap<Parameters<Fn>>;\n  /**\n   * A signal to retrieve the current Telegram Mini Apps version or the value itself.\n   */\n  version?: MaybeAccessor<Version>;\n  /**\n   * Allows to determine what exactly should be returned from the function - TaskEither or Either.\n   * There is no other way to know it until the function itself is called, but we need to perform\n   * some checks before calling it and return a valid value based on the function return type.\n   */\n  returns: Fn extends AnyFnAnyEither\n    ? IfReturnsTask<Fn, 'task', 'either'>\n    : ReturnType<Fn> extends PromiseLike<any> ? 'promise' : 'plain';\n}\n\nexport function withChecksFp<Fn extends AnyFn, O extends WithChecksOptions<Fn>>(\n  fn: Fn,\n  options: O,\n): WithChecksFp<Fn, OptionsBasedRequires<O>, OptionsBasedSupports<O>> {\n  const version = computed(() => access(options.version) || '100');\n  const isTma = computed(() => access(options.isTma));\n\n  // Simplify the isSupported value to work with an array of validators or a single object.\n  const { requires: optionsIsSupported, returns } = options;\n  const isSupportedSimplified = optionsIsSupported\n    ? typeof optionsIsSupported === 'object'\n      ? optionsIsSupported\n      : { every: [optionsIsSupported] }\n    : undefined;\n\n  /**\n   * @param optionName - target option.\n   * @returns True if specified option is supported.\n   */\n  const isOptionSupported = (optionName: string): boolean => {\n    if (!options.supports) {\n      return true;\n    }\n    const optionSettings = options.supports[optionName];\n    return supports(optionSettings.method, optionSettings.param, version());\n  };\n\n  /**\n   * @returns All found errors according to the isSupported variable value.\n   */\n  const calculateSupportError = (): string | undefined => {\n    // isSupported was not specified. In this case, we assume that the function has no\n    // dependencies and is always supported.\n    if (!isSupportedSimplified) {\n      return;\n    }\n    const [mode, requirements] = 'every' in isSupportedSimplified\n      ? ['every', isSupportedSimplified.every] as const\n      : ['some', isSupportedSimplified.some] as const;\n\n    for (let i = 0; i < requirements.length; i++) {\n      const requirement = requirements[i];\n      const error = typeof requirement === 'function'\n        ? requirement()\n        : supports(requirement, version())\n          ? undefined\n          : `it is unsupported in Mini Apps version ${version()}`;\n      // Return only if there was an error and all requirements must be satisfied, or\n      // this was the last one requirement (when some of the requirements must be met).\n      if (error && (mode === 'every' || i === requirements.length - 1)) {\n        return error;\n      }\n    }\n  };\n\n  /**\n   * @returns An error related to supports.<name> check.\n   */\n  const calculateOptionSupportError = (\n    ...args: Parameters<Fn>\n  ): string | undefined => {\n    for (const k in options.supports) {\n      if (options.supports[k].shouldCheck(...args) && !isOptionSupported(k)) {\n        return `option ${k} is not supported in Mini Apps version ${version()}`;\n      }\n    }\n  };\n\n  const isSupported = computed(() => !calculateSupportError());\n  const isInitialized = computed(() => version() !== '0.0');\n  const isMounted = computed(() => (options.isMounted ? options.isMounted() : true));\n  const isAvailable = computed(\n    () => isTma()\n      && isInitialized()\n      && isSupported()\n      && isMounted(),\n  );\n\n  const wrapError = (message: string): WrappedFnReturnType<Fn> => {\n    const err = new FunctionUnavailableError(message);\n    return (['task', 'promise'].includes(options.returns)\n      ? TE.left(err)\n      : E.left(err)) as WrappedFnReturnType<Fn>;\n  };\n\n  const call = (...args: Parameters<Fn>): MaybeCommonReturnTypeToMonad<Fn> => {\n    if (returns === 'plain') {\n      return E.tryCatch(() => fn(...args), e => e) as MaybeCommonReturnTypeToMonad<Fn>;\n    }\n    if (returns === 'promise') {\n      return TE.tryCatch(() => fn(...args), e => e) as MaybeCommonReturnTypeToMonad<Fn>;\n    }\n    return fn(...args);\n  };\n\n  return Object.assign(\n    (...args: Parameters<Fn>): WrappedFnReturnType<Fn> => {\n      const errMessagePrefix = 'Unable to call function:';\n      if (!isTma()) {\n        return wrapError(`${errMessagePrefix} it can't be called outside Mini Apps`);\n      }\n      if (!isInitialized()) {\n        return wrapError(`${errMessagePrefix} the SDK was not initialized. Use the SDK init() function`);\n      }\n      const supportErr = calculateSupportError();\n      if (supportErr) {\n        return wrapError(`${errMessagePrefix} ${supportErr}`);\n      }\n      const supportsOptionErr = calculateOptionSupportError(...args);\n      if (supportsOptionErr) {\n        return wrapError(`${errMessagePrefix} ${supportsOptionErr}`);\n      }\n      if (!isMounted()) {\n        const message = options.isMounting?.()\n          ? 'mounting. Wait for the mount completion'\n          : 'unmounted. Use the mount() method';\n        return wrapError(`${errMessagePrefix} the component is ${message}`);\n      }\n      return call(...args) as WrappedFnReturnType<Fn>;\n    },\n    fn,\n    {\n      isAvailable,\n      ifAvailable(...args: Parameters<Fn>): O.Option<MaybeCommonReturnTypeToMonad<Fn>> {\n        return isAvailable() ? O.some(call(...args)) : O.none;\n      },\n    },\n    isSupportedSimplified ? { isSupported } : {},\n    options.supports ? { supports: isOptionSupported } : {},\n  );\n}\n\nexport function createWithChecksFp<O extends WithChecksOptions<any>>(options: O) {\n  return <Fn extends OptionsBasedFn<O>>(fn: Fn): WithChecksFp<\n    Fn,\n    OptionsBasedRequires<O>,\n    OptionsBasedSupports<O>\n  > => withChecksFp(fn, options);\n}\n","import type { PostEventError, MethodName, MethodParams } from '@tma.js/bridge';\nimport { computed, type Computed } from '@tma.js/signals';\nimport * as E from 'fp-ts/Either';\nimport { pipe } from 'fp-ts/function';\n\nimport { Mountable } from '@/composables/Mountable.js';\nimport { Stateful } from '@/composables/Stateful.js';\nimport type { SharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport type { WithPostEvent } from '@/fn-options/withPostEvent.js';\nimport type { WithStateRestore } from '@/fn-options/withStateRestore.js';\nimport type { WithVersion } from '@/fn-options/withVersion.js';\nimport { createIsSupportedSignal } from '@/helpers/createIsSupportedSignal.js';\nimport { removeUndefined } from '@/helpers/removeUndefined.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport {\n  type WithChecksFp,\n  type WithChecks,\n  createWithChecksFp,\n} from '@/with-checks/withChecksFp.js';\n\ntype ButtonEither = E.Either<PostEventError, void>;\n\ntype BoolFields<S> = {\n  [K in keyof S]-?: S[K] extends boolean ? K : never;\n}[keyof S];\n\nexport interface ButtonOptions<S, M extends MethodName>\n  extends SharedFeatureOptions,\n  WithStateRestore<S>,\n  WithPostEvent,\n  WithVersion {\n  /**\n   * The initial button state.\n   */\n  initialState: S;\n  /**\n   * Removes a component click listener.\n   * @param listener - a listener to remove.\n   * @param once - should the listener be called only once.\n   */\n  offClick: (listener: VoidFunction, once?: boolean) => void;\n  /**\n   * Adds a component click listener.\n   * @returns A function to remove listener.\n   * @param listener - a listener to add.\n   * @param once - should the listener be called only once.\n   */\n  onClick: (listener: VoidFunction, once?: boolean) => VoidFunction;\n  /**\n   * A Mini Apps method to commit changes.\n   */\n  method: M;\n  /**\n   * A function to create method payload.\n   * @param state\n   */\n  payload: (state: S) => MethodParams<M>;\n}\n\nexport class Button<S extends object, M extends MethodName> {\n  constructor({\n    isTma,\n    storage,\n    onClick,\n    offClick,\n    initialState,\n    isPageReload,\n    postEvent,\n    payload,\n    method,\n    version,\n  }: ButtonOptions<S, M>) {\n    const stateful = new Stateful({\n      initialState,\n      onChange(state) {\n        storage.set(state);\n      },\n    });\n    const mountable = new Mountable<S>({\n      initialState,\n      isPageReload,\n      onMounted: stateful.setState,\n      restoreState: storage.get,\n    });\n\n    const wrapOptions = { version, requires: method, isTma };\n    const wrapSupportedPlain = createWithChecksFp({\n      ...wrapOptions,\n      returns: 'plain',\n    });\n    const wrapMountedEither = createWithChecksFp({\n      ...wrapOptions,\n      returns: 'either',\n      isMounted: mountable.isMounted,\n    });\n\n    this.isMounted = mountable.isMounted;\n    this.isSupported = createIsSupportedSignal(method, version);\n    this.state = stateful.state;\n\n    this.setStateFp = wrapMountedEither(state => {\n      const nextState = { ...this.state(), ...removeUndefined(state) };\n      if (!stateful.hasDiff(nextState)) {\n        return E.right(undefined);\n      }\n      return pipe(\n        postEvent(method as any, payload(nextState)),\n        E.map(() => {\n          stateful.setState(nextState);\n        }),\n      );\n    });\n    this.setState = throwifyWithChecksFp(this.setStateFp);\n    this.onClickFp = wrapSupportedPlain(onClick);\n    this.onClick = throwifyWithChecksFp(this.onClickFp);\n    this.offClickFp = wrapSupportedPlain(offClick);\n    this.offClick = throwifyWithChecksFp(this.offClickFp);\n    this.mountFp = wrapSupportedPlain(() => {\n      const nothing = () => undefined;\n      return pipe(mountable.mount(), E.match(nothing, nothing));\n    });\n    this.mount = throwifyWithChecksFp(this.mountFp);\n    this.unmount = mountable.unmount;\n    this.stateSetters = key => {\n      const wrapped = wrapMountedEither(value => {\n        return this.setStateFp({ [key]: value } as unknown as Partial<S>);\n      });\n      return [throwifyWithChecksFp(wrapped), wrapped];\n    };\n    this.stateBoolSetters = <K extends keyof S>(key: K) => {\n      const [, setFp] = this.stateSetters(key);\n      const setFalse = wrapMountedEither(() => setFp(false as S[K]));\n      const setTrue = wrapMountedEither(() => setFp(true as S[K]));\n      return [\n        [throwifyWithChecksFp(setFalse), setFalse],\n        [throwifyWithChecksFp(setTrue), setTrue],\n      ];\n    };\n  }\n\n  /**\n   * Signal indicating if the component is currently mounted.\n   */\n  readonly isMounted: Computed<boolean>;\n\n  /**\n   * Signal indicating if the component is supported.\n   */\n  readonly isSupported: Computed<boolean>;\n\n  /**\n   * Complete button state.\n   */\n  readonly state: Computed<S>;\n\n  /**\n   * @returns A computed based on the specified state and its related key.\n   * @param key - a key to use.\n   */\n  stateGetter<K extends keyof S>(key: K): Computed<S[K]> {\n    return computed(() => this.state()[key]);\n  }\n\n  /**\n   * @returns A setter with checks for the specified key.\n   * @param key\n   */\n  readonly stateSetters: <K extends keyof S>(key: K) => [\n    throwing: WithChecks<(value: S[K]) => void, true>,\n    fp: WithChecksFp<(value: S[K]) => ButtonEither, true>,\n  ];\n\n  /**\n   * @returns Setters with checks to set a specified boolean key.\n   * @param key\n   */\n  readonly stateBoolSetters: <K extends BoolFields<S>>(key: K) => [\n    setFalse: [\n      throwing: WithChecks<() => void, true>,\n      fp: WithChecksFp<() => ButtonEither, true>,\n    ],\n    setTrue: [\n      throwing: WithChecks<() => void, true>,\n      fp: WithChecksFp<() => ButtonEither, true>,\n    ],\n  ];\n\n  /**\n   * Updates the button state.\n   */\n  readonly setStateFp: WithChecksFp<(state: Partial<S>) => ButtonEither, true>;\n\n  /**\n   * @see setStateFp\n   */\n  readonly setState: WithChecks<(state: Partial<S>) => void, true>;\n\n  /**\n   * Adds a new button listener.\n   * @param listener - event listener.\n   * @param once - should the listener be called only once.\n   * @returns A function to remove bound listener.\n   * @example\n   * const off = button.onClick(() => {\n   *   console.log('User clicked the button');\n   *   off();\n   * });\n   */\n  readonly onClickFp: WithChecksFp<(listener: VoidFunction, once?: boolean) => VoidFunction, true>;\n\n  /**\n   * @see onClickFp\n   */\n  readonly onClick: WithChecks<(listener: VoidFunction, once?: boolean) => VoidFunction, true>;\n\n  /**\n   * Removes the button click listener.\n   * @param listener - event listener.\n   * @param once - should the listener be called only once.\n   * @example\n   * function listener() {\n   *   console.log('User clicked the button');\n   *   button.offClick(listener);\n   * }\n   * button.onClick(listener);\n   */\n  readonly offClickFp: WithChecksFp<\n    (listener: VoidFunction, once?: boolean) => void,\n    true\n  >;\n\n  /**\n   * @see offClickFp\n   */\n  readonly offClick: WithChecks<(listener: VoidFunction, once?: boolean) => void, true>;\n\n  /**\n   * Mounts the component restoring its state.\n   * @since Mini Apps v6.1\n   */\n  readonly mountFp: WithChecksFp<() => void, true>;\n\n  /**\n   * @see mountFp\n   */\n  readonly mount: WithChecks<() => void, true>;\n\n  /**\n   * Unmounts the component.\n   *\n   * Note that this function does not remove listeners added via the `onClick`\n   * function, so you have to remove them on your own.\n   * @see onClick\n   */\n  readonly unmount: () => void;\n}\n","import type { PostEventError } from '@tma.js/bridge';\nimport type { Computed } from '@tma.js/signals';\nimport * as E from 'fp-ts/Either';\n\nimport { Button, type ButtonOptions } from '@/composables/Button.js';\nimport type { WithChecksFp, WithChecks } from '@/with-checks/withChecksFp.js';\n\nexport interface BackButtonState {\n  isVisible: boolean;\n}\n\nexport type BackButtonOptions = Omit<\n  ButtonOptions<BackButtonState, 'web_app_setup_back_button'>,\n  'method' | 'payload' | 'initialState'\n>;\n\n/**\n * @since Mini Apps v6.1\n */\nexport class BackButton {\n  constructor(options: BackButtonOptions) {\n    const button = new Button({\n      ...options,\n      method: 'web_app_setup_back_button',\n      payload: state => ({ is_visible: state.isVisible }),\n      initialState: { isVisible: false },\n    });\n\n    this.isVisible = button.stateGetter('isVisible');\n    this.isMounted = button.isMounted;\n    this.isSupported = button.isSupported;\n    [[this.hide, this.hideFp], [this.show, this.showFp]] = button.stateBoolSetters('isVisible');\n    this.onClick = button.onClick;\n    this.onClickFp = button.onClickFp;\n    this.offClick = button.offClick;\n    this.offClickFp = button.offClickFp;\n    this.mount = button.mount;\n    this.mountFp = button.mountFp;\n    this.unmount = button.unmount;\n  }\n\n  /**\n   * Signal indicating if the component is currently visible.\n   */\n  readonly isVisible: Computed<boolean>;\n\n  /**\n   * Signal indicating if the component is currently mounted.\n   */\n  readonly isMounted: Computed<boolean>;\n\n  /**\n   * Signal indicating if the component is supported.\n   */\n  readonly isSupported: Computed<boolean>;\n\n  /**\n   * Hides the button.\n   * @since Mini Apps v6.1\n   */\n  readonly hideFp: WithChecksFp<() => E.Either<PostEventError, void>, true>;\n\n  /**\n   * @see hideFp\n   */\n  readonly hide: WithChecks<() => void, true>;\n\n  /**\n   * Shows the button.\n   * @since Mini Apps v6.1\n   */\n  readonly showFp: WithChecksFp<() => E.Either<PostEventError, void>, true>;\n\n  /**\n   * @see showFp\n   */\n  readonly show: WithChecks<() => void, true>;\n\n  /**\n   * Adds a new button listener.\n   * @param listener - event listener.\n   * @param once - should the listener be called only once.\n   * @returns A function to remove bound listener.\n   * @since Mini Apps v6.1\n   * @example\n   * const off = button.onClick(() => {\n   *   console.log('User clicked the button');\n   *   off();\n   * });\n   */\n  readonly onClickFp: WithChecksFp<\n    (listener: VoidFunction, once?: boolean) => VoidFunction,\n    true\n  >;\n\n  /**\n   * @see onClickFp\n   */\n  readonly onClick: WithChecks<(listener: VoidFunction, once?: boolean) => VoidFunction, true>;\n\n  /**\n   * Removes the button click listener.\n   * @param listener - event listener.\n   * @param once - should the listener be called only once.\n   * @since Mini Apps v6.1\n   * @example\n   * function listener() {\n   *   console.log('User clicked the button');\n   *   button.offClick(listener);\n   * }\n   * button.onClick(listener);\n   */\n  readonly offClickFp: WithChecksFp<\n    (listener: VoidFunction, once?: boolean) => void,\n    true\n  >;\n\n  /**\n   * @see offClickFp\n   */\n  readonly offClick: WithChecks<(listener: VoidFunction, once?: boolean) => void, true>;\n\n  /**\n   * Mounts the component restoring its state.\n   * @since Mini Apps v6.1\n   */\n  readonly mountFp: WithChecksFp<() => void, true>;\n\n  /**\n   * @see mountFp\n   */\n  readonly mount: WithChecks<() => void, true>;\n\n  /**\n   * Unmounts the component.\n   *\n   * Note that this function does not remove listeners added via the `onClick`\n   * function, so you have to remove them on your own.\n   * @see onClick\n   */\n  readonly unmount: () => void;\n}\n","import { isTMAFp } from '@tma.js/bridge';\nimport { computed } from '@tma.js/signals';\n\nimport type { MaybeAccessor } from '@/types.js';\n\nexport interface SharedFeatureOptions {\n  /**\n   * True if the current environment is Telegram Mini Apps.\n   */\n  isTma: MaybeAccessor<boolean>;\n}\n\nexport function sharedFeatureOptions(): SharedFeatureOptions {\n  return { isTma: computed(() => isTMAFp()) };\n}\n","import { access } from '@/helpers/access.js';\nimport type { MaybeAccessor } from '@/types.js';\n\nexport function createFnOption<T>(mix: MaybeAccessor<T>) {\n  return <O extends object>(obj: O) => {\n    return { ...obj, ...access(mix) };\n  };\n}\n","import {\n  computed,\n  type Computed,\n  type Signal,\n  signal,\n  type SignalOptions,\n} from '@tma.js/signals';\n\nexport type SignalsTuple<T> = [Signal<T>, Computed<T>];\n\nconst signals: (Signal<any> | Computed<any>)[] = [];\n\n/**\n * Creates a new signal with the initial value.\n * @param initialValue - the initial value.\n * @param options - additional options.\n */\nexport function createSignal<T>(\n  initialValue: T,\n  options?: SignalOptions<T>,\n): Signal<T>;\n\n/**\n * Creates a new signal without the initial value.\n * @param initialValue - the initial value.\n * @param options - additional options.\n */\nexport function createSignal<T>(\n  initialValue?: T,\n  options?: SignalOptions<T | undefined>,\n): Signal<T | undefined>;\n\n// #__NO_SIDE_EFFECTS__\nexport function createSignal<T>(\n  initialValue?: T,\n  options?: SignalOptions<T | undefined>,\n): Signal<T | undefined> {\n  const s = signal(initialValue, options);\n  signals.push(s);\n  return s;\n}\n\n/**\n * Creates a signal, which wil be automatically updated if some of its dependant signals were\n * modified.\n * @param fn - computation function.\n * @param options - additional functions.\n */\n// #__NO_SIDE_EFFECTS__\nexport function createComputed<T>(fn: (prev?: T) => T, options?: SignalOptions<T>): Computed<T> {\n  const s = computed(fn, options);\n  signals.push(s);\n  return s;\n}\n\n/**\n * Resets all signals states.\n */\nexport function resetSignals() {\n  signals.forEach(s => {\n    s.unsubAll();\n    'reset' in s && s.reset();\n  });\n}\n\n/**\n * @returns A tuple, containing a manual and computed signals. The computed signal is based on\n * the manual one.\n * @param initialValue - the initial value.\n * @param options - additional options.\n */\nexport function createSignalsTuple<T>(\n  initialValue: T,\n  options?: SignalOptions<T>,\n): SignalsTuple<T>;\n\n/**\n * @returns A tuple, containing a manual and computed signals. The computed signal is based on\n * the manual one.\n * @param initialValue - an initial value.\n * @param options - additional options.\n */\nexport function createSignalsTuple<T>(\n  initialValue?: T,\n  options?: SignalOptions<T | undefined>,\n): SignalsTuple<T | undefined>;\n\n// #__NO_SIDE_EFFECTS__\nexport function createSignalsTuple<T>(\n  initialValue?: T,\n  options?: SignalOptions<T | undefined>,\n): SignalsTuple<T | undefined> {\n  const s = createSignal(initialValue, options);\n  return [s, createComputed(s)];\n}\n","import { postEventFp as _postEventFp, type PostEventFpFn, type PostEventFn } from '@tma.js/bridge';\nimport { throwifyAnyEither } from '@tma.js/toolkit';\n\nimport { createSignal } from '@/globals/signals-registry.js';\n\nexport const postEventFpSignal = createSignal(_postEventFp);\n\nexport const postEventFp: PostEventFpFn = (...args: any[]) => {\n  return (postEventFpSignal as any)()(...args);\n};\n\nexport const postEvent: PostEventFn = (...args: any[]) => {\n  return throwifyAnyEither((postEventFp as any)(...args));\n};\n","import { type PostEventFpFn } from '@tma.js/bridge';\n\nimport { createFnOption } from '@/fn-options/createFnOption.js';\nimport { postEventFp } from '@/globals/postEvent.js';\n\nexport interface WithPostEvent {\n  /**\n   * A postEvent function to use to call Mini Apps methods.\n   */\n  postEvent: PostEventFpFn;\n}\n\nexport const withPostEvent = createFnOption<WithPostEvent>({\n  postEvent: postEventFp,\n});\n","import { getStorageValue, setStorageValue } from '@tma.js/toolkit';\n\nexport interface ComponentStorage<T> {\n  get: () => T | undefined;\n  set: (value: T) => void;\n}\n\n/**\n * Creates a new sessionStorage-based component storage.\n * @param key - session storage key to use.\n */\nexport function createComponentSessionStorage<T>(key: string): ComponentStorage<T> {\n  return {\n    get: () => getStorageValue<T>(key),\n    set(value) {\n      setStorageValue<T>(key, value);\n    },\n  };\n}\n","/**\n * Returns the first navigation entry from window.performance.\n * @returns First navigation entry or null, in case performance functionality is not supported\n * or navigation entry was not found.\n */\nfunction getFirstNavigationEntry(): PerformanceNavigationTiming | undefined {\n  return performance.getEntriesByType('navigation')[0] as PerformanceNavigationTiming | undefined;\n}\n\n/**\n * @returns True, if the current page was reloaded.\n * @see https://stackoverflow.com/a/36444134/11894710\n */\nexport function isPageReload(): boolean {\n  const entry = getFirstNavigationEntry();\n  return !!entry && entry.type === 'reload';\n}\n","import { createFnOption } from '@/fn-options/createFnOption.js';\nimport { type ComponentStorage, createComponentSessionStorage } from '@/helpers/component-storage.js';\nimport { isPageReload } from '@/helpers/navigation.js';\nimport type { MaybeAccessor } from '@/types.js';\n\nexport interface WithStateRestore<T> {\n  /**\n   * A storage the component could use to store its data.\n   */\n  storage: ComponentStorage<T>;\n  /**\n   * True if the current page is reloaded.\n   */\n  isPageReload: MaybeAccessor<boolean>;\n}\n\nexport function withStateRestore<S>(storageName: string) {\n  return createFnOption<WithStateRestore<S>>({\n    storage: createComponentSessionStorage<S>(storageName),\n    isPageReload,\n  });\n}\n","import type { Version } from '@tma.js/types';\n\nimport { createSignal } from '@/globals/signals-registry.js';\n\n/**\n * The current Mini Apps version.\n */\nexport const version = createSignal<Version>('0.0');\n","import type { Version } from '@tma.js/types';\n\nimport { createFnOption } from '@/fn-options/createFnOption.js';\nimport { version } from '@/globals/version.js';\nimport type { MaybeAccessor } from '@/types.js';\n\nexport interface WithVersion {\n  /**\n   * The currently supported Telegram Mini Apps version by the Telegram client.\n   */\n  version: MaybeAccessor<Version>;\n}\n\nexport const withVersion = createFnOption<WithVersion>({ version });\n","import { on, off, type EventName } from '@tma.js/bridge';\nimport { pipe } from 'fp-ts/function';\n\nimport { sharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport { withPostEvent } from '@/fn-options/withPostEvent.js';\nimport { withStateRestore } from '@/fn-options/withStateRestore.js';\nimport { withVersion } from '@/fn-options/withVersion.js';\n\nexport function buttonOptions<S>(storageName: string, trackedClickEvent: EventName) {\n  return {\n    ...pipe(\n      sharedFeatureOptions(),\n      withPostEvent,\n      withVersion,\n      withStateRestore<S>(storageName),\n    ),\n    onClick(listener: VoidFunction, once?: boolean): VoidFunction {\n      return on(trackedClickEvent, listener, once);\n    },\n    offClick(listener: VoidFunction, once?: boolean): void {\n      off(trackedClickEvent, listener, once);\n    },\n  };\n}\n","import { BackButton } from '@/features/BackButton/BackButton.js';\nimport { buttonOptions } from '@/fn-options/buttonOptions.js';\n\nexport const backButton = new BackButton(buttonOptions('backButton', 'back_button_pressed'));\n","import { batch, computed, signal } from '@tma.js/signals';\nimport * as TE from 'fp-ts/TaskEither';\nimport { pipe } from 'fp-ts/function';\n\nimport { access } from '@/helpers/access.js';\nimport type { AsyncOptions, MaybeAccessor } from '@/types.js';\n\nexport interface AsyncMountableOptions<S, E> {\n  /**\n   * A function to retrieve the initial state.\n   * @param options - additional options.\n   */\n  initialState: (options?: AsyncOptions) => TE.TaskEither<E, S>;\n  /**\n   * @returns True if the current page was reloaded.\n   */\n  isPageReload: MaybeAccessor<boolean>;\n  /**\n   * A function to call whenever the component was mounted.\n   * @param state - restored state.\n   */\n  onMounted?: (state: S) => void;\n  /**\n   * A function to call whenever the component was unmounted.\n   */\n  onUnmounted?: VoidFunction;\n  /**\n   * Attempts to restore previously saved component state. This function\n   * will only be called if the current page was reloaded.\n   */\n  restoreState: () => (S | undefined);\n}\n\nexport class AsyncMountable<S extends object, E> {\n  constructor({\n    initialState,\n    onMounted,\n    restoreState,\n    onUnmounted,\n    isPageReload,\n  }: AsyncMountableOptions<S, E>) {\n    this.mount = options => {\n      if (this._isMounted()) {\n        return TE.right(undefined);\n      }\n      const restored = access(isPageReload) ? restoreState() : undefined;\n      return pipe(\n        restored ? TE.right(restored) : initialState(options),\n        TE.map(state => {\n          // The user could call mount several times in a row while the\n          // component was still mounting. We should prevent calling the\n          // same hooks several times in this case.\n          if (!this._isMounted()) {\n            batch(() => {\n              this._isMounted.set(true);\n              onMounted?.(state);\n            });\n          }\n        }),\n      );\n    };\n\n    this.unmount = () => {\n      if (this._isMounted()) {\n        batch(() => {\n          this._isMounted.set(false);\n          onUnmounted?.();\n        });\n      }\n    };\n  }\n\n  private readonly _isMounted = signal(false);\n\n  /**\n   * Signal indicating if the component is mounted.\n   */\n  readonly isMounted = computed(this._isMounted);\n\n  /**\n   * Mounts the component restoring its state and calling required side effects.\n   * @param options - additional execution options.\n   */\n  readonly mount: (options?: AsyncOptions) => TE.TaskEither<E, void>;\n\n  /**\n   * Unmounts the component.\n   */\n  readonly unmount: () => void;\n}\n","import type {\n  RequestError,\n  PostEventError,\n  EventPayload,\n  BiometryAuthRequestStatus,\n  EventListener,\n  BiometryTokenUpdateStatus,\n} from '@tma.js/bridge';\nimport type { Computed } from '@tma.js/signals';\nimport { BetterPromise } from 'better-promises';\nimport * as E from 'fp-ts/Either';\nimport * as TE from 'fp-ts/TaskEither';\nimport { pipe } from 'fp-ts/function';\n\nimport { AsyncMountable } from '@/composables/AsyncMountable.js';\nimport { Stateful } from '@/composables/Stateful.js';\nimport { NotAvailableError } from '@/errors.js';\nimport type {\n  BiometryAuthenticateOptions, BiometryOptions,\n  BiometryRequestAccessOptions,\n  BiometryState,\n  BiometryUpdateTokenOptions,\n} from '@/features/Biometry/types.js';\nimport { createIsSupportedSignal } from '@/helpers/createIsSupportedSignal.js';\nimport type { AsyncOptions } from '@/types.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport { createWithChecksFp, WithChecks, WithChecksFp } from '@/with-checks/withChecksFp.js';\n\ntype BiometryTask<T> = TE.TaskEither<RequestError, T>;\n\ninterface AuthenticateResult {\n  /**\n   * Authentication status.\n   */\n  status: BiometryAuthRequestStatus;\n  /**\n   * Token from the local secure storage saved previously.\n   */\n  token?: string;\n}\n\nconst notAvailableError = new NotAvailableError('Biometry is not available');\n\nfunction eventToState(event: EventPayload<'biometry_info_received'>): BiometryState {\n  let available = false;\n  let tokenSaved = false;\n  let deviceId = '';\n  let accessRequested = false;\n  let type = '';\n  let accessGranted = false;\n  if (event.available) {\n    available = true;\n    tokenSaved = event.token_saved;\n    deviceId = event.device_id;\n    accessRequested = event.access_requested;\n    type = event.type;\n    accessGranted = event.access_granted;\n  }\n  return { available, tokenSaved, deviceId, type, accessGranted, accessRequested };\n}\n\n/**\n * @since Mini Apps v7.2\n */\nexport class Biometry {\n  constructor({\n    version,\n    request,\n    postEvent,\n    storage,\n    onInfoReceived,\n    offInfoReceived,\n    isTma,\n    isPageReload,\n  }: BiometryOptions) {\n    const listener: EventListener<'biometry_info_received'> = event => {\n      stateful.setState(eventToState(event));\n    };\n\n    const stateful = new Stateful<BiometryState>({\n      initialState: {\n        available: false,\n        type: 'unknown',\n        accessGranted: false,\n        accessRequested: false,\n        deviceId: '',\n        tokenSaved: false,\n      },\n      onChange: storage.set,\n    });\n    const mountable = new AsyncMountable({\n      initialState(options) {\n        return pipe(\n          request('web_app_biometry_get_info', 'biometry_info_received', options),\n          TE.map(eventToState),\n        );\n      },\n      isPageReload,\n      onMounted(state) {\n        stateful.setState(state);\n        onInfoReceived(listener);\n      },\n      onUnmounted() {\n        offInfoReceived(listener);\n      },\n      restoreState: storage.get,\n    });\n\n    const wrapOptions = { version, requires: 'web_app_biometry_request_auth', isTma } as const;\n    const wrapSupportedEither = createWithChecksFp({\n      ...wrapOptions,\n      returns: 'either',\n    });\n    const wrapSupportedTask = createWithChecksFp({\n      ...wrapOptions,\n      returns: 'task',\n    });\n    const wrapMountedTask = createWithChecksFp({\n      ...wrapOptions,\n      isMounted: mountable.isMounted,\n      returns: 'task',\n    });\n\n    this.isAvailable = stateful.getter('available');\n    this.isMounted = mountable.isMounted;\n    this.isSupported = createIsSupportedSignal('web_app_biometry_request_auth', version);\n    this.state = stateful.state;\n    this.unmount = mountable.unmount;\n    this.mountFp = wrapSupportedTask(mountable.mount);\n\n    this.authenticateFp = wrapMountedTask(options => {\n      return !this.isAvailable()\n        ? TE.left(notAvailableError)\n        : pipe(\n          request('web_app_biometry_request_auth', 'biometry_auth_requested', {\n            ...options,\n            params: { reason: ((options || {}).reason || '').trim() },\n          }),\n          TE.map(response => {\n            stateful.setState({ token: response.token });\n            return response;\n          }),\n        );\n    });\n\n    this.openSettingsFp = wrapSupportedEither(() => postEvent('web_app_biometry_open_settings'));\n\n    this.requestAccessFp = wrapMountedTask(options => {\n      return pipe(\n        request('web_app_biometry_request_access', 'biometry_info_received', {\n          ...options,\n          params: { reason: ((options || {}).reason || '').trim() },\n        }),\n        TE.chain(response => {\n          const state = eventToState(response);\n          if (!state.available) {\n            return TE.left(notAvailableError);\n          }\n          stateful.setState(state);\n          return TE.right(state.accessRequested);\n        }),\n      );\n    });\n\n    this.updateTokenFp = wrapMountedTask((options = {}) => {\n      return pipe(\n        request('web_app_biometry_update_token', 'biometry_token_updated', {\n          ...options,\n          params: { token: options.token || '', reason: options.reason?.trim() },\n        }),\n        TE.map(response => response.status),\n      );\n    });\n\n    this.authenticate = throwifyWithChecksFp(this.authenticateFp);\n    this.openSettings = throwifyWithChecksFp(this.openSettingsFp);\n    this.requestAccess = throwifyWithChecksFp(this.requestAccessFp);\n    this.updateToken = throwifyWithChecksFp(this.updateTokenFp);\n    this.mount = throwifyWithChecksFp(this.mountFp);\n  }\n\n  /**\n   * Signal indicating if biometry is available.\n   */\n  readonly isAvailable: Computed<boolean>;\n\n  /**\n   * Signal indicating if the component is supported.\n   */\n  readonly isSupported: Computed<boolean>;\n\n  /**\n   * Signal indicating if the component is mounted.\n   */\n  readonly isMounted: Computed<boolean>;\n\n  /**\n   * Complete component state.\n   */\n  readonly state: Computed<BiometryState>;\n\n  /**\n   * Attempts to authenticate a user using biometrics and fetch a previously stored secure token.\n   * @param options - method options.\n   * @since Mini Apps v7.2\n   * @returns Token from the local secure storage saved previously or undefined.\n   * @example\n   * const { status, token } = await biometry.authenticate({\n   *   reason: 'Authenticate to open wallet',\n   * });\n   */\n  readonly authenticateFp: WithChecksFp<(options?: BiometryAuthenticateOptions) => BiometryTask<{\n    /**\n     * Authentication status.\n     */\n    status: BiometryAuthRequestStatus;\n    /**\n     * Token from the local secure storage saved previously.\n     */\n    token?: string;\n  }>, true>;\n\n  /**\n   * @see authenticateFp\n   */\n  readonly authenticate: WithChecks<\n    (options?: BiometryAuthenticateOptions) => BetterPromise<AuthenticateResult>,\n    true\n  >;\n\n  /**\n   * Opens the biometric access settings for bots. Useful when you need to request biometrics\n   * access to users who haven't granted it yet.\n   *\n   * _Note that this method can be called only in response to user interaction with the Mini App\n   * interface (e.g. a click inside the Mini App or on the main button)_.\n   * @since Mini Apps v7.2\n   */\n  readonly openSettingsFp: WithChecksFp<() => E.Either<PostEventError, void>, true>;\n\n  /**\n   * @see openSettingsFp\n   */\n  readonly openSettings: WithChecks<() => void, true>;\n\n  /**\n   * Requests permission to use biometrics.\n   * @since Mini Apps v7.2\n   * @returns Promise with true, if access was granted.\n   * @example\n   * const accessGranted = await biometry.requestAccess({\n   *   reason: 'Authenticate to open wallet',\n   * });\n   */\n  readonly requestAccessFp: WithChecksFp<\n    (options?: BiometryRequestAccessOptions) => BiometryTask<boolean>,\n    true\n  >;\n\n  /**\n   * @see requestAccessFp\n   */\n  readonly requestAccess: WithChecks<\n    (options?: BiometryRequestAccessOptions) => BetterPromise<boolean>,\n    true\n  >;\n\n  /**\n   * Updates the biometric token in a secure storage on the device.\n   * @since Mini Apps v7.2\n   * @returns Promise with `true`, if token was updated.\n   * @example Setting a new token\n   * biometry.updateToken({\n   *   token: 'abcdef',\n   * })\n   * @example Deleting the token\n   * biometry.updateToken();\n   */\n  readonly updateTokenFp: WithChecksFp<\n    (options?: BiometryUpdateTokenOptions) => BiometryTask<BiometryTokenUpdateStatus>,\n    true\n  >;\n\n  /**\n   * @see updateTokenFp\n   */\n  readonly updateToken: WithChecks<\n    (options?: BiometryUpdateTokenOptions) => BetterPromise<BiometryTokenUpdateStatus>,\n    true\n  >;\n\n  /**\n   * Mounts the component restoring its state.\n   * @since Mini Apps v7.2\n   */\n  readonly mountFp: WithChecksFp<(options?: AsyncOptions) => BiometryTask<void>, true>;\n\n  /**\n   * @see mountFp\n   */\n  readonly mount: WithChecks<(options?: AsyncOptions) => BetterPromise<void>, true>;\n\n  /**\n   * Unmounts the component.\n   */\n  readonly unmount: () => void;\n}\n","import {\n  requestFp as _requestFp,\n  request2Fp as _request2Fp,\n  type RequestFpFn,\n  type RequestFn,\n  type Request2FpFn,\n  type Request2Fn,\n} from '@tma.js/bridge';\nimport { BetterPromise } from 'better-promises';\n\nimport { postEventFp } from '@/globals/postEvent.js';\n\n/**\n * @deprecated To be removed in the next major update. Use `request2fp` instead, it provides\n * a proper way of handling multiple events.\n */\nexport const requestFp: RequestFpFn = (method: any, events: any, options: any) => {\n  return _requestFp(method, events, {\n    postEvent: postEventFp,\n    ...options,\n  });\n};\n\nexport const request2Fp: Request2FpFn = (method: any, events: any, options: any) => {\n  return _request2Fp(method, events, {\n    postEvent: postEventFp,\n    ...options,\n  });\n};\n\n/**\n * @deprecated To be removed in the next major update. Use `request` instead, it provides\n * a proper way of handling multiple events.\n */\nexport const request: RequestFn = (...args: any[]) => {\n  return BetterPromise.fn(() => (requestFp as any)(...args)());\n};\n\nexport const request2: Request2Fn = (...args: any[]) => {\n  return BetterPromise.fn(() => (request2Fp as any)(...args)());\n};\n","import type { Request2FpFn } from '@tma.js/bridge';\n\nimport { createFnOption } from '@/fn-options/createFnOption.js';\nimport { request2Fp } from '@/globals/request.js';\n\nexport interface WithRequest {\n  /**\n   * A request function to use to call Mini Apps methods.\n   */\n  request: Request2FpFn;\n}\n\nexport const withRequest = createFnOption<WithRequest>({ request: request2Fp });\n","import { on, off } from '@tma.js/bridge';\nimport { pipe } from 'fp-ts/function';\n\nimport { Biometry } from '@/features/Biometry/Biometry.js';\nimport type { BiometryState } from '@/features/Biometry/types.js';\nimport { sharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport { withPostEvent } from '@/fn-options/withPostEvent.js';\nimport { withRequest } from '@/fn-options/withRequest.js';\nimport { withStateRestore } from '@/fn-options/withStateRestore.js';\nimport { withVersion } from '@/fn-options/withVersion.js';\n\nexport const biometry = new Biometry({\n  ...pipe(\n    sharedFeatureOptions(),\n    withPostEvent,\n    withVersion,\n    withRequest,\n    withStateRestore<BiometryState>('biometry'),\n  ),\n  offInfoReceived(listener) {\n    off('biometry_info_received', listener);\n  },\n  onInfoReceived(listener) {\n    return on('biometry_info_received', listener);\n  },\n});\n","import type { PostEventError } from '@tma.js/bridge';\nimport type { Computed } from '@tma.js/signals';\nimport * as E from 'fp-ts/Either';\nimport { pipe } from 'fp-ts/function';\n\nimport { Mountable } from '@/composables/Mountable.js';\nimport { Stateful } from '@/composables/Stateful.js';\nimport type { SharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport type { WithPostEvent } from '@/fn-options/withPostEvent.js';\nimport type { WithStateRestore } from '@/fn-options/withStateRestore.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport {\n  createWithChecksFp,\n  type WithChecks,\n  type WithChecksFp,\n} from '@/with-checks/withChecksFp.js';\n\nexport interface ClosingBehaviorState {\n  isConfirmationEnabled: boolean;\n}\n\nexport interface ClosingBehaviorOptions\n  extends WithStateRestore<ClosingBehaviorState>,\n  WithPostEvent,\n  SharedFeatureOptions {\n}\n\nexport class ClosingBehavior {\n  constructor({ postEvent, storage, isTma, isPageReload }: ClosingBehaviorOptions) {\n    const stateful = new Stateful({\n      initialState: { isConfirmationEnabled: false },\n      onChange(state) {\n        storage.set(state);\n      },\n    });\n    const mountable = new Mountable({\n      onMounted: stateful.setState,\n      restoreState: storage.get,\n      initialState: { isConfirmationEnabled: false },\n      isPageReload,\n    });\n\n    const wrapOptions = { requires: 'web_app_setup_closing_behavior', isTma } as const;\n    const wrapSupportedPlain = createWithChecksFp({\n      ...wrapOptions,\n      returns: 'plain',\n    });\n    const wrapMountedEither = createWithChecksFp({\n      ...wrapOptions,\n      returns: 'either',\n      isMounted: mountable.isMounted,\n    });\n\n    const setClosingConfirmation = (isConfirmationEnabled: boolean) => {\n      if (isConfirmationEnabled === this.isConfirmationEnabled()) {\n        return E.right(undefined);\n      }\n      stateful.setState({ isConfirmationEnabled });\n      return postEvent('web_app_setup_closing_behavior', {\n        need_confirmation: isConfirmationEnabled,\n      });\n    };\n\n    this.isConfirmationEnabled = stateful.getter('isConfirmationEnabled');\n    this.isMounted = mountable.isMounted;\n\n    this.disableConfirmationFp = wrapMountedEither(() => {\n      return setClosingConfirmation(false);\n    });\n    this.enableConfirmationFp = wrapMountedEither(() => {\n      return setClosingConfirmation(true);\n    });\n    this.mountFp = wrapSupportedPlain(() => {\n      const nothing = () => undefined;\n      return pipe(mountable.mount(), E.match(nothing, nothing));\n    });\n    this.unmount = mountable.unmount;\n\n    this.disableConfirmation = throwifyWithChecksFp(this.disableConfirmationFp);\n    this.enableConfirmation = throwifyWithChecksFp(this.enableConfirmationFp);\n    this.mount = throwifyWithChecksFp(this.mountFp);\n  }\n\n  /**\n   * Signal indicating if closing confirmation dialog is currently enabled.\n   */\n  readonly isConfirmationEnabled: Computed<boolean>;\n\n  /**\n   * Signal indicating if the component is currently mounted.\n   */\n  readonly isMounted: Computed<boolean>;\n\n  /**\n   * Mounts the component restoring its state.\n   */\n  readonly mountFp: WithChecksFp<() => void, false>;\n\n  /**\n   * @see mountFp\n   */\n  readonly mount: WithChecks<() => void, false>;\n\n  /**\n   * Unmounts the component.\n   */\n  readonly unmount: () => void;\n\n  /**\n   * Disables the closing confirmation dialog.\n   */\n  readonly disableConfirmationFp: WithChecksFp<() => E.Either<PostEventError, void>, false>;\n\n  /**\n   * @see disableConfirmationFp\n   */\n  readonly disableConfirmation: WithChecks<() => void, false>;\n\n  /**\n   * Enables the closing confirmation dialog.\n   */\n  readonly enableConfirmationFp: WithChecksFp<() => E.Either<PostEventError, void>, false>;\n\n  /**\n   * @see enableConfirmationFp\n   */\n  readonly enableConfirmation: WithChecks<() => void, false>;\n}\n","import { pipe } from 'fp-ts/function';\n\nimport {\n  ClosingBehavior,\n  type ClosingBehaviorState,\n} from '@/features/ClosingBehavior/ClosingBehavior.js';\nimport { sharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport { withPostEvent } from '@/fn-options/withPostEvent.js';\nimport { withStateRestore } from '@/fn-options/withStateRestore.js';\n\nexport const closingBehavior = new ClosingBehavior(pipe(\n  sharedFeatureOptions(),\n  withStateRestore<ClosingBehaviorState>('closingBehavior'),\n  withPostEvent,\n));\n","import type { InvokeCustomMethodFpOptions, RequestError } from '@tma.js/bridge';\nimport type { Computed } from '@tma.js/signals';\nimport { BetterPromise } from 'better-promises';\nimport * as TE from 'fp-ts/TaskEither';\nimport { pipe } from 'fp-ts/function';\nimport { array, parse, record, string } from 'valibot';\n\nimport type { SharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport type { WithInvokeCustomMethod } from '@/fn-options/withInvokeCustomMethod.js';\nimport type { WithVersion } from '@/fn-options/withVersion.js';\nimport { createIsSupportedSignal } from '@/helpers/createIsSupportedSignal.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport { createWithChecksFp, type WithChecks, type WithChecksFp } from '@/with-checks/withChecksFp.js';\n\ntype CloudStorageTask<T> = TE.TaskEither<RequestError, T>;\n\nexport interface CloudStorageOptions extends WithVersion,\n  WithInvokeCustomMethod,\n  SharedFeatureOptions {\n}\n\n/**\n * @since Mini Apps v6.9\n */\nexport class CloudStorage {\n  constructor({ version, isTma, invokeCustomMethod }: CloudStorageOptions) {\n    const wrapSupportedTask = createWithChecksFp({\n      version,\n      requires: 'web_app_invoke_custom_method',\n      isTma,\n      returns: 'task',\n    });\n\n    this.isSupported = createIsSupportedSignal('web_app_invoke_custom_method', version);\n    this.deleteItemFp = wrapSupportedTask((keyOrKeys, options) => {\n      const keys = Array.isArray(keyOrKeys) ? keyOrKeys : [keyOrKeys];\n      return pipe(\n        keys.length\n          ? invokeCustomMethod('deleteStorageValues', { keys }, options)\n          : TE.right(undefined),\n        TE.map(() => undefined),\n      );\n    });\n    this.getItemFp = wrapSupportedTask((key, options) => {\n      return pipe(\n        this.getItemsFp([key], options),\n        TE.map(values => values[key] || ''),\n      );\n    });\n    this.getItemsFp = wrapSupportedTask((keys, options) => {\n      return pipe(\n        keys.length ? invokeCustomMethod('getStorageValues', { keys }, options) : TE.right({}),\n        TE.map(data => {\n          return {\n            // Fulfill the response with probably missing keys.\n            ...keys.reduce<Record<string, string>>((acc, key) => {\n              acc[key] = '';\n              return acc;\n            }, {}),\n            ...parse(record(string(), string()), data),\n          };\n        }),\n      );\n    });\n    this.getKeysFp = wrapSupportedTask(options => {\n      return pipe(\n        invokeCustomMethod('getStorageKeys', {}, options),\n        TE.map(data => parse(array(string()), data)),\n      );\n    });\n    this.setItemFp = wrapSupportedTask((key, value, options) => {\n      return pipe(\n        invokeCustomMethod('saveStorageValue', { key, value }, options),\n        TE.map(() => undefined),\n      );\n    });\n    this.clearFp = wrapSupportedTask(options => {\n      return pipe(this.getKeysFp(options), TE.chain(this.deleteItemFp));\n    });\n\n    this.deleteItem = throwifyWithChecksFp(this.deleteItemFp);\n    this.getItem = throwifyWithChecksFp(this.getItemFp);\n    this.getItems = throwifyWithChecksFp(this.getItemsFp);\n    this.getKeys = throwifyWithChecksFp(this.getKeysFp);\n    this.setItem = throwifyWithChecksFp(this.setItemFp);\n    this.clear = throwifyWithChecksFp(this.clearFp);\n  }\n\n  /**\n   * Signal indicating if the component is supported.\n   */\n  readonly isSupported: Computed<boolean>;\n\n  /**\n   * Deletes specified key or keys from the cloud storage.\n   * @param keyOrKeys - key or keys to delete.\n   * @param options - request execution options.\n   * @since Mini Apps v6.9\n   */\n  readonly deleteItemFp: WithChecksFp<\n    (keyOrKeys: string | string[], options?: InvokeCustomMethodFpOptions) => CloudStorageTask<void>,\n    true\n  >;\n\n  readonly deleteItem: WithChecks<\n    (keyOrKeys: string | string[], options?: InvokeCustomMethodFpOptions) => BetterPromise<void>,\n    true\n  >;\n\n  /**\n   * Gets a single key value from the cloud storage.\n   * @param key - a key to get.\n   * @param options - request execution options.\n   * @returns A key value as a string.\n   * @since Mini Apps v6.9\n   */\n  readonly getItemFp: WithChecksFp<\n    (key: string, options?: InvokeCustomMethodFpOptions) => CloudStorageTask<string>,\n    true\n  >;\n\n  /**\n   * @see getItemFp\n   */\n  readonly getItem: WithChecks<{\n    <K extends string>(\n      keys: K[],\n      options?: InvokeCustomMethodFpOptions,\n    ): BetterPromise<Record<K, string>>;\n    (key: string, options?: InvokeCustomMethodFpOptions): BetterPromise<string>;\n  }, true>;\n\n  /**\n   * Gets multiple keys' values from the cloud storage.\n   * @param keys - keys list.\n   * @param options - request execution options.\n   * @returns A map, where a key is one of the specified in the `keys` argument,\n   * and a value is a corresponding storage value if an array of keys was passed.\n   * @since Mini Apps v6.9\n   */\n  readonly getItemsFp: WithChecksFp<\n    <K extends string>(\n      keys: K[],\n      options?: InvokeCustomMethodFpOptions,\n    ) => CloudStorageTask<Record<K, string>>,\n    true\n  >;\n\n  /**\n   * @see getItemsFp\n   */\n  readonly getItems: WithChecks<\n    <K extends string>(\n      keys: K[],\n      options?: InvokeCustomMethodFpOptions,\n    ) => BetterPromise<Record<K, string>>,\n    true\n  >;\n\n  /**\n   * Returns a list of all keys presented in the cloud storage.\n   * @param options - request execution options.\n   * @since Mini Apps v6.9\n   */\n  readonly getKeysFp: WithChecksFp<\n    (options?: InvokeCustomMethodFpOptions) => CloudStorageTask<string[]>,\n    true\n  >;\n\n  /**\n   * @see getKeysFp\n   */\n  readonly getKeys: WithChecks<\n    (options?: InvokeCustomMethodFpOptions) => BetterPromise<string[]>,\n    true\n  >;\n\n  /**\n   * Saves the specified value by a key.\n   * @param key - storage key.\n   * @param value - storage value.\n   * @param options - request execution options.\n   * @since Mini Apps v6.9\n   */\n  readonly setItemFp: WithChecksFp<\n    (key: string, value: string, options?: InvokeCustomMethodFpOptions) => CloudStorageTask<void>,\n    true\n  >;\n\n  /**\n   * @see setItemFp\n   */\n  readonly setItem: WithChecks<\n    (key: string, value: string, options?: InvokeCustomMethodFpOptions) => BetterPromise<void>,\n    true\n  >;\n\n  /**\n   * Clears the cloud storage.\n   * @param options - additional options.\n   * @since Mini Apps v6.9\n   */\n  readonly clearFp: WithChecksFp<\n    (options?: InvokeCustomMethodFpOptions) => CloudStorageTask<void>,\n    true\n  >;\n\n  /**\n   * @see clearFp\n   */\n  readonly clear: WithChecks<(options?: InvokeCustomMethodFpOptions) => BetterPromise<void>, true>;\n}\n","import { createSignal } from '@/globals/signals-registry.js';\n\nconst lastRequestId = createSignal(0);\n\n/**\n * @returns A new request identifier.\n */\nexport function createRequestId(): string {\n  lastRequestId.set(lastRequestId() + 1);\n  return lastRequestId().toString();\n}\n","import {\n  type RequestError,\n  type CustomMethodName,\n  type CustomMethodParams,\n  type InvokeCustomMethodOptions,\n  invokeCustomMethodFp,\n} from '@tma.js/bridge';\nimport * as TE from 'fp-ts/TaskEither';\n\nimport { createRequestId } from '@/globals/createRequestId.js';\nimport { postEventFp } from '@/globals/postEvent.js';\n\n/**\n * Invokes known custom method. Returns method execution result.\n * @param method - method name.\n * @param params - method parameters.\n * @param options - additional options.\n */\nexport function invokeCustomMethod<M extends CustomMethodName>(\n  method: M,\n  params: CustomMethodParams<M>,\n  options?: InvokeCustomMethodOptions,\n): TE.TaskEither<RequestError, unknown>;\n\n/**\n * Invokes unknown custom method. Returns method execution result.\n * @param method - method name.\n * @param params - method parameters.\n * @param options - additional options.\n */\nexport function invokeCustomMethod(\n  method: string,\n  params: object,\n  options?: InvokeCustomMethodOptions,\n): TE.TaskEither<RequestError, unknown>;\n\nexport function invokeCustomMethod(\n  method: string,\n  params: object,\n  options?: InvokeCustomMethodOptions,\n): TE.TaskEither<RequestError, unknown> {\n  return invokeCustomMethodFp(method, params, createRequestId(), {\n    ...options || {},\n    postEvent: postEventFp,\n  });\n}\n","import type {\n  CustomMethodParams,\n  CustomMethodName,\n  InvokeCustomMethodError,\n  InvokeCustomMethodFpOptions,\n  RequestError,\n} from '@tma.js/bridge';\nimport type * as TE from 'fp-ts/TaskEither';\n\nimport { createFnOption } from '@/fn-options/createFnOption.js';\nimport { invokeCustomMethod } from '@/globals/invokeCustomMethod.js';\n\nexport type { InvokeCustomMethodError };\n\nexport interface InvokeCustomMethodNoRequestIdFn {\n  <M extends CustomMethodName>(\n    this: void,\n    method: M,\n    params: CustomMethodParams<M>,\n    options?: InvokeCustomMethodFpOptions,\n  ): TE.TaskEither<InvokeCustomMethodError, unknown>;\n\n  (\n    this: void,\n    method: string,\n    params: object,\n    options?: InvokeCustomMethodFpOptions,\n  ): TE.TaskEither<RequestError, unknown>;\n}\n\nexport interface WithInvokeCustomMethod {\n  invokeCustomMethod: InvokeCustomMethodNoRequestIdFn;\n}\n\nexport const withInvokeCustomMethod = createFnOption<WithInvokeCustomMethod>({\n  invokeCustomMethod,\n});\n","import { pipe } from 'fp-ts/function';\n\nimport { CloudStorage } from '@/features/CloudStorage/CloudStorage.js';\nimport { sharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport { withInvokeCustomMethod } from '@/fn-options/withInvokeCustomMethod.js';\nimport { withVersion } from '@/fn-options/withVersion.js';\n\nexport const cloudStorage = new CloudStorage(pipe(\n  sharedFeatureOptions(),\n  withVersion,\n  withInvokeCustomMethod,\n));\n","import { EventPayload, type MethodParams, type Request2CaptureFn, RequestError } from '@tma.js/bridge';\nimport * as TE from 'fp-ts/TaskEither';\nimport { pipe } from 'fp-ts/function';\n\nimport { DeviceStorageMethodError } from '@/errors.js';\nimport type { SharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport type { WithCreateRequestId } from '@/fn-options/withCreateRequestId.js';\nimport type { WithRequest } from '@/fn-options/withRequest.js';\nimport type { WithVersion } from '@/fn-options/withVersion.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport {\n  createWithChecksFp,\n  type WithChecks,\n  type WithChecksFp,\n} from '@/with-checks/withChecksFp.js';\n\nexport type DeviceStorageError = RequestError | DeviceStorageMethodError;\n\nexport interface DeviceStorageOptions extends SharedFeatureOptions,\n  WithVersion,\n  WithRequest,\n  WithCreateRequestId {\n}\n\n/**\n * @since Mini Apps v9.0\n */\nexport class DeviceStorage {\n  constructor({ isTma, request, version, createRequestId }: DeviceStorageOptions) {\n    const wrapSupportedTask = createWithChecksFp({\n      version,\n      requires: 'web_app_device_storage_get_key',\n      isTma,\n      returns: 'task',\n    });\n\n    const invokeMethod = <\n      M extends (\n        | 'web_app_device_storage_save_key'\n        | 'web_app_device_storage_get_key'\n        | 'web_app_device_storage_save_key'\n        | 'web_app_device_storage_clear'\n      ),\n      E extends (\n        | 'device_storage_key_saved'\n        | 'device_storage_key_received'\n        | 'device_storage_cleared'\n      ),\n    >(\n      method: M,\n      event: E,\n      params: Omit<MethodParams<M>, 'req_id'>,\n    ): TE.TaskEither<DeviceStorageError, EventPayload<E>> => {\n      const requestId = createRequestId();\n      return pipe(\n        request<M, ('device_storage_failed' | E)[]>(method, ['device_storage_failed', event], {\n          params: { ...params, req_id: requestId },\n          capture: (event => {\n            return 'payload' in event ? event.payload.req_id === requestId : true;\n          }) as Request2CaptureFn<('device_storage_failed' | E)[]>,\n        }),\n        TE.chain(response => (\n          response.event === 'device_storage_failed'\n            ? TE.left(new DeviceStorageMethodError(response.payload.error || 'UNKNOWN_ERROR'))\n            : TE.right(response.payload as EventPayload<E>)\n        )),\n      );\n    };\n\n    this.getItemFp = wrapSupportedTask(key => {\n      return pipe(\n        invokeMethod('web_app_device_storage_get_key', 'device_storage_key_received', { key }),\n        TE.map(payload => payload.value),\n      );\n    });\n    this.setItemFp = wrapSupportedTask((key, value) => {\n      return pipe(\n        invokeMethod('web_app_device_storage_save_key', 'device_storage_key_saved', { key, value }),\n        TE.map(() => undefined),\n      );\n    });\n    this.deleteItemFp = wrapSupportedTask(key => {\n      return this.setItemFp(key, null);\n    });\n    this.clearFp = wrapSupportedTask(() => {\n      return pipe(\n        invokeMethod('web_app_device_storage_clear', 'device_storage_cleared', {}),\n        TE.map(() => undefined),\n      );\n    });\n\n    this.getItem = throwifyWithChecksFp(this.getItemFp);\n    this.setItem = throwifyWithChecksFp(this.setItemFp);\n    this.deleteItem = throwifyWithChecksFp(this.deleteItemFp);\n    this.clear = throwifyWithChecksFp(this.clearFp);\n  }\n\n  /**\n    * Retrieves an item using its key.\n    * @since Mini Apps v9.0\n    */\n  readonly getItemFp: WithChecksFp<\n    (key: string) => TE.TaskEither<DeviceStorageError, string | null>,\n    true\n  >;\n\n  /**\n   * @see getItemFp\n   */\n  readonly getItem: WithChecks<(key: string) => Promise<string | null>, true>;\n\n  /**\n    * Sets a new item in the storage.\n    * @since Mini Apps v9.0\n    */\n  readonly setItemFp: WithChecksFp<\n    (key: string, value: string | null) => TE.TaskEither<DeviceStorageError, void>,\n    true\n  >;\n\n  /**\n   * @see setItemFp\n   */\n  readonly setItem: WithChecks<(key: string, value: string | null) => Promise<void>, true>;\n\n  /**\n    * Removes a key from the storage.\n    * @since Mini Apps v9.0\n    */\n  readonly deleteItemFp: WithChecksFp<\n    (key: string) => TE.TaskEither<DeviceStorageError, void>,\n    true\n  >;\n\n  /**\n   * @see deleteItemFp\n   */\n  readonly deleteItem: WithChecks<(key: string) => Promise<void>, true>;\n\n  /**\n    * Removes all keys from the storage.\n    * @since Mini Apps v9.0\n    */\n  readonly clearFp: WithChecksFp<() => TE.TaskEither<DeviceStorageError, void>, true>;\n\n  /**\n   * @see clearFp\n   */\n  readonly clear: WithChecks<() => Promise<void>, true>;\n}\n","import { createFnOption } from '@/fn-options/createFnOption.js';\nimport { createRequestId } from '@/globals/createRequestId.js';\n\nexport interface WithCreateRequestId {\n  /**\n   * A function generating a request identifier.\n   */\n  createRequestId: () => string;\n}\n\nexport const withCreateRequestId = createFnOption<WithCreateRequestId>({ createRequestId });\n","import { pipe } from 'fp-ts/function';\n\nimport { sharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport { withCreateRequestId } from '@/fn-options/withCreateRequestId.js';\nimport { withRequest } from '@/fn-options/withRequest.js';\nimport { withVersion } from '@/fn-options/withVersion.js';\n\nimport { DeviceStorage } from './DeviceStorage.js';\n\nexport const deviceStorage = new DeviceStorage(pipe(\n  sharedFeatureOptions(),\n  withVersion,\n  withRequest,\n  withCreateRequestId,\n));\n","import type { EmojiStatusAccessRequestedStatus, RequestError } from '@tma.js/bridge';\nimport * as TE from 'fp-ts/TaskEither';\nimport { pipe } from 'fp-ts/function';\n\nimport {\n  sharedFeatureOptions,\n  type SharedFeatureOptions,\n} from '@/fn-options/sharedFeatureOptions.js';\nimport { withRequest, type WithRequest } from '@/fn-options/withRequest.js';\nimport { withVersion, type WithVersion } from '@/fn-options/withVersion.js';\nimport type { AsyncOptions } from '@/types.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport { withChecksFp } from '@/with-checks/withChecksFp.js';\n\ninterface CreateOptions extends SharedFeatureOptions, WithVersion, WithRequest {\n}\n\nfunction create({ request, ...rest }: CreateOptions) {\n  return withChecksFp((\n    options: AsyncOptions,\n  ): TE.TaskEither<RequestError, EmojiStatusAccessRequestedStatus> => {\n    return pipe(\n      request('web_app_request_emoji_status_access', 'emoji_status_access_requested', options),\n      TE.map(response => response.status),\n    );\n  }, { ...rest, requires: 'web_app_request_emoji_status_access', returns: 'task' });\n}\n\n/**\n * Shows a native popup requesting permission for the bot to manage user's emoji status.\n * @param options - additional options.\n * @returns Emoji status access status.\n * @since Mini Apps v8.0\n * @example\n * const status = await requestEmojiStatusAccess();\n */\nexport const requestEmojiStatusAccessFp = create(pipe(\n  sharedFeatureOptions(),\n  withVersion,\n  withRequest,\n));\n\n/**\n * @see requestEmojiStatusAccessFp\n */\nexport const requestEmojiStatusAccess = throwifyWithChecksFp(requestEmojiStatusAccessFp);\n","import { RequestError } from '@tma.js/bridge';\nimport * as TE from 'fp-ts/TaskEither';\nimport { pipe } from 'fp-ts/function';\n\nimport { SetEmojiStatusError } from '@/errors.js';\nimport {\n  type SharedFeatureOptions,\n  sharedFeatureOptions,\n} from '@/fn-options/sharedFeatureOptions.js';\nimport { withRequest, type WithRequest } from '@/fn-options/withRequest.js';\nimport { withVersion, type WithVersion } from '@/fn-options/withVersion.js';\nimport type { AsyncOptions } from '@/types.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport { withChecksFp } from '@/with-checks/withChecksFp.js';\n\nexport interface SetEmojiStatusOptions extends AsyncOptions {\n  duration?: number;\n}\n\ninterface CreateOptions extends SharedFeatureOptions, WithRequest, WithVersion {\n}\n\nfunction create({ request, ...rest }: CreateOptions) {\n  return withChecksFp((\n    customEmojiId: string,\n    options?: SetEmojiStatusOptions,\n  ): TE.TaskEither<RequestError | SetEmojiStatusError, void> => {\n    return pipe(\n      request('web_app_set_emoji_status', ['emoji_status_set', 'emoji_status_failed'], {\n        params: {\n          custom_emoji_id: customEmojiId,\n          duration: (options || {}).duration,\n        },\n        ...options,\n      }),\n      TE.chainW(response => (\n        response.event === 'emoji_status_failed'\n          ? TE.left(new SetEmojiStatusError(response.payload.error))\n          : TE.right(undefined)\n      )),\n    );\n  }, {\n    ...rest,\n    requires: 'web_app_set_emoji_status',\n    returns: 'task',\n  });\n}\n\n/**\n * Opens a dialog allowing the user to set the specified custom emoji as their status.\n * @returns Nothing if status set was successful.\n * @param options - additional options.\n * @since Mini Apps v8.0\n * @example\n * pipe(\n *   setEmojiStatusFp('5361800828313167608'),\n *   TE.match(error => {\n *     console.error('Error occurred', error);\n *   }, () => {\n *     console.log('Status set');\n *   }),\n * );\n * const statusSet = await setEmojiStatus('5361800828313167608');\n */\nexport const setEmojiStatusFp = create(pipe(\n  sharedFeatureOptions(),\n  withRequest,\n  withVersion,\n));\n\n/**\n * @see setEmojiStatusFp\n */\nexport const setEmojiStatus = throwifyWithChecksFp(setEmojiStatusFp);\n","import type {\n  ImpactHapticFeedbackStyle,\n  NotificationHapticFeedbackType,\n  PostEventError,\n} from '@tma.js/bridge';\nimport type { Computed } from '@tma.js/signals';\nimport * as E from 'fp-ts/Either';\n\nimport type { SharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport type { WithPostEvent } from '@/fn-options/withPostEvent.js';\nimport type { WithVersion } from '@/fn-options/withVersion.js';\nimport { createIsSupportedSignal } from '@/helpers/createIsSupportedSignal.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport { createWithChecksFp, type WithChecksFp, type WithChecks } from '@/with-checks/withChecksFp.js';\n\ntype HapticFeedbackEither = E.Either<PostEventError, void>;\n\nexport interface HapticFeedbackOptions extends WithVersion, WithPostEvent, SharedFeatureOptions {\n}\n\n/**\n * @since Mini Apps v6.1\n */\nexport class HapticFeedback {\n  constructor({ postEvent, isTma, version }: HapticFeedbackOptions) {\n    const HAPTIC_METHOD_NAME = 'web_app_trigger_haptic_feedback';\n    const wrapSupported = createWithChecksFp({\n      requires: HAPTIC_METHOD_NAME,\n      isTma,\n      version,\n      returns: 'plain',\n    });\n\n    this.isSupported = createIsSupportedSignal(HAPTIC_METHOD_NAME, version);\n    this.impactOccurredFp = wrapSupported(style => {\n      return postEvent(HAPTIC_METHOD_NAME, { type: 'impact', impact_style: style });\n    });\n    this.notificationOccurredFp = wrapSupported(type => {\n      return postEvent(HAPTIC_METHOD_NAME, { type: 'notification', notification_type: type });\n    });\n    this.selectionChangedFp = wrapSupported(() => {\n      return postEvent(HAPTIC_METHOD_NAME, { type: 'selection_change' });\n    });\n\n    this.impactOccurred = throwifyWithChecksFp(this.impactOccurredFp);\n    this.notificationOccurred = throwifyWithChecksFp(this.notificationOccurredFp);\n    this.selectionChanged = throwifyWithChecksFp(this.selectionChangedFp);\n  }\n\n  /**\n   * Signal indicating if the component is supported.\n   */\n  readonly isSupported: Computed<boolean>;\n\n  /**\n   * A method that tells if an impact occurred. The Telegram app may play the\n   * appropriate haptics based on style value passed.\n   * @param style - impact style.\n   * @since Mini Apps v6.1\n   */\n  impactOccurredFp: WithChecksFp<(style: ImpactHapticFeedbackStyle) => HapticFeedbackEither, true>;\n\n  /**\n   * @see impactOccurredFp\n   */\n  impactOccurred: WithChecks<(style: ImpactHapticFeedbackStyle) => void, true>;\n\n  /**\n   * A method tells that a task or action has succeeded, failed, or produced\n   * a warning. The Telegram app may play the appropriate haptics based on type\n   * value passed.\n   * @param type - notification type.\n   * @since Mini Apps v6.1\n   */\n  notificationOccurredFp: WithChecksFp<\n    (type: NotificationHapticFeedbackType) => HapticFeedbackEither,\n    true\n  >;\n\n  /**\n   * @see notificationOccurredFp\n   */\n  notificationOccurred: WithChecks<(type: NotificationHapticFeedbackType) => void, true>;\n\n  /**\n   * A method tells that the user has changed a selection. The Telegram app may\n   * play the appropriate haptics.\n   *\n   * Do not use this feedback when the user makes or confirms a selection; use\n   * it only when the selection changes.\n   * @since Mini Apps v6.1\n   */\n  selectionChangedFp: WithChecksFp<() => HapticFeedbackEither, true>;\n\n  /**\n   * @see selectionChangedFp\n   */\n  selectionChanged: WithChecks<() => void, true>;\n}\n","import { pipe } from 'fp-ts/function';\n\nimport { HapticFeedback } from '@/features/HapticFeedback/HapticFeedback.js';\nimport { sharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport { withPostEvent } from '@/fn-options/withPostEvent.js';\nimport { withVersion } from '@/fn-options/withVersion.js';\n\nexport const hapticFeedback = new HapticFeedback(pipe(\n  sharedFeatureOptions(),\n  withPostEvent,\n  withVersion,\n));\n","import type { PostEventError } from '@tma.js/bridge';\nimport type * as E from 'fp-ts/Either';\nimport { pipe } from 'fp-ts/function';\n\nimport {\n  sharedFeatureOptions,\n  type SharedFeatureOptions,\n} from '@/fn-options/sharedFeatureOptions.js';\nimport { withPostEvent, type WithPostEvent } from '@/fn-options/withPostEvent.js';\nimport { withVersion, type WithVersion } from '@/fn-options/withVersion.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport { withChecksFp } from '@/with-checks/withChecksFp.js';\n\ninterface CreateOptions extends SharedFeatureOptions, WithPostEvent, WithVersion {\n}\n\nfunction create({ postEvent, ...rest }: CreateOptions) {\n  return withChecksFp((): E.Either<PostEventError, void> => {\n    return postEvent('web_app_add_to_home_screen');\n  }, { ...rest, requires: 'web_app_add_to_home_screen', returns: 'either' });\n}\n\n/**\n * Prompts the user to add the Mini App to the home screen.\n * @since Mini Apps v8.0\n */\nexport const addToHomeScreenFp = create(pipe(\n  sharedFeatureOptions(),\n  withVersion,\n  withPostEvent,\n));\n\n/**\n * @see addToHomeScreenFp\n */\nexport const addToHomeScreen = throwifyWithChecksFp(addToHomeScreenFp);\n","import type { HomeScreenStatus, RequestError } from '@tma.js/bridge';\nimport * as TE from 'fp-ts/TaskEither';\nimport { pipe } from 'fp-ts/function';\n\nimport {\n  sharedFeatureOptions,\n  type SharedFeatureOptions,\n} from '@/fn-options/sharedFeatureOptions.js';\nimport { withRequest, type WithRequest } from '@/fn-options/withRequest.js';\nimport { withVersion, type WithVersion } from '@/fn-options/withVersion.js';\nimport type { AsyncOptions } from '@/types.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport { withChecksFp } from '@/with-checks/withChecksFp.js';\n\ninterface CreateOptions extends SharedFeatureOptions, WithRequest, WithVersion {\n}\n\nfunction create({ request, ...rest }: CreateOptions) {\n  return withChecksFp((options?: AsyncOptions): TE.TaskEither<RequestError, HomeScreenStatus> => {\n    return pipe(\n      request('web_app_check_home_screen', 'home_screen_checked', options),\n      TE.map(response => response.status || 'unknown'),\n    );\n  }, { ...rest, requires: 'web_app_check_home_screen', returns: 'task' });\n}\n\n/**\n * Sends a request to the native Telegram application to check if the current mini\n * application is added to the device's home screen.\n * @param options - additional options.\n * @since Mini Apps v8.0\n */\nexport const checkHomeScreenStatusFp = create(pipe(\n  sharedFeatureOptions(),\n  withVersion,\n  withRequest,\n));\n\n/**\n * @see checkHomeScreenStatusFp\n */\nexport const checkHomeScreenStatus = throwifyWithChecksFp(checkHomeScreenStatusFp);\n","import { computed, type Computed, signal } from '@tma.js/signals';\nimport { throwifyFpFn } from '@tma.js/toolkit';\nimport type { InitData as InitDataType } from '@tma.js/types';\nimport * as E from 'fp-ts/Either';\nimport * as O from 'fp-ts/Option';\nimport { pipe } from 'fp-ts/function';\n\nexport interface InitDataOptions<Err> {\n  /**\n   * Retrieves init data from the current environment.\n   */\n  retrieveInitData: () => E.Either<Err, O.Option<{\n    raw: string;\n    obj: InitDataType;\n  }>>;\n}\n\nexport class InitData<Err extends Error> {\n  constructor({ retrieveInitData }: InitDataOptions<Err>) {\n    this.restoreFp = () => {\n      return pipe(\n        retrieveInitData(),\n        E.map(O.match(() => undefined, ({ raw, obj }) => {\n          this._state.set(obj);\n          this._raw.set(raw);\n        })),\n      );\n    };\n    this.restore = throwifyFpFn(this.restoreFp);\n  }\n\n  private fromState<K extends keyof InitDataType>(key: K): Computed<InitDataType[K] | undefined> {\n    return computed(() => {\n      const s = this._state();\n      return s ? s[key] : undefined;\n    });\n  }\n\n  private readonly _state = signal<InitDataType>();\n\n  private readonly _raw = signal<string>();\n\n  /**\n   * Complete component state.\n   */\n  readonly state = computed(this._state);\n\n  /**\n   * @see InitDataType.auth_date\n   */\n  readonly authDate = this.fromState('auth_date');\n\n  /**\n   * @see InitDataType.can_send_after\n   */\n  readonly canSendAfter = this.fromState('can_send_after');\n\n  /**\n   * Date after which it is allowed to call\n   * the [answerWebAppQuery](https://core.telegram.org/bots/api#answerwebappquery) method.\n   */\n  readonly canSendAfterDate = computed(() => {\n    const authDateValue = this.authDate();\n    const canSendAfterValue = this.canSendAfter();\n\n    return canSendAfterValue && authDateValue\n      ? new Date(authDateValue.getTime() + (canSendAfterValue * 1000))\n      : undefined;\n  });\n\n  /**\n   * @see InitDataType.chat\n   */\n  readonly chat = this.fromState('chat');\n\n  /**\n   * @see InitDataType.chat_type\n   */\n  readonly chatType = this.fromState('chat_type');\n\n  /**\n   * @see InitDataType.chat_instance\n   */\n  readonly chatInstance = this.fromState('chat_instance');\n\n  /**\n   * @see InitDataType.hash\n   */\n  readonly hash = this.fromState('hash');\n\n  /**\n   * @see InitDataType.query_id\n   */\n  readonly queryId = this.fromState('query_id');\n\n  /**\n   * Raw representation of init data.\n   */\n  readonly raw = computed(this._raw);\n\n  /**\n   * @see InitDataType.receiver\n   */\n  readonly receiver = this.fromState('receiver');\n\n  /**\n   * @see InitDataType.signature\n   */\n  readonly signature = this.fromState('signature');\n\n  /**\n   * @see InitDataType.start_param\n   */\n  readonly startParam = this.fromState('start_param');\n\n  /**\n   * @see InitDataType.user\n   */\n  readonly user = this.fromState('user');\n\n  /**\n   * Restores the component state.\n   */\n  readonly restoreFp: () => E.Either<Err, void>;\n\n  /**\n   * @see restoreFp\n   */\n  readonly restore: () => void;\n}\n","import { retrieveRawInitDataFp, retrieveLaunchParamsFp } from '@tma.js/bridge';\nimport * as E from 'fp-ts/Either';\nimport * as O from 'fp-ts/Option';\nimport { pipe } from 'fp-ts/function';\n\nimport { InitData } from '@/features/InitData/InitData.js';\n\nexport const initData = new InitData({\n  retrieveInitData() {\n    return pipe(\n      E.Do,\n      E.bindW('obj', () => pipe(\n        retrieveLaunchParamsFp(),\n        E.map(({ tgWebAppData }) => {\n          return tgWebAppData ? O.some(tgWebAppData) : O.none;\n        }),\n      )),\n      E.bindW('raw', retrieveRawInitDataFp),\n      E.map(({ obj, raw }) => {\n        return pipe(\n          O.Do,\n          O.bind('obj', () => obj),\n          O.bind('raw', () => raw),\n        );\n      }),\n    );\n  },\n});\n","import type { InvoiceStatus, RequestError } from '@tma.js/bridge';\nimport { computed, type Computed, signal } from '@tma.js/signals';\nimport { BetterPromise } from 'better-promises';\nimport * as TE from 'fp-ts/TaskEither';\nimport { pipe } from 'fp-ts/function';\n\nimport { ConcurrentCallError, InvalidArgumentsError } from '@/errors.js';\nimport type { SharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport type { WithRequest } from '@/fn-options/withRequest.js';\nimport type { WithVersion } from '@/fn-options/withVersion.js';\nimport { createIsSupportedSignal } from '@/helpers/createIsSupportedSignal.js';\nimport type { AsyncOptions } from '@/types.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport { createWithChecksFp, type WithChecks, type WithChecksFp } from '@/with-checks/withChecksFp.js';\n\ntype InvoiceTask<E, T> = TE.TaskEither<RequestError | ConcurrentCallError | E, T>;\n\nexport interface InvoiceOptions extends WithVersion, WithRequest, SharedFeatureOptions {\n}\n\n/**\n * @since Mini Apps v6.1\n */\nexport class Invoice {\n  constructor({ version, request, isTma }: InvoiceOptions) {\n    const wrapSupportedTask = createWithChecksFp({\n      version,\n      isTma,\n      requires: 'web_app_open_invoice',\n      returns: 'task',\n    });\n\n    const isOpened = signal(false);\n    const toggleClosed = () => {\n      isOpened.set(false);\n    };\n\n    this.isSupported = createIsSupportedSignal('web_app_open_invoice', version);\n    this.isOpened = computed(isOpened);\n    this.openSlugFp = wrapSupportedTask((slug, options) => {\n      return pipe(\n        this.isOpened()\n          ? TE.left(new ConcurrentCallError('Invoice is already opened'))\n          : TE.right(undefined as never),\n        TE.chain(() => {\n          isOpened.set(true);\n          return request('web_app_open_invoice', 'invoice_closed', {\n            ...options,\n            params: { slug },\n            capture: data => slug === data.slug,\n          });\n        }),\n        TE.mapBoth(err => {\n          toggleClosed();\n          return err;\n        }, data => {\n          toggleClosed();\n          return data.status;\n        }),\n      );\n    });\n    this.openUrlFp = wrapSupportedTask((url, options) => {\n      const { hostname, pathname } = new URL(url, window.location.href);\n      if (hostname !== 't.me') {\n        return TE.left(new InvalidArgumentsError(`Link has unexpected hostname: ${hostname}`));\n      }\n\n      // Valid examples:\n      // \"/invoice/my-slug\"\n      // \"/$my-slug\"\n      const match = pathname.match(/^\\/(\\$|invoice\\/)([A-Za-z0-9\\-_=]+)$/);\n      if (!match) {\n        return TE.left(new InvalidArgumentsError(\n          'Expected to receive a link with a pathname in format \"/invoice/{slug}\" or \"/${slug}\"',\n        ));\n      }\n      return this.openSlugFp(match[2], options);\n    });\n\n    this.openUrl = throwifyWithChecksFp(this.openUrlFp);\n    this.openSlug = throwifyWithChecksFp(this.openSlugFp);\n  }\n\n  /**\n   * Signal indicating if any invoice is currently opened.\n   */\n  readonly isOpened: Computed<boolean>;\n\n  /**\n   * Signal indicating if the component is supported.\n   */\n  readonly isSupported: Computed<boolean>;\n\n  /**\n   * Opens an invoice using its slug or URL.\n   * @param slug - invoice slug.\n   * @param options - additional options.\n   * @since Mini Apps v6.1\n   * @example\n   * const status = await invoice.openSlug('kJNFS331');\n   */\n  readonly openSlugFp: WithChecksFp<\n    (slug: string, options?: AsyncOptions) => InvoiceTask<never, InvoiceStatus>,\n    true\n  >;\n\n  /**\n   * @see openSlugFp\n   */\n  readonly openSlug: WithChecks<\n    (slug: string, options?: AsyncOptions) => BetterPromise<InvoiceStatus>,\n    true\n  >;\n\n  /**\n   * Opens an invoice using its URL.\n   * @param url - invoice URL.\n   * @param options - additional options.\n   * @since Mini Apps v6.1\n   * @example\n   * const status = await invoice.openUrl('https://t.me/$kJNFS331');\n   */\n  readonly openUrlFp: WithChecksFp<\n    (url: string, options?: AsyncOptions) => (\n      InvoiceTask<InvalidArgumentsError, InvoiceStatus>\n    ),\n    true\n  >;\n\n  /**\n   * @see openUrlFp\n   */\n  readonly openUrl: WithChecks<\n    (url: string, options?: AsyncOptions) => BetterPromise<InvoiceStatus>,\n    true\n  >;\n}\n","import { pipe } from 'fp-ts/function';\n\nimport { Invoice } from '@/features/Invoice/Invoice.js';\nimport { sharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport { withRequest } from '@/fn-options/withRequest.js';\nimport { withVersion } from '@/fn-options/withVersion.js';\n\nexport const invoice = new Invoice(pipe(sharedFeatureOptions(), withRequest, withVersion));\n","import type { OpenLinkBrowser, PostEventError } from '@tma.js/bridge';\nimport * as E from 'fp-ts/Either';\nimport { pipe } from 'fp-ts/function';\n\nimport { InvalidArgumentsError } from '@/errors.js';\nimport {\n  type SharedFeatureOptions,\n  sharedFeatureOptions,\n} from '@/fn-options/sharedFeatureOptions.js';\nimport { type WithPostEvent, withPostEvent } from '@/fn-options/withPostEvent.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport { withChecksFp } from '@/with-checks/withChecksFp.js';\n\ninterface CreateOptions extends SharedFeatureOptions, WithPostEvent {\n}\n\nexport interface OpenLinkOptions {\n  /**\n   * Attempts to use the instant view mode.\n   */\n  tryInstantView?: boolean;\n  /**\n   * A preferred browser to open the link in.\n   */\n  tryBrowser?: OpenLinkBrowser;\n}\n\nexport type OpenLinkError = PostEventError | InvalidArgumentsError;\n\nfunction create({ postEvent, ...rest }: CreateOptions) {\n  return withChecksFp((\n    url: string | URL,\n    options: OpenLinkOptions = {},\n  ): E.Either<OpenLinkError, void> => {\n    if (typeof url === 'string') {\n      try {\n        url = new URL(url);\n      } catch (e) {\n        return E.left(new InvalidArgumentsError(`\"${url.toString()}\" is invalid URL`, e));\n      }\n    }\n    return postEvent('web_app_open_link', {\n      url: url.toString(),\n      try_browser: options.tryBrowser,\n      try_instant_view: options.tryInstantView,\n    });\n  }, { ...rest, returns: 'either' });\n}\n\n/**\n * Opens a link.\n *\n * The Mini App will not be closed.\n *\n * Note that this method can be called only in response to the user\n * interaction with the Mini App interface (e.g. click inside the Mini App or on the main button).\n * @param url - URL to be opened.\n * @param options - additional options.\n * @example\n * openLink('https://google.com', {\n *   tryInstantView: true,\n *   tryBrowser: 'chrome',\n * });\n */\nexport const openLinkFp = create(pipe(\n  sharedFeatureOptions(),\n  withPostEvent,\n));\n\nexport const openLink = throwifyWithChecksFp(openLinkFp);\n","import { supports, type PostEventError } from '@tma.js/bridge';\nimport * as E from 'fp-ts/Either';\nimport { pipe } from 'fp-ts/function';\n\nimport { InvalidArgumentsError } from '@/errors.js';\nimport {\n  type SharedFeatureOptions,\n  sharedFeatureOptions,\n} from '@/fn-options/sharedFeatureOptions.js';\nimport { withPostEvent, type WithPostEvent } from '@/fn-options/withPostEvent.js';\nimport { withVersion, type WithVersion } from '@/fn-options/withVersion.js';\nimport { access } from '@/helpers/access.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport { withChecksFp } from '@/with-checks/withChecksFp.js';\n\ninterface CreateOptions extends SharedFeatureOptions, WithPostEvent, WithVersion {\n}\n\nexport type OpenTelegramLinkError = PostEventError | InvalidArgumentsError;\n\nfunction create({ postEvent, version, ...rest }: CreateOptions) {\n  return withChecksFp((\n    url: string | URL,\n  ): E.Either<OpenTelegramLinkError, void> => {\n    const urlString = url.toString();\n    if (!urlString.match(/^https:\\/\\/t.me\\/.+/)) {\n      return E.left(new InvalidArgumentsError(`\"${urlString}\" is invalid URL`));\n    }\n\n    if (supports('web_app_open_tg_link', access(version))) {\n      url = new URL(url);\n      return postEvent('web_app_open_tg_link', { path_full: url.pathname + url.search });\n    }\n\n    window.location.href = urlString;\n    return E.right(undefined);\n  }, { ...rest, returns: 'either' });\n}\n\n/**\n * Opens a Telegram link inside the Telegram app. The function expects passing a link in a full\n * format using the hostname \"t.me\".\n *\n * The Mini App will be closed.\n * @param url - URL to be opened.\n * @example\n * openTelegramLink('https://t.me/heyqbnk');\n */\nexport const openTelegramLinkFp = create(pipe(\n  sharedFeatureOptions(),\n  withPostEvent,\n  withVersion,\n));\n\n/**\n * @see openTelegramLinkFp\n */\nexport const openTelegramLink = throwifyWithChecksFp(openTelegramLinkFp);\n","import type { PostEventError } from '@tma.js/bridge';\nimport type * as E from 'fp-ts/Either';\n\nimport { openTelegramLinkFp } from '@/features/links/openTelegramLink.js';\nimport {\n  sharedFeatureOptions,\n  type SharedFeatureOptions,\n} from '@/fn-options/sharedFeatureOptions.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport { withChecksFp } from '@/with-checks/withChecksFp.js';\n\ninterface CreateOptions extends SharedFeatureOptions {\n  openTelegramLink: (url: string) => E.Either<PostEventError, void>;\n}\n\nexport type ShareURLError = PostEventError;\n\nfunction create({ openTelegramLink, ...rest }: CreateOptions) {\n  return withChecksFp((url: string, text?: string): E.Either<ShareURLError, void> => {\n    return openTelegramLink(\n      'https://t.me/share/url?' + new URLSearchParams({ url, text: text || '' })\n        .toString()\n        // By default, URL search params encode spaces with \"+\".\n        // We are replacing them with \"%20\", because plus symbols are working incorrectly\n        // in Telegram.\n        .replace(/\\+/g, '%20'),\n    );\n  }, { ...rest, returns: 'either' });\n}\n\n/**\n * Shares the specified URL with the passed to the chats, selected by user.\n * After being called, it closes the mini application.\n *\n * This method uses Telegram's Share Links.\n * @param url - URL to share.\n * @param text - text to append after the URL.\n * @see https://core.telegram.org/api/links#share-links\n * @see https://core.telegram.org/widgets/share#custom-buttons\n */\nexport const shareURLFp = create({\n  ...sharedFeatureOptions(),\n  openTelegramLink: openTelegramLinkFp,\n});\n\n/**\n * @see shareURLFp\n */\nexport const shareURL = throwifyWithChecksFp(shareURLFp);\n","import type { EventPayload, RequestError, PostEventError } from '@tma.js/bridge';\nimport type { Computed } from '@tma.js/signals';\nimport type { Maybe } from '@tma.js/toolkit';\nimport { BetterPromise } from 'better-promises';\nimport * as E from 'fp-ts/Either';\nimport * as TE from 'fp-ts/TaskEither';\nimport { pipe } from 'fp-ts/function';\n\nimport { AsyncMountable } from '@/composables/AsyncMountable.js';\nimport { Stateful } from '@/composables/Stateful.js';\nimport type {\n  LocationManagerOptions,\n  LocationManagerRequestLocationResponse,\n  LocationManagerState,\n} from '@/features/LocationManager/types.js';\nimport { createIsSupportedSignal } from '@/helpers/createIsSupportedSignal.js';\nimport type { AsyncOptions } from '@/types.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport { createWithChecksFp, type WithChecks, type WithChecksFp } from '@/with-checks/withChecksFp.js';\n\nfunction eventToState(event: EventPayload<'location_checked'>): LocationManagerState {\n  let available = false;\n  let accessRequested: Maybe<boolean>;\n  let accessGranted: Maybe<boolean>;\n  if (event.available) {\n    available = true;\n    accessRequested = event.access_requested;\n    accessGranted = event.access_granted;\n  }\n  return {\n    available,\n    accessGranted: accessGranted || false,\n    accessRequested: accessRequested || false,\n  };\n}\n\n/**\n * @since Mini Apps v8.0\n */\nexport class LocationManager {\n  constructor({\n    version,\n    request,\n    postEvent,\n    storage,\n    isTma,\n    isPageReload,\n  }: LocationManagerOptions) {\n    const stateful = new Stateful({\n      initialState: {\n        available: false,\n        accessGranted: false,\n        accessRequested: false,\n      },\n      onChange: storage.set,\n    });\n    const mountable = new AsyncMountable<LocationManagerState, RequestError>({\n      isPageReload,\n      restoreState: storage.get,\n      onMounted: stateful.setState,\n      initialState(options) {\n        return pipe(\n          request('web_app_check_location', 'location_checked', options),\n          TE.map(eventToState),\n        );\n      },\n    });\n\n    const wrapOptions = { version, requires: 'web_app_check_location', isTma } as const;\n    const wrapSupportedEither = createWithChecksFp({\n      ...wrapOptions,\n      returns: 'either',\n    });\n    const wrapSupportedTask = createWithChecksFp({\n      ...wrapOptions,\n      returns: 'task',\n    });\n    const wrapMountedTask = createWithChecksFp({\n      ...wrapOptions,\n      returns: 'task',\n      isMounted: mountable.isMounted,\n    });\n\n    this.isAvailable = stateful.getter('available');\n    this.isAccessRequested = stateful.getter('accessRequested');\n    this.isAccessGranted = stateful.getter('accessGranted');\n    this.isSupported = createIsSupportedSignal('web_app_check_location', version);\n    this.isMounted = mountable.isMounted;\n    this.state = stateful.state;\n\n    this.unmount = mountable.unmount;\n    this.mountFp = wrapSupportedTask(mountable.mount);\n    this.openSettingsFp = wrapSupportedEither(() => {\n      return postEvent('web_app_open_location_settings');\n    });\n    this.requestLocationFp = wrapMountedTask(options => {\n      return pipe(\n        request('web_app_request_location', 'location_requested', options),\n        TE.map(response => {\n          if (!response.available) {\n            stateful.setState({ available: false });\n            return null;\n          }\n          // eslint-disable-next-line @typescript-eslint/no-unused-vars\n          const { available, ...rest } = response;\n          return rest;\n        }),\n      );\n    });\n\n    this.mount = throwifyWithChecksFp(this.mountFp);\n    this.openSettings = throwifyWithChecksFp(this.openSettingsFp);\n    this.requestLocation = throwifyWithChecksFp(this.requestLocationFp);\n  }\n\n  /**\n   * Complete location manager state.\n   */\n  readonly state: Computed<LocationManagerState>;\n\n  /**\n   * Signal indicating whether the location data tracking is currently available.\n   */\n  readonly isAvailable: Computed<boolean>;\n\n  /**\n   * Signal indicating whether the user has granted the app permission to track location data.\n   */\n  readonly isAccessGranted: Computed<boolean>;\n\n  /**\n   * Signal indicating whether the app has previously requested permission to track location data.\n   */\n  readonly isAccessRequested: Computed<boolean>;\n\n  /**\n   * Signal indicating if the component is currently mounted.\n   */\n  readonly isMounted: Computed<boolean>;\n\n  /**\n   * Signal indicating if the component is supported.\n   */\n  readonly isSupported: Computed<boolean>;\n\n  /**\n   * Opens the location access settings for bots. Useful when you need to request location access\n   * from users who haven't granted it yet.\n   *\n   * Note that this method can be called only in response to user interaction with the Mini App\n   * interface (e.g., a click inside the Mini App or on the main button).\n   * @since Mini Apps v8.0\n   */\n  readonly openSettingsFp: WithChecksFp<() => E.Either<PostEventError, void>, true>;\n\n  /**\n   * @see openSettingsFp\n   */\n  readonly openSettings: WithChecks<() => void, true>;\n\n  /**\n   * Requests location data.\n   * @since Mini Apps v8.0\n   * @returns Promise with location data or null it access was not granted.\n   */\n  readonly requestLocationFp: WithChecksFp<\n    (options?: AsyncOptions) => (\n      TE.TaskEither<RequestError, LocationManagerRequestLocationResponse | null>\n    ),\n    true\n  >;\n\n  /**\n   * @see requestLocationFp\n   */\n  readonly requestLocation: WithChecks<\n    (options?: AsyncOptions) => BetterPromise<LocationManagerRequestLocationResponse | null>,\n    true\n  >;\n\n  /**\n   * Mounts the component restoring its state.\n   * @since Mini Apps v8.0\n   */\n  readonly mountFp: WithChecksFp<\n    (options?: AsyncOptions) => TE.TaskEither<RequestError, void>,\n    true\n  >;\n\n  /**\n   * @see mountFp\n   */\n  readonly mount: WithChecks<(options?: AsyncOptions) => BetterPromise<void>, true>;\n\n  /**\n   * Unmounts the component.\n   */\n  readonly unmount: () => void;\n}\n","import { pipe } from 'fp-ts/function';\n\nimport { LocationManager } from '@/features/LocationManager/LocationManager.js';\nimport type { LocationManagerState } from '@/features/LocationManager/types.js';\nimport { sharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport { withPostEvent } from '@/fn-options/withPostEvent.js';\nimport { withRequest } from '@/fn-options/withRequest.js';\nimport { withStateRestore } from '@/fn-options/withStateRestore.js';\nimport { withVersion } from '@/fn-options/withVersion.js';\n\nexport const locationManager = new LocationManager(pipe(\n  sharedFeatureOptions(),\n  withPostEvent,\n  withVersion,\n  withRequest,\n  withStateRestore<LocationManagerState>('locationManager'),\n));\n","import type { PostEventError } from '@tma.js/bridge';\nimport { computed, type Computed } from '@tma.js/signals';\nimport type { RGB } from '@tma.js/types';\nimport * as E from 'fp-ts/Either';\n\nimport { Button, type ButtonOptions } from '@/composables/Button.js';\nimport { access } from '@/helpers/access.js';\nimport type { MaybeAccessor } from '@/types.js';\nimport type { WithChecks, WithChecksFp } from '@/with-checks/withChecksFp.js';\n\ntype MainButtonEither = E.Either<PostEventError, void>;\n\nexport interface MainButtonState {\n  isVisible: boolean;\n  bgColor?: RGB;\n  hasShineEffect: boolean;\n  isEnabled: boolean;\n  isLoaderVisible: boolean;\n  text: string;\n  textColor?: RGB;\n}\n\nexport interface MainButtonOptions extends Omit<\n  ButtonOptions<MainButtonState, 'web_app_setup_main_button'>,\n  'initialState' | 'method' | 'payload' | 'version'\n> {\n  /**\n   * Default values for different kinds of the button properties.\n   */\n  defaults: {\n    bgColor: MaybeAccessor<RGB>;\n    textColor: MaybeAccessor<RGB>;\n  };\n}\n\nexport class MainButton {\n  constructor({ defaults, ...options }: MainButtonOptions) {\n    const button = new Button({\n      ...options,\n      version: '100',\n      initialState: {\n        hasShineEffect: false,\n        isEnabled: true,\n        isLoaderVisible: false,\n        isVisible: false,\n        text: 'Continue',\n      },\n      method: 'web_app_setup_main_button',\n      payload: state => ({\n        has_shine_effect: state.hasShineEffect,\n        is_visible: state.isVisible,\n        is_active: state.isEnabled,\n        is_progress_visible: state.isLoaderVisible,\n        text: state.text,\n        color: state.bgColor,\n        text_color: state.textColor,\n      }),\n    });\n\n    const withDefault = (\n      field: 'bgColor' | 'textColor',\n      getDefault: MaybeAccessor<RGB>,\n    ) => {\n      const fromState = button.stateGetter(field);\n      return computed(() => fromState() || access(getDefault));\n    };\n\n    this.bgColor = withDefault('bgColor', defaults.bgColor);\n    this.textColor = withDefault('textColor', defaults.textColor);\n    this.hasShineEffect = button.stateGetter('hasShineEffect');\n    this.isEnabled = button.stateGetter('isEnabled');\n    this.isLoaderVisible = button.stateGetter('isLoaderVisible');\n    this.text = button.stateGetter('text');\n    this.isVisible = button.stateGetter('isVisible');\n    this.isMounted = button.isMounted;\n    this.state = button.state;\n\n    [this.setBgColor, this.setBgColorFp] = button.stateSetters('bgColor');\n    [this.setTextColor, this.setTextColorFp] = button.stateSetters('textColor');\n    [\n      [this.disableShineEffect, this.disableShineEffectFp],\n      [this.enableShineEffect, this.enableShineEffectFp],\n    ] = button.stateBoolSetters('hasShineEffect');\n    [\n      [this.disable, this.disableFp],\n      [this.enable, this.enableFp],\n    ] = button.stateBoolSetters('isEnabled');\n    [\n      [this.hideLoader, this.hideLoaderFp],\n      [this.showLoader, this.showLoaderFp],\n    ] = button.stateBoolSetters('isLoaderVisible');\n\n    [this.setText, this.setTextFp] = button.stateSetters('text');\n    [[this.hide, this.hideFp], [this.show, this.showFp]] = button.stateBoolSetters('isVisible');\n    this.setParams = button.setState;\n    this.setParamsFp = button.setStateFp;\n    this.onClick = button.onClick;\n    this.onClickFp = button.onClickFp;\n    this.offClick = button.offClick;\n    this.offClickFp = button.offClickFp;\n    this.mount = button.mount;\n    this.mountFp = button.mountFp;\n    this.unmount = button.unmount;\n  }\n\n  //#region Properties.\n  /**\n   * The button background color.\n   */\n  readonly bgColor: Computed<RGB>;\n\n  /**\n   * True if the button has a shining effect.\n   */\n  readonly hasShineEffect: Computed<boolean>;\n\n  /**\n   * True if the button is clickable.\n   */\n  readonly isEnabled: Computed<boolean>;\n\n  /**\n   * True if the button loader is visible.\n   */\n  readonly isLoaderVisible: Computed<boolean>;\n\n  /**\n   * True if the button is visible.\n   */\n  readonly isVisible: Computed<boolean>;\n\n  /**\n   * Signal indicating if the component is currently mounted.\n   */\n  readonly isMounted: Computed<boolean>;\n\n  /**\n   * The complete button state.\n   */\n  readonly state: Computed<MainButtonState>;\n\n  /**\n   * The button displayed text.\n   */\n  readonly text: Computed<string>;\n\n  /**\n   * The button text color.\n   *\n   * Note that this value is computed based on the external defaults. For\n   * example, if not explicitly set, this value may be equal to one of theme\n   * params colors.\n   */\n  readonly textColor: Computed<RGB>;\n  //#endregion\n\n  //#region Methods.\n  /**\n   * Shows the button.\n   */\n  readonly showFp: WithChecksFp<() => MainButtonEither, false>;\n\n  /**\n   * @see showFp\n   */\n  readonly show: WithChecks<() => void, false>;\n\n  /**\n   * Hides the button.\n   */\n  readonly hideFp: WithChecksFp<() => MainButtonEither, false>;\n\n  /**\n   * @see hideFp\n   */\n  readonly hide: WithChecks<() => void, false>;\n\n  /**\n   * Enables the button.\n   */\n  readonly enableFp: WithChecksFp<() => MainButtonEither, false>;\n\n  /**\n   * @see enableFp\n   */\n  readonly enable: WithChecks<() => void, false>;\n\n  /**\n   * Enables the button.\n   */\n  readonly enableShineEffectFp: WithChecksFp<() => MainButtonEither, false>;\n\n  /**\n   * @see enableShineEffectFp\n   */\n  readonly enableShineEffect: WithChecks<() => void, false>;\n\n  /**\n   * Disables the button.\n   */\n  readonly disableFp: WithChecksFp<() => MainButtonEither, false>;\n\n  /**\n   * @see disableFp\n   */\n  readonly disable: WithChecks<() => void, false>;\n\n  /**\n   * Enables the button.\n   */\n  readonly disableShineEffectFp: WithChecksFp<() => MainButtonEither, false>;\n\n  /**\n   * @see disableShineEffectFp\n   */\n  readonly disableShineEffect: WithChecks<() => void, false>;\n\n  /**\n   * Updates the button background color.\n   */\n  readonly setBgColorFp: WithChecksFp<(value: RGB) => MainButtonEither, false>;\n\n  /**\n   * @see setBgColorFp\n   */\n  readonly setBgColor: WithChecks<(value: RGB) => void, false>;\n\n  /**\n   * Updates the button text color.\n   */\n  readonly setTextColorFp: WithChecksFp<(value: RGB) => MainButtonEither, false>;\n\n  /**\n   * @see setTextColorFp\n   */\n  readonly setTextColor: WithChecks<(value: RGB) => void, false>;\n\n  /**\n   * Updates the button text.\n   */\n  readonly setTextFp: WithChecksFp<(value: string) => MainButtonEither, false>;\n\n  /**\n   * @see setTextFp\n   */\n  readonly setText: WithChecks<(value: string) => void, false>;\n\n  /**\n   * Shows the button loader.\n   */\n  readonly showLoaderFp: WithChecksFp<() => MainButtonEither, false>;\n\n  /**\n   * @see showLoaderFp\n   */\n  readonly showLoader: WithChecks<() => void, false>;\n\n  /**\n   * Hides the button loader.\n   */\n  readonly hideLoaderFp: WithChecksFp<() => MainButtonEither, false>;\n\n  /**\n   * @see hideLoaderFp\n   */\n  readonly hideLoader: WithChecks<() => void, false>;\n\n  /**\n   * Updates the button state.\n   * @param state - updates to apply.\n   * @example\n   * button.setParams({\n   *   text: 'Submit',\n   *   isEnabled: true,\n   *   hasShineEffect: true,\n   * });\n   */\n  readonly setParamsFp: WithChecksFp<(state: Partial<MainButtonState>) => MainButtonEither, false>;\n\n  readonly setParams: WithChecks<(state: Partial<MainButtonState>) => void, false>;\n\n  /**\n   * Mounts the component restoring its state.\n   */\n  readonly mountFp: WithChecksFp<() => void, false>;\n\n  /**\n   * @see mountFp\n   */\n  readonly mount: WithChecks<() => void, false>;\n\n  /**\n   * Unmounts the component.\n   */\n  readonly unmount: () => void;\n\n  /**\n   * Adds a new button listener.\n   * @param listener - event listener.\n   * @param once - should the listener be called only once.\n   * @returns A function to remove bound listener.\n   * @example\n   * const off = button.onClick(() => {\n   *   console.log('User clicked the button');\n   *   off();\n   * });\n   */\n  readonly onClickFp: WithChecksFp<(listener: VoidFunction, once?: boolean) => VoidFunction, false>;\n\n  /**\n   * @see onClickFp\n   */\n  readonly onClick: WithChecks<(listener: VoidFunction, once?: boolean) => VoidFunction, false>;\n\n  /**\n   * Removes the button click listener.\n   * @param listener - event listener.\n   * @param once - should the listener be called only once.\n   * @example\n   * function listener() {\n   *   console.log('User clicked the button');\n   *   button.offClick(listener);\n   * }\n   * button.onClick(listener);\n   */\n  readonly offClickFp: WithChecksFp<(listener: VoidFunction, once?: boolean) => void, false>;\n\n  /**\n   * @see offClickFp\n   */\n  readonly offClick: WithChecks<(listener: VoidFunction, once?: boolean) => void, false>;\n  //#endregion\n}\n","/**\n * Sets CSS variable globally.\n * @param name - variable name.\n * @param value - variable value.\n */\nexport function setCssVar(name: string, value: string | null): void {\n  document.documentElement.style.setProperty(name, value);\n}\n\n/**\n * Deletes specified CSS variable.\n * @param name - variable name.\n */\nexport function deleteCssVar(name: string): void {\n  document.documentElement.style.removeProperty(name);\n}\n","import { throwifyFpFn } from '@tma.js/toolkit';\nimport { toRGBFullFp } from '@tma.js/transformers';\nimport * as E from 'fp-ts/Either';\nimport { pipe } from 'fp-ts/function';\n\n/**\n * @param color - color in any format acceptable by the `toRGB` function.\n * @returns True if the color is recognized as dark.\n * @see toRGB\n */\nexport function isColorDarkFp(color: string): E.Either<Error, boolean> {\n  return pipe(\n    toRGBFullFp(color),\n    E.map(rgb => {\n      // Actual formula: hsp = Math.sqrt(0.299 * r * r + 0.587 * g * g + 0.114 * b * b)\n      // See: https://stackoverflow.com/a/596243\n      return Math.sqrt(\n        [0.299, 0.587, 0.114].reduce<number>((acc, modifier, idx) => {\n          // Extract part of #RRGGBB pattern and convert it to DEC.\n          const dec = parseInt(rgb.slice(1 + (idx * 2), 1 + ((idx + 1) * 2)), 16);\n          return acc + (dec * dec * modifier);\n        }, 0),\n      ) < 120;\n    }),\n  );\n}\n\n/**\n * @see isColorDarkFp\n */\nexport const isColorDark = throwifyFpFn(isColorDarkFp);\n","import type { EventListener } from '@tma.js/bridge';\nimport { computed, type Computed, signal } from '@tma.js/signals';\nimport { snakeToKebab } from '@tma.js/toolkit';\nimport type { ThemeParams as ThemeParamsType, RGB } from '@tma.js/types';\nimport * as E from 'fp-ts/Either';\n\nimport { Mountable } from '@/composables/Mountable.js';\nimport { Stateful } from '@/composables/Stateful.js';\nimport { CSSVarsBoundError } from '@/errors.js';\nimport type { SharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport type { WithStateRestore } from '@/fn-options/withStateRestore.js';\nimport { access } from '@/helpers/access.js';\nimport { deleteCssVar, setCssVar } from '@/helpers/css-vars.js';\nimport { isColorDark } from '@/helpers/isColorDark.js';\nimport type { MaybeAccessor } from '@/types.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport {\n  createWithChecksFp,\n  type WithChecks,\n  type WithChecksFp,\n} from '@/with-checks/withChecksFp.js';\n\nexport type ThemeParamsState = ThemeParamsType;\n\nexport interface ThemeParamsOptions extends WithStateRestore<ThemeParamsState>,\n  SharedFeatureOptions {\n  /**\n   * Removes a theme change listener.\n   * @param listener - a listener to remove.\n   */\n  offChange: (listener: EventListener<'theme_changed'>) => void;\n  /**\n   * Adds a theme change listener.\n   * @returns A function to remove listener.\n   * @param listener - a listener to add.\n   */\n  onChange: (listener: EventListener<'theme_changed'>) => void;\n  /**\n   * Theme parameters initial state.\n   */\n  initialState: MaybeAccessor<ThemeParamsType>;\n}\n\nexport interface ThemeParamsGetCssVarNameFn {\n  /**\n   * @param property - palette key.\n   * @returns Computed complete CSS variable name.\n   */\n  (property: Extract<keyof ThemeParamsType, string>): string;\n}\n\nexport class ThemeParams {\n  constructor({\n    initialState,\n    onChange,\n    offChange,\n    isTma,\n    storage,\n    isPageReload,\n  }: ThemeParamsOptions) {\n    const stateful = new Stateful<ThemeParamsState>({\n      initialState: {},\n      onChange: storage.set,\n    });\n    const listener: EventListener<'theme_changed'> = event => {\n      stateful.setState(event.theme_params);\n    };\n    const mountable = new Mountable<ThemeParamsType>({\n      initialState: () => E.right(access(initialState)),\n      isPageReload,\n      onMounted(state) {\n        stateful.setState(state);\n        onChange(listener);\n      },\n      onUnmounted() {\n        offChange(listener);\n      },\n      restoreState: storage.get,\n    });\n\n    const wrapOptions = { isTma, returns: 'either' } as const;\n    const wrapSupportedEither = createWithChecksFp(wrapOptions);\n    const wrapMountedEither = createWithChecksFp({\n      ...wrapOptions,\n      isMounted: mountable.isMounted,\n    });\n\n    // Colors.\n    this.accentTextColor = stateful.getter('accent_text_color');\n    this.bgColor = stateful.getter('bg_color');\n    this.buttonColor = stateful.getter('button_color');\n    this.buttonTextColor = stateful.getter('button_text_color');\n    this.bottomBarBgColor = stateful.getter('bottom_bar_bg_color');\n    this.destructiveTextColor = stateful.getter('destructive_text_color');\n    this.headerBgColor = stateful.getter('header_bg_color');\n    this.hintColor = stateful.getter('hint_color');\n    this.linkColor = stateful.getter('link_color');\n    this.secondaryBgColor = stateful.getter('secondary_bg_color');\n    this.sectionBgColor = stateful.getter('section_bg_color');\n    this.sectionHeaderTextColor = stateful.getter('section_header_text_color');\n    this.sectionSeparatorColor = stateful.getter('section_separator_color');\n    this.subtitleTextColor = stateful.getter('subtitle_text_color');\n    this.textColor = stateful.getter('text_color');\n\n    // Other public signals.\n    this.state = stateful.state;\n    this.isMounted = mountable.isMounted;\n    this.bindCssVarsFp = wrapMountedEither(getCSSVarName => {\n      if (this._isCssVarsBound()) {\n        return E.left(new CSSVarsBoundError());\n      }\n      getCSSVarName ||= prop => `--tg-theme-${snakeToKebab(prop)}`;\n\n      const forEachEntry = (fn: (key: string, value: RGB) => void): void => {\n        Object.entries(stateful.state()).forEach(([k, v]) => {\n          v && fn(k, v);\n        });\n      };\n\n      const actualize = (): void => {\n        forEachEntry((k, v) => {\n          setCssVar(getCSSVarName(k), v);\n        });\n      };\n\n      actualize();\n      stateful.state.sub(actualize);\n      this._isCssVarsBound.set(true);\n\n      return E.right(() => {\n        forEachEntry(deleteCssVar);\n        stateful.state.unsub(actualize);\n        this._isCssVarsBound.set(false);\n      });\n    });\n    this.mountFp = wrapSupportedEither(mountable.mount);\n    this.unmount = mountable.unmount;\n\n    this.bindCssVars = throwifyWithChecksFp(this.bindCssVarsFp);\n    this.mount = throwifyWithChecksFp(this.mountFp);\n  }\n\n  //#region Colors.\n  /**\n   * @since v6.10\n   */\n  readonly accentTextColor: Computed<RGB | undefined>;\n\n  readonly bgColor: Computed<RGB | undefined>;\n\n  readonly buttonColor: Computed<RGB | undefined>;\n\n  readonly buttonTextColor: Computed<RGB | undefined>;\n\n  /**\n   * @since v7.10\n   */\n  readonly bottomBarBgColor: Computed<RGB | undefined>;\n\n  readonly destructiveTextColor: Computed<RGB | undefined>;\n\n  /**\n   * @since v6.10\n   */\n  readonly headerBgColor: Computed<RGB | undefined>;\n\n  readonly hintColor: Computed<RGB | undefined>;\n\n  readonly linkColor: Computed<RGB | undefined>;\n\n  readonly secondaryBgColor: Computed<RGB | undefined>;\n\n  /**\n   * @since v6.10\n   */\n  readonly sectionBgColor: Computed<RGB | undefined>;\n\n  /**\n   * @since v6.10\n   */\n  readonly sectionHeaderTextColor: Computed<RGB | undefined>;\n\n  /**\n   * @since v7.6\n   */\n  readonly sectionSeparatorColor: Computed<RGB | undefined>;\n\n  /**\n   * @since v6.10\n   */\n  readonly subtitleTextColor: Computed<RGB | undefined>;\n\n  readonly textColor: Computed<RGB | undefined>;\n  //#endregion\n\n  //#region CSS variables.\n  private readonly _isCssVarsBound = signal(false);\n\n  /**\n   * True if CSS variables are currently bound.\n   */\n  readonly isCssVarsBound = computed(this._isCssVarsBound);\n\n  /**\n   * Creates CSS variables connected with the current theme parameters.\n   *\n   * By default, created CSS variables names are following the pattern \"--tg-theme-{name}\", where\n   * {name} is a theme parameters key name converted from snake case to kebab case.\n   *\n   * Default variables:\n   * - `--tg-theme-bg-color`\n   * - `--tg-theme-secondary-text-color`\n   *\n   * Variables are being automatically updated if theme parameters were changed.\n   *\n   * @param getCSSVarName - function, returning complete CSS variable name for the specified\n   * theme parameters key.\n   * @returns Function to stop updating variables.\n   * @throws {CSSVarsBoundError} CSS variables are already bound\n   * @example Using custom CSS vars generator\n   * themeParams.bindCssVars(key => `--my-prefix-${key}`);\n   */\n  readonly bindCssVarsFp: WithChecksFp<\n    (getCSSVarName?: ThemeParamsGetCssVarNameFn) => E.Either<CSSVarsBoundError, VoidFunction>,\n    false\n  >;\n\n  /**\n   * @see bindCssVarsFp\n   */\n  readonly bindCssVars: WithChecks<\n    (getCSSVarName?: ThemeParamsGetCssVarNameFn) => VoidFunction,\n    false\n  >;\n  //#endregion\n\n  //#region Other public signals.\n  /**\n   * Complete component state.\n   */\n  readonly state: Computed<ThemeParamsType>;\n\n  /**\n   * @returns True if the current color scheme is recognized as dark.\n   * This value is calculated based on the current theme's background color.\n   */\n  readonly isDark = computed(() => {\n    const color = this.bgColor();\n    return !color || isColorDark(color);\n  });\n  //#endregion\n\n  //#region Mounting.\n  /**\n   * Signal indicating if the component is currently mounted.\n   */\n  readonly isMounted: Computed<boolean>;\n\n  /**\n   * Mounts the component restoring its state.\n   */\n  readonly mountFp: WithChecksFp<() => E.Either<never, void>, false>;\n\n  /**\n   * @see mountFp\n   */\n  readonly mount: WithChecks<() => void, false>;\n\n  /**\n   * Unmounts the component.\n   */\n  readonly unmount: () => void;\n  //#endregion\n}\n","import type { ThemeParams } from '@tma.js/types';\n\nimport { createSignal } from '@/globals/signals-registry.js';\n\n/**\n * Mini application's theme parameters.\n */\nexport const themeParams = createSignal<ThemeParams>({});\n","import { on, off } from '@tma.js/bridge';\nimport { pipe } from 'fp-ts/function';\n\nimport { ThemeParams, type ThemeParamsState } from '@/features/ThemeParams/ThemeParams.js';\nimport { sharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport { withStateRestore } from '@/fn-options/withStateRestore.js';\nimport { themeParams as globalThemeParams } from '@/globals/themeParams.js';\n\nexport const themeParams = new ThemeParams({\n  ...pipe(\n    sharedFeatureOptions(),\n    withStateRestore<ThemeParamsState>('themeParams'),\n  ),\n  offChange(listener) {\n    off('theme_changed', listener);\n  },\n  onChange(listener) {\n    on('theme_changed', listener);\n  },\n  initialState: globalThemeParams,\n});\n","import type { EventName } from '@tma.js/bridge';\nimport { pipe } from 'fp-ts/function';\n\nimport { buttonOptions } from '@/fn-options/buttonOptions.js';\n\nexport function bottomButtonOptions<S, D>(\n  storageName: string,\n  trackedClickEvent: EventName,\n  defaults: D,\n) {\n  return pipe(\n    buttonOptions<S>(storageName, trackedClickEvent),\n    obj => ({ ...obj, defaults }),\n  );\n}\n","import { computed } from '@tma.js/signals';\n\nimport { MainButton } from '@/features/MainButton/MainButton.js';\nimport { themeParams } from '@/features/ThemeParams/instance.js';\nimport { bottomButtonOptions } from '@/fn-options/bottomButtonOptions.js';\n\nexport const mainButton = new MainButton(\n  bottomButtonOptions('mainButton', 'main_button_pressed', {\n    bgColor: computed(() => themeParams.buttonColor() || '#2481cc'),\n    textColor: computed(() => themeParams.buttonTextColor() || '#ffffff'),\n  }),\n);\n","import {\n  supports,\n  type PostEventError,\n  type EventPayload,\n  type EventListener,\n} from '@tma.js/bridge';\nimport { type Computed, computed } from '@tma.js/signals';\nimport { signal } from '@tma.js/signals';\nimport { createCbCollector, camelToKebab } from '@tma.js/toolkit';\nimport { isRGB } from '@tma.js/transformers';\nimport type { KnownThemeParamsKey, RGB, ThemeParams } from '@tma.js/types';\nimport * as E from 'fp-ts/Either';\nimport { pipe } from 'fp-ts/function';\n\nimport { Mountable } from '@/composables/Mountable.js';\nimport { Stateful } from '@/composables/Stateful.js';\nimport { CSSVarsBoundError, UnknownThemeParamsKeyError } from '@/errors.js';\nimport type { SharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport type { WithPostEvent } from '@/fn-options/withPostEvent.js';\nimport type { WithStateRestore } from '@/fn-options/withStateRestore.js';\nimport type { WithVersion } from '@/fn-options/withVersion.js';\nimport { access } from '@/helpers/access.js';\nimport { deleteCssVar, setCssVar } from '@/helpers/css-vars.js';\nimport { isColorDark } from '@/helpers/isColorDark.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport {\n  createWithChecksFp,\n  type WithChecks,\n  withChecksFp,\n  type WithChecksFp,\n} from '@/with-checks/withChecksFp.js';\n\ntype AnyColor = RGB | KnownThemeParamsKey | string;\n\nexport interface MiniAppState {\n  bgColor: AnyColor;\n  bottomBarColor: AnyColor;\n  headerColor: AnyColor;\n  isActive: boolean;\n}\n\nexport interface MiniAppGetCssVarNameFn {\n  /**\n   * @param property - mini app property.\n   * @returns Computed complete CSS variable name.\n   */\n  (property: 'bgColor' | 'bottomBarColor' | 'headerColor'): string;\n}\n\ntype WithListeners<Handlers extends string, Payload> = {\n  [K in Handlers]: (listener: (payload: Payload) => void) => void;\n};\n\nexport interface MiniAppOptions extends WithPostEvent,\n  WithVersion,\n  WithStateRestore<MiniAppState>,\n  WithListeners<'onVisibilityChanged' | 'offVisibilityChanged', EventPayload<'visibility_changed'>>,\n  SharedFeatureOptions {\n  /**\n   * The current theme parameters.\n   */\n  theme: Computed<ThemeParams>;\n}\n\n/**\n * @since Mini Apps v6.1\n */\nexport class MiniApp {\n  constructor({\n    storage,\n    isPageReload,\n    version,\n    postEvent,\n    isTma,\n    theme,\n    onVisibilityChanged,\n    offVisibilityChanged,\n  }: MiniAppOptions) {\n    //#region Mounting.\n    const visibilityChangedListener: EventListener<'visibility_changed'> = event => {\n      stateful.setState({ isActive: event.is_visible });\n    };\n    const themeChangedListener = (theme: ThemeParams) => {\n      // Sometimes we may have the following colors to be specified as some theme params keys.\n      // Due to the Mini Apps nature, we are not really allowed to do that, but we want to provide\n      // such an opportunity to developers.\n      //\n      // So if the developer specified some field as a reference to some theme params key, we\n      // should find an according RGB color for it and send it to the Telegram client. We have one\n      // exclusion here - the method 'web_app_set_header_color' may accept values 'bg_color'\n      // and 'secondary_bg_color'. Other methods accept only RGB values.\n      ([\n        [this.headerColor, 'web_app_set_header_color'],\n        [this.bgColor, 'web_app_set_background_color'],\n        [this.bottomBarColor, 'web_app_set_bottom_bar_color'],\n      ] as const).forEach(([signal, method]) => {\n        const color = signal();\n        // The value is already in RGB format, we have nothing to update here.\n        if (isRGB(color)) {\n          return;\n        }\n        // The real RGB value should only be extracted for the following methods:\n        // - 'web_app_set_background_color'\n        // - 'web_app_set_bottom_bar_color'\n        // We should also do it in case of the 'web_app_set_header_color' method, if the value\n        // specified is not 'bg_color' and 'secondary_bg_color' (unknown key to\n        // the Telegram client).\n        if (\n          method !== 'web_app_set_header_color'\n          || !['bg_color', 'secondary_bg_color'].includes(color)\n        ) {\n          const rgb = theme[color];\n          if (rgb) {\n            postEvent(method, { color: rgb });\n          }\n        }\n      });\n    };\n    const mountable = new Mountable({\n      initialState() {\n        return E.right({\n          bgColor: 'bg_color',\n          headerColor: 'header_bg_color',\n          bottomBarColor: 'bottom_bar_bg_color',\n          isActive: true,\n        });\n      },\n      isPageReload,\n      onMounted: state => {\n        onVisibilityChanged(visibilityChangedListener);\n        theme.sub(themeChangedListener);\n        stateful.setState(state);\n      },\n      onUnmounted() {\n        offVisibilityChanged(visibilityChangedListener);\n        theme.unsub(themeChangedListener);\n      },\n      restoreState: storage.get,\n    });\n    this.isMounted = mountable.isMounted;\n    this.mountFp = withChecksFp(() => {\n      const nothing = () => undefined;\n      return pipe(mountable.mount(), E.match(nothing, nothing));\n    }, { isTma, returns: 'plain' });\n    this.mount = throwifyWithChecksFp(this.mountFp);\n    this.unmount = mountable.unmount;\n    //#endregion\n\n    //#region State.\n    const stateful = new Stateful({\n      initialState: {\n        bgColor: 'bg_color',\n        bottomBarColor: 'bottom_bar_bg_color',\n        headerColor: 'bg_color',\n        isActive: false,\n      },\n      onChange: storage.set,\n    });\n    this.state = stateful.state;\n\n    const rgbBasedOn = (color: AnyColor): RGB | undefined => {\n      return isRGB(color) ? color : access(theme)[color];\n    };\n    const computedRgbBasedOn = (signal: Computed<AnyColor>): Computed<RGB | undefined> => {\n      return computed(() => rgbBasedOn(signal()));\n    };\n    //#endregion\n\n    //#region Other properties.\n    this.isActive = stateful.getter('isActive');\n    this.isSupported = computed(() => {\n      return ([\n        'web_app_set_header_color',\n        'web_app_set_background_color',\n        'web_app_set_bottom_bar_color',\n      ] as const).some(method => supports(method, access(version)));\n    });\n    //#endregion\n\n    //#region Css vars.\n    const isCssVarsBound = signal(false);\n    this.isCssVarsBound = computed(isCssVarsBound);\n    this.bindCssVarsFp = withChecksFp(getCSSVarName => {\n      if (isCssVarsBound()) {\n        return E.left(new CSSVarsBoundError());\n      }\n      const [addCleanup, cleanup] = createCbCollector(() => {\n        isCssVarsBound.set(false);\n      });\n\n      const bind = (cssVar: string, signal: Computed<RGB | undefined>) => {\n        const update = () => {\n          setCssVar(cssVar, signal() || null);\n        };\n        update();\n        addCleanup(signal.sub(update), deleteCssVar.bind(null, cssVar));\n      };\n\n      getCSSVarName ||= prop => `--tg-${camelToKebab(prop)}`;\n      bind(getCSSVarName('bgColor'), this.bgColorRgb);\n      bind(getCSSVarName('bottomBarColor'), this.bottomBarColorRgb);\n      bind(getCSSVarName('headerColor'), this.headerColorRgb);\n\n      isCssVarsBound.set(true);\n\n      return E.right(cleanup);\n    }, { isTma, returns: 'either', isMounted: this.isMounted });\n    this.bindCssVars = throwifyWithChecksFp(this.bindCssVarsFp);\n    //#endregion\n\n    //#region Colors.\n    type GenColorToolsetResult<K extends Exclude<keyof MiniAppState, 'isActive'>> = [\n      rawColor: Computed<AnyColor>,\n      rgbColor: Computed<RGB | undefined>,\n      throwing: WithChecks<\n        (color: AnyColor) => void,\n        true,\n        K extends 'headerColor' ? 'rgb' : never\n      >,\n      fp: WithChecksFp<\n        (color: AnyColor) => E.Either<UnknownThemeParamsKeyError | PostEventError, void>,\n        true,\n        K extends 'headerColor' ? 'rgb' : never\n      >,\n    ];\n    const genColorToolset = <K extends Exclude<keyof MiniAppState, 'isActive'>>(\n      stateKey: K,\n    ): GenColorToolsetResult<K> => {\n      const rawColor = stateful.getter(stateKey);\n      const rgbColor = computedRgbBasedOn(rawColor);\n      const method = ({\n        headerColor: 'web_app_set_header_color',\n        bgColor: 'web_app_set_background_color',\n        bottomBarColor: 'web_app_set_bottom_bar_color',\n      } as const)[stateKey];\n\n      const fp = withChecksFp(\n        (color: AnyColor): E.Either<UnknownThemeParamsKeyError | PostEventError, void> => {\n          if (color === rawColor()) {\n            return E.right(undefined);\n          }\n          if (\n            method === 'web_app_set_header_color'\n            && (color === 'bg_color' || color === 'secondary_bg_color')\n          ) {\n            return pipe(\n              postEvent('web_app_set_header_color', { color_key: color }),\n              E.map(() => {\n                stateful.setState({ [stateKey]: color });\n              }),\n            );\n          }\n          const rgb = rgbBasedOn(color);\n          return pipe(\n            rgb\n              ? postEvent(method, { color: rgb })\n              : E.left(new UnknownThemeParamsKeyError(color)),\n            E.map(() => {\n              stateful.setState({ [stateKey]: color });\n            }),\n          );\n        },\n        {\n          isTma,\n          version,\n          requires: method,\n          isMounted: this.isMounted,\n          returns: 'either',\n          supports: stateKey === 'headerColor'\n            ? {\n              rgb: {\n                method: 'web_app_set_header_color',\n                param: 'color',\n                shouldCheck: isRGB,\n              },\n            }\n            : undefined,\n        },\n      );\n\n      return [rawColor, rgbColor, throwifyWithChecksFp(fp), fp] as GenColorToolsetResult<K>;\n    };\n    [\n      this.bgColor,\n      this.bgColorRgb,\n      this.setBgColor,\n      this.setBgColorFp,\n    ] = genColorToolset('bgColor');\n    [\n      this.headerColor,\n      this.headerColorRgb,\n      this.setHeaderColor,\n      this.setHeaderColorFp,\n    ] = genColorToolset('headerColor');\n    [\n      this.bottomBarColor,\n      this.bottomBarColorRgb,\n      this.setBottomBarColor,\n      this.setBottomBarColorFp,\n    ] = genColorToolset('bottomBarColor');\n    //#endregion\n\n    //#region Other methods.\n    const withBasicEither = createWithChecksFp({ isTma, returns: 'either' });\n    this.closeFp = withBasicEither(returnBack => {\n      return postEvent('web_app_close', { return_back: returnBack });\n    });\n    this.close = throwifyWithChecksFp(this.closeFp);\n\n    this.readyFp = withBasicEither(() => postEvent('web_app_ready'));\n    this.ready = throwifyWithChecksFp(this.readyFp);\n    //#endregion\n  }\n\n  //#region Other properties.\n  /**\n   * Signal indicating if the component is supported.\n   */\n  readonly isSupported: Computed<boolean>;\n\n  /**\n   * True if the current Mini App background color is recognized as dark.\n   */\n  readonly isDark = computed(() => {\n    const color = this.bgColorRgb();\n    return color ? isColorDark(color) : false;\n  });\n\n  /**\n   * Signal indicating if the mini app is currently active.\n   */\n  readonly isActive: Computed<boolean>;\n\n  /**\n   * Complete component state.\n   */\n  readonly state: Computed<MiniAppState>;\n  //#endregion\n\n  //#region CSS variables.\n  /**\n   * True if the CSS variables are currently bound.\n   */\n  readonly isCssVarsBound: Computed<boolean>;\n\n  /**\n   * Creates CSS variables connected with the mini app.\n   *\n   * Default variables:\n   * - `--tg-bg-color`\n   * - `--tg-header-color`\n   * - `--tg-bottom-bar-color`\n   *\n   * Variables are being automatically updated if theme parameters were changed.\n   *\n   * @param getCSSVarName - function, returning complete CSS variable name for the specified\n   * mini app key.\n   * @returns Function to stop updating variables.\n   * @example Using no arguments\n   * miniApp.bindCssVars();\n   * @example Using custom CSS vars generator\n   * miniApp.bindCssVars(key => `--my-prefix-${key}`);\n   */\n  readonly bindCssVarsFp: WithChecksFp<\n    (getCssVarName?: MiniAppGetCssVarNameFn) => E.Either<CSSVarsBoundError, VoidFunction>,\n    false\n  >;\n\n  readonly bindCssVars: WithChecks<(getCssVarName?: MiniAppGetCssVarNameFn) => VoidFunction, false>;\n  //#endregion\n\n  //#region Mounting.\n  /**\n   * Signal indicating if the component is mounted.\n   */\n  readonly isMounted: Computed<boolean>;\n\n  /**\n   * Mounts the component.\n   *\n   * This function restores the component state and is automatically saving it in the local storage\n   * if it changed.\n   * @since Mini Apps v6.1\n   */\n  readonly mountFp: WithChecksFp<() => void, false>;\n\n  /**\n   * @see mount\n   */\n  readonly mount: WithChecks<() => void, false>;\n\n  /**\n   * Unmounts the component.\n   */\n  readonly unmount: () => void;\n  //#endregion\n\n  //#region Background color.\n  /**\n   * The Mini App background color.\n   *\n   * Represents an RGB color, or theme parameters key, like \"bg_color\", \"secondary_bg_color\", etc.\n   *\n   * Note that using a theme parameters key, background color becomes bound to the current\n   * theme parameters, making it automatically being updated whenever theme parameters change.\n   * In order to remove this bind, use an explicit RGB color.\n   */\n  readonly bgColor: Computed<AnyColor>;\n\n  /**\n   * RGB representation of the background color.\n   *\n   * This value requires the Theme Params component to be mounted to extract a valid RGB value\n   * of the color key.\n   */\n  readonly bgColorRgb: Computed<RGB | undefined>;\n\n  /**\n   * Updates the mini app background color.\n   * @since Mini Apps v6.1\n   */\n  readonly setBgColorFp: WithChecksFp<\n    (color: AnyColor) => E.Either<PostEventError | UnknownThemeParamsKeyError, void>,\n    true\n  >;\n\n  /**\n   * @see setBgColorFp\n   */\n  readonly setBgColor: WithChecks<(color: AnyColor) => void, true>;\n  //#endregion\n\n  //#region Header color.\n  /**\n   * The Mini App header color.\n   */\n  readonly headerColor: Computed<AnyColor>;\n\n  /**\n   * RGB representation of the header color.\n   *\n   * This value requires the Theme Params component to be mounted to extract a valid RGB value\n   * of the color key.\n   */\n  readonly headerColorRgb: Computed<RGB | undefined>;\n\n  /**\n   * Updates the mini app header color.\n   * @since Mini Apps v6.1\n   */\n  readonly setHeaderColorFp: WithChecksFp<\n    (color: AnyColor) => E.Either<PostEventError | UnknownThemeParamsKeyError, void>,\n    true,\n    'rgb'\n  >;\n\n  /**\n   * @see setHeaderColorFp\n   */\n  readonly setHeaderColor: WithChecks<(color: AnyColor) => void, true, 'rgb'>;\n  //#endregion\n\n  //#region Bottom bar background color.\n  /**\n   * The Mini App bottom bar background color.\n   */\n  readonly bottomBarColor: Computed<AnyColor>;\n\n  /**\n   * RGB representation of the bottom bar background color.\n   *\n   * This value requires the Theme Params component to be mounted to extract a valid RGB value\n   * of the color key.\n   */\n  readonly bottomBarColorRgb: Computed<RGB | undefined>;\n\n  /**\n   * Updates the mini app bottom bar bg color.\n   * @since Mini Apps v7.10\n   */\n  readonly setBottomBarColorFp: WithChecksFp<\n    (color: AnyColor) => E.Either<PostEventError | UnknownThemeParamsKeyError, void>,\n    true\n  >;\n\n  /**\n   * @see setBottomBarColorFp\n   */\n  readonly setBottomBarColor: WithChecks<(color: AnyColor) => void, true>;\n  //#endregion\n\n  //#region Other methods.\n  /**\n   * Closes the Mini App.\n   * @param returnBack - should the client return to the previous activity.\n   */\n  readonly closeFp: WithChecksFp<(returnBack?: boolean) => E.Either<PostEventError, void>, false>;\n\n  /**\n   * @see closeFp\n   */\n  readonly close: WithChecks<(returnBack?: boolean) => void, false>;\n\n  /**\n   * Informs the Telegram app that the Mini App is ready to be displayed.\n   *\n   * It is recommended to call this method as early as possible, as soon as all\n   * essential interface elements loaded.\n   *\n   * Once this method is called, the loading placeholder is hidden and the Mini\n   * App shown.\n   *\n   * If the method is not called, the placeholder will be hidden only when the\n   * page was fully loaded.\n   */\n  readonly readyFp: WithChecksFp<() => E.Either<PostEventError, void>, false>;\n\n  /**\n   * @see readyFp\n   */\n  readonly ready: WithChecks<() => void, false>;\n  //#endregion\n}\n","import { on, off } from '@tma.js/bridge';\nimport { pipe } from 'fp-ts/function';\n\nimport { MiniApp, type MiniAppState } from '@/features/MiniApp/MiniApp.js';\nimport { themeParams } from '@/features/ThemeParams/instance.js';\nimport { sharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport { withPostEvent } from '@/fn-options/withPostEvent.js';\nimport { withStateRestore } from '@/fn-options/withStateRestore.js';\nimport { withVersion } from '@/fn-options/withVersion.js';\n\nexport const miniApp = new MiniApp({\n  ...pipe(\n    sharedFeatureOptions(),\n    withPostEvent,\n    withVersion,\n    withStateRestore<MiniAppState>('miniApp'),\n  ),\n  offVisibilityChanged(listener) {\n    off('visibility_changed', listener);\n  },\n  onVisibilityChanged(listener) {\n    on('visibility_changed', listener);\n  },\n  theme: themeParams.state,\n});\n","import type { PopupParams, PopupButton } from '@tma.js/bridge';\nimport * as E from 'fp-ts/Either';\n\nimport { InvalidArgumentsError } from '@/errors.js';\nimport type { ShowOptions } from '@/features/Popup/types.js';\n\n/**\n * Prepares popup parameters before sending them to native app.\n * @param params - popup parameters.\n */\nexport function prepareParams(params: ShowOptions): E.Either<InvalidArgumentsError, PopupParams> {\n  const message = params.message.trim();\n  const title = (params.title || '').trim();\n  const paramsButtons = params.buttons || [];\n\n  if (title.length > 64) {\n    return E.left(new InvalidArgumentsError(`Invalid title: ${title}`));\n  }\n  if (!message || message.length > 256) {\n    return E.left(new InvalidArgumentsError(`Invalid message: ${message}`));\n  }\n  if (paramsButtons.length > 3) {\n    return E.left(new InvalidArgumentsError(`Invalid buttons count: ${paramsButtons.length}`));\n  }\n\n  const buttons: PopupButton[] = [];\n  if (!paramsButtons.length) {\n    buttons.push({ type: 'close', id: '' });\n  } else {\n    for (let i = 0; i < paramsButtons.length; i++) {\n      const button = paramsButtons[i];\n      const id = button.id || '';\n      if (id.length > 64) {\n        return E.left(new InvalidArgumentsError(`Button with index ${i} has invalid id: ${id}`));\n      }\n\n      if (!button.type || button.type === 'default' || button.type === 'destructive') {\n        const text = button.text.trim();\n        if (!text || text.length > 64) {\n          return E.left(new InvalidArgumentsError(`Button with index ${i} has invalid text: ${text}`));\n        }\n        buttons.push({ type: button.type, text, id });\n      } else {\n        buttons.push({ type: button.type, id });\n      }\n    }\n  }\n\n  return E.right({ title, message, buttons });\n}\n","import type { RequestError } from '@tma.js/bridge';\nimport { type Computed, signal, computed } from '@tma.js/signals';\nimport type { BetterPromise } from 'better-promises';\nimport * as TE from 'fp-ts/TaskEither';\nimport { pipe } from 'fp-ts/function';\n\nimport { ConcurrentCallError, type InvalidArgumentsError } from '@/errors.js';\nimport { prepareParams } from '@/features/Popup/prepareParams.js';\nimport type { ShowOptions } from '@/features/Popup/types.js';\nimport type { SharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport type { WithRequest } from '@/fn-options/withRequest.js';\nimport type { WithVersion } from '@/fn-options/withVersion.js';\nimport { createIsSupportedSignal } from '@/helpers/createIsSupportedSignal.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport { createWithChecksFp, type WithChecksFp, type WithChecks } from '@/with-checks/withChecksFp.js';\n\nexport interface PopupOptions extends SharedFeatureOptions, WithVersion, WithRequest {\n}\n\n/**\n * @since Mini Apps v6.2\n */\nexport class Popup {\n  constructor({ version, isTma, request }: PopupOptions) {\n    const isOpened = signal(false);\n    const toggleClosed = () => {\n      isOpened.set(false);\n    };\n\n    const wrapSupportedTask = createWithChecksFp({\n      version,\n      isTma,\n      requires: 'web_app_open_popup',\n      returns: 'task',\n    });\n\n    this.isSupported = createIsSupportedSignal('web_app_open_popup', version);\n    this.isOpened = computed(isOpened);\n    this.showFp = wrapSupportedTask(options => {\n      return pipe(\n        this.isOpened()\n          ? TE.left(new ConcurrentCallError('A popup is already opened'))\n          : TE.right(undefined as never),\n        TE.chainW(() => TE.fromEither(prepareParams(options))),\n        TE.chain(preparedOptions => {\n          isOpened.set(true);\n          return request('web_app_open_popup', 'popup_closed', {\n            ...options,\n            params: preparedOptions,\n          });\n        }),\n        TE.mapBoth(\n          err => {\n            toggleClosed();\n            return err;\n          },\n          response => {\n            toggleClosed();\n            return response.button_id;\n          },\n        ),\n      );\n    });\n    this.show = throwifyWithChecksFp(this.showFp);\n  }\n\n  /**\n   * Signal indicating if any popup is currently opened.\n   */\n  readonly isOpened: Computed<boolean>;\n\n  /**\n   * Signal indicating if the component is supported.\n   */\n  readonly isSupported: Computed<boolean>;\n\n  /**\n   * A method that shows a native popup described by the `params` argument.\n   * The promise will be resolved when the popup is closed. Resolved value will have\n   * an identifier of the pressed button.\n   *\n   * If a user clicked outside the popup or clicked the top right popup close\n   * button, null will be resolved.\n   *\n   * @param options - popup parameters.\n   * @since Mini Apps v6.2\n   * @example\n   * pipe(\n   *   popup.showFp({\n   *     title: 'Confirm action',\n   *     message: 'Do you really want to buy this burger?',\n   *     buttons: [\n   *       { id: 'yes', text: 'Yes' },\n   *       { id: 'no', type: 'destructive', text: 'No' },\n   *     ],\n   *   }),\n   *   TE.map(buttonId => {\n   *     console.log('User clicked a button with ID', buttonId);\n   *   }),\n   * );\n   */\n  readonly showFp: WithChecksFp<\n    (options: ShowOptions) => TE.TaskEither<\n      RequestError | InvalidArgumentsError | ConcurrentCallError,\n      string | undefined\n    >,\n    true\n  >;\n\n  /**\n   * @see showFp\n   */\n  readonly show: WithChecks<(options: ShowOptions) => BetterPromise<string | undefined>, true>;\n}\n","import { pipe } from 'fp-ts/function';\n\nimport { Popup } from '@/features/Popup/Popup.js';\nimport { sharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport { withRequest } from '@/fn-options/withRequest.js';\nimport { withVersion } from '@/fn-options/withVersion.js';\n\nexport const popup = new Popup(pipe(sharedFeatureOptions(), withRequest, withVersion));\n","import type { PhoneRequestedStatus, RequestError } from '@tma.js/bridge';\nimport * as TE from 'fp-ts/TaskEither';\nimport { pipe } from 'fp-ts/function';\n\nimport {\n  sharedFeatureOptions,\n  type SharedFeatureOptions,\n} from '@/fn-options/sharedFeatureOptions.js';\nimport { withRequest, type WithRequest } from '@/fn-options/withRequest.js';\nimport { withVersion, type WithVersion } from '@/fn-options/withVersion.js';\nimport type { AsyncOptions } from '@/types.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport { withChecksFp } from '@/with-checks/withChecksFp.js';\n\ninterface CreateOptions extends SharedFeatureOptions, WithRequest, WithVersion {\n}\n\nexport type RequestPhoneAccessError = RequestError;\n\nfunction create({ request, ...rest }: CreateOptions) {\n  return withChecksFp((\n    options?: AsyncOptions,\n  ): TE.TaskEither<RequestPhoneAccessError, PhoneRequestedStatus> => {\n    return pipe(\n      request('web_app_request_phone', 'phone_requested', options),\n      TE.map(response => response.status),\n    );\n  }, { ...rest, requires: 'web_app_request_phone', returns: 'task' });\n}\n\n/**\n * Requests current user phone access. Method returns promise, which resolves\n * status of the request. In case, user accepted the request, Mini App bot will receive\n * the according notification.\n *\n * To obtain the retrieved information instead, utilize the `requestContact` method.\n * @param options - additional options.\n * @since Mini Apps v6.9\n * @see requestContact\n */\nexport const requestPhoneAccessFp = create(pipe(\n  sharedFeatureOptions(),\n  withVersion,\n  withRequest,\n));\n\n/**\n * @see requestPhoneAccessFp\n */\nexport const requestPhoneAccess = throwifyWithChecksFp(requestPhoneAccessFp);\n","import { PhoneRequestedStatus } from '@tma.js/bridge';\nimport { BetterTaskEither, type BetterTaskEitherError } from '@tma.js/toolkit';\nimport { pipeJsonToSchema, pipeQueryToSchema } from '@tma.js/transformers';\nimport * as E from 'fp-ts/Either';\nimport * as TE from 'fp-ts/TaskEither';\nimport { pipe } from 'fp-ts/function';\nimport {\n  safeParse,\n  pipe as valiPipe,\n  date,\n  looseObject,\n  number,\n  optional,\n  string,\n  transform,\n} from 'valibot';\n\nimport { AccessDeniedError, ValidationError } from '@/errors.js';\nimport {\n  sharedFeatureOptions,\n  type SharedFeatureOptions,\n} from '@/fn-options/sharedFeatureOptions.js';\n\nimport {\n  withInvokeCustomMethod,\n  type WithInvokeCustomMethod,\n  InvokeCustomMethodError,\n} from '@/fn-options/withInvokeCustomMethod.js';\n\nimport { withVersion, type WithVersion } from '@/fn-options/withVersion.js';\nimport type { AsyncOptions } from '@/types.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\n\nimport { withChecksFp } from '@/with-checks/withChecksFp.js';\n\nimport { type RequestPhoneAccessError, requestPhoneAccessFp } from './requestPhoneAccess.js';\n\n/**\n * Requested contact information.\n */\nexport interface RequestedContact {\n  contact: {\n    user_id: number;\n    phone_number: string;\n    first_name: string;\n    last_name?: string;\n    [key: string]: unknown;\n  };\n  auth_date: Date;\n  hash: string;\n  [key: string]: unknown;\n}\n\n/**\n * Requested contact complete data.\n */\nexport interface RequestedContactCompleteData {\n  /**\n   * Raw original representation of the contact data returned from the Telegram server.\n   */\n  raw: string;\n  /**\n   * Parsed representation of the contact data.\n   */\n  parsed: RequestedContact;\n}\n\ninterface CreateCompleteOptions extends SharedFeatureOptions, WithInvokeCustomMethod, WithVersion {\n  requestPhoneAccess: (options?: AsyncOptions) => (\n    TE.TaskEither<RequestPhoneAccessError, PhoneRequestedStatus>\n  );\n}\n\ninterface CreateParsedOptions extends SharedFeatureOptions, WithVersion {\n  requestContact: (options?: AsyncOptions) => TE.TaskEither<RequestContactError, RequestedContact>;\n}\n\nexport type RequestContactError =\n  | InvokeCustomMethodError\n  | AccessDeniedError\n  | ValidationError\n  | BetterTaskEitherError;\n\nfunction createComplete({\n  invokeCustomMethod,\n  requestPhoneAccess,\n  ...rest\n}: CreateCompleteOptions) {\n  type GetRequestedContactError = InvokeCustomMethodError | ValidationError;\n\n  // Attempts to get previously requested contact.\n  const getContact = (\n    options?: AsyncOptions,\n  ): TE.TaskEither<GetRequestedContactError, RequestedContactCompleteData | undefined> => {\n    return pipe(\n      invokeCustomMethod('getRequestedContact', {}, {\n        ...options,\n        timeout: (options || {}).timeout || 5000,\n      }),\n      TE.chainW(response => {\n        const toStringResult = safeParse(string(), response);\n        if (!toStringResult.success) {\n          return TE.left(new ValidationError(response, toStringResult.issues));\n        }\n\n        if (!toStringResult.output) {\n          return TE.right(undefined);\n        }\n\n        const toParsedResult = safeParse(\n          pipeQueryToSchema(\n            looseObject({\n              contact: pipeJsonToSchema(looseObject({\n                user_id: number(),\n                phone_number: string(),\n                first_name: string(),\n                last_name: optional(string()),\n              })),\n              auth_date: valiPipe(\n                string(),\n                transform(input => new Date(Number(input) * 1000)),\n                date(),\n              ),\n              hash: string(),\n            }),\n          ),\n          toStringResult.output,\n        );\n        return toParsedResult.success\n          ? TE.right({ raw: toStringResult.output, parsed: toParsedResult.output })\n          : TE.left(new ValidationError(toStringResult.output, toParsedResult.issues));\n      }),\n    );\n  };\n\n  // Attempts to get previously requested contact, but ignores all errors except validation error.\n  const getContactWithErrorsIgnore = (\n    options?: AsyncOptions,\n  ): TE.TaskEither<ValidationError, RequestedContactCompleteData | undefined> => {\n    return pipe(\n      getContact(options),\n      TE.match(\n        // All other errors except validation ones should be ignored. Receiving validation error\n        // means that we have some data, but we are unable to parse it properly. So, there is no\n        // need to make some more requests further, the problem is local.\n        error => (ValidationError.is(error) ? E.left(error) : E.right(undefined)),\n        contact => E.right(contact),\n      ),\n    );\n  };\n\n  // Polls previously requested contact with increasing timeout between requests.\n  const pollContact = (ctx: {\n    isRejected: boolean;\n    rejectReason: unknown;\n    abortSignal: AbortSignal;\n  }): TE.TaskEither<BetterTaskEitherError | ValidationError, RequestedContactCompleteData> => {\n    return BetterTaskEither<ValidationError, RequestedContactCompleteData>(\n      async (res, rej, context) => {\n        // Time to wait before executing the next request.\n        let sleepTime = 50;\n\n        // We are trying to retrieve the requested contact until the deadline was reached.\n        while (!context.isRejected) {\n          const result = await getContactWithErrorsIgnore(context)();\n          if (result._tag === 'Left') {\n            return rej(result.left);\n          }\n          if (result.right) {\n            return res(result.right);\n          }\n          await new Promise(resolve => setTimeout(resolve, sleepTime));\n          sleepTime += 50;\n        }\n      },\n      ctx,\n    );\n  };\n\n  return withChecksFp((\n    options?: AsyncOptions,\n  ): TE.TaskEither<RequestContactError, RequestedContactCompleteData> => {\n    return BetterTaskEither.fn(context => {\n      return pipe(\n        // Try to get the requested contact. Probably, we already requested it before.\n        getContactWithErrorsIgnore(context),\n        TE.chain(contact => {\n          if (contact) {\n            return TE.right(contact);\n          }\n          return pipe(\n            requestPhoneAccess(context),\n            TE.chainW(status => {\n              return status === 'sent'\n                ? pollContact(context)\n                : TE.left(new AccessDeniedError('User denied access'));\n            }),\n          );\n        }),\n      );\n    }, options);\n  }, { ...rest, returns: 'task', requires: 'web_app_request_phone' });\n}\n\nfunction createParsed({ requestContact, ...rest }: CreateParsedOptions) {\n  return withChecksFp(\n    requestContact,\n    { ...rest, returns: 'task', requires: 'web_app_request_phone' },\n  );\n}\n\n/**\n * Requests current user contact information.\n *\n * This function returns an object, containing both raw and parsed representations of a response,\n * received from the Telegram client.\n * @param options - additional options.\n * @since Mini Apps v6.9\n */\nexport const requestContactCompleteFp = createComplete({\n  ...pipe(sharedFeatureOptions(), withInvokeCustomMethod, withVersion),\n  requestPhoneAccess: requestPhoneAccessFp,\n});\n\n/**\n * @see requestContactCompleteFp\n */\nexport const requestContactComplete = throwifyWithChecksFp(requestContactCompleteFp);\n\n/**\n * Works the same way as the `requestContactCompleteFp` function, but returns only parsed\n * representation of the contact data.\n * @see requestContactCompleteFp\n * @param options - additional options.\n * @since Mini Apps v6.9\n */\nexport const requestContactFp = createParsed({\n  ...pipe(sharedFeatureOptions(), withVersion),\n  requestContact(options) {\n    return pipe(\n      requestContactCompleteFp(options),\n      TE.map(contact => contact.parsed),\n    );\n  },\n});\n\n/**\n * @see requestContactFp\n */\nexport const requestContact = throwifyWithChecksFp(requestContactFp);\n","import type { WriteAccessRequestedStatus, RequestError } from '@tma.js/bridge';\nimport * as TE from 'fp-ts/TaskEither';\nimport { pipe } from 'fp-ts/function';\n\nimport {\n  sharedFeatureOptions,\n  type SharedFeatureOptions,\n} from '@/fn-options/sharedFeatureOptions.js';\nimport { withRequest, type WithRequest } from '@/fn-options/withRequest.js';\nimport { withVersion, type WithVersion } from '@/fn-options/withVersion.js';\nimport type { AsyncOptions } from '@/types.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport { withChecksFp } from '@/with-checks/withChecksFp.js';\n\ninterface CreateOptions extends SharedFeatureOptions, WithRequest, WithVersion {\n}\n\nexport type RequestWriteAccessError = RequestError;\n\nfunction create({ request, ...rest }: CreateOptions) {\n  return withChecksFp((\n    options?: AsyncOptions,\n  ): TE.TaskEither<RequestWriteAccessError, WriteAccessRequestedStatus> => {\n    return pipe(\n      request('web_app_request_write_access', 'write_access_requested', options),\n      TE.map(response => response.status),\n    );\n  }, { ...rest, requires: 'web_app_request_write_access', returns: 'task' });\n}\n\n/**\n * Requests write message access to the current user.\n * @param options - additional options.\n * @since Mini Apps v6.9\n */\nexport const requestWriteAccessFp = create(pipe(\n  sharedFeatureOptions(),\n  withVersion,\n  withRequest,\n));\n\n/**\n * @see requestWriteAccessFp\n */\nexport const requestWriteAccess = throwifyWithChecksFp(requestWriteAccessFp);\n","import type { PostEventError } from '@tma.js/bridge';\nimport { computed, type Computed, signal } from '@tma.js/signals';\nimport { createCbCollector, BetterTaskEither, type BetterTaskEitherError } from '@tma.js/toolkit';\nimport { BetterPromise } from 'better-promises';\nimport * as E from 'fp-ts/Either';\nimport * as TE from 'fp-ts/TaskEither';\nimport { pipe } from 'fp-ts/function';\n\nimport { ConcurrentCallError } from '@/errors.js';\nimport type { SharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport type { WithPostEvent } from '@/fn-options/withPostEvent.js';\nimport type { WithVersion } from '@/fn-options/withVersion.js';\nimport { createIsSupportedSignal } from '@/helpers/createIsSupportedSignal.js';\nimport type { AsyncOptions } from '@/types.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport {\n  createWithChecksFp,\n  type WithChecks,\n  type WithChecksFp,\n} from '@/with-checks/withChecksFp.js';\n\nexport interface QrScannerOptions extends WithVersion, WithPostEvent, SharedFeatureOptions {\n  /**\n   * A function to add a listener to the event determining if the QR scanner\n   * was closed.\n   * @param listener - a listener to add.\n   * @returns A function to remove the listener.\n   */\n  onClosed: (listener: VoidFunction) => VoidFunction;\n  /**\n   * A function to add a listener to the event containing a scanned QR content.\n   * @param listener - a listener to add.\n   * @returns A function to remove the listener.\n   */\n  onTextReceived: (listener: (data: string) => void) => VoidFunction;\n}\n\ninterface SharedOptions extends AsyncOptions {\n  /**\n   * Title to be displayed in the scanner.\n   */\n  text?: string;\n}\n\ninterface CaptureOptions extends SharedOptions {\n  /**\n   * @returns True if the passed QR code should be captured.\n   * @param qr - scanned QR content.\n   */\n  capture: (qr: string) => boolean;\n}\n\ninterface OpenOptions extends SharedOptions {\n  /**\n   * Function which will be called if a QR code was scanned.\n   * @param qr - scanned QR content.\n   */\n  onCaptured: (qr: string) => void;\n}\n\n/**\n * @since Mini Apps v6.4\n */\nexport class QrScanner {\n  constructor({\n    version,\n    onClosed,\n    onTextReceived,\n    isTma,\n    postEvent,\n  }: QrScannerOptions) {\n    const wrapOptions = { version, requires: 'web_app_open_scan_qr_popup', isTma } as const;\n    const wrapSupportedEither = createWithChecksFp({ ...wrapOptions, returns: 'either' });\n    const wrapSupportedTask = createWithChecksFp({ ...wrapOptions, returns: 'task' });\n\n    const isOpened = signal(false);\n    const setClosed = () => {\n      isOpened.set(false);\n    };\n\n    this.isSupported = createIsSupportedSignal('web_app_open_scan_qr_popup', version);\n    this.isOpened = computed(isOpened);\n\n    this.captureFp = wrapSupportedTask(options => {\n      let captured: string | undefined;\n      return pipe(\n        this.openFp({\n          ...options,\n          onCaptured: qr => {\n            if (options.capture(qr)) {\n              captured = qr;\n              this.close();\n            }\n          },\n        }),\n        TE.map(() => captured),\n      );\n    });\n    this.closeFp = wrapSupportedEither(() => {\n      return pipe(postEvent('web_app_close_scan_qr_popup'), E.map(setClosed));\n    });\n    this.openFp = wrapSupportedTask(options => {\n      return pipe(\n        isOpened()\n          ? TE.left(new ConcurrentCallError('The QR Scanner is already opened'))\n          : async () => postEvent('web_app_open_scan_qr_popup', { text: options.text }),\n        TE.chainW(() => {\n          isOpened.set(true);\n          const [addToCleanup, cleanup] = createCbCollector();\n          const onSettled = <T>(value: T): T => {\n            cleanup();\n            isOpened.set(false);\n            return value;\n          };\n\n          return pipe(\n            BetterTaskEither<never, void>(resolve => {\n              addToCleanup(\n                // The scanner was closed externally.\n                onClosed(resolve),\n                // The scanner was closed internally.\n                isOpened.sub(isOpenedValue => {\n                  if (!isOpenedValue) {\n                    resolve();\n                  }\n                }),\n                onTextReceived(options.onCaptured),\n              );\n            }, options),\n            TE.mapBoth(onSettled, onSettled),\n          );\n        }),\n      );\n    });\n\n    this.open = throwifyWithChecksFp(this.openFp);\n    this.capture = throwifyWithChecksFp(this.captureFp);\n    this.close = throwifyWithChecksFp(this.closeFp);\n  }\n\n  /**\n   * Signal indicating if the scanner is currently opened.\n   */\n  readonly isOpened: Computed<boolean>;\n\n  /**\n   * Signal indicating if the component is supported.\n   */\n  readonly isSupported: Computed<boolean>;\n\n  /**\n   * Opens the scanner and returns a task which will be completed with the QR content if the\n   * passed `capture` function returned true.\n   *\n   * Task may also be completed with undefined if the scanner was closed.\n   * @param options - method options.\n   * @returns A promise with QR content presented as string or undefined if the scanner was closed.\n   * @since Mini Apps v6.4\n   * @example\n   * pipe(\n   *   qrScanner.captureFp({\n   *     capture(scannedQr) {\n   *       return scannedQr === 'any expected by me qr';\n   *     }\n   *   }),\n   *   TE.match(\n   *     error => {\n   *       console.error(error);\n   *     },\n   *     qr => {\n   *       console.log('My QR:'), qr;\n   *     }\n   *   ),\n   * );\n   */\n  readonly captureFp: WithChecksFp<\n    (options: CaptureOptions) => (\n      TE.TaskEither<PostEventError | BetterTaskEitherError, string | undefined>\n    ),\n    true\n  >;\n\n  /**\n   * @see captureFp\n   */\n  readonly capture: WithChecks<\n    (options: CaptureOptions) => BetterPromise<string | undefined>,\n    true\n  >;\n\n  /**\n   * Closes the scanner.\n   * @since Mini Apps v6.4\n   */\n  readonly closeFp: WithChecksFp<() => E.Either<PostEventError, void>, true>;\n\n  /**\n   * @see close\n   */\n  readonly close: WithChecks<() => void, true>;\n\n  /**\n   * Opens the scanner and returns a task which will be completed when the scanner was closed.\n   * @param options - method options.\n   * @since Mini Apps v6.4\n   * @example Without `capture` option\n   * if (qrScanner.open.isAvailable()) {\n   *   const qr = await qrScanner.open({ text: 'Scan any QR' });\n   * }\n   * @example\n   * pipe(\n   *   qrScanner.openFp({\n   *     onCaptured(scannedQr) {\n   *       if (scannedQr === 'any expected by me qr') {\n   *         qrScanner.close();\n   *       }\n   *     }\n   *   }),\n   *   TE.match(\n   *     error => {\n   *       console.error(error);\n   *     },\n   *     () => {\n   *       console.log('The scanner was closed');\n   *     }\n   *   ),\n   * );\n   */\n  readonly openFp: WithChecksFp<\n    (options: OpenOptions) => TE.TaskEither<PostEventError, void>,\n    true\n  >;\n\n  /**\n   * @see openFp\n   */\n  readonly open: WithChecks<(options: OpenOptions) => BetterPromise<void>, true>;\n}\n","import { on } from '@tma.js/bridge';\n\nimport { pipe } from 'fp-ts/function';\n\nimport { QrScanner } from '@/features/QrScanner/QrScanner.js';\nimport { sharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport { withPostEvent } from '@/fn-options/withPostEvent.js';\nimport { withVersion } from '@/fn-options/withVersion.js';\n\nexport const qrScanner = new QrScanner({\n  ...pipe(sharedFeatureOptions(), withPostEvent, withVersion),\n  onClosed(listener) {\n    return on('scan_qr_popup_closed', listener);\n  },\n  onTextReceived(listener) {\n    return on('qr_text_received', event => {\n      listener(event.data);\n    });\n  },\n});\n","import type { PostEventError, SecondaryButtonPosition } from '@tma.js/bridge';\nimport { computed, type Computed } from '@tma.js/signals';\nimport type { RGB } from '@tma.js/types';\nimport * as E from 'fp-ts/Either';\n\nimport { Button, type ButtonOptions } from '@/composables/Button.js';\nimport { access } from '@/helpers/access.js';\nimport { createIsSupportedSignal } from '@/helpers/createIsSupportedSignal.js';\nimport type { MaybeAccessor } from '@/types.js';\nimport type { WithChecks, WithChecksFp } from '@/with-checks/withChecksFp.js';\n\ntype SecondaryButtonEither = E.Either<PostEventError, void>;\n\nexport interface SecondaryButtonState {\n  isVisible: boolean;\n  bgColor?: RGB;\n  hasShineEffect: boolean;\n  isEnabled: boolean;\n  isLoaderVisible: boolean;\n  text: string;\n  textColor?: RGB;\n  position: SecondaryButtonPosition;\n}\n\nexport interface SecondaryButtonOptions extends Omit<\n  ButtonOptions<SecondaryButtonState, 'web_app_setup_secondary_button'>,\n  'initialState' | 'method' | 'payload'\n> {\n  /**\n   * Default values for different kinds of the button properties.\n   */\n  defaults: {\n    bgColor: MaybeAccessor<RGB>;\n    textColor: MaybeAccessor<RGB>;\n  };\n}\n\n/**\n * @since Mini Apps v7.10\n */\nexport class SecondaryButton {\n  constructor({ defaults, ...options }: SecondaryButtonOptions) {\n    const button = new Button({\n      ...options,\n      initialState: {\n        hasShineEffect: false,\n        isEnabled: true,\n        isLoaderVisible: false,\n        isVisible: false,\n        text: 'Cancel',\n        position: 'left',\n      },\n      method: 'web_app_setup_secondary_button',\n      payload: state => ({\n        has_shine_effect: state.hasShineEffect,\n        is_visible: state.isVisible,\n        is_active: state.isEnabled,\n        is_progress_visible: state.isLoaderVisible,\n        text: state.text,\n        color: state.bgColor,\n        text_color: state.textColor,\n        position: state.position,\n      }),\n    });\n\n    const withDefault = (\n      field: 'bgColor' | 'textColor',\n      getDefault: MaybeAccessor<RGB>,\n    ) => {\n      const fromState = button.stateGetter(field);\n      return computed(() => fromState() || access(getDefault));\n    };\n\n    this.isSupported = createIsSupportedSignal('web_app_setup_secondary_button', options.version);\n    this.bgColor = withDefault('bgColor', defaults.bgColor);\n    this.textColor = withDefault('textColor', defaults.textColor);\n    this.position = button.stateGetter('position');\n    this.hasShineEffect = button.stateGetter('hasShineEffect');\n    this.isEnabled = button.stateGetter('isEnabled');\n    this.isLoaderVisible = button.stateGetter('isLoaderVisible');\n    this.text = button.stateGetter('text');\n    this.isVisible = button.stateGetter('isVisible');\n    this.isMounted = button.isMounted;\n    this.state = button.state;\n\n    [this.setPosition, this.setPositionFp] = button.stateSetters('position');\n    [this.setBgColor, this.setBgColorFp] = button.stateSetters('bgColor');\n    [this.setTextColor, this.setTextColorFp] = button.stateSetters('textColor');\n    [\n      [this.disableShineEffect, this.disableShineEffectFp],\n      [this.enableShineEffect, this.enableShineEffectFp],\n    ] = button.stateBoolSetters('hasShineEffect');\n    [\n      [this.disable, this.disableFp],\n      [this.enable, this.enableFp],\n    ] = button.stateBoolSetters('isEnabled');\n    [\n      [this.hideLoader, this.hideLoaderFp],\n      [this.showLoader, this.showLoaderFp],\n    ] = button.stateBoolSetters('isLoaderVisible');\n\n    [this.setText, this.setTextFp] = button.stateSetters('text');\n    [[this.hide, this.hideFp], [this.show, this.showFp]] = button.stateBoolSetters('isVisible');\n    this.setParams = button.setState;\n    this.setParamsFp = button.setStateFp;\n    this.onClick = button.onClick;\n    this.onClickFp = button.onClickFp;\n    this.offClick = button.offClick;\n    this.offClickFp = button.offClickFp;\n    this.mount = button.mount;\n    this.mountFp = button.mountFp;\n    this.unmount = button.unmount;\n  }\n\n  //#region Properties.\n  /**\n   * Signal indicating if the component is supported.\n   */\n  readonly isSupported: Computed<boolean>;\n\n  /**\n   * The button position relative to the main one.\n   */\n  readonly position: Computed<SecondaryButtonPosition>;\n\n  /**\n   * The button background color.\n   */\n  readonly bgColor: Computed<RGB>;\n\n  /**\n   * True if the button has a shining effect.\n   */\n  readonly hasShineEffect: Computed<boolean>;\n\n  /**\n   * True if the button is clickable.\n   */\n  readonly isEnabled: Computed<boolean>;\n\n  /**\n   * True if the button loader is visible.\n   */\n  readonly isLoaderVisible: Computed<boolean>;\n\n  /**\n   * True if the button is visible.\n   */\n  readonly isVisible: Computed<boolean>;\n\n  /**\n   * Signal indicating if the component is currently mounted.\n   */\n  readonly isMounted: Computed<boolean>;\n\n  /**\n   * The complete button state.\n   */\n  readonly state: Computed<SecondaryButtonState>;\n\n  /**\n   * The button displayed text.\n   */\n  readonly text: Computed<string>;\n\n  /**\n   * The button text color.\n   *\n   * Note that this value is computed based on the external defaults. For\n   * example, if not explicitly set, this value may be equal to one of theme\n   * params colors.\n   */\n  readonly textColor: Computed<RGB>;\n  //#endregion\n\n  //#region Methods.\n  /**\n   * Shows the button.\n   * @since Mini Apps v7.10\n   */\n  readonly showFp: WithChecksFp<() => SecondaryButtonEither, true>;\n\n  /**\n   * @see showFp\n   */\n  readonly show: WithChecks<() => void, true>;\n\n  /**\n   * Hides the button.\n   * @since Mini Apps v7.10\n   */\n  readonly hideFp: WithChecksFp<() => SecondaryButtonEither, true>;\n\n  /**\n   * @see hideFp\n   */\n  readonly hide: WithChecks<() => void, true>;\n\n  /**\n   * Enables the button.\n   * @since Mini Apps v7.10\n   */\n  readonly enableFp: WithChecksFp<() => SecondaryButtonEither, true>;\n\n  /**\n   * @see enableFp\n   */\n  readonly enable: WithChecks<() => void, true>;\n\n  /**\n   * Enables the button.\n   * @since Mini Apps v7.10\n   */\n  readonly enableShineEffectFp: WithChecksFp<() => SecondaryButtonEither, true>;\n\n  /**\n   * @see enableShineEffectFp\n   */\n  readonly enableShineEffect: WithChecks<() => void, true>;\n\n  /**\n   * Disables the button.\n   * @since Mini Apps v7.10\n   */\n  readonly disableFp: WithChecksFp<() => SecondaryButtonEither, true>;\n\n  /**\n   * @see disableFp\n   */\n  readonly disable: WithChecks<() => void, true>;\n\n  /**\n   * Enables the button.\n   * @since Mini Apps v7.10\n   */\n  readonly disableShineEffectFp: WithChecksFp<() => SecondaryButtonEither, true>;\n\n  /**\n   * @see disableShineEffectFp\n   */\n  readonly disableShineEffect: WithChecks<() => void, true>;\n\n  /**\n   * Updates the button background color.\n   * @since Mini Apps v7.10\n   */\n  readonly setBgColorFp: WithChecksFp<(value: RGB) => SecondaryButtonEither, true>;\n\n  /**\n   * @see setBgColorFp\n   */\n  readonly setBgColor: WithChecks<(value: RGB) => void, true>;\n\n  /**\n   * Updates the button text color.\n   * @since Mini Apps v7.10\n   */\n  readonly setTextColorFp: WithChecksFp<(value: RGB) => SecondaryButtonEither, true>;\n\n  /**\n   * @see setTextColorFp\n   */\n  readonly setTextColor: WithChecks<(value: RGB) => void, true>;\n\n  /**\n   * Updates the button text.\n   * @since Mini Apps v7.10\n   */\n  readonly setTextFp: WithChecksFp<(value: string) => SecondaryButtonEither, true>;\n\n  /**\n   * @see setTextFp\n   */\n  readonly setText: WithChecks<(value: string) => void, true>;\n\n  /**\n   * Updates the button position.\n   * @since Mini Apps v7.10\n   */\n  readonly setPositionFp: WithChecksFp<\n    (position: SecondaryButtonPosition) => SecondaryButtonEither,\n    true\n  >;\n\n  /**\n   * @see setPositionFp\n   */\n  readonly setPosition: WithChecks<(position: SecondaryButtonPosition) => void, true>;\n\n  /**\n   * Shows the button loader.\n   * @since Mini Apps v7.10\n   */\n  readonly showLoaderFp: WithChecksFp<() => SecondaryButtonEither, true>;\n\n  /**\n   * @see showLoaderFp\n   */\n  readonly showLoader: WithChecks<() => void, true>;\n\n  /**\n   * Hides the button loader.\n   * @since Mini Apps v7.10\n   */\n  readonly hideLoaderFp: WithChecksFp<() => SecondaryButtonEither, true>;\n\n  /**\n   * @see hideLoaderFp\n   */\n  readonly hideLoader: WithChecks<() => void, true>;\n\n  /**\n   * Updates the button state.\n   * @param state - updates to apply.\n   * @since Mini Apps v7.10\n   * @example\n   * button.setParams({\n   *   text: 'Submit',\n   *   isEnabled: true,\n   *   hasShineEffect: true,\n   * });\n   */\n  readonly setParamsFp: WithChecksFp<\n    (state: Partial<SecondaryButtonState>) => SecondaryButtonEither,\n    true\n  >;\n\n  /**\n   * @see setParamsFp\n   */\n  readonly setParams: WithChecks<(state: Partial<SecondaryButtonState>) => void, true>;\n\n  /**\n   * Mounts the component restoring its state.\n   * @since Mini Apps v7.10\n   */\n  readonly mountFp: WithChecksFp<() => void, true>;\n\n  /**\n   * @see mountFp\n   */\n  readonly mount: WithChecks<() => void, true>;\n\n  /**\n   * Unmounts the component.\n   */\n  readonly unmount: () => void;\n\n  /**\n   * Adds a new button listener.\n   * @param listener - event listener.\n   * @param once - should the listener be called only once.\n   * @returns A function to remove bound listener.\n   * @since Mini Apps v7.10\n   * @example\n   * const off = button.onClick(() => {\n   *   console.log('User clicked the button');\n   *   off();\n   * });\n   */\n  readonly onClickFp: WithChecksFp<(listener: VoidFunction, once?: boolean) => VoidFunction, true>;\n\n  /**\n   * @see onClick\n   */\n  readonly onClick: WithChecks<(listener: VoidFunction, once?: boolean) => VoidFunction, true>;\n\n  /**\n   * Removes the button click listener.\n   * @param listener - event listener.\n   * @param once - should the listener be called only once.\n   * @since Mini Apps v7.10\n   * @example\n   * function listener() {\n   *   console.log('User clicked the button');\n   *   button.offClick(listener);\n   * }\n   * button.onClick(listener);\n   */\n  readonly offClickFp: WithChecksFp<(listener: VoidFunction, once?: boolean) => void, true>;\n\n  /**\n   * @see offClick\n   */\n  readonly offClick: WithChecks<(listener: VoidFunction, once?: boolean) => void, true>;\n  //#endregion\n}\n","import { computed } from '@tma.js/signals';\n\nimport { miniApp } from '@/features/MiniApp/instance.js';\nimport { SecondaryButton } from '@/features/SecondaryButton/SecondaryButton.js';\nimport { themeParams } from '@/features/ThemeParams/instance.js';\nimport { bottomButtonOptions } from '@/fn-options/bottomButtonOptions.js';\n\nexport const secondaryButton = new SecondaryButton(\n  bottomButtonOptions('secondaryButton', 'secondary_button_pressed', {\n    bgColor: computed(() => miniApp.bottomBarColorRgb() || '#000000'),\n    textColor: computed(() => themeParams.buttonColor() || '#2481cc'),\n  }),\n);\n","import { EventPayload, type MethodParams, type Request2CaptureFn, RequestError } from '@tma.js/bridge';\nimport * as TE from 'fp-ts/TaskEither';\nimport { pipe } from 'fp-ts/function';\n\nimport { SecureStorageMethodError } from '@/errors.js';\nimport type { SharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport type { WithCreateRequestId } from '@/fn-options/withCreateRequestId.js';\nimport type { WithRequest } from '@/fn-options/withRequest.js';\nimport type { WithVersion } from '@/fn-options/withVersion.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport {\n  createWithChecksFp,\n  type WithChecks,\n  type WithChecksFp,\n} from '@/with-checks/withChecksFp.js';\n\nexport type SecureStorageError = RequestError | SecureStorageMethodError;\n\nexport interface SecureStorageOptions extends SharedFeatureOptions,\n  WithVersion,\n  WithRequest,\n  WithCreateRequestId {\n}\n\n/**\n * @since Mini Apps v9.0\n */\nexport class SecureStorage {\n  constructor({ isTma, request, version, createRequestId }: SecureStorageOptions) {\n    const wrapSupportedTask = createWithChecksFp({\n      version,\n      requires: 'web_app_secure_storage_get_key',\n      isTma,\n      returns: 'task',\n    });\n\n    const invokeMethod = <\n      M extends (\n        | 'web_app_secure_storage_save_key'\n        | 'web_app_secure_storage_get_key'\n        | 'web_app_secure_storage_restore_key'\n        | 'web_app_secure_storage_save_key'\n        | 'web_app_secure_storage_clear'\n      ),\n      E extends (\n        | 'secure_storage_key_saved'\n        | 'secure_storage_key_received'\n        | 'secure_storage_key_restored'\n        | 'secure_storage_cleared'\n      ),\n    >(\n      method: M,\n      event: E,\n      params: Omit<MethodParams<M>, 'req_id'>,\n    ): TE.TaskEither<SecureStorageError, EventPayload<E>> => {\n      const requestId = createRequestId();\n      return pipe(\n        request<M, ('secure_storage_failed' | E)[]>(method, ['secure_storage_failed', event], {\n          params: { ...params, req_id: requestId },\n          capture: (event => {\n            return 'payload' in event ? event.payload.req_id === requestId : true;\n          }) as Request2CaptureFn<('secure_storage_failed' | E)[]>,\n        }),\n        TE.chain(response => (\n          response.event === 'secure_storage_failed'\n            ? TE.left(new SecureStorageMethodError(response.payload.error || 'UNKNOWN_ERROR'))\n            : TE.right(response.payload as EventPayload<E>)\n        )),\n      );\n    };\n\n    this.getItemFp = wrapSupportedTask(key => {\n      return pipe(\n        invokeMethod('web_app_secure_storage_get_key', 'secure_storage_key_received', { key }),\n        TE.map(payload => ({\n          value: payload.value,\n          canRestore: !!payload.can_restore,\n        })),\n      );\n    });\n    this.setItemFp = wrapSupportedTask((key, value) => {\n      return pipe(\n        invokeMethod('web_app_secure_storage_save_key', 'secure_storage_key_saved', { key, value }),\n        TE.map(() => undefined),\n      );\n    });\n    this.deleteItemFp = wrapSupportedTask(key => {\n      return this.setItemFp(key, null);\n    });\n    this.clearFp = wrapSupportedTask(() => {\n      return pipe(\n        invokeMethod('web_app_secure_storage_clear', 'secure_storage_cleared', {}),\n        TE.map(() => undefined),\n      );\n    });\n    this.restoreItemFp = wrapSupportedTask(key => {\n      return pipe(\n        invokeMethod('web_app_secure_storage_restore_key', 'secure_storage_key_restored', { key }),\n        TE.map(payload => payload.value),\n      );\n    });\n\n    this.getItem = throwifyWithChecksFp(this.getItemFp);\n    this.setItem = throwifyWithChecksFp(this.setItemFp);\n    this.deleteItem = throwifyWithChecksFp(this.deleteItemFp);\n    this.clear = throwifyWithChecksFp(this.clearFp);\n    this.restoreItem = throwifyWithChecksFp(this.restoreItemFp);\n  }\n\n  /**\n    * Retrieves an item using its key.\n    * @since Mini Apps v9.0\n    */\n  readonly getItemFp: WithChecksFp<\n    (key: string) => TE.TaskEither<SecureStorageError, {\n      value: string | null;\n      canRestore: boolean;\n    }>,\n    true\n  >;\n\n  /**\n   * @see getItemFp\n   */\n  readonly getItem: WithChecks<\n    (key: string) => Promise<{ value: string | null; canRestore: boolean }>,\n    true\n  >;\n\n  /**\n   * Restores an item from the storage.\n   * @since Mini Apps v9.0\n   */\n  readonly restoreItemFp: WithChecksFp<\n    (key: string) => TE.TaskEither<SecureStorageError, string | null>,\n    true\n  >;\n\n  /**\n   * @see restoreItemFp\n   */\n  readonly restoreItem: WithChecks<(key: string) => Promise<string | null>, true>;\n\n  /**\n    * Sets a new item in the storage.\n    * @since Mini Apps v9.0\n    */\n  readonly setItemFp: WithChecksFp<\n    (key: string, value: string | null) => TE.TaskEither<SecureStorageError, void>,\n    true\n  >;\n\n  /**\n   * @see setItemFp\n   */\n  readonly setItem: WithChecks<(key: string, value: string | null) => Promise<void>, true>;\n\n  /**\n    * Removes a key from the storage.\n    * @since Mini Apps v9.0\n    */\n  readonly deleteItemFp: WithChecksFp<\n    (key: string) => TE.TaskEither<SecureStorageError, void>,\n    true\n  >;\n\n  /**\n   * @see deleteItemFp\n   */\n  readonly deleteItem: WithChecks<(key: string) => Promise<void>, true>;\n\n  /**\n    * Removes all keys from the storage.\n    * @since Mini Apps v9.0\n    */\n  readonly clearFp: WithChecksFp<() => TE.TaskEither<SecureStorageError, void>, true>;\n\n  /**\n   * @see clearFp\n   */\n  readonly clear: WithChecks<() => Promise<void>, true>;\n}\n","import { pipe } from 'fp-ts/function';\n\nimport { sharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport { withCreateRequestId } from '@/fn-options/withCreateRequestId.js';\nimport { withRequest } from '@/fn-options/withRequest.js';\nimport { withVersion } from '@/fn-options/withVersion.js';\n\nimport { SecureStorage } from './SecureStorage.js';\n\nexport const secureStorage = new SecureStorage(pipe(\n  sharedFeatureOptions(),\n  withVersion,\n  withRequest,\n  withCreateRequestId,\n));\n","import type { PostEventError } from '@tma.js/bridge';\nimport type { Computed } from '@tma.js/signals';\nimport * as E from 'fp-ts/Either';\n\nimport { Button, type ButtonOptions } from '@/composables/Button.js';\nimport type { WithChecksFp, WithChecks } from '@/with-checks/withChecksFp.js';\n\nexport interface SettingsButtonState {\n  isVisible: boolean;\n}\n\nexport type SettingsButtonOptions = Omit<\n  ButtonOptions<SettingsButtonState, 'web_app_setup_settings_button'>,\n  'method' | 'payload' | 'initialState'\n>;\n\n/**\n * @since Mini Apps v6.10\n */\nexport class SettingsButton {\n  constructor(options: SettingsButtonOptions) {\n    const button = new Button({\n      ...options,\n      method: 'web_app_setup_settings_button',\n      payload: state => ({ is_visible: state.isVisible }),\n      initialState: { isVisible: false },\n    });\n\n    this.isVisible = button.stateGetter('isVisible');\n    this.isMounted = button.isMounted;\n    this.isSupported = button.isSupported;\n    [[this.hide, this.hideFp], [this.show, this.showFp]] = button.stateBoolSetters('isVisible');\n    this.onClick = button.onClick;\n    this.onClickFp = button.onClickFp;\n    this.offClick = button.offClick;\n    this.offClickFp = button.offClickFp;\n    this.mount = button.mount;\n    this.mountFp = button.mountFp;\n    this.unmount = button.unmount;\n  }\n\n  /**\n   * Signal indicating if the component is currently visible.\n   */\n  readonly isVisible: Computed<boolean>;\n\n  /**\n   * Signal indicating if the component is currently mounted.\n   */\n  readonly isMounted: Computed<boolean>;\n\n  /**\n   * Signal indicating if the component is supported.\n   */\n  readonly isSupported: Computed<boolean>;\n\n  /**\n   * Hides the button.\n   * @since Mini Apps v6.10\n   */\n  readonly hideFp: WithChecksFp<() => E.Either<PostEventError, void>, true>;\n\n  /**\n   * @see hideFp\n   */\n  readonly hide: WithChecks<() => void, true>;\n\n  /**\n   * Shows the button.\n   * @since Mini Apps v6.10\n   */\n  readonly showFp: WithChecksFp<() => E.Either<PostEventError, void>, true>;\n\n  /**\n   * @see showFp\n   */\n  readonly show: WithChecks<() => void, true>;\n\n  /**\n   * Adds a new button listener.\n   * @param listener - event listener.\n   * @param once - should the listener be called only once.\n   * @returns A function to remove bound listener.\n   * @since Mini Apps v6.10\n   * @example\n   * const off = button.onClick(() => {\n   *   console.log('User clicked the button');\n   *   off();\n   * });\n   */\n  readonly onClickFp: WithChecksFp<\n    (listener: VoidFunction, once?: boolean) => VoidFunction,\n    true\n  >;\n\n  /**\n   * @see onClickFp\n   */\n  readonly onClick: WithChecks<(listener: VoidFunction, once?: boolean) => VoidFunction, true>;\n\n  /**\n   * Removes the button click listener.\n   * @param listener - event listener.\n   * @param once - should the listener be called only once.\n   * @since Mini Apps v6.10\n   * @example\n   * function listener() {\n   *   console.log('User clicked the button');\n   *   button.offClick(listener);\n   * }\n   * button.onClick(listener);\n   */\n  readonly offClickFp: WithChecksFp<\n    (listener: VoidFunction, once?: boolean) => void,\n    true\n  >;\n\n  /**\n   * @see offClickFp\n   */\n  readonly offClick: WithChecks<(listener: VoidFunction, once?: boolean) => void, true>;\n\n  /**\n   * Mounts the component restoring its state.\n   * @since Mini Apps v6.10\n   */\n  readonly mountFp: WithChecksFp<() => void, true>;\n\n  /**\n   * @see mountFp\n   */\n  readonly mount: WithChecks<() => void, true>;\n\n  /**\n   * Unmounts the component.\n   *\n   * Note that this function does not remove listeners added via the `onClick`\n   * function, so you have to remove them on your own.\n   * @see onClick\n   */\n  readonly unmount: () => void;\n}\n","import { SettingsButton } from '@/features/SettingsButton/SettingsButton.js';\nimport { buttonOptions } from '@/fn-options/buttonOptions.js';\n\nexport const settingsButton = new SettingsButton(\n  buttonOptions('settingsButton', 'settings_button_pressed'),\n);\n","import type { PostEventError } from '@tma.js/bridge';\nimport type { Computed } from '@tma.js/signals';\nimport * as E from 'fp-ts/Either';\nimport { pipe } from 'fp-ts/function';\n\nimport { Mountable } from '@/composables/Mountable.js';\nimport { Stateful } from '@/composables/Stateful.js';\nimport type { SharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport type { WithPostEvent } from '@/fn-options/withPostEvent.js';\nimport type { WithStateRestore } from '@/fn-options/withStateRestore.js';\nimport type { WithVersion } from '@/fn-options/withVersion.js';\nimport { createIsSupportedSignal } from '@/helpers/createIsSupportedSignal.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport { createWithChecksFp, type WithChecks, type WithChecksFp } from '@/with-checks/withChecksFp.js';\n\nexport interface SwipeBehaviorState {\n  isVerticalEnabled: boolean;\n}\n\nexport interface SwipeBehaviorOptions\n  extends WithStateRestore<SwipeBehaviorState>,\n  WithVersion,\n  WithPostEvent,\n  SharedFeatureOptions {\n}\n\n/**\n * @since Mini Apps v7.7\n */\nexport class SwipeBehavior {\n  constructor({ postEvent, storage, isTma, isPageReload, version }: SwipeBehaviorOptions) {\n    const initialState = { isVerticalEnabled: true };\n    const stateful = new Stateful({\n      initialState,\n      onChange(state) {\n        storage.set(state);\n      },\n    });\n    const mountable = new Mountable({\n      initialState,\n      isPageReload,\n      onMounted: stateful.setState,\n      restoreState: storage.get,\n    });\n\n    const wrapOptions = { requires: 'web_app_setup_swipe_behavior', isTma, version } as const;\n    const wrapSupportedPlain = createWithChecksFp({\n      ...wrapOptions,\n      returns: 'plain',\n    });\n    const wrapMountedEither = createWithChecksFp({\n      ...wrapOptions,\n      isMounted: mountable.isMounted,\n      returns: 'either',\n    });\n\n    const setVerticalEnabled = (isVerticalEnabled: boolean) => {\n      const update = { isVerticalEnabled };\n      if (!stateful.hasDiff(update)) {\n        return E.right(undefined);\n      }\n      return pipe(\n        postEvent('web_app_setup_swipe_behavior', { allow_vertical_swipe: isVerticalEnabled }),\n        E.map(() => {\n          stateful.setState(update);\n        }),\n      );\n    };\n\n    this.isSupported = createIsSupportedSignal('web_app_setup_swipe_behavior', version);\n    this.isVerticalEnabled = stateful.getter('isVerticalEnabled');\n    this.isMounted = mountable.isMounted;\n    this.disableVerticalFp = wrapMountedEither(() => {\n      return setVerticalEnabled(false);\n    });\n    this.enableVerticalFp = wrapMountedEither(() => {\n      return setVerticalEnabled(true);\n    });\n    this.mountFp = wrapSupportedPlain(() => {\n      const nothing = () => undefined;\n      return pipe(mountable.mount(), E.match(nothing, nothing));\n    });\n    this.unmount = mountable.unmount;\n\n    this.disableVertical = throwifyWithChecksFp(this.disableVerticalFp);\n    this.enableVertical = throwifyWithChecksFp(this.enableVerticalFp);\n    this.mount = throwifyWithChecksFp(this.mountFp);\n  }\n\n  /**\n   * Signal indicating if the component is supported.\n   */\n  readonly isSupported: Computed<boolean>;\n\n  /**\n   * Signal indicating if vertical swipes are enabled.\n   */\n  readonly isVerticalEnabled: Computed<boolean>;\n\n  /**\n   * Signal indicating if the component is currently mounted.\n   */\n  readonly isMounted: Computed<boolean>;\n\n  /**\n   * Mounts the component restoring its state.\n   * @since Mini Apps v7.7\n   */\n  readonly mountFp: WithChecksFp<() => void, true>;\n\n  /**\n   * @see mountFp\n   */\n  readonly mount: WithChecks<() => void, true>;\n\n  /**\n   * Unmounts the component.\n   */\n  readonly unmount: () => void;\n\n  /**\n   * Disables the closing confirmation dialog.\n   * @since Mini Apps v7.7\n   */\n  readonly disableVerticalFp: WithChecksFp<() => E.Either<PostEventError, void>, true>;\n\n  /**\n   * @see disableVerticalFp\n   */\n  readonly disableVertical: WithChecks<() => void, true>;\n\n  /**\n   * Enables the closing confirmation dialog.\n   * @since Mini Apps v7.7\n   */\n  readonly enableVerticalFp: WithChecksFp<() => E.Either<PostEventError, void>, true>;\n\n  /**\n   * @see enableVerticalFp\n   */\n  readonly enableVertical: WithChecks<() => void, true>;\n}\n","import { pipe } from 'fp-ts/function';\n\nimport { SwipeBehavior, type SwipeBehaviorState } from '@/features/SwipeBehavior/SwipeBehavior.js';\nimport { sharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport { withPostEvent } from '@/fn-options/withPostEvent.js';\nimport { withStateRestore } from '@/fn-options/withStateRestore.js';\nimport { withVersion } from '@/fn-options/withVersion.js';\n\nexport const swipeBehavior = new SwipeBehavior(pipe(\n  sharedFeatureOptions(),\n  withPostEvent,\n  withVersion,\n  withStateRestore<SwipeBehaviorState>('swipeBehavior'),\n));\n","/**\n * Copies specified text to the clipboard.\n * @param text - text to copy.\n */\nexport async function copyTextToClipboard(text: string): Promise<void> {\n  try {\n    const { clipboard } = navigator;\n    if (clipboard) {\n      return await clipboard.writeText(text);\n    }\n  } catch {\n  }\n  const textArea = document.createElement('textarea');\n  textArea.value = text;\n\n  // Avoid scrolling to bottom\n  textArea.style.top = '0';\n  textArea.style.left = '0';\n  textArea.style.position = 'fixed';\n\n  document.body.appendChild(textArea);\n  textArea.focus();\n  textArea.select();\n\n  try {\n    document.execCommand('copy');\n  } finally {\n    document.body.removeChild(textArea);\n  }\n}\n","import { RequestError } from '@tma.js/bridge';\nimport * as TE from 'fp-ts/TaskEither';\nimport { pipe } from 'fp-ts/function';\n\nimport { AccessDeniedError } from '@/errors.js';\nimport {\n  sharedFeatureOptions,\n  type SharedFeatureOptions,\n} from '@/fn-options/sharedFeatureOptions.js';\nimport { withRequest, type WithRequest } from '@/fn-options/withRequest.js';\nimport { withVersion, type WithVersion } from '@/fn-options/withVersion.js';\nimport type { AsyncOptions } from '@/types.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport { withChecksFp } from '@/with-checks/withChecksFp.js';\n\ninterface CreateOptions extends SharedFeatureOptions, WithRequest, WithVersion {\n}\n\nexport type DownloadFileError = RequestError | AccessDeniedError;\n\nfunction create({ request, ...rest }: CreateOptions) {\n  return withChecksFp((\n    url: string,\n    fileName: string,\n    options?: AsyncOptions,\n  ): TE.TaskEither<DownloadFileError, void> => {\n    return pipe(\n      request(\n        'web_app_request_file_download',\n        'file_download_requested',\n        { ...options, params: { url, file_name: fileName } },\n      ),\n      TE.chain(response => {\n        return response.status === 'downloading'\n          ? TE.right(undefined)\n          : TE.left(new AccessDeniedError('User denied the action'));\n      }),\n    );\n  }, { ...rest, requires: 'web_app_request_file_download', returns: 'task' });\n}\n\n/**\n * Displays a native popup prompting the user to download a file.\n * @param url - the HTTPS URL of the file to be downloaded.\n * @param file - the suggested name for the downloaded file.\n * @param options - additional request execution options.\n * @since Mini Apps v8.0\n * @example\n * pipe(\n *   downloadFileFp('https://telegram.org/js/telegram-web-app.js', 'telegram-sdk.js'),\n *   TE.map(() => {\n *     console.log('Downloading');\n *   })\n * )\n */\nexport const downloadFileFp = create(pipe(\n  sharedFeatureOptions(),\n  withRequest,\n  withVersion,\n));\n\nexport const downloadFile = throwifyWithChecksFp(downloadFileFp);\n","import * as TE from 'fp-ts/TaskEither';\nimport { pipe } from 'fp-ts/function';\nimport { date, integer, number, transform, pipe as valiPipe, safeParse } from 'valibot';\n\nimport { ValidationError } from '@/errors.js';\nimport {\n  type SharedFeatureOptions,\n  sharedFeatureOptions,\n} from '@/fn-options/sharedFeatureOptions.js';\nimport {\n  type WithInvokeCustomMethod,\n  withInvokeCustomMethod,\n  type InvokeCustomMethodError,\n} from '@/fn-options/withInvokeCustomMethod.js';\nimport { type WithVersion, withVersion } from '@/fn-options/withVersion.js';\nimport type { AsyncOptions } from '@/types.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport { withChecksFp } from '@/with-checks/withChecksFp.js';\n\ninterface CreateOptions extends SharedFeatureOptions, WithInvokeCustomMethod, WithVersion {\n}\n\nexport type GetCurrentTimeError = InvokeCustomMethodError | ValidationError;\n\nfunction create({ invokeCustomMethod, ...rest }: CreateOptions) {\n  return withChecksFp((options?: AsyncOptions): TE.TaskEither<GetCurrentTimeError, Date> => {\n    return pipe(\n      invokeCustomMethod('getCurrentTime', {}, options),\n      TE.chain(response => {\n        const parsed = safeParse(\n          valiPipe(number(), integer(), transform(v => new Date(v * 1000)), date()),\n          response,\n        );\n        return parsed.success\n          ? TE.right(parsed.output)\n          : TE.left(new ValidationError(response, parsed.issues));\n      }),\n    );\n  }, { ...rest, requires: 'web_app_invoke_custom_method', returns: 'task' });\n}\n\n/**\n * @returns The current time according to the Telegram server time.\n * @param options - additional options.\n * @since Mini Apps v6.9\n */\nexport const getCurrentTimeFp = create(pipe(\n  sharedFeatureOptions(),\n  withInvokeCustomMethod,\n  withVersion,\n));\n\n/**\n * @see getCurrentTimeFp\n */\nexport const getCurrentTime = throwifyWithChecksFp(getCurrentTimeFp);\n","import type { PostEventError } from '@tma.js/bridge';\nimport * as E from 'fp-ts/Either';\nimport { pipe } from 'fp-ts/function';\n\nimport {\n  sharedFeatureOptions,\n  type SharedFeatureOptions,\n} from '@/fn-options/sharedFeatureOptions.js';\nimport { withPostEvent, type WithPostEvent } from '@/fn-options/withPostEvent.js';\nimport { withVersion, type WithVersion } from '@/fn-options/withVersion.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport { withChecksFp } from '@/with-checks/withChecksFp.js';\n\ninterface CreateOptions extends SharedFeatureOptions, WithPostEvent, WithVersion {\n}\n\nexport type HideKeyboardError = PostEventError;\n\nfunction create({ postEvent, ...rest }: CreateOptions) {\n  return withChecksFp((): E.Either<HideKeyboardError, void> => {\n    return postEvent('web_app_hide_keyboard');\n  }, { ...rest, returns: 'either', requires: 'web_app_hide_keyboard' });\n}\n\n/**\n * Hides the on-screen keyboard, if it is currently visible. Does nothing if the keyboard is\n * not active.\n * @since Mini Apps v9.1\n */\nexport const hideKeyboardFp = create(pipe(\n  sharedFeatureOptions(),\n  withPostEvent,\n  withVersion,\n));\n\n/**\n * @see hideKeyboardFp\n */\nexport const hideKeyboard = throwifyWithChecksFp(hideKeyboardFp);\n","import { captureSameReq, type RequestError } from '@tma.js/bridge';\nimport * as TE from 'fp-ts/TaskEither';\nimport { pipe } from 'fp-ts/function';\n\nimport {\n  sharedFeatureOptions,\n  type SharedFeatureOptions,\n} from '@/fn-options/sharedFeatureOptions.js';\nimport { withRequest, type WithRequest } from '@/fn-options/withRequest.js';\nimport { withVersion, type WithVersion } from '@/fn-options/withVersion.js';\nimport { createRequestId } from '@/globals/createRequestId.js';\nimport type { AsyncOptions } from '@/types.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport { withChecksFp } from '@/with-checks/withChecksFp.js';\n\ninterface CreateOptions extends SharedFeatureOptions, WithVersion, WithRequest {\n  createRequestId: () => string;\n}\n\nexport type ReadTextFromClipboardError = RequestError;\n\nfunction create({ request, createRequestId, ...rest }: CreateOptions) {\n  return withChecksFp((\n    options?: AsyncOptions,\n  ): TE.TaskEither<ReadTextFromClipboardError, string | null> => {\n    const reqId = createRequestId();\n    return pipe(\n      request('web_app_read_text_from_clipboard', 'clipboard_text_received', {\n        ...options,\n        params: { req_id: reqId },\n        capture: captureSameReq(reqId),\n      }),\n      TE.map(({ data = null }) => data),\n    );\n  }, { ...rest, requires: 'web_app_read_text_from_clipboard', returns: 'task' });\n}\n\n/**\n * Reads a text from the clipboard and returns a `string` or `null`. `null` is returned\n * in one of the following cases:\n * - A value in the clipboard is not a text.\n * - Access to the clipboard is not granted.\n * @since Mini Apps v6.4\n */\nexport const readTextFromClipboardFp = create({\n  ...pipe(\n    sharedFeatureOptions(),\n    withVersion,\n    withRequest,\n  ),\n  createRequestId,\n});\n\nexport const readTextFromClipboard = throwifyWithChecksFp(readTextFromClipboardFp);\n","export interface AndroidDeviceData {\n  appVersion?: string;\n  manufacturer?: string;\n  model?: string;\n  androidVersion?: string;\n  sdkVersion?: number;\n  performanceClass?: 'LOW' | 'AVERAGE' | 'HIGH' | string;\n}\n\n/**\n * Retrieves Android device data from the specified User Agent.\n * @see https://core.telegram.org/bots/webapps#additional-data-in-user-agent\n * @param userAgent - user agent.\n */\nexport function retrieveAndroidDeviceDataFrom(userAgent: string): AndroidDeviceData {\n  const result: AndroidDeviceData = {};\n  const match = userAgent.match(/Telegram-Android(?:\\/([^ ]+))?(?: (\\([^)]+\\))?|$)/);\n  if (match) {\n    const [, appVersion, systemInfo] = match;\n    appVersion && (result.appVersion = appVersion);\n    systemInfo && systemInfo\n      .slice(1, systemInfo.length - 1)\n      .split(';')\n      .forEach(item => {\n        const [key, value] = item.trim().split(' ');\n        if (key === 'Android') {\n          result.androidVersion = value;\n        } else if (key === 'SDK') {\n          const parsed = parseInt(value, 10);\n          parsed && (result.sdkVersion = parsed);\n        } else if (value) {\n          result.manufacturer = key;\n          result.model = value;\n        } else {\n          result.performanceClass = key;\n        }\n      });\n  }\n  return result;\n}\n","import {\n  type AndroidDeviceData,\n  retrieveAndroidDeviceDataFrom,\n} from './retrieveAndroidDeviceDataFrom.js';\n\n/**\n * Retrieves Android device data from the navigator.userAgent.\n * @see https://core.telegram.org/bots/webapps#additional-data-in-user-agent\n */\nexport function retrieveAndroidDeviceData(): AndroidDeviceData {\n  return retrieveAndroidDeviceDataFrom(navigator.userAgent);\n}\n","import type { PostEventError } from '@tma.js/bridge';\nimport * as E from 'fp-ts/Either';\nimport { pipe } from 'fp-ts/function';\n\nimport { InvalidArgumentsError } from '@/errors.js';\nimport {\n  sharedFeatureOptions,\n  type SharedFeatureOptions,\n} from '@/fn-options/sharedFeatureOptions.js';\nimport { withPostEvent, type WithPostEvent } from '@/fn-options/withPostEvent.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport { withChecksFp } from '@/with-checks/withChecksFp.js';\n\ninterface CreateOptions extends SharedFeatureOptions, WithPostEvent {\n}\n\nexport type SendDataError = PostEventError | InvalidArgumentsError;\n\nfunction create({ postEvent, ...rest }: CreateOptions) {\n  return withChecksFp((data: string): E.Either<SendDataError, void> => {\n    const { size } = new Blob([data]);\n    if (!size || size > 4096) {\n      return E.left(\n        new InvalidArgumentsError(size\n          ? 'Maximum size of data to send is 4096 bytes'\n          : 'Attempted to send empty data'),\n      );\n    }\n    return postEvent('web_app_data_send', { data });\n  }, { ...rest, returns: 'either' });\n}\n\n/**\n * Sends data to the bot.\n *\n * When this method called, a service message sent to the bot containing the data of the length\n * up to 4096 bytes, and the Mini App closed.\n *\n * See the field `web_app_data` in the class [Message](https://core.telegram.org/bots/api#message).\n *\n * This method is only available for Mini Apps launched via a Keyboard button.\n * @param data - data to send to bot.\n */\nexport const sendDataFp = create(pipe(sharedFeatureOptions(), withPostEvent));\n\n/**\n * @see sendDataFp\n */\nexport const sendData = throwifyWithChecksFp(sendDataFp);\n","import { RequestError } from '@tma.js/bridge';\nimport * as TE from 'fp-ts/TaskEither';\nimport { pipe } from 'fp-ts/function';\n\nimport { ShareMessageError } from '@/errors.js';\nimport {\n  sharedFeatureOptions,\n  type SharedFeatureOptions,\n} from '@/fn-options/sharedFeatureOptions.js';\nimport { withRequest, type WithRequest } from '@/fn-options/withRequest.js';\nimport { withVersion, type WithVersion } from '@/fn-options/withVersion.js';\nimport type { AsyncOptions } from '@/types.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport { withChecksFp } from '@/with-checks/withChecksFp.js';\n\ninterface CreateOptions extends SharedFeatureOptions, WithRequest, WithVersion {\n}\n\nexport type ShareMessageFnError = RequestError | ShareMessageError;\n\nfunction create({ request, ...rest }: CreateOptions) {\n  return withChecksFp((\n    messageId: string,\n    options?: AsyncOptions,\n  ): TE.TaskEither<ShareMessageFnError, void> => {\n    return pipe(\n      request(\n        'web_app_send_prepared_message',\n        ['prepared_message_failed', 'prepared_message_sent'],\n        {\n          ...options,\n          params: { id: messageId },\n        },\n      ),\n      TE.chain(response => (\n        response.event === 'prepared_message_failed'\n          ? TE.left(new ShareMessageError(response.payload.error))\n          : TE.right(undefined)\n      )),\n    );\n  }, { ...rest, requires: 'web_app_send_prepared_message', returns: 'task' });\n}\n\n/**\n * Opens a dialog allowing the user to share a message provided by the bot.\n * @since Mini Apps v8.0\n */\nexport const shareMessageFp = create(pipe(\n  sharedFeatureOptions(),\n  withRequest,\n  withVersion,\n));\n\n/**\n * @see shareMessageFp\n */\nexport const shareMessage = throwifyWithChecksFp(shareMessageFp);\n","import type { PostEventError } from '@tma.js/bridge';\nimport * as E from 'fp-ts/Either';\nimport { pipe } from 'fp-ts/function';\n\nimport {\n  sharedFeatureOptions,\n  type SharedFeatureOptions,\n} from '@/fn-options/sharedFeatureOptions.js';\nimport { withPostEvent, type WithPostEvent } from '@/fn-options/withPostEvent.js';\nimport { withVersion, type WithVersion } from '@/fn-options/withVersion.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport { withChecksFp } from '@/with-checks/withChecksFp.js';\n\ninterface CreateOptions extends SharedFeatureOptions, WithPostEvent, WithVersion {\n}\n\nexport interface ShareStoryOptions {\n  /**\n   * The caption to be added to the media.\n   * 0-200 characters for regular users and 0-2048 characters for premium subscribers.\n   * @see https://telegram.org/faq_premium#telegram-premium\n   */\n  text?: string;\n  /**\n   * An object that describes a widget link to be included in the story.\n   * Note that only premium subscribers can post stories with links.\n   * @see https://telegram.org/faq_premium#telegram-premium\n   */\n  widgetLink?: {\n    /**\n     * The URL to be included in the story.\n     */\n    url: string;\n    /**\n     * The name to be displayed for the widget link, 0-48 characters.\n     */\n    name?: string;\n  };\n}\n\nexport type ShareStoryError = PostEventError;\n\nfunction create({ postEvent, ...rest }: CreateOptions) {\n  return withChecksFp((\n    mediaUrl: string,\n    options: ShareStoryOptions = {},\n  ): E.Either<ShareStoryError, void> => {\n    return postEvent('web_app_share_to_story', {\n      text: options.text,\n      media_url: mediaUrl,\n      widget_link: options.widgetLink,\n    });\n  }, { ...rest, requires: 'web_app_share_to_story', returns: 'either' });\n}\n\n/**\n * Opens the native story editor.\n * @since Mini Apps v7.8\n * @example\n * pipe(\n *   shareStory('https://example.com/background.png', {\n *     text: 'Look at this cool group!',\n *     widgetLink: {\n *       url: 'https://t.me/heyqbnk',\n *       name: 'Vlad\\'s community',\n *     },\n *   }),\n *   TE.match(error => {\n *     console.error('Something went wrong', error);\n *   }, () => {\n *     console.log('Call was successful');\n *   }),\n * );\n */\nexport const shareStoryFp = create(pipe(\n  sharedFeatureOptions(),\n  withPostEvent,\n  withVersion,\n));\n\n/**\n * @see shareStoryFp\n */\nexport const shareStory = throwifyWithChecksFp(shareStoryFp);\n","import { createSignal } from '@/globals/signals-registry.js';\n\n/**\n * True if the application is launched in inline mode.\n */\nexport const isInlineMode = createSignal(false);\n","import type { PostEventError, SwitchInlineQueryChatType } from '@tma.js/bridge';\nimport * as E from 'fp-ts/Either';\nimport { pipe } from 'fp-ts/function';\n\nimport {\n  sharedFeatureOptions,\n  type SharedFeatureOptions,\n} from '@/fn-options/sharedFeatureOptions.js';\nimport { withPostEvent, type WithPostEvent } from '@/fn-options/withPostEvent.js';\nimport { withVersion, type WithVersion } from '@/fn-options/withVersion.js';\nimport { isInlineMode } from '@/globals/isInlineMode.js';\nimport { access } from '@/helpers/access.js';\nimport type { MaybeAccessor } from '@/types.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport { withChecksFp } from '@/with-checks/withChecksFp.js';\n\ninterface CreateOptions extends SharedFeatureOptions, WithPostEvent, WithVersion {\n  isInlineMode: MaybeAccessor<boolean>;\n}\n\nexport type SwitchInlineQueryError = PostEventError;\n\nfunction create({ isInlineMode, postEvent, ...rest }: CreateOptions) {\n  return withChecksFp((\n    query: string,\n    chatTypes?: SwitchInlineQueryChatType[],\n  ): E.Either<SwitchInlineQueryError, void> => {\n    return postEvent('web_app_switch_inline_query', {\n      query: query,\n      chat_types: chatTypes || [],\n    });\n  }, {\n    ...rest,\n    requires: {\n      every: ['web_app_switch_inline_query', () => {\n        return access(isInlineMode)\n          ? undefined\n          : 'The application must be launched in the inline mode';\n      }],\n    },\n    returns: 'either',\n  });\n}\n\n/**\n * Inserts the bot's username and the specified inline query in the current chat's input field.\n * Query may be empty, in which case only the bot's username will be inserted. The client prompts\n * the user to choose a specific chat, then opens that chat and inserts the bot's username and\n * the specified inline query in the input field.\n * @param query - text which should be inserted in the input after the current bot name. Max\n * length is 256 symbols.\n * @param chatTypes - List of chat types which could be chosen to send the message. Could be an\n * empty list.\n * @since Mini Apps v6.7\n * @example\n * pipe(\n *   switchInlineQuery('my query goes here', ['users']),\n *   E.match(error => {\n *     console.error('Something went wrong', error);\n *   }, () => {\n *     console.log('Call was successful');\n *   }),\n * );\n */\nexport const switchInlineQueryFp = create({\n  ...pipe(\n    sharedFeatureOptions(),\n    withPostEvent,\n    withVersion,\n  ),\n  isInlineMode,\n});\n\n/**\n * @see switchInlineQueryFp\n */\nexport const switchInlineQuery = throwifyWithChecksFp(switchInlineQueryFp);\n","import {\n  type SafeAreaInsets,\n  type EventListener,\n  supports,\n  type RequestError,\n  type PostEventError,\n} from '@tma.js/bridge';\nimport { Computed, computed, signal } from '@tma.js/signals';\nimport { camelToKebab } from '@tma.js/toolkit';\nimport { BetterPromise } from 'better-promises';\nimport * as E from 'fp-ts/Either';\nimport * as TE from 'fp-ts/TaskEither';\nimport { pipe } from 'fp-ts/function';\n\nimport { AsyncMountable } from '@/composables/AsyncMountable.js';\nimport { Stateful } from '@/composables/Stateful.js';\nimport { CSSVarsBoundError, FullscreenFailedError } from '@/errors.js';\nimport { SharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport { WithPostEvent } from '@/fn-options/withPostEvent.js';\nimport { WithRequest } from '@/fn-options/withRequest.js';\nimport { WithStateRestore } from '@/fn-options/withStateRestore.js';\nimport { WithVersion } from '@/fn-options/withVersion.js';\nimport { access } from '@/helpers/access.js';\nimport { deleteCssVar, setCssVar } from '@/helpers/css-vars.js';\nimport { AsyncOptions } from '@/types.js';\nimport { throwifyWithChecksFp } from '@/with-checks/throwifyWithChecksFp.js';\nimport { createWithChecksFp, WithChecks, WithChecksFp } from '@/with-checks/withChecksFp.js';\n\ntype FullscreenError = FullscreenFailedError | RequestError;\ntype ViewportChangedEventListener = EventListener<'viewport_changed'>;\ntype FullscreenChangedEventListener = EventListener<'fullscreen_changed'>;\ntype SafeAreaInsetsChangedEventListener = EventListener<'safe_area_changed'>;\ntype SafeAreaInsetCSSVarKey = `safeAreaInset${Capitalize<keyof SafeAreaInsets>}`;\n\nexport type GetCSSVarNameKey =\n  | 'width'\n  | 'height'\n  | 'stableHeight'\n  | SafeAreaInsetCSSVarKey\n  | `content${Capitalize<SafeAreaInsetCSSVarKey>}`;\n\nexport type GetCSSVarNameFn = (key: GetCSSVarNameKey) => string | null | undefined | false;\n\nexport interface ViewportState {\n  contentSafeAreaInsets: SafeAreaInsets;\n  height: number;\n  isExpanded: boolean;\n  isFullscreen: boolean;\n  safeAreaInsets: SafeAreaInsets;\n  stableHeight: number;\n  width: number;\n}\n\ntype WithListeners<On extends string, Off extends string, L> = {\n  [K in On | Off]: (listener: L) => void;\n};\n\nexport interface ViewportOptions<EViewportStable, EFullscreen>\n  extends WithStateRestore<ViewportState>,\n  WithVersion,\n  WithRequest,\n  WithPostEvent,\n  WithListeners<'onViewportChanged', 'offViewportChanged', ViewportChangedEventListener>,\n  WithListeners<'onFullscreenChanged', 'offFullscreenChanged', FullscreenChangedEventListener>,\n  WithListeners<'onSafeAreaInsetsChanged', 'offSafeAreaInsetsChanged', SafeAreaInsetsChangedEventListener>,\n  WithListeners<'onContentSafeAreaInsetsChanged', 'offContentSafeAreaInsetsChanged', SafeAreaInsetsChangedEventListener>,\n  SharedFeatureOptions {\n  /**\n   * True if the viewport is stable.\n   */\n  isViewportStable: boolean | (() => E.Either<EViewportStable, boolean>);\n  /**\n   * True if the application was opened in fullscreen initially.\n   */\n  isFullscreen: boolean | (() => E.Either<EFullscreen, boolean>);\n}\n\nexport class Viewport<EViewportStable, EFullscreen> {\n  constructor({\n    storage,\n    isPageReload,\n    onContentSafeAreaInsetsChanged,\n    onSafeAreaInsetsChanged,\n    onViewportChanged,\n    onFullscreenChanged,\n    offContentSafeAreaInsetsChanged,\n    offFullscreenChanged,\n    offSafeAreaInsetsChanged,\n    offViewportChanged,\n    request,\n    isViewportStable,\n    isFullscreen,\n    isTma,\n    version,\n    postEvent,\n  }: ViewportOptions<EViewportStable, EFullscreen>) {\n    const initialInsets: SafeAreaInsets = { top: 0, right: 0, left: 0, bottom: 0 };\n    const stateful = new Stateful<ViewportState>({\n      initialState: {\n        contentSafeAreaInsets: initialInsets,\n        height: 0,\n        isExpanded: false,\n        isFullscreen: false,\n        safeAreaInsets: initialInsets,\n        stableHeight: 0,\n        width: 0,\n      },\n      onChange: storage.set,\n    });\n\n    const viewportChangedListener: ViewportChangedEventListener = event => {\n      stateful.setState({\n        isExpanded: event.is_expanded,\n        height: event.height,\n        width: event.width,\n        stableHeight: event.is_state_stable ? event.height : undefined,\n      });\n    };\n    const fullscreenChangedListener: FullscreenChangedEventListener = event => {\n      stateful.setState({ isFullscreen: event.is_fullscreen });\n    };\n    const safeAreaInsetsChangedListener: SafeAreaInsetsChangedEventListener = event => {\n      stateful.setState({ safeAreaInsets: event });\n    };\n    const contentSafeAreaInsetsChangedListener: SafeAreaInsetsChangedEventListener = event => {\n      stateful.setState({ contentSafeAreaInsets: event });\n    };\n\n    const mountable = new AsyncMountable({\n      initialState(options) {\n        const genRequestInsets = (kind: 'safe-area' | 'content-safe-area') => {\n          return () => {\n            const [method, event] = kind === 'safe-area'\n              ? ['web_app_request_safe_area', 'safe_area_changed'] as const\n              : ['web_app_request_content_safe_area', 'content_safe_area_changed'] as const;\n\n            if (!supports(method, access(version))) {\n              return TE.right({ top: 0, left: 0, right: 0, bottom: 0 });\n            }\n            return request(method, event, options);\n          };\n        };\n        const genFlag = <E>(flag: boolean | (() => E.Either<E, boolean>)) => {\n          return () => (\n            typeof flag === 'boolean'\n              ? TE.right(flag)\n              : TE.fromEither(flag())\n          );\n        };\n\n        return pipe(\n          TE.Do,\n          TE.bindW('safeAreaInsets', genRequestInsets('safe-area')),\n          TE.bindW('contentSafeAreaInsets', genRequestInsets('content-safe-area')),\n          TE.bindW('isFullscreen', genFlag(isFullscreen)),\n          TE.bindW('isViewportStable', genFlag(isViewportStable)),\n          TE.chainW(({ isViewportStable, ...shared }) => {\n            if (isViewportStable) {\n              return TE.right({\n                ...shared,\n                height: window.innerHeight,\n                isExpanded: true,\n                stableHeight: window.innerHeight,\n                width: window.innerWidth,\n              });\n            }\n            return pipe(\n              request('web_app_request_viewport', 'viewport_changed', options),\n              TE.map(viewport => ({\n                ...shared,\n                height: viewport.height,\n                isExpanded: viewport.is_expanded,\n                stableHeight: viewport.is_state_stable ? viewport.height : 0,\n                width: viewport.width,\n              })),\n            );\n          }),\n        );\n      },\n      isPageReload,\n      onMounted(state) {\n        onViewportChanged(viewportChangedListener);\n        onFullscreenChanged(fullscreenChangedListener);\n        onSafeAreaInsetsChanged(safeAreaInsetsChangedListener);\n        onContentSafeAreaInsetsChanged(contentSafeAreaInsetsChangedListener);\n        stateful.setState(state);\n      },\n      onUnmounted() {\n        offViewportChanged(viewportChangedListener);\n        offFullscreenChanged(fullscreenChangedListener);\n        offSafeAreaInsetsChanged(safeAreaInsetsChangedListener);\n        offContentSafeAreaInsetsChanged(contentSafeAreaInsetsChangedListener);\n      },\n      restoreState: storage.get,\n    });\n\n    const saBased = <K extends keyof SafeAreaInsets>(key: K) => {\n      return computed(() => this.safeAreaInsets()[key]);\n    };\n    const csaBased = <K extends keyof SafeAreaInsets>(key: K) => {\n      return computed(() => this.contentSafeAreaInsets()[key]);\n    };\n\n    this.state = stateful.state;\n    this.height = stateful.getter('height');\n    this.stableHeight = stateful.getter('stableHeight');\n    this.width = stateful.getter('width');\n    this.isExpanded = stateful.getter('isExpanded');\n    this.safeAreaInsets = stateful.getter('safeAreaInsets');\n    this.safeAreaInsetTop = saBased('top');\n    this.safeAreaInsetBottom = saBased('bottom');\n    this.safeAreaInsetLeft = saBased('left');\n    this.safeAreaInsetRight = saBased('right');\n    this.contentSafeAreaInsets = stateful.getter('contentSafeAreaInsets');\n    this.contentSafeAreaInsetTop = csaBased('top');\n    this.contentSafeAreaInsetBottom = csaBased('bottom');\n    this.contentSafeAreaInsetLeft = csaBased('left');\n    this.contentSafeAreaInsetRight = csaBased('right');\n\n    const wrapTask = createWithChecksFp({ isTma, returns: 'task' });\n    const wrapMountedEither = createWithChecksFp({\n      isTma,\n      returns: 'either',\n    });\n    const wrapFullscreenTask = createWithChecksFp({\n      isTma,\n      requires: 'web_app_request_fullscreen',\n      version,\n      returns: 'task',\n    });\n    const genFullscreenFn = (enable: boolean) => {\n      return wrapFullscreenTask((options?: AsyncOptions) => {\n        return pipe(\n          request(\n            enable ? 'web_app_request_fullscreen' : 'web_app_exit_fullscreen',\n            ['fullscreen_changed', 'fullscreen_failed'],\n            options,\n          ),\n          TE.chain(response => {\n            if (\n              response.event === 'fullscreen_failed'\n              && response.payload.error !== 'ALREADY_FULLSCREEN'\n            ) {\n              return TE.left(new FullscreenFailedError(response.payload.error));\n            }\n            stateful.setState({\n              isFullscreen: 'is_fullscreen' in response.payload\n                ? response.payload.is_fullscreen\n                : true,\n            });\n            return TE.right(undefined);\n          }),\n        );\n      });\n    };\n\n    // Mount.\n    this.isMounted = mountable.isMounted;\n    this.mountFp = wrapTask(mountable.mount);\n    this.mount = throwifyWithChecksFp(this.mountFp);\n\n    // Fullscreen.\n    this.isFullscreen = stateful.getter('isFullscreen');\n    this.requestFullscreenFp = genFullscreenFn(true);\n    this.requestFullscreen = throwifyWithChecksFp(this.requestFullscreenFp);\n    this.exitFullscreenFp = genFullscreenFn(false);\n    this.exitFullscreen = throwifyWithChecksFp(this.exitFullscreenFp);\n\n    // CSS vars.\n    const isCssVarsBound = signal(false);\n    this.isCssVarsBound = computed(isCssVarsBound);\n    this.bindCssVarsFp = wrapMountedEither(\n      (getCSSVarName?: GetCSSVarNameFn) => {\n        if (isCssVarsBound()) {\n          return E.left(new CSSVarsBoundError());\n        }\n        getCSSVarName ||= prop => `--tg-viewport-${camelToKebab(prop)}`;\n\n        const settings = ([\n          ['height', this.height],\n          ['stableHeight', this.stableHeight],\n          ['width', this.width],\n          ['safeAreaInsetTop', this.safeAreaInsetTop],\n          ['safeAreaInsetBottom', this.safeAreaInsetBottom],\n          ['safeAreaInsetLeft', this.safeAreaInsetLeft],\n          ['safeAreaInsetRight', this.safeAreaInsetRight],\n          ['contentSafeAreaInsetTop', this.contentSafeAreaInsetTop],\n          ['contentSafeAreaInsetBottom', this.contentSafeAreaInsetBottom],\n          ['contentSafeAreaInsetLeft', this.contentSafeAreaInsetLeft],\n          ['contentSafeAreaInsetRight', this.contentSafeAreaInsetRight],\n        ] as const).reduce<{\n          update: VoidFunction;\n          removeListener: VoidFunction;\n          cssVar: string;\n        }[]>((acc, [key, signal]) => {\n          const cssVar = getCSSVarName(key);\n          if (cssVar) {\n            const update = () => {\n              setCssVar(cssVar, `${signal()}px`);\n            };\n            acc.push({ update, removeListener: signal.sub(update), cssVar });\n          }\n          return acc;\n        }, []);\n\n        settings.forEach(setting => {\n          setting.update();\n        });\n        isCssVarsBound.set(true);\n\n        return E.right(() => {\n          settings.forEach(s => {\n            s.removeListener();\n            deleteCssVar(s.cssVar);\n          });\n          isCssVarsBound.set(false);\n        });\n      },\n    );\n    this.bindCssVars = throwifyWithChecksFp(this.bindCssVarsFp);\n\n    // Other methods.\n    this.expandFp = wrapMountedEither(() => postEvent('web_app_expand'));\n    this.expand = throwifyWithChecksFp(this.expandFp);\n  }\n\n  //#region Other properties.\n  /**\n   * Complete component state.\n   */\n  readonly state: Computed<ViewportState>;\n\n  /**\n   * Signal containing the current height of the **visible area** of the Mini App.\n   *\n   * The application can display just the top part of the Mini App, with its\n   * lower part remaining outside the screen area. From this position, the user\n   * can \"pull\" the Mini App to its maximum height, while the bot can do the same\n   * by calling `expand` method. As the position of the Mini App changes, the\n   * current height value of the visible area will be updated  in real time.\n   *\n   * Please note that the refresh rate of this value is not sufficient to\n   * smoothly follow the lower border of the window. It should not be used to pin\n   * interface elements to the bottom of the visible area. It's more appropriate\n   * to use the value of the `stableHeight` field for this purpose.\n   *\n   * @see stableHeight\n   */\n  readonly height: Computed<number>;\n\n  /**\n   * Signal containing the height of the visible area of the Mini App in its last stable state.\n   *\n   * The application can display just the top part of the Mini App, with its\n   * lower part remaining outside the screen area. From this position, the user\n   * can \"pull\" the Mini App to its maximum height, while the application can do\n   * the same by calling `expand` method.\n   *\n   * Unlike the value of `height`, the value of `stableHeight` does not change as\n   * the position of the Mini App changes with user gestures or during\n   * animations. The value of `stableHeight` will be updated after all gestures\n   * and animations are completed and the Mini App reaches its final size.\n   *\n   * @see height\n   */\n  readonly stableHeight: Computed<number>;\n\n  /**\n   * Signal containing the currently visible area width.\n   */\n  readonly width: Computed<number>;\n\n  /**\n   * Signal indicating if the Mini App is expanded to the maximum available height. Otherwise,\n   * if the Mini App occupies part of the screen and can be expanded to the full\n   * height using the `expand` method.\n   */\n  readonly isExpanded: Computed<boolean>;\n\n  /**\n   * Signal indicating if the current viewport height is stable and is not going to change in\n   * the next moment.\n   */\n  readonly isStable = computed(() => this.height() === this.stableHeight());\n  //#endregion\n\n  //#region Content safe area insets.\n  /**\n   * Signal containing content safe area insets.\n   */\n  readonly contentSafeAreaInsets: Computed<SafeAreaInsets>;\n\n  /**\n   * Signal containing top content safe area inset.\n   */\n  readonly contentSafeAreaInsetTop: Computed<number>;\n\n  /**\n   * Signal containing left content safe area inset.\n   */\n  readonly contentSafeAreaInsetLeft: Computed<number>;\n\n  /**\n   * Signal containing right content safe area inset.\n   */\n  readonly contentSafeAreaInsetRight: Computed<number>;\n\n  /**\n   * Signal containing bottom content safe area inset.\n   */\n  readonly contentSafeAreaInsetBottom: Computed<number>;\n  //#endregion\n\n  //#region Safe area insets.\n  /**\n   * Signal containing safe area insets.\n   */\n  readonly safeAreaInsets: Computed<SafeAreaInsets>;\n\n  /**\n   * Signal containing top safe area inset.\n   */\n  readonly safeAreaInsetTop: Computed<number>;\n\n  /**\n   * Signal containing left safe area inset.\n   */\n  readonly safeAreaInsetLeft: Computed<number>;\n\n  /**\n   * Signal containing right safe area inset.\n   */\n  readonly safeAreaInsetRight: Computed<number>;\n\n  /**\n   * Signal containing bottom safe area inset.\n   */\n  readonly safeAreaInsetBottom: Computed<number>;\n  //#endregion\n\n  //#region Fullscreen.\n  /**\n   * Signal indicating if the viewport is currently in fullscreen mode.\n   */\n  readonly isFullscreen: Computed<boolean>;\n\n  /**\n   * Requests fullscreen mode for the mini application.\n   * @since Mini Apps v8.0\n   */\n  readonly requestFullscreenFp: WithChecksFp<\n    (options?: AsyncOptions) => TE.TaskEither<FullscreenError, void>,\n    true\n  >;\n\n  /**\n   * @see requestFullscreenFp\n   */\n  readonly requestFullscreen: WithChecks<(options?: AsyncOptions) => BetterPromise<void>, true>;\n\n  /**\n   * Exits mini application from the fullscreen mode.\n   * @since Mini Apps v8.0\n   */\n  readonly exitFullscreenFp: WithChecksFp<\n    (options?: AsyncOptions) => TE.TaskEither<FullscreenError, void>,\n    true\n  >;\n\n  /**\n   * @see exitFullscreenFp\n   */\n  readonly exitFullscreen: WithChecks<(options?: AsyncOptions) => BetterPromise<void>, true>;\n  //#endregion\n\n  //#region CSS Vars.\n  /**\n   * Signal indicating if CSS variables are bound.\n   */\n  readonly isCssVarsBound: Computed<boolean>;\n\n  /**\n   * Creates CSS variables connected with the current viewport.\n   *\n   * By default, created CSS variables names are following the pattern \"--tg-theme-{name}\", where\n   * {name} is a viewport property name converted from camel case to kebab case.\n   *\n   * Default variables:\n   * - `--tg-viewport-height`\n   * - `--tg-viewport-width`\n   * - `--tg-viewport-stable-height`\n   * - `--tg-viewport-content-safe-area-inset-top`\n   * - `--tg-viewport-content-safe-area-inset-bottom`\n   * - `--tg-viewport-content-safe-area-inset-left`\n   * - `--tg-viewport-content-safe-area-inset-right`\n   * - `--tg-viewport-safe-area-inset-top`\n   * - `--tg-viewport-safe-area-inset-bottom`\n   * - `--tg-viewport-safe-area-inset-left`\n   * - `--tg-viewport-safe-area-inset-right`\n   *\n   * Variables are being automatically updated if the viewport was changed.\n   *\n   * @param getCSSVarName - function, returning computed complete CSS variable name. The CSS\n   * variable will only be defined if the function returned non-empty string value.\n   * @returns Function to stop updating variables.\n   * @example Using no arguments\n   * bindCssVarsFp();\n   * @example Using custom CSS vars generator\n   * bindCssVarsFp(key => `--my-prefix-${key}`);\n   */\n  readonly bindCssVarsFp: WithChecksFp<(getCSSVarName?: GetCSSVarNameFn) => (\n    E.Either<CSSVarsBoundError, VoidFunction>\n  ), false>;\n\n  /**\n   * @see bindCssVarsFp\n   */\n  readonly bindCssVars: WithChecks<(getCSSVarName?: GetCSSVarNameFn) => VoidFunction, false>;\n  //#endregion\n\n  //#region Mount.\n  /**\n   * Signal indicating if the component is currently mounted.\n   */\n  readonly isMounted: Computed<boolean>;\n\n  /**\n   * Mounts the component.\n   */\n  readonly mountFp: WithChecksFp<(options?: AsyncOptions) => (\n    TE.TaskEither<EFullscreen | EViewportStable | RequestError, void>\n  ), false>;\n\n  /**\n   * @see mountFp\n   */\n  readonly mount: WithChecks<(options?: AsyncOptions) => BetterPromise<void>, false>;\n  //#endregion\n\n  //#region Other methods.\n  /**\n   * A method that expands the Mini App to the maximum available height. To find\n   * out if the Mini App is expanded to the maximum height, refer to the value of\n   * the `isExpanded`.\n   */\n  readonly expandFp: WithChecksFp<() => E.Either<PostEventError, void>, false>;\n\n  /**\n   * @see expandFp\n   */\n  readonly expand: WithChecks<() => void, false>;\n  //#endregion\n}\n","import { retrieveLaunchParamsFp, on, off, type EventName, EventListener } from '@tma.js/bridge';\nimport * as E from 'fp-ts/Either';\nimport { pipe } from 'fp-ts/function';\n\nimport { Viewport, type ViewportState } from '@/features/Viewport/Viewport.js';\nimport { sharedFeatureOptions } from '@/fn-options/sharedFeatureOptions.js';\nimport { withPostEvent } from '@/fn-options/withPostEvent.js';\nimport { withRequest } from '@/fn-options/withRequest.js';\nimport { withStateRestore } from '@/fn-options/withStateRestore.js';\nimport { withVersion } from '@/fn-options/withVersion.js';\n\nfunction create() {\n  const createListeners = <E extends EventName>(event: E) => {\n    return {\n      on: (listener: EventListener<E>) => {\n        on(event, listener);\n      },\n      off: (listener: EventListener<E>) => {\n        off(event, listener);\n      },\n    };\n  };\n  const viewportListeners = createListeners('viewport_changed');\n  const fullscreenListeners = createListeners('fullscreen_changed');\n  const safeAreaListeners = createListeners('safe_area_changed');\n  const contentSafeAreaListeners = createListeners('content_safe_area_changed');\n\n  return new Viewport({\n    ...pipe(\n      sharedFeatureOptions(),\n      withStateRestore<ViewportState>('viewport'),\n      withVersion,\n      withPostEvent,\n      withRequest,\n    ),\n    isFullscreen() {\n      return pipe(retrieveLaunchParamsFp(), E.map(lp => !!lp.tgWebAppFullscreen));\n    },\n    isViewportStable() {\n      return pipe(retrieveLaunchParamsFp(), E.map(lp => {\n        return ['macos', 'tdesktop', 'unigram', 'webk', 'weba', 'web'].includes(lp.tgWebAppPlatform);\n      }));\n    },\n    offContentSafeAreaInsetsChanged: contentSafeAreaListeners.off,\n    offFullscreenChanged: fullscreenListeners.off,\n    offSafeAreaInsetsChanged: safeAreaListeners.off,\n    offViewportChanged: viewportListeners.off,\n    onContentSafeAreaInsetsChanged: contentSafeAreaListeners.on,\n    onFullscreenChanged: fullscreenListeners.on,\n    onSafeAreaInsetsChanged: safeAreaListeners.on,\n    onViewportChanged: viewportListeners.on,\n  });\n}\n\nexport const viewport = create();\n","import {\n  on,\n  logger,\n  retrieveLaunchParamsFp,\n  type RetrieveLaunchParamsError,\n  type PostEventError,\n  type PostEventFpFn,\n} from '@tma.js/bridge';\nimport { createCbCollector, throwifyFpFn } from '@tma.js/toolkit';\nimport type { Version, ThemeParams } from '@tma.js/types';\nimport * as E from 'fp-ts/Either';\nimport { pipe } from 'fp-ts/function';\n\nimport { isInlineMode } from '@/globals/isInlineMode.js';\nimport { postEventFpSignal, postEventFp, postEvent } from '@/globals/postEvent.js';\nimport { themeParams } from '@/globals/themeParams.js';\nimport { version } from '@/globals/version.js';\n\nexport interface InitOptions {\n  /**\n   * True if SDK should accept styles sent from the Telegram application.\n   * @default true\n   */\n  acceptCustomStyles?: boolean;\n  /**\n   * True if the application is launched in inline mode.\n   * @default Will be calculated based on the launch parameters' tgWebAppBotInline field.\n   */\n  isInlineMode?: boolean;\n  /**\n   * A custom `postEvent` function to use across the package.\n   * @default tma.js/bridge's postEventFp function will be used.\n   */\n  postEvent?: PostEventFpFn;\n  /**\n   * Mini application theme parameters.\n   * @default Will be calculated based on the launch parameters' tgWebAppThemeParams field.\n   */\n  themeParams?: ThemeParams;\n  /**\n   * Telegram Mini Apps version supported by the Telegram client.\n   * @default Will be calculated based on the launch parameters' tgWebAppVersion field.\n   */\n  version?: Version;\n}\n\n/**\n * Initializes the SDK allowing it to properly handle events, sent from the native Telegram\n * application. This function also configure the package's global dependencies (functions,\n * variables used across the package).\n * @param options - function options.\n * @returns A function, to perform a cleanup.\n */\nexport function initFp(\n  options: InitOptions = {},\n): E.Either<RetrieveLaunchParamsError | PostEventError, VoidFunction> {\n  const {\n    version: optionsVersion,\n    isInlineMode: optionsInlineMode,\n    themeParams: optionsThemeParams,\n  } = options;\n\n  if (optionsVersion && typeof optionsInlineMode === 'boolean' && optionsThemeParams) {\n    version.set(optionsVersion);\n    isInlineMode.set(optionsInlineMode);\n    themeParams.set(optionsThemeParams);\n  } else {\n    const error = pipe(retrieveLaunchParamsFp(), E.matchW(\n      err => err,\n      lp => {\n        version.set(optionsVersion || lp.tgWebAppVersion);\n        isInlineMode.set(typeof optionsInlineMode === 'boolean'\n          ? optionsInlineMode\n          : !!lp.tgWebAppBotInline);\n        themeParams.set(optionsThemeParams || lp.tgWebAppThemeParams);\n      },\n    ));\n    if (error) {\n      return E.left(error);\n    }\n  }\n  if (options.postEvent) {\n    postEventFpSignal.set(options.postEvent);\n  }\n\n  const [addCleanup, cleanup] = createCbCollector(\n    on('reload_iframe', () => {\n      logger().log('Received a request to reload the page');\n      postEvent('iframe_will_reload');\n      window.location.reload();\n    }),\n  );\n\n  const { acceptCustomStyles = true } = options;\n  if (acceptCustomStyles) {\n    const style = document.createElement('style');\n    style.id = 'telegram-custom-styles';\n    document.head.appendChild(style);\n\n    addCleanup(\n      on('set_custom_style', html => {\n        // It is safe to use innerHTML here as long as style tag has a special behavior related\n        // to the specified content.\n        // In case any script will be passed here, it will not be executed, so XSS is not possible.\n        style.innerHTML = html;\n      }),\n      () => {\n        document.head.removeChild(style);\n      },\n    );\n  }\n\n  // Notify Telegram that the application is ready.\n  //\n  // This will result in sending style tag html content from the Telegram web application.\n  // We should call this method also to start receiving \"reload_iframe\" events from the Telegram\n  // application.\n  //\n  // It really has no effect outside non-Telegram web environment.\n  return pipe(\n    postEventFp('iframe_ready', { reload_supported: true }),\n    E.map(() => {\n      logger().log('The package was initialized');\n      return cleanup;\n    }),\n  );\n}\n\n/**\n * @see initFp\n */\nexport const init = throwifyFpFn(initFp);\n"],"names":["__spreadArray","to","from","pack","i","l","ar","flow","ab","bc","cd","de","ef","fg","gh","hi","ij","pipe","a","ret","dual","arity","body","isDataFirst","args","self","none","some","isLeft","ma","left","e","right","emptyRecord","ap","F","G","fa","fab","gab","ga","map","f","bind","M","name","b","_a","_.left","_.right","flatMap","_map","_ap","URI","Functor","of","apW","Apply","Chain","bimap","g","_.isLeft","matchW","onLeft","onRight","match","tryCatch","onThrow","Do","_.emptyRecord","chainable.bind","bindW","access","value","Mountable","onMounted","restoreState","initialState","onUnmounted","isPageReload","__publicField","signal","computed","E.right","restored","state","E.map","s","batch","removeUndefined","result","k","v","shallowEqual","aKeys","bKeys","aKey","Stateful","onChange","nextState","key","createIsSupportedSignal","method","version","supports","_.none","_.some","isNone","onNone","onSome","throwifyWithChecksFp","fn","throwifyFpFn","O.match","data","throwifyAnyEither","E.left","map_","E.Functor","ap_","E.Apply","E.isLeft","mapBoth","E.bimap","E.match","_apPar","Pointed","ApplyPar","Monad","__awaiter","thisArg","_arguments","P","generator","adopt","resolve","reject","fulfilled","step","rejected","__generator","_","t","y","verb","n","op","ET.left","T.Pointed","ET.right","fromEither","T.of","ET.match","T.Functor","onRejected","reason_1","ET.map","ET.mapBoth","ET.ap","T.ApplyPar","ET.flatMap","T.Monad","chain","chainW","msgToTuple","message","ValidationError","errorClassWithData","input","issues","CSSVarsBoundError","errorClass","DeviceStorageMethodError","error","SecureStorageMethodError","NotAvailableError","InvalidEnvError","FunctionUnavailableError","InvalidArgumentsError","cause","ConcurrentCallError","SetEmojiStatusError","AccessDeniedError","FullscreenFailedError","ShareMessageError","UnknownThemeParamsKeyError","withChecksFp","options","isTma","optionsIsSupported","returns","isSupportedSimplified","isOptionSupported","optionName","optionSettings","calculateSupportError","mode","requirements","requirement","calculateOptionSupportError","isSupported","isInitialized","isMounted","isAvailable","wrapError","err","TE.left","call","E.tryCatch","TE.tryCatch","errMessagePrefix","supportErr","supportsOptionErr","O.some","O.none","createWithChecksFp","Button","storage","onClick","offClick","postEvent","payload","stateful","mountable","wrapOptions","wrapSupportedPlain","wrapMountedEither","nothing","wrapped","setFp","setFalse","setTrue","BackButton","button","sharedFeatureOptions","isTMAFp","createFnOption","mix","obj","createSignal","initialValue","postEventFpSignal","_postEventFp","postEventFp","withPostEvent","createComponentSessionStorage","getStorageValue","setStorageValue","getFirstNavigationEntry","entry","withStateRestore","storageName","withVersion","buttonOptions","trackedClickEvent","listener","once","on","off","backButton","AsyncMountable","TE.right","TE.map","notAvailableError","eventToState","event","available","tokenSaved","deviceId","accessRequested","type","accessGranted","Biometry","request","onInfoReceived","offInfoReceived","wrapSupportedEither","wrapSupportedTask","wrapMountedTask","response","TE.chain","requestFp","events","_requestFp","request2Fp","_request2Fp","BetterPromise","withRequest","biometry","ClosingBehavior","setClosingConfirmation","isConfirmationEnabled","closingBehavior","CloudStorage","invokeCustomMethod","keyOrKeys","keys","values","acc","parse","record","string","array","lastRequestId","createRequestId","params","invokeCustomMethodFp","withInvokeCustomMethod","cloudStorage","DeviceStorage","invokeMethod","requestId","withCreateRequestId","deviceStorage","create","rest","requestEmojiStatusAccessFp","requestEmojiStatusAccess","customEmojiId","TE.chainW","setEmojiStatusFp","setEmojiStatus","HapticFeedback","HAPTIC_METHOD_NAME","wrapSupported","style","hapticFeedback","addToHomeScreenFp","addToHomeScreen","checkHomeScreenStatusFp","checkHomeScreenStatus","InitData","retrieveInitData","authDateValue","canSendAfterValue","raw","initData","E.Do","E.bindW","retrieveLaunchParamsFp","tgWebAppData","retrieveRawInitDataFp","O.Do","O.bind","Invoice","isOpened","toggleClosed","slug","TE.mapBoth","url","hostname","pathname","invoice","openLinkFp","openLink","urlString","openTelegramLinkFp","openTelegramLink","text","shareURLFp","shareURL","LocationManager","locationManager","MainButton","defaults","withDefault","field","getDefault","fromState","setCssVar","deleteCssVar","isColorDarkFp","color","toRGBFullFp","rgb","modifier","idx","dec","isColorDark","ThemeParams","offChange","getCSSVarName","prop","snakeToKebab","forEachEntry","actualize","themeParams","globalThemeParams","bottomButtonOptions","mainButton","MiniApp","theme","onVisibilityChanged","offVisibilityChanged","visibilityChangedListener","themeChangedListener","isRGB","rgbBasedOn","computedRgbBasedOn","isCssVarsBound","addCleanup","cleanup","createCbCollector","cssVar","update","camelToKebab","genColorToolset","stateKey","rawColor","rgbColor","fp","withBasicEither","returnBack","miniApp","prepareParams","title","paramsButtons","buttons","id","Popup","TE.fromEither","preparedOptions","popup","requestPhoneAccessFp","requestPhoneAccess","createComplete","getContact","toStringResult","safeParse","toParsedResult","pipeQueryToSchema","looseObject","pipeJsonToSchema","number","optional","valiPipe","transform","date","getContactWithErrorsIgnore","TE.match","contact","pollContact","ctx","BetterTaskEither","res","rej","context","sleepTime","status","createParsed","requestContact","requestContactCompleteFp","requestContactComplete","requestContactFp","requestWriteAccessFp","requestWriteAccess","QrScanner","onClosed","onTextReceived","setClosed","captured","qr","addToCleanup","onSettled","isOpenedValue","qrScanner","SecondaryButton","secondaryButton","SecureStorage","secureStorage","SettingsButton","settingsButton","SwipeBehavior","setVerticalEnabled","isVerticalEnabled","swipeBehavior","copyTextToClipboard","clipboard","textArea","fileName","downloadFileFp","downloadFile","parsed","integer","getCurrentTimeFp","getCurrentTime","hideKeyboardFp","hideKeyboard","reqId","captureSameReq","readTextFromClipboardFp","readTextFromClipboard","retrieveAndroidDeviceDataFrom","userAgent","appVersion","systemInfo","item","retrieveAndroidDeviceData","size","sendDataFp","sendData","messageId","shareMessageFp","shareMessage","mediaUrl","shareStoryFp","shareStory","isInlineMode","query","chatTypes","switchInlineQueryFp","switchInlineQuery","Viewport","onContentSafeAreaInsetsChanged","onSafeAreaInsetsChanged","onViewportChanged","onFullscreenChanged","offContentSafeAreaInsetsChanged","offFullscreenChanged","offSafeAreaInsetsChanged","offViewportChanged","isViewportStable","isFullscreen","initialInsets","viewportChangedListener","fullscreenChangedListener","safeAreaInsetsChangedListener","contentSafeAreaInsetsChangedListener","genRequestInsets","kind","genFlag","flag","TE.Do","TE.bindW","shared","viewport","saBased","csaBased","wrapTask","wrapFullscreenTask","genFullscreenFn","enable","settings","setting","createListeners","viewportListeners","fullscreenListeners","safeAreaListeners","contentSafeAreaListeners","lp","initFp","optionsVersion","optionsInlineMode","optionsThemeParams","E.matchW","logger","acceptCustomStyles","html","init"],"mappings":"gcAAA,IAAIA,GAAgD,SAAUC,EAAIC,EAAMC,EAAM,CAC1E,GAAIA,GAAQ,UAAU,SAAW,EAAG,QAASC,EAAI,E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