{"version":3,"file":"kiosk-transaction.mjs","names":["#validateFinalizedStatus","#setPendingStatuses","kioskContract._new","#pendingShare","#validateKioskIsSet","personalKioskContract._new","#borrowFromPersonalCap","#personalCap","kioskContract.borrowVal","kioskContract.returnVal","kioskContract.withdraw","kioskContract.place","kioskContract.placeAndList","kioskContract.list","kioskContract.delist","kioskContract.take","kioskContract.lock","kioskContract.purchase","transferPolicyContract.confirmRequest","#pendingTransfer","#promise","personalKioskContract.returnVal","personalKioskContract.transferToSender","#finalized","personalKioskContract.borrowVal"],"sources":["../../src/client/kiosk-transaction.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type {\n\tTransaction,\n\tTransactionArgument,\n\tTransactionObjectArgument,\n} from '@mysten/sui/transactions';\n\nimport * as kioskContract from '../contracts/0x2/kiosk.js';\nimport * as transferPolicyContract from '../contracts/0x2/transfer_policy.js';\nimport * as personalKioskContract from '../contracts/kiosk/personal_kiosk.js';\nimport { createKioskAndShare } from '../tx/kiosk.js';\nimport type {\n\tItemId,\n\tItemReference,\n\tItemValue,\n\tKioskOwnerCap,\n\tObjectArgument,\n\tPrice,\n\tPurchaseOptions,\n} from '../types/index.js';\nimport { getNormalizedRuleType } from '../utils.js';\nimport type { KioskClient } from './kiosk-client.js';\n\nexport type KioskTransactionParams = {\n\t/** The Transaction for this run */\n\ttransaction: Transaction;\n\n\t/**\n\t * You can create a new KioskClient by calling `new KioskClient()`\n\t */\n\tkioskClient: KioskClient;\n\t/**\n\t * You can optionally pass in the `cap` as returned\n\t * from `kioskClient.getOwnedKiosks` when initializing the client\n\t * Otherwise, you can set it by calling `kioskTransaction.setCap()`\n\t */\n\tcap?: KioskOwnerCap;\n};\n\n/**\n * A helper for building transactions that involve kiosk.\n */\nexport class KioskTransaction {\n\ttransaction: Transaction;\n\tkioskClient: KioskClient;\n\tkiosk?: TransactionObjectArgument;\n\tkioskCap?: TransactionObjectArgument;\n\t// If we're pending `share` of a new kiosk, `finalize()` will share it.\n\t#pendingShare?: boolean;\n\t// If we're pending transferring of the cap, `finalize()` will either error or transfer the cap if it's a new personal.\n\t#pendingTransfer?: boolean;\n\t// The promise that the personalCap will be returned on `finalize()`.\n\t#promise?: TransactionArgument | undefined;\n\t// The personal kiosk argument.\n\t#personalCap?: TransactionObjectArgument;\n\t// A flag that checks whether kiosk TX is finalized.\n\t#finalized: boolean = false;\n\n\tconstructor({ transaction, kioskClient, cap }: KioskTransactionParams) {\n\t\tthis.transaction = transaction;\n\t\tthis.kioskClient = kioskClient;\n\n\t\tif (cap) this.setCap(cap);\n\t}\n\n\t/**\n\t * Creates a kiosk and saves `kiosk` and `kioskOwnerCap` in state.\n\t * Helpful if we want to chain some actions before sharing + transferring the cap to the specified address.\n\t * @param borrow If true, the `kioskOwnerCap` is borrowed from the `PersonalKioskCap` to be used in next transactions.\n\t */\n\tcreate() {\n\t\tthis.#validateFinalizedStatus();\n\t\tthis.#setPendingStatuses({\n\t\t\tshare: true,\n\t\t\ttransfer: true,\n\t\t});\n\t\tconst [kiosk, cap] = this.transaction.add(kioskContract._new({}));\n\t\tthis.kiosk = kiosk;\n\t\tthis.kioskCap = cap;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Creates a personal kiosk & shares it.\n\t * The `PersonalKioskCap` is transferred to the signer.\n\t * @param borrow If true, the `kioskOwnerCap` is borrowed from the `PersonalKioskCap` to be used in next transactions.\n\t */\n\tcreatePersonal(borrow?: boolean) {\n\t\tthis.#pendingShare = true;\n\t\treturn this.create().convertToPersonal(borrow);\n\t}\n\n\t/**\n\t * Converts a kiosk to a Personal (Soulbound) Kiosk.\n\t * Requires initialization by either calling `ktxb.create()` or `ktxb.setCap()`.\n\t */\n\tconvertToPersonal(borrow?: boolean) {\n\t\tthis.#validateKioskIsSet();\n\n\t\tconst packageId = this.kioskClient.getRulePackageId('personalKioskRulePackageId');\n\n\t\tconst [cap] = this.transaction.add(\n\t\t\tpersonalKioskContract._new({\n\t\t\t\tpackage: packageId,\n\t\t\t\targuments: {\n\t\t\t\t\tkiosk: this.kiosk!,\n\t\t\t\t\tcap: this.kioskCap!,\n\t\t\t\t},\n\t\t\t}),\n\t\t);\n\n\t\t// if we enable `borrow`, we borrow the kioskCap from the cap.\n\t\tif (borrow) this.#borrowFromPersonalCap(cap);\n\t\telse this.#personalCap = cap;\n\n\t\tthis.#setPendingStatuses({ transfer: true });\n\t\treturn this;\n\t}\n\n\t/**\n\t * Single function way to create a kiosk, share it and transfer the cap to the specified address.\n\t */\n\tcreateAndShare(address: string) {\n\t\tthis.#validateFinalizedStatus();\n\t\tconst cap = createKioskAndShare(this.transaction);\n\t\tthis.transaction.transferObjects([cap], address);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Shares the kiosk.\n\t */\n\tshare() {\n\t\tthis.#validateKioskIsSet();\n\t\tthis.#setPendingStatuses({ share: false });\n\t\tthis.transaction.moveCall({\n\t\t\ttarget: '0x2::transfer::public_share_object',\n\t\t\targuments: [this.kiosk!],\n\t\t\ttypeArguments: ['0x2::kiosk::Kiosk'],\n\t\t});\n\t\treturn this;\n\t}\n\n\t/**\n\t * Should be called only after `create` is called.\n\t * It shares the kiosk & transfers the cap to the specified address.\n\t */\n\tshareAndTransferCap(address: string) {\n\t\tif (this.#personalCap)\n\t\t\tthrow new Error('You can only call `shareAndTransferCap` on a non-personal kiosk.');\n\t\tthis.#setPendingStatuses({ transfer: false });\n\t\tthis.share();\n\t\tthis.transaction.transferObjects([this.kioskCap!], address);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to borrow an item from a kiosk & execute any function with it.\n\t * Example: You could borrow a Fren out of a kiosk, attach an accessory (or mix), and return it.\n\t */\n\tborrowTx({ itemType, itemId }: ItemId, callback: (item: TransactionArgument) => void) {\n\t\tthis.#validateKioskIsSet();\n\t\tconst [itemObj, promise] = this.transaction.add(\n\t\t\tkioskContract.borrowVal({\n\t\t\t\targuments: [this.kiosk!, this.kioskCap!, itemId],\n\t\t\t\ttypeArguments: [itemType],\n\t\t\t}),\n\t\t);\n\n\t\tcallback(itemObj);\n\n\t\treturn this.return({ itemType, item: itemObj, promise });\n\t}\n\n\t/**\n\t * Borrows an item from the kiosk.\n\t * This will fail if the item is listed for sale.\n\t *\n\t * Requires calling `return`.\n\t */\n\tborrow({ itemType, itemId }: ItemId): [TransactionArgument, TransactionArgument] {\n\t\tthis.#validateKioskIsSet();\n\t\tconst [itemObj, promise] = this.transaction.add(\n\t\t\tkioskContract.borrowVal({\n\t\t\t\targuments: [this.kiosk!, this.kioskCap!, itemId],\n\t\t\t\ttypeArguments: [itemType],\n\t\t\t}),\n\t\t);\n\n\t\treturn [itemObj, promise];\n\t}\n\n\t/**\n\t * Returns the item back to the kiosk.\n\t * Accepts the parameters returned from the `borrow` function.\n\t */\n\treturn({ itemType, item, promise }: ItemValue & { promise: TransactionArgument }) {\n\t\tthis.#validateKioskIsSet();\n\t\tthis.transaction.add(\n\t\t\tkioskContract.returnVal({\n\t\t\t\targuments: [this.kiosk!, item, promise],\n\t\t\t\ttypeArguments: [itemType],\n\t\t\t}),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to withdraw from kiosk\n\t * @param address Where to transfer the coin.\n\t * @param amount The amount we aim to withdraw.\n\t */\n\twithdraw(address: string, amount?: string | bigint | number) {\n\t\tthis.#validateKioskIsSet();\n\n\t\tconst [coin] = this.transaction.add(\n\t\t\tkioskContract.withdraw({\n\t\t\t\targuments: [this.kiosk!, this.kioskCap!, amount == null ? null : BigInt(amount)],\n\t\t\t}),\n\t\t);\n\t\tthis.transaction.transferObjects([coin], address);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to place an item in the kiosk.\n\t * @param itemType The type `T` of the item\n\t * @param item The ID or Transaction Argument of the item\n\t */\n\tplace({ itemType, item }: ItemReference) {\n\t\tthis.#validateKioskIsSet();\n\t\tconst itemArg = typeof item === 'string' ? this.transaction.object(item) : item;\n\t\tthis.transaction.add(\n\t\t\tkioskContract.place({\n\t\t\t\targuments: [this.kiosk!, this.kioskCap!, itemArg],\n\t\t\t\ttypeArguments: [itemType],\n\t\t\t}),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to place an item in the kiosk and list it for sale in one transaction.\n\t * @param itemType The type `T` of the item\n\t * @param item The ID or Transaction Argument of the item\n\t * @param price The price in MIST\n\t */\n\tplaceAndList({ itemType, item, price }: ItemReference & Price) {\n\t\tthis.#validateKioskIsSet();\n\t\tconst itemArg = typeof item === 'string' ? this.transaction.object(item) : item;\n\t\tconst priceArg = typeof price === 'string' ? BigInt(price) : price;\n\t\tthis.transaction.add(\n\t\t\tkioskContract.placeAndList({\n\t\t\t\targuments: [this.kiosk!, this.kioskCap!, itemArg, priceArg],\n\t\t\t\ttypeArguments: [itemType],\n\t\t\t}),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to list an item in the kiosk.\n\t * @param itemType The type `T` of the item\n\t * @param itemId The ID of the item\n\t * @param price The price in MIST\n\t */\n\tlist({ itemType, itemId, price }: ItemId & { price: string | bigint }) {\n\t\tthis.#validateKioskIsSet();\n\t\tconst priceArg = typeof price === 'string' ? BigInt(price) : price;\n\t\tthis.transaction.add(\n\t\t\tkioskContract.list({\n\t\t\t\targuments: [this.kiosk!, this.kioskCap!, itemId, priceArg],\n\t\t\t\ttypeArguments: [itemType],\n\t\t\t}),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to delist an item from the kiosk.\n\t * @param itemType The type `T` of the item\n\t * @param itemId The ID of the item\n\t */\n\tdelist({ itemType, itemId }: ItemId) {\n\t\tthis.#validateKioskIsSet();\n\t\tthis.transaction.add(\n\t\t\tkioskContract.delist({\n\t\t\t\targuments: [this.kiosk!, this.kioskCap!, itemId],\n\t\t\t\ttypeArguments: [itemType],\n\t\t\t}),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to take an item from the kiosk. The transaction won't succeed if the item is listed or locked.\n\n\t * @param itemType The type `T` of the item\n\t * @param itemId The ID of the item\n\t */\n\ttake({ itemType, itemId }: ItemId): TransactionObjectArgument {\n\t\tthis.#validateKioskIsSet();\n\t\tconst [item] = this.transaction.add(\n\t\t\tkioskContract.take({\n\t\t\t\targuments: [this.kiosk!, this.kioskCap!, itemId],\n\t\t\t\ttypeArguments: [itemType],\n\t\t\t}),\n\t\t);\n\t\treturn item;\n\t}\n\n\t/**\n\t * Transfer a non-locked/non-listed item to an address.\n\t *\n\t * @param itemType The type `T` of the item\n\t * @param itemId The ID of the item\n\t * @param address The destination address\n\t */\n\ttransfer({ itemType, itemId, address }: ItemId & { address: string }) {\n\t\tthis.#validateKioskIsSet();\n\t\tconst item = this.take({ itemType, itemId });\n\t\tthis.transaction.transferObjects([item], address);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to take lock an item in the kiosk.\n\n\t * @param itemType The type `T` of the item\n\t * @param item The ID or Transaction Argument of the item\n\t * @param itemId The ID of the item - Deprecated: Use `item` instead.\n\t * @param policy The Policy ID or Transaction Argument for item T\n\t */\n\tlock({\n\t\titemType,\n\t\titem,\n\t\titemId,\n\t\tpolicy,\n\t}: ItemReference & { policy: ObjectArgument; itemId?: string }) {\n\t\tthis.#validateKioskIsSet();\n\t\tconst itemArg = itemId\n\t\t\t? this.transaction.object(itemId)\n\t\t\t: typeof item === 'string'\n\t\t\t\t? this.transaction.object(item)\n\t\t\t\t: item;\n\t\tconst policyArg = typeof policy === 'string' ? this.transaction.object(policy) : policy;\n\t\tthis.transaction.add(\n\t\t\tkioskContract.lock({\n\t\t\t\targuments: [this.kiosk!, this.kioskCap!, policyArg, itemArg],\n\t\t\t\ttypeArguments: [itemType],\n\t\t\t}),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Purchase an item from a seller's kiosk.\n\t * Returns [item, transferRequest]\n\t * Can be called like: `const [item, transferRequest] = kioskTx.purchase({...})`\n\t * @param itemType The type `T` of the item\n\t * @param itemId The ID of the item\n\t * @param price The price in MIST\n\t * @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument.\n\t */\n\tpurchase({\n\t\titemType,\n\t\titemId,\n\t\tprice,\n\t\tsellerKiosk,\n\t}: ItemId & Price & { sellerKiosk: ObjectArgument }): [\n\t\tTransactionObjectArgument,\n\t\tTransactionObjectArgument,\n\t] {\n\t\t// Split the coin for the amount of the listing.\n\t\tconst [coin] = this.transaction.splitCoins(this.transaction.gas, [price]);\n\t\tconst kioskArg =\n\t\t\ttypeof sellerKiosk === 'string' ? this.transaction.object(sellerKiosk) : sellerKiosk;\n\t\tconst [item, transferRequest] = this.transaction.add(\n\t\t\tkioskContract.purchase({\n\t\t\t\targuments: [kioskArg, itemId, coin],\n\t\t\t\ttypeArguments: [itemType],\n\t\t\t}),\n\t\t);\n\t\treturn [item, transferRequest];\n\t}\n\n\t/**\n\t * A function to purchase and resolve a transfer policy.\n\t * If the transfer policy has the `lock` rule, the item is locked in the kiosk.\n\t * Otherwise, the item is placed in the kiosk.\n\t * @param itemType The type of the item\n\t * @param itemId The id of the item\n\t * @param price The price of the specified item\n\t * @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument.\n\t * @param extraArgs Used to pass arguments for custom rule resolvers.\n\t */\n\tasync purchaseAndResolve({\n\t\titemType,\n\t\titemId,\n\t\tprice,\n\t\tsellerKiosk,\n\t\textraArgs,\n\t}: ItemId & Price & { sellerKiosk: ObjectArgument } & PurchaseOptions) {\n\t\tthis.#validateKioskIsSet();\n\t\t// Get a list of the transfer policies.\n\t\tconst policies = await this.kioskClient.getTransferPolicies({ type: itemType });\n\n\t\tif (policies.length === 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`The type ${itemType} doesn't have a Transfer Policy so it can't be traded through kiosk.`,\n\t\t\t);\n\t\t}\n\n\t\tconst policy = policies[0]; // we now pick the first one. We need to add an option to define which one.\n\n\t\t// initialize the purchase `kiosk::purchase`\n\t\tconst [purchasedItem, transferRequest] = this.purchase({\n\t\t\titemType,\n\t\t\titemId,\n\t\t\tprice,\n\t\t\tsellerKiosk,\n\t\t});\n\n\t\tlet canTransferOutsideKiosk = true;\n\n\t\tfor (const rule of policy.rules) {\n\t\t\tconst ruleDefinition = this.kioskClient.rules.find(\n\t\t\t\t(x) => getNormalizedRuleType(x.rule) === getNormalizedRuleType(rule),\n\t\t\t);\n\t\t\tif (!ruleDefinition) throw new Error(`No resolver for the following rule: ${rule}.`);\n\n\t\t\tif (ruleDefinition.hasLockingRule) canTransferOutsideKiosk = false;\n\n\t\t\tawait ruleDefinition.resolveRuleFunction({\n\t\t\t\tpackageId: ruleDefinition.packageId,\n\t\t\t\ttransaction: this.transaction,\n\t\t\t\titemType,\n\t\t\t\titemId,\n\t\t\t\tprice: price.toString(),\n\t\t\t\tsellerKiosk,\n\t\t\t\tpolicyId: policy.id,\n\t\t\t\ttransferRequest,\n\t\t\t\tpurchasedItem,\n\t\t\t\tkiosk: this.kiosk!,\n\t\t\t\tkioskCap: this.kioskCap!,\n\t\t\t\textraArgs: extraArgs || {},\n\t\t\t\tkioskClient: this.kioskClient,\n\t\t\t});\n\t\t}\n\n\t\tthis.transaction.add(\n\t\t\ttransferPolicyContract.confirmRequest({\n\t\t\t\targuments: [this.transaction.object(policy.id), transferRequest],\n\t\t\t\ttypeArguments: [itemType],\n\t\t\t}),\n\t\t);\n\n\t\tif (canTransferOutsideKiosk) this.place({ itemType, item: purchasedItem });\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to setup the client using an existing `ownerCap`,\n\t * as return from the `kioskClient.getOwnedKiosks` function.\n\t * @param cap `KioskOwnerCap` object as returned from `getOwnedKiosks` SDK call.\n\t */\n\tsetCap(cap: KioskOwnerCap) {\n\t\tthis.#validateFinalizedStatus();\n\t\tthis.kiosk = this.transaction.object(cap.kioskId);\n\t\tif (!cap.isPersonal) {\n\t\t\tthis.kioskCap = this.transaction.object(cap.objectId);\n\t\t\treturn;\n\t\t}\n\n\t\treturn this.#borrowFromPersonalCap(cap.objectId);\n\t}\n\n\t/**\n\t *\tA function that ends up the kiosk building tx & returns the `kioskOwnerCap` back to the\n\t *  `PersonalKioskCap`, in case we are operating on a personal kiosk.\n\t * \tIt will also share the `kiosk` if it's not shared, and finalize the transfer of the personal cap if it's pending.\n\t */\n\tfinalize() {\n\t\tthis.#validateKioskIsSet();\n\t\t// If we're pending the sharing of the new kiosk, share it.\n\t\tif (this.#pendingShare) this.share();\n\n\t\t// If we're operating on a non-personal kiosk, we don't need to do anything else.\n\t\tif (!this.#personalCap) {\n\t\t\t// If we're pending transfer though, we inform user to call `shareAndTransferCap()`.\n\t\t\tif (this.#pendingTransfer)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'You need to transfer the `kioskOwnerCap` by calling `shareAndTransferCap()` before wrap',\n\t\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// if we have a promise, return the `ownerCap` back to the personal cap.\n\t\tif (this.#promise) {\n\t\t\tconst packageId = this.kioskClient.getRulePackageId('personalKioskRulePackageId');\n\n\t\t\tthis.transaction.add(\n\t\t\t\tpersonalKioskContract.returnVal({\n\t\t\t\t\tpackage: packageId,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tself: this.#personalCap,\n\t\t\t\t\t\tcap: this.kioskCap!,\n\t\t\t\t\t\tborrow: this.#promise,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\t// If we are pending transferring the personalCap, we do it here.\n\t\tif (this.#pendingTransfer) {\n\t\t\tconst packageId = this.kioskClient.getRulePackageId('personalKioskRulePackageId');\n\n\t\t\tthis.transaction.add(\n\t\t\t\tpersonalKioskContract.transferToSender({\n\t\t\t\t\tpackage: packageId,\n\t\t\t\t\targuments: { self: this.#personalCap },\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\t// Mark the transaction as finalized, so no other functions can be called.\n\t\tthis.#finalized = true;\n\t}\n\n\t// Some setters in case we want custom behavior.\n\tsetKioskCap(cap: TransactionObjectArgument) {\n\t\tthis.#validateFinalizedStatus();\n\t\tthis.kioskCap = cap;\n\t\treturn this;\n\t}\n\n\tsetKiosk(kiosk: TransactionObjectArgument) {\n\t\tthis.#validateFinalizedStatus();\n\t\tthis.kiosk = kiosk;\n\t\treturn this;\n\t}\n\n\t// Some getters\n\t/*\n\t * Returns the active transaction's kiosk, or undefined if `setCap` or `create()` hasn't been called yet.\n\t */\n\tgetKiosk() {\n\t\tthis.#validateFinalizedStatus();\n\t\tif (!this.kiosk) throw new Error('Kiosk is not set.');\n\t\treturn this.kiosk;\n\t}\n\n\t/*\n\t * Returns the active transaction's kioskOwnerCap, or undefined if `setCap` or `create()` hasn't been called yet.\n\t */\n\tgetKioskCap() {\n\t\tthis.#validateFinalizedStatus();\n\t\tif (!this.kioskCap) throw new Error('Kiosk cap is not set');\n\t\treturn this.kioskCap;\n\t}\n\n\t/**\n\t * A function to borrow from `personalCap`.\n\t */\n\t#borrowFromPersonalCap(personalCap: ObjectArgument) {\n\t\tconst packageId = this.kioskClient.getRulePackageId('personalKioskRulePackageId');\n\t\tconst personalCapArg =\n\t\t\ttypeof personalCap === 'string' ? this.transaction.object(personalCap) : personalCap;\n\t\tconst [kioskCap, promise] = this.transaction.add(\n\t\t\tpersonalKioskContract.borrowVal({\n\t\t\t\tpackage: packageId,\n\t\t\t\targuments: { self: personalCapArg },\n\t\t\t}),\n\t\t);\n\n\t\tthis.kioskCap = kioskCap;\n\t\tthis.#personalCap = personalCapArg;\n\t\tthis.#promise = promise;\n\n\t\treturn this;\n\t}\n\n\t#setPendingStatuses({ share, transfer }: { share?: boolean; transfer?: boolean }) {\n\t\tif (transfer !== undefined) this.#pendingTransfer = transfer;\n\t\tif (share !== undefined) this.#pendingShare = share;\n\t}\n\n\t#validateKioskIsSet() {\n\t\tthis.#validateFinalizedStatus();\n\n\t\tif (!this.kiosk || !this.kioskCap)\n\t\t\tthrow new Error(\n\t\t\t\t'You need to initialize the client by either supplying an existing owner cap or by creating a new by calling `.create()`',\n\t\t\t);\n\t}\n\n\t// Validates that `finalize`\n\t#validateFinalizedStatus() {\n\t\tif (this.#finalized)\n\t\t\tthrow new Error(\"You can't add more transactions to a finalized kiosk transaction.\");\n\t}\n}\n"],"mappings":";;;;;;;;;;AA4CA,IAAa,mBAAb,MAA8B;CAM7B;CAEA;CAEA;CAEA;CAEA,aAAsB;CAEtB,YAAY,EAAE,aAAa,aAAa,OAA+B;AACtE,OAAK,cAAc;AACnB,OAAK,cAAc;AAEnB,MAAI,IAAK,MAAK,OAAO,IAAI;;;;;;;CAQ1B,SAAS;AACR,QAAKA,yBAA0B;AAC/B,QAAKC,mBAAoB;GACxB,OAAO;GACP,UAAU;GACV,CAAC;EACF,MAAM,CAAC,OAAO,OAAO,KAAK,YAAY,IAAIC,KAAmB,EAAE,CAAC,CAAC;AACjE,OAAK,QAAQ;AACb,OAAK,WAAW;AAChB,SAAO;;;;;;;CAQR,eAAe,QAAkB;AAChC,QAAKC,eAAgB;AACrB,SAAO,KAAK,QAAQ,CAAC,kBAAkB,OAAO;;;;;;CAO/C,kBAAkB,QAAkB;AACnC,QAAKC,oBAAqB;EAE1B,MAAM,YAAY,KAAK,YAAY,iBAAiB,6BAA6B;EAEjF,MAAM,CAAC,OAAO,KAAK,YAAY,IAC9BC,OAA2B;GAC1B,SAAS;GACT,WAAW;IACV,OAAO,KAAK;IACZ,KAAK,KAAK;IACV;GACD,CAAC,CACF;AAGD,MAAI,OAAQ,OAAKC,sBAAuB,IAAI;MACvC,OAAKC,cAAe;AAEzB,QAAKN,mBAAoB,EAAE,UAAU,MAAM,CAAC;AAC5C,SAAO;;;;;CAMR,eAAe,SAAiB;AAC/B,QAAKD,yBAA0B;EAC/B,MAAM,MAAM,oBAAoB,KAAK,YAAY;AACjD,OAAK,YAAY,gBAAgB,CAAC,IAAI,EAAE,QAAQ;AAChD,SAAO;;;;;CAMR,QAAQ;AACP,QAAKI,oBAAqB;AAC1B,QAAKH,mBAAoB,EAAE,OAAO,OAAO,CAAC;AAC1C,OAAK,YAAY,SAAS;GACzB,QAAQ;G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