@internetarchive/bookreader 5.0.0-74-alpha → 5.0.0-75

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,5 +22,5 @@
22
22
  .stroke-color {
23
23
  stroke: var(--iconStrokeColor);
24
24
  }
25
- `}render(){return c}}customElements.define("ia-icon-toc",s);var l,u,f,p,h,d,y,v=r(5311),m=r(5311);function g(e){return g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},g(e)}function b(e,t){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},b(e,t)}function w(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function k(){k=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach((function(r){t.forEach((function(t){t.kind===r&&"own"===t.placement&&this.defineClassElement(e,t)}),this)}),this)},initializeClassElements:function(e,t){var r=e.prototype;["method","field"].forEach((function(n){t.forEach((function(t){var o=t.placement;if(t.kind===n&&("static"===o||"prototype"===o)){var i="static"===o?e:r;this.defineClassElement(i,t)}}),this)}),this)},defineClassElement:function(e,t){var r=t.descriptor;if("field"===t.kind){var n=t.initializer;r={enumerable:r.enumerable,writable:r.writable,configurable:r.configurable,value:void 0===n?void 0:n.call(e)}}Object.defineProperty(e,t.key,r)},decorateClass:function(e,t){var r=[],n=[],o={static:[],prototype:[],own:[]};if(e.forEach((function(e){this.addElementPlacement(e,o)}),this),e.forEach((function(e){if(!P(e))return r.push(e);var t=this.decorateElement(e,o);r.push(t.element),r.push.apply(r,t.extras),n.push.apply(n,t.finishers)}),this),!t)return{elements:r,finishers:n};var i=this.decorateConstructor(r,t);return n.push.apply(n,i.finishers),i.finishers=n,i},addElementPlacement:function(e,t,r){var n=t[e.placement];if(!r&&-1!==n.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");n.push(e.key)},decorateElement:function(e,t){for(var r=[],n=[],o=e.decorators,i=o.length-1;i>=0;i--){var a=t[e.placement];a.splice(a.indexOf(e.key),1);var c=this.fromElementDescriptor(e),s=this.toElementFinisherExtras((0,o[i])(c)||c);e=s.element,this.addElementPlacement(e,t),s.finisher&&n.push(s.finisher);var l=s.extras;if(l){for(var u=0;u<l.length;u++)this.addElementPlacement(l[u],t);r.push.apply(r,l)}}return{element:e,finishers:n,extras:r}},decorateConstructor:function(e,t){for(var r=[],n=t.length-1;n>=0;n--){var o=this.fromClassDescriptor(e),i=this.toClassDescriptor((0,t[n])(o)||o);if(void 0!==i.finisher&&r.push(i.finisher),void 0!==i.elements){e=i.elements;for(var a=0;a<e.length-1;a++)for(var c=a+1;c<e.length;c++)if(e[a].key===e[c].key&&e[a].placement===e[c].placement)throw new TypeError("Duplicated element ("+e[a].key+")")}}return{elements:e,finishers:r}},fromElementDescriptor:function(e){var t={kind:e.kind,key:e.key,placement:e.placement,descriptor:e.descriptor};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),"field"===e.kind&&(t.initializer=e.initializer),t},toElementDescriptors:function(e){var t;if(void 0!==e)return(t=e,function(e){if(Array.isArray(e))return e}(t)||I(t)||R(t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map((function(e){var t=this.toElementDescriptor(e);return this.disallowProperty(e,"finisher","An element descriptor"),this.disallowProperty(e,"extras","An element descriptor"),t}),this)},toElementDescriptor:function(e){var t=String(e.kind);if("method"!==t&&"field"!==t)throw new TypeError('An element descriptor\'s .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "'+t+'"');var r=O(e.key),n=String(e.placement);if("static"!==n&&"prototype"!==n&&"own"!==n)throw new TypeError('An element descriptor\'s .placement property must be one of "static", "prototype" or "own", but a decorator created an element descriptor with .placement "'+n+'"');var o=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var i={kind:t,key:r,placement:n,descriptor:Object.assign({},o)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(o,"get","The property descriptor of a field descriptor"),this.disallowProperty(o,"set","The property descriptor of a field descriptor"),this.disallowProperty(o,"value","The property descriptor of a field descriptor"),i.initializer=e.initializer),i},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:_(e,"finisher"),extras:this.toElementDescriptors(e.extras)}},fromClassDescriptor:function(e){var t={kind:"class",elements:e.map(this.fromElementDescriptor,this)};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),t},toClassDescriptor:function(e){var t=String(e.kind);if("class"!==t)throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator created a class descriptor with .kind "'+t+'"');this.disallowProperty(e,"key","A class descriptor"),this.disallowProperty(e,"placement","A class descriptor"),this.disallowProperty(e,"descriptor","A class descriptor"),this.disallowProperty(e,"initializer","A class descriptor"),this.disallowProperty(e,"extras","A class descriptor");var r=_(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:r}},runClassFinishers:function(e,t){for(var r=0;r<t.length;r++){var n=(0,t[r])(e);if(void 0!==n){if("function"!=typeof n)throw new TypeError("Finishers must return a constructor.");e=n}}return e},disallowProperty:function(e,t,r){if(void 0!==e[t])throw new TypeError(r+" can't have a ."+t+" property.")}};return e}function x(e){var t,r=O(e.key);"method"===e.kind?t={value:e.value,writable:!0,configurable:!0,enumerable:!1}:"get"===e.kind?t={get:e.value,configurable:!0,enumerable:!1}:"set"===e.kind?t={set:e.value,configurable:!0,enumerable:!1}:"field"===e.kind&&(t={configurable:!0,writable:!0,enumerable:!0});var n={kind:"field"===e.kind?"field":"method",key:r,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(n.decorators=e.decorators),"field"===e.kind&&(n.initializer=e.value),n}function E(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function P(e){return e.decorators&&e.decorators.length}function C(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function _(e,t){var r=e[t];if(void 0!==r&&"function"!=typeof r)throw new TypeError("Expected '"+t+"' to be a function");return r}function O(e){var t=function(e,t){if("object"!==g(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!==g(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===g(t)?t:String(t)}function j(){return j="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=T(e)););return e}(e,t);if(n){var o=Object.getOwnPropertyDescriptor(n,t);return o.get?o.get.call(arguments.length<3?e:r):o.value}},j.apply(this,arguments)}function T(e){return T=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},T(e)}function R(e,t){if(e){if("string"==typeof e)return L(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?L(e,t):void 0}}function I(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function L(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function S(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function D(){D=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var i=t&&t.prototype instanceof m?t:m,a=Object.create(i.prototype),c=new I(n||[]);return o(a,"_invoke",{value:O(e,r,c)}),a}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var p="suspendedStart",h="suspendedYield",d="executing",y="completed",v={};function m(){}function b(){}function w(){}var k={};l(k,a,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(L([])));E&&E!==r&&n.call(E,a)&&(k=E);var P=w.prototype=m.prototype=Object.create(k);function C(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function _(e,t){function r(o,i,a,c){var s=f(e[o],e,i);if("throw"!==s.type){var l=s.arg,u=l.value;return u&&"object"==g(u)&&n.call(u,"__await")?t.resolve(u.__await).then((function(e){r("next",e,a,c)}),(function(e){r("throw",e,a,c)})):t.resolve(u).then((function(e){l.value=e,a(l)}),(function(e){return r("throw",e,a,c)}))}c(s.arg)}var i;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return i=i?i.then(o,o):o()}})}function O(t,r,n){var o=p;return function(i,a){if(o===d)throw new Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:e,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var s=j(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var l=f(t,r,n);if("normal"===l.type){if(o=n.done?y:h,l.arg===v)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=y,n.method="throw",n.arg=l.arg)}}}function j(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,j(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var i=f(o,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var a=i.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,v):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function R(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function L(t){if(t||""===t){var r=t[a];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(g(t)+" is not iterable")}return b.prototype=w,o(P,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:b,configurable:!0}),b.displayName=l(w,s,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===b||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,w):(e.__proto__=w,l(e,s,"GeneratorFunction")),e.prototype=Object.create(P),e},t.awrap=function(e){return{__await:e}},C(_.prototype),l(_.prototype,c,(function(){return this})),t.AsyncIterator=_,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new _(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},C(P),l(P,s,"Generator"),l(P,a,(function(){return this})),l(P,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=L,I.prototype={constructor:I,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(R),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return c.type="throw",c.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),l=n.call(a,"finallyLoc");if(s&&l){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),R(r),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;R(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:L(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),v}},t}function B(e,t,r,n,o,i,a){try{var c=e[i](a),s=c.value}catch(e){return void r(e)}c.done?t(s):Promise.resolve(s).then(n,o)}function A(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function a(e){B(i,n,o,a,c,"next",e)}function c(e){B(i,n,o,a,c,"throw",e)}a(void 0)}))}}v.extend(BookReader.defaultOptions,{olHost:"https://openlibrary.org",enableChaptersPlugin:!0,bookId:""}),BookReader.prototype.init=(y=BookReader.prototype.init,function(){y.call(this),this.options.enableChaptersPlugin&&"embed"!==this.ui&&this._chapterInit()}),BookReader.prototype._chapterInit=A(D().mark((function e(){var t,r,n,o,i=this;return D().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=null,null===(t=this.options.table_of_contents)||void 0===t||!t.length){e.next=5;break}r=this.options.table_of_contents,e.next=9;break;case 5:return e.next=7,this.getOpenLibraryRecord(this.options.olHost,this.options.bookId);case 7:null!=(o=e.sent)&&null!==(n=o.table_of_contents)&&void 0!==n&&n.length&&(r=o.table_of_contents);case 9:r&&(this._tocEntries=r.map((function(e){return Object.assign({},e,{pageIndex:"number"==typeof e.leaf?i.book.leafNumToIndex(e.leaf):e.pagenum?i.book.getPageIndex(e.pagenum):void 0})})),this._chaptersRender(this._tocEntries),this.bind(BookReader.eventNames.pageChanged,(function(){return i._chaptersUpdateCurrent()})));case 10:case"end":return e.stop()}}),e,this)}))),BookReader.prototype._chaptersRender=function(){var e=this,t=this.shell;t.menuProviders.chapters={id:"chapters",icon:(0,n.dy)(l||(l=S(['<ia-icon-toc style="width: var(--iconWidth); height: var(--iconHeight);"></ia-icon-toc>']))),label:"Table of Contents",component:(0,n.dy)(u||(u=S(['<br-chapters-panel\n .contents="','"\n .jumpToPage="','"\n @connected="','"\n />'])),this._tocEntries,(function(t){e._chaptersUpdateCurrent(t),e.jumpToIndex(t)}),(function(t){e._chaptersPanel=t.target,e._chaptersUpdateCurrent()}))},t.updateMenuContents(),this._tocEntries.forEach((function(t,r){return e._chaptersRenderMarker(t,r)}))},BookReader.prototype._chaptersRenderMarker=function(e,t){var r=this;if(null!=e.pageIndex){var n=[e.label,e.title].filter((function(e){return e})).join(" ")||"Chapter ".concat(t+1),o=BookReader.util.cssPercentage(e.pageIndex,this.book.getNumLeafs()-1);m("<div></div>").append(m("<div />").text(n).append(m('<div class="BRchapterPage" />').text(this.book.getPageName(e.pageIndex)))).addClass("BRchapter").css({left:o}).appendTo(this.$(".BRnavline")).on("mouseenter",(function(e){var t=e.currentTarget,n=t.querySelector("div"),o=n.getBoundingClientRect(),i=t.getBoundingClientRect(),a=2*parseInt(getComputedStyle(n).paddingLeft);o.x-a<0&&n.style.setProperty("transform","translateX(-".concat(i.left-a,"px)")),r.$(".BRsearch,.BRchapter").removeClass("front"),m(e.target).addClass("front")})).on("mouseleave",(function(e){return m(e.target).removeClass("front")})).on("click",(function(){r._chaptersUpdateCurrent(e.pageIndex),r.jumpToIndex(e.pageIndex)})),this.$(".BRchapter, .BRsearch").each((function(e,t){var r=m(t);r.on("mouseenter",(function(){return r.addClass("front")})).on("mouseleave",(function(){return r.removeClass("front")}))}))}},BookReader.prototype.getOpenLibraryRecord=function(){var e=A(D().mark((function e(t,r){var n,o,i,a;return D().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o="".concat(t,"/query.json?type=/type/edition&*="),i="".concat(o,"&ocaid=").concat(r),e.next=4,m.ajax({url:i,dataType:"jsonp"});case 4:if((a=e.sent)&&a.length){e.next=9;break}return e.next=8,m.ajax({url:"".concat(o,"&source_records=ia:").concat(r),dataType:"jsonp"});case 8:a=e.sent;case 9:return e.abrupt("return",null===(n=a)||void 0===n?void 0:n[0]);case 10:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),BookReader.prototype._chaptersUpdateCurrent=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2==this.mode?Math.max.apply(Math,function(e){if(Array.isArray(e))return L(e)}(e=this.displayedIndices)||I(e)||R(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()):this.firstIndex,r=this._tocEntries.filter((function(e){return null!=e.pageIndex})).reverse(),n=r[r.findIndex((function(e){return e.pageIndex<=t}))];this._chaptersPanel&&(this._chaptersPanel.currentChapter=n)},function(e,t,r,n){var o=k(),i=t((function(e){o.initializeInstanceElements(e,a.elements)}),r),a=o.decorateClass(function(e){for(var t=[],r=function(e){return"method"===e.kind&&e.key===i.key&&e.placement===i.placement},n=0;n<e.length;n++){var o,i=e[n];if("method"===i.kind&&(o=t.find(r)))if(C(i.descriptor)||C(o.descriptor)){if(P(i)||P(o))throw new ReferenceError("Duplicated methods ("+i.key+") can't be decorated.");o.descriptor=i.descriptor}else{if(P(i)){if(P(o))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+i.key+").");o.decorators=i.decorators}E(i,o)}else t.push(i)}return t}(i.d.map(x)),e);o.initializeClassElements(i.F,a.elements),o.runClassFinishers(i.F,a.finishers)}([(0,o.Mo)("br-chapters-panel")],(function(e,t){var r=function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&b(e,t)}(a,t);var r,n,o,i=(n=a,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=T(n);if(o){var r=T(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"===g(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return w(e)}(this,e)});function a(t){var r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),r=i.call(this),e(w(r)),r.contents=t,r}return r=a,Object.defineProperty(r,"prototype",{writable:!1}),r}(t);return{F:r,d:[{kind:"field",decorators:[(0,o.Cb)({type:Array})],key:"contents",value:function(){return[]}},{kind:"field",decorators:[(0,o.Cb)({type:Object})],key:"currentChapter",value:function(){return{}}},{kind:"field",key:"jumpToPage",value:function(){return function(){}}},{kind:"method",key:"render",value:function(){var e=this;return(0,n.dy)(f||(f=S(["\n <ol>\n ","\n </ol>\n "])),this.contents.map((function(t){return e.renderTOCEntry(t)})))}},{kind:"method",key:"renderTOCEntry",value:function(e){var t=this,r=[e.label,e.title].filter((function(e){return e})).join(" "),o=null!=e.pageIndex;return(0,n.dy)(p||(p=S(['\n <li\n class="\n BRtable-contents-el\n ',"\n ",'\n "\n style="','"\n data-event-click-tracking="','"\n @click="','"\n >\n ',"\n ","\n </li>"])),o?"clickable":"",e==this.currentChapter?"current":"",(0,a.V)({marginLeft:10*(e.level-1)+"px"}),(0,i.o)(o?"BRTOCPanel|GoToChapter":void 0),(function(){return t.jumpToPage(e.pageIndex)}),r,e.pagenum?(0,n.dy)(h||(h=S(['\n <br />\n <span class="BRTOCElementPage">Page ',"</span>\n "])),e.pagenum):n.Ld)}},{kind:"method",key:"connectedCallback",value:function(){j(T(r.prototype),"connectedCallback",this).call(this),this.dispatchEvent(new CustomEvent("connected"))}},{kind:"method",key:"updated",value:function(e){var t;e.has("currentChapter")&&(null===(t=this.shadowRoot.querySelector("li.current"))||void 0===t||t.scrollIntoView({block:"nearest",behavior:"smooth"}))}},{kind:"get",static:!0,key:"styles",value:function(){return(0,n.iv)(d||(d=S(["\n ol {\n padding: 0;\n margin: 0;\n margin-right: 5px;\n }\n li {\n padding: 10px;\n overflow: hidden;\n border-radius: 4px;\n }\n li.clickable {\n font-weight: normal;\n cursor: pointer;\n transition: background-color 0.2s;\n }\n\n li.clickable:not(.current):hover {\n background-color: rgba(255,255,255, 0.05);\n }\n\n li.current {\n background-color: rgba(255,255,255,0.9);\n color: #333;\n }\n\n .BRTOCElementPage {\n font-size: 0.85em;\n opacity: .8;\n }"])))}}]}}),n.oi)},9407:function(e,t,r){r.d(t,{o:function(){return o}});var n=r(4817),o=function(e){return null!=e?e:n.Ld}}},function(e){e(e.s=235)}]);
25
+ `}render(){return c}}customElements.define("ia-icon-toc",s);var l,u,f,p,h,d,y,v=r(5311),m=r(5311);function g(e){return g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},g(e)}function b(e,t){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},b(e,t)}function w(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function k(){k=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach((function(r){t.forEach((function(t){t.kind===r&&"own"===t.placement&&this.defineClassElement(e,t)}),this)}),this)},initializeClassElements:function(e,t){var r=e.prototype;["method","field"].forEach((function(n){t.forEach((function(t){var o=t.placement;if(t.kind===n&&("static"===o||"prototype"===o)){var i="static"===o?e:r;this.defineClassElement(i,t)}}),this)}),this)},defineClassElement:function(e,t){var r=t.descriptor;if("field"===t.kind){var n=t.initializer;r={enumerable:r.enumerable,writable:r.writable,configurable:r.configurable,value:void 0===n?void 0:n.call(e)}}Object.defineProperty(e,t.key,r)},decorateClass:function(e,t){var r=[],n=[],o={static:[],prototype:[],own:[]};if(e.forEach((function(e){this.addElementPlacement(e,o)}),this),e.forEach((function(e){if(!P(e))return r.push(e);var t=this.decorateElement(e,o);r.push(t.element),r.push.apply(r,t.extras),n.push.apply(n,t.finishers)}),this),!t)return{elements:r,finishers:n};var i=this.decorateConstructor(r,t);return n.push.apply(n,i.finishers),i.finishers=n,i},addElementPlacement:function(e,t,r){var n=t[e.placement];if(!r&&-1!==n.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");n.push(e.key)},decorateElement:function(e,t){for(var r=[],n=[],o=e.decorators,i=o.length-1;i>=0;i--){var a=t[e.placement];a.splice(a.indexOf(e.key),1);var c=this.fromElementDescriptor(e),s=this.toElementFinisherExtras((0,o[i])(c)||c);e=s.element,this.addElementPlacement(e,t),s.finisher&&n.push(s.finisher);var l=s.extras;if(l){for(var u=0;u<l.length;u++)this.addElementPlacement(l[u],t);r.push.apply(r,l)}}return{element:e,finishers:n,extras:r}},decorateConstructor:function(e,t){for(var r=[],n=t.length-1;n>=0;n--){var o=this.fromClassDescriptor(e),i=this.toClassDescriptor((0,t[n])(o)||o);if(void 0!==i.finisher&&r.push(i.finisher),void 0!==i.elements){e=i.elements;for(var a=0;a<e.length-1;a++)for(var c=a+1;c<e.length;c++)if(e[a].key===e[c].key&&e[a].placement===e[c].placement)throw new TypeError("Duplicated element ("+e[a].key+")")}}return{elements:e,finishers:r}},fromElementDescriptor:function(e){var t={kind:e.kind,key:e.key,placement:e.placement,descriptor:e.descriptor};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),"field"===e.kind&&(t.initializer=e.initializer),t},toElementDescriptors:function(e){var t;if(void 0!==e)return(t=e,function(e){if(Array.isArray(e))return e}(t)||I(t)||R(t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map((function(e){var t=this.toElementDescriptor(e);return this.disallowProperty(e,"finisher","An element descriptor"),this.disallowProperty(e,"extras","An element descriptor"),t}),this)},toElementDescriptor:function(e){var t=String(e.kind);if("method"!==t&&"field"!==t)throw new TypeError('An element descriptor\'s .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "'+t+'"');var r=O(e.key),n=String(e.placement);if("static"!==n&&"prototype"!==n&&"own"!==n)throw new TypeError('An element descriptor\'s .placement property must be one of "static", "prototype" or "own", but a decorator created an element descriptor with .placement "'+n+'"');var o=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var i={kind:t,key:r,placement:n,descriptor:Object.assign({},o)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(o,"get","The property descriptor of a field descriptor"),this.disallowProperty(o,"set","The property descriptor of a field descriptor"),this.disallowProperty(o,"value","The property descriptor of a field descriptor"),i.initializer=e.initializer),i},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:_(e,"finisher"),extras:this.toElementDescriptors(e.extras)}},fromClassDescriptor:function(e){var t={kind:"class",elements:e.map(this.fromElementDescriptor,this)};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),t},toClassDescriptor:function(e){var t=String(e.kind);if("class"!==t)throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator created a class descriptor with .kind "'+t+'"');this.disallowProperty(e,"key","A class descriptor"),this.disallowProperty(e,"placement","A class descriptor"),this.disallowProperty(e,"descriptor","A class descriptor"),this.disallowProperty(e,"initializer","A class descriptor"),this.disallowProperty(e,"extras","A class descriptor");var r=_(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:r}},runClassFinishers:function(e,t){for(var r=0;r<t.length;r++){var n=(0,t[r])(e);if(void 0!==n){if("function"!=typeof n)throw new TypeError("Finishers must return a constructor.");e=n}}return e},disallowProperty:function(e,t,r){if(void 0!==e[t])throw new TypeError(r+" can't have a ."+t+" property.")}};return e}function x(e){var t,r=O(e.key);"method"===e.kind?t={value:e.value,writable:!0,configurable:!0,enumerable:!1}:"get"===e.kind?t={get:e.value,configurable:!0,enumerable:!1}:"set"===e.kind?t={set:e.value,configurable:!0,enumerable:!1}:"field"===e.kind&&(t={configurable:!0,writable:!0,enumerable:!0});var n={kind:"field"===e.kind?"field":"method",key:r,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(n.decorators=e.decorators),"field"===e.kind&&(n.initializer=e.value),n}function E(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function P(e){return e.decorators&&e.decorators.length}function C(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function _(e,t){var r=e[t];if(void 0!==r&&"function"!=typeof r)throw new TypeError("Expected '"+t+"' to be a function");return r}function O(e){var t=function(e,t){if("object"!==g(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!==g(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===g(t)?t:String(t)}function j(){return j="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=T(e)););return e}(e,t);if(n){var o=Object.getOwnPropertyDescriptor(n,t);return o.get?o.get.call(arguments.length<3?e:r):o.value}},j.apply(this,arguments)}function T(e){return T=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},T(e)}function R(e,t){if(e){if("string"==typeof e)return L(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?L(e,t):void 0}}function I(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function L(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function S(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function D(){D=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var i=t&&t.prototype instanceof m?t:m,a=Object.create(i.prototype),c=new I(n||[]);return o(a,"_invoke",{value:O(e,r,c)}),a}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var p="suspendedStart",h="suspendedYield",d="executing",y="completed",v={};function m(){}function b(){}function w(){}var k={};l(k,a,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(L([])));E&&E!==r&&n.call(E,a)&&(k=E);var P=w.prototype=m.prototype=Object.create(k);function C(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function _(e,t){function r(o,i,a,c){var s=f(e[o],e,i);if("throw"!==s.type){var l=s.arg,u=l.value;return u&&"object"==g(u)&&n.call(u,"__await")?t.resolve(u.__await).then((function(e){r("next",e,a,c)}),(function(e){r("throw",e,a,c)})):t.resolve(u).then((function(e){l.value=e,a(l)}),(function(e){return r("throw",e,a,c)}))}c(s.arg)}var i;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return i=i?i.then(o,o):o()}})}function O(t,r,n){var o=p;return function(i,a){if(o===d)throw new Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:e,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var s=j(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var l=f(t,r,n);if("normal"===l.type){if(o=n.done?y:h,l.arg===v)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=y,n.method="throw",n.arg=l.arg)}}}function j(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,j(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var i=f(o,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var a=i.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,v):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function R(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function L(t){if(t||""===t){var r=t[a];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(g(t)+" is not iterable")}return b.prototype=w,o(P,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:b,configurable:!0}),b.displayName=l(w,s,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===b||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,w):(e.__proto__=w,l(e,s,"GeneratorFunction")),e.prototype=Object.create(P),e},t.awrap=function(e){return{__await:e}},C(_.prototype),l(_.prototype,c,(function(){return this})),t.AsyncIterator=_,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new _(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},C(P),l(P,s,"Generator"),l(P,a,(function(){return this})),l(P,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=L,I.prototype={constructor:I,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(R),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return c.type="throw",c.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),l=n.call(a,"finallyLoc");if(s&&l){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),R(r),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;R(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:L(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),v}},t}function B(e,t,r,n,o,i,a){try{var c=e[i](a),s=c.value}catch(e){return void r(e)}c.done?t(s):Promise.resolve(s).then(n,o)}function A(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function a(e){B(i,n,o,a,c,"next",e)}function c(e){B(i,n,o,a,c,"throw",e)}a(void 0)}))}}v.extend(BookReader.defaultOptions,{olHost:"https://openlibrary.org",enableChaptersPlugin:!0,bookId:""}),BookReader.prototype.init=(y=BookReader.prototype.init,function(){y.call(this),this.options.enableChaptersPlugin&&"embed"!==this.ui&&this._chapterInit()}),BookReader.prototype._chapterInit=A(D().mark((function e(){var t,r,n,o,i=this;return D().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=null,null===(t=this.options.table_of_contents)||void 0===t||!t.length){e.next=5;break}r=this.options.table_of_contents,e.next=9;break;case 5:return e.next=7,this.getOpenLibraryRecord(this.options.olHost,this.options.bookId);case 7:null!=(o=e.sent)&&null!==(n=o.table_of_contents)&&void 0!==n&&n.length&&(r=o.table_of_contents);case 9:r&&(this._tocEntries=r.map((function(e){return Object.assign({},e,{pageIndex:"number"==typeof e.leaf?i.book.leafNumToIndex(e.leaf):e.pagenum?i.book.getPageIndex(e.pagenum):void 0})})),this._chaptersRender(this._tocEntries),this.bind(BookReader.eventNames.pageChanged,(function(){return i._chaptersUpdateCurrent()})));case 10:case"end":return e.stop()}}),e,this)}))),BookReader.prototype._chaptersRender=function(){var e=this,t=this.shell;t.menuProviders.chapters={id:"chapters",icon:(0,n.dy)(l||(l=S(['<ia-icon-toc style="width: var(--iconWidth); height: var(--iconHeight);"></ia-icon-toc>']))),label:"Table of Contents",component:(0,n.dy)(u||(u=S(['<br-chapters-panel\n .contents="','"\n .jumpToPage="','"\n @connected="','"\n />'])),this._tocEntries,(function(t){e._chaptersUpdateCurrent(t),e.jumpToIndex(t)}),(function(t){e._chaptersPanel=t.target,e._chaptersUpdateCurrent()}))},t.addMenuShortcut("chapters"),t.updateMenuContents(),this._tocEntries.forEach((function(t,r){return e._chaptersRenderMarker(t,r)}))},BookReader.prototype._chaptersRenderMarker=function(e,t){var r=this;if(null!=e.pageIndex){var n=[e.label,e.title].filter((function(e){return e})).join(" ")||"Chapter ".concat(t+1),o=BookReader.util.cssPercentage(e.pageIndex,this.book.getNumLeafs()-1);m("<div></div>").append(m("<div />").text(n).append(m('<div class="BRchapterPage" />').text(this.book.getPageName(e.pageIndex)))).addClass("BRchapter").css({left:o}).appendTo(this.$(".BRnavline")).on("mouseenter",(function(e){var t=e.currentTarget,n=t.querySelector("div"),o=n.getBoundingClientRect(),i=t.getBoundingClientRect(),a=2*parseInt(getComputedStyle(n).paddingLeft);o.x-a<0&&n.style.setProperty("transform","translateX(-".concat(i.left-a,"px)")),r.$(".BRsearch,.BRchapter").removeClass("front"),m(e.target).addClass("front")})).on("mouseleave",(function(e){return m(e.target).removeClass("front")})).on("click",(function(){r._chaptersUpdateCurrent(e.pageIndex),r.jumpToIndex(e.pageIndex)})),this.$(".BRchapter, .BRsearch").each((function(e,t){var r=m(t);r.on("mouseenter",(function(){return r.addClass("front")})).on("mouseleave",(function(){return r.removeClass("front")}))}))}},BookReader.prototype.getOpenLibraryRecord=function(){var e=A(D().mark((function e(t,r){var n,o,i,a;return D().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o="".concat(t,"/query.json?type=/type/edition&*="),i="".concat(o,"&ocaid=").concat(r),e.next=4,m.ajax({url:i,dataType:"jsonp"});case 4:if((a=e.sent)&&a.length){e.next=9;break}return e.next=8,m.ajax({url:"".concat(o,"&source_records=ia:").concat(r),dataType:"jsonp"});case 8:a=e.sent;case 9:return e.abrupt("return",null===(n=a)||void 0===n?void 0:n[0]);case 10:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),BookReader.prototype._chaptersUpdateCurrent=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2==this.mode?Math.max.apply(Math,function(e){if(Array.isArray(e))return L(e)}(e=this.displayedIndices)||I(e)||R(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()):this.firstIndex,r=this._tocEntries.filter((function(e){return null!=e.pageIndex})).reverse(),n=r[r.findIndex((function(e){return e.pageIndex<=t}))];this._chaptersPanel&&(this._chaptersPanel.currentChapter=n)},function(e,t,r,n){var o=k(),i=t((function(e){o.initializeInstanceElements(e,a.elements)}),r),a=o.decorateClass(function(e){for(var t=[],r=function(e){return"method"===e.kind&&e.key===i.key&&e.placement===i.placement},n=0;n<e.length;n++){var o,i=e[n];if("method"===i.kind&&(o=t.find(r)))if(C(i.descriptor)||C(o.descriptor)){if(P(i)||P(o))throw new ReferenceError("Duplicated methods ("+i.key+") can't be decorated.");o.descriptor=i.descriptor}else{if(P(i)){if(P(o))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+i.key+").");o.decorators=i.decorators}E(i,o)}else t.push(i)}return t}(i.d.map(x)),e);o.initializeClassElements(i.F,a.elements),o.runClassFinishers(i.F,a.finishers)}([(0,o.Mo)("br-chapters-panel")],(function(e,t){var r=function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&b(e,t)}(a,t);var r,n,o,i=(n=a,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=T(n);if(o){var r=T(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"===g(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return w(e)}(this,e)});function a(t){var r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),r=i.call(this),e(w(r)),r.contents=t,r}return r=a,Object.defineProperty(r,"prototype",{writable:!1}),r}(t);return{F:r,d:[{kind:"field",decorators:[(0,o.Cb)({type:Array})],key:"contents",value:function(){return[]}},{kind:"field",decorators:[(0,o.Cb)({type:Object})],key:"currentChapter",value:function(){return{}}},{kind:"field",key:"jumpToPage",value:function(){return function(){}}},{kind:"method",key:"render",value:function(){var e=this;return(0,n.dy)(f||(f=S(["\n <ol>\n ","\n </ol>\n "])),this.contents.map((function(t){return e.renderTOCEntry(t)})))}},{kind:"method",key:"renderTOCEntry",value:function(e){var t=this,r=[e.label,e.title].filter((function(e){return e})).join(" "),o=null!=e.pageIndex;return(0,n.dy)(p||(p=S(['\n <li\n class="\n BRtable-contents-el\n ',"\n ",'\n "\n style="','"\n data-event-click-tracking="','"\n @click="','"\n >\n ',"\n ","\n </li>"])),o?"clickable":"",e==this.currentChapter?"current":"",(0,a.V)({marginLeft:10*(e.level-1)+"px"}),(0,i.o)(o?"BRTOCPanel|GoToChapter":void 0),(function(){return t.jumpToPage(e.pageIndex)}),r,e.pagenum?(0,n.dy)(h||(h=S(['\n <br />\n <span class="BRTOCElementPage">Page ',"</span>\n "])),e.pagenum):n.Ld)}},{kind:"method",key:"connectedCallback",value:function(){j(T(r.prototype),"connectedCallback",this).call(this),this.dispatchEvent(new CustomEvent("connected"))}},{kind:"method",key:"updated",value:function(e){var t;e.has("currentChapter")&&(null===(t=this.shadowRoot.querySelector("li.current"))||void 0===t||t.scrollIntoView({block:"nearest",behavior:"smooth"}))}},{kind:"get",static:!0,key:"styles",value:function(){return(0,n.iv)(d||(d=S(["\n ol {\n padding: 0;\n margin: 0;\n margin-right: 5px;\n }\n li {\n padding: 10px;\n overflow: hidden;\n border-radius: 4px;\n }\n li.clickable {\n font-weight: normal;\n cursor: pointer;\n transition: background-color 0.2s;\n }\n\n li.clickable:not(.current):hover {\n background-color: rgba(255,255,255, 0.05);\n }\n\n li.current {\n background-color: rgba(255,255,255,0.9);\n color: #333;\n }\n\n .BRTOCElementPage {\n font-size: 0.85em;\n opacity: .8;\n }"])))}}]}}),n.oi)},9407:function(e,t,r){r.d(t,{o:function(){return o}});var n=r(4817),o=function(e){return null!=e?e:n.Ld}}},function(e){e(e.s=235)}]);
26
26
  //# sourceMappingURL=plugin.chapters.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugins/plugin.chapters.js","mappings":";odAEA,EAAe,IAAI;;;;;;;;;;ECCnB,MAAMA,UAAkB,KACXC,oBACT,OAAO,IAAG;;;;;;;;;;;;;KAcZ,CAEAC,SACE,OAAO,CACT,EAGFC,eAAeC,OAAO,cAAeJ,GAErC,gBCRsCK,uwPAnBtCC,EAAA,kBAAAC,CAAA,MAAAC,EAAAD,EAAA,GAAAE,EAAAC,OAAAC,UAAAC,EAAAH,EAAAI,eAAAC,EAAAJ,OAAAK,gBAAA,SAAAP,EAAAD,EAAAE,GAAAD,EAAAD,GAAAE,EAAAO,KAAA,EAAAC,EAAA,mBAAAC,OAAAA,OAAA,GAAAC,EAAAF,EAAAG,UAAA,aAAAC,EAAAJ,EAAAK,eAAA,kBAAAC,EAAAN,EAAAO,aAAA,yBAAApB,EAAAI,EAAAD,EAAAE,GAAA,OAAAC,OAAAK,eAAAP,EAAAD,EAAA,CAAAS,MAAAP,EAAAgB,YAAA,EAAAC,cAAA,EAAAC,UAAA,IAAAnB,EAAAD,EAAA,KAAAH,EAAA,aAAAI,GAAAJ,EAAA,SAAAI,EAAAD,EAAAE,GAAA,OAAAD,EAAAD,GAAAE,CAAA,WAAAmB,EAAAp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UY,EAAAA,EAAAA,IAAIwG,IAAAA,EAAAtG,EAAA,uFAEeQ,EAAStB,SAC7CqH,EAAAA,GAER,GAAC,CAAAjB,KAAA,SAAA5I,IAAA,oBAAAlG,MAED,WACEgQ,EAAAC,EAzDS5B,EAAe1O,WAAA,0BAAAyB,KAAA,MA0DxBiG,KAAK6I,cAAc,IAAIC,YAAY,aACrC,GAAC,CAAArB,KAAA,SAAA5I,IAAA,UAAAlG,MAED,SAAQoQ,GACuC,IAAAC,EAAzCD,EAAkBE,IAAI,oBACmB,QAA3CD,EAAAhJ,KAAKkJ,WAAW5E,cAAc,qBAAa,IAAA0E,GAA3CA,EAA6CG,eAAe,CAC1DC,MAAO,UACPC,SAAU,WAGhB,GAAC,CAAA5B,KAAA,MAAA6B,QAAA,EAAAzK,IAAA,SAAAlG,MAED,WACE,OAAOmL,EAAAA,EAAAA,IAAGyF,IAAAA,EAAApH,EAAA,inBA8BZ,IAAC,GArGkCqH,EAAAA,wECnLxBvP,EAAgB,SAAAA,GAAA,OAAa,MAAAA,EAAAA,EAAS9B,EAAAA,EAAA","sources":["webpack://@internetarchive/bookreader/./node_modules/@internetarchive/icon-toc/index.js","webpack://@internetarchive/bookreader/./node_modules/@internetarchive/icon-toc/icon-toc.js","webpack://@internetarchive/bookreader/./src/plugins/plugin.chapters.js","webpack://@internetarchive/bookreader/../src/directives/if-defined.ts"],"sourcesContent":["import { html } from 'lit';\n\nexport default html`\n<svg\n viewBox=\"0 0 24 24\"\n xmlns=\"http://www.w3.org/2000/svg\"\n aria-labelledby=\"tocTitleID tocDescID\"\n>\n <title id=\"tocTitleID\">Table of contents icon</title>\n <desc id=\"tocDescID\">An illustration of three text list items</desc>\n <g class=\"fill-color\" fill-rule=\"evenodd\"><rect height=\"3\" rx=\"1.5\" width=\"18\" x=\"6\"/><rect height=\"3\" rx=\"1.5\" width=\"18\" x=\"6\" y=\"21\"/><rect height=\"3\" rx=\"1.5\" width=\"18\" x=\"6\" y=\"14\"/><rect height=\"3\" rx=\"1.5\" width=\"18\" x=\"6\" y=\"7\"/><rect height=\"3\" rx=\"1.5\" width=\"4\"/><rect height=\"3\" rx=\"1.5\" width=\"4\" y=\"21\"/><rect height=\"3\" rx=\"1.5\" width=\"4\" y=\"14\"/><rect height=\"3\" rx=\"1.5\" width=\"4\" y=\"7\"/></g>\n</svg>\n`;\n","import icon from './index.js';\nimport { css, LitElement } from 'lit';\n\nclass IAIconToc extends LitElement {\n static get styles() {\n return css`\n :host {\n width: var(--iconWidth, 'auto');\n height: var(--iconHeight, 'auto');\n }\n\n .fill-color {\n fill: var(--iconFillColor);\n }\n\n .stroke-color {\n stroke: var(--iconStrokeColor);\n }\n `;\n }\n\n render() {\n return icon;\n }\n}\n\ncustomElements.define('ia-icon-toc', IAIconToc);\n\nexport default IAIconToc;\n","/* global BookReader */\nimport { css, html, LitElement, nothing } from \"lit\";\nimport { customElement, property } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport '@internetarchive/icon-toc/icon-toc';\n/** @typedef {import('@/src/BookNavigator/book-navigator.js').BookNavigator} BookNavigator */\n\n/**\n * Plugin for chapter markers in BookReader. Fetches from openlibrary.org\n * Could be forked, or extended to alter behavior\n */\n\njQuery.extend(BookReader.defaultOptions, {\n olHost: 'https://openlibrary.org',\n enableChaptersPlugin: true,\n bookId: '',\n});\n\n/** @override Extend to call Open Library for TOC */\nBookReader.prototype.init = (function(super_) {\n return function() {\n super_.call(this);\n if (this.options.enableChaptersPlugin && this.ui !== 'embed') {\n this._chapterInit();\n }\n };\n})(BookReader.prototype.init);\n\nBookReader.prototype._chapterInit = async function() {\n let rawTableOfContents = null;\n // Prefer IA TOC for now, until we update the second half to check for\n // `openlibrary_edition` on the IA metadata instead of making a bunch of\n // requests to OL.\n if (this.options.table_of_contents?.length) {\n rawTableOfContents = this.options.table_of_contents;\n } else {\n const olEdition = await this.getOpenLibraryRecord(this.options.olHost, this.options.bookId);\n if (olEdition?.table_of_contents?.length) {\n rawTableOfContents = olEdition.table_of_contents;\n }\n }\n\n if (rawTableOfContents) {\n this._tocEntries = rawTableOfContents\n .map(rawTOCEntry => (Object.assign({}, rawTOCEntry, {\n pageIndex: (\n typeof(rawTOCEntry.leaf) == 'number' ? this.book.leafNumToIndex(rawTOCEntry.leaf) :\n rawTOCEntry.pagenum ? this.book.getPageIndex(rawTOCEntry.pagenum) :\n undefined\n ),\n })));\n this._chaptersRender(this._tocEntries);\n this.bind(BookReader.eventNames.pageChanged, () => this._chaptersUpdateCurrent());\n }\n};\n\n/**\n * Update the table of contents based on array of TOC entries.\n */\nBookReader.prototype._chaptersRender = function() {\n const shell = /** @type {BookNavigator} */(this.shell);\n shell.menuProviders['chapters'] = {\n id: 'chapters',\n icon: html`<ia-icon-toc style=\"width: var(--iconWidth); height: var(--iconHeight);\"></ia-icon-toc>`,\n label: 'Table of Contents',\n component: html`<br-chapters-panel\n .contents=\"${this._tocEntries}\"\n .jumpToPage=\"${(pageIndex) => {\n this._chaptersUpdateCurrent(pageIndex);\n this.jumpToIndex(pageIndex);\n }}\"\n @connected=\"${(e) => {\n this._chaptersPanel = e.target;\n this._chaptersUpdateCurrent();\n }}\"\n />`,\n };\n shell.updateMenuContents();\n this._tocEntries.forEach((tocEntry, i) => this._chaptersRenderMarker(tocEntry, i));\n};\n\n/**\n * @typedef {Object} TocEntry\n * Table of contents entry as defined by Open Library, with some extra values for internal use\n * @property {number} [level]\n * @property {string} [label]\n * @property {string} [title]\n * @property {PageString} [pagenum]\n * @property {LeafNum} [leaf]\n * @property {number} [pageIndex] - Added\n *\n * @example {\n * \"pagenum\": \"17\",\n * \"level\": 1,\n * \"label\": \"CHAPTER I\",\n * \"title\": \"THE COUNTRY AND THE MISSION\"\n * }\n */\n\n/**\n * @param {TocEntry} tocEntry\n * @param {number} entryIndex\n */\nBookReader.prototype._chaptersRenderMarker = function(tocEntry, entryIndex) {\n if (tocEntry.pageIndex == undefined) return;\n\n //creates a string with non-void tocEntry.label and tocEntry.title\n const chapterStr = [tocEntry.label, tocEntry.title]\n .filter(x => x)\n .join(' ') || `Chapter ${entryIndex + 1}`;\n\n const percentThrough = BookReader.util.cssPercentage(tocEntry.pageIndex, this.book.getNumLeafs() - 1);\n $(`<div></div>`)\n .append(\n $('<div />')\n .text(chapterStr)\n .append(\n $('<div class=\"BRchapterPage\" />')\n .text(this.book.getPageName(tocEntry.pageIndex))\n )\n )\n .addClass('BRchapter')\n .css({ left: percentThrough })\n .appendTo(this.$('.BRnavline'))\n .on(\"mouseenter\", event => {\n // remove hover effect from other markers then turn on just for this\n const marker = event.currentTarget;\n const tooltip = marker.querySelector('div');\n const tooltipOffset = tooltip.getBoundingClientRect();\n const targetOffset = marker.getBoundingClientRect();\n const boxSizeAdjust = parseInt(getComputedStyle(tooltip).paddingLeft) * 2;\n if (tooltipOffset.x - boxSizeAdjust < 0) {\n tooltip.style.setProperty('transform', `translateX(-${targetOffset.left - boxSizeAdjust}px)`);\n }\n this.$('.BRsearch,.BRchapter').removeClass('front');\n $(event.target).addClass('front');\n })\n .on(\"mouseleave\", event => $(event.target).removeClass('front'))\n .on('click', () => {\n this._chaptersUpdateCurrent(tocEntry.pageIndex);\n this.jumpToIndex(tocEntry.pageIndex);\n });\n\n this.$('.BRchapter, .BRsearch').each((i, el) => {\n const $el = $(el);\n $el\n .on(\"mouseenter\", () => $el.addClass('front'))\n .on(\"mouseleave\", () => $el.removeClass('front'));\n });\n};\n\n/**\n * This makes a call to OL API and calls the given callback function with the\n * response from the API.\n *\n * @param {string} olHost\n * @param {string} ocaid\n */\nBookReader.prototype.getOpenLibraryRecord = async function (olHost, ocaid) {\n // Try looking up by ocaid first, then by source_record\n const baseURL = `${olHost}/query.json?type=/type/edition&*=`;\n const fetchUrlByBookId = `${baseURL}&ocaid=${ocaid}`;\n\n let data = await $.ajax({ url: fetchUrlByBookId, dataType: 'jsonp' });\n\n if (!data || !data.length) {\n // try sourceid\n data = await $.ajax({ url: `${baseURL}&source_records=ia:${ocaid}`, dataType: 'jsonp' });\n }\n\n return data?.[0];\n};\n\n/**\n * @private\n * Highlights the current chapter based on current page\n * @param {PageIndex} curIndex\n */\nBookReader.prototype._chaptersUpdateCurrent = function(\n curIndex = (this.mode == 2 ? Math.max(...this.displayedIndices) : this.firstIndex)\n) {\n const tocEntriesIndexed = this._tocEntries.filter((el) => el.pageIndex != undefined).reverse();\n const currChapter = tocEntriesIndexed[\n // subtract one so that 2up shows the right label\n tocEntriesIndexed.findIndex((chapter) => chapter.pageIndex <= curIndex)\n ];\n if (this._chaptersPanel) {\n this._chaptersPanel.currentChapter = currChapter;\n }\n};\n\n@customElement('br-chapters-panel')\nexport class BRChaptersPanel extends LitElement {\n /** @type {TocEntry[]} */\n @property({ type: Array })\n contents = [];\n\n /** @type {TocEntry?} */\n @property({ type: Object })\n currentChapter = {};\n\n /** @type {(pageIndex: PageIndex) => void} */\n jumpToPage = () => {};\n\n /**\n * @param {TocEntry[]} contents\n */\n constructor(contents) {\n super();\n this.contents = contents;\n }\n\n render() {\n return html`\n <ol>\n ${this.contents.map(tocEntry => this.renderTOCEntry(tocEntry))}\n </ol>\n `;\n }\n\n /**\n * @param {TocEntry} tocEntry\n */\n renderTOCEntry(tocEntry) {\n const chapterTitle = [tocEntry.label, tocEntry.title]\n .filter(x => x)\n .join(' ');\n const clickable = tocEntry.pageIndex != undefined;\n // note the click-tracking won't work...\n return html`\n <li\n class=\"\n BRtable-contents-el\n ${clickable ? 'clickable' : ''}\n ${tocEntry == this.currentChapter ? 'current' : ''}\n \"\n style=\"${styleMap({marginLeft: (tocEntry.level - 1) * 10 + 'px'})}\"\n data-event-click-tracking=\"${ifDefined(clickable ? \"BRTOCPanel|GoToChapter\" : undefined)}\"\n @click=\"${() => this.jumpToPage(tocEntry.pageIndex)}\"\n >\n ${chapterTitle}\n ${tocEntry.pagenum ? html`\n <br />\n <span class=\"BRTOCElementPage\">Page ${tocEntry.pagenum}</span>\n ` : nothing}\n </li>`;\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.dispatchEvent(new CustomEvent('connected'));\n }\n\n updated(changedProperties) {\n if (changedProperties.has('currentChapter')) {\n this.shadowRoot.querySelector('li.current')?.scrollIntoView({\n block: 'nearest',\n behavior: 'smooth',\n });\n }\n }\n\n static get styles() {\n return css`\n ol {\n padding: 0;\n margin: 0;\n margin-right: 5px;\n }\n li {\n padding: 10px;\n overflow: hidden;\n border-radius: 4px;\n }\n li.clickable {\n font-weight: normal;\n cursor: pointer;\n transition: background-color 0.2s;\n }\n\n li.clickable:not(.current):hover {\n background-color: rgba(255,255,255, 0.05);\n }\n\n li.current {\n background-color: rgba(255,255,255,0.9);\n color: #333;\n }\n\n .BRTOCElementPage {\n font-size: 0.85em;\n opacity: .8;\n }`;\n }\n}\n","/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {nothing} from '../lit-html.js';\n\n/**\n * For AttributeParts, sets the attribute if the value is defined and removes\n * the attribute if the value is undefined.\n *\n * For other part types, this directive is a no-op.\n */\nexport const ifDefined = <T>(value: T) => value ?? nothing;\n"],"names":["IAIconToc","styles","render","customElements","define","super_","_regeneratorRuntime","e","t","r","Object","prototype","n","hasOwnProperty","o","defineProperty","value","i","Symbol","a","iterator","c","asyncIterator","u","toStringTag","enumerable","configurable","writable","wrap","Generator","create","Context","makeInvokeMethod","tryCatch","type","arg","call","h","l","f","s","y","GeneratorFunction","GeneratorFunctionPrototype","p","d","getPrototypeOf","v","values","g","defineIteratorMethods","forEach","_invoke","AsyncIterator","invoke","_typeof","resolve","__await","then","callInvokeWithMethodAndArg","Error","done","method","delegate","maybeInvokeDelegate","sent","_sent","dispatchException","abrupt","return","TypeError","resultName","next","nextLoc","pushTryEntry","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","push","resetTryEntry","completion","reset","isNaN","length","displayName","isGeneratorFunction","constructor","name","mark","setPrototypeOf","__proto__","awrap","async","Promise","keys","reverse","pop","prev","charAt","slice","stop","rval","handle","complete","finish","catch","delegateYield","asyncGeneratorStep","gen","reject","_next","_throw","key","info","error","_asyncToGenerator","fn","self","args","arguments","apply","err","undefined","jQuery","extend","BookReader","defaultOptions","olHost","enableChaptersPlugin","bookId","init","this","options","ui","_chapterInit","_callee","_this$options$table_o","rawTableOfContents","_olEdition$table_of_c","olEdition","_this","_context","table_of_contents","getOpenLibraryRecord","_tocEntries","map","rawTOCEntry","assign","pageIndex","leaf","book","leafNumToIndex","pagenum","getPageIndex","_chaptersRender","bind","eventNames","pageChanged","_chaptersUpdateCurrent","_this2","shell","menuProviders","id","icon","html","_templateObject","_taggedTemplateLiteral","label","component","_templateObject2","jumpToIndex","_chaptersPanel","target","updateMenuContents","tocEntry","_chaptersRenderMarker","entryIndex","_this3","chapterStr","title","filter","x","join","concat","percentThrough","util","cssPercentage","getNumLeafs","$","append","text","getPageName","addClass","css","left","appendTo","on","event","marker","currentTarget","tooltip","querySelector","tooltipOffset","getBoundingClientRect","targetOffset","boxSizeAdjust","parseInt","getComputedStyle","paddingLeft","style","setProperty","removeClass","each","el","$el","_ref2","_callee2","ocaid","_data","baseURL","fetchUrlByBookId","data","_context2","ajax","url","dataType","_x","_x2","curIndex","mode","Math","max","displayedIndices","firstIndex","tocEntriesIndexed","currChapter","findIndex","chapter","currentChapter","_decorate","customElement","_initialize","_LitElement","BRChaptersPanel","_LitElement2","_inherits","_super","contents","_this4","_classCallCheck","_assertThisInitialized","F","kind","decorators","property","Array","_this5","_templateObject3","renderTOCEntry","_this6","chapterTitle","clickable","_templateObject4","styleMap","marginLeft","level","ifDefined","jumpToPage","_templateObject5","nothing","_get","_getPrototypeOf","dispatchEvent","CustomEvent","changedProperties","_this$shadowRoot$quer","has","shadowRoot","scrollIntoView","block","behavior","static","_templateObject6","LitElement"],"sourceRoot":""}
1
+ {"version":3,"file":"plugins/plugin.chapters.js","mappings":";odAEA,EAAe,IAAI;;;;;;;;;;ECCnB,MAAMA,UAAkB,KACXC,oBACT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AAA,EAAArH,EAAA,inBA8BZ,IAAC,GArGkCsH,EAAAA,wECpLxBxP,EAAgB,SAAAA,GAAA,OAAa,MAAAA,EAAAA,EAAS9B,EAAAA,EAAA","sources":["webpack://@internetarchive/bookreader/./node_modules/@internetarchive/icon-toc/index.js","webpack://@internetarchive/bookreader/./node_modules/@internetarchive/icon-toc/icon-toc.js","webpack://@internetarchive/bookreader/./src/plugins/plugin.chapters.js","webpack://@internetarchive/bookreader/../src/directives/if-defined.ts"],"sourcesContent":["import { html } from 'lit';\n\nexport default html`\n<svg\n viewBox=\"0 0 24 24\"\n xmlns=\"http://www.w3.org/2000/svg\"\n aria-labelledby=\"tocTitleID tocDescID\"\n>\n <title id=\"tocTitleID\">Table of contents icon</title>\n <desc id=\"tocDescID\">An illustration of three text list items</desc>\n <g class=\"fill-color\" fill-rule=\"evenodd\"><rect height=\"3\" rx=\"1.5\" width=\"18\" x=\"6\"/><rect height=\"3\" rx=\"1.5\" width=\"18\" x=\"6\" y=\"21\"/><rect height=\"3\" rx=\"1.5\" width=\"18\" x=\"6\" y=\"14\"/><rect height=\"3\" rx=\"1.5\" width=\"18\" x=\"6\" y=\"7\"/><rect height=\"3\" rx=\"1.5\" width=\"4\"/><rect height=\"3\" rx=\"1.5\" width=\"4\" y=\"21\"/><rect height=\"3\" rx=\"1.5\" width=\"4\" y=\"14\"/><rect height=\"3\" rx=\"1.5\" width=\"4\" y=\"7\"/></g>\n</svg>\n`;\n","import icon from './index.js';\nimport { css, LitElement } from 'lit';\n\nclass IAIconToc extends LitElement {\n static get styles() {\n return css`\n :host {\n width: var(--iconWidth, 'auto');\n height: var(--iconHeight, 'auto');\n }\n\n .fill-color {\n fill: var(--iconFillColor);\n }\n\n .stroke-color {\n stroke: var(--iconStrokeColor);\n }\n `;\n }\n\n render() {\n return icon;\n }\n}\n\ncustomElements.define('ia-icon-toc', IAIconToc);\n\nexport default IAIconToc;\n","/* global BookReader */\nimport { css, html, LitElement, nothing } from \"lit\";\nimport { customElement, property } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport '@internetarchive/icon-toc/icon-toc';\n/** @typedef {import('@/src/BookNavigator/book-navigator.js').BookNavigator} BookNavigator */\n\n/**\n * Plugin for chapter markers in BookReader. Fetches from openlibrary.org\n * Could be forked, or extended to alter behavior\n */\n\njQuery.extend(BookReader.defaultOptions, {\n olHost: 'https://openlibrary.org',\n enableChaptersPlugin: true,\n bookId: '',\n});\n\n/** @override Extend to call Open Library for TOC */\nBookReader.prototype.init = (function(super_) {\n return function() {\n super_.call(this);\n if (this.options.enableChaptersPlugin && this.ui !== 'embed') {\n this._chapterInit();\n }\n };\n})(BookReader.prototype.init);\n\nBookReader.prototype._chapterInit = async function() {\n let rawTableOfContents = null;\n // Prefer IA TOC for now, until we update the second half to check for\n // `openlibrary_edition` on the IA metadata instead of making a bunch of\n // requests to OL.\n if (this.options.table_of_contents?.length) {\n rawTableOfContents = this.options.table_of_contents;\n } else {\n const olEdition = await this.getOpenLibraryRecord(this.options.olHost, this.options.bookId);\n if (olEdition?.table_of_contents?.length) {\n rawTableOfContents = olEdition.table_of_contents;\n }\n }\n\n if (rawTableOfContents) {\n this._tocEntries = rawTableOfContents\n .map(rawTOCEntry => (Object.assign({}, rawTOCEntry, {\n pageIndex: (\n typeof(rawTOCEntry.leaf) == 'number' ? this.book.leafNumToIndex(rawTOCEntry.leaf) :\n rawTOCEntry.pagenum ? this.book.getPageIndex(rawTOCEntry.pagenum) :\n undefined\n ),\n })));\n this._chaptersRender(this._tocEntries);\n this.bind(BookReader.eventNames.pageChanged, () => this._chaptersUpdateCurrent());\n }\n};\n\n/**\n * Update the table of contents based on array of TOC entries.\n */\nBookReader.prototype._chaptersRender = function() {\n const shell = /** @type {BookNavigator} */(this.shell);\n shell.menuProviders['chapters'] = {\n id: 'chapters',\n icon: html`<ia-icon-toc style=\"width: var(--iconWidth); height: var(--iconHeight);\"></ia-icon-toc>`,\n label: 'Table of Contents',\n component: html`<br-chapters-panel\n .contents=\"${this._tocEntries}\"\n .jumpToPage=\"${(pageIndex) => {\n this._chaptersUpdateCurrent(pageIndex);\n this.jumpToIndex(pageIndex);\n }}\"\n @connected=\"${(e) => {\n this._chaptersPanel = e.target;\n this._chaptersUpdateCurrent();\n }}\"\n />`,\n };\n shell.addMenuShortcut('chapters');\n shell.updateMenuContents();\n this._tocEntries.forEach((tocEntry, i) => this._chaptersRenderMarker(tocEntry, i));\n};\n\n/**\n * @typedef {Object} TocEntry\n * Table of contents entry as defined by Open Library, with some extra values for internal use\n * @property {number} [level]\n * @property {string} [label]\n * @property {string} [title]\n * @property {PageString} [pagenum]\n * @property {LeafNum} [leaf]\n * @property {number} [pageIndex] - Added\n *\n * @example {\n * \"pagenum\": \"17\",\n * \"level\": 1,\n * \"label\": \"CHAPTER I\",\n * \"title\": \"THE COUNTRY AND THE MISSION\"\n * }\n */\n\n/**\n * @param {TocEntry} tocEntry\n * @param {number} entryIndex\n */\nBookReader.prototype._chaptersRenderMarker = function(tocEntry, entryIndex) {\n if (tocEntry.pageIndex == undefined) return;\n\n //creates a string with non-void tocEntry.label and tocEntry.title\n const chapterStr = [tocEntry.label, tocEntry.title]\n .filter(x => x)\n .join(' ') || `Chapter ${entryIndex + 1}`;\n\n const percentThrough = BookReader.util.cssPercentage(tocEntry.pageIndex, this.book.getNumLeafs() - 1);\n $(`<div></div>`)\n .append(\n $('<div />')\n .text(chapterStr)\n .append(\n $('<div class=\"BRchapterPage\" />')\n .text(this.book.getPageName(tocEntry.pageIndex))\n )\n )\n .addClass('BRchapter')\n .css({ left: percentThrough })\n .appendTo(this.$('.BRnavline'))\n .on(\"mouseenter\", event => {\n // remove hover effect from other markers then turn on just for this\n const marker = event.currentTarget;\n const tooltip = marker.querySelector('div');\n const tooltipOffset = tooltip.getBoundingClientRect();\n const targetOffset = marker.getBoundingClientRect();\n const boxSizeAdjust = parseInt(getComputedStyle(tooltip).paddingLeft) * 2;\n if (tooltipOffset.x - boxSizeAdjust < 0) {\n tooltip.style.setProperty('transform', `translateX(-${targetOffset.left - boxSizeAdjust}px)`);\n }\n this.$('.BRsearch,.BRchapter').removeClass('front');\n $(event.target).addClass('front');\n })\n .on(\"mouseleave\", event => $(event.target).removeClass('front'))\n .on('click', () => {\n this._chaptersUpdateCurrent(tocEntry.pageIndex);\n this.jumpToIndex(tocEntry.pageIndex);\n });\n\n this.$('.BRchapter, .BRsearch').each((i, el) => {\n const $el = $(el);\n $el\n .on(\"mouseenter\", () => $el.addClass('front'))\n .on(\"mouseleave\", () => $el.removeClass('front'));\n });\n};\n\n/**\n * This makes a call to OL API and calls the given callback function with the\n * response from the API.\n *\n * @param {string} olHost\n * @param {string} ocaid\n */\nBookReader.prototype.getOpenLibraryRecord = async function (olHost, ocaid) {\n // Try looking up by ocaid first, then by source_record\n const baseURL = `${olHost}/query.json?type=/type/edition&*=`;\n const fetchUrlByBookId = `${baseURL}&ocaid=${ocaid}`;\n\n let data = await $.ajax({ url: fetchUrlByBookId, dataType: 'jsonp' });\n\n if (!data || !data.length) {\n // try sourceid\n data = await $.ajax({ url: `${baseURL}&source_records=ia:${ocaid}`, dataType: 'jsonp' });\n }\n\n return data?.[0];\n};\n\n/**\n * @private\n * Highlights the current chapter based on current page\n * @param {PageIndex} curIndex\n */\nBookReader.prototype._chaptersUpdateCurrent = function(\n curIndex = (this.mode == 2 ? Math.max(...this.displayedIndices) : this.firstIndex)\n) {\n const tocEntriesIndexed = this._tocEntries.filter((el) => el.pageIndex != undefined).reverse();\n const currChapter = tocEntriesIndexed[\n // subtract one so that 2up shows the right label\n tocEntriesIndexed.findIndex((chapter) => chapter.pageIndex <= curIndex)\n ];\n if (this._chaptersPanel) {\n this._chaptersPanel.currentChapter = currChapter;\n }\n};\n\n@customElement('br-chapters-panel')\nexport class BRChaptersPanel extends LitElement {\n /** @type {TocEntry[]} */\n @property({ type: Array })\n contents = [];\n\n /** @type {TocEntry?} */\n @property({ type: Object })\n currentChapter = {};\n\n /** @type {(pageIndex: PageIndex) => void} */\n jumpToPage = () => {};\n\n /**\n * @param {TocEntry[]} contents\n */\n constructor(contents) {\n super();\n this.contents = contents;\n }\n\n render() {\n return html`\n <ol>\n ${this.contents.map(tocEntry => this.renderTOCEntry(tocEntry))}\n </ol>\n `;\n }\n\n /**\n * @param {TocEntry} tocEntry\n */\n renderTOCEntry(tocEntry) {\n const chapterTitle = [tocEntry.label, tocEntry.title]\n .filter(x => x)\n .join(' ');\n const clickable = tocEntry.pageIndex != undefined;\n // note the click-tracking won't work...\n return html`\n <li\n class=\"\n BRtable-contents-el\n ${clickable ? 'clickable' : ''}\n ${tocEntry == this.currentChapter ? 'current' : ''}\n \"\n style=\"${styleMap({marginLeft: (tocEntry.level - 1) * 10 + 'px'})}\"\n data-event-click-tracking=\"${ifDefined(clickable ? \"BRTOCPanel|GoToChapter\" : undefined)}\"\n @click=\"${() => this.jumpToPage(tocEntry.pageIndex)}\"\n >\n ${chapterTitle}\n ${tocEntry.pagenum ? html`\n <br />\n <span class=\"BRTOCElementPage\">Page ${tocEntry.pagenum}</span>\n ` : nothing}\n </li>`;\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.dispatchEvent(new CustomEvent('connected'));\n }\n\n updated(changedProperties) {\n if (changedProperties.has('currentChapter')) {\n this.shadowRoot.querySelector('li.current')?.scrollIntoView({\n block: 'nearest',\n behavior: 'smooth',\n });\n }\n }\n\n static get styles() {\n return css`\n ol {\n padding: 0;\n margin: 0;\n margin-right: 5px;\n }\n li {\n padding: 10px;\n overflow: hidden;\n border-radius: 4px;\n }\n li.clickable {\n font-weight: normal;\n cursor: pointer;\n transition: background-color 0.2s;\n }\n\n li.clickable:not(.current):hover {\n background-color: rgba(255,255,255, 0.05);\n }\n\n li.current {\n background-color: rgba(255,255,255,0.9);\n color: #333;\n }\n\n .BRTOCElementPage {\n font-size: 0.85em;\n opacity: .8;\n }`;\n }\n}\n","/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {nothing} from '../lit-html.js';\n\n/**\n * For AttributeParts, sets the attribute if the value is defined and removes\n * the attribute if the value is undefined.\n *\n * For other part types, this directive is a no-op.\n */\nexport const ifDefined = <T>(value: T) => value ?? nothing;\n"],"names":["IAIconToc","styles","render","customElements","define","super_","_regeneratorRuntime","e","t","r","Object","prototype","n","hasOwnProperty","o","defineProperty","value","i","Symbol","a","iterator","c","asyncIterator","u","toStringTag","enumerable","configurable","writable","wrap","Generator","create","Context","makeInvokeMethod","tryCatch","type","arg","call","h","l","f","s","y","GeneratorFunction","GeneratorFunctionPrototype","p","d","getPrototypeOf","v","values","g","defineIteratorMethods","forEach","_invoke","AsyncIterator","invoke","_typeof","resolve","__await","then","callInvokeWithMethodAndArg","Error","done","method","delegate","maybeInvokeDelegate","sent","_sent","dispatchException","abrupt","return","TypeError","resultName","next","nextLoc","pushTryEntry","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","push","resetTryEntry","completion","reset","isNaN","length","displayName","isGeneratorFunction","constructor","name","mark","setPrototypeOf","__proto__","awrap","async","Promise","keys","reverse","pop","prev","charAt","slice","stop","rval","handle","complete","finish","catch","delegateYield","asyncGeneratorStep","gen","reject","_next","_throw","key","info","error","_asyncToGenerator","fn","self","args","arguments","apply","err","undefined","jQuery","extend","BookReader","defaultOptions","olHost","enableChaptersPlugin","bookId","init","this","options","ui","_chapterInit","_callee","_this$options$table_o","rawTableOfContents","_olEdition$table_of_c","olEdition","_this","_context","table_of_contents","getOpenLibraryRecord","_tocEntries","map","rawTOCEntry","assign","pageIndex","leaf","book","leafNumToIndex","pagenum","getPageIndex","_chaptersRender","bind","eventNames","pageChanged","_chaptersUpdateCurrent","_this2","shell","menuProviders","id","icon","html","_templateObject","_taggedTemplateLiteral","label","component","_templateObject2","jumpToIndex","_chaptersPanel","target","addMenuShortcut","updateMenuContents","tocEntry","_chaptersRenderMarker","entryIndex","_this3","chapterStr","title","filter","x","join","concat","percentThrough","util","cssPercentage","getNumLeafs","$","append","text","getPageName","addClass","css","left","appendTo","on","event","marker","currentTarget","tooltip","querySelector","tooltipOffset","getBoundingClientRect","targetOffset","boxSizeAdjust","parseInt","getComputedStyle","paddingLeft","style","setProperty","removeClass","each","el","$el","_ref2","_callee2","ocaid","_data","baseURL","fetchUrlByBookId","data","_context2","ajax","url","dataType","_x","_x2","curIndex","mode","Math","max","displayedIndices","firstIndex","tocEntriesIndexed","currChapter","findIndex","chapter","currentChapter","_decorate","customElement","_initialize","_LitElement","BRChaptersPanel","_LitElement2","_inherits","_super","contents","_this4","_classCallCheck","_assertThisInitialized","F","kind","decorators","property","Array","_this5","_templateObject3","renderTOCEntry","_this6","chapterTitle","clickable","_templateObject4","styleMap","marginLeft","level","ifDefined","jumpToPage","_templateObject5","nothing","_get","_getPrototypeOf","dispatchEvent","CustomEvent","changedProperties","_this$shadowRoot$quer","has","shadowRoot","scrollIntoView","block","behavior","static","_templateObject6","LitElement"],"sourceRoot":""}
package/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ # 5.0.0-75
2
+ - Dev: Update deps via renovatebot
3
+ - Dev: Add .env file in .gitignore
4
+ - Dev: Update CHANGELOG.md @eltociear
5
+ - Feature: Add ToC icon if enableChapterPlugin @dualcnhq
6
+
7
+ # 5.0.0-74
8
+ - See 5.0.0-75
9
+
1
10
  # 5.0.0-73
2
11
  - Feature: Add `table_of_contents` option to work with chapters plugin @cdrini
3
12
  - Fix: Simple demos not working @xonx4l
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetarchive/bookreader",
3
- "version": "5.0.0-74-alpha",
3
+ "version": "5.0.0-75",
4
4
  "description": "The Internet Archive BookReader.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -320,11 +320,13 @@ describe('<book-navigator>', () => {
320
320
  describe('Shortcuts', () => {
321
321
  test('has specific order of menu shortcuts to show', () => {
322
322
  const el = fixtureSync(container());
323
- expect(el.shortcutOrder[0]).toEqual('chapters');
324
- expect(el.shortcutOrder[1]).toEqual('fullscreen');
325
- expect(el.shortcutOrder[2]).toEqual('volumes');
326
- expect(el.shortcutOrder[3]).toEqual('search');
327
- expect(el.shortcutOrder[4]).toEqual('bookmarks');
323
+ expect(el.shortcutOrder).toEqual([
324
+ 'chapters',
325
+ 'fullscreen',
326
+ 'volumes',
327
+ 'search',
328
+ 'bookmarks'
329
+ ]);
328
330
  });
329
331
  });
330
332
 
@@ -157,14 +157,14 @@ describe("BRChaptersPlugin", () => {
157
157
  _chaptersRenderMarker: sinon.stub(),
158
158
  shell: {
159
159
  menuProviders: {},
160
+ addMenuShortcut: sinon.stub(),
160
161
  updateMenuContents: sinon.stub(),
161
- addMenuShortcut: sinon.stub()
162
162
  }
163
163
  };
164
164
  BookReader.prototype._chaptersRender.call(fakeBR);
165
165
  expect(fakeBR.shell.menuProviders['chapters']).toBeTruthy();
166
- expect(fakeBR.shell.updateMenuContents.callCount).toBe(1);
167
166
  expect(fakeBR.shell.addMenuShortcut.callCount).toBe(1);
167
+ expect(fakeBR.shell.updateMenuContents.callCount).toBe(1);
168
168
  expect(fakeBR._chaptersRenderMarker.callCount).toBeGreaterThan(1);
169
169
  });
170
170
  });