'use strict';

var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var index = require('../packages/ui/dist/index.js');
var VectorEditor_module = require('./VectorEditor.module.css.js');

const VectorEditorMenuBar = ({ api, hasOnSaveToLibrary }) => {
    const { selId, hasClipboard, snapGrid, fInp, shapes, boolSecondShape, newCanvas, setDlgSvg, setBoolSecondShape, exportSVG, exportPNG, exportJPG, exportWebP, exportBMP, undo, redo, duplicateShape, copyShape, pasteShape, deleteShape, bringToFront, sendToBack, flipH, flipV, alignShapes, setSnapGrid, saveToLibrary, unionShapes, subtractShapes, intersectShapes, excludeShapes, outlineStroke, } = api;
    // Check if we can perform boolean ops (need 2 shapes selected)
    const canBool = selId && boolSecondShape && selId !== boolSecondShape;
    return (jsxRuntime.jsxs("div", { className: VectorEditor_module.menuBar, children: [jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: newCanvas, children: "New" }), jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: () => { var _a; return (_a = fInp.current) === null || _a === void 0 ? void 0 : _a.click(); }, children: "Open SVG" }), jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: () => setDlgSvg(true), children: "Paste SVG" }), jsxRuntime.jsx("div", { className: VectorEditor_module.menuSep }), jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: exportSVG, children: "SVG" }), jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: exportPNG, children: "PNG" }), jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: exportJPG, children: "JPG" }), jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: exportWebP, children: "WebP" }), jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: exportBMP, children: "BMP" }), jsxRuntime.jsx("div", { className: VectorEditor_module.menuSep }), jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: undo, children: "Undo" }), jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: redo, children: "Redo" }), jsxRuntime.jsx("div", { className: VectorEditor_module.menuSep }), jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: duplicateShape, disabled: !selId, "aria-label": "Ctrl+D", children: "Dup" }), jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: copyShape, disabled: !selId, "aria-label": "Ctrl+C", children: "Copy" }), jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: pasteShape, disabled: !hasClipboard, "aria-label": "Ctrl+V", children: "Paste" }), jsxRuntime.jsx("div", { className: VectorEditor_module.menuSep }), jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: deleteShape, disabled: !selId, children: "Delete" }), jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: bringToFront, disabled: !selId, children: "\u2191 Front" }), jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: sendToBack, disabled: !selId, children: "\u2193 Back" }), jsxRuntime.jsx("div", { className: VectorEditor_module.menuSep }), jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: flipH, disabled: !selId, "aria-label": "Flip H", children: "\u21D4" }), jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: flipV, disabled: !selId, "aria-label": "Flip V", children: "\u21D5" }), jsxRuntime.jsx("div", { className: VectorEditor_module.menuSep }), jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: () => alignShapes("left"), disabled: !selId, "aria-label": "Align Left", children: "\u25E7" }), jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: () => alignShapes("center"), disabled: !selId, "aria-label": "Align Center", children: "\u25EB" }), jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: () => alignShapes("right"), disabled: !selId, "aria-label": "Align Right", children: "\u25E8" }), jsxRuntime.jsx("div", { className: VectorEditor_module.menuSep }), shapes.length >= 2 && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(index.NiceSelect, { className: VectorEditor_module.menuBtn, value: boolSecondShape || "", onChange: (val) => setBoolSecondShape(val || null), options: [
                            { value: "", label: "2nd Shape" },
                            ...shapes.filter(s => s.id !== selId).map((s, i) => ({ value: s.id, label: `Shape ${i + 1}` })),
                        ], style: { minWidth: 80 } }), jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: unionShapes, disabled: !canBool, "aria-label": "Union", children: "\u222A" }), jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: subtractShapes, disabled: !canBool, "aria-label": "Subtract", children: "\u2212" }), jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: intersectShapes, disabled: !canBool, "aria-label": "Intersect", children: "\u2229" }), jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: excludeShapes, disabled: !canBool, "aria-label": "Exclude", children: "\u2295" }), jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: outlineStroke, disabled: !selId, "aria-label": "Outline Stroke", children: "\u25AD" }), jsxRuntime.jsx("div", { className: VectorEditor_module.menuSep })] })), jsxRuntime.jsxs("label", { className: VectorEditor_module.menuLabel, children: [jsxRuntime.jsx(index.NiceCheckbox, { checked: snapGrid, onChange: () => setSnapGrid((v) => !v) }), "Snap"] }), hasOnSaveToLibrary && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: VectorEditor_module.menuSep }), jsxRuntime.jsx(index.NiceButton, { className: VectorEditor_module.menuBtn, variant: "ghost", size: "sm", onClick: saveToLibrary, children: "\uD83D\uDCE6 Save to Library" })] }))] }));
};
var VectorEditorMenuBar$1 = React.memo(VectorEditorMenuBar);

module.exports = VectorEditorMenuBar$1;
//# sourceMappingURL=VectorEditorMenuBar.js.map
