import { __esDecorate, __runInitializers } from "tslib";
import { MessagePriority } from "@zwave-js/core";
import { FunctionType, Message, MessageType, expectedResponse, messageTypes, priority, } from "@zwave-js/serial";
let GetProtocolVersionRequest = (() => {
    let _classDecorators = [messageTypes(MessageType.Request, FunctionType.GetProtocolVersion), priority(MessagePriority.Controller), expectedResponse(FunctionType.GetProtocolVersion)];
    let _classDescriptor;
    let _classExtraInitializers = [];
    let _classThis;
    let _classSuper = Message;
    var GetProtocolVersionRequest = class extends _classSuper {
        static { _classThis = this; }
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
            GetProtocolVersionRequest = _classThis = _classDescriptor.value;
            if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
            __runInitializers(_classThis, _classExtraInitializers);
        }
    };
    return GetProtocolVersionRequest = _classThis;
})();
export { GetProtocolVersionRequest };
let GetProtocolVersionResponse = (() => {
    let _classDecorators = [messageTypes(MessageType.Response, FunctionType.GetProtocolVersion)];
    let _classDescriptor;
    let _classExtraInitializers = [];
    let _classThis;
    let _classSuper = Message;
    var GetProtocolVersionResponse = class extends _classSuper {
        static { _classThis = this; }
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
            GetProtocolVersionResponse = _classThis = _classDescriptor.value;
            if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
            __runInitializers(_classThis, _classExtraInitializers);
        }
        constructor(options) {
            super(options);
            // TODO: Check implementation:
            this.protocolType = options.protocolType;
            this.protocolVersion = options.protocolVersion;
            this.applicationFrameworkBuildNumber =
                options.applicationFrameworkBuildNumber;
            this.gitCommitHash = options.gitCommitHash;
        }
        static from(raw, _ctx) {
            const protocolType = raw.payload[0];
            const protocolVersion = [
                raw.payload[1],
                raw.payload[2],
                raw.payload[3],
            ].join(".");
            let applicationFrameworkBuildNumber;
            if (raw.payload.length >= 6) {
                const appBuild = raw.payload.readUInt16BE(4);
                if (appBuild !== 0)
                    applicationFrameworkBuildNumber = appBuild;
            }
            let gitCommitHash;
            if (raw.payload.length >= 22) {
                const commitHash = raw.payload.subarray(6, 22);
                if (!commitHash.every((b) => b === 0)) {
                    gitCommitHash = commitHash.toString("hex");
                }
            }
            return new this({
                protocolType,
                protocolVersion,
                applicationFrameworkBuildNumber,
                gitCommitHash,
            });
        }
        protocolType;
        protocolVersion;
        applicationFrameworkBuildNumber;
        gitCommitHash;
    };
    return GetProtocolVersionResponse = _classThis;
})();
export { GetProtocolVersionResponse };
//# sourceMappingURL=GetProtocolVersionMessages.js.map