function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import React, { useEffect, useMemo, useState } from 'react';
import { PisellReservationBookingPage } from "./PisellReservationBookingPage";
import { PisellVenueControlPage } from "./PisellVenueControlPage";
import { PISELL_RESERVATION_BODY_VIEW_STORAGE_KEY } from "./reservationConstants";
import { defaultReservationTableRows, getDefaultReservationFloorMapConfig } from "./floorMap/reservationMock";
var meta = {
  title: 'Plus/PisellReservation',
  component: PisellReservationBookingPage,
  parameters: {
    layout: 'padded',
    docs: {
      description: {
        component: '预约页面（PisellReservationBookingPage）与场控页面（PisellVenueControlPage）共用 PisellReservationCore。桌位 mock 走 dataSources.tables。'
      }
    }
  }
};
export default meta;
/** 给平面图点击「预约详情弹窗」Story 用的：T-2 绑定一条可解析的 raw booking */
function withDemoFloorMapSourceBookings(rows) {
  return rows.map(function (r) {
    return r.id === 't2' ? _objectSpread(_objectSpread({}, 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;
  });
}
export var Default = {
  render: function PisellReservationDefault() {
    var _useState = useState(function () {
        var base = getDefaultReservationFloorMapConfig();
        return _objectSpread(_objectSpread({}, base), {}, {
          sceneElements: base.sceneElements.map(function (el) {
            return _objectSpread({}, el);
          })
        });
      }),
      _useState2 = _slicedToArray(_useState, 2),
      floorMapConfig = _useState2[0],
      setFloorMapConfig = _useState2[1];
    var _useState3 = useState(function () {
        return _toConsumableArray(defaultReservationTableRows);
      }),
      _useState4 = _slicedToArray(_useState3, 2),
      rows = _useState4[0],
      setRows = _useState4[1];
    var floorMap = useMemo(function () {
      return {
        floorMapConfig: floorMapConfig,
        onSave: function onSave(config) {
          // eslint-disable-next-line no-console
          console.log('[PisellReservation story] floor save', config);
          setFloorMapConfig(config);
        },
        onDataSourceRecordSave: function onDataSourceRecordSave(dataSourceKey, id, newData) {
          // eslint-disable-next-line no-console
          console.log('[PisellReservation story] record save', {
            dataSourceKey: dataSourceKey,
            id: id,
            newData: newData
          });
          setRows(function (prev) {
            return prev.map(function (r) {
              return r.id === id ? _objectSpread(_objectSpread({}, r), newData) : r;
            });
          });
        }
      };
    }, [floorMapConfig]);
    return /*#__PURE__*/React.createElement("div", {
      style: {
        height: 560
      }
    }, /*#__PURE__*/React.createElement(PisellReservationBookingPage, {
      floorPlanId: null,
      dataSources: {
        tables: rows
      },
      floorMap: floorMap,
      onNewReservation: function onNewReservation() {
        // eslint-disable-next-line no-console
        console.log('[PisellReservation story] new reservation');
      },
      fab: /*#__PURE__*/React.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)")
    }));
  }
};

/** 通过 localStorage 模拟「上次停留在表格」 */
function GridFirstStoryHost() {
  useEffect(function () {
    return function () {
      try {
        localStorage.removeItem(PISELL_RESERVATION_BODY_VIEW_STORAGE_KEY);
      } catch (_unused) {
        /* ignore */
      }
    };
  }, []);
  if (typeof window !== 'undefined') {
    localStorage.setItem(PISELL_RESERVATION_BODY_VIEW_STORAGE_KEY, 'grid');
  }
  return /*#__PURE__*/React.createElement("div", {
    style: {
      height: 520
    }
  }, /*#__PURE__*/React.createElement(PisellReservationBookingPage, {
    floorPlanId: null
  }));
}
export var GridFirst = {
  render: function render() {
    return /*#__PURE__*/React.createElement(GridFirstStoryHost, null);
  }
};

/**
 * 直接进平面图 + 内置预约详情弹窗：点击画布上 **T-2** 桌位即可打开弹窗（mock 带 floorMapSourceBookings）。
 * 内置分流依赖引擎 `shop_id`：非 2155 走弹窗；2155 走宿主结账抽屉（Story 无引擎时多为弹窗）。
 */
export var FloorMapBookingDetailModal = {
  render: function PisellReservationFloorDetailModal() {
    var _useState5 = useState(function () {
        var base = getDefaultReservationFloorMapConfig();
        return _objectSpread(_objectSpread({}, base), {}, {
          sceneElements: base.sceneElements.map(function (el) {
            return _objectSpread({}, el);
          })
        });
      }),
      _useState6 = _slicedToArray(_useState5, 2),
      floorMapConfig = _useState6[0],
      setFloorMapConfig = _useState6[1];
    var _useState7 = useState(function () {
        return withDemoFloorMapSourceBookings(_toConsumableArray(defaultReservationTableRows));
      }),
      _useState8 = _slicedToArray(_useState7, 1),
      rows = _useState8[0];
    var floorMap = useMemo(function () {
      return {
        floorMapConfig: floorMapConfig,
        onSave: function onSave(config) {
          setFloorMapConfig(config);
        }
      };
    }, [floorMapConfig]);
    return /*#__PURE__*/React.createElement("div", {
      style: {
        height: 640
      }
    }, /*#__PURE__*/React.createElement(PisellReservationBookingPage, {
      floorPlanId: null,
      dataSources: {
        tables: rows
      },
      floorMap: floorMap
    }));
  }
};

/** 场控：仅平面图、锁日、HUD 点开窄屏表抽屉 */
export var VenueControl = {
  render: function VenueControlStory() {
    var _useState9 = useState(function () {
        var base = getDefaultReservationFloorMapConfig();
        return _objectSpread(_objectSpread({}, base), {}, {
          sceneElements: base.sceneElements.map(function (el) {
            return _objectSpread({}, el);
          })
        });
      }),
      _useState10 = _slicedToArray(_useState9, 2),
      floorMapConfig = _useState10[0],
      setFloorMapConfig = _useState10[1];
    var _useState11 = useState(function () {
        return _toConsumableArray(defaultReservationTableRows);
      }),
      _useState12 = _slicedToArray(_useState11, 2),
      rows = _useState12[0],
      setRows = _useState12[1];
    var floorMap = useMemo(function () {
      return {
        floorMapConfig: floorMapConfig,
        onSave: function onSave(config) {
          setFloorMapConfig(config);
        },
        onDataSourceRecordSave: function onDataSourceRecordSave(dataSourceKey, id, newData) {
          setRows(function (prev) {
            return prev.map(function (r) {
              return r.id === id ? _objectSpread(_objectSpread({}, r), newData) : r;
            });
          });
        }
      };
    }, [floorMapConfig]);
    return /*#__PURE__*/React.createElement("div", {
      style: {
        height: 560
      }
    }, /*#__PURE__*/React.createElement(PisellVenueControlPage, {
      floorPlanId: null,
      dataSources: {
        tables: rows
      },
      floorMap: floorMap
    }));
  }
};