EPUBJS.reader.search={},EPUBJS.reader.search.SERVER="https://pacific-cliffs-3579.herokuapp.com",EPUBJS.reader.search.request=function(t,i){var a=$.ajax({dataType:"json",url:EPUBJS.reader.search.SERVER+"/search?q="+encodeURIComponent(t)});a.fail(function(e){console.error(e)}),a.done(function(e){i(e)})},EPUBJS.reader.plugins.SearchController=function(t){var i=this,a=$("#searchBox"),e=$("#searchResults"),h=$("#searchView"),r,s=!1,p=function(){v(),s=!0,h.addClass("shown")},u=function(){s=!1,h.removeClass("shown")},v=function(){var n=a.val();n!=""&&(e.empty(),e.append("
  • Searching...

  • "),EPUBJS.reader.search.request(n,function(c){var l=c.results;if(e.empty(),r&&$(r).find("body").unhighlight(),l.length==0){e.append("
  • No Results Found

  • ");return}r=$("#viewer iframe")[0].contentDocument,$(r).find("body").highlight(n,{element:"span"}),l.forEach(function(o){var f=$("
  • "),d=$(""+o.title+"

    "+o.highlight+"

    ");d.on("click",function(g){var S=$(this),m=S.data("cfi");g.preventDefault(),t.gotoCfi(m+"/1:0"),t.on("renderer:chapterDisplayed",function(){r=$("#viewer iframe")[0].contentDocument,$(r).find("body").highlight(n,{element:"span"})})}),f.append(d),e.append(f)})}))};return a.on("search",function(n){var c=a.val();if(c==""){e.empty(),i.SidebarController.getActivePanel()=="Search"&&i.SidebarController.changePanelTo("Toc"),$(r).find("body").unhighlight(),r=!1;return}i.SidebarController.changePanelTo("Search"),n.preventDefault()}),{show:p,hide:u}};