"use strict";
// -*- mode: js; 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>
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
// Slot fill templates: the agent asks a question, and the user replies
//
// There are two types slot-fill templates:
// - for searches: the agent is trying to add a filter
// - for actions/queries w/ parameters: the agent is trying to add a parameter
const thingtalk_1 = require("thingtalk");
const C = __importStar(require("../../ast_manip"));
const D = __importStar(require("../../dialogue_acts"));
async function default_1($runtime, $ttUtils, $options, $locale, $grammar, $loader) {
    $grammar.declareSymbol("one_param_direct_search_question");
    $grammar.addRule("one_param_direct_search_question", ["what", new $runtime.NonTerminal("out_param_Any", ["filterable", (true)]), new $runtime.NonTerminal("prefer_question_phrase", undefined), "?"], (($0, p, $1, $2) => {
        if (p.name === 'id')
            return null;
        if (!p.filterable)
            return null;
        return [p];
    }), C.paramArrayKeyFn, {});
    $grammar.addRule("one_param_direct_search_question", [new $runtime.NonTerminal("thingpedia_search_question", ["filterable", (true)]), "?"], ((p, $0) => {
        if (p.name === 'id')
            return null;
        if (!p.filterable)
            return null;
        return [p];
    }), C.paramArrayKeyFn, {});
    $grammar.declareSymbol("one_param_direct_search_question_with_preamble");
    $grammar.addRule("one_param_direct_search_question_with_preamble", [new $runtime.NonTerminal("search_result_preamble", undefined), new $runtime.NonTerminal("one_param_direct_search_question", undefined)], (($0, question) => question), C.paramArrayKeyFn, {});
    $grammar.declareSymbol("two_param_direct_search_question");
    $grammar.addRule("two_param_direct_search_question", ["what", new $runtime.NonTerminal("out_param_Any", ["filterable", (true)]), "and", new $runtime.NonTerminal("out_param_Any", ["functionName", 1, "functionName"]), new $runtime.NonTerminal("prefer_question_phrase", undefined), "?"], (($0, p1, $1, p2, $2, $3) => {
        if (!C.isSameFunction(p1.schema, p2.schema))
            return null;
        if (p1.name === 'id' || p2.name === 'id' || p1.name === p2.name)
            return null;
        if (!p1.filterable || !p2.filterable)
            return null;
        return [p1, p2];
    }), C.paramArrayKeyFn, {});
    $grammar.addRule("two_param_direct_search_question", [new $runtime.NonTerminal("thingpedia_search_question", ["filterable", (true)]), "and", "what", new $runtime.NonTerminal("out_param_Any", ["functionName", 0, "functionName"]), new $runtime.NonTerminal("prefer_question_phrase", undefined), "?"], ((p1, $0, $1, p2, $2, $3) => {
        if (!C.isSameFunction(p1.schema, p2.schema))
            return null;
        if (p1.name === 'id' || p2.name === 'id' || p1.name === p2.name)
            return null;
        if (!p1.filterable || !p2.filterable)
            return null;
        return [p1, p2];
    }), C.paramArrayKeyFn, {});
    $grammar.addRule("two_param_direct_search_question", ["what", new $runtime.NonTerminal("out_param_Any", ["filterable", (true)]), new $runtime.NonTerminal("prefer_question_phrase", undefined), "and", new $runtime.NonTerminal("thingpedia_search_question", ["functionName", 1, "functionName"]), "?"], (($0, p1, $1, $2, p2, $3) => {
        if (!C.isSameFunction(p1.schema, p2.schema))
            return null;
        if (p1.name === 'id' || p2.name === 'id' || p1.name === p2.name)
            return null;
        if (!p1.filterable || !p2.filterable)
            return null;
        return [p1, p2];
    }), C.paramArrayKeyFn, {});
    $grammar.declareSymbol("one_param_yesno_direct_search_question");
    $grammar.addRule("one_param_yesno_direct_search_question", ["any preference of", new $runtime.NonTerminal("out_param_Any", ["filterable", (true)]), "?"], (($0, p, $1) => {
        if (p.name === 'id')
            return null;
        if (!p.filterable)
            return null;
        return [p];
    }), C.paramArrayKeyFn, {});
    $grammar.addRule("one_param_yesno_direct_search_question", ["do you have a specific", new $runtime.NonTerminal("out_param_Any", ["filterable", (true)]), "in mind?"], (($0, p, $1) => {
        if (p.name === 'id')
            return null;
        if (!p.filterable)
            return null;
        return [p];
    }), C.paramArrayKeyFn, {});
    $grammar.addRule("one_param_yesno_direct_search_question", ["do you have a preference of", new $runtime.NonTerminal("out_param_Any", ["filterable", (true)]), "?"], (($0, p, $1) => {
        if (p.name === 'id')
            return null;
        if (!p.filterable)
            return null;
        return [p];
    }), C.paramArrayKeyFn, {});
    $grammar.addRule("one_param_yesno_direct_search_question", ["do you have a preferred", new $runtime.NonTerminal("out_param_Any", ["filterable", (true)]), "?"], (($0, p, $1) => {
        if (p.name === 'id')
            return null;
        if (!p.filterable)
            return null;
        return [p];
    }), C.paramArrayKeyFn, {});
    $grammar.addRule("one_param_yesno_direct_search_question", ["are you looking for a specific", new $runtime.NonTerminal("out_param_Any", ["filterable", (true)]), "?"], (($0, p, $1) => {
        if (p.name === 'id')
            return null;
        if (!p.filterable)
            return null;
        return [p];
    }), C.paramArrayKeyFn, {});
    $grammar.addRule("one_param_yesno_direct_search_question", ["are you interested in a specific", new $runtime.NonTerminal("out_param_Any", ["filterable", (true)]), "?"], (($0, p, $1) => {
        if (p.name === 'id')
            return null;
        if (!p.filterable)
            return null;
        return [p];
    }), C.paramArrayKeyFn, {});
    $grammar.declareSymbol("one_param_yesno_direct_search_question_with_preamble");
    $grammar.addRule("one_param_yesno_direct_search_question_with_preamble", [new $runtime.NonTerminal("search_result_preamble", undefined), new $runtime.NonTerminal("one_param_yesno_direct_search_question", undefined)], (($0, question) => question), C.paramArrayKeyFn, {});
    $grammar.declareSymbol("two_param_yesno_direct_search_question");
    $grammar.addRule("two_param_yesno_direct_search_question", ["any preference of", new $runtime.NonTerminal("out_param_Any", ["filterable", (true)]), "or", new $runtime.NonTerminal("out_param_Any", ["functionName", 1, "functionName"]), "?"], (($0, p1, $1, p2, $2) => {
        if (!C.isSameFunction(p1.schema, p2.schema))
            return null;
        if (p1.name === 'id' || p2.name === 'id' || p1.name === p2.name)
            return null;
        if (!p1.filterable || !p2.filterable)
            return null;
        return [p1, p2];
    }), C.paramArrayKeyFn, {});
    $grammar.addRule("two_param_yesno_direct_search_question", ["do you have a specific", new $runtime.NonTerminal("out_param_Any", ["filterable", (true)]), "or", new $runtime.NonTerminal("out_param_Any", ["functionName", 1, "functionName"]), "in mind?"], (($0, p1, $1, p2, $2) => {
        if (!C.isSameFunction(p1.schema, p2.schema))
            return null;
        if (p1.name === 'id' || p2.name === 'id' || p1.name === p2.name)
            return null;
        if (!p1.filterable || !p2.filterable)
            return null;
        return [p1, p2];
    }), C.paramArrayKeyFn, {});
    $grammar.addRule("two_param_yesno_direct_search_question", ["do you have a preference of", new $runtime.NonTerminal("out_param_Any", ["filterable", (true)]), "or", new $runtime.NonTerminal("out_param_Any", ["functionName", 1, "functionName"]), "?"], (($0, p1, $1, p2, $2) => {
        if (!C.isSameFunction(p1.schema, p2.schema))
            return null;
        if (p1.name === 'id' || p2.name === 'id' || p1.name === p2.name)
            return null;
        if (!p1.filterable || !p2.filterable)
            return null;
        return [p1, p2];
    }), C.paramArrayKeyFn, {});
    $grammar.addRule("two_param_yesno_direct_search_question", ["do you have a preferred", new $runtime.NonTerminal("out_param_Any", ["filterable", (true)]), "or", new $runtime.NonTerminal("out_param_Any", ["functionName", 1, "functionName"]), "?"], (($0, p1, $1, p2, $2) => {
        if (!C.isSameFunction(p1.schema, p2.schema))
            return null;
        if (p1.name === 'id' || p2.name === 'id' || p1.name === p2.name)
            return null;
        if (!p1.filterable || !p2.filterable)
            return null;
        return [p1, p2];
    }), C.paramArrayKeyFn, {});
    $grammar.addRule("two_param_yesno_direct_search_question", ["are you looking for a specific", new $runtime.NonTerminal("out_param_Any", ["filterable", (true)]), "or", new $runtime.NonTerminal("out_param_Any", ["functionName", 1, "functionName"]), "?"], (($0, p1, $1, p2, $2) => {
        if (!C.isSameFunction(p1.schema, p2.schema))
            return null;
        if (p1.name === 'id' || p2.name === 'id' || p1.name === p2.name)
            return null;
        if (!p1.filterable || !p2.filterable)
            return null;
        return [p1, p2];
    }), C.paramArrayKeyFn, {});
    $grammar.addRule("two_param_yesno_direct_search_question", ["are you interested in a specific", new $runtime.NonTerminal("out_param_Any", ["filterable", (true)]), "or", new $runtime.NonTerminal("out_param_Any", ["functionName", 1, "functionName"]), "?"], (($0, p1, $1, p2, $2) => {
        if (!C.isSameFunction(p1.schema, p2.schema))
            return null;
        if (p1.name === 'id' || p2.name === 'id' || p1.name === p2.name)
            return null;
        if (!p1.filterable || !p2.filterable)
            return null;
        return [p1, p2];
    }), C.paramArrayKeyFn, {});
    $grammar.declareSymbol("question_npp_filter_pair");
    $grammar.addRule("question_npp_filter_pair", [new $runtime.NonTerminal("ctx_with_result_noquestion", undefined), new $runtime.NonTerminal("npp_filter", ["functionName", 0, "currentFunction"]), "or", new $runtime.NonTerminal("npp_filter", ["functionName", 0, "currentFunction"])], ((ctx, f1, $0, f2) => D.checkFilterPairForDisjunctiveQuestion(ctx, f1, f2)), C.paramKeyFn, {});
    $grammar.addRule("question_npp_filter_pair", [new $runtime.NonTerminal("ctx_with_result_noquestion", undefined), new $runtime.NonTerminal("npp_filter", ["functionName", 0, "currentFunction"]), "or", new $runtime.NonTerminal("constant_Any", ["type", 1, "type"])], ((ctx, f1, $0, c) => D.checkFilterPairForDisjunctiveQuestionWithConstant(ctx, f1, c)), C.paramKeyFn, {});
    $grammar.declareSymbol("question_apv_filter_pair");
    $grammar.addRule("question_apv_filter_pair", [new $runtime.NonTerminal("ctx_with_result_noquestion", undefined), new $runtime.NonTerminal("apv_filter", ["functionName", 0, "currentFunction"]), "or", new $runtime.NonTerminal("apv_filter", ["functionName", 0, "currentFunction"])], ((ctx, f1, $0, f2) => D.checkFilterPairForDisjunctiveQuestion(ctx, f1, f2)), C.paramKeyFn, {});
    $grammar.declareSymbol("question_avp_filter_pair");
    $grammar.addRule("question_avp_filter_pair", [new $runtime.NonTerminal("ctx_with_result_noquestion", undefined), new $runtime.NonTerminal("avp_filter", ["functionName", 0, "currentFunction"]), "or", new $runtime.NonTerminal("constant_Any", ["type", 1, "type"])], ((ctx, f1, $0, c) => D.checkFilterPairForDisjunctiveQuestionWithConstant(ctx, f1, c)), C.paramKeyFn, {});
    $grammar.declareSymbol("question_preposition_filter_pair");
    $grammar.addRule("question_preposition_filter_pair", [new $runtime.NonTerminal("ctx_with_result_noquestion", undefined), new $runtime.NonTerminal("preposition_filter", ["functionName", 0, "currentFunction"]), "or", new $runtime.NonTerminal("preposition_filter", ["functionName", 0, "currentFunction"])], ((ctx, f1, $0, f2) => D.checkFilterPairForDisjunctiveQuestion(ctx, f1, f2)), C.paramKeyFn, {});
    $grammar.declareSymbol("question_pvp_filter_pair");
    $grammar.addRule("question_pvp_filter_pair", [new $runtime.NonTerminal("ctx_with_result_noquestion", undefined), new $runtime.NonTerminal("pvp_filter", ["functionName", 0, "currentFunction"]), "or", new $runtime.NonTerminal("pvp_filter", ["functionName", 0, "currentFunction"])], ((ctx, f1, $0, f2) => D.checkFilterPairForDisjunctiveQuestion(ctx, f1, f2)), C.paramKeyFn, {});
    $grammar.declareSymbol("disjunctive_search_question");
    $grammar.addRule("disjunctive_search_question", [new $runtime.Choice(["are you looking for", "would you like", "do you need"]), "something with", new $runtime.NonTerminal("question_npp_filter_pair", undefined), "?"], (($0, $1, question, $2) => [question]), C.paramArrayKeyFn, {});
    $grammar.addRule("disjunctive_search_question", [new $runtime.Choice(["are you looking for", "would you like", "do you need"]), "something", new $runtime.NonTerminal("question_apv_filter_pair", undefined), "?"], (($0, $1, question, $2) => [question]), C.paramArrayKeyFn, {});
    $grammar.addRule("disjunctive_search_question", [new $runtime.Choice(["are you looking for", "would you like", "do you need"]), "something", new $runtime.NonTerminal("question_preposition_filter_pair", undefined), "?"], (($0, $1, question, $2) => [question]), C.paramArrayKeyFn, {});
    $grammar.addRule("disjunctive_search_question", [new $runtime.Choice(["are you looking for", "would you like", "do you need"]), "something", new $runtime.NonTerminal("question_pvp_filter_pair", undefined), "?"], (($0, $1, question, $2) => [question]), C.paramArrayKeyFn, {});
    $grammar.addRule("disjunctive_search_question", [new $runtime.Choice(["are you looking for", "would you like", "do you need"]), "something that", new $runtime.NonTerminal("question_avp_filter_pair", undefined), "?"], (($0, $1, question, $2) => [question]), C.paramArrayKeyFn, {});
    $grammar.addRule("disjunctive_search_question", [new $runtime.Choice(["are you looking for", "would you like", "do you need"]), "a", new $runtime.NonTerminal("base_table", undefined), new $runtime.Choice(["with", "that has"]), new $runtime.NonTerminal("question_npp_filter_pair", ["functionName", 2, "functionName"]), "?"], (($0, $1, table, $2, question, $3) => {
        if (!C.isSameFunction(table.schema, question.schema))
            return null;
        return [question];
    }), C.paramArrayKeyFn, {});
    $grammar.addRule("disjunctive_search_question", [new $runtime.Choice(["are you looking for", "would you like", "do you need"]), "a", new $runtime.NonTerminal("question_apv_filter_pair", undefined), new $runtime.NonTerminal("base_table", ["functionName", 2, "functionName"]), "?"], (($0, $1, question, table, $2) => {
        if (!C.isSameFunction(table.schema, question.schema))
            return null;
        return [question];
    }), C.paramArrayKeyFn, {});
    $grammar.addRule("disjunctive_search_question", [new $runtime.Choice(["are you looking for", "would you like", "do you need"]), "a", new $runtime.NonTerminal("base_table", undefined), new $runtime.NonTerminal("question_pvp_filter_pair", ["functionName", 2, "functionName"]), "?"], (($0, $1, table, question, $2) => {
        if (!C.isSameFunction(table.schema, question.schema))
            return null;
        return [question];
    }), C.paramArrayKeyFn, {});
    $grammar.addRule("disjunctive_search_question", [new $runtime.Choice(["are you looking for", "would you like", "do you need"]), "a", new $runtime.NonTerminal("base_table", undefined), new $runtime.NonTerminal("question_preposition_filter_pair", ["functionName", 2, "functionName"]), "?"], (($0, $1, table, question, $2) => {
        if (!C.isSameFunction(table.schema, question.schema))
            return null;
        return [question];
    }), C.paramArrayKeyFn, {});
    $grammar.addRule("disjunctive_search_question", [new $runtime.Choice(["are you looking for", "would you like", "do you need"]), "a", new $runtime.NonTerminal("base_table", undefined), "that", new $runtime.NonTerminal("question_avp_filter_pair", ["functionName", 2, "functionName"]), "?"], (($0, $1, table, $2, question, $3) => {
        if (!C.isSameFunction(table.schema, question.schema))
            return null;
        return [question];
    }), C.paramArrayKeyFn, {});
    $grammar.declareSymbol("generic_question");
    $grammar.addRule("generic_question", ["which one would you like ?"], (($0) => []), undefined, {});
    $grammar.addRule("generic_question", ["do you have a specific one in mind ?"], (($0) => []), undefined, {});
    $grammar.addRule("generic_question", ["do you have any more information to narrow down the search ?"], (($0) => []), undefined, {});
    $grammar.declareSymbol("simple_search_question");
    $grammar.addRule("simple_search_question", [new $runtime.NonTerminal("one_param_direct_search_question", undefined)], (($0) => { return $0; }), C.paramArrayKeyFn, { priority: (0.1), identity: (true) });
    $grammar.addRule("simple_search_question", [new $runtime.NonTerminal("two_param_direct_search_question", undefined)], (($0) => { return $0; }), C.paramArrayKeyFn, { identity: (true) });
    if ($options.flags.disjunctive_search_questions) {
        $grammar.addRule("simple_search_question", [new $runtime.NonTerminal("disjunctive_search_question", undefined)], (($0) => { return $0; }), C.paramArrayKeyFn, { identity: (true) });
    }
    $grammar.addRule("simple_search_question", [new $runtime.NonTerminal("one_param_yesno_direct_search_question", undefined)], (($0) => { return $0; }), C.paramArrayKeyFn, { priority: (0.1), identity: (true) });
    $grammar.addRule("simple_search_question", [new $runtime.NonTerminal("two_param_yesno_direct_search_question", undefined)], (($0) => { return $0; }), C.paramArrayKeyFn, { identity: (true) });
    $grammar.declareSymbol("search_question");
    $grammar.addRule("search_question", [new $runtime.NonTerminal("simple_search_question", undefined)], (($0) => { return $0; }), C.paramArrayKeyFn, { identity: (true) });
    $grammar.addRule("search_question", [new $runtime.NonTerminal("search_result_preamble", undefined), new $runtime.NonTerminal("simple_search_question", undefined)], (($0, question) => question), C.paramArrayKeyFn, { weight: (0.1) });
    $grammar.declareSymbol("verbose_search_answer");
    $grammar.addRule("verbose_search_answer", [new $runtime.NonTerminal("generic_preamble_for_answer", undefined), new $runtime.Choice(["a", "the"]), new $runtime.NonTerminal("answer_noun_phrase", undefined)], (($0, $1, query) => query), C.expressionKeyFn, {});
    $grammar.addRule("verbose_search_answer", [new $runtime.NonTerminal("generic_preamble_for_answer", undefined), new $runtime.NonTerminal("anything_phrase", undefined)], (($0, query) => query), C.expressionKeyFn, {});
    $grammar.declareSymbol("verbose_search_answer_with_action");
    $grammar.addRule("verbose_search_answer_with_action", [new $runtime.NonTerminal("verbose_search_answer", undefined), new $runtime.Choice([".", ","]), new $runtime.NonTerminal("generic_preamble_for_action", undefined), new $runtime.NonTerminal("coref_action_command", undefined)], ((query, $0, $1, action) => {
        // check that one of the parameters of action has the right type to param pass into the action
        let idArg = query.schema.getArgument('id');
        if (!idArg)
            return null;
        let found = false;
        for (let arg of action.schema.iterateArguments()) {
            if (!arg.is_input)
                continue;
            if (arg.type.equals(idArg.type)) {
                found = true;
                break;
            }
        }
        if (!found)
            return null;
        return [query, action];
    }), undefined, {});
    $grammar.declareSymbol("precise_search_question_answer");
    $grammar.addRule("precise_search_question_answer", [new $runtime.NonTerminal("verbose_search_answer", undefined)], ((table) => [table, null, false]), D.preciseSearchQuestionAnswerKeyFn, {});
    $grammar.addRule("precise_search_question_answer", [new $runtime.Choice(["yes", "yes ,", ""]), new $runtime.NonTerminal("verbose_search_answer", undefined)], (($0, table) => [table, null, true]), D.preciseSearchQuestionAnswerKeyFn, {});
    $grammar.addRule("precise_search_question_answer", [new $runtime.NonTerminal("verbose_search_answer_with_action", undefined)], ((table_action) => [...table_action, false]), D.preciseSearchQuestionAnswerKeyFn, {});
    $grammar.addRule("precise_search_question_answer", [new $runtime.Choice(["yes", "yes ,", ""]), new $runtime.NonTerminal("verbose_search_answer_with_action", undefined)], (($0, table_action) => [...table_action, true]), D.preciseSearchQuestionAnswerKeyFn, {});
    $grammar.declareSymbol("specific_dontcare_phrase");
    $grammar.addRule("specific_dontcare_phrase", ["the", new $runtime.NonTerminal("out_param_Any", undefined), "does not matter ."], (($0, param, $1) => C.makeDontCareFilter(param)), C.filterKeyFn, {});
    $grammar.addRule("specific_dontcare_phrase", ["the", new $runtime.NonTerminal("out_param_Any", undefined), "is not an issue ."], (($0, param, $1) => C.makeDontCareFilter(param)), C.filterKeyFn, {});
    $grammar.addRule("specific_dontcare_phrase", ["the", new $runtime.NonTerminal("out_param_Any", undefined), "is not important ."], (($0, param, $1) => C.makeDontCareFilter(param)), C.filterKeyFn, {});
    $grammar.addRule("specific_dontcare_phrase", ["the", new $runtime.NonTerminal("out_param_Any", undefined), "does not matter . can you suggest one ?"], (($0, param, $1) => C.makeDontCareFilter(param)), C.filterKeyFn, {});
    $grammar.addRule("specific_dontcare_phrase", ["i", new $runtime.Choice(["do not have a", "have no"]), "preference of ", new $runtime.NonTerminal("out_param_Any", undefined), "."], (($0, $1, $2, param, $3) => C.makeDontCareFilter(param)), C.filterKeyFn, {});
    $grammar.addRule("specific_dontcare_phrase", ["i", new $runtime.Choice(["do not have a", "have no"]), "preference of ", new $runtime.NonTerminal("out_param_Any", undefined), ". what do you recommend ?"], (($0, $1, $2, param, $3) => C.makeDontCareFilter(param)), C.filterKeyFn, {});
    $grammar.addRule("specific_dontcare_phrase", ["i have no preference of ", new $runtime.NonTerminal("out_param_Any", undefined), ". please make a recommendation ."], (($0, param, $1) => C.makeDontCareFilter(param)), C.filterKeyFn, {});
    $grammar.addRule("specific_dontcare_phrase", [new $runtime.Choice(["i do not care that it has", "it need not have", "i do not need"]), new $runtime.NonTerminal("npp_filter", undefined)], (($0, param) => {
        var _a;
        if (!(param.ast instanceof thingtalk_1.Ast.AtomBooleanExpression))
            return null;
        if (!(param.ast.value instanceof thingtalk_1.Ast.BooleanValue) || param.ast.value.value !== true)
            return null;
        return C.makeDontCareFilter({ schema: param.schema, type: param.ptype, name: param.ast.name, filterable: (_a = param.schema.getArgument(param.ast.name).getImplementationAnnotation('filterable')) !== null && _a !== void 0 ? _a : true, ast: new thingtalk_1.Ast.Value.VarRef(param.ast.name) });
    }), C.filterKeyFn, {});
    $grammar.declareSymbol("coref_constant");
    $grammar.addRule("coref_constant", [new $runtime.NonTerminal("ctx_multidomain", undefined), new $runtime.Choice(["the", "the same"]), new $runtime.NonTerminal("base_table", undefined), "'s", new $runtime.NonTerminal("out_param_Any", ["functionName", 2, "functionName"]), "."], ((ctx, $0, base, $1, param, $2) => D.corefConstant(ctx, base, param)), C.valueKeyFn, {});
    $grammar.addRule("coref_constant", [new $runtime.NonTerminal("ctx_multidomain", undefined), new $runtime.NonTerminal("generic_preamble_for_answer", undefined), new $runtime.Choice(["the", "the same"]), new $runtime.NonTerminal("base_table", undefined), "'s", new $runtime.NonTerminal("out_param_Any", ["functionName", 3, "functionName"]), "."], ((ctx, $0, $1, base, $2, param, $3) => D.corefConstant(ctx, base, param)), C.valueKeyFn, {});
    $grammar.addRule("coref_constant", [new $runtime.NonTerminal("ctx_multidomain", undefined), "the same", new $runtime.NonTerminal("out_param_Any", undefined), "as", "the", new $runtime.NonTerminal("base_table", ["functionName", 2, "functionName"]), "."], ((ctx, $0, param, $1, $2, base, $3) => D.corefConstant(ctx, base, param)), C.valueKeyFn, {});
    $grammar.addRule("coref_constant", [new $runtime.NonTerminal("ctx_multidomain", undefined), new $runtime.NonTerminal("generic_preamble_for_answer", undefined), "the same", new $runtime.NonTerminal("out_param_Any", undefined), "as", "the", new $runtime.NonTerminal("base_table", ["functionName", 3, "functionName"]), "."], ((ctx, $0, $1, param, $2, $3, base, $4) => D.corefConstant(ctx, base, param)), C.valueKeyFn, {});
    $grammar.addRule("coref_constant", [new $runtime.NonTerminal("ctx_multidomain", undefined), new $runtime.Choice(["the same as the", "the"]), new $runtime.NonTerminal("out_param_Any", undefined), "of", "the", new $runtime.NonTerminal("base_table", ["functionName", 2, "functionName"]), "."], ((ctx, $0, param, $1, $2, base, $3) => D.corefConstant(ctx, base, param)), C.valueKeyFn, {});
    $grammar.addRule("coref_constant", [new $runtime.NonTerminal("ctx_multidomain", undefined), new $runtime.NonTerminal("generic_preamble_for_answer", undefined), new $runtime.Choice(["the same as the", "the"]), new $runtime.NonTerminal("out_param_Any", undefined), "of", "the", new $runtime.NonTerminal("base_table", ["functionName", 3, "functionName"]), "."], ((ctx, $0, $1, param, $2, $3, base, $4) => D.corefConstant(ctx, base, param)), C.valueKeyFn, {});
    $grammar.declareSymbol("imprecise_search_coref_answer");
    $grammar.addRule("imprecise_search_coref_answer", [new $runtime.NonTerminal("coref_constant", undefined)], ((slot) => slot), undefined, {});
    $grammar.addRule("imprecise_search_coref_answer", [new $runtime.NonTerminal("coref_npp_filter", undefined)], ((slot) => slot), undefined, {});
    $grammar.addRule("imprecise_search_coref_answer", [new $runtime.NonTerminal("coref_apv_filter", undefined)], ((slot) => slot), undefined, {});
    $grammar.addRule("imprecise_search_coref_answer", [new $runtime.NonTerminal("coref_pvp_filter", undefined)], ((slot) => slot), undefined, {});
    $grammar.addRule("imprecise_search_coref_answer", [new $runtime.NonTerminal("coref_preposition_filter", undefined)], ((slot) => slot), undefined, {});
    $grammar.declareSymbol("imprecise_search_answer_phrase");
    $grammar.addRule("imprecise_search_answer_phrase", [new $runtime.NonTerminal("constant_Any", undefined)], ((slot) => slot), undefined, {});
    $grammar.addRule("imprecise_search_answer_phrase", [new $runtime.NonTerminal("npp_filter", undefined)], ((slot) => slot), undefined, {});
    $grammar.addRule("imprecise_search_answer_phrase", [new $runtime.NonTerminal("apv_filter", undefined)], ((slot) => slot), undefined, {});
    $grammar.addRule("imprecise_search_answer_phrase", [new $runtime.NonTerminal("pvp_filter", undefined)], ((slot) => slot), undefined, {});
    $grammar.addRule("imprecise_search_answer_phrase", [new $runtime.NonTerminal("preposition_filter", undefined)], ((slot) => slot), undefined, {});
    $grammar.declareSymbol("imprecise_search_answer");
    $grammar.addRule("imprecise_search_answer", [new $runtime.NonTerminal("imprecise_search_answer_phrase", undefined), new $runtime.Choice(["please", ""]), "."], ((ans, $0, $1) => ans), undefined, {});
    $grammar.addRule("imprecise_search_answer", [new $runtime.NonTerminal("generic_preamble_for_answer", undefined), new $runtime.NonTerminal("imprecise_search_answer_phrase", undefined), "."], (($0, ans, $1) => ans), undefined, {});
    $grammar.declareSymbol("imprecise_search_question_answer");
    $grammar.addRule("imprecise_search_question_answer", [new $runtime.NonTerminal("imprecise_search_answer", undefined)], (($0) => { return $0; }), undefined, { identity: (true) });
    $grammar.addRule("imprecise_search_question_answer", [new $runtime.NonTerminal("imprecise_search_coref_answer", undefined)], (($0) => { return $0; }), undefined, { identity: (true) });
    if ($options.flags.dontcare) {
        $grammar.addRule("imprecise_search_question_answer", [new $runtime.NonTerminal("generic_dontcare_phrase", undefined)], (($0) => 'dontcare'), undefined, { weight: (0.1) });
        $grammar.addRule("imprecise_search_question_answer", [new $runtime.NonTerminal("no_dontcare_phrase", undefined)], (($0) => 'dontcare'), undefined, { weight: (0.1) });
        $grammar.addRule("imprecise_search_question_answer", [new $runtime.NonTerminal("specific_dontcare_phrase", undefined)], (($0) => { return $0; }), undefined, { identity: (true) });
    }
}
exports.default = default_1;
;
//# sourceMappingURL=search-questions.genie.js.map