"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CmptAction = void 0;
var tslib_1 = require("tslib");
var Action_1 = require("./Action");
/**
 * 组件动作
 *
 * @export
 * @class CmptAction
 * @implements {Action}
 */
var CmptAction = /** @class */ (function () {
    function CmptAction() {
    }
    CmptAction.prototype.run = function (action, renderer, event) {
        var _a, _b, _c, _d;
        return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
            var component;
            return (0, tslib_1.__generator)(this, function (_e) {
                switch (_e.label) {
                    case 0:
                        component = renderer.props.$schema.id !== action.componentId
                            ? (_a = renderer.props.scoped) === null || _a === void 0 ? void 0 : _a.getComponentById(action.componentId)
                            : renderer;
                        return [4 /*yield*/, ((_c = (_b = component.props).onAction) === null || _c === void 0 ? void 0 : _c.call(_b, event, action, action.args))];
                    case 1:
                        // 执行组件动作
                        (_e.sent()) ||
                            ((_d = component.doAction) === null || _d === void 0 ? void 0 : _d.call(component, action, action.args));
                        return [2 /*return*/];
                }
            });
        });
    };
    return CmptAction;
}());
exports.CmptAction = CmptAction;
(0, Action_1.registerAction)('component', new CmptAction());
//# sourceMappingURL=./actions/CmptAction.js.map
