const require_runtime = require("../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_asyncToGenerator = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
const require_objectWithoutProperties = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js");
const require_useEngineContext = require("../../hooks/useEngineContext.js");
const require_index = require("../../utils/index.js");
const require_index$1 = require("../../components/walletList/tempHolderSelector/index.js");
const require_serve = require("./serve.js");
const require_locales = require("./locales.js");
const require_index$2 = require("./components/passList/index.js");
const require_index$3 = require("./components/passDetail/index.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
let ahooks = require("ahooks");
require("./index.less");
//#region src/plus/walletPassGallery/index.tsx
const _excluded = [
	"id",
	"product_name",
	"balance",
	"code",
	"encoded",
	"expire_date",
	"shop",
	"limit_status",
	"product_cover",
	"unified_available_status",
	"unified_messages",
	"par_value",
	"tag"
];
const { Title } = antd.Typography;
const KEYS = {
	available: "available",
	unavailable: "unavailable"
};
const ARow = antd.Row;
const ACol = antd.Col;
const TAGS = [
	"gift_card",
	"point_card",
	"product_discount_card",
	"good_pass",
	"product_voucher"
];
const WalletPassGallery = (props) => {
	var _context$appHelper, _context$appHelper2, _context$engine, _utils$translation, _getWalletDetail$data;
	const { hideAddButton, hideTitle, customer, platform: platformProp, hideHeader } = props;
	const [activeKey, setActiveKey] = (0, react.useState)("available");
	const [currentItemId, setCurrentItemId] = (0, react.useState)(void 0);
	const [isOpenAddModal, setIsOpenAddModal] = (0, react.useState)(false);
	const [currentUnbindItem, setCurrentUnbindItem] = (0, react.useState)(null);
	const [editHolderData, setEditHolderData] = (0, react.useState)(null);
	const [updateHolderLoading, setUpdateHolderLoading] = (0, react.useState)(false);
	const context = require_useEngineContext.default();
	const utils = (context === null || context === void 0 || (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils) || {};
	const { apiPrefix } = ((_context$appHelper2 = context.appHelper) === null || _context$appHelper2 === void 0 ? void 0 : _context$appHelper2.constants) || { apiPrefix: "/h5" };
	const { isTerminal, isApp, interaction } = utils;
	const isTerminalEnv = (typeof isTerminal === "function" ? isTerminal() : !!isTerminal) || (isApp === null || isApp === void 0 ? void 0 : isApp());
	const platform = (0, react.useMemo)(() => {
		if (platformProp) return platformProp;
		if (utils.isMobile) return utils.isMobile() ? "h5" : "pc";
		if (typeof window !== "undefined") return window.innerWidth <= 768 ? "h5" : "pc";
		return "pc";
	}, [utils, platformProp]);
	_pisell_utils.locales.init(require_locales.default, (context === null || context === void 0 || (_context$engine = context.engine) === null || _context$engine === void 0 || (_context$engine = _context$engine.props) === null || _context$engine === void 0 ? void 0 : _context$engine.locale) || "en");
	require_index.request.setRequest(utils === null || utils === void 0 ? void 0 : utils.request);
	const _getWalletDetail = (0, ahooks.useRequest)(require_serve.getWalletDetail, { manual: true });
	const _getAvailableList = (0, ahooks.useInfiniteScroll)(function() {
		var _ref = require_asyncToGenerator._asyncToGenerator(function* (d) {
			const _searchParams = new URLSearchParams(window.location.search);
			const walletId = _searchParams.get("id");
			const holderId = _searchParams.get("holder_id");
			const res = yield require_serve.getWalletPassList({
				available: 1,
				num: 20,
				skip: (d === null || d === void 0 ? void 0 : d.nextId) || 1,
				tags: TAGS,
				filter_wallet_id: walletId || void 0,
				filter_holder_id: holderId || void 0,
				with: ["customScheduleSnapshot", "holder.detail"],
				customer_id: customer === null || customer === void 0 ? void 0 : customer.id
			}, { apiPrefix });
			return {
				list: (res === null || res === void 0 ? void 0 : res.list) || [],
				count: (res === null || res === void 0 ? void 0 : res.count) || 0,
				nextId: (res === null || res === void 0 ? void 0 : res.skip) || 1
			};
		});
		return function(_x) {
			return _ref.apply(this, arguments);
		};
	}(), {
		manual: true,
		onSuccess: (data) => {},
		isNoMore: (d) => {
			if (!(d === null || d === void 0 ? void 0 : d.list)) return false;
			return d.list.length >= (d.count || 0);
		}
	});
	const _getUnavailableList = (0, ahooks.useInfiniteScroll)(function() {
		var _ref2 = require_asyncToGenerator._asyncToGenerator(function* (d) {
			const _searchParams = new URLSearchParams(window.location.search);
			const walletId = _searchParams.get("id");
			const holderId = _searchParams.get("holder_id");
			const res = yield require_serve.getWalletPassList({
				available: 0,
				num: 20,
				skip: (d === null || d === void 0 ? void 0 : d.nextId) || 1,
				tags: TAGS,
				filter_wallet_id: walletId || void 0,
				filter_holder_id: holderId || void 0,
				with: ["customScheduleSnapshot", "holder.detail"],
				customer_id: customer === null || customer === void 0 ? void 0 : customer.id
			}, { apiPrefix });
			return {
				list: (res === null || res === void 0 ? void 0 : res.list) || [],
				count: (res === null || res === void 0 ? void 0 : res.count) || 0,
				nextId: (res === null || res === void 0 ? void 0 : res.skip) || 1
			};
		});
		return function(_x2) {
			return _ref2.apply(this, arguments);
		};
	}(), {
		manual: true,
		isNoMore: (d) => {
			if (!(d === null || d === void 0 ? void 0 : d.list)) return false;
			return d.list.length >= (d.count || 0);
		}
	});
	(0, react.useEffect)(() => {
		const walletId = new URLSearchParams(window.location.search).get("id");
		const passId = new URLSearchParams(window.location.search).get("wallet_pass_detail_id");
		if (walletId) _getWalletDetail.runAsync(walletId);
		const req1 = _getAvailableList.reloadAsync();
		const req2 = _getUnavailableList.reloadAsync();
		let req3 = passId ? require_serve.getWalletPassDetail(passId, { with: ["holder.detail"] }) : Promise.resolve();
		Promise.all([
			req1,
			req2,
			req3
		]).then(([data1, data2, data3]) => {
			if (platform !== "h5") {
				const list1 = (data1 === null || data1 === void 0 ? void 0 : data1.list) || [];
				const list2 = (data2 === null || data2 === void 0 ? void 0 : data2.list) || [];
				if (passId) {
					var _data3$holder, _data3$holder2;
					const matchedInList1 = list1.find((item) => String(item.id) === passId);
					const matchedInList2 = list2.find((item) => String(item.id) === passId);
					if (matchedInList1 || matchedInList2) {
						setCurrentItemId(Number(passId));
						if (matchedInList2) setActiveKey("unavailable");
					} else if (data3) if (data3.unified_available_status === 1) {
						_getAvailableList.mutate((data) => require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, data), {}, { list: [data3, ...(data === null || data === void 0 ? void 0 : data.list) || []] }));
						setCurrentItemId(data3.id);
					} else {
						_getUnavailableList.mutate((data) => require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, data), {}, { list: [data3, ...(data === null || data === void 0 ? void 0 : data.list) || []] }));
						setCurrentItemId(data3.id);
						setActiveKey("unavailable");
					}
					else {
						const firstAvailable = list1[0];
						if (firstAvailable) setCurrentItemId(firstAvailable.id);
						else {
							const firstUnavailable = list2[0];
							if (firstUnavailable) {
								setCurrentItemId(firstUnavailable.id);
								setActiveKey("unavailable");
							}
						}
					}
					if (data3 && ((_data3$holder = data3.holder) === null || _data3$holder === void 0 ? void 0 : _data3$holder.holder_type) === "form" && !((_data3$holder2 = data3.holder) === null || _data3$holder2 === void 0 ? void 0 : _data3$holder2.holder_id)) {
						var _data3$holder3, _data3$holder4;
						setEditHolderData({
							wallet_pass_detail_id: passId,
							customer_id: (_data3$holder3 = data3.holder) === null || _data3$holder3 === void 0 ? void 0 : _data3$holder3.customer_id,
							form_id: (_data3$holder4 = data3.holder) === null || _data3$holder4 === void 0 || (_data3$holder4 = _data3$holder4.metadata) === null || _data3$holder4 === void 0 ? void 0 : _data3$holder4.custom_id
						});
					}
				} else {
					const firstAvailable = list1[0];
					if (firstAvailable) setCurrentItemId(firstAvailable.id);
					else {
						const firstUnavailable = list2[0];
						if (firstUnavailable) {
							setCurrentItemId(firstUnavailable.id);
							setActiveKey("unavailable");
						}
					}
				}
			}
		});
	}, [customer]);
	(0, react.useEffect)(() => {
		var _interaction$utils, _interaction$utils$mo;
		interaction === null || interaction === void 0 || (_interaction$utils = interaction.utils) === null || _interaction$utils === void 0 || (_interaction$utils$mo = _interaction$utils.mountFunction) === null || _interaction$utils$mo === void 0 || _interaction$utils$mo.call(_interaction$utils, "customer", "new", () => {
			try {
				_getAvailableList.reloadAsync();
				_getUnavailableList.reloadAsync();
			} catch (err) {
				console.error(err);
			}
		});
	}, []);
	const listReload = () => {
		_getAvailableList.reloadAsync();
		_getUnavailableList.reloadAsync();
	};
	const _getUnbindList = (0, ahooks.useRequest)(require_serve.getUnbindList, {
		manual: true,
		onSuccess: (data) => {
			if (data === null || data === void 0 ? void 0 : data.length) setCurrentUnbindItem(data[0]);
			else {
				setCurrentUnbindItem(null);
				(0, _pisell_materials.PisellToast)({
					content: _pisell_utils.locales.getText("wallet-pass-gallery.searchNoFound"),
					duration: 2
				});
			}
		},
		onError: (e) => {
			console.log("get unbind list error", e);
			setCurrentUnbindItem(null);
			(0, _pisell_materials.PisellToast)({
				content: _pisell_utils.locales.getText("wallet-pass-gallery.searchNoFound"),
				duration: 2
			});
		}
	});
	(0, react.useEffect)(() => {
		document.body.id = "body";
	}, []);
	const _avaliable = (0, react.useMemo)(() => {
		var _getAvailableList$dat;
		return ((_getAvailableList$dat = _getAvailableList.data) === null || _getAvailableList$dat === void 0 ? void 0 : _getAvailableList$dat.list) || [];
	}, [_getAvailableList.data]);
	const _unavailable = (0, react.useMemo)(() => {
		var _getUnavailableList$d;
		return ((_getUnavailableList$d = _getUnavailableList.data) === null || _getUnavailableList$d === void 0 ? void 0 : _getUnavailableList$d.list) || [];
	}, [_getUnavailableList.data]);
	const _handleTabChange = (key) => {
		var _unavailable$, _avaliable$;
		setActiveKey(key);
		if (platform === "h5") {
			setCurrentItemId(void 0);
			return;
		}
		setCurrentItemId(key === KEYS.unavailable ? (_unavailable$ = _unavailable[0]) === null || _unavailable$ === void 0 ? void 0 : _unavailable$.id : (_avaliable$ = _avaliable[0]) === null || _avaliable$ === void 0 ? void 0 : _avaliable$.id);
	};
	const handleAddClick = () => {
		if (isTerminalEnv) {
			var _interaction$utils2, _interaction$utils2$p;
			interaction === null || interaction === void 0 || (_interaction$utils2 = interaction.utils) === null || _interaction$utils2 === void 0 || (_interaction$utils2$p = _interaction$utils2.postMessageToApp) === null || _interaction$utils2$p === void 0 || _interaction$utils2$p.call(_interaction$utils2, {
				module: "customer",
				key: "new",
				data: { customer_id: String((customer === null || customer === void 0 ? void 0 : customer.id) || "") }
			});
			return;
		}
		setIsOpenAddModal(true);
	};
	const _resetSearchState = () => {
		setCurrentUnbindItem(null);
		_getUnbindList.mutate([]);
	};
	const _handleCardClick = (id) => {
		setCurrentItemId(id);
	};
	const _handleSearchByCode = function() {
		var _ref3 = require_asyncToGenerator._asyncToGenerator(function* (code) {
			if (!code || !code.trim()) {
				_resetSearchState();
				return;
			}
			try {
				yield _getUnbindList.run({ code });
			} catch (error) {
				_resetSearchState();
				(0, _pisell_materials.PisellToast)({
					content: _pisell_utils.locales.getText("wallet-pass-gallery.searchNoFound"),
					duration: 2
				});
			}
		});
		return function _handleSearchByCode(_x3) {
			return _ref3.apply(this, arguments);
		};
	}();
	const _handleBind = function() {
		var _ref4 = require_asyncToGenerator._asyncToGenerator(function* () {
			if (!(currentUnbindItem === null || currentUnbindItem === void 0 ? void 0 : currentUnbindItem.code)) return;
			try {
				const data = yield require_serve.bindCodeToCustomer({ code: currentUnbindItem.code });
				console.log("bind result", data);
				if (data) {
					(0, _pisell_materials.PisellToast)({
						content: _pisell_utils.locales.getText("wallet-pass-gallery.addSuccess"),
						duration: 2
					});
					_getAvailableList.reloadAsync();
					_getUnavailableList.reloadAsync();
				}
				setIsOpenAddModal(false);
				_resetSearchState();
			} catch (error) {
				(0, _pisell_materials.PisellToast)({
					content: _pisell_utils.locales.getText("wallet-pass-gallery.addError"),
					duration: 2
				});
			}
		});
		return function _handleBind() {
			return _ref4.apply(this, arguments);
		};
	}();
	const _handleHolderChange = (passId, holder) => {
		if (_avaliable.find((item) => item.id === passId)) _getAvailableList.mutate((data) => {
			const newList = data.list.map((item) => item.id === passId ? require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, { holder }) : item);
			return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, data), {}, { list: newList });
		});
		else if (_unavailable.find((item) => item.id === passId)) _getUnavailableList.mutate((data) => {
			const newList = data.list.map((item) => item.id === passId ? require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, { holder }) : item);
			return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, data), {}, { list: newList });
		});
		else console.log("pass not found", passId);
	};
	const _handleBindHolder = function() {
		var _ref5 = require_asyncToGenerator._asyncToGenerator(function* (holderId) {
			setUpdateHolderLoading(true);
			const { wallet_pass_detail_id: passId } = editHolderData;
			try {
				const res = yield require_serve.updateWalletPassHolder(passId, {
					holder_type: "form",
					holder_id: holderId
				});
				setEditHolderData(null);
				if (holderId) {
					if (res) _handleHolderChange === null || _handleHolderChange === void 0 || _handleHolderChange(Number(passId), res);
				} else _handleHolderChange === null || _handleHolderChange === void 0 || _handleHolderChange(Number(passId), null);
			} catch (error) {
				console.error("Error updating wallet pass holder:", error);
			} finally {
				setUpdateHolderLoading(false);
			}
		});
		return function _handleBindHolder(_x4) {
			return _ref5.apply(this, arguments);
		};
	}();
	const _currentItem = (0, react.useMemo)(() => {
		if (!currentItemId) return null;
		const found1 = _avaliable.find((item) => item.id === currentItemId);
		if (found1) return found1;
		return _unavailable.find((item) => item.id === currentItemId);
	}, [
		currentItemId,
		_avaliable,
		_unavailable
	]);
	const _pcTitle = /* @__PURE__ */ react.default.createElement("div", { className: "pisell-wallet-pass-gallery_title" }, hideTitle ? null : /* @__PURE__ */ react.default.createElement(Title, null, (utils === null || utils === void 0 || (_utils$translation = utils.translation) === null || _utils$translation === void 0 ? void 0 : _utils$translation.call(utils, (_getWalletDetail$data = _getWalletDetail.data) === null || _getWalletDetail$data === void 0 || (_getWalletDetail$data = _getWalletDetail$data.data) === null || _getWalletDetail$data === void 0 ? void 0 : _getWalletDetail$data.name)) || _pisell_utils.locales.getText("wallet-pass-gallery.wallet")));
	const renderAvaliableList = () => {
		if (platform === "h5") return /* @__PURE__ */ react.default.createElement(require_index$2.default, {
			onLoadMore: () => _getAvailableList.loadMoreAsync(),
			loading: _getAvailableList.loadingMore,
			hasMore: !_getAvailableList.noMore,
			dataSource: _avaliable,
			value: currentItemId,
			onChange: _handleCardClick,
			onEditHolder: setEditHolderData
		});
		return /* @__PURE__ */ react.default.createElement(ARow, {
			gutter: 20,
			wrap: false
		}, /* @__PURE__ */ react.default.createElement(ACol, { flex: "367px" }, /* @__PURE__ */ react.default.createElement(require_index$2.default, {
			onLoadMore: () => _getAvailableList.loadMoreAsync(),
			loading: _getAvailableList.loadingMore,
			hasMore: !_getAvailableList.noMore,
			dataSource: _avaliable,
			value: currentItemId,
			onChange: _handleCardClick,
			onEditHolder: setEditHolderData
		})), /* @__PURE__ */ react.default.createElement(ACol, { flex: "auto" }, /* @__PURE__ */ react.default.createElement(require_index$3.default, {
			dataSource: _currentItem,
			platform,
			onListRefresh: listReload
		})));
	};
	const renderUnavailableList = () => {
		if (platform === "h5") return /* @__PURE__ */ react.default.createElement(require_index$2.default, {
			onLoadMore: () => _getUnavailableList.loadMoreAsync(),
			hasMore: !_getUnavailableList.noMore,
			loading: _getUnavailableList.loadingMore,
			dataSource: _unavailable,
			value: currentItemId,
			onChange: _handleCardClick,
			onEditHolder: setEditHolderData
		});
		return /* @__PURE__ */ react.default.createElement(ARow, {
			gutter: 20,
			wrap: false
		}, /* @__PURE__ */ react.default.createElement(ACol, { flex: "367px" }, /* @__PURE__ */ react.default.createElement(require_index$2.default, {
			onLoadMore: () => _getUnavailableList.loadMoreAsync(),
			hasMore: !_getUnavailableList.noMore,
			loading: _getUnavailableList.loadingMore,
			dataSource: _unavailable,
			value: currentItemId,
			onChange: _handleCardClick,
			onEditHolder: setEditHolderData
		})), /* @__PURE__ */ react.default.createElement(ACol, { flex: "auto" }, /* @__PURE__ */ react.default.createElement(require_index$3.default, {
			dataSource: _currentItem,
			platform,
			onListRefresh: listReload
		})));
	};
	const renderTabBar = (props, DefaultTabBar) => {
		return /* @__PURE__ */ react.default.createElement("div", { style: {
			zIndex: 99,
			position: "sticky",
			top: 0
		} }, /* @__PURE__ */ react.default.createElement(DefaultTabBar, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, props), {}, { style: { background: "white" } })));
	};
	const renderContent = () => {
		var _getAvailableList$dat2, _getUnavailableList$d2;
		return /* @__PURE__ */ react.default.createElement("div", { className: "pisell-wallet-pass-gallery_content" }, /* @__PURE__ */ react.default.createElement(_pisell_materials.Tabs, {
			defaultActiveKey: "available",
			activeKey,
			type: "line",
			onChange: _handleTabChange,
			renderTabBar: platform === "h5" ? renderTabBar : void 0,
			items: [{
				key: KEYS.available,
				label: _pisell_utils.locales.getText("wallet-pass-gallery.available"),
				children: renderAvaliableList(),
				badge: ((_getAvailableList$dat2 = _getAvailableList.data) === null || _getAvailableList$dat2 === void 0 ? void 0 : _getAvailableList$dat2.count) || 0
			}, {
				key: KEYS.unavailable,
				label: _pisell_utils.locales.getText("wallet-pass-gallery.unavailable"),
				children: renderUnavailableList(),
				badge: ((_getUnavailableList$d2 = _getUnavailableList.data) === null || _getUnavailableList$d2 === void 0 ? void 0 : _getUnavailableList$d2.count) || 0
			}],
			tabBarExtraContent: platform === "pc" && !hideAddButton ? /* @__PURE__ */ react.default.createElement(antd.Button, {
				icon: /* @__PURE__ */ react.default.createElement(_pisell_materials.Icon, { type: "pisell2-plus" }),
				size: "large",
				onClick: handleAddClick
			}, _pisell_utils.locales.getText("wallet-pass-gallery.add")) : null
		}));
	};
	const renderPcContent = () => {
		return /* @__PURE__ */ react.default.createElement("div", null, _pcTitle, renderContent());
	};
	const renderSearchCard = (item, index) => {
		const { id, product_name = "", balance = 0, code = "", encoded = "", expire_date = "", shop, limit_status, product_cover = "", unified_available_status, unified_messages = {}, par_value = "", tag = "" } = item, rest = require_objectWithoutProperties._objectWithoutProperties(item, _excluded);
		const { title = "" } = unified_messages;
		const { name = "" } = shop;
		const isActive = id === (currentUnbindItem === null || currentUnbindItem === void 0 ? void 0 : currentUnbindItem.id) && platform === "pc";
		const isDisabled = unified_available_status === 0;
		const isDiscountCard = tag === "product_discount_card";
		const getBalanceTitle = () => {
			if (tag === "point_card") return _pisell_utils.locales.getText("wallet-pass-gallery.points");
			else if (tag === "good_pass") return _pisell_utils.locales.getText("wallet-pass-gallery.goodPass");
		};
		return /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellWalletPassCard, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, rest), {}, {
			id,
			type: tag,
			key: id,
			balanceTitle: getBalanceTitle(),
			showDetail: false,
			showRedeem: false,
			showQrCode: false,
			cover: product_cover,
			disabled: isDisabled,
			showDisabledReason: isDisabled,
			disabledReason: title,
			propStyle: { marginBottom: 10 },
			showBalanceSymbol: !["point_card", "good_pass"].includes(tag),
			showBalance: tag !== "product_discount_card",
			active: isActive,
			name: product_name,
			qrCode: code,
			storeName: name,
			balance: Number(balance),
			code: encoded,
			discount: Number(par_value),
			showDiscount: isDiscountCard,
			validDate: expire_date,
			onClick: () => setCurrentUnbindItem(item),
			style: {
				cursor: "pointer",
				width: "100%",
				marginTop: 8
			}
		}));
	};
	const renderH5Content = () => {
		var _utils$isApp, _utils$translation2, _getWalletDetail$data2;
		const _walletBar = !(utils === null || utils === void 0 || (_utils$isApp = utils.isApp) === null || _utils$isApp === void 0 ? void 0 : _utils$isApp.call(utils)) && !hideHeader && /* @__PURE__ */ react.default.createElement("div", { className: "pisell-wallet-pass-gallery-bar" }, /* @__PURE__ */ react.default.createElement("div", {
			className: "pisell-wallet-pass-gallery-header-bar-arrow",
			onClick: () => {
				history.back();
			}
		}, /* @__PURE__ */ react.default.createElement(_pisell_materials.Icon, { type: "pisell2-chevron-left" })), /* @__PURE__ */ react.default.createElement("span", { className: "header-title" }, (utils === null || utils === void 0 || (_utils$translation2 = utils.translation) === null || _utils$translation2 === void 0 ? void 0 : _utils$translation2.call(utils, (_getWalletDetail$data2 = _getWalletDetail.data) === null || _getWalletDetail$data2 === void 0 || (_getWalletDetail$data2 = _getWalletDetail$data2.data) === null || _getWalletDetail$data2 === void 0 ? void 0 : _getWalletDetail$data2.name)) || _pisell_utils.locales.getText("wallet-pass-gallery.wallet")));
		return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, _walletBar, renderContent(), hideAddButton ? null : /* @__PURE__ */ react.default.createElement("div", { style: { padding: 24 } }, /* @__PURE__ */ react.default.createElement(antd.Button, {
			size: "large",
			onClick: handleAddClick,
			block: true
		}, _pisell_utils.locales.getText("wallet-pass-gallery.button.add"))), /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellModal, {
			zIndex: 997,
			destroyOnClose: true,
			platform,
			visible: !!_currentItem,
			onCancel: () => setCurrentItemId(""),
			footer: null,
			title: _pisell_utils.locales.getText("wallet-pass-gallery.details")
		}, /* @__PURE__ */ react.default.createElement(require_index$3.default, {
			dataSource: _currentItem,
			platform,
			onListRefresh: listReload
		})));
	};
	return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("pisell-wallet-pass-gallery", `pisell-wallet-pass-gallery-${platform}`) }, platform === "pc" ? renderPcContent() : renderH5Content()), /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellModal, {
		title: _pisell_utils.locales.getText("wallet-pass-gallery.add"),
		platform: platform === "pc" ? "pc" : "h5",
		mobileModalHeight: "auto",
		open: isOpenAddModal,
		onCancel: () => setIsOpenAddModal(false),
		cancelVisible: false,
		destroyOnClose: true,
		okText: _pisell_utils.locales.getText("wallet-pass-gallery.confirm"),
		okButtonProps: { disabled: !(currentUnbindItem === null || currentUnbindItem === void 0 ? void 0 : currentUnbindItem.code) },
		onOk: _handleBind
	}, /* @__PURE__ */ react.default.createElement("div", { style: { margin: "24px 0" } }, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellInformationEntry, {
		title: _pisell_utils.locales.getText("wallet-pass-gallery.addModalTitle"),
		entryModes: [{
			type: "scanCode",
			name: _pisell_utils.locales.getText("wallet-pass-gallery.scanBarQrCode")
		}, {
			type: "input",
			name: _pisell_utils.locales.getText("wallet-pass-gallery.enterCodes")
		}],
		searchDescribe: _pisell_utils.locales.getText("wallet-pass-gallery.searchDescribe"),
		onChange: _handleSearchByCode,
		onChangeType: _resetSearchState
	}), (_getUnbindList.data || []).map(renderSearchCard))), !!editHolderData && /* @__PURE__ */ react.default.createElement(require_index$1.default, {
		visible: true,
		onCancel: () => {
			setEditHolderData(null);
		},
		onConfirm: _handleBindHolder,
		confirmLoading: updateHolderLoading,
		formId: editHolderData === null || editHolderData === void 0 ? void 0 : editHolderData.form_id,
		customerId: editHolderData === null || editHolderData === void 0 ? void 0 : editHolderData.customer_id,
		value: editHolderData === null || editHolderData === void 0 ? void 0 : editHolderData.holder_id
	}));
};
//#endregion
exports.default = WalletPassGallery;
