var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/plus/pisellReservation/PisellReservation.stories.tsx
var PisellReservation_stories_exports = {};
__export(PisellReservation_stories_exports, {
  Default: () => Default,
  FloorMapBookingDetailModal: () => FloorMapBookingDetailModal,
  GridFirst: () => GridFirst,
  VenueControl: () => VenueControl,
  default: () => PisellReservation_stories_default
});
module.exports = __toCommonJS(PisellReservation_stories_exports);
var import_react = __toESM(require("react"));
var import_PisellReservationBookingPage = require("./PisellReservationBookingPage");
var import_PisellVenueControlPage = require("./PisellVenueControlPage");
var import_reservationConstants = require("./reservationConstants");
var import_reservationMock = require("./floorMap/reservationMock");
var meta = {
  title: "Plus/PisellReservation",
  component: import_PisellReservationBookingPage.PisellReservationBookingPage,
  parameters: {
    layout: "padded",
    docs: {
      description: {
        component: "预约页面（PisellReservationBookingPage）与场控页面（PisellVenueControlPage）共用 PisellReservationCore。桌位 mock 走 dataSources.tables。"
      }
    }
  }
};
var PisellReservation_stories_default = meta;
function withDemoFloorMapSourceBookings(rows) {
  return rows.map(
    (r) => r.id === "t2" ? {
      ...r,
      floorMapSourceBookings: [
        {
          id: "story-booking-1",
          booking_id: "story-booking-1",
          relation_form_name: "Story · 预约详情弹窗示例",
          status: "started",
          start_at: "2026-03-31T16:40:00",
          end_at: "2026-03-31T17:40:00",
          notes: "这是 Story 里的备注示例。",
          products: [{ sku: "demo-a" }, { sku: "demo-b" }],
          order: {
            status: "open",
            currency_symbol: "$",
            total_amount: 60.3,
            payment_status: "unpaid",
            summary: {
              total_amount: 60.3,
              amount_gap: 24.5,
              product_quantity: 2
            },
            items: [
              {
                name: "定金测试-预约普通商品",
                quantity: 1,
                price: 12
              }
            ]
          }
        }
      ]
    } : r
  );
}
var Default = {
  render: function PisellReservationDefault() {
    const [floorMapConfig, setFloorMapConfig] = (0, import_react.useState)(() => {
      const base = (0, import_reservationMock.getDefaultReservationFloorMapConfig)();
      return {
        ...base,
        sceneElements: base.sceneElements.map((el) => ({ ...el }))
      };
    });
    const [rows, setRows] = (0, import_react.useState)(() => [...import_reservationMock.defaultReservationTableRows]);
    const floorMap = (0, import_react.useMemo)(
      () => ({
        floorMapConfig,
        onSave: (config) => {
          console.log("[PisellReservation story] floor save", config);
          setFloorMapConfig(config);
        },
        onDataSourceRecordSave: (dataSourceKey, id, newData) => {
          console.log("[PisellReservation story] record save", {
            dataSourceKey,
            id,
            newData
          });
          setRows(
            (prev) => prev.map((r) => r.id === id ? { ...r, ...newData } : r)
          );
        }
      }),
      [floorMapConfig]
    );
    return /* @__PURE__ */ import_react.default.createElement("div", { style: { height: 560 } }, /* @__PURE__ */ import_react.default.createElement(
      import_PisellReservationBookingPage.PisellReservationBookingPage,
      {
        floorPlanId: null,
        dataSources: { tables: rows },
        floorMap,
        onNewReservation: () => {
          console.log("[PisellReservation story] new reservation");
        },
        fab: /* @__PURE__ */ import_react.default.createElement(
          "button",
          {
            type: "button",
            style: {
              padding: "12px 20px",
              borderRadius: 24,
              border: "none",
              fontWeight: 700,
              background: "#fa8c16",
              color: "#fff",
              cursor: "pointer",
              boxShadow: "0 4px 12px rgba(250, 140, 22, 0.45)"
            }
          },
          "Payment Due (8)"
        )
      }
    ));
  }
};
function GridFirstStoryHost() {
  (0, import_react.useEffect)(() => {
    return () => {
      try {
        localStorage.removeItem(import_reservationConstants.PISELL_RESERVATION_BODY_VIEW_STORAGE_KEY);
      } catch {
      }
    };
  }, []);
  if (typeof window !== "undefined") {
    localStorage.setItem(import_reservationConstants.PISELL_RESERVATION_BODY_VIEW_STORAGE_KEY, "grid");
  }
  return /* @__PURE__ */ import_react.default.createElement("div", { style: { height: 520 } }, /* @__PURE__ */ import_react.default.createElement(import_PisellReservationBookingPage.PisellReservationBookingPage, { floorPlanId: null }));
}
var GridFirst = {
  render: () => /* @__PURE__ */ import_react.default.createElement(GridFirstStoryHost, null)
};
var FloorMapBookingDetailModal = {
  render: function PisellReservationFloorDetailModal() {
    const [floorMapConfig, setFloorMapConfig] = (0, import_react.useState)(() => {
      const base = (0, import_reservationMock.getDefaultReservationFloorMapConfig)();
      return {
        ...base,
        sceneElements: base.sceneElements.map((el) => ({ ...el }))
      };
    });
    const [rows] = (0, import_react.useState)(
      () => withDemoFloorMapSourceBookings([...import_reservationMock.defaultReservationTableRows])
    );
    const floorMap = (0, import_react.useMemo)(
      () => ({
        floorMapConfig,
        onSave: (config) => {
          setFloorMapConfig(config);
        }
      }),
      [floorMapConfig]
    );
    return /* @__PURE__ */ import_react.default.createElement("div", { style: { height: 640 } }, /* @__PURE__ */ import_react.default.createElement(
      import_PisellReservationBookingPage.PisellReservationBookingPage,
      {
        floorPlanId: null,
        dataSources: { tables: rows },
        floorMap
      }
    ));
  }
};
var VenueControl = {
  render: function VenueControlStory() {
    const [floorMapConfig, setFloorMapConfig] = (0, import_react.useState)(() => {
      const base = (0, import_reservationMock.getDefaultReservationFloorMapConfig)();
      return {
        ...base,
        sceneElements: base.sceneElements.map((el) => ({ ...el }))
      };
    });
    const [rows, setRows] = (0, import_react.useState)(() => [...import_reservationMock.defaultReservationTableRows]);
    const floorMap = (0, import_react.useMemo)(
      () => ({
        floorMapConfig,
        onSave: (config) => {
          setFloorMapConfig(config);
        },
        onDataSourceRecordSave: (dataSourceKey, id, newData) => {
          setRows(
            (prev) => prev.map((r) => r.id === id ? { ...r, ...newData } : r)
          );
        }
      }),
      [floorMapConfig]
    );
    return /* @__PURE__ */ import_react.default.createElement("div", { style: { height: 560 } }, /* @__PURE__ */ import_react.default.createElement(
      import_PisellVenueControlPage.PisellVenueControlPage,
      {
        floorPlanId: null,
        dataSources: { tables: rows },
        floorMap
      }
    ));
  }
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  Default,
  FloorMapBookingDetailModal,
  GridFirst,
  VenueControl
});
