"use strict";
// -*- mode: typescript; indent-tabs-mode: nil; js-basic-offset: 4 -*-
//
// This file is part of Genie
//
// Copyright 2020 The Board of Trustees of the Leland Stanford Junior University
//
// 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.
//
// Author: Giovanni Campagna <gcampagn@cs.stanford.edu>
Object.defineProperty(exports, "__esModule", { value: true });
const thingtalk_1 = require("thingtalk");
var ValueCategory;
(function (ValueCategory) {
    ValueCategory[ValueCategory["YesNo"] = 0] = "YesNo";
    ValueCategory[ValueCategory["MultipleChoice"] = 1] = "MultipleChoice";
    ValueCategory[ValueCategory["Number"] = 2] = "Number";
    ValueCategory[ValueCategory["Measure"] = 3] = "Measure";
    ValueCategory[ValueCategory["RawString"] = 4] = "RawString";
    ValueCategory[ValueCategory["Password"] = 5] = "Password";
    ValueCategory[ValueCategory["Date"] = 6] = "Date";
    ValueCategory[ValueCategory["Time"] = 7] = "Time";
    ValueCategory[ValueCategory["Unknown"] = 8] = "Unknown";
    ValueCategory[ValueCategory["Picture"] = 9] = "Picture";
    ValueCategory[ValueCategory["Location"] = 10] = "Location";
    ValueCategory[ValueCategory["PhoneNumber"] = 11] = "PhoneNumber";
    ValueCategory[ValueCategory["EmailAddress"] = 12] = "EmailAddress";
    ValueCategory[ValueCategory["Contact"] = 13] = "Contact";
    ValueCategory[ValueCategory["Command"] = 14] = "Command";
})(ValueCategory || (ValueCategory = {}));
exports.default = ValueCategory;
(function (ValueCategory) {
    function fromType(type) {
        if (type instanceof thingtalk_1.Type.Entity && type.type === 'tt:picture')
            return ValueCategory.Picture;
        else if (type instanceof thingtalk_1.Type.Entity && type.type === 'tt:phone_number')
            return ValueCategory.PhoneNumber;
        else if (type instanceof thingtalk_1.Type.Entity && type.type === 'tt:email_address')
            return ValueCategory.EmailAddress;
        else if (type instanceof thingtalk_1.Type.Entity && type.type === 'tt:contact')
            return ValueCategory.Contact;
        else if (type instanceof thingtalk_1.Type.Entity)
            return ValueCategory.RawString;
        else if (type.isBoolean)
            return ValueCategory.YesNo;
        else if (type.isString)
            return ValueCategory.RawString;
        else if (type.isNumber)
            return ValueCategory.Number;
        else if (type.isMeasure)
            return ValueCategory.Measure;
        else if (type.isEnum)
            return ValueCategory.RawString;
        else if (type.isTime)
            return ValueCategory.Time;
        else if (type.isDate)
            return ValueCategory.Date;
        else if (type.isLocation)
            return ValueCategory.Location;
        else
            return ValueCategory.Unknown;
    }
    ValueCategory.fromType = fromType;
    function fromValue(value) {
        if (value.isVarRef)
            return ValueCategory.Unknown;
        const type = value.getType();
        return fromType(type);
    }
    ValueCategory.fromValue = fromValue;
    function toAskSpecial(expected) {
        let what;
        if (expected === ValueCategory.YesNo)
            what = 'yesno';
        else if (expected === ValueCategory.Location)
            what = 'location';
        else if (expected === ValueCategory.Picture)
            what = 'picture';
        else if (expected === ValueCategory.PhoneNumber)
            what = 'phone_number';
        else if (expected === ValueCategory.EmailAddress)
            what = 'email_address';
        else if (expected === ValueCategory.Contact)
            what = 'contact';
        else if (expected === ValueCategory.Number)
            what = 'number';
        else if (expected === ValueCategory.Date)
            what = 'date';
        else if (expected === ValueCategory.Time)
            what = 'time';
        else if (expected === ValueCategory.RawString)
            what = 'raw_string';
        else if (expected === ValueCategory.Password)
            what = 'password';
        else if (expected === ValueCategory.MultipleChoice)
            what = 'choice';
        else if (expected === ValueCategory.Command)
            what = 'command';
        else if (expected !== null)
            what = 'generic';
        else
            what = null;
        return what;
    }
    ValueCategory.toAskSpecial = toAskSpecial;
})(ValueCategory || (ValueCategory = {}));
//# sourceMappingURL=value-category.js.map