"use strict";
/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module AccuDraw
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.AccuDrawWidget = exports.AccuDrawWidgetControl = void 0;
const React = require("react");
const core_react_1 = require("@itwin/core-react");
const AccuDrawFieldContainer_1 = require("./AccuDrawFieldContainer");
const WidgetControl_1 = require("../widgets/WidgetControl");
const UiFramework_1 = require("../UiFramework");
/** AccuDraw Widget Control
 * @beta
 */
class AccuDrawWidgetControl extends WidgetControl_1.WidgetControl {
    static get label() {
        return UiFramework_1.UiFramework.translate("accuDraw.dialogTitle");
    }
    constructor(info, options) {
        super(info, options);
        this.reactNode = React.createElement(AccuDrawWidget, null);
    }
}
exports.AccuDrawWidgetControl = AccuDrawWidgetControl;
AccuDrawWidgetControl.id = "AccuDrawWidget";
/** AccuDraw Widget displays [[AccuDrawFieldContainer]] for AccuDraw Ui
 * @beta
 */
function AccuDrawWidget() {
    const [orientation, setOrientation] = React.useState(core_react_1.Orientation.Vertical);
    const breakpoint = 400;
    const handleResize = React.useCallback((w, _h) => {
        setOrientation(w <= breakpoint ? core_react_1.Orientation.Vertical : core_react_1.Orientation.Horizontal);
    }, []);
    const ref = (0, core_react_1.useResizeObserver)(handleResize);
    return (React.createElement("div", { ref: ref },
        React.createElement(AccuDrawFieldContainer_1.AccuDrawFieldContainer, { orientation: orientation })));
}
exports.AccuDrawWidget = AccuDrawWidget;
//# sourceMappingURL=AccuDrawWidget.js.map