"use strict";
/* Copyright 2015 Bloomberg Finance L.P.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const widgets = __importStar(require("@jupyter-widgets/base"));
const BaseModel_1 = require("./BaseModel");
const serialize = __importStar(require("./serialize"));
const version_1 = require("./version");
class AxisModel extends BaseModel_1.BaseModel {
    defaults() {
        return Object.assign({}, widgets.WidgetModel.prototype.defaults(), { _model_name: "AxisModel", _view_name: "Axis", _model_module: "bqplot", _view_module: "bqplot", _model_module_version: version_1.semver_range, _view_module_version: version_1.semver_range, orientation: "horizontal", side: null, label: "", grid_lines: "solid", tick_format: null, scale: undefined, num_ticks: null, tick_values: [], offset: {}, label_location: "middle", label_color: null, grid_color: null, color: null, label_offset: null, visible: true, tick_style: {}, tick_rotate: 0 });
    }
    initialize(attributes, options) {
        super.initialize(attributes, options);
        this.on("change:side", this.validate_orientation, this);
        this.on("change:orientation", this.validate_side, this);
        this.validate_orientation();
        this.validate_side();
    }
    validate_side() {
        const orientation = this.get("orientation");
        let side = this.get("side");
        if (orientation === "vertical") {
            if (side !== "left" && side !== "right") {
                this.set("side", "left");
            }
        }
        else {
            if (side !== "bottom" && side !== "top") {
                this.set("side", "bottom");
            }
        }
        this.save_changes();
    }
    validate_orientation() {
        const side = this.get("side");
        if (side) {
            if (side === "left" || side === "right") {
                this.set("orientation", "vertical");
            }
            else {
                this.set("orientation", "horizontal");
            }
            this.save_changes();
        }
    }
}
AxisModel.serializers = Object.assign({}, widgets.WidgetModel.serializers, { scale: { deserialize: widgets.unpack_models }, offset: { deserialize: widgets.unpack_models }, tick_values: serialize.array_or_json });
exports.AxisModel = AxisModel;
class ColorAxisModel extends AxisModel {
    defaults() {
        return Object.assign({}, AxisModel.prototype.defaults(), { _model_name: "ColorAxisModel", _view_name: "ColorAxis" });
    }
}
exports.ColorAxisModel = ColorAxisModel;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQXhpc01vZGVsLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL0F4aXNNb2RlbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7Ozs7Ozs7Ozs7Ozs7R0FhRzs7Ozs7Ozs7O0FBRUgsK0RBQWlEO0FBQ2pELDJDQUF3QztBQUN4Qyx1REFBeUM7QUFDekMsdUNBQXlDO0FBRXpDLE1BQWEsU0FBVSxTQUFRLHFCQUFTO0lBRXBDLFFBQVE7UUFDSix5QkFBVyxPQUFPLENBQUMsV0FBVyxDQUFDLFNBQVMsQ0FBQyxRQUFRLEVBQUUsSUFDL0MsV0FBVyxFQUFFLFdBQVcsRUFDeEIsVUFBVSxFQUFFLE1BQU0sRUFDbEIsYUFBYSxFQUFFLFFBQVEsRUFDdkIsWUFBWSxFQUFFLFFBQVEsRUFDdEIscUJBQXFCLEVBQUUsc0JBQVksRUFDbkMsb0JBQW9CLEVBQUUsc0JBQVksRUFFbEMsV0FBVyxFQUFFLFlBQVksRUFDekIsSUFBSSxFQUFFLElBQUksRUFDVixLQUFLLEVBQUUsRUFBRSxFQUNULFVBQVUsRUFBRSxPQUFPLEVBQ25CLFdBQVcsRUFBRSxJQUFJLEVBQ2pCLEtBQUssRUFBRSxTQUFTLEVBQ2hCLFNBQVMsRUFBRSxJQUFJLEVBQ2YsV0FBVyxFQUFFLEVBQUUsRUFD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