const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_useEngineContext = require("../../../hooks/useEngineContext.js");
const require_index = require("../Cart/index.js");
const require_utils = require("./utils.js");
const require_index$1 = require("../Init/index.js");
const require_serve = require("./serve.js");
let react = require("react");
react = require_runtime.__toESM(react);
//#region src/components/Sales/Summary/index.tsx
const defaultState = {};
const SummaryContext = (0, react.createContext)(void 0);
const SummaryProvider = ({ children }) => {
	const pisellos = require_useEngineContext.usePisellOS();
	const { cartData } = require_index.useCart();
	const { initData } = require_index$1.useInit();
	const [isAgreeDepositPolicy, setIsAgreeDepositPolicy] = (0, react.useState)(false);
	const summaryModule = pisellos.getModule("summary");
	const summaryData = (0, react.useMemo)(() => {
		return require_utils.calculatePriceDetails((initData === null || initData === void 0 ? void 0 : initData.shop) || {}, cartData.cartItems, summaryModule);
	}, [
		cartData.cartItems,
		initData === null || initData === void 0 ? void 0 : initData.shop,
		summaryModule
	]);
	const contextValue = {
		subtotal: summaryData.subtotal,
		total: summaryData.total,
		taxTitle: summaryData.taxTitle,
		totalTaxFee: summaryData.totalTaxFee,
		isPriceIncludeTax: summaryData.isPriceIncludeTax,
		taxRate: summaryData.taxRate,
		surcharge: summaryData.surcharge,
		deposit: summaryData.deposit,
		isAgreeDepositPolicy,
		setIsAgreeDepositPolicy,
		getDepositProtocol: require_serve.getDepositProtocolApi
	};
	return /* @__PURE__ */ react.default.createElement(SummaryContext.Provider, { value: contextValue }, children);
};
/**
* 使用步骤管理的Hook
* @throws {Error} 如果在StepProvider外部使用会抛出错误
* @returns {StepContextType} 步骤管理上下文
*/
const useSummary = () => {
	const context = react.default.useContext(SummaryContext);
	if (!context) throw new Error("useSummary must be used within a SummaryProvider");
	return context;
};
var Summary_default = { defaultState };
//#endregion
exports.SummaryProvider = SummaryProvider;
exports.default = Summary_default;
exports.useSummary = useSummary;
