require("../../../_virtual/_rolldown/runtime.js");
const require_useEngineContext = require("../../../hooks/useEngineContext.js");
let react = require("react");
//#region src/components/pisellInformationEntry/hooks/useTerminalPeripherals.ts
const useTerminalPeripherals = (onChange) => {
	var _context$appHelper;
	const { interaction } = ((_context$appHelper = require_useEngineContext.default().appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils) || {};
	const [peripheralsStatus, setPeripheralsStatus] = (0, react.useState)({
		scanner: "none",
		nfc: "none"
	});
	(0, react.useEffect)(() => {
		var _interaction$utils, _interaction$utils$mo, _interaction$utils2, _interaction$utils2$p, _interaction$utils3, _interaction$utils3$m;
		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, "global", "peripheralsResult", (strVal) => {
			try {
				const val = JSON.parse(strVal);
				onChange === null || onChange === void 0 || onChange(val.value);
			} catch (err) {
				console.error(err);
			}
		});
		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: "global",
			key: "get_peripherals_status",
			data: {}
		});
		interaction === null || interaction === void 0 || (_interaction$utils3 = interaction.utils) === null || _interaction$utils3 === void 0 || (_interaction$utils3$m = _interaction$utils3.mountFunction) === null || _interaction$utils3$m === void 0 || _interaction$utils3$m.call(_interaction$utils3, "global", "peripheralsStatus", (strPeripherals) => {
			try {
				setPeripheralsStatus(JSON.parse(strPeripherals));
			} catch (err) {
				console.error(err);
			}
		});
	}, []);
	return { peripheralsStatus };
};
//#endregion
exports.default = useTerminalPeripherals;
