function AmazonNavigateResponseGenerator(e){function i(){t=e}function s(e,i){n=i.message.body.navigate.attributess.source,r=i.message.body.navigate.attributess.sourceAccount;var s=objFactory.getObj("section"),o=objFactory.getObj("sections"),u,a=Object.keys(e),l;for(l=1;l<a.length;l++){nodes=e[a[l]].getNavigationNodes(),u=objFactory.getObj("items");var c=nodes.length;for(var h=0;h<c&&h<AmazonWorker.Constants.TOP_LEVEL_MENU_SELECTION_LIMIT;h++)u.addChild(f(nodes[h]));c>AmazonWorker.Constants.TOP_LEVEL_MENU_SELECTION_LIMIT&&u.addChild(f(e[""].getNavigationNodes()[l-1]));var p=e[""].getNavigationNodes()[l-1].getName();s.setItems(u),s.setTitle(p),o.addChild(s),s=objFactory.getObj("section")}var d=objFactory.getObj("navigateresponse").setSource(n).setSourceAccount(r).setSections(o),v=t.formatResponseToXML(i,d);return v}function o(e,t,n){var r=objFactory.getObj("items"),i,s=t.length;for(var o=0;o<s;++o){var u=t[o].getChildren();if(u.length>0){i||(i=objFactory.getObj("sections"));var a=objFactory.getObj("section"),l=objFactory.getObj("items");for(var c=0;c<u.length;++c)l.addChild(f(u[c],n));a.setItems(l),a.setTitle(t[o].getName()),i.addChild(a)}else r.addChild(f(t[o],n))}e.setItems(r),i&&e.setSections(i)}function u(e,i,s,u,a,f){n=f.message.body.navigate.attributess.source,r=f.message.body.navigate.attributess.sourceAccount;var l=objFactory.getObj("navigateresponse").setSource(n).setSourceAccount(r);o(l,i,f),s!=""&&l.setNextPageURI(s),u!=""&&l.setPrevPageURI(u),a||(a=[]);if(a.length>0){var c=objFactory.getObj("searchFilters");for(var h=0;h<a.length;++h)if(a[h].fragmentId){var p=objFactory.getObj("searchfilter");p.setID(a[h].fragmentId).setUrl(a[h].fragmentId).setName(a[h].title||""),c.addChild(p)}l.setSearchFilters(c)}var d=t.formatResponseToXML(f,l);return d}function a(e,i,s){n=s.message.body.search.attributess.source,r=s.message.body.search.attributess.sourceAccount;var u=objFactory.getObj("searchresponse").setSource(n).setSourceAccount(r).setFilter(i);return o(u,e,s),t.formatResponseToXML(s,u)}function f(e,t){var i=e.getType(),s="";!e.isNavigable()&&!e.isPlayable()&&(i=AmazonWorker.NodeType.INVALID_NODE),t&&typeof t.requestObject!="undefined"&&t.requestObject.type["#text"]===AmazonWorker.NodeType.PLAYLIST?s=t.requestObject.logo["#text"]:e.getImageURL()!==""&&(s=e.getImageURL());var o="tracklist",u=objFactory.getObj("item").setName(e.getName().toString()).setToken(e.getId()).setUrl(e.getURI().toString()).setLogo(e.getImageURL().toString()).setDescription(e.getSubTitle().toString()).setType(i);i===AmazonWorker.NodeType.TRACK&&(u.setArtistName(e.getArtistName().toString()),u.setAlbumName(e.getAlbumName().toString()),e.isAvailable()||u.setAvailability("AMAZON_UNAVAILABLE_TRACK")),i===AmazonWorker.NodeType.UNPLAYABLE_STATION&&u.setType("station"),e.isPlayable()&&i!==AmazonWorker.NodeType.TRACK&&e.getPresetURI()!==""&&u.setContentItem(objFactory.getObj("contentitem").setSource(n).setSourceAccount(r).setLocation(e.getPresetURI().toString()).setItemName(e.getPresetName().toString()).setIsPresetable(!0).setType(o).setContainerArt(s));if(e.isPlayable()&&!e.isNavigable()){var a=objFactory.getObj("playbackrequest").setSource(n).setSourceAccount(r).setContainer(objFactory.getObj("container").setSource(n).setSourceAccount(r).setLocation(e.getPresetURI()).setItemName(e.getPresetName()).setType(o).setIsPresetable("true").setContainerArt(s));if(i===AmazonWorker.NodeType.TRACK||i===AmazonWorker.NodeType.UNPLAYABLE_STATION){var f="index:"+e.getTrackIndex().toString()+"::uri:"+e.getURI().toString();a.setTrack(objFactory.getObj("track").setSource(n).setSourceAccount(r).setType("track").setLocation(f).setIsPresetable("true").setItemName(e.getName().toString()))}u.setPlaybackRequest(a)}return u}this.getNavigateResponse=u,this.generateTopLevelForMenuNavigationResponse=s,this.getSearchResponse=a;var t,n,r;i()};