"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
var $ = require("jquery");
var React = require("react");
var antd_1 = require("antd");
// @ts-ignore
var zh_ch = antd.locales.zh_CN;
function PageFix(diff, className) {
    if (diff === void 0) { diff = 0.1; }
    if (className === void 0) { className = ''; }
    $(document.body).css({
        width: 1920,
        height: 1080,
        transformOrigin: 'top left'
    });
    document.body.style.width = '1920px';
    if (className) {
        $('#root').addClass(className);
    }
    var min = 0.5625 - diff;
    var max = 0.5625 + diff;
    var resize = function () {
        var tW = window.innerWidth;
        var tH = window.innerHeight;
        var scale = tH / tW;
        if (min <= scale && scale <= max) {
            $(document.body).css('transform', 'scale(' + tW / 1920 + ',' + tH / 1080 + ')');
            $(document.body).css('margin-left', 0);
            $(document.body).css('margin-top', 0);
        }
        else if (scale > max) {
            $(document.body).css('transform', 'scale(' + tW / 1920 + ')');
            $(document.body).css('margin-left', 0);
            $(document.body).css('margin-top', (tH / (tW / 1920) - 1080) / 2 * tW / 1920 + 'px');
        }
        else {
            $(document.body).css('transform', 'scale(' + tH / 1080 + ')');
            $(document.body).css('margin-left', (tW / (tH / 1080) - 1920) / 2 * tH / 1080 + 'px');
            $(document.body).css('margin-top', 0);
        }
    };
    resize();
    $(window).on('resize', resize);
}
/**
 * 大屏组件根节点，用 <Page> 包住后，可实现自动resize，收放
*/
var default_1 = /** @class */ (function (_super) {
    __extends(default_1, _super);
    function default_1() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    default_1.prototype.componentDidMount = function () {
        PageFix(this.props.diff, this.props.className);
    };
    default_1.prototype.render = function () {
        return React.createElement(antd_1.LocaleProvider, { locale: zh_ch }, this.props.children);
    };
    return default_1;
}(React.PureComponent));
exports.default = default_1;
