define(["./voicecommands.js","./grammarprocessor.js","require"],function(voicecommands,grammarprocessor,require){"use strict";functiongetCommandGroups(){returncommandgroups?Promise.resolve(commandgroups):newPromise(function(resolve,reject){varfile="grammar";require(["text!./grammar/"+file+".json"],function(response){commandgroups=JSON.parse(response),resolve(commandgroups)})})}functionprocessTranscript(text){returntext?getCommandGroups().then(function(commandgroups){varprocessor=grammarprocessor(commandgroups,text);returnprocessor&&processor.command?(console.log("Command from Grammar Processor",processor),voicecommands(processor).then(function(result){returnconsole.log("Result of executed command",result),"show"===result.item.actionid&&"group"===result.item.sourceid?Promise.resolve({error:"group",item:result.item,groupName:result.name,fn:result.fn}):Promise.resolve({item:result.item,fn:result.fn})},function(){returnPromise.reject({error:"unrecognized-command",text:text})})):Promise.reject({error:"unrecognized-command",text:text})}):Promise.reject({error:"empty"})}varcommandgroups;return{processTranscript:processTranscript,getCommandGroups:getCommandGroups}});