vivlio-pdf 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,651 @@
1
+ /**
2
+ * @vivliostyle/viewer v2.45.0
3
+ * Vivliostyle Viewer - HTML+CSS typesetting and rich paged viewing with EPUB/Web publications support
4
+ *
5
+ * @author Vivliostyle Foundation
6
+ * @license AGPL-3.0
7
+ * @preserve
8
+ */
9
+ !function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict";function e(e,t){return t.forEach(function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach(function(i){if("default"!==i&&!(i in e)){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})}})}),Object.freeze(e)}function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var i,n={exports:{}};
10
+ /*!
11
+ * Knockout JavaScript library v3.5.3
12
+ * (c) The Knockout.js team - http://knockoutjs.com/
13
+ * License: MIT (http://www.opensource.org/licenses/mit-license.php)
14
+ */var r,o,s=(i||(i=1,r=n,o=n.exports,function(e){var t=this||(0,eval)("this"),i=t.document,n=t.navigator,s=t.jQuery,a=t.JSON;s||"undefined"==typeof jQuery||(s=jQuery),function(e){e(r.exports||o)}(function(r,o){function l(e,t){return(null===e||typeof e in S)&&e===t}function h(t,i){var n;return function(){n||(n=x.a.setTimeout(function(){n=e,t()},i))}}function u(e,t){var i;return function(){clearTimeout(i),i=x.a.setTimeout(e,t)}}function c(e,t){t&&"change"!==t?"beforeChange"===t?this.pc(e):this.ib(e,t):this.qc(e)}function d(e,t){null!==t&&t.s&&t.s()}function p(e,t){var i=this.qd,n=i[N];n.ta||(this.Rb&&this.ob[t]?(i.uc(t,e,this.ob[t]),this.ob[t]=null,--this.Rb):n.I[t]||i.uc(t,e,n.K?{da:e}:i.$c(e)),e.La&&e.gd())}var f,g,m,v,y,b,w,x=void 0!==r?r:{};if(x.b=function(e,t){for(var i=e.split("."),n=x,r=0;r<i.length-1;r++)n=n[i[r]];n[i[i.length-1]]=t},x.L=function(e,t,i){e[t]=i},x.version="3.5.3",x.b("version",x.version),x.options={deferUpdates:!1,useOnlyNativeEvents:!1,foreachHidesDestroyed:!1},"undefined"!=typeof trustedTypes)try{f=trustedTypes.createPolicy("knockout",{createHTML:function(e){return e},createScript:function(e){return e}})}catch(e){}x.a=function(){function r(e,t){for(var i in e)u.call(e,i)&&t(i,e[i])}function o(e,t){if(t)for(var i in t)u.call(t,i)&&(e[i]=t[i]);return e}function l(e,t){return e.__proto__=t,e}function h(e,t,i,n){var r=e[t].match(b)||[];x.a.D(i.match(b),function(e){x.a.Pa(r,e,n)}),e[t]=r.join(" ")}var u=Object.prototype.hasOwnProperty,c={__proto__:[]}instanceof Array,d="function"==typeof Symbol,p={},g={};p[n&&/Firefox\/2/i.test(n.userAgent)?"KeyboardEvent":"UIEvents"]=["keyup","keydown","keypress"],p.MouseEvents="click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave".split(" "),r(p,function(e,t){if(t.length)for(var i=0,n=t.length;i<n;i++)g[t[i]]=e});var m,v={propertychange:!0};f||(m=i&&function(){for(var t=3,n=i.createElement("div"),r=n.getElementsByTagName("i");n.innerHTML="\x3c!--[if gt IE "+ ++t+"]><i></i><![endif]--\x3e",r[0];);return 4<t?t:e}());var y,b=/\S+/g;return{Jc:["authenticity_token",/^__RequestVerificationToken(_.*)?$/],D:function(e,t,i){for(var n=0,r=e.length;n<r;n++)t.call(i,e[n],n,e)},A:"function"==typeof Array.prototype.indexOf?function(e,t){return Array.prototype.indexOf.call(e,t)}:function(e,t){for(var i=0,n=e.length;i<n;i++)if(e[i]===t)return i;return-1},Mb:function(t,i,n){for(var r=0,o=t.length;r<o;r++)if(i.call(n,t[r],r,t))return t[r];return e},Ra:function(e,t){var i=x.a.A(e,t);0<i?e.splice(i,1):0===i&&e.shift()},wc:function(e){var t=[];return e&&x.a.D(e,function(e){0>x.a.A(t,e)&&t.push(e)}),t},Nb:function(e,t,i){var n=[];if(e)for(var r=0,o=e.length;r<o;r++)n.push(t.call(i,e[r],r));return n},lb:function(e,t,i){var n=[];if(e)for(var r=0,o=e.length;r<o;r++)t.call(i,e[r],r)&&n.push(e[r]);return n},Ob:function(e,t){if(t instanceof Array)e.push.apply(e,t);else for(var i=0,n=t.length;i<n;i++)e.push(t[i]);return e},Pa:function(e,t,i){var n=x.a.A(x.a.bc(e),t);0>n?i&&e.push(t):i||e.splice(n,1)},Ca:c,extend:o,setPrototypeOf:l,Bb:c?l:o,P:r,Ia:function(e,t,i){if(!e)return e;var n,r={};for(n in e)u.call(e,n)&&(r[n]=t.call(i,e[n],n,e));return r},Ub:function(e){for(;e.firstChild;)x.removeNode(e.firstChild)},Zb:function(e){for(var t=((e=x.a.la(e))[0]&&e[0].ownerDocument||i).createElement("div"),n=0,r=e.length;n<r;n++)t.appendChild(x.pa(e[n]));return t},Da:function(e,t){for(var i=0,n=e.length,r=[];i<n;i++){var o=e[i].cloneNode(!0);r.push(t?x.pa(o):o)}return r},xa:function(e,t){if(x.a.Ub(e),t)for(var i=0,n=t.length;i<n;i++)e.appendChild(t[i])},Xc:function(e,t){var i=e.nodeType?[e]:e;if(0<i.length){for(var n=i[0],r=n.parentNode,o=0,s=t.length;o<s;o++)r.insertBefore(t[o],n);for(o=0,s=i.length;o<s;o++)x.removeNode(i[o])}},Wa:function(e,t){if(e.length){for(t=8===t.nodeType&&t.parentNode||t;e.length&&e[0].parentNode!==t;)e.splice(0,1);for(;1<e.length&&e[e.length-1].parentNode!==t;)e.length--;if(1<e.length){var i=e[0],n=e[e.length-1];for(e.length=0;i!==n;)e.push(i),i=i.nextSibling;e.push(n)}}return e},Zc:function(e,t){7>m?e.setAttribute("selected",t):e.selected=t},Eb:function(t){return null===t||t===e?"":t.trim?t.trim():t.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")},Ud:function(e,t){return e=e||"",!(t.length>e.length)&&e.substring(0,t.length)===t},vd:function(e,t){if(e===t)return!0;if(11===e.nodeType)return!1;if(t.contains)return t.contains(1!==e.nodeType?e.parentNode:e);if(t.compareDocumentPosition)return!(16&~t.compareDocumentPosition(e));for(;e&&e!=t;)e=e.parentNode;return!!e},Tb:function(e){return x.a.vd(e,e.ownerDocument.documentElement)},kd:function(e){return!!x.a.Mb(e,x.a.Tb)},R:function(e){return e&&e.tagName&&e.tagName.toLowerCase()},Ac:function(e){return x.onError?function(){try{return e.apply(this,arguments)}catch(e){throw x.onError&&x.onError(e),e}}:e},setTimeout:function(e,t){return setTimeout(x.a.Ac(e),t)},Gc:function(e){setTimeout(function(){throw x.onError&&x.onError(e),e},0)},B:function(e,t,i){var n=x.a.Ac(i);if(i=v[t],x.options.useOnlyNativeEvents||i||!s)if(i||"function"!=typeof e.addEventListener){if(void 0!==e.attachEvent){var r=function(t){n.call(e,t)},o="on"+t;e.attachEvent(o,r),x.a.J.oa(e,function(){e.detachEvent(o,r)})}}else e.addEventListener(t,n,!1),x.a.J.oa(e,function(){e.removeEventListener(t,n)});else y||(y="function"==typeof s(e).on?"on":"bind"),s(e)[y](t,n)},Gb:function(e,n){if(!e||!e.nodeType)throw Error("element must be a DOM node when calling triggerEvent");var r;if(r=!("input"!==x.a.R(e)||!e.type||"click"!=n.toLowerCase()||"checkbox"!=(r=e.type)&&"radio"!=r),x.options.useOnlyNativeEvents||!s||r)if("function"==typeof i.createEvent){if("function"!=typeof e.dispatchEvent)throw Error("The supplied element doesn't support dispatchEvent");(r=i.createEvent(g[n]||"HTMLEvents")).initEvent(n,!0,!0,t,0,0,0,0,0,!1,!1,!1,!1,0,e),e.dispatchEvent(r)}else if(r&&e.click)e.click();else{if(void 0===e.fireEvent)throw Error("Browser doesn't support triggering events");e.fireEvent("on"+n)}else s(e).trigger(n)},f:function(e){return x.O(e)?e():e},bc:function(e){return x.O(e)?e.v():e},Fb:function(e,t,i){var n;t&&("object"==typeof e.classList?(n=e.classList[i?"add":"remove"],x.a.D(t.match(b),function(t){n.call(e.classList,t)})):"string"==typeof e.className.baseVal?h(e.className,"baseVal",t,i):h(e,"className",t,i))},Cb:function(t,i){var n=x.a.f(i);null!==n&&n!==e||(n="");var r=x.h.firstChild(t);!r||3!=r.nodeType||x.h.nextSibling(r)?x.h.xa(t,[t.ownerDocument.createTextNode(n)]):r.data=n,x.a.Ad(t)},Yc:function(e,t){if(e.name=t,7>=m)try{var n=e.name.replace(/[&<>'"]/g,function(e){return"&#"+e.charCodeAt(0)+";"});e.mergeAttributes(i.createElement("<input name='"+n+"'/>"),!1)}catch(e){}},Ad:function(e){9<=m&&(e=1==e.nodeType?e:e.parentNode).style&&(e.style.zoom=e.style.zoom)},wd:function(e){if(m){var t=e.style.width;e.style.width=0,e.style.width=t}},Pd:function(e,t){e=x.a.f(e),t=x.a.f(t);for(var i=[],n=e;n<=t;n++)i.push(n);return i},la:function(e){for(var t=[],i=0,n=e.length;i<n;i++)t.push(e[i]);return t},Ea:function(e){return d?Symbol(e):e},Zd:6===m,$d:7===m,W:m,Lc:function(e,t){for(var i=x.a.la(e.getElementsByTagName("input")).concat(x.a.la(e.getElementsByTagName("textarea"))),n="string"==typeof t?function(e){return e.name===t}:function(e){return t.test(e.name)},r=[],o=i.length-1;0<=o;o--)n(i[o])&&r.push(i[o]);return r},Nd:function(e){return"string"==typeof e&&(e=x.a.Eb(e))?a&&a.parse?a.parse(e):new Function("return "+e)():null},hc:function(e,t,i){if(!a||!a.stringify)throw Error("Cannot find JSON.stringify(). Some browsers (e.g., IE < 8) don't support it natively, but you can overcome this by adding a script reference to json2.js, downloadable from http://www.json.org/json2.js");return a.stringify(x.a.f(e),t,i)},Od:function(e,t,n){var o=(n=n||{}).params||{},s=n.includeFields||this.Jc,a=e;if("object"==typeof e&&"form"===x.a.R(e)){a=e.action;for(var l=s.length-1;0<=l;l--)for(var h=x.a.Lc(e,s[l]),u=h.length-1;0<=u;u--)o[h[u].name]=h[u].value}t=x.a.f(t);var c=i.createElement("form");for(var d in c.style.display="none",c.action=a,c.method="post",t)(e=i.createElement("input")).type="hidden",e.name=d,e.value=x.a.hc(x.a.f(t[d])),c.appendChild(e);r(o,function(e,t){var n=i.createElement("input");n.type="hidden",n.name=e,n.value=t,c.appendChild(n)}),i.body.appendChild(c),n.submitter?n.submitter(c):c.submit(),setTimeout(function(){c.parentNode.removeChild(c)},0)}}}(),x.b("utils",x.a),x.b("utils.arrayForEach",x.a.D),x.b("utils.arrayFirst",x.a.Mb),x.b("utils.arrayFilter",x.a.lb),x.b("utils.arrayGetDistinctValues",x.a.wc),x.b("utils.arrayIndexOf",x.a.A),x.b("utils.arrayMap",x.a.Nb),x.b("utils.arrayPushAll",x.a.Ob),x.b("utils.arrayRemoveItem",x.a.Ra),x.b("utils.cloneNodes",x.a.Da),x.b("utils.createSymbolOrString",x.a.Ea),x.b("utils.extend",x.a.extend),x.b("utils.fieldsIncludedWithJsonPost",x.a.Jc),x.b("utils.getFormFields",x.a.Lc),x.b("utils.objectMap",x.a.Ia),x.b("utils.peekObservable",x.a.bc),x.b("utils.postJson",x.a.Od),x.b("utils.parseJson",x.a.Nd),x.b("utils.registerEventHandler",x.a.B),x.b("utils.stringifyJson",x.a.hc),x.b("utils.range",x.a.Pd),x.b("utils.toggleDomNodeCssClass",x.a.Fb),x.b("utils.triggerEvent",x.a.Gb),x.b("utils.unwrapObservable",x.a.f),x.b("utils.objectForEach",x.a.P),x.b("utils.addOrRemoveItem",x.a.Pa),x.b("utils.setTextContent",x.a.Cb),x.b("unwrap",x.a.f),Function.prototype.bind||(Function.prototype.bind=function(e){var t=this;if(1===arguments.length)return function(){return t.apply(e,arguments)};var i=Array.prototype.slice.call(arguments,1);return function(){var n=i.slice(0);return n.push.apply(n,arguments),t.apply(e,n)}}),x.a.g=new function(){var t,i,n=0,r="__ko__"+(new Date).getTime(),o={};return x.a.W?(t=function(t,i){var s=t[r];if(!s||"null"===s||!o[s]){if(!i)return e;s=t[r]="ko"+n++,o[s]={}}return o[s]},i=function(e){var t=e[r];return!!t&&(delete o[t],e[r]=null,!0)}):(t=function(e,t){var i=e[r];return!i&&t&&(i=e[r]={}),i},i=function(e){return!!e[r]&&(delete e[r],!0)}),{get:function(e,i){var n=t(e,!1);return n&&n[i]},set:function(i,n,r){(i=t(i,r!==e))&&(i[n]=r)},Vb:function(e,i,n){return(e=t(e,!0))[i]||(e[i]=n)},clear:i,Z:function(){return n+++r}}},x.b("utils.domData",x.a.g),x.b("utils.domData.clear",x.a.g.clear),x.a.J=new function(){function t(t,i){var n=x.a.g.get(t,r);return n===e&&i&&(n=[],x.a.g.set(t,r,n)),n}function i(e){if(i=t(e,!1))for(var i=i.slice(0),r=0;r<i.length;r++)i[r](e);x.a.g.clear(e),x.a.J.cleanExternalData(e),a[e.nodeType]&&n(e.childNodes,!0)}function n(e,t){for(var n,r=[],o=0;o<e.length;o++)if((!t||8===e[o].nodeType)&&(i(r[r.length]=n=e[o]),e[o]!==n))for(;o--&&-1==x.a.A(r,e[o]););}var r=x.a.g.Z(),o={1:!0,8:!0,9:!0},a={1:!0,9:!0};return{oa:function(e,i){if("function"!=typeof i)throw Error("Callback must be a function");t(e,!0).push(i)},zb:function(i,n){var o=t(i,!1);o&&(x.a.Ra(o,n),0==o.length&&x.a.g.set(i,r,e))},pa:function(e){return x.u.G(function(){o[e.nodeType]&&(i(e),a[e.nodeType]&&n(e.getElementsByTagName("*")))}),e},removeNode:function(e){x.pa(e),e.parentNode&&e.parentNode.removeChild(e)},cleanExternalData:function(e){s&&"function"==typeof s.cleanData&&s.cleanData([e])}}},x.pa=x.a.J.pa,x.removeNode=x.a.J.removeNode,x.b("cleanNode",x.pa),x.b("removeNode",x.removeNode),x.b("utils.domNodeDisposal",x.a.J),x.b("utils.domNodeDisposal.addDisposeCallback",x.a.J.oa),x.b("utils.domNodeDisposal.removeDisposeCallback",x.a.J.zb),g=[0,"",""],b={thead:m=[1,"<table>","</table>"],tbody:m,tfoot:m,tr:[2,"<table><tbody>","</tbody></table>"],td:v=[3,"<table><tbody><tr>","</tr></tbody></table>"],th:v,option:y=[1,"<select multiple='multiple'>","</select>"],optgroup:y},w=8>=x.a.W,x.a.wa=function(e,n){var r;if(s){if(s.parseHTML)r=s.parseHTML(e,n)||[];else if((r=s.clean([e],n))&&r[0]){for(var o=r[0];o.parentNode&&11!==o.parentNode.nodeType;)o=o.parentNode;o.parentNode&&o.parentNode.removeChild(o)}}else{(r=n)||(r=i),o=r.parentWindow||r.defaultView||t;var a,l=x.a.Eb(e).toLowerCase(),h=r.createElement("div");for(a=(l=l.match(/^(?:\x3c!--.*?--\x3e\s*?)*?<([a-z]+)[\s>]/))&&b[l[1]]||g,l=a[0],a="ignored<div>"+a[1]+e+a[2]+"</div>","function"==typeof o.innerShiv?h.appendChild(o.innerShiv(a)):(w&&r.body.appendChild(h),h.innerHTML=f?f.createHTML(a):a,w&&h.parentNode.removeChild(h));l--;)h=h.lastChild;r=x.a.la(h.lastChild.childNodes)}return r},x.a.Md=function(e,t){var i=x.a.wa(e,t);return i.length&&i[0].parentElement||x.a.Zb(i)},x.a.fc=function(t,i){if(x.a.Ub(t),null!==(i=x.a.f(i))&&i!==e){if("string"!=typeof i){if("undefined"!=typeof trustedTypes&&trustedTypes.isHTML(i))return void(t.innerHTML=i);i=i.toString()}if(s)s(t).html(i);else for(var n=x.a.wa(i,t.ownerDocument),r=0;r<n.length;r++)t.appendChild(n[r])}},x.b("utils.parseHtmlFragment",x.a.wa),x.b("utils.setHtml",x.a.fc),x.aa=function(){function t(e,i){if(e)if(8==e.nodeType)null!=(n=x.aa.Uc(e.nodeValue))&&i.push({ud:e,Kd:n});else if(1==e.nodeType)for(var n=0,r=e.childNodes,o=r.length;n<o;n++)t(r[n],i)}var i={};return{Yb:function(e){if("function"!=typeof e)throw Error("You can only pass a function to ko.memoization.memoize()");var t=(4294967296*(1+Math.random())|0).toString(16).substring(1)+(4294967296*(1+Math.random())|0).toString(16).substring(1);return i[t]=e,"\x3c!--[ko_memo:"+t+"]--\x3e"},bd:function(t,n){var r=i[t];if(r===e)throw Error("Couldn't find any memo with ID "+t+". Perhaps it's already been unmemoized.");try{return r.apply(null,n||[]),!0}finally{delete i[t]}},cd:function(e,i){var n=[];t(e,n);for(var r=0,o=n.length;r<o;r++){var s=n[r].ud,a=[s];i&&x.a.Ob(a,i),x.aa.bd(n[r].Kd,a),s.nodeValue="",s.parentNode&&s.parentNode.removeChild(s)}},Uc:function(e){return(e=e.match(/^\[ko_memo\:(.*?)\]$/))?e[1]:null}}}(),x.b("memoization",x.aa),x.b("memoization.memoize",x.aa.Yb),x.b("memoization.unmemoize",x.aa.bd),x.b("memoization.parseMemoText",x.aa.Uc),x.b("memoization.unmemoizeDomNodeAndDescendants",x.aa.cd),x.na=function(){function e(){if(s)for(var e,t=s,i=0;l<s;)if(e=o[l++]){if(l>t){if(5e3<=++i){l=s,x.a.Gc(Error("'Too much recursion' after processing "+i+" task groups."));break}t=s}try{e()}catch(e){x.a.Gc(e)}}}function n(){e(),l=s=o.length=0}var r,o=[],s=0,a=1,l=0;return r=t.MutationObserver?function(e){var t=i.createElement("div");return new MutationObserver(e).observe(t,{attributes:!0}),function(){t.classList.toggle("foo")}}(n):i&&"onreadystatechange"in i.createElement("script")?function(e){var t=i.createElement("script");t.onreadystatechange=function(){t.onreadystatechange=null,i.documentElement.removeChild(t),t=null,e()},i.documentElement.appendChild(t)}:function(e){setTimeout(e,0)},{scheduler:r,Ab:function(e){return s||x.na.scheduler(n),o[s++]=e,a++},cancel:function(e){(e-=a-s)>=l&&e<s&&(o[e]=null)},resetForTesting:function(){var e=s-l;return l=s=o.length=0,e},Sd:e}}(),x.b("tasks",x.na),x.b("tasks.schedule",x.na.Ab),x.b("tasks.runEarly",x.na.Sd),x.Va={throttle:function(e,t){e.throttleEvaluation=t;var i=null;return x.$({read:e,write:function(n){clearTimeout(i),i=x.a.setTimeout(function(){e(n)},t)}})},rateLimit:function(e,t){var i,n,r;"number"==typeof t?i=t:(i=t.timeout,n=t.method),e.Ib=!1,r="function"==typeof n?n:"notifyWhenChangesStop"==n?u:h,e.ub(function(e){return r(e,i,t)})},deferred:function(t,i){if(!0!==i)throw Error("The 'deferred' extender only accepts the value 'true', because it is not supported to turn deferral off once enabled.");t.Ib||(t.Ib=!0,t.ub(function(i){var n,r=!1;return function(){if(!r){x.na.cancel(n),n=x.na.Ab(i);try{r=!0,t.notifySubscribers(e,"dirty")}finally{r=!1}}}}))},notify:function(e,t){e.equalityComparer="always"==t?null:l}};var S={undefined:1,boolean:1,number:1,string:1};x.b("extenders",x.Va),x.ic=function(e,t,i){this.da=e,this.lc=t,this.mc=i,this.Jb=!1,this.hb=this.Kb=null,x.L(this,"dispose",this.s),x.L(this,"disposeWhenNodeIsRemoved",this.l)},x.ic.prototype.s=function(){this.Jb||(this.hb&&x.a.J.zb(this.Kb,this.hb),this.Jb=!0,this.mc(),this.da=this.lc=this.mc=this.Kb=this.hb=null)},x.ic.prototype.l=function(e){this.Kb=e,x.a.J.oa(e,this.hb=this.s.bind(this))},x.T=function(){x.a.Bb(this,C),C.rb(this)};var C={rb:function(e){e.U={change:[]},e.sc=1},subscribe:function(e,t,i){var n=this;i=i||"change";var r=new x.ic(n,t?e.bind(t):e,function(){x.a.Ra(n.U[i],r),n.jb&&n.jb(i)});return n.Sa&&n.Sa(i),n.U[i]||(n.U[i]=[]),n.U[i].push(r),r},notifySubscribers:function(e,t){if("change"===(t=t||"change")&&this.Hb(),this.Ya(t)){var i="change"===t&&this.ed||this.U[t].slice(0);try{x.u.xc();for(var n,r=0;n=i[r];++r)n.Jb||n.lc(e)}finally{x.u.end()}}},qb:function(){return this.sc},Dd:function(e){return this.qb()!==e},Hb:function(){++this.sc},ub:function(e){var t,i,n,r,o,s=this,a=x.O(s);s.ib||(s.ib=s.notifySubscribers,s.notifySubscribers=c);var l=e(function(){s.La=!1,a&&r===s&&(r=s.nc?s.nc():s());var e=i||o&&s.sb(n,r);o=i=t=!1,e&&s.ib(n=r)});s.qc=function(e,i){i&&s.La||(o=!i),s.ed=s.U.change.slice(0),s.La=t=!0,r=e,l()},s.pc=function(e){t||(n=e,s.ib(e,"beforeChange"))},s.rc=function(){o=!0},s.gd=function(){s.sb(n,s.v(!0))&&(i=!0)}},Ya:function(e){return this.U[e]&&this.U[e].length},Bd:function(e){if(e)return this.U[e]&&this.U[e].length||0;var t=0;return x.a.P(this.U,function(e,i){"dirty"!==e&&(t+=i.length)}),t},sb:function(e,t){return!this.equalityComparer||!this.equalityComparer(e,t)},toString:function(){return"[object Object]"},extend:function(e){var t=this;return e&&x.a.P(e,function(e,i){var n=x.Va[e];"function"==typeof n&&(t=n(t,i)||t)}),t}};x.L(C,"init",C.rb),x.L(C,"subscribe",C.subscribe),x.L(C,"extend",C.extend),x.L(C,"getSubscriptionsCount",C.Bd),x.a.Ca&&x.a.setPrototypeOf(C,Function.prototype),x.T.fn=C,x.Qc=function(e){return null!=e&&"function"==typeof e.subscribe&&"function"==typeof e.notifySubscribers},x.b("subscribable",x.T),x.b("isSubscribable",x.Qc),x.S=x.u=function(){function e(e){n.push(i),i=e}function t(){i=n.pop()}var i,n=[],r=0;return{xc:e,end:t,cc:function(e){if(i){if(!x.Qc(e))throw Error("Only subscribable things can act as dependencies");i.od.call(i.pd,e,e.fd||(e.fd=++r))}},G:function(i,n,r){try{return e(),i.apply(n,r||[])}finally{t()}},ra:function(){if(i)return i.o.ra()},Xa:function(){if(i)return i.o.Xa()},$a:function(){if(i)return i.$a},o:function(){if(i)return i.o}}}(),x.b("computedContext",x.S),x.b("computedContext.getDependenciesCount",x.S.ra),x.b("computedContext.getDependencies",x.S.Xa),x.b("computedContext.isInitial",x.S.$a),x.b("computedContext.registerDependency",x.S.cc),x.b("ignoreDependencies",x.Yd=x.u.G);var k=x.a.Ea("_latestValue");x.va=function(e){function t(){return 0<arguments.length?(t.sb(t[k],arguments[0])&&(t.Aa(),t[k]=arguments[0],t.za()),this):(x.u.cc(t),t[k])}return t[k]=e,x.a.Ca||x.a.extend(t,x.T.fn),x.T.fn.rb(t),x.a.Bb(t,P),x.options.deferUpdates&&x.Va.deferred(t,!0),t};var P={equalityComparer:l,v:function(){return this[k]},za:function(){this.notifySubscribers(this[k],"spectate"),this.notifySubscribers(this[k])},Aa:function(){this.notifySubscribers(this[k],"beforeChange")}};x.a.Ca&&x.a.setPrototypeOf(P,x.T.fn);var E=x.va.Oa="__ko_proto__";P[E]=x.va,x.O=function(e){if((e="function"==typeof e&&e[E])&&e!==P[E]&&e!==x.o.fn[E])throw Error("Invalid object that looks like an observable; possibly from another Knockout instance");return!!e},x.ab=function(e){return"function"==typeof e&&(e[E]===P[E]||e[E]===x.o.fn[E]&&e.Nc)},x.b("observable",x.va),x.b("isObservable",x.O),x.b("isWriteableObservable",x.ab),x.b("isWritableObservable",x.ab),x.b("observable.fn",P),x.L(P,"peek",P.v),x.L(P,"valueHasMutated",P.za),x.L(P,"valueWillMutate",P.Aa),x.Ja=function(e){if("object"!=typeof(e=e||[])||!("length"in e))throw Error("The argument passed when initializing an observable array must be an array, or null, or undefined.");return e=x.va(e),x.a.Bb(e,x.Ja.fn),e.extend({trackArrayChanges:!0})},x.Ja.fn={remove:function(e){for(var t=this.v(),i=[],n="function"!=typeof e||x.O(e)?function(t){return t===e}:e,r=0;r<t.length;r++){var o=t[r];if(n(o)){if(0===i.length&&this.Aa(),t[r]!==o)throw Error("Array modified during remove; cannot remove item");i.push(o),t.splice(r,1),r--}}return i.length&&this.za(),i},removeAll:function(t){if(t===e){var i=this.v(),n=i.slice(0);return this.Aa(),i.splice(0,i.length),this.za(),n}return t?this.remove(function(e){return 0<=x.a.A(t,e)}):[]},destroy:function(e){var t=this.v(),i="function"!=typeof e||x.O(e)?function(t){return t===e}:e;this.Aa();for(var n=t.length-1;0<=n;n--){var r=t[n];i(r)&&(r._destroy=!0)}this.za()},destroyAll:function(t){return t===e?this.destroy(function(){return!0}):t?this.destroy(function(e){return 0<=x.a.A(t,e)}):[]},indexOf:function(e){var t=this();return x.a.A(t,e)},replace:function(e,t){var i=this.indexOf(e);0<=i&&(this.Aa(),this.v()[i]=t,this.za())},sorted:function(e){var t=this().slice(0);return e?t.sort(e):t.sort()},reversed:function(){return this().slice(0).reverse()}},x.a.Ca&&x.a.setPrototypeOf(x.Ja.fn,x.va.fn),x.a.D("pop push reverse shift sort splice unshift".split(" "),function(e){x.Ja.fn[e]=function(){var t=this.v();this.Aa(),this.zc(t,e,arguments);var i=t[e].apply(t,arguments);return this.za(),i===t?this:i}}),x.a.D(["slice"],function(e){x.Ja.fn[e]=function(){var t=this();return t[e].apply(t,arguments)}}),x.Pc=function(e){return x.O(e)&&"function"==typeof e.remove&&"function"==typeof e.push},x.b("observableArray",x.Ja),x.b("isObservableArray",x.Pc),x.Va.trackArrayChanges=function(t,i){function n(){function e(){if(h){var e,i=[].concat(t.v()||[]);t.Ya("arrayChange")&&((!l||1<h)&&(l=x.a.Qb(s,i,t.Pb)),e=l),s=i,l=null,h=0,e&&e.length&&t.notifySubscribers(e,"arrayChange")}}a?e():(a=!0,o=t.subscribe(function(){++h},null,"spectate"),s=[].concat(t.v()||[]),l=null,r=t.subscribe(e))}if(t.Pb={},i&&"object"==typeof i&&x.a.extend(t.Pb,i),t.Pb.sparse=!0,!t.zc){var r,o,s,a=!1,l=null,h=0,u=t.Sa,c=t.jb;t.Sa=function(e){u&&u.call(t,e),"arrayChange"===e&&n()},t.jb=function(i){c&&c.call(t,i),"arrayChange"!==i||t.Ya("arrayChange")||(r&&r.s(),o&&o.s(),o=r=null,a=!1,s=e)},t.zc=function(e,t,i){function n(e,t,i){return r[r.length]={status:e,value:t,index:i}}if(a&&!h){var r=[],o=e.length,s=i.length,u=0;switch(t){case"push":u=o;case"unshift":for(t=0;t<s;t++)n("added",i[t],u+t);break;case"pop":u=o-1;case"shift":o&&n("deleted",e[u],u);break;case"splice":t=Math.min(Math.max(0,0>i[0]?o+i[0]:i[0]),o),o=1===s?o:Math.min(t+(i[1]||0),o),s=t+s-2,u=Math.max(o,s);for(var c=[],d=[],p=2;t<u;++t,++p)t<o&&d.push(n("deleted",e[t],t)),t<s&&c.push(n("added",i[p],t));x.a.Kc(d,c);break;default:return}l=r}}}};var N=x.a.Ea("_state");x.o=x.$=function(t,i,n){function r(){if(0<arguments.length){if("function"!=typeof o)throw Error("Cannot write a value to a ko.computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters.");return o.apply(s.pb,arguments),this}return s.ta||x.u.cc(r),(s.ka||s.K&&r.Za())&&r.ha(),s.X}if("object"==typeof t?n=t:(n=n||{},t&&(n.read=t)),"function"!=typeof n.read)throw Error("Pass a function that returns the value of the ko.computed");var o=n.write,s={X:e,ua:!0,ka:!0,sa:!1,jc:!1,ta:!1,xb:!1,K:!1,Wc:n.read,pb:i||n.owner,l:n.disposeWhenNodeIsRemoved||n.l||null,Ua:n.disposeWhen||n.Ua,Sb:null,I:{},V:0,Ic:null};return r[N]=s,r.Nc="function"==typeof o,x.a.Ca||x.a.extend(r,x.T.fn),x.T.fn.rb(r),x.a.Bb(r,T),n.pure?(s.xb=!0,s.K=!0,x.a.extend(r,I)):n.deferEvaluation&&x.a.extend(r,A),x.options.deferUpdates&&x.Va.deferred(r,!0),s.l&&(s.jc=!0,s.l.nodeType||(s.l=null)),s.K||n.deferEvaluation||r.ha(),s.l&&r.ja()&&x.a.J.oa(s.l,s.Sb=function(){r.s()}),r};var T={equalityComparer:l,ra:function(){return this[N].V},Xa:function(){var e=[];return x.a.P(this[N].I,function(t,i){e[i.Ma]=i.da}),e},Wb:function(e){if(!this[N].V)return!1;var t=this.Xa();return-1!==x.a.A(t,e)||!!x.a.Mb(t,function(t){return t.Wb&&t.Wb(e)})},uc:function(e,t,i){if(this[N].xb&&t===this)throw Error("A 'pure' computed must not be called recursively");this[N].I[e]=i,i.Ma=this[N].V++,i.Na=t.qb()},Za:function(){var e=this[N];if(e.sa)return!1;e.sa=!0;try{var t,i,n=e.I;for(t in n)if(Object.prototype.hasOwnProperty.call(n,t)&&(i=n[t],this.Ka&&i.da.La||i.da.Dd(i.Na)))return!0}finally{e.sa=!1}},Jd:function(){this.Ka&&!this[N].sa&&this.Ka(!1)},ja:function(){var e=this[N];return e.ka||0<e.V},Rd:function(){this.La?this[N].ka&&(this[N].ua=!0):this.Hc()},$c:function(e){if(e.Ib){var t=e.subscribe(this.Jd,this,"dirty"),i=e.subscribe(this.Rd,this);return{da:e,s:function(){t.s(),i.s()}}}return e.subscribe(this.Hc,this)},Hc:function(){var e=this,t=e.throttleEvaluation;t&&0<=t?(clearTimeout(this[N].Ic),this[N].Ic=x.a.setTimeout(function(){e.ha(!0)},t)):e.Ka?e.Ka(!0):e.ha(!0)},ha:function(e){var t=this[N],i=t.Ua,n=!1;if(!t.sa&&!t.ta){if(t.l&&!x.a.Tb(t.l)||i&&i()){if(!t.jc)return void this.s()}else t.jc=!1;t.sa=!0;try{n=this.zd(e)}finally{t.sa=!1}return n}},zd:function(t){var i=this[N],n=!1,r=i.xb?e:!i.V;n={qd:this,ob:i.I,Rb:i.V},x.u.xc({pd:n,od:p,o:this,$a:r}),i.I={},i.V=0;var o=this.yd(i,n);return i.V?n=this.sb(i.X,o):(this.s(),n=!0),n&&(i.K?this.Hb():this.notifySubscribers(i.X,"beforeChange"),i.X=o,this.notifySubscribers(i.X,"spectate"),!i.K&&t&&this.notifySubscribers(i.X),this.rc&&this.rc()),r&&this.notifySubscribers(i.X,"awake"),n},yd:function(e,t){try{var i=e.Wc;return e.pb?i.call(e.pb):i()}finally{x.u.end(),t.Rb&&!e.K&&x.a.P(t.ob,d),e.ua=e.ka=!1}},v:function(e){var t=this[N];return(t.ka&&(e||!t.V)||t.K&&this.Za())&&this.ha(),t.X},ub:function(e){x.T.fn.ub.call(this,e),this.nc=function(){return this[N].K||(this[N].ua?this.ha():this[N].ka=!1),this[N].X},this.Ka=function(e){this.pc(this[N].X),this[N].ka=!0,e&&(this[N].ua=!0),this.qc(this,!e)}},s:function(){var t=this[N];!t.K&&t.I&&x.a.P(t.I,function(e,t){t.s&&t.s()}),t.l&&t.Sb&&x.a.J.zb(t.l,t.Sb),t.I=e,t.V=0,t.ta=!0,t.ua=!1,t.ka=!1,t.K=!1,t.l=e,t.Ua=e,t.Wc=e,this.Nc||(t.pb=e)}},I={Sa:function(e){var t=this,i=t[N];if(!i.ta&&i.K&&"change"==e){if(i.K=!1,i.ua||t.Za())i.I=null,i.V=0,t.ha()&&t.Hb();else{var n=[];x.a.P(i.I,function(e,t){n[t.Ma]=e}),x.a.D(n,function(e,n){var r=i.I[e],o=t.$c(r.da);o.Ma=n,o.Na=r.Na,i.I[e]=o}),t.Za()&&t.ha()&&t.Hb()}i.ta||t.notifySubscribers(i.X,"awake")}},jb:function(t){var i=this[N];i.ta||"change"!=t||this.Ya("change")||(x.a.P(i.I,function(e,t){t.s&&(i.I[e]={da:t.da,Ma:t.Ma,Na:t.Na},t.s())}),i.K=!0,this.notifySubscribers(e,"asleep"))},qb:function(){var e=this[N];return e.K&&(e.ua||this.Za())&&this.ha(),x.T.fn.qb.call(this)}},A={Sa:function(e){"change"!=e&&"beforeChange"!=e||this.v()}};x.a.Ca&&x.a.setPrototypeOf(T,x.T.fn);var F=x.va.Oa;T[F]=x.o,x.Oc=function(e){return"function"==typeof e&&e[F]===T[F]},x.Fd=function(e){return x.Oc(e)&&e[N]&&e[N].xb},x.b("computed",x.o),x.b("dependentObservable",x.o),x.b("isComputed",x.Oc),x.b("isPureComputed",x.Fd),x.b("computed.fn",T),x.L(T,"peek",T.v),x.L(T,"dispose",T.s),x.L(T,"isActive",T.ja),x.L(T,"getDependenciesCount",T.ra),x.L(T,"getDependencies",T.Xa),x.yb=function(e,t){return"function"==typeof e?x.o(e,t,{pure:!0}):((e=x.a.extend({},e)).pure=!0,x.o(e,t))},x.b("pureComputed",x.yb),function(){function t(n,r,o){if(o=o||new i,"object"!=typeof(n=r(n))||null===n||n===e||n instanceof RegExp||n instanceof Date||n instanceof String||n instanceof Number||n instanceof Boolean)return n;var s=n instanceof Array?[]:{};return o.save(n,s),function(e,t){if(e instanceof Array){for(var i=0;i<e.length;i++)t(i);"function"==typeof e.toJSON&&t("toJSON")}else for(i in e)t(i)}(n,function(i){var a=r(n[i]);switch(typeof a){case"boolean":case"number":case"string":case"bigint":case"symbol":case"function":s[i]=a;break;case"object":case"undefined":var l=o.get(a);s[i]=l!==e?l:t(a,r,o)}}),s}function i(){this.keys=[],this.values=[]}x.ad=function(e){if(0==arguments.length)throw Error("When calling ko.toJS, pass the object you want to convert.");return t(e,function(e){for(var t=0;x.O(e)&&10>t;t++)e=e();return e})},x.toJSON=function(e,t,i){return e=x.ad(e),x.a.hc(e,t,i)},i.prototype={constructor:i,save:function(e,t){var i=x.a.A(this.keys,e);0<=i?this.values[i]=t:(this.keys.push(e),this.values.push(t))},get:function(t){return 0<=(t=x.a.A(this.keys,t))?this.values[t]:e}}}(),x.b("toJS",x.ad),x.b("toJSON",x.toJSON),x.Wd=function(e,t,i){function n(t){var n=x.yb(e,i).extend({ma:"always"}),r=n.subscribe(function(e){e&&(r.s(),t(e))});return n.notifySubscribers(n.v()),r}return"function"!=typeof Promise||t?n(t.bind(i)):new Promise(n)},x.b("when",x.Wd),x.w={M:function(t){switch(x.a.R(t)){case"option":return!0===t.__ko__hasDomDataOptionValue__?x.a.g.get(t,x.c.options.$b):7>=x.a.W?t.getAttributeNode("value")&&t.getAttributeNode("value").specified?t.value:t.text:t.value;case"select":return 0<=t.selectedIndex?x.w.M(t.options[t.selectedIndex]):e;default:return t.value}},fb:function(t,i,n){switch(x.a.R(t)){case"option":"string"==typeof i?(x.a.g.set(t,x.c.options.$b,e),"__ko__hasDomDataOptionValue__"in t&&delete t.__ko__hasDomDataOptionValue__,t.value=i):(x.a.g.set(t,x.c.options.$b,i),t.__ko__hasDomDataOptionValue__=!0,t.value="number"==typeof i?i:"");break;case"select":""!==i&&null!==i||(i=e);for(var r,o=-1,s=0,a=t.options.length;s<a;++s)if((r=x.w.M(t.options[s]))==i||""===r&&i===e){o=s;break}(n||0<=o||i===e&&1<t.size)&&(t.selectedIndex=o,6===x.a.W&&x.a.setTimeout(function(){t.selectedIndex=o},0));break;default:null!==i&&i!==e||(i=""),t.value=i}}},x.b("selectExtensions",x.w),x.b("selectExtensions.readValue",x.w.M),x.b("selectExtensions.writeValue",x.w.fb),x.m=function(){function e(e){123===(e=x.a.Eb(e)).charCodeAt(0)&&(e=e.slice(1,-1));var t,i=[],s=(e+="\n,").match(n),a=[],l=0;if(1<s.length){for(var h,u=0;h=s[u];++u){var c=h.charCodeAt(0);if(44===c){if(0>=l){i.push(t&&a.length?{key:t,value:a.join("")}:{unknown:t||a.join("")}),t=l=0,a=[];continue}}else if(58===c){if(!l&&!t&&1===a.length){t=a.pop();continue}}else{if(47===c&&1<h.length&&(47===h.charCodeAt(1)||42===h.charCodeAt(1)))continue;47===c&&u&&1<h.length?(c=s[u-1].match(r))&&!o[c[0]]&&(s=(e=e.substr(e.indexOf(h)+1)).match(n),u=-1,h="/"):40===c||123===c||91===c?++l:41===c||125===c||93===c?--l:t||a.length||34!==c&&39!==c||(h=h.slice(1,-1))}a.push(h)}if(0<l)throw Error("Unbalanced parentheses, braces, or brackets")}return i}var t=["true","false","null","undefined"],i=/^(?:[$_a-z][$\w]*|(.+)(\.\s*[$_a-z][$\w]*|\[.+\]))$/i,n=RegExp("\"(?:\\\\.|[^\"])*\"|'(?:\\\\.|[^'])*'|`(?:\\\\.|[^`])*`|/\\*(?:[^*]|\\*+[^*/])*\\*+/|//.*\n|/(?:\\\\.|[^/])+/w*|[^\\s:,/][^,\"'`{}()/:[\\]]*[^\\s,\"'`{}()/:[\\]]|[^\\s]","g"),r=/[\])"'A-Za-z0-9_$]+$/,o={in:1,return:1,typeof:1},s={};return{Ta:[],ya:s,ac:e,wb:function(n,r){function o(e,n){var r;if(!u){var c=x.getBindingHandler(e);if(c&&c.preprocess&&!(n=c.preprocess(n,e,o)))return;(c=s[e])&&(r=n,0<=x.a.A(t,r)?r=!1:(c=r.match(i),r=null!==c&&(c[1]?"Object("+c[1]+")"+c[2]:r)),c=r),c&&l.push("'"+("string"==typeof s[e]?s[e]:e)+"':function(_z){"+r+"=_z}")}h&&(n="function(){return "+n+" }"),a.push("'"+e+"':"+n)}var a=[],l=[],h=(r=r||{}).valueAccessors,u=r.bindingParams,c="string"==typeof n?e(n):n;return x.a.D(c,function(e){o(e.key||e.unknown,e.value)}),l.length&&o("_ko_property_writers","{"+l.join(",")+" }"),a.join(",")},Id:function(e,t){for(var i=0;i<e.length;i++)if(e[i].key==t)return!0;return!1},gb:function(e,t,i,n,r){e&&x.O(e)?!x.ab(e)||r&&e.v()===n||e(n):(e=t.get("_ko_property_writers"))&&e[i]&&e[i](n)}}}(),x.b("expressionRewriting",x.m),x.b("expressionRewriting.bindingRewriteValidators",x.m.Ta),x.b("expressionRewriting.parseObjectLiteral",x.m.ac),x.b("expressionRewriting.preProcessBindings",x.m.wb),x.b("expressionRewriting._twoWayBindings",x.m.ya),x.b("jsonExpressionRewriting",x.m),x.b("jsonExpressionRewriting.insertPropertyAccessorsIntoJson",x.m.wb),function(){function e(e){return 8==e.nodeType&&s.test(o?e.text:e.nodeValue)}function t(e){return 8==e.nodeType&&a.test(o?e.text:e.nodeValue)}function n(i,n){for(var r=i,o=1,s=[];r=r.nextSibling;){if(t(r)&&(x.a.g.set(r,h,!0),0===--o))return s;s.push(r),e(r)&&o++}if(!n)throw Error("Cannot find closing comment tag to match: "+i.nodeValue);return null}function r(e,t){var i=n(e,t);return i?0<i.length?i[i.length-1].nextSibling:e.nextSibling:null}var o=i&&"\x3c!--test--\x3e"===i.createComment("test").text,s=o?/^\x3c!--\s*ko(?:\s+([\s\S]+))?\s*--\x3e$/:/^\s*ko(?:\s+([\s\S]+))?\s*$/,a=o?/^\x3c!--\s*\/ko\s*--\x3e$/:/^\s*\/ko\s*$/,l={ul:!0,ol:!0},h="__ko_matchedEndComment__";x.h={ea:{},childNodes:function(t){return e(t)?n(t):t.childNodes},Fa:function(t){if(e(t))for(var i=0,n=(t=x.h.childNodes(t)).length;i<n;i++)x.removeNode(t[i]);else x.a.Ub(t)},xa:function(t,i){if(e(t)){x.h.Fa(t);for(var n=t.nextSibling,r=0,o=i.length;r<o;r++)n.parentNode.insertBefore(i[r],n)}else x.a.xa(t,i)},Vc:function(t,i){var n;e(t)?(n=t.nextSibling,t=t.parentNode):n=t.firstChild,n?i!==n&&t.insertBefore(i,n):t.appendChild(i)},Xb:function(t,i,n){n?(n=n.nextSibling,e(t)&&(t=t.parentNode),n?i!==n&&t.insertBefore(i,n):t.appendChild(i)):x.h.Vc(t,i)},firstChild:function(i){return e(i)?!i.nextSibling||t(i.nextSibling)?null:i.nextSibling:i.firstChild&&t(i.firstChild)?i.firstChild.nextSibling:i.firstChild},nextSibling:function(i){return e(i)&&(i=r(i)),i.nextSibling&&t(i.nextSibling)?(t(i=i.nextSibling)&&x.a.g.get(i,h),null):i.nextSibling},Cd:e,Vd:function(e){return(e=(o?e.text:e.nodeValue).match(s))?e[1]:null},Sc:function(i){if(l[x.a.R(i)]){var n=i.firstChild;if(n)do{if(1===n.nodeType){var o,s=null;if(o=n.firstChild)do{if(s)s.push(o);else if(e(o)){var a=r(o,!0);a?o=a:s=[o]}else t(o)&&(s=[o])}while(o=o.nextSibling);if(o=s)for(s=n.nextSibling,a=0;a<o.length;a++)s?i.insertBefore(o[a],s):i.appendChild(o[a])}}while(n=n.nextSibling)}}}}(),x.b("virtualElements",x.h),x.b("virtualElements.allowedBindings",x.h.ea),x.b("virtualElements.emptyNode",x.h.Fa),x.b("virtualElements.insertAfter",x.h.Xb),x.b("virtualElements.prepend",x.h.Vc),x.b("virtualElements.setDomNodeChildren",x.h.xa),function(){function e(e,t){var i="with($context){with($data||{}){return{"+x.m.wb(e,t)+"}}}";return f?(0,eval)(f.createScript("(function($context,$element){"+i+"})")):new Function("$context","$element",i)}x.ga=function(){this.nd={}},x.a.extend(x.ga.prototype,{nodeHasBindings:function(e){switch(e.nodeType){case 1:return null!=e.getAttribute("data-bind")||x.j.getComponentNameForNode(e);case 8:return x.h.Cd(e);default:return!1}},getBindings:function(e,t){var i=(i=this.getBindingsString(e,t))?this.parseBindingsString(i,t,e):null;return x.j.tc(i,e,t,!1)},getBindingAccessors:function(e,t){var i=(i=this.getBindingsString(e,t))?this.parseBindingsString(i,t,e,{valueAccessors:!0}):null;return x.j.tc(i,e,t,!0)},getBindingsString:function(e){switch(e.nodeType){case 1:return e.getAttribute("data-bind");case 8:return x.h.Vd(e);default:return null}},parseBindingsString:function(t,i,n,r){try{var o=this.nd,s=t+(r&&r.valueAccessors||"");return(o[s]||(o[s]=e(t,r)))(i,n)}catch(e){throw e.message="Unable to parse bindings.\nBindings value: "+t+"\nMessage: "+e.message,e}}}),x.ga.instance=new x.ga}(),x.b("bindingProvider",x.ga),function(){function n(e){var t=(e=x.a.g.get(e,w))&&e.N;t&&(e.N=null,t.Tc())}function r(e,t,i){this.node=e,this.yc=t,this.mb=[],this.H=!1,t.N||x.a.J.oa(e,n),i&&i.N&&(i.N.mb.push(e),this.Lb=i)}function o(e){return function(){return e}}function a(e){return e()}function l(e){return x.a.Ia(x.u.G(e),function(t,i){return function(){return e()[i]}})}function h(e,t,i){return"function"==typeof e?l(e.bind(null,t,i)):x.a.Ia(e,o)}function u(e,t){return l(this.getBindings.bind(this,e,t))}function c(e,t){var i=x.h.firstChild(t);if(i){var n,r=x.ga.instance,o=r.preprocessNode;if(o){for(;n=i;)i=x.h.nextSibling(n),o.call(r,n);i=x.h.firstChild(t)}for(;n=i;)i=x.h.nextSibling(n),d(e,n)}x.i.ma(t,x.i.H)}function d(e,t){var i=e,n=1===t.nodeType;n&&x.h.Sc(t),(n||x.ga.instance.nodeHasBindings(t))&&(i=p(t,null,e).bindingContextForDescendants),i&&!y[x.a.R(t)]&&c(i,t)}function p(t,i,n){var r,o=x.a.g.Vb(t,w,{}),s=o.hd;if(!i){if(s)throw Error("You cannot apply bindings multiple times to the same element.");o.hd=!0}if(s||(o.context=n),o.vb||(o.vb={}),i&&"function"!=typeof i)r=i;else{var l=x.ga.instance,h=l.getBindingAccessors||u,c=x.$(function(){return(r=i?i(n,t):h.call(l,t,n))&&(n[g]&&n[g](),n[v]&&n[v]()),r},null,{l:t});r&&c.ja()||(c=null)}var d,p=n;if(r){var f=c?function(e){return function(){return a(c()[e])}}:function(e){return r[e]},m=function(){return x.a.Ia(c?c():r,a)};m.get=function(e){return r[e]&&a(f(e))},m.has=function(e){return e in r},x.i.H in r&&x.i.subscribe(t,x.i.H,function(){var e=(0,r[x.i.H])();if(e){var i=x.h.childNodes(t);i.length&&e(i,x.Ec(i[0]))}}),x.i.qa in r&&(p=x.i.Db(t,n),x.i.subscribe(t,x.i.qa,function(){var e=(0,r[x.i.qa])();e&&x.h.firstChild(t)&&e(t)})),o=function(e){var t=[],i={},n=[];return x.a.P(e,function r(o){if(!i[o]){var s=x.getBindingHandler(o);s&&(s.after&&(n.push(o),x.a.D(s.after,function(t){if(e[t]){if(-1!==x.a.A(n,t))throw Error("Cannot combine the following bindings, because they have a cyclic dependency: "+n.join(", "));r(t)}}),n.length--),t.push({key:o,Mc:s})),i[o]=!0}}),t}(r),x.a.D(o,function(i){var n=i.Mc.init,o=i.Mc.update,s=i.key;if(8===t.nodeType&&!x.h.ea[s])throw Error("The binding '"+s+"' cannot be used with virtual elements");try{"function"==typeof n&&x.u.G(function(){var i=n(t,f(s),m,p.$data,p);if(i&&i.controlsDescendantBindings){if(d!==e)throw Error("Multiple bindings ("+d+" and "+s+") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.");d=s}}),"function"==typeof o&&x.$(function(){o(t,f(s),m,p.$data,p)},null,{l:t})}catch(e){throw e.message='Unable to process binding "'+s+": "+r[s]+'"\nMessage: '+e.message,e}})}return{shouldBindDescendants:o=d===e,bindingContextForDescendants:o&&p}}function f(t,i){return t&&t instanceof x.fa?t:new x.fa(t,e,e,i)}var g=x.a.Ea("_subscribable"),m=x.a.Ea("_ancestorBindingInfo"),v=x.a.Ea("_dataDependency");x.c={};var y={script:!0,textarea:!0,template:!0};x.getBindingHandler=function(e){return x.c[e]};var b={};x.fa=function(t,i,n,r,o){function s(){var e=c?u():u,t=x.a.f(e);return i?(x.a.extend(l,i),m in i&&(l[m]=i[m])):(l.$parents=[],l.$root=t,l.ko=x),l[g]=a,h?t=l.$data:(l.$rawData=e,l.$data=t),n&&(l[n]=t),r&&r(l,i,t),i&&i[g]&&!x.S.o().Wb(i[g])&&i[g](),d&&(l[v]=d),l.$data}var a,l=this,h=t===b,u=h?e:t,c="function"==typeof u&&!x.O(u),d=o&&o.dataDependency;o&&o.exportDependencies?s():((a=x.yb(s)).v(),a.ja()?a.equalityComparer=null:l[g]=e)},x.fa.prototype.createChildContext=function(e,t,i,n){if(!n&&t&&"object"==typeof t&&(t=(n=t).as,i=n.extend),t&&n&&n.noChildContext){var r="function"==typeof e&&!x.O(e);return new x.fa(b,this,null,function(n){i&&i(n),n[t]=r?e():e},n)}return new x.fa(e,this,t,function(e,t){e.$parentContext=t,e.$parent=t.$data,e.$parents=(t.$parents||[]).slice(0),e.$parents.unshift(e.$parent),i&&i(e)},n)},x.fa.prototype.extend=function(e,t){return new x.fa(b,this,null,function(t){x.a.extend(t,"function"==typeof e?e(t):e)},t)};var w=x.a.g.Z();r.prototype.Tc=function(){this.Lb&&this.Lb.N&&this.Lb.N.sd(this.node)},r.prototype.sd=function(e){x.a.Ra(this.mb,e),!this.mb.length&&this.H&&this.Cc()},r.prototype.Cc=function(){this.H=!0,this.yc.N&&!this.mb.length&&(this.yc.N=null,x.a.J.zb(this.node,n),x.i.ma(this.node,x.i.qa),this.Tc())},x.i={H:"childrenComplete",qa:"descendantsComplete",subscribe:function(e,t,i,n,r){var o=x.a.g.Vb(e,w,{});return o.Ga||(o.Ga=new x.T),r&&r.notifyImmediately&&o.vb&&o.vb[t]&&x.u.G(i,n,[e]),o.Ga.subscribe(i,n,t)},ma:function(t,i){var n=x.a.g.get(t,w);if(n&&(n.vb[i]=!0,n.Ga&&n.Ga.notifySubscribers(t,i),i==x.i.H))if(n.N)n.N.Cc();else if(n.N===e&&n.Ga&&n.Ga.Ya(x.i.qa))throw Error("descendantsComplete event not supported for bindings on this node")},Db:function(e,t){var i=x.a.g.Vb(e,w,{});return i.N||(i.N=new r(e,i,t[m])),t[m]==i?t:t.extend(function(e){e[m]=i})}},x.Td=function(e){return(e=x.a.g.get(e,w))&&e.context},x.kb=function(e,t,i){return 1===e.nodeType&&x.h.Sc(e),p(e,t,f(i))},x.ld=function(e,t,i){return i=f(i),x.kb(e,h(t,i,e),i)},x.Qa=function(e,t){1!==t.nodeType&&8!==t.nodeType||c(f(e),t)},x.vc=function(e,n,r){if(!s&&t.jQuery&&(s=t.jQuery),2>arguments.length){if(!(n=i.body))throw Error("ko.applyBindings: could not find document.body; has the document been loaded?")}else if(!n||1!==n.nodeType&&8!==n.nodeType)throw Error("ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node");d(f(e,r),n)},x.Dc=function(t){return!t||1!==t.nodeType&&8!==t.nodeType?e:x.Td(t)},x.Ec=function(t){return(t=x.Dc(t))?t.$data:e},x.b("bindingHandlers",x.c),x.b("bindingEvent",x.i),x.b("bindingEvent.subscribe",x.i.subscribe),x.b("bindingEvent.startPossiblyAsyncContentBinding",x.i.Db),x.b("applyBindings",x.vc),x.b("applyBindingsToDescendants",x.Qa),x.b("applyBindingAccessorsToNode",x.kb),x.b("applyBindingsToNode",x.ld),x.b("contextFor",x.Dc),x.b("dataFor",x.Ec)}(),function(e){function t(t,n){var s,a=Object.prototype.hasOwnProperty.call(r,t)?r[t]:e;a?a.subscribe(n):((a=r[t]=new x.T).subscribe(n),i(t,function(e,i){var n=!(!i||!i.synchronous);o[t]={definition:e,Gd:n},delete r[t],s||n?a.notifySubscribers(e):x.na.Ab(function(){a.notifySubscribers(e)})}),s=!0)}function i(e,t){n("getConfig",[e],function(i){i?n("loadComponent",[e,i],function(e){t(e,i)}):t(null,null)})}function n(t,i,r,o){o||(o=x.j.loaders.slice(0));var s=o.shift();if(s){var a=s[t];if(a){var l=!1;if(a.apply(s,i.concat(function(e){l?r(null):null!==e?r(e):n(t,i,r,o)}))!==e&&(l=!0,!s.suppressLoaderExceptions))throw Error("Component loaders must supply values by invoking the callback, not by returning values synchronously.")}else n(t,i,r,o)}else r(null)}var r={},o={};x.j={get:function(i,n){var r=Object.prototype.hasOwnProperty.call(o,i)?o[i]:e;r?r.Gd?x.u.G(function(){n(r.definition)}):x.na.Ab(function(){n(r.definition)}):t(i,n)},Bc:function(e){delete o[e]},oc:n},x.j.loaders=[],x.b("components",x.j),x.b("components.get",x.j.get),x.b("components.clearCachedDefinition",x.j.Bc)}(),function(){function e(e,t,i,n){function r(){0===--s&&n(o)}var o={},s=2,l=i.template;i=i.viewModel,l?a(t,l,function(t){x.j.oc("loadTemplate",[e,t],function(e){o.template=e,r()})}):r(),i?a(t,i,function(t){x.j.oc("loadViewModel",[e,t],function(e){o[u]=e,r()})}):r()}function n(e,t,i){if("function"==typeof t)i(function(e){return new t(e)});else if("function"==typeof t[u])i(t[u]);else if("instance"in t){var r=t.instance;i(function(){return r})}else"viewModel"in t?n(e,t.viewModel,i):e("Unknown viewModel value: "+t)}function r(e){switch(x.a.R(e)){case"script":return x.a.wa(e.text);case"textarea":return x.a.wa(e.value);case"template":if(s(e.content))return x.a.Da(e.content.childNodes)}return x.a.Da(e.childNodes)}function s(e){return t.DocumentFragment?e instanceof DocumentFragment:e&&11===e.nodeType}function a(e,i,n){"string"==typeof i.require?o||t.require?(o||t.require)([i.require],function(e){e&&"object"==typeof e&&e.Xd&&e.default&&(e=e.default),n(e)}):e("Uses require, but no AMD loader is present"):n(i)}function l(e){return function(t){throw Error("Component '"+e+"': "+t)}}var h={};x.j.register=function(e,t){if(!t)throw Error("Invalid configuration for "+e);if(x.j.tb(e))throw Error("Component "+e+" is already registered");h[e]=t},x.j.tb=function(e){return Object.prototype.hasOwnProperty.call(h,e)},x.j.unregister=function(e){delete h[e],x.j.Bc(e)},x.j.Fc={getConfig:function(e,t){t(x.j.tb(e)?h[e]:null)},loadComponent:function(t,i,n){var r=l(t);a(r,i,function(i){e(t,r,i,n)})},loadTemplate:function(e,n,o){if(e=l(e),"string"==typeof n)o(x.a.wa(n));else if(n instanceof Array)o(n);else if(s(n))o(x.a.la(n.childNodes));else if(n.element)if(n=n.element,t.HTMLElement?n instanceof HTMLElement:n&&n.tagName&&1===n.nodeType)o(r(n));else if("string"==typeof n){var a=i.getElementById(n);a?o(r(a)):e("Cannot find element with ID "+n)}else e("Unknown element type: "+n);else e("Unknown template value: "+n)},loadViewModel:function(e,t,i){n(l(e),t,i)}};var u="createViewModel";x.b("components.register",x.j.register),x.b("components.isRegistered",x.j.tb),x.b("components.unregister",x.j.unregister),x.b("components.defaultLoader",x.j.Fc),x.j.loaders.push(x.j.Fc),x.j.dd=h}(),function(){function e(e,i){if(n=e.getAttribute("params")){var n=t.parseBindingsString(n,i,e,{valueAccessors:!0,bindingParams:!0}),r=(n=x.a.Ia(n,function(t){return x.o(t,null,{l:e})}),x.a.Ia(n,function(t){var i=t.v();return t.ja()?x.o({read:function(){return x.a.f(t())},write:x.ab(i)&&function(e){t()(e)},l:e}):i}));return Object.prototype.hasOwnProperty.call(r,"$raw")||(r.$raw=n),r}return{$raw:{}}}x.j.getComponentNameForNode=function(e){var t=x.a.R(e);if(x.j.tb(t)&&(-1!=t.indexOf("-")||"[object HTMLUnknownElement]"==""+e||8>=x.a.W&&e.tagName===t))return t},x.j.tc=function(t,i,n,r){if(1===i.nodeType){var o=x.j.getComponentNameForNode(i);if(o){if((t=t||{}).component)throw Error('Cannot use the "component" binding on a custom element matching a component');var s={name:o,params:e(i,n)};t.component=r?function(){return s}:s}}return t};var t=new x.ga;9>x.a.W&&(x.j.register=function(e){return function(t){return e.apply(this,arguments)}}(x.j.register),i.createDocumentFragment=function(e){return function(){var t=e();return x.j.dd,t}}(i.createDocumentFragment))}(),function(){var e=0;x.c.component={init:function(t,i,n,r,o){function s(){var e=a&&a.dispose;"function"==typeof e&&e.call(a),h&&h.s(),l=a=h=null}var a,l,h,u=x.a.la(x.h.childNodes(t));return x.h.Fa(t),x.a.J.oa(t,s),x.o(function(){var n,r,c=x.a.f(i());if("string"==typeof c?n=c:(n=x.a.f(c.name),r=x.a.f(c.params)),!n)throw Error("No component name specified");var d=x.i.Db(t,o),p=l=++e;x.j.get(n,function(e){if(l===p){if(s(),!e)throw Error("Unknown component '"+n+"'");!function(e,t,i){if(!(t=t.template))throw Error("Component '"+e+"' has no template");e=x.a.Da(t),x.h.xa(i,e)}(n,e,t);var i=function(e,t,i){var n=e.createViewModel;return n?n.call(e,t,i):t}(e,r,{element:t,templateNodes:u});e=d.createChildContext(i,{extend:function(e){e.$component=i,e.$componentTemplateNodes=u}}),i&&i.koDescendantsComplete&&(h=x.i.subscribe(t,x.i.qa,i.koDescendantsComplete,i)),a=i,x.Qa(e,t)}})},null,{l:t}),{controlsDescendantBindings:!0}}},x.h.ea.component=!0}();var R={class:"className",for:"htmlFor"};x.c.attr={update:function(t,i){var n=x.a.f(i())||{};x.a.P(n,function(i,n){n=x.a.f(n);var r=i.indexOf(":"),o=(r="lookupNamespaceURI"in t&&0<r&&t.lookupNamespaceURI(i.substr(0,r)),!1===n||null===n||n===e);o?r?t.removeAttributeNS(r,i):t.removeAttribute(i):n=n.toString(),8>=x.a.W&&i in R?(i=R[i],o?t.removeAttribute(i):t[i]=n):o||(r?t.setAttributeNS(r,i,n):t.setAttribute(i,n)),"name"===i&&x.a.Yc(t,o?"":n)})}},x.c.checked={after:["value","attr"],init:function(t,i,n){function r(){var r=t.checked,l=o();if(!x.S.$a()&&(r||!a&&!x.S.ra())){var c=x.u.G(i);if(h){var p=u?c.v():c,f=d;d=l,f!==l?r&&(x.a.Pa(p,l,!0),x.a.Pa(p,f,!1)):x.a.Pa(p,l,r),u&&x.ab(c)&&c(p)}else s&&(l===e?l=r:r||(l=e)),x.m.gb(c,n,"checked",l,!0)}}var o=x.yb(function(){return n.has("checkedValue")?x.a.f(n.get("checkedValue")):c?n.has("value")?x.a.f(n.get("value")):t.value:void 0}),s="checkbox"==t.type,a="radio"==t.type;if(s||a){var l=i(),h=s&&x.a.f(l)instanceof Array,u=!(h&&l.push&&l.splice),c=a||h,d=h?o():e;a&&!t.name&&x.c.uniqueName.init(t,function(){return!0}),x.o(r,null,{l:t}),x.a.B(t,"click",r),x.o(function(){var n=x.a.f(i()),r=o();h?(t.checked=null!=n&&0<=x.a.A(n,r),d=r):t.checked=s&&r===e?!!n:o()===n},null,{l:t}),l=e}}},x.m.ya.checked=!0,x.c.checkedValue={update:function(e,t){e.value=x.a.f(t())}},x.c.class={update:function(e,t){var i=x.a.Eb(x.a.f(t()));x.a.Fb(e,e.__ko__cssValue,!1),e.__ko__cssValue=i,x.a.Fb(e,i,!0)}},x.c.css={update:function(e,t){var i=x.a.f(t());null!==i&&"object"==typeof i?x.a.P(i,function(t,i){i=x.a.f(i),x.a.Fb(e,t,i)}):x.c.class.update(e,t)}},x.c.enable={update:function(e,t){var i=x.a.f(t());i&&e.disabled?e.removeAttribute("disabled"):i||e.disabled||(e.disabled=!0)}},x.c.disable={update:function(e,t){x.c.enable.update(e,function(){return!x.a.f(t())})}},x.c.event={init:function(e,t,i,n,r){var o=t()||{};x.a.P(o,function(o){"string"==typeof o&&x.a.B(e,o,function(e){var s,a=t()[o];if(a){try{var l=x.a.la(arguments);n=r.$data,l.unshift(n),s=a.apply(n,l)}finally{!0!==s&&(e.preventDefault?e.preventDefault():e.returnValue=!1)}!1===i.get(o+"Bubble")&&(e.cancelBubble=!0,e.stopPropagation&&e.stopPropagation())}})})}},x.c.foreach={Rc:function(e){return function(){var t=e(),i=x.a.bc(t);return i&&"number"!=typeof i.length?(x.a.f(t),{foreach:i.data,as:i.as,noChildContext:i.noChildContext,includeDestroyed:i.includeDestroyed,afterAdd:i.afterAdd,beforeRemove:i.beforeRemove,afterRender:i.afterRender,beforeMove:i.beforeMove,afterMove:i.afterMove,templateEngine:x.ba.Oa}):{foreach:t,templateEngine:x.ba.Oa}}},init:function(e,t){return x.c.template.init(e,x.c.foreach.Rc(t))},update:function(e,t,i,n,r){return x.c.template.update(e,x.c.foreach.Rc(t),i,n,r)}},x.m.Ta.foreach=!1,x.h.ea.foreach=!0,x.c.hasfocus={init:function(e,t,i){function n(n){e.__ko_hasfocusUpdating=!0;var r=e.ownerDocument;if("activeElement"in r){var o;try{o=r.activeElement}catch(e){o=r.body}n=o===e}r=t(),x.m.gb(r,i,"hasfocus",n,!0),e.__ko_hasfocusLastValue=n,e.__ko_hasfocusUpdating=!1}var r=n.bind(null,!0),o=n.bind(null,!1);x.a.B(e,"focus",r),x.a.B(e,"focusin",r),x.a.B(e,"blur",o),x.a.B(e,"focusout",o),e.__ko_hasfocusLastValue=!1},update:function(e,t){var i=!!x.a.f(t());e.__ko_hasfocusUpdating||e.__ko_hasfocusLastValue===i||(i?e.focus():e.blur(),!i&&e.__ko_hasfocusLastValue&&e.ownerDocument.body.focus(),x.u.G(x.a.Gb,null,[e,i?"focusin":"focusout"]))}},x.m.ya.hasfocus=!0,x.c.hasFocus=x.c.hasfocus,x.m.ya.hasFocus="hasfocus",x.c.html={init:function(){return{controlsDescendantBindings:!0}},update:function(e,t){x.a.fc(e,t())}},function(){function e(e,t,i){x.c[e]={init:function(e,n,r,o,s){var a,l,h,u,c,d={};if(t){o=r.get("as");var p=r.get("noChildContext");d={as:o,noChildContext:p,exportDependencies:c=!(o&&p)}}return u=(h="render"==r.get("completeOn"))||r.has(x.i.qa),x.o(function(){var r,o=x.a.f(n()),p=!i!=!o,f=!l;(c||p!==a)&&(u&&(s=x.i.Db(e,s)),p&&(t&&!c||(d.dataDependency=x.S.o()),r=t?s.createChildContext("function"==typeof o?o:n,d):x.S.ra()?s.extend(null,d):s),f&&x.S.ra()&&(l=x.a.Da(x.h.childNodes(e),!0)),p?(f||x.h.xa(e,x.a.Da(l)),x.Qa(r,e)):(x.h.Fa(e),h||x.i.ma(e,x.i.H)),a=p)},null,{l:e}),{controlsDescendantBindings:!0}}},x.m.Ta[e]=!1,x.h.ea[e]=!0}e("if"),e("ifnot",!1,!0),e("with",!0)}(),x.c.let={init:function(e,t,i,n,r){return t=r.extend(t),x.Qa(t,e),{controlsDescendantBindings:!0}}},x.h.ea.let=!0;var O={};x.c.options={init:function(e){if("select"!==x.a.R(e))throw Error("options binding applies only to SELECT elements");for(;0<e.length;)e.remove(0);return{controlsDescendantBindings:!0}},update:function(t,i,n){function r(){return x.a.lb(t.options,function(e){return e.selected})}function o(e,t,i){var n=typeof t;return"function"==n?t(e):"string"==n?e[t]:i}function s(e,i){if(f&&u)x.i.ma(t,x.i.H);else if(p.length){var n=0<=x.a.A(p,x.w.M(i[0]));x.a.Zc(i[0],n),f&&!n&&x.u.G(x.a.Gb,null,[t,"change"])}}var a=t.multiple,l=0!=t.length&&a?t.scrollTop:null,h=x.a.f(i()),u=n.get("valueAllowUnset")&&n.has("value"),c=n.get("optionsIncludeDestroyed");i={};var d,p=[];u||(a?p=x.a.Nb(r(),x.w.M):0<=t.selectedIndex&&p.push(x.w.M(t.options[t.selectedIndex]))),h&&(void 0===h.length&&(h=[h]),d=x.a.lb(h,function(t){return c||t===e||null===t||!x.a.f(t._destroy)}),n.has("optionsCaption")&&null!==(h=x.a.f(n.get("optionsCaption")))&&h!==e&&d.unshift(O));var f=!1;i.beforeRemove=function(e){t.removeChild(e)},h=s,n.has("optionsAfterRender")&&"function"==typeof n.get("optionsAfterRender")&&(h=function(t,i){s(0,i),x.u.G(n.get("optionsAfterRender"),null,[i[0],t!==O?t:e])}),x.a.ec(t,d,function(i,r,s){return s.length&&(p=!u&&s[0].selected?[x.w.M(s[0])]:[],f=!0),r=t.ownerDocument.createElement("option"),i===O?(x.a.Cb(r,n.get("optionsCaption")),x.w.fb(r,e)):(s=o(i,n.get("optionsValue"),i),x.w.fb(r,x.a.f(s)),i=o(i,n.get("optionsText"),s),x.a.Cb(r,i)),[r]},i,h),u||(a?p.length&&r().length<p.length:p.length&&0<=t.selectedIndex?x.w.M(t.options[t.selectedIndex])!==p[0]:p.length||0<=t.selectedIndex)&&x.u.G(x.a.Gb,null,[t,"change"]),(u||x.S.$a())&&x.i.ma(t,x.i.H),x.a.wd(t),l&&20<Math.abs(l-t.scrollTop)&&(t.scrollTop=l)}},x.c.options.$b=x.a.g.Z(),x.c.selectedOptions={init:function(e,t,i){function n(){var n=t(),r=[];x.a.D(e.getElementsByTagName("option"),function(e){e.selected&&r.push(x.w.M(e))}),x.m.gb(n,i,"selectedOptions",r)}function r(){var i=x.a.f(t()),n=e.scrollTop;i&&"number"==typeof i.length&&x.a.D(e.getElementsByTagName("option"),function(e){var t=0<=x.a.A(i,x.w.M(e));e.selected!=t&&x.a.Zc(e,t)}),e.scrollTop=n}if("select"!=x.a.R(e))throw Error("selectedOptions binding applies only to SELECT elements");var o;x.i.subscribe(e,x.i.H,function(){o?n():(x.a.B(e,"change",n),o=x.o(r,null,{l:e}))},null,{notifyImmediately:!0})},update:function(){}},x.m.ya.selectedOptions=!0,x.c.style={update:function(t,i){var n=x.a.f(i()||{});x.a.P(n,function(i,n){if(null!==(n=x.a.f(n))&&n!==e&&!1!==n||(n=""),s)s(t).css(i,n);else if(/^--/.test(i))t.style.setProperty(i,n);else{i=i.replace(/-(\w)/g,function(e,t){return t.toUpperCase()});var r=t.style[i];t.style[i]=n,n===r||t.style[i]!=r||isNaN(n)||(t.style[i]=n+"px")}})}},x.c.submit={init:function(e,t,i,n,r){if("function"!=typeof t())throw Error("The value for a submit binding must be a function");x.a.B(e,"submit",function(i){var n,o=t();try{n=o.call(r.$data,e)}finally{!0!==n&&(i.preventDefault?i.preventDefault():i.returnValue=!1)}})}},x.c.text={init:function(){return{controlsDescendantBindings:!0}},update:function(e,t){x.a.Cb(e,t())}},x.h.ea.text=!0,function(){if(t&&t.navigator){var i,n,r,o,s,a=function(e){if(e)return parseFloat(e[1])},l=t.navigator.userAgent;(i=t.opera&&t.opera.version&&parseInt(t.opera.version()))||(s=a(l.match(/Edge\/([^ ]+)$/)))||a(l.match(/Chrome\/([^ ]+)/))||(n=a(l.match(/Version\/([^ ]+) Safari/)))||(r=a(l.match(/Firefox\/([^ ]+)/)))||(o=x.a.W||a(l.match(/MSIE ([^ ]+)/)))||(o=a(l.match(/rv:([^ )]+)/)))}if(8<=o&&10>o)var h=x.a.g.Z(),u=x.a.g.Z(),c=function(e){var t=this.activeElement;(t=t&&x.a.g.get(t,u))&&t(e)},d=function(e,t){var i=e.ownerDocument;x.a.g.get(i,h)||(x.a.g.set(i,h,!0),x.a.B(i,"selectionchange",c)),x.a.g.set(e,u,t)};x.c.textInput={init:function(t,a,l){function h(e,i){x.a.B(t,e,i)}function u(){p||(f=t.value,p=x.a.setTimeout(c,4))}function c(){clearTimeout(p),f=p=e;var i=t.value;g!==i&&(g=i,x.m.gb(a(),l,"textInput",i))}var p,f,g=t.value,m=9==x.a.W?u:c,v=!1;o&&h("keypress",c),11>o&&h("propertychange",function(e){v||"value"!==e.propertyName||m()}),8==o&&(h("keyup",c),h("keydown",c)),d&&(d(t,m),h("dragend",u)),(!o||9<=o)&&h("input",m),5>n&&"textarea"===x.a.R(t)?(h("keydown",u),h("paste",u),h("cut",u)):11>i?h("keydown",u):4>r?(h("DOMAutoComplete",c),h("dragdrop",c),h("drop",c)):s&&"number"===t.type&&h("keydown",u),h("change",c),h("blur",c),x.o(function i(){var n=x.a.f(a());null!==n&&n!==e||(n=""),f!==e&&n===f?x.a.setTimeout(i,4):t.value!==n&&(v=!0,t.value=n,v=!1,g=t.value)},null,{l:t})}},x.m.ya.textInput=!0,x.c.textinput={preprocess:function(e,t,i){i("textInput",e)}}}(),x.c.uniqueName={init:function(e,t){if(t()){var i="ko_unique_"+ ++x.c.uniqueName.rd;x.a.Yc(e,i)}}},x.c.uniqueName.rd=0,x.c.using={init:function(e,t,i,n,r){var o;return i.has("as")&&(o={as:i.get("as"),noChildContext:i.get("noChildContext")}),t=r.createChildContext(t,o),x.Qa(t,e),{controlsDescendantBindings:!0}}},x.h.ea.using=!0,x.c.value={init:function(t,i,n){var r=x.a.R(t),o="input"==r;if(!o||"checkbox"!=t.type&&"radio"!=t.type){var s=[],a=n.get("valueUpdate"),l=!1,h=null;a&&(s="string"==typeof a?[a]:x.a.wc(a),x.a.Ra(s,"change"));var u,c,d=function(){h=null,l=!1;var e=i(),r=x.w.M(t);x.m.gb(e,n,"value",r)};!x.a.W||!o||"text"!=t.type||"off"==t.autocomplete||t.form&&"off"==t.form.autocomplete||-1!=x.a.A(s,"propertychange")||(x.a.B(t,"propertychange",function(){l=!0}),x.a.B(t,"focus",function(){l=!1}),x.a.B(t,"blur",function(){l&&d()})),x.a.D(s,function(e){var i=d;x.a.Ud(e,"after")&&(i=function(){h=x.w.M(t),x.a.setTimeout(d,0)},e=e.substring(5)),x.a.B(t,e,i)}),u=o&&"file"==t.type?function(){var n=x.a.f(i());null===n||n===e||""===n?t.value="":x.u.G(d)}:function(){var o=x.a.f(i()),s=x.w.M(t);null!==h&&o===h?x.a.setTimeout(u,0):o===s&&s!==e||("select"===r?(s=n.get("valueAllowUnset"),x.w.fb(t,o,s),s||o===x.w.M(t)||x.u.G(d)):x.w.fb(t,o))},"select"===r?(x.a.B(t,"change",function(){c&&d()}),x.i.subscribe(t,x.i.H,function(){c?n.get("valueAllowUnset")?u():d():c=x.o(u,null,{l:t})},null,{notifyImmediately:!0})):(x.a.B(t,"change",d),x.o(u,null,{l:t}))}else x.kb(t,{checkedValue:i})},update:function(){}},x.m.ya.value=!0,x.c.visible={update:function(e,t){var i=x.a.f(t()),n="none"!=e.style.display;i&&!n?e.style.display="":!i&&n&&(e.style.display="none")}},x.c.hidden={update:function(e,t){x.c.visible.update(e,function(){return!x.a.f(t())})}},function(e){x.c[e]={init:function(t,i,n,r,o){return x.c.event.init.call(this,t,function(){var t={};return t[e]=i(),t},n,r,o)}}}("click"),x.ca=function(){},x.ca.prototype.renderTemplateSource=function(){throw Error("Override renderTemplateSource")},x.ca.prototype.createJavaScriptEvaluatorBlock=function(){throw Error("Override createJavaScriptEvaluatorBlock")},x.ca.prototype.makeTemplateSource=function(e,t){if("string"==typeof e){var n=(t=t||i).getElementById(e);if(!n)throw Error("Cannot find template with ID "+e);return new x.C.F(n)}if(1==e.nodeType||8==e.nodeType)return new x.C.ia(e);throw Error("Unknown template type: "+e)},x.ca.prototype.renderTemplate=function(e,t,i,n){return e=this.makeTemplateSource(e,n),this.renderTemplateSource(e,t,i,n)},x.ca.prototype.isTemplateRewritten=function(e,t){return!1===this.allowTemplateRewriting||this.makeTemplateSource(e,t).data("isRewritten")},x.ca.prototype.rewriteTemplate=function(e,t,i){t=t((e=this.makeTemplateSource(e,i)).text()),e.text(t),e.data("isRewritten",!0)},x.b("templateEngine",x.ca),x.kc=function(){function e(e,t,i,n){e=x.m.ac(e);for(var r=x.m.Ta,o=0;o<e.length;o++){var s=e[o].key;if(Object.prototype.hasOwnProperty.call(r,s)){var a=r[s];if("function"==typeof a){if(s=a(e[o].value))throw Error(s)}else if(!a)throw Error("This template engine does not support the '"+s+"' binding within its templates")}}return i="ko.__tr_ambtns(function($context,$element){return(function(){return{ "+x.m.wb(e,{valueAccessors:!0})+" } })()},'"+i.toLowerCase()+"')",n.createJavaScriptEvaluatorBlock(i)+t}var t=/(<([a-z]+\d*)(?:\s+(?!data-bind\s*=\s*)[a-z0-9\-]+(?:=(?:\"[^\"]*\"|\'[^\']*\'|[^>]*))?)*\s+)data-bind\s*=\s*(["'])([\s\S]*?)\3/gi,i=/\x3c!--\s*ko\b\s*([\s\S]*?)\s*--\x3e/g;return{xd:function(e,t,i){t.isTemplateRewritten(e,i)||t.rewriteTemplate(e,function(e){return x.kc.Ld(e,t)},i)},Ld:function(n,r){return n.replace(t,function(t,i,n,o,s){return e(s,i,n,r)}).replace(i,function(t,i){return e(i,"\x3c!-- ko --\x3e","#comment",r)})},md:function(e,t){return x.aa.Yb(function(i,n){var r=i.nextSibling;r&&r.nodeName.toLowerCase()===t&&x.kb(r,e,n)})}}}(),x.b("__tr_ambtns",x.kc.md),function(){x.C={},x.C.F=function(e){if(this.F=e){var t=x.a.R(e);this.cb="script"===t?1:"textarea"===t?2:"template"==t&&e.content&&11===e.content.nodeType?3:4}},x.C.F.prototype.text=function(){var e=1===this.cb?"text":2===this.cb?"value":"innerHTML";if(0==arguments.length)return this.F[e];var t=arguments[0];"innerHTML"===e?x.a.fc(this.F,t):this.F[e]=t};var t=x.a.g.Z()+"_";x.C.F.prototype.data=function(e){if(1===arguments.length)return x.a.g.get(this.F,t+e);x.a.g.set(this.F,t+e,arguments[1])};var i=x.a.g.Z();x.C.F.prototype.nodes=function(){var t=this.F;if(0==arguments.length){var n=x.a.g.get(t,i)||{},r=n.nb||(3===this.cb?t.content:4===this.cb?t:e);if(!r||n.jd){var o=this.text();o&&o!==n.eb&&(r=x.a.Md(o,t.ownerDocument),x.a.g.set(t,i,{nb:r,eb:o,jd:!0}))}return r}n=arguments[0],this.cb!==e&&this.text(""),x.a.g.set(t,i,{nb:n})},x.C.ia=function(e){this.F=e},x.C.ia.prototype=new x.C.F,x.C.ia.prototype.constructor=x.C.ia,x.C.ia.prototype.text=function(){if(0==arguments.length){var t=x.a.g.get(this.F,i)||{};return t.eb===e&&t.nb&&(t.eb=t.nb.innerHTML),t.eb}x.a.g.set(this.F,i,{eb:arguments[0]})},x.b("templateSources",x.C),x.b("templateSources.domElement",x.C.F),x.b("templateSources.anonymousTemplate",x.C.ia)}(),function(){function t(e,t,i){var n;for(t=x.h.nextSibling(t);e&&(n=e)!==t;)i(n,e=x.h.nextSibling(n))}function i(e,i){if(e.length){var n=e[0],r=e[e.length-1],o=n.parentNode,s=x.ga.instance,a=s.preprocessNode;if(a){if(t(n,r,function(e,t){var i=e.previousSibling,o=a.call(s,e);o&&(e===n&&(n=o[0]||t),e===r&&(r=o[o.length-1]||i))}),e.length=0,!n)return;n===r?e.push(n):(e.push(n,r),x.a.Wa(e,o))}t(n,r,function(e){1!==e.nodeType&&8!==e.nodeType||x.vc(i,e)}),t(n,r,function(e){1!==e.nodeType&&8!==e.nodeType||x.aa.cd(e,[i])}),x.a.Wa(e,o)}}function n(e){return e.nodeType?e:0<e.length?e[0]:null}function r(e,t,r,o,a){a=a||{};var l=(e&&n(e)||r||{}).ownerDocument,h=a.templateEngine||s;if(x.kc.xd(r,h,l),"number"!=typeof(r=h.renderTemplate(r,o,a,l)).length||0<r.length&&"number"!=typeof r[0].nodeType)throw Error("Template engine must return an array of DOM nodes");switch(l=!1,t){case"replaceChildren":x.h.xa(e,r),l=!0;break;case"replaceNode":x.a.Xc(e,r),l=!0;break;case"ignoreTargetNode":break;default:throw Error("Unknown renderMode: "+t)}return l&&(i(r,o),a.afterRender&&x.u.G(a.afterRender,null,[r,o[a.as||"$data"]]),"replaceChildren"==t&&x.i.ma(e,x.i.H)),r}function o(e,t,i){return x.O(e)?e():"function"==typeof e?e(t,i):e}var s;x.gc=function(t){if(t!=e&&!(t instanceof x.ca))throw Error("templateEngine must inherit from ko.templateEngine");s=t},x.dc=function(t,i,a,l,h){if(((a=a||{}).templateEngine||s)==e)throw Error("Set a template engine before calling renderTemplate");if(h=h||"replaceChildren",l){var u=n(l);return x.$(function(){var e=i&&i instanceof x.fa?i:new x.fa(i,null,null,null,{exportDependencies:!0}),s=o(t,e.$data,e);e=r(l,h,s,e,a),"replaceNode"==h&&(u=n(l=e))},null,{Ua:function(){return!u||!x.a.Tb(u)},l:u&&"replaceNode"==h?u.parentNode:u})}return x.aa.Yb(function(e){x.dc(t,i,a,e,"replaceNode")})},x.Qd=function(t,n,s,a,l){function h(e){if(m.push(e),!v){v=!0;try{for(;m.length;)try{u(n.v(),m[0])}finally{m.shift()}}finally{v=!1}}}function u(e,t){x.u.G(x.a.ec,null,[a,e,d,s,c,t]),x.i.ma(a,x.i.H)}function c(e,t){i(t,p),s.afterRender&&s.afterRender(t,e),p=null}function d(e,i){p=l.createChildContext(e,{as:f,noChildContext:s.noChildContext,extend:function(e){e.$index=i,f&&(e[f+"Index"]=i)}});var n=o(t,e,p);return r(a,"ignoreTargetNode",n,p,s)}var p,f=s.as,g=!1===s.includeDestroyed||x.options.foreachHidesDestroyed&&!s.includeDestroyed;if(g||s.beforeRemove||!x.Pc(n))return x.$(function(){var t=x.a.f(n)||[];void 0===t.length&&(t=[t]),g&&(t=x.a.lb(t,function(t){return t===e||null===t||!x.a.f(t._destroy)})),u(t)},null,{l:a});var m=[],v=!1,y=n.subscribe(h,null,"arrayChange");return y.l(a),h(),y};var a=x.a.g.Z(),l=x.a.g.Z();x.c.template={init:function(e,t){var i=x.a.f(t());if("string"==typeof i||"name"in i)x.h.Fa(e);else if("nodes"in i){if(i=i.nodes||[],x.O(i))throw Error('The "nodes" option must be a plain, non-observable array.');var n=i[0]&&i[0].parentNode;n&&x.a.g.get(n,l)||(n=x.a.Zb(i),x.a.g.set(n,l,!0)),new x.C.ia(e).nodes(n)}else{if(!(0<(i=x.h.childNodes(e)).length))throw Error("Anonymous template defined, but no template content was provided");n=x.a.Zb(i),new x.C.ia(e).nodes(n)}return{controlsDescendantBindings:!0}},update:function(t,i,n,r,o){var s=i();n=!0,r=null,"string"==typeof(i=x.a.f(s))?i={}:(s="name"in i?i.name:t,"if"in i&&(n=x.a.f(i.if)),n&&"ifnot"in i&&(n=!x.a.f(i.ifnot))),n&&!s&&(n=!1);var l=x.a.g.get(t,a);l&&"function"==typeof l.s&&l.s(),"foreach"in i?r=x.Qd(s,n&&i.foreach||[],i,t,o):n?(n=o,"data"in i&&(n=o.createChildContext(i.data,{as:i.as,noChildContext:i.noChildContext,exportDependencies:!0})),r=x.dc(s,n,i,t)):x.h.Fa(t),x.a.g.set(t,a,!r||r.ja&&!r.ja()?e:r)}},x.m.Ta.template=function(e){return 1==(e=x.m.ac(e)).length&&e[0].unknown||x.m.Id(e,"name")?null:"This template engine does not support anonymous templates nested within its templates"},x.h.ea.template=!0}(),x.b("setTemplateEngine",x.gc),x.b("renderTemplate",x.dc),x.a.Kc=function(e,t,i){var n,r,o,s,a;if(e.length&&t.length)for(n=r=0;(!i||n<i)&&(s=e[r]);++r){for(o=0;a=t[o];++o)if(s.value===a.value){s.moved=a.index,a.moved=s.index,t.splice(o,1),n=o=0;break}n+=o}},x.a.Qb=function(){function e(e,t,i,n,r){var o,s,a,l,h,u=Math.min,c=Math.max,d=[],p=e.length,f=t.length,g=f-p||1,m=p+f+1;for(o=0;o<=p;o++)for(l=a,d.push(a=[]),h=u(f,o+g),s=c(0,o-1);s<=h;s++)a[s]=s?o?e[o-1]===t[s-1]?l[s-1]:u(l[s]||m,a[s-1]||m)+1:s+1:o+1;for(u=[],c=[],g=[],o=p,s=f;o||s;)f=d[o][s]-1,s&&f===d[o][s-1]?c.push(u[u.length]={status:i,value:t[--s],index:s}):o&&f===d[o-1][s]?g.push(u[u.length]={status:n,value:e[--o],index:o}):(--s,--o,r.sparse||u.push({status:"retained",value:t[s]}));return x.a.Kc(g,c,!r.dontLimitMoves&&10*p),u.reverse()}return function(t,i,n){return n="boolean"==typeof n?{dontLimitMoves:n}:n||{},i=i||[],(t=t||[]).length<i.length?e(t,i,"added","deleted",n):e(i,t,"deleted","added",n)}}(),x.b("utils.compareArrays",x.a.Qb),function(){function t(t,i,n,r,o){var s=[],a=x.$(function(){var e=i(n,o,x.a.Wa(s,t))||[];0<s.length&&(x.a.Xc(s,e),r&&x.u.G(r,null,[n,e,o])),s.length=0,x.a.Ob(s,e)},null,{l:t,Ua:function(){return!x.a.kd(s)}});return{Y:s,$:a.ja()?a:e}}var i=x.a.g.Z(),n=x.a.g.Z();x.a.ec=function(r,o,s,a,l,h){function u(e){p={Ba:e,Ha:x.va(S++)},b.push(p),y||(T[S-1]=p)}function c(e){p=v[e],S!==p.Ha.v()&&(E[p.Ha.v()]=p,N[S]=p),p.Ha(S++),x.a.Wa(p.Y,r),b.push(p)}function d(e,t){if(e)for(var i=0,n=t.length;i<n;i++)t[i]&&x.a.D(t[i].Y,function(n){e(n,i,t[i].Ba)})}void 0===(o=o||[]).length&&(o=[o]),a=a||{};var p,f,g,m,v=x.a.g.get(r,i),y=!v,b=[],w=0,S=0,C=[],k=[],P=[],E=[],N=[],T=[],I=0;if(y)x.a.D(o,u);else{if(!h||v&&v._countWaitingForRemove){var A=x.a.Nb(v,function(e){return e.Ba});h=x.a.Qb(A,o,{dontLimitMoves:a.dontLimitMoves,sparse:!0})}var F,R,O;for(A=0;F=h[A];A++)switch(R=F.moved,O=F.index,F.status){case"deleted":for(;w<O;)c(w++);R===e&&((p=v[w]).$&&(p.$.s(),p.$=e),x.a.Wa(p.Y,r).length&&(a.beforeRemove&&(b.push(p),I++,p.Ba===n?p=null:P[p.Ha.v()]=p),p&&C.push.apply(C,p.Y))),w++;break;case"added":for(;S<O;)c(w++);R!==e?(k.push(b.length),c(R)):u(F.value)}for(;S<o.length;)c(w++);b._countWaitingForRemove=I}x.a.g.set(r,i,b),d(a.beforeMove,E),x.a.D(C,a.beforeRemove?x.pa:x.removeNode);try{m=r.ownerDocument.activeElement}catch(e){}if(k.length)for(;(A=k.shift())!=e;){for(p=b[A],f=e;A;)if((g=b[--A].Y)&&g.length){f=g[g.length-1];break}for(o=0;w=p.Y[o];f=w,o++)x.h.Xb(r,w,f)}for(A=0;p=b[A];A++){for(p.Y||x.a.extend(p,t(r,s,p.Ba,l,p.Ha)),o=0;w=p.Y[o];f=w,o++)x.h.Xb(r,w,f);!p.Ed&&l&&(l(p.Ba,p.Y,p.Ha),p.Ed=!0,f=p.Y[p.Y.length-1])}for(m&&r.ownerDocument.activeElement!=m&&"function"==typeof m.focus&&m.focus(),d(a.beforeRemove,P),A=0;A<P.length;++A)P[A]&&(P[A].Ba=n);d(a.afterMove,N),d(a.afterAdd,T)}}(),x.b("utils.setDomNodeChildrenFromArrayMapping",x.a.ec),x.ba=function(){this.allowTemplateRewriting=!1},x.ba.prototype=new x.ca,x.ba.prototype.constructor=x.ba,x.ba.prototype.renderTemplateSource=function(e,t,i,n){return(t=9>x.a.W||!e.nodes?null:e.nodes())?x.a.la(t.cloneNode(!0).childNodes):(e=e.text(),x.a.wa(e,n))},x.ba.Oa=new x.ba,x.gc(x.ba.Oa),x.b("nativeTemplateEngine",x.ba),function(){x.bb=function(){var e=this.Hd=function(){if(!s||!s.tmpl)return 0;try{if(0<=s.tmpl.tag.tmpl.open.toString().indexOf("__"))return 2}catch(e){}return 1}();this.renderTemplateSource=function(t,n,r,o){if(o=o||i,r=r||{},2>e)throw Error("Your version of jQuery.tmpl is too old. Please upgrade to jQuery.tmpl 1.0.0pre or later.");var a=t.data("precompiled");return a||(a=t.text()||"",a=s.template(null,"{{ko_with $item.koBindingContext}}"+a+"{{/ko_with}}"),t.data("precompiled",a)),t=[n.$data],n=s.extend({koBindingContext:n},r.templateOptions),(n=s.tmpl(a,t,n)).appendTo(o.createElement("div")),s.fragments={},n},this.createJavaScriptEvaluatorBlock=function(e){return"{{ko_code ((function() { return "+e+" })()) }}"},this.addTemplate=function(e,t){i.write("<script type='text/html' id='"+e+"'>"+t+"<\/script>")},0<e&&(s.tmpl.tag.ko_code={open:"__.push($1 || '');"},s.tmpl.tag.ko_with={open:"with($1) {",close:"} "})},x.bb.prototype=new x.ca,x.bb.prototype.constructor=x.bb;var e=new x.bb;0<e.Hd&&x.gc(e),x.b("jqueryTmplTemplateEngine",x.bb)}()})}()),n.exports),a=t(s);function l(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var h,u={exports:{}};var c,d,p=(h||(h=1,function(e){e.exports=function e(t,i,n){function r(s,a){if(!i[s]){if(!t[s]){if(!a&&l)return l(s);if(o)return o(s,!0);var h=new Error("Cannot find module '"+s+"'");throw h.code="MODULE_NOT_FOUND",h}var u=i[s]={exports:{}};t[s][0].call(u.exports,function(e){var i=t[s][1][e];return r(i||e)},u,u.exports,e,t,i,n)}return i[s].exports}for(var o=l,s=0;s<n.length;s++)r(n[s]);return r}({1:[function(e,t,i){!function(){var i,n,r;i=void 0!==e?e("i18next"):window.i18n;var o={init:function(e,t,i,r,a){n.utils.domNodeDisposal.addDisposeCallback(e,function(){var t=s._koElements.indexOf(e);t>=0&&(s._koElements.splice(t,1),s._koCallbacks.splice(t,1))}),s._koElements.push(e),s._koCallbacks.push(n.bindingHandlers.i18n.update.bind(void 0,e,t,i,r,a)),o.update(e,t,i,r,a)},update:function(e,t,r,o,s){var a=n.toJS(t());if("string"==typeof a)e.innerHTML=i.t(a);else if(a.key)e.innerHTML=i.t(a.key,a.options);else for(var l in a){var h,u=a[l];if(h="string"==typeof u?i.t(u):i.t(u.key,n.toJS(u.options)),"html"==l)e.innerHTML=h;else{var c=document.createElement("div");c.innerHTML=h,e.setAttribute(l,c.innerText)}}}},s={_koElements:[],_koCallbacks:[],setLanguage:function(e){i.setLng(e),s._language(e),s._koCallbacks.forEach(function(e){return e.call(void 0)}),void 0!==r&&void 0!==r.fn.i18n&&r("html").i18n()},init:function(e,t,a,l){n=a||window.ko,r=l||window.$,i.init({compatibilityAPI:"v1",lng:t||"en",resStore:e}),n.bindingHandlers.i18n=o,s._language=n.observable(t),s.setLanguage(t)},t:function(){var e=arguments;return n.computed(function(){return s._language(),i.t.apply(i,e)})},i18n:i};void 0!==t?t.exports=s:window.i18nextko=s}()},{i18next:17}],2:[function(e,t,i){Object.defineProperty(i,"__esModule",{value:!0});var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e},r=function(){function e(e,t){var i=[],n=!0,r=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(n=(s=a.next()).done)&&(i.push(s.value),!t||i.length!==t);n=!0);}catch(e){r=!0,o=e}finally{try{!n&&a.return&&a.return()}finally{if(r)throw o}}return i}return function(t,i){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),o=l(e("./utils")),s=a(e("./logger"));function a(e){return e&&e.__esModule?e:{default:e}}function l(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t.default=e,t}function h(e,t){for(var i=Object.getOwnPropertyNames(t),n=0;n<i.length;n++){var r=i[n],o=Object.getOwnPropertyDescriptor(t,r);o&&o.configurable&&void 0===e[r]&&Object.defineProperty(e,r,o)}return e}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function d(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):h(e,t))}function p(e,t){for(var i=e.indexOf(t);-1!==i;)e.splice(i,1),i=e.indexOf(t)}var f=function(e){function t(i,n,r){var o=arguments.length<=3||void 0===arguments[3]?{}:arguments[3];u(this,t);var a=c(this,e.call(this));return a.backend=i,a.store=n,a.services=r,a.options=o,a.logger=s.default.create("backendConnector"),a.state={},a.queue=[],a.backend&&a.backend.init&&a.backend.init(r,o.backend,o),a}return d(t,e),t.prototype.queueLoad=function(e,t,i){var n=this,r=[],o=[],s=[],a=[];return e.forEach(function(e){var i=!0;t.forEach(function(t){var s=e+"|"+t;n.store.hasResourceBundle(e,t)?n.state[s]=2:n.state[s]<0||(1===n.state[s]?o.indexOf(s)<0&&o.push(s):(n.state[s]=1,i=!1,o.indexOf(s)<0&&o.push(s),r.indexOf(s)<0&&r.push(s),a.indexOf(t)<0&&a.push(t)))}),i||s.push(e)}),(r.length||o.length)&&this.queue.push({pending:o,loaded:{},errors:[],callback:i}),{toLoad:r,pending:o,toLoadLanguages:s,toLoadNamespaces:a}},t.prototype.loaded=function(e,t,i){var n=this,s=e.split("|"),a=r(s,2),l=a[0],h=a[1];t&&this.emit("failedLoading",l,h,t),i&&this.store.addResourceBundle(l,h,i),this.state[e]=t?-1:2,this.queue.forEach(function(i){o.pushPath(i.loaded,[l],h),p(i.pending,e),t&&i.errors.push(t),0!==i.pending.length||i.done||(i.errors.length?i.callback(i.errors):i.callback(),n.emit("loaded",i.loaded),i.done=!0)}),this.queue=this.queue.filter(function(e){return!e.done})},t.prototype.read=function(e,t,i,n,r,o){var s=this;if(n||(n=0),r||(r=250),!e.length)return o(null,{});this.backend[i](e,t,function(a,l){a&&l&&n<5?setTimeout(function(){s.read.call(s,e,t,i,++n,2*r,o)},r):o(a,l)})},t.prototype.load=function(e,t,i){var s=this;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();var a=n({},this.backend.options,this.options.backend);"string"==typeof e&&(e=this.services.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]);var l,h=this.queueLoad(e,t,i);h.toLoad.length?a.allowMultiLoading&&this.backend.readMulti?this.read(h.toLoadLanguages,h.toLoadNamespaces,"readMulti",null,null,function(e,t){e&&s.logger.warn("loading namespaces "+h.toLoadNamespaces.join(", ")+" for languages "+h.toLoadLanguages.join(", ")+" via multiloading failed",e),!e&&t&&s.logger.log("loaded namespaces "+h.toLoadNamespaces.join(", ")+" for languages "+h.toLoadLanguages.join(", ")+" via multiloading",t),h.toLoad.forEach(function(i){var n=i.split("|"),a=r(n,2),l=a[0],h=a[1],u=o.getPath(t,[l,h]);if(u)s.loaded(i,e,u);else{var c="loading namespace "+h+" for language "+l+" via multiloading failed";s.loaded(i,c),s.logger.error(c)}})}):(l=function(e){var t=this,i=e.split("|"),n=r(i,2),o=n[0],s=n[1];this.read(o,s,"read",null,null,function(i,n){i&&t.logger.warn("loading namespace "+s+" for language "+o+" failed",i),!i&&n&&t.logger.log("loaded namespace "+s+" for language "+o,n),t.loaded(e,i,n)})},h.toLoad.forEach(function(e){l.call(s,e)})):h.pending.length||i()},t.prototype.reload=function(e,t){var i=this;this.backend||this.logger.warn("No backend was added via i18next.use. Will not load resources.");var s,a=n({},this.backend.options,this.options.backend);"string"==typeof e&&(e=this.services.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]),a.allowMultiLoading&&this.backend.readMulti?this.read(e,t,"readMulti",null,null,function(n,r){n&&i.logger.warn("reloading namespaces "+t.join(", ")+" for languages "+e.join(", ")+" via multiloading failed",n),!n&&r&&i.logger.log("reloaded namespaces "+t.join(", ")+" for languages "+e.join(", ")+" via multiloading",r),e.forEach(function(e){t.forEach(function(t){var s=o.getPath(r,[e,t]);if(s)i.loaded(e+"|"+t,n,s);else{var a="reloading namespace "+t+" for language "+e+" via multiloading failed";i.loaded(e+"|"+t,a),i.logger.error(a)}})})}):(s=function(e){var t=this,i=e.split("|"),n=r(i,2),o=n[0],s=n[1];this.read(o,s,"read",null,null,function(i,n){i&&t.logger.warn("reloading namespace "+s+" for language "+o+" failed",i),!i&&n&&t.logger.log("reloaded namespace "+s+" for language "+o,n),t.loaded(e,i,n)})},e.forEach(function(e){t.forEach(function(t){s.call(i,e+"|"+t)})}))},t.prototype.saveMissing=function(e,t,i,n){this.backend&&this.backend.create&&this.backend.create(e,t,i,n),e&&e[0]&&this.store.addResource(e[0],t,i,n)},t}(a(e("./EventEmitter")).default);i.default=f},{"./EventEmitter":4,"./logger":14,"./utils":16}],3:[function(e,t,i){Object.defineProperty(i,"__esModule",{value:!0});var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e};s(e("./utils"));var r=o(e("./logger"));function o(e){return e&&e.__esModule?e:{default:e}}function s(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t.default=e,t}function a(e,t){for(var i=Object.getOwnPropertyNames(t),n=0;n<i.length;n++){var r=i[n],o=Object.getOwnPropertyDescriptor(t,r);o&&o.configurable&&void 0===e[r]&&Object.defineProperty(e,r,o)}return e}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function h(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):a(e,t))}var c=function(e){function t(i,n,o){var s=arguments.length<=3||void 0===arguments[3]?{}:arguments[3];l(this,t);var a=h(this,e.call(this));return a.cache=i,a.store=n,a.services=o,a.options=s,a.logger=r.default.create("cacheConnector"),a.cache&&a.cache.init&&a.cache.init(o,s.cache,s),a}return u(t,e),t.prototype.load=function(e,t,i){var r=this;if(!this.cache)return i&&i();var o=n({},this.cache.options,this.options.cache);"string"==typeof e&&(e=this.services.languageUtils.toResolveHierarchy(e)),o.enabled?this.cache.load(e,function(t,n){if(t&&r.logger.error("loading languages "+e.join(", ")+" from cache failed",t),n)for(var o in n)for(var s in n[o])if("i18nStamp"!==s){var a=n[o][s];a&&r.store.addResourceBundle(o,s,a)}i&&i()}):i&&i()},t.prototype.save=function(){this.cache&&this.options.cache&&this.options.cache.enabled&&this.cache.save(this.store.data)},t}(o(e("./EventEmitter")).default);i.default=c},{"./EventEmitter":4,"./logger":14,"./utils":16}],4:[function(e,t,i){function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(){n(this,e),this.observers={}}return e.prototype.on=function(e,t){var i=this;e.split(" ").forEach(function(e){i.observers[e]=i.observers[e]||[],i.observers[e].push(t)})},e.prototype.off=function(e,t){var i=this;this.observers[e]&&this.observers[e].forEach(function(){if(t){var n=i.observers[e].indexOf(t);n>-1&&i.observers[e].splice(n,1)}else delete i.observers[e]})},e.prototype.emit=function(e){for(var t=arguments.length,i=Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];this.observers[e]&&this.observers[e].forEach(function(e){e.apply(void 0,i)}),this.observers["*"]&&this.observers["*"].forEach(function(t){var n;t.apply(t,(n=[e]).concat.apply(n,i))})},e}();i.default=r},{}],5:[function(e,t,i){Object.defineProperty(i,"__esModule",{value:!0});var n=s(e("./utils")),r=o(e("./logger"));function o(e){return e&&e.__esModule?e:{default:e}}function s(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t.default=e,t}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var l=function(){function e(){var t=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];a(this,e),this.logger=r.default.create("interpolator"),this.init(t,!0)}return e.prototype.init=function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];arguments[1]&&(this.options=e,this.format=e.interpolation&&e.interpolation.format||function(e){return e}),e.interpolation||(e.interpolation={escapeValue:!0});var t=e.interpolation;this.escapeValue=t.escapeValue,this.prefix=t.prefix?n.regexEscape(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?n.regexEscape(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?n.regexEscape(t.formatSeparator):t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?n.regexEscape(t.nestingPrefix):t.nestingPrefixEscaped||n.regexEscape("$t("),this.nestingSuffix=t.nestingSuffix?n.regexEscape(t.nestingSuffix):t.nestingSuffixEscaped||n.regexEscape(")"),this.resetRegExp()},e.prototype.reset=function(){this.options&&this.init(this.options)},e.prototype.resetRegExp=function(){var e=this.prefix+"(.+?)"+this.suffix;this.regexp=new RegExp(e,"g");var t=this.prefix+this.unescapePrefix+"(.+?)"+this.unescapeSuffix+this.suffix;this.regexpUnescape=new RegExp(t,"g");var i=this.nestingPrefix+"(.+?)"+this.nestingSuffix;this.nestingRegexp=new RegExp(i,"g")},e.prototype.interpolate=function(e,t,i){var r=this,o=void 0,s=void 0;function a(e){return e.replace(/\$/g,"$$$$")}var l=function(e){if(e.indexOf(r.formatSeparator)<0)return n.getPath(t,e);var o=e.split(r.formatSeparator),s=o.shift().trim(),a=o.join(r.formatSeparator).trim();return r.format(n.getPath(t,s),a,i)};for(this.resetRegExp();o=this.regexpUnescape.exec(e);){var h=l(o[1].trim());e=e.replace(o[0],h),this.regexpUnescape.lastIndex=0}for(;o=this.regexp.exec(e);)"string"!=typeof(s=l(o[1].trim()))&&(s=n.makeString(s)),s||(this.logger.warn("missed to pass in variable "+o[1]+" for interpolating "+e),s=""),s=this.escapeValue?a(n.escape(s)):a(s),e=e.replace(o[0],s),this.regexp.lastIndex=0;return e},e.prototype.nest=function(e,t){var i=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],r=void 0,o=void 0,s=JSON.parse(JSON.stringify(i));function a(e){return e.replace(/\$/g,"$$$$")}function l(e){if(e.indexOf(",")<0)return e;var t=e.split(",");e=t.shift();var i=t.join(",");i=this.interpolate(i,s);try{s=JSON.parse(i)}catch(t){this.logger.error("failed parsing options string in nesting for key "+e,t)}return e}for(s.applyPostProcessor=!1;r=this.nestingRegexp.exec(e);)"string"!=typeof(o=t(l.call(this,r[1].trim()),s))&&(o=n.makeString(o)),o||(this.logger.warn("missed to pass in variable "+r[1]+" for interpolating "+e),o=""),o=this.escapeValue?a(n.escape(o)):a(o),e=e.replace(r[0],o),this.regexp.lastIndex=0;return e},e}();i.default=l},{"./logger":14,"./utils":16}],6:[function(e,t,i){Object.defineProperty(i,"__esModule",{value:!0});var n=r(e("./logger"));function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e){return e.charAt(0).toUpperCase()+e.slice(1)}var a=function(){function e(t){o(this,e),this.options=t,this.whitelist=this.options.whitelist||!1,this.logger=n.default.create("languageUtils")}return e.prototype.getLanguagePartFromCode=function(e){if(e.indexOf("-")<0)return e;var t=["NB-NO","NN-NO","nb-NO","nn-NO","nb-no","nn-no"],i=e.split("-");return this.formatLanguageCode(t.indexOf(e)>-1?i[1].toLowerCase():i[0])},e.prototype.formatLanguageCode=function(e){if("string"==typeof e&&e.indexOf("-")>-1){var t=["hans","hant","latn","cyrl","cans","mong","arab"],i=e.split("-");return this.options.lowerCaseLng?i=i.map(function(e){return e.toLowerCase()}):2===i.length?(i[0]=i[0].toLowerCase(),i[1]=i[1].toUpperCase(),t.indexOf(i[1].toLowerCase())>-1&&(i[1]=s(i[1].toLowerCase()))):3===i.length&&(i[0]=i[0].toLowerCase(),2===i[1].length&&(i[1]=i[1].toUpperCase()),"sgn"!==i[0]&&2===i[2].length&&(i[2]=i[2].toUpperCase()),t.indexOf(i[1].toLowerCase())>-1&&(i[1]=s(i[1].toLowerCase())),t.indexOf(i[2].toLowerCase())>-1&&(i[2]=s(i[2].toLowerCase()))),i.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e},e.prototype.isWhitelisted=function(e,t){return("languageOnly"===this.options.load||this.options.nonExplicitWhitelist&&!t)&&(e=this.getLanguagePartFromCode(e)),!this.whitelist||!this.whitelist.length||this.whitelist.indexOf(e)>-1},e.prototype.toResolveHierarchy=function(e,t){var i=this;"string"==typeof(t=t||this.options.fallbackLng||[])&&(t=[t]);var n=[],r=function(e){var t=!(arguments.length<=1||void 0===arguments[1])&&arguments[1];i.isWhitelisted(e,t)?n.push(e):i.logger.warn("rejecting non-whitelisted language code: "+e)};return"string"==typeof e&&e.indexOf("-")>-1?("languageOnly"!==this.options.load&&r(this.formatLanguageCode(e),!0),"currentOnly"!==this.options.load&&r(this.getLanguagePartFromCode(e))):"string"==typeof e&&r(this.formatLanguageCode(e)),t.forEach(function(e){n.indexOf(e)<0&&r(i.formatLanguageCode(e))}),n},e}();i.default=a},{"./logger":14}],7:[function(e,t,i){Object.defineProperty(i,"__esModule",{value:!0});var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},r=o(e("./logger"));function o(e){return e&&e.__esModule?e:{default:e}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var a=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","tg","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","es_ar","et","eu","fi","fo","fur","fy","gl","gu","ha","he","hi","hu","hy","ia","it","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt","pt_br","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","id","ja","jbo","ka","kk","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21}],l={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0===e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(1==e||e%10==1?0:1)},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0===e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0===e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0)}};function h(){var e={};return a.forEach(function(t){t.lngs.forEach(function(i){return e[i]={numbers:t.nr,plurals:l[t.fc]}})}),e}var u=function(){function e(t){var i=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];s(this,e),this.languageUtils=t,this.options=i,this.logger=r.default.create("pluralResolver"),this.rules=h()}return e.prototype.addRule=function(e,t){this.rules[e]=t},e.prototype.getRule=function(e){return this.rules[this.languageUtils.getLanguagePartFromCode(e)]},e.prototype.needsPlural=function(e){var t=this.getRule(e);return!(t&&t.numbers.length<=1)},e.prototype.getSuffix=function(e,t){var i=this,r=this.getRule(e);if(!r)return this.logger.warn("no plural rule found for: "+e),"";var o=function(){if(1===r.numbers.length)return{v:""};var e=r.noAbs?r.plurals(t):r.plurals(Math.abs(t)),n=r.numbers[e];2===r.numbers.length&&1===r.numbers[0]&&(2===n?n="plural":1===n&&(n=""));var o=function(){return i.options.prepend&&n.toString()?i.options.prepend+n.toString():n.toString()};return"v1"===i.options.compatibilityJSON?1===n?{v:""}:"number"==typeof n?{v:"_plural_"+n.toString()}:{v:o()}:"v2"===i.options.compatibilityJSON||2===r.numbers.length&&1===r.numbers[0]||2===r.numbers.length&&1===r.numbers[0]?{v:o()}:{v:i.options.prepend&&e.toString()?i.options.prepend+e.toString():e.toString()}}();return"object"===(void 0===o?"undefined":n(o))?o.v:void 0},e}();i.default=u},{"./logger":14}],8:[function(e,t,i){Object.defineProperty(i,"__esModule",{value:!0});var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e},r=a(e("./EventEmitter")),o=s(e("./utils"));function s(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t.default=e,t}function a(e){return e&&e.__esModule?e:{default:e}}function l(e,t){for(var i=Object.getOwnPropertyNames(t),n=0;n<i.length;n++){var r=i[n],o=Object.getOwnPropertyDescriptor(t,r);o&&o.configurable&&void 0===e[r]&&Object.defineProperty(e,r,o)}return e}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):l(e,t))}var d=function(e){function t(){var i=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],n=arguments.length<=1||void 0===arguments[1]?{ns:["translation"],defaultNS:"translation"}:arguments[1];h(this,t);var r=u(this,e.call(this));return r.data=i,r.options=n,r}return c(t,e),t.prototype.addNamespaces=function(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)},t.prototype.removeNamespaces=function(e){var t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)},t.prototype.getResource=function(e,t,i){var n=(arguments.length<=3||void 0===arguments[3]?{}:arguments[3]).keySeparator||this.options.keySeparator;void 0===n&&(n=".");var r=[e,t];return i&&"string"!=typeof i&&(r=r.concat(i)),i&&"string"==typeof i&&(r=r.concat(n?i.split(n):i)),e.indexOf(".")>-1&&(r=e.split(".")),o.getPath(this.data,r)},t.prototype.addResource=function(e,t,i,n){var r=arguments.length<=4||void 0===arguments[4]?{silent:!1}:arguments[4],s=this.options.keySeparator;void 0===s&&(s=".");var a=[e,t];i&&(a=a.concat(s?i.split(s):i)),e.indexOf(".")>-1&&(n=t,t=(a=e.split("."))[1]),this.addNamespaces(t),o.setPath(this.data,a,n),r.silent||this.emit("added",e,t,i,n)},t.prototype.addResources=function(e,t,i){for(var n in i)"string"==typeof i[n]&&this.addResource(e,t,n,i[n],{silent:!0});this.emit("added",e,t,i)},t.prototype.addResourceBundle=function(e,t,i,r,s){var a=[e,t];e.indexOf(".")>-1&&(r=i,i=t,t=(a=e.split("."))[1]),this.addNamespaces(t);var l=o.getPath(this.data,a)||{};r?o.deepExtend(l,i,s):l=n({},l,i),o.setPath(this.data,a,l),this.emit("added",e,t,i)},t.prototype.removeResourceBundle=function(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)},t.prototype.hasResourceBundle=function(e,t){return void 0!==this.getResource(e,t)},t.prototype.getResourceBundle=function(e,t){return t||(t=this.options.defaultNS),"v1"===this.options.compatibilityAPI?n({},this.getResource(e,t)):this.getResource(e,t)},t.prototype.toJSON=function(){return this.data},t}(r.default);i.default=d},{"./EventEmitter":4,"./utils":16}],9:[function(e,t,i){Object.defineProperty(i,"__esModule",{value:!0});var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e},r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},o=c(e("./logger")),s=c(e("./EventEmitter")),a=c(e("./postProcessor")),l=u(e("./compatibility/v1")),h=u(e("./utils"));function u(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t.default=e,t}function c(e){return e&&e.__esModule?e:{default:e}}function d(e,t){for(var i=Object.getOwnPropertyNames(t),n=0;n<i.length;n++){var r=i[n],o=Object.getOwnPropertyDescriptor(t,r);o&&o.configurable&&void 0===e[r]&&Object.defineProperty(e,r,o)}return e}function p(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function g(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):d(e,t))}var m=function(e){function t(i){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];p(this,t);var r=f(this,e.call(this));return h.copy(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector"],i,r),r.options=n,r.logger=o.default.create("translator"),r}return g(t,e),t.prototype.changeLanguage=function(e){e&&(this.language=e)},t.prototype.exists=function(e){var t=arguments.length<=1||void 0===arguments[1]?{interpolation:{}}:arguments[1];return"v1"===this.options.compatibilityAPI&&(t=l.convertTOptions(t)),void 0!==this.resolve(e,t)},t.prototype.extractFromKey=function(e,t){var i=t.nsSeparator||this.options.nsSeparator;void 0===i&&(i=":");var n=t.ns||this.options.defaultNS;if(i&&e.indexOf(i)>-1){var r=e.split(i);n=r[0],e=r[1]}return"string"==typeof n&&(n=[n]),{key:e,namespaces:n}},t.prototype.translate=function(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if("object"!==(void 0===t?"undefined":r(t))?t=this.options.overloadTranslationOptionHandler(arguments):"v1"===this.options.compatibilityAPI&&(t=l.convertTOptions(t)),null==e||""===e)return"";"number"==typeof e&&(e=String(e)),"string"==typeof e&&(e=[e]);var i=t.lng||this.language;if(i&&"cimode"===i.toLowerCase())return e[e.length-1];var o=t.keySeparator||this.options.keySeparator||".",s=this.extractFromKey(e[e.length-1],t),a=s.key,h=s.namespaces,u=h[h.length-1],c=this.resolve(e,t),d=Object.prototype.toString.apply(c),p=["[object Number]","[object Function]","[object RegExp]"],f=void 0!==t.joinArrays?t.joinArrays:this.options.joinArrays;if(c&&"string"!=typeof c&&p.indexOf(d)<0&&(!f||"[object Array]"!==d)){if(!t.returnObjects&&!this.options.returnObjects)return this.logger.warn("accessing an object - but returnObjects options is not enabled!"),this.options.returnedObjectHandler?this.options.returnedObjectHandler(a,c,t):"key '"+a+" ("+this.language+")' returned an object instead of string.";var g="[object Array]"===d?[]:{};for(var m in c)g[m]=this.translate(""+a+o+m,n({joinArrays:!1,ns:h},t));c=g}else if(f&&"[object Array]"===d)(c=c.join(f))&&(c=this.extendTranslation(c,a,t));else{var v=!1,y=!1;if(this.isValidLookup(c)||void 0===t.defaultValue||(v=!0,c=t.defaultValue),this.isValidLookup(c)||(y=!0,c=a),y||v){this.logger.log("missingKey",i,u,a,c);var b=[];if("fallback"===this.options.saveMissingTo&&this.options.fallbackLng&&this.options.fallbackLng[0])for(var w=0;w<this.options.fallbackLng.length;w++)b.push(this.options.fallbackLng[w]);else"all"===this.options.saveMissingTo?b=this.languageUtils.toResolveHierarchy(t.lng||this.language):b.push(t.lng||this.language);this.options.saveMissing&&(this.options.missingKeyHandler?this.options.missingKeyHandler(b,u,a,c):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(b,u,a,c)),this.emit("missingKey",b,u,a,c)}c=this.extendTranslation(c,a,t),y&&c===a&&this.options.appendNamespaceToMissingKey&&(c=u+":"+a),y&&this.options.parseMissingKeyHandler&&(c=this.options.parseMissingKeyHandler(c))}return c},t.prototype.extendTranslation=function(e,t,i){var r=this;i.interpolation&&this.interpolator.init(i);var o=i.replace&&"string"!=typeof i.replace?i.replace:i;this.options.interpolation.defaultVariables&&(o=n({},this.options.interpolation.defaultVariables,o)),e=this.interpolator.interpolate(e,o,this.language),e=this.interpolator.nest(e,function(){for(var e=arguments.length,t=Array(e),i=0;i<e;i++)t[i]=arguments[i];return r.translate.apply(r,t)},i),i.interpolation&&this.interpolator.reset();var s=i.postProcess||this.options.postProcess,l="string"==typeof s?[s]:s;return void 0!==e&&l&&l.length&&!1!==i.applyPostProcessor&&(e=a.default.handle(l,e,t,i,this)),e},t.prototype.resolve=function(e){var t=this,i=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],n=void 0;return"string"==typeof e&&(e=[e]),e.forEach(function(e){if(!t.isValidLookup(n)){var r=t.extractFromKey(e,i),o=r.key,s=r.namespaces;t.options.fallbackNS&&(s=s.concat(t.options.fallbackNS));var a=void 0!==i.count&&"string"!=typeof i.count,l=void 0!==i.context&&"string"==typeof i.context&&""!==i.context,h=i.lngs?i.lngs:t.languageUtils.toResolveHierarchy(i.lng||t.language);s.forEach(function(e){t.isValidLookup(n)||h.forEach(function(r){if(!t.isValidLookup(n)){var s=o,h=[s],u=void 0;a&&(u=t.pluralResolver.getSuffix(r,i.count)),a&&l&&h.push(s+u),l&&h.push(s+=""+t.options.contextSeparator+i.context),a&&h.push(s+=u);for(var c=void 0;c=h.pop();)t.isValidLookup(n)||(n=t.getResource(r,e,c,i))}})})}}),n},t.prototype.isValidLookup=function(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)},t.prototype.getResource=function(e,t,i){var n=arguments.length<=3||void 0===arguments[3]?{}:arguments[3];return this.resourceStore.getResource(e,t,i,n)},t}(s.default);i.default=m},{"./EventEmitter":4,"./compatibility/v1":10,"./logger":14,"./postProcessor":15,"./utils":16}],10:[function(e,t,i){Object.defineProperty(i,"__esModule",{value:!0}),i.convertAPIOptions=s,i.convertJSONOptions=a,i.convertTOptions=l,i.appendBackwardsAPI=h;var n=r(e("../logger"));function r(e){return e&&e.__esModule?e:{default:e}}function o(e){return e.interpolation={unescapeSuffix:"HTML"},e.interpolation.prefix=e.interpolationPrefix||"__",e.interpolation.suffix=e.interpolationSuffix||"__",e.interpolation.escapeValue=e.escapeInterpolation||!1,e.interpolation.nestingPrefix=e.reusePrefix||"$t(",e.interpolation.nestingSuffix=e.reuseSuffix||")",e}function s(e){return e.resStore&&(e.resources=e.resStore),e.ns&&e.ns.defaultNs?(e.defaultNS=e.ns.defaultNs,e.ns=e.ns.namespaces):e.defaultNS=e.ns||"translation",e.fallbackToDefaultNS&&e.defaultNS&&(e.fallbackNS=e.defaultNS),e.saveMissing=e.sendMissing,e.saveMissingTo=e.sendMissingTo||"current",e.returnNull=!e.fallbackOnNull,e.returnEmptyString=!e.fallbackOnEmpty,e.returnObjects=e.returnObjectTrees,e.joinArrays="\n",e.returnedObjectHandler=e.objectTreeKeyHandler,e.parseMissingKeyHandler=e.parseMissingKey,e.appendNamespaceToMissingKey=!0,e.nsSeparator=e.nsseparator,e.keySeparator=e.keyseparator,"sprintf"===e.shortcutFunction&&(e.overloadTranslationOptionHandler=function(e){for(var t=[],i=1;i<e.length;i++)t.push(e[i]);return{postProcess:"sprintf",sprintf:t}}),e.whitelist=e.lngWhitelist,e.preload=e.preload,"current"===e.load&&(e.load="currentOnly"),"unspecific"===e.load&&(e.load="languageOnly"),e.backend=e.backend||{},e.backend.loadPath=e.resGetPath||"locales/__lng__/__ns__.json",e.backend.addPath=e.resPostPath||"locales/add/__lng__/__ns__",e.backend.allowMultiLoading=e.dynamicLoad,e.cache=e.cache||{},e.cache.prefix="res_",e.cache.expirationTime=6048e5,e.cache.enabled=!!e.useLocalStorage,(e=o(e)).defaultVariables&&(e.interpolation.defaultVariables=e.defaultVariables),e}function a(e){return(e=o(e)).joinArrays="\n",e}function l(e){return(e.interpolationPrefix||e.interpolationSuffix||e.escapeInterpolation)&&(e=o(e)),e.nsSeparator=e.nsseparator,e.keySeparator=e.keyseparator,e.returnObjects=e.returnObjectTrees,e}function h(e){e.lng=function(){return n.default.deprecate("i18next.lng() can be replaced by i18next.language for detected language or i18next.languages for languages ordered by translation lookup."),e.services.languageUtils.toResolveHierarchy(e.language)[0]},e.preload=function(t,i){n.default.deprecate("i18next.preload() can be replaced with i18next.loadLanguages()"),e.loadLanguages(t,i)},e.setLng=function(t,i,r){if(n.default.deprecate("i18next.setLng() can be replaced with i18next.changeLanguage() or i18next.getFixedT() to get a translation function with fixed language or namespace."),"function"==typeof i&&(r=i,i={}),i||(i={}),!0===i.fixLng&&r)return r(null,e.getFixedT(t));e.changeLanguage(t,r)},e.addPostProcessor=function(t,i){n.default.deprecate("i18next.addPostProcessor() can be replaced by i18next.use({ type: 'postProcessor', name: 'name', process: fc })"),e.use({type:"postProcessor",name:t,process:i})}}},{"../logger":14}],11:[function(e,t,i){function n(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,whitelist:!1,nonExplicitWhitelist:!1,load:"all",preload:!1,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",saveMissing:!1,saveMissingTo:"fallback",missingKeyHandler:!1,postProcess:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:function(){},parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,overloadTranslationOptionHandler:function(e){return{defaultValue:e[1]}},interpolation:{escapeValue:!0,format:function(e,t,i){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",defaultVariables:void 0}}}function r(e){return"string"==typeof e.ns&&(e.ns=[e.ns]),"string"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),"string"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.whitelist&&e.whitelist.indexOf("cimode")<0&&e.whitelist.push("cimode"),e}Object.defineProperty(i,"__esModule",{value:!0}),i.get=n,i.transformOptions=r},{}],12:[function(e,t,i){Object.defineProperty(i,"__esModule",{value:!0});var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e},o=y(e("./logger")),s=y(e("./EventEmitter")),a=y(e("./ResourceStore")),l=y(e("./Translator")),h=y(e("./LanguageUtils")),u=y(e("./PluralResolver")),c=y(e("./Interpolator")),d=y(e("./BackendConnector")),p=y(e("./CacheConnector")),f=e("./defaults"),g=y(e("./postProcessor")),m=v(e("./compatibility/v1"));function v(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t.default=e,t}function y(e){return e&&e.__esModule?e:{default:e}}function b(e,t){for(var i=Object.getOwnPropertyNames(t),n=0;n<i.length;n++){var r=i[n],o=Object.getOwnPropertyDescriptor(t,r);o&&o.configurable&&void 0===e[r]&&Object.defineProperty(e,r,o)}return e}function w(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function x(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function S(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):b(e,t))}var C=function(e){function t(){var i=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],n=arguments[1];w(this,t);var r=x(this,e.call(this));return r.options=(0,f.transformOptions)(i),r.services={},r.logger=o.default,r.modules={},n&&!r.isInitialized&&r.init(i,n),r}return S(t,e),t.prototype.init=function(e,t){var i=this;function n(e){if(e)return"function"==typeof e?new e:e}if("function"==typeof e&&(t=e,e={}),e||(e={}),"v1"===e.compatibilityAPI?this.options=r({},(0,f.get)(),(0,f.transformOptions)(m.convertAPIOptions(e)),{}):"v1"===e.compatibilityJSON?this.options=r({},(0,f.get)(),(0,f.transformOptions)(m.convertJSONOptions(e)),{}):this.options=r({},(0,f.get)(),this.options,(0,f.transformOptions)(e)),t||(t=function(){}),!this.options.isClone){this.modules.logger?o.default.init(n(this.modules.logger),this.options):o.default.init(null,this.options);var s=new h.default(this.options);this.store=new a.default(this.options.resources,this.options);var g=this.services;g.logger=o.default,g.resourceStore=this.store,g.resourceStore.on("added removed",function(e,t){g.cacheConnector.save()}),g.languageUtils=s,g.pluralResolver=new u.default(s,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON}),g.interpolator=new c.default(this.options),g.backendConnector=new d.default(n(this.modules.backend),g.resourceStore,g,this.options),g.backendConnector.on("*",function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];i.emit.apply(i,[e].concat(n))}),g.backendConnector.on("loaded",function(e){g.cacheConnector.save()}),g.cacheConnector=new p.default(n(this.modules.cache),g.resourceStore,g,this.options),g.cacheConnector.on("*",function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];i.emit.apply(i,[e].concat(n))}),this.modules.languageDetector&&(g.languageDetector=n(this.modules.languageDetector),g.languageDetector.init(g,this.options.detection,this.options)),this.translator=new l.default(this.services,this.options),this.translator.on("*",function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];i.emit.apply(i,[e].concat(n))})}["getResource","addResource","addResources","addResourceBundle","removeResourceBundle","hasResourceBundle","getResourceBundle"].forEach(function(e){i[e]=function(){return this.store[e].apply(this.store,arguments)}}),"v1"===this.options.compatibilityAPI&&m.appendBackwardsAPI(this);var v=function(){i.changeLanguage(i.options.lng,function(e,n){i.emit("initialized",i.options),i.logger.log("initialized",i.options),t(e,n)})};return this.options.resources||!this.options.initImmediate?v():setTimeout(v,0),this},t.prototype.loadResources=function(e){var t=this;if(e||(e=function(){}),this.options.resources)e(null);else{var i=function(){if(t.language&&"cimode"===t.language.toLowerCase())return{v:e()};var i=[],n=function(e){t.services.languageUtils.toResolveHierarchy(e).forEach(function(e){i.indexOf(e)<0&&i.push(e)})};n(t.language),t.options.preload&&t.options.preload.forEach(function(e){n(e)}),t.services.cacheConnector.load(i,t.options.ns,function(){t.services.backendConnector.load(i,t.options.ns,e)})}();if("object"===(void 0===i?"undefined":n(i)))return i.v}},t.prototype.reloadResources=function(e,t){e||(e=this.languages),t||(t=this.options.ns),this.services.backendConnector.reload(e,t)},t.prototype.use=function(e){return"backend"===e.type&&(this.modules.backend=e),"cache"===e.type&&(this.modules.cache=e),("logger"===e.type||e.log&&e.warn&&e.warn)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"postProcessor"===e.type&&g.default.addPostProcessor(e),this},t.prototype.changeLanguage=function(e,t){var i=this,n=function(n){e&&(i.emit("languageChanged",e),i.logger.log("languageChanged",e)),t&&t(n,function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return i.t.apply(i,t)})};!e&&this.services.languageDetector&&(e=this.services.languageDetector.detect()),e&&(this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.translator.changeLanguage(e),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage(e)),this.loadResources(function(e){n(e)})},t.prototype.getFixedT=function(e,t){var i=this,n=function e(t,n){return(n=n||{}).lng=n.lng||e.lng,n.ns=n.ns||e.ns,i.t(t,n)};return n.lng=e,n.ns=t,n},t.prototype.t=function(){return this.translator&&this.translator.translate.apply(this.translator,arguments)},t.prototype.exists=function(){return this.translator&&this.translator.exists.apply(this.translator,arguments)},t.prototype.setDefaultNamespace=function(e){this.options.defaultNS=e},t.prototype.loadNamespaces=function(e,t){var i=this;if(!this.options.ns)return t&&t();"string"==typeof e&&(e=[e]),e.forEach(function(e){i.options.ns.indexOf(e)<0&&i.options.ns.push(e)}),this.loadResources(t)},t.prototype.loadLanguages=function(e,t){"string"==typeof e&&(e=[e]);var i=this.options.preload||[],n=e.filter(function(e){return i.indexOf(e)<0});if(!n.length)return t();this.options.preload=i.concat(n),this.loadResources(t)},t.prototype.dir=function(e){return e||(e=this.language),e?["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam"].indexOf(this.services.languageUtils.getLanguagePartFromCode(e))>=0?"rtl":"ltr":"rtl"},t.prototype.createInstance=function(){return new t(arguments.length<=0||void 0===arguments[0]?{}:arguments[0],arguments[1])},t.prototype.cloneInstance=function(){var e=this,i=arguments[1],n=new t(r({},arguments.length<=0||void 0===arguments[0]?{}:arguments[0],this.options,{isClone:!0}),i);return["store","translator","services","language"].forEach(function(t){n[t]=e[t]}),n},t}(s.default);i.default=new C},{"./BackendConnector":2,"./CacheConnector":3,"./EventEmitter":4,"./Interpolator":5,"./LanguageUtils":6,"./PluralResolver":7,"./ResourceStore":8,"./Translator":9,"./compatibility/v1":10,"./defaults":11,"./logger":14,"./postProcessor":15}],13:[function(e,t,i){Object.defineProperty(i,"__esModule",{value:!0});var n=r(e("./i18next"));function r(e){return e&&e.__esModule?e:{default:e}}i.default=n.default},{"./i18next":12}],14:[function(e,t,i){Object.defineProperty(i,"__esModule",{value:!0});var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e};function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o={type:"logger",log:function(e){this._output("log",e)},warn:function(e){this._output("warn",e)},error:function(e){this._output("error",e)},_output:function(e,t){console&&console[e]&&console[e].apply(console,Array.prototype.slice.call(t))}},s=function(){function e(t){var i=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];r(this,e),this.subs=[],this.init(t,i)}return e.prototype.init=function(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];this.prefix=t.prefix||"i18next:",this.logger=e||o,this.options=t,this.debug=!1!==t.debug},e.prototype.setDebug=function(e){this.debug=e,this.subs.forEach(function(t){t.setDebug(e)})},e.prototype.log=function(){this.forward(arguments,"log","",!0)},e.prototype.warn=function(){this.forward(arguments,"warn","",!0)},e.prototype.error=function(){this.forward(arguments,"error","")},e.prototype.deprecate=function(){this.forward(arguments,"warn","WARNING DEPRECATED: ",!0)},e.prototype.forward=function(e,t,i,n){n&&!this.debug||("string"==typeof e[0]&&(e[0]=i+this.prefix+" "+e[0]),this.logger[t](e))},e.prototype.create=function(t){var i=new e(this.logger,n({prefix:this.prefix+":"+t+":"},this.options));return this.subs.push(i),i},e}();i.default=new s},{}],15:[function(e,t,i){Object.defineProperty(i,"__esModule",{value:!0}),i.default={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,i,n,r){var o=this;return e.forEach(function(e){o.processors[e]&&(t=o.processors[e].process(t,i,n,r))}),t}}},{}],16:[function(e,t,i){function n(e){return null==e?"":""+e}function r(e,t,i){e.forEach(function(e){t[e]&&(i[e]=t[e])})}function o(e,t,i){function n(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}for(var r="string"!=typeof t?[].concat(t):t.split(".");r.length>1;){if(!e)return{};var o=n(r.shift());!e[o]&&i&&(e[o]=new i),e=e[o]}return e?{obj:e,k:n(r.shift())}:{}}function s(e,t,i){var n=o(e,t,Object);n.obj[n.k]=i}function a(e,t,i,n){var r=o(e,t,Object),s=r.obj,a=r.k;s[a]=s[a]||[],n&&(s[a]=s[a].concat(i)),n||s[a].push(i)}function l(e,t){var i=o(e,t),n=i.obj,r=i.k;if(n)return n[r]}function h(e,t,i){for(var n in t)n in e?"string"==typeof e[n]||e[n]instanceof String||"string"==typeof t[n]||t[n]instanceof String?i&&(e[n]=t[n]):h(e[n],t[n],i):e[n]=t[n];return e}function u(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}Object.defineProperty(i,"__esModule",{value:!0}),i.makeString=n,i.copy=r,i.setPath=s,i.pushPath=a,i.getPath=l,i.deepExtend=h,i.regexEscape=u,i.escape=d;var c={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};function d(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,function(e){return c[e]}):e}},{}],17:[function(e,t,i){t.exports=e("./dist/commonjs/index.js").default},{"./dist/commonjs/index.js":13}]},{},[1])(1)}(u)),u.exports),f=t(p);var g,m=function(){if(d)return c;d=1;var e,t=Object.create,i=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,a=e=>{throw TypeError(e)},l=(e,t,o,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let l of r(t))!s.call(e,l)&&l!==o&&i(e,l,{get:()=>t[l],enumerable:!(a=n(t,l))||a.enumerable});return e},h=(e,t,n)=>((e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n),u=(e,t,i)=>t.has(e)||a("Cannot "+i),p=(e,t,i)=>(u(e,t,"read from private field"),i?i.call(e):t.get(e)),f=(e,t,i)=>t.has(e)?a("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),g=(e,t,i,n)=>(u(e,t,"write to private field"),n?n.call(e,i):t.set(e,i),i),m=(e,t,i)=>(u(e,t,"access private method"),i),v=((e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(e){throw t=0,e}})((e,t)=>{var i=-1;function n(e,t,f,g,m){if(e===t)return e?[[0,e]]:[];if(null!=f){var v=function(e,t,i){var n="number"==typeof i?{index:i,length:0}:i.oldRange,r="number"==typeof i?null:i.newRange,o=e.length,s=t.length;if(0===n.length&&(null===r||0===r.length)){var a=n.index,l=e.slice(0,a),h=e.slice(a),u=r?r.index:null,c=a+s-o;if(!(null!==u&&u!==c||c<0||c>s)){var d=t.slice(0,c);if((g=t.slice(c))===h){var p=Math.min(a,c);if((v=l.slice(0,p))===(w=d.slice(0,p)))return y(v,l.slice(p),d.slice(p),h)}}if(null===u||u===a){var f=a,g=(d=t.slice(0,f),t.slice(f));if(d===l){var m=Math.min(o-f,s-f);if((b=h.slice(h.length-m))===(x=g.slice(g.length-m)))return y(l,h.slice(0,h.length-m),g.slice(0,g.length-m),b)}}}if(n.length>0&&r&&0===r.length){var v=e.slice(0,n.index),b=e.slice(n.index+n.length);if(!(s<(p=v.length)+(m=b.length))){var w=t.slice(0,p),x=t.slice(s-m);if(v===w&&b===x)return y(v,e.slice(p,o-m),t.slice(p,s-m),b)}}return null}(e,t,f);if(v)return v}var b=o(e,t),w=e.substring(0,b);b=a(e=e.substring(b),t=t.substring(b));var x=e.substring(e.length-b),S=function(e,t){var s;if(!e)return[[1,t]];if(!t)return[[i,e]];var l=e.length>t.length?e:t,h=e.length>t.length?t:e,u=l.indexOf(h);if(-1!==u)return s=[[1,l.substring(0,u)],[0,h],[1,l.substring(u+h.length)]],e.length>t.length&&(s[0][0]=s[2][0]=i),s;if(1===h.length)return[[i,e],[1,t]];var c=function(e,t){var i=e.length>t.length?e:t,n=e.length>t.length?t:e;if(i.length<4||2*n.length<i.length)return null;function r(e,t,i){for(var n,r,s,l,h=e.substring(i,i+Math.floor(e.length/4)),u=-1,c="";-1!==(u=t.indexOf(h,u+1));){var d=o(e.substring(i),t.substring(u)),p=a(e.substring(0,i),t.substring(0,u));c.length<p+d&&(c=t.substring(u-p,u)+t.substring(u,u+d),n=e.substring(0,i-p),r=e.substring(i+d),s=t.substring(0,u-p),l=t.substring(u+d))}return 2*c.length>=e.length?[n,r,s,l,c]:null}var s,l,h,u,c,d=r(i,n,Math.ceil(i.length/4)),p=r(i,n,Math.ceil(i.length/2));if(!d&&!p)return null;s=p?d&&d[4].length>p[4].length?d:p:d,e.length>t.length?(l=s[0],h=s[1],u=s[2],c=s[3]):(u=s[0],c=s[1],l=s[2],h=s[3]);var f=s[4];return[l,h,u,c,f]}(e,t);if(c){var d=c[0],p=c[1],f=c[2],g=c[3],m=c[4],v=n(d,f),y=n(p,g);return v.concat([[0,m]],y)}return function(e,t){for(var n=e.length,o=t.length,s=Math.ceil((n+o)/2),a=s,l=2*s,h=new Array(l),u=new Array(l),c=0;c<l;c++)h[c]=-1,u[c]=-1;h[a+1]=0,u[a+1]=0;for(var d=n-o,p=d%2!=0,f=0,g=0,m=0,v=0,y=0;y<s;y++){for(var b=-y+f;b<=y-g;b+=2){for(var w=a+b,x=(E=b===-y||b!==y&&h[w-1]<h[w+1]?h[w+1]:h[w-1]+1)-b;E<n&&x<o&&e.charAt(E)===t.charAt(x);)E++,x++;if(h[w]=E,E>n)g+=2;else if(x>o)f+=2;else if(p){if((k=a+d-b)>=0&&k<l&&-1!==u[k])if(E>=(C=n-u[k]))return r(e,t,E,x)}}for(var S=-y+m;S<=y-v;S+=2){for(var C,k=a+S,P=(C=S===-y||S!==y&&u[k-1]<u[k+1]?u[k+1]:u[k-1]+1)-S;C<n&&P<o&&e.charAt(n-C-1)===t.charAt(o-P-1);)C++,P++;if(u[k]=C,C>n)v+=2;else if(P>o)m+=2;else if(!p){if((w=a+d-S)>=0&&w<l&&-1!==h[w]){var E;x=a+(E=h[w])-w;if(E>=(C=n-C))return r(e,t,E,x)}}}}return[[i,e],[1,t]]}(e,t)}(e=e.substring(0,e.length-b),t=t.substring(0,t.length-b));return w&&S.unshift([0,w]),x&&S.push([0,x]),p(S,m),g&&function(e){for(var t=!1,n=[],r=0,o=null,f=0,g=0,m=0,v=0,y=0;f<e.length;)0==e[f][0]?(n[r++]=f,g=v,m=y,v=0,y=0,o=e[f][1]):(1==e[f][0]?v+=e[f][1].length:y+=e[f][1].length,o&&o.length<=Math.max(g,m)&&o.length<=Math.max(v,y)&&(e.splice(n[r-1],0,[i,o]),e[n[r-1]+1][0]=1,r--,r--,f=r>0?n[r-1]:-1,g=0,m=0,v=0,y=0,o=null,t=!0)),f++;for(t&&p(e),function(e){function t(e,t){if(!e||!t)return 6;var i=e.charAt(e.length-1),n=t.charAt(0),r=i.match(l),o=n.match(l),s=r&&i.match(h),a=o&&n.match(h),p=s&&i.match(u),f=a&&n.match(u),g=p&&e.match(c),m=f&&t.match(d);return g||m?5:p||f?4:r&&!s&&a?3:s||a?2:r||o?1:0}for(var i=1;i<e.length-1;){if(0==e[i-1][0]&&0==e[i+1][0]){var n=e[i-1][1],r=e[i][1],o=e[i+1][1],s=a(n,r);if(s){var p=r.substring(r.length-s);n=n.substring(0,n.length-s),r=p+r.substring(0,r.length-s),o=p+o}for(var f=n,g=r,m=o,v=t(n,r)+t(r,o);r.charAt(0)===o.charAt(0);){n+=r.charAt(0),r=r.substring(1)+o.charAt(0),o=o.substring(1);var y=t(n,r)+t(r,o);y>=v&&(v=y,f=n,g=r,m=o)}e[i-1][1]!=f&&(f?e[i-1][1]=f:(e.splice(i-1,1),i--),e[i][1]=g,m?e[i+1][1]=m:(e.splice(i+1,1),i--))}i++}}(e),f=1;f<e.length;){if(e[f-1][0]==i&&1==e[f][0]){var b=e[f-1][1],w=e[f][1],x=s(b,w),S=s(w,b);x>=S?(x>=b.length/2||x>=w.length/2)&&(e.splice(f,0,[0,w.substring(0,x)]),e[f-1][1]=b.substring(0,b.length-x),e[f+1][1]=w.substring(x),f++):(S>=b.length/2||S>=w.length/2)&&(e.splice(f,0,[0,b.substring(0,S)]),e[f-1][0]=1,e[f-1][1]=w.substring(0,w.length-S),e[f+1][0]=i,e[f+1][1]=b.substring(S),f++),f++}f++}}(S),S}function r(e,t,i,r){var o=e.substring(0,i),s=t.substring(0,r),a=e.substring(i),l=t.substring(r),h=n(o,s),u=n(a,l);return h.concat(u)}function o(e,t){if(!e||!t||e.charAt(0)!==t.charAt(0))return 0;for(var i=0,n=Math.min(e.length,t.length),r=n,o=0;i<r;)e.substring(o,r)==t.substring(o,r)?o=i=r:n=r,r=Math.floor((n-i)/2+i);return f(e.charCodeAt(r-1))&&r--,r}function s(e,t){var i=e.length,n=t.length;if(0==i||0==n)return 0;i>n?e=e.substring(i-n):i<n&&(t=t.substring(0,i));var r=Math.min(i,n);if(e==t)return r;for(var o=0,s=1;;){var a=e.substring(r-s),l=t.indexOf(a);if(-1==l)return o;s+=l,(0==l||e.substring(r-s)==t.substring(0,s))&&(o=s,s++)}}function a(e,t){if(!e||!t||e.slice(-1)!==t.slice(-1))return 0;for(var i=0,n=Math.min(e.length,t.length),r=n,o=0;i<r;)e.substring(e.length-r,e.length-o)==t.substring(t.length-r,t.length-o)?o=i=r:n=r,r=Math.floor((n-i)/2+i);return g(e.charCodeAt(e.length-r))&&r--,r}var l=/[^a-zA-Z0-9]/,h=/\s/,u=/[\r\n]/,c=/\n\r?\n$/,d=/^\r?\n\r?\n/;function p(e,t){e.push([0,""]);for(var n,r=0,s=0,l=0,h="",u="";r<e.length;)if(r<e.length-1&&!e[r][1])e.splice(r,1);else switch(e[r][0]){case 1:l++,u+=e[r][1],r++;break;case i:s++,h+=e[r][1],r++;break;case 0:var c=r-l-s-1;if(t){if(c>=0&&v(e[c][1])){var d=e[c][1].slice(-1);if(e[c][1]=e[c][1].slice(0,-1),h=d+h,u=d+u,!e[c][1]){e.splice(c,1),r--;var f=c-1;e[f]&&1===e[f][0]&&(l++,u=e[f][1]+u,f--),e[f]&&e[f][0]===i&&(s++,h=e[f][1]+h,f--),c=f}}if(m(e[r][1])){d=e[r][1].charAt(0);e[r][1]=e[r][1].slice(1),h+=d,u+=d}}if(r<e.length-1&&!e[r][1]){e.splice(r,1);break}if(h.length>0||u.length>0){h.length>0&&u.length>0&&(0!==(n=o(u,h))&&(c>=0?e[c][1]+=u.substring(0,n):(e.splice(0,0,[0,u.substring(0,n)]),r++),u=u.substring(n),h=h.substring(n)),0!==(n=a(u,h))&&(e[r][1]=u.substring(u.length-n)+e[r][1],u=u.substring(0,u.length-n),h=h.substring(0,h.length-n)));var g=l+s;0===h.length&&0===u.length?(e.splice(r-g,g),r-=g):0===h.length?(e.splice(r-g,g,[1,u]),r=r-g+1):0===u.length?(e.splice(r-g,g,[i,h]),r=r-g+1):(e.splice(r-g,g,[i,h],[1,u]),r=r-g+2)}0!==r&&0===e[r-1][0]?(e[r-1][1]+=e[r][1],e.splice(r,1)):r++,l=0,s=0,h="",u=""}""===e[e.length-1][1]&&e.pop();var y=!1;for(r=1;r<e.length-1;)0===e[r-1][0]&&0===e[r+1][0]&&(e[r][1].substring(e[r][1].length-e[r-1][1].length)===e[r-1][1]?(e[r][1]=e[r-1][1]+e[r][1].substring(0,e[r][1].length-e[r-1][1].length),e[r+1][1]=e[r-1][1]+e[r+1][1],e.splice(r-1,1),y=!0):e[r][1].substring(0,e[r+1][1].length)==e[r+1][1]&&(e[r-1][1]+=e[r+1][1],e[r][1]=e[r][1].substring(e[r+1][1].length)+e[r+1][1],e.splice(r+1,1),y=!0)),r++;y&&p(e,t)}function f(e){return e>=55296&&e<=56319}function g(e){return e>=56320&&e<=57343}function m(e){return g(e.charCodeAt(0))}function v(e){return f(e.charCodeAt(e.length-1))}function y(e,t,n,r){return v(e)||m(r)?null:function(e){for(var t=[],i=0;i<e.length;i++)e[i][1].length>0&&t.push(e[i]);return t}([[0,e],[i,t],[1,n],[0,r]])}function b(e,t,i,r){return n(e,t,i,r,!0)}b.INSERT=1,b.DELETE=i,b.EQUAL=0,t.exports=b}),y={};((e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})})(y,{CoreViewer:()=>rb,HOOKS:()=>O,Navigation:()=>ab,PageProgression:()=>S,PageSide:()=>E,PageViewMode:()=>hb,Profiler:()=>z,ReadyState:()=>N,UserAgentBaseCss:()=>Po,UserAgentCounterStylesCss:()=>To,UserAgentPageCss:()=>ko,UserAgentTocCss:()=>Eo,UserAgentXml:()=>Co,ValidationTxt:()=>So,VivliostylePolyfillCss:()=>No,VivliostyleViewportCss:()=>xo,VivliostyleViewportScreenCss:()=>wo,ZoomType:()=>lb,getHooksForName:()=>M,isDebug:()=>b,pageProgressionOf:()=>C,plugin:()=>D,printHTML:()=>cb,profile:()=>q,profiler:()=>G,registerHook:()=>_,removeHook:()=>B,setDebug:()=>w}),e=y,c=l(i({},"__esModule",{value:!0}),e);var b=!1;function w(e){b=e}var x,S=((x=S||{}).LTR="ltr",x.RTL="rtl",x);function C(e){switch(e){case"ltr":return"ltr";case"rtl":return"rtl";default:throw new Error(`unknown PageProgression: ${e}`)}}var k,P,E=(e=>(e.LEFT="left",e.RIGHT="right",e))(E||{}),N=((k=N||{}).LOADING="loading",k.INTERACTIVE="interactive",k.COMPLETE="complete",k),T=((P=T||{})[P.DEBUG=1]="DEBUG",P[P.INFO=2]="INFO",P[P.WARN=3]="WARN",P[P.ERROR=4]="ERROR",P);function I(e){let t=Array.from(e),i=null;return t[0]instanceof Error&&(i=t.shift()),{error:i,messages:t}}function A(e){let t=e.error,i=t&&(t.frameTrace||t.stack),n=[].concat(e.messages);return t&&(n.length>0&&(n=n.concat(["\n"])),n=n.concat([t.toString()]),i&&(n=n.concat(["\n"]).concat(i))),n}var F,R=new class{constructor(e){h(this,"opt_console",e),h(this,"listeners",{})}consoleDebug(e){this.opt_console?this.opt_console.debug?this.opt_console.debug(...e):this.opt_console.log(...e):console.debug(...e)}consoleInfo(e){this.opt_console?this.opt_console.info?this.opt_console.info(...e):this.opt_console.log(...e):console.info(...e)}consoleWarn(e){this.opt_console?this.opt_console.warn?this.opt_console.warn(...e):this.opt_console.log(...e):console.warn(...e)}consoleError(e){this.opt_console?this.opt_console.error?this.opt_console.error(...e):this.opt_console.log(...e):console.error(...e)}triggerListeners(e,t){let i=this.listeners[e];i&&i(t)}addListener(e,t){this.listeners[e]=t}debug(...e){let t=I(arguments);this.consoleDebug(A(t)),this.triggerListeners(1,t)}info(...e){let t=I(arguments);this.consoleInfo(A(t)),this.triggerListeners(2,t)}warn(...e){let t=I(arguments);this.consoleWarn(A(t)),this.triggerListeners(3,t)}error(...e){let t=I(arguments);this.consoleError(A(t)),this.triggerListeners(4,t)}},O=((F=O||{}).SIMPLE_PROPERTY="SIMPLE_PROPERTY",F.PREPROCESS_SINGLE_DOCUMENT="PREPROCESS_SINGLE_DOCUMENT",F.PREPROCESS_TEXT_CONTENT="PREPROCESS_TEXT_CONTENT",F.PREPROCESS_ELEMENT_STYLE="PREPROCESS_ELEMENT_STYLE",F.POLYFILLED_INHERITED_PROPS="POLYFILLED_INHERITED_PROPS",F.CONFIGURATION="CONFIGURATION",F.RESOLVE_TEXT_NODE_BREAKER="RESOLVE_TEXT_NODE_BREAKER",F.RESOLVE_FORMATTING_CONTEXT="RESOLVE_FORMATTING_CONTEXT",F.RESOLVE_LAYOUT_PROCESSOR="RESOLVE_LAYOUT_PROCESSOR",F.POST_LAYOUT_BLOCK="POST_LAYOUT_BLOCK",F.PAGINATION_PROGRESS="PAGINATION_PROGRESS",F),L={};function _(e,t,i){if(O[e]){let n=L[e];n||(n=L[e]=[]),i?n.unshift(t):n.push(t)}else R.warn(new Error(`Skipping unknown plugin hook '${e}'.`))}function B(e,t){if(O[e]){let i=L[e];if(i){let e=i.indexOf(t);e>=0&&i.splice(e,1)}}else R.warn(new Error(`Ignoring unknown plugin hook '${e}'.`))}function M(e){return L[e]||[]}var D={registerHook:_,removeHook:B},z=class{constructor(e){h(this,"performanceInstance",e),h(this,"timestamps",{}),h(this,"registerTiming"),h(this,"registerStartTiming"),h(this,"registerEndTiming"),this.registerTiming=V,this.registerStartTiming=this.registerStartTiming=V,this.registerEndTiming=this.registerEndTiming=V}forceRegisterStartTiming(e,t){U.call(this,e,"start",t)}forceRegisterEndTiming(e,t){U.call(this,e,"end",t)}printTimings(){let e=this.timestamps,t="";Object.keys(e).forEach(i=>{let n=e[i],r=n.length;for(let e=0;e<r;e++){let o=n[e];t+=i,r>1&&(t+=`(${e})`),t+=` => start: ${o.start}, end: ${o.end}, duration: ${o.end-o.start}\n`}}),R.info(t)}disable(){this.registerTiming=V,this.registerStartTiming=this.registerStartTiming=V,this.registerEndTiming=this.registerEndTiming=V}enable(){this.registerTiming=U,this.registerStartTiming=this.registerStartTiming=H,this.registerEndTiming=this.registerEndTiming=$}isEnabled(){return this.registerStartTiming===H}};function V(){}function U(e,t,i){i||(i=this.performanceInstance.now());let n,r=this.timestamps[e];r||(r=this.timestamps[e]=[]);for(let e=r.length-1;e>=0&&(n=r[e],!n||n[t]);e--)n=null;n||(n={},r.push(n)),n[t]=i}function H(e,t){this.registerTiming(e,"start",t)}function $(e,t){this.registerTiming(e,"end",t)}var j={now:Date.now},W=window&&window.performance,G=new z(W||j);G.forceRegisterStartTiming("load_vivliostyle");var q={profiler:{registerStartTiming:G.registerStartTiming,registerEndTiming:G.registerEndTiming,printTimings:G.printTimings,disable:G.disable,enable:G.enable}},X=navigator.userAgent.includes("Chrome")?"chromium":navigator.userAgent.includes("Firefox")?"firefox":navigator.userAgent.includes("AppleWebKit")?"webkit":"unknown",Y=/^[\s\p{Zs}\p{P}\p{Mn}]*[\p{L}\p{N}]\p{Mn}*(?:[\s\p{Zs}]*\p{P}\p{Mn}*)*/u,K="data-adapt-eloff",Z={};function J(e){return JSON.parse(e)}function Q(e){let t=e.match(/^([^#]*)/);return t?t[1]:e}function ee(e){let t=e.match(/^([^#?]*)/);return t?t[1]:e}var te="?viv-toc-box";function ie(e){return e.endsWith(te)}function ne(e){return ie(e)?e.slice(0,-12):e}function re(e){return ie(e)?e:Q(e)+te}var oe=window.location.href;function se(e){oe=e}var ae=window.location.href;function le(e){ae=e}function he(e){return e.replace(/^(https?:)\/\/raw\.githack\.com\/web-platform-tests\/wpt\/[^/]+\//,"$1//wpt.live/")}function ue(e,t){if(/^data:/i.test(t))return e||t;if(!t||e.match(/^\w{2,}:/))return e.toLowerCase().match("^javascript:")?"#":(e.match(/^\w{2,}:\/\/[^\/]+$/)&&(e=`${e}/`),e);let i;if(t.match(/^\w{2,}:\/\/[^\/]+$/)&&(t=`${t}/`),e.match(/^\/\//))return i=t.match(/^(\w{2,}:)\/\//),i?i[1]+e:e;if(e.match(/^\//)){let n=function(e){let t=ee(e).match(/^(https?:\/\/raw\.githack\.com\/web-platform-tests\/wpt\/[^/]+)(?:\/|$)/);return t?t[1]:null}(t);return n?n+e:(i=t.match(/^(\w{2,}:\/\/[^\/]+)\//),i?i[1]+e:e)}if(e.match(/^\.(\/|$)/)&&(e=e.substr(2)),t=ee(t),e.match(/^#/))return t+e;let n=t.lastIndexOf("/");if(n<0)return e;let r=t.substr(0,n+1)+e,o="";for(i=r.match(/^([^?#]*)([?#].*)$/),i&&(r=i[1],o=i[2]);n=r.indexOf("/../"),!(n<=0);){let e=r.lastIndexOf("/",n-1);if(e<=0)break;r=r.substr(0,e)+r.substr(n+3)}return r.replace(/\/(\.\/)+/g,"/")+o}function ce(e,t){return e.match(/^#/)&&t?Q(t)+e:ue(e,t)}function de(e){return/^about:blank($|[?#])/i.test(e)?"data:text/html,":e}function pe(e){let t;return(e=de(e))!==e||((t=/^(https?:)\/\/github\.com\/web-platform-tests\/wpt\/(blob\/|tree\/|raw\/)?(.*)$/.exec(e))?e=`${t[1]}//raw.githack.com/web-platform-tests/wpt/${t[2]?"":"master/"}${t[3]}`:(t=/^(https?:)\/\/github\.com\/([^/]+\/[^/]+)\/(blob\/|tree\/|raw\/)?(.*)$/.exec(e))?e=`${t[1]}//raw.githubusercontent.com/${t[2]}/${t[3]?"":"master/"}${t[4]}`:(t=/^(https?:)\/\/wpt\.live\/(.*)$/.exec(e))?/\.sub\.[^/]+(?:[?#].*)?$/.test(t[2])||(e=`${t[1]}//raw.githack.com/web-platform-tests/wpt/master/${t[2]}`):(t=/^(https?:)\/\/www\.aozora\.gr\.jp\/(cards\/[^/]+\/files\/[^/.]+\.html)$/.exec(e))?e=`${t[1]}//raw.githubusercontent.com/aozorabunko/aozorabunko/master/${t[2]}`:(t=/^(https?:)\/\/gist\.github\.com\/([^/]+\/\w+)(\/|$)(raw(\/|$))?(.*)$/.exec(e))?e=`${t[1]}//gist.githubusercontent.com/${t[2]}/raw/${t[6]}`:(t=/^(https?:)\/\/gist\.github\.com\/([^/]+\/\w+)(?:#|%23)file-(.*)-(\w+)$/.exec(e))?e=`${t[1]}//gist.githubusercontent.com/${t[2]}/raw/${t[3]}.${t[4]}`:(t=/^(https?:)\/\/(?:[^/.]+\.)?jsbin\.com\/(?!(?:blog|help)\b)(\w+)((\/\d+)?).*$/.exec(e))&&(e=`${t[1]}//output.jsbin.com/${t[2]}${t[3]}/`)),e}function fe(e){return null==e?e:e.toString()}var ge=class{constructor(){h(this,"queue",[null])}length(){return this.queue.length-1}add(e){let t=this.queue.length;for(;t>1;){let i=Math.floor(t/2),n=this.queue[i];if(n.compare(e)>0)return void(this.queue[t]=e);this.queue[t]=n,t=i}this.queue[1]=e}peek(){return this.queue[1]}remove(){let e=this.queue[1],t=this.queue.pop(),i=this.queue.length;if(i>1){let e=1;for(;;){let n=2*e;if(n>=i)break;if(this.queue[n].compare(t)>0)n+1<i&&this.queue[n+1].compare(this.queue[n])>0&&n++;else{if(!(n+1<i&&this.queue[n+1].compare(t)>0))break;n++}this.queue[e]=this.queue[n],e=n}this.queue[e]=t}return e}},me=["","-webkit-","-moz-"],ve={};function ye(e,t){return CSS.supports(e+t,"unset")}function be(e,t,i){let n=null==e?void 0:e.style;if(!n)return;if(t.startsWith("--"))return void n.setProperty(t,i||" ");let r=function(e){let t=ve[e];if(t||null===t)return t;switch(e){case"behavior":case"template":case"ua-list-item-count":case"x-first-pseudo":return ve[e]=null,null;case"text-combine-upright":if(ye("-webkit-","text-combine")&&!ye("","text-combine-upright"))return ve[e]=["-webkit-text-combine"],["-webkit-text-combine"]}for(let i of me)if(ye(i,e))return t=[i+e],ve[e]=t,t;return R.warn("Property not supported by the browser: ",e),ve[e]=null,null}(t);if(r)for(let e of r){switch(e){case"-webkit-text-combine":"all"===i&&(i="horizontal");break;case"text-combine-upright":"all"===i&&n.setProperty("text-indent","0")}n.setProperty(e,i)}}function we(e,t,i){try{let i=ve[t];return e.style.getPropertyValue(i?i[0]:t)}catch{}return i||""}function xe(e){return e.nextElementSibling}function Se(e){return e.previousElementSibling}var Ce=class e{constructor(e,t){h(this,"root",e),h(this,"node",t)}static atRoot(t){return new e(t,t)}moveTo(t){return null===t?null:new e(this.root,t)}get firstChild(){return this.moveTo(this.node.firstChild)}get nextSibling(){return this.moveTo(this.node.nextSibling)}get parent(){if(this.node===this.root)return null;let e=this.node.parentNode;return e===this.root||e===this.root.parentNode?null:this.moveTo(e)}};function ke(e){let t=e.getAttributeNS("http://www.w3.org/XML/1998/namespace","lang");return!t&&"http://www.w3.org/1999/xhtml"==e.namespaceURI&&(t=e.getAttribute("lang")),t}var Pe=class{constructor(){h(this,"list",[])}append(e){return this.list.push(e),this}clear(){this.list=[]}toString(){let e=this.list.join("");return this.list=[e],e}};function Ee(e){return`\\${e.charCodeAt(0).toString(16)} `}function Ne(e){return e.replace(/[^-_a-zA-Z0-9\u0080-\uFFFF]/g,Ee)}function Te(e){return e.replace(/[\u0000-\u001F"\\]/g,Ee)}function Ie(e){return e.replace(/[\s+&?=#\u007F-\uFFFF]+/g,encodeURIComponent)}function Ae(e){return!!e.match(/^[a-zA-Z\u009E\u009F\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u024F\u037B-\u037D\u0386\u0388-\u0482\u048A-\u0527]$/)}function Fe(e,t){return e.replace(/[^-a-zA-Z0-9_]/g,function(e){return function(e,t){return(t="string"==typeof t?t:"\\u")+(65536|e.charCodeAt(0)).toString(16).substr(1)}(e,t)})}function Re(e){return Fe(e)}function Oe(e,t){t="string"==typeof t?t:"\\u";let i=new RegExp(`${Re(t)}[0-9a-fA-F]{4}`,"g");return e.replace(i,function(e){return function(e,t){return t="string"==typeof t?t:"\\u",0===e.indexOf(t)?String.fromCharCode(parseInt(e.substring(t.length),16)):e}(e,t)})}function Le(e,t){let i=0,n=e;for(;;){if(0==i||t(i-1),n==e||t(n),i==n)return i;let r=i+n>>1;t(r)?n=r:i=r+1}}function _e(e,t){return e-t}function Be(e,t){let i={};for(let n of e){let e=t(n);e&&!i[e]&&(i[e]=n)}return i}function Me(e,t){let i={};for(let n of e){let e=t(n);e&&(i[e]?i[e].push(n):i[e]=[n])}return i}var De=class{constructor(){h(this,"listeners",{})}dispatchEvent(e){let t=this.listeners[e.type];if(t){e.target=this,e.currentTarget=this;for(let i=0;i<t.length;i++)t[i](e)}}addEventListener(e,t,i){if(i)return;let n=this.listeners[e];n?n.includes(t)||n.push(t):this.listeners[e]=[t]}removeEventListener(e,t,i){if(i)return;let n=this.listeners[e];if(n){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}},ze={audio:!0,canvas:!0,embed:!0,iframe:!0,img:!0,math:!0,object:!0,picture:!0,svg:!0,video:!0};function Ve(e){return{fontFamily:e.fontFamily,lineHeight:e.lineHeight,margin:e.margin,hyphenate:e.hyphenate,columnWidth:e.columnWidth,horizontal:e.horizontal,nightMode:e.nightMode,spreadView:e.spreadView,pageBorder:e.pageBorder,enabledMediaTypes:Object.assign({},e.enabledMediaTypes),defaultPaperSize:e.defaultPaperSize?Object.assign({},e.defaultPaperSize):void 0}}var Ue={fontFamily:"serif",lineHeight:1.25,margin:8,hyphenate:!1,columnWidth:25,horizontal:!1,nightMode:!1,spreadView:!1,pageBorder:1,enabledMediaTypes:{vivliostyle:!0,print:!0},defaultPaperSize:void 0},He={};function $e(e,t,i,n){let r=Math.min((e-0)/i,(t-0)/n);return`matrix(${r},0,0,${r},0,0)`}function je(e){return`"${Te(`${e}`)}"`}function We(e){return Ne(`${e}`)}function Ge(e,t){return e?`${Ne(e)}.${Ne(t)}`:Ne(t)}var qe=0,Xe=class{constructor(e,t){if(h(this,"parent",e),h(this,"resolver",t),h(this,"scopeKey"),h(this,"children",[]),h(this,"zero"),h(this,"one"),h(this,"_true"),h(this,"_false"),h(this,"values",{}),h(this,"funcs",{}),h(this,"builtIns",{}),this.scopeKey="S"+qe++,this.zero=new Rt(this,0),this.one=new Rt(this,1),this._true=new Rt(this,!0),this._false=new Rt(this,!1),e&&e.children.push(this),!e){let e=this.builtIns;e.floor=Math.floor,e.ceil=Math.ceil,e.round=Math.round,e.sqrt=Math.sqrt,e.min=Math.min,e.max=Math.max,e.letterbox=$e,e["css-string"]=je,e["css-name"]=We,e.typeof=e=>typeof e,this.defineBuiltInName("page-width",function(){return this.pageWidth()}),this.defineBuiltInName("page-height",function(){return this.pageHeight()}),this.defineBuiltInName("pref-font-family",function(){return this.pref.fontFamily}),this.defineBuiltInName("pref-night-mode",function(){return this.pref.nightMode}),this.defineBuiltInName("pref-hyphenate",function(){return this.pref.hyphenate}),this.defineBuiltInName("pref-margin",function(){return this.pref.margin}),this.defineBuiltInName("pref-line-height",function(){return this.pref.lineHeight}),this.defineBuiltInName("pref-column-width",function(){return this.pref.columnWidth*this.fontSize}),this.defineBuiltInName("pref-horizontal",function(){return this.pref.horizontal}),this.defineBuiltInName("pref-spread-view",function(){return this.pref.spreadView}),this.defineBuiltInName("pub-title",function(){return this.pubTitle?this.pubTitle:""}),this.defineBuiltInName("doc-title",function(){return this.docTitle?this.docTitle:""})}}defineBuiltInName(e,t){this.values[e]=new It(this,t,e)}defineName(e,t){this.values[e]=t}defineFunc(e,t){this.funcs[e]=t}defineBuiltIn(e,t){this.builtIns[e]=t}};function Ye(e){switch(null==e?void 0:e.toLowerCase()){case"vw":case"vh":case"vi":case"vb":case"vmin":case"vmax":case"pvw":case"pvh":case"pvi":case"pvb":case"pvmin":case"pvmax":return!0;default:return!1}}var Ke={px:1,in:96,pt:4/3,pc:16,cm:96/2.54,mm:96/25.4,q:96/2.54/40,em:16,rem:16,lh:20,rlh:20,dppx:1,dpi:1/96,dpcm:2.54/96};function Ze(e){switch(e){case"q":return!CSS.supports("font-size","1q");case"lh":return!CSS.supports("line-height","1lh");case"rem":case"rlh":return!0;default:return!1}}var Je=class{constructor(e,t,i,n,r){h(this,"rootScope",e),h(this,"viewportWidth",t),h(this,"viewportHeight",i),h(this,"actualPageWidth",null),h(this,"pageWidth"),h(this,"actualPageHeight",null),h(this,"pageHeight"),h(this,"initialFontSize"),h(this,"rootFontSize",null),h(this,"isRelativeRootFontSize",null),h(this,"fontSize"),h(this,"rootLineHeight"),h(this,"isRootLineHeightFromRelativeCalc",!1),h(this,"pref"),h(this,"scopes",{}),h(this,"pageAreaWidth",null),h(this,"pageAreaHeight",null),h(this,"pageVertical",null),h(this,"pubTitle",null),h(this,"docTitle",null),this.pageWidth=function(){return this.actualPageWidth?this.actualPageWidth:this.pref.spreadView?Math.floor(t/2)-this.pref.pageBorder:t},this.pageHeight=function(){return this.actualPageHeight?this.actualPageHeight:i},this.initialFontSize=n,this.rootLineHeight=r,this.fontSize=function(){return this.rootFontSize?this.rootFontSize:n},this.pref=Ue}getScopeContext(e){let t=this.scopes[e.scopeKey];return t||(t={},this.scopes[e.scopeKey]=t),t}clearScope(e){this.scopes[e.scopeKey]={};for(let t=0;t<e.children.length;t++)this.clearScope(e.children[t])}queryUnitSize(e,t,i){if(Ye(e)){let t=this.pageWidth()/100,n=this.pageHeight()/100,r=null!=this.pageAreaWidth?this.pageAreaWidth/100:t,o=null!=this.pageAreaHeight?this.pageAreaHeight/100:n,s=null!=i?i:this.pageVertical;switch(e){case"vw":return r;case"vh":return o;case"vi":return s?o:r;case"vb":return s?r:o;case"vmin":return r<o?r:o;case"vmax":return r>o?r:o;case"pvw":return t;case"pvh":return n;case"pvi":return s?n:t;case"pvb":return s?t:n;case"pvmin":return t<n?t:n;case"pvmax":return t>n?t:n}}return"em"==e||"rem"==e?t?this.initialFontSize:this.fontSize():"lh"==e||"rlh"==e?this.rootLineHeight:Ke[e]}evalName(e,t){let i=e;for(;i;){let e=i.values[t];if(e||i.resolver&&(e=i.resolver.call(this,t,!1),e))return e;i=i.parent}throw new Error(`Name '${t}' is undefined`)}evalCall(e,t,i,n){let r=e;for(;r;){let e=r.funcs[t];if(e||r.resolver&&(e=r.resolver.call(this,t,!0),e))return e;let o=r.builtIns[t];if(o){if(n)return r.zero;let e=Array(i.length);for(let t=0;t<i.length;t++)e[t]=i[t].evaluate(this);return new Rt(r,o.apply(this,e))}r=r.parent}throw new Error(`Function '${t}' is undefined`)}evalMediaName(e,t){let i="all"===e||!!this.pref.enabledMediaTypes[e];return t?!i:i}evalMediaTest(e,t){let i="",n=e.match(/^(min|max)-(.*)$/);n&&(i=n[1],e=n[2]);let r=null,o=null;switch(e){case"width":case"height":case"device-width":case"device-height":case"color":t&&(r=t.evaluate(this))}switch(e){case"width":o=this.pageWidth();break;case"height":o=this.pageHeight();break;case"device-width":o=window.screen.availWidth;break;case"device-height":o=window.screen.availHeight;break;case"color":o=window.screen.pixelDepth}if(null!=o&&null!=r)switch(i){case"min":return o>=Number(r);case"max":return o<=Number(r);default:return o==r}else if(null!=o&&null==t)return 0!==o;return!1}evalSupportsTest(e,t,i){return!1}queryVal(e,t){let i=this.scopes[e.scopeKey];return i?i[t]:void 0}storeVal(e,t,i){this.getScopeContext(e)[t]=i}},Qe=class{constructor(e){h(this,"scope",e),h(this,"key"),this.key="_"+qe++}toString(){let e=new Pe;return this.appendTo(e,0),e.toString()}expand(e,t){return this}dependCore(e,t,i){return e===this}dependOuter(e,t,i){let n=i[this.key];if(null!=n)return n!==He&&n;{i[this.key]=He;let n=this.dependCore(e,t,i);return i[this.key]=n,n}}depend(e,t){return this.dependOuter(e,t,{})}evaluate(e){let t=e.queryVal(this.scope,this.key);return void 0!==t||(t=this.evaluateCore(e),e.storeVal(this.scope,this.key,t)),t}isMediaName(){return!1}},et=class extends Qe{constructor(e,t){super(e),h(this,"val",t)}evaluateCore(e){let t=this.val.evaluate(e);return this.evalPrefix(t)}dependCore(e,t,i){return e===this||this.val.dependOuter(e,t,i)}appendTo(e,t){10<t&&e.append("("),e.append(this.getOp()),this.val.appendTo(e,10),10<t&&e.append(")")}expand(e,t){let i=this.val.expand(e,t);return i===this.val?this:new this.constructor(this.scope,i)}},tt=class extends Qe{constructor(e,t,i){super(e),h(this,"lhs",t),h(this,"rhs",i)}dependCore(e,t,i){return e===this||this.lhs.dependOuter(e,t,i)||this.rhs.dependOuter(e,t,i)}appendTo(e,t){let i=this.getPriority();i<=t&&e.append("("),this.lhs.appendTo(e,i),e.append(this.getOp()),this.rhs.appendTo(e,i),i<=t&&e.append(")")}expand(e,t){let i=this.lhs.expand(e,t),n=this.rhs.expand(e,t);return i===this.lhs&&n===this.rhs?this:new this.constructor(this.scope,i,n)}},it=class extends tt{evaluateCore(e){let t=this.lhs.evaluate(e),i=this.rhs.evaluate(e);return this.evalInfix(t,i)}},nt=class extends tt{constructor(e,t,i){super(e,t,i)}getPriority(){return 1}},rt=class extends it{constructor(e,t,i){super(e,t,i)}getPriority(){return 2}},ot=class extends it{constructor(e,t,i){super(e,t,i)}getPriority(){return 3}},st=class extends it{constructor(e,t,i){super(e,t,i)}getPriority(){return 4}},at=class extends et{constructor(e,t){super(e,t)}getOp(){return"!"}evalPrefix(e){return!e}},lt=class extends at{constructor(e,t){super(e,t)}getOp(){return"not "}},ht=class extends et{constructor(e,t){super(e,t)}getOp(){return"-"}evalPrefix(e){return-e}},ut=class extends nt{constructor(e,t,i){super(e,t,i)}getOp(){return"&&"}evaluateCore(e){return this.lhs.evaluate(e)&&this.rhs.evaluate(e)}},ct=class extends ut{constructor(e,t,i){super(e,t,i)}getOp(){return" and "}},dt=class extends nt{constructor(e,t,i){super(e,t,i)}getOp(){return"||"}evaluateCore(e){return this.lhs.evaluate(e)||this.rhs.evaluate(e)}},pt=class extends dt{constructor(e,t,i){super(e,t,i)}getOp(){return", "}},ft=class extends dt{constructor(e,t,i){super(e,t,i)}getOp(){return" or "}},gt=class extends rt{constructor(e,t,i){super(e,t,i)}getOp(){return"<"}evalInfix(e,t){return e<t}},mt=class extends rt{constructor(e,t,i){super(e,t,i)}getOp(){return"<="}evalInfix(e,t){return e<=t}},vt=class extends rt{constructor(e,t,i){super(e,t,i)}getOp(){return">"}evalInfix(e,t){return e>t}},yt=class extends rt{constructor(e,t,i){super(e,t,i)}getOp(){return">="}evalInfix(e,t){return e>=t}},bt=class extends rt{constructor(e,t,i){super(e,t,i)}getOp(){return"=="}evalInfix(e,t){return e==t}},wt=class extends rt{constructor(e,t,i){super(e,t,i)}getOp(){return"!="}evalInfix(e,t){return e!=t}},xt=class extends ot{constructor(e,t,i){super(e,t,i)}getOp(){return"+"}evalInfix(e,t){return e+t}},St=class extends ot{constructor(e,t,i){super(e,t,i)}getOp(){return" - "}evalInfix(e,t){return e-t}},Ct=class extends st{constructor(e,t,i){super(e,t,i)}getOp(){return"*"}evalInfix(e,t){return e*t}},kt=class extends st{constructor(e,t,i){super(e,t,i)}getOp(){return"/"}evalInfix(e,t){return e/t}},Pt=class extends st{constructor(e,t,i){super(e,t,i)}getOp(){return"%"}evalInfix(e,t){return e%t}},Et=class extends Qe{constructor(e,t,i){var n;super(e),h(this,"num",t),h(this,"unit"),this.unit=null!=(n=null==i?void 0:i.toLowerCase())?n:""}appendTo(e,t){e.append(this.num.toString()),e.append(Ne(this.unit))}evaluateCore(e){return this.num*e.queryUnitSize(this.unit,!1)}},Nt=class extends Qe{constructor(e,t){super(e),h(this,"qualifiedName",t)}appendTo(e,t){e.append(this.qualifiedName)}evaluateCore(e){return e.evalName(this.scope,this.qualifiedName).evaluate(e)}dependCore(e,t,i){return e===this||t.evalName(this.scope,this.qualifiedName).dependOuter(e,t,i)}},Tt=class extends Qe{constructor(e,t,i){super(e),h(this,"not",t),h(this,"name",i)}appendTo(e,t){this.not&&e.append("not "),e.append(Ne(this.name))}evaluateCore(e){return e.evalMediaName(this.name,this.not)}isMediaName(){return!0}},It=class extends Qe{constructor(e,t,i){super(e),h(this,"fn",t),h(this,"str",i)}appendTo(e,t){e.append(this.str)}evaluateCore(e){return this.fn.call(e)}},At=class e extends Qe{constructor(e,t,i){super(e),h(this,"qualifiedName",t),h(this,"params",i)}appendTo(e,t){e.append(this.qualifiedName),function(e,t){e.append("(");for(let i=0;i<t.length;i++)i&&e.append(","),t[i].appendTo(e,0);e.append(")")}(e,this.params)}evaluateCore(e){return e.evalCall(this.scope,this.qualifiedName,this.params,!1).expand(e,this.params).evaluate(e)}dependCore(e,t,i){if(e===this)return!0;for(let n=0;n<this.params.length;n++)if(this.params[n].dependOuter(e,t,i))return!0;return t.evalCall(this.scope,this.qualifiedName,this.params,!0).dependOuter(e,t,i)}expand(t,i){let n=function(e,t,i){let n=t;for(let r=0;r<t.length;r++){let o=t[r].expand(e,i);if(t!==n)n[r]=o;else if(o!==t[r]){n=Array(t.length);for(let e=0;e<r;e++)n[e]=t[e];n[r]=o}}return n}(t,this.params,i);return n===this.params?this:new e(this.scope,this.qualifiedName,n)}},Ft=class e extends Qe{constructor(e,t,i,n){super(e),h(this,"cond",t),h(this,"ifTrue",i),h(this,"ifFalse",n)}appendTo(e,t){t>0&&e.append("("),this.cond.appendTo(e,0),e.append("?"),this.ifTrue.appendTo(e,0),e.append(":"),this.ifFalse.appendTo(e,0),t>0&&e.append(")")}evaluateCore(e){return this.cond.evaluate(e)?this.ifTrue.evaluate(e):this.ifFalse.evaluate(e)}dependCore(e,t,i){return e===this||this.cond.dependOuter(e,t,i)||this.ifTrue.dependOuter(e,t,i)||this.ifFalse.dependOuter(e,t,i)}expand(t,i){let n=this.cond.expand(t,i),r=this.ifTrue.expand(t,i),o=this.ifFalse.expand(t,i);return n===this.cond&&r===this.ifTrue&&o===this.ifFalse?this:new e(this.scope,n,r,o)}},Rt=class extends Qe{constructor(e,t){super(e),h(this,"val",t)}appendTo(e,t){switch(typeof this.val){case"number":case"boolean":e.append(this.val.toString());break;case"string":e.append('"'),e.append(Te(this.val)),e.append('"');break;default:throw new Error("F_UNEXPECTED_STATE")}}evaluateCore(e){return this.val}},Ot=class e extends Qe{constructor(e,t,i){super(e),h(this,"name",t),h(this,"value",i)}appendTo(e,t){e.append("("),e.append(Te(this.name.name)),e.append(":"),this.value.appendTo(e,0),e.append(")")}evaluateCore(e){return e.evalMediaTest(this.name.name,this.value)}dependCore(e,t,i){return e===this||this.value.dependOuter(e,t,i)}expand(t,i){let n=this.value.expand(t,i);return n===this.value?this:new e(this.scope,this.name,n)}},Lt=class extends Qe{constructor(e,t,i,n){super(e),h(this,"name",t),h(this,"value",i),h(this,"isFunc",n)}appendTo(e,t){this.isFunc&&e.append(this.name),e.append("("),!this.isFunc&&this.name&&(e.append(this.name),e.append(":")),e.append(this.value),e.append(")")}evaluateCore(e){return e.evalSupportsTest(this.name,this.value,this.isFunc)}},_t=class extends Qe{constructor(e,t){super(e),h(this,"index",t)}appendTo(e,t){e.append("$"),e.append(this.index.toString())}evaluateCore(e){throw new Error(`Parameter not expanded: ${this.index}`)}expand(e,t){let i=t[this.index];if(!i)throw new Error(`Parameter missing: ${this.index}`);return i}};function Bt(e,t,i){return t===e._false||t===e.zero||i==e._false||i==e.zero?e._false:t===e._true||t===e.one?i:i===e._true||i===e.one?t:new ut(e,t,i)}function Mt(e,t,i){return t===e.zero?i:i===e.zero?t:new xt(e,t,i)}function Dt(e,t,i){return t===e.zero?new ht(e,i):i===e.zero?t:new St(e,t,i)}function zt(e,t,i){return t===e.zero||i===e.zero?e.zero:t===e.one?i:i===e.one?t:new Ct(e,t,i)}function Vt(e,t,i){return t===e.zero?e.zero:i===e.one?t:new kt(e,t,i)}var Ut=class{visitValues(e){for(let t=0;t<e.length;t++)e[t].visit(this);return null}visitEmpty(e){return null}visitSlash(e){return null}visitStr(e){return null}visitIdent(e){return null}visitNumeric(e){return null}visitNum(e){return null}visitInt(e){return this.visitNum(e)}visitHexColor(e){return null}visitURL(e){return null}visitURange(e){return null}visitSpaceList(e){return this.visitValues(e.values),null}visitCommaList(e){return this.visitValues(e.values),null}visitFunc(e){return this.visitValues(e.values),null}visitExpr(e){return null}},Ht=class extends Ut{constructor(){super(),h(this,"error",!1)}visitValues(e){let t=null;for(let i=0;i<e.length;i++){let n=e[i],r=n.visit(this);if(this.error)return[];if(t)t[i]=r;else if(n!==r){t=new Array(e.length);for(let n=0;n<i;n++)t[n]=e[n];t[i]=r}}return t||e}visitEmpty(e){return e}visitStr(e){return e}visitIdent(e){return e}visitSlash(e){return e}visitNumeric(e){return e}visitNum(e){return e}visitInt(e){return e}visitHexColor(e){return e}visitURL(e){return e}visitURange(e){return e}visitSpaceList(e){let t=this.visitValues(e.values);return this.error?Wt:t===e.values?e:new oi(t)}visitCommaList(e){let t=this.visitValues(e.values);return this.error?Wt:t===e.values?e:new si(t)}visitFunc(e){let t=this.visitValues(e.values);return this.error?Wt:t===e.values?e:new ai(e.name,t)}visitExpr(e){return e}},$t=class{toString(){let e=new Pe;return this.appendTo(e,!0),e.toString()}stringValue(){let e=new Pe;return this.appendTo(e,!1),e.toString()}toExpr(e,t){return null}appendTo(e,t){e.append("[error]")}isExpr(){return!1}isNumeric(){return!1}isNum(){return!1}isIdent(){return!1}isSpaceList(){return!1}visit(e){return this}},jt=class e extends $t{static get instance(){return this.empty||(this.empty=new e),this.empty}constructor(){super()}toExpr(e,t){return new Rt(e,"")}appendTo(e,t){}visit(e){return e.visitEmpty(this)}};h(jt,"empty");var Wt=jt.instance,Gt=class e extends $t{static get instance(){return this.slash||(this.slash=new e),this.slash}constructor(){super()}toExpr(e,t){return new Rt(e,"/")}appendTo(e,t){e.append("/")}visit(e){return e.visitSlash(this)}};h(Gt,"slash");var qt=Gt.instance,Xt=class extends $t{constructor(e){super(),h(this,"str",e)}toExpr(e,t){return new Rt(e,this.str)}appendTo(e,t){t?(e.append('"'),e.append(Te(this.str)),e.append('"')):e.append(this.str)}visit(e){return e.visitStr(this)}},Yt=Object.create(null),Kt=class extends $t{constructor(e){if(super(),h(this,"name",e),Yt[e])throw new Error("E_INVALID_CALL");Yt[e]=this}toExpr(e,t){return new Rt(e,this.name)}appendTo(e,t){t?e.append(Ne(this.name)):e.append(this.name)}visit(e){return e.visitIdent(this)}isIdent(){return!0}};function Zt(e){let t=Yt[e];return t||(t=new Kt(e)),t}var Jt=class extends $t{constructor(e,t){var i;super(),h(this,"num",e),h(this,"unit"),this.unit=null!=(i=null==t?void 0:t.toLowerCase())?i:""}toExpr(e,t){return 0==this.num?e.zero:t&&"%"==this.unit?100==this.num?t:new Ct(e,t,new Rt(e,this.num/100)):new Et(e,this.num,this.unit)}appendTo(e,t){e.append(this.num.toString()),e.append(this.unit)}visit(e){return e.visitNumeric(this)}isNumeric(){return!0}},Qt=class extends $t{constructor(e){super(),h(this,"num",e)}toExpr(e,t){return 0==this.num?e.zero:1==this.num?e.one:new Rt(e,this.num)}appendTo(e,t){e.append(this.num.toString())}visit(e){return e.visitNum(this)}isNum(){return!0}},ei=class extends Qt{constructor(e){super(e)}visit(e){return e.visitInt(this)}},ti=class extends $t{constructor(e){super(),h(this,"hex",e)}appendTo(e,t){e.append("#"),e.append(this.hex)}visit(e){return e.visitHexColor(this)}},ii=class extends $t{constructor(e){super(),h(this,"url",e)}appendTo(e,t){e.append('url("'),e.append(Te(this.url)),e.append('")')}visit(e){return e.visitURL(this)}},ni=class extends $t{constructor(e){super(),h(this,"urangeText",e)}appendTo(e,t){e.append(this.urangeText)}visit(e){return e.visitURange(this)}};function ri(e,t,i,n){var r,o;let s=t.length;if(s>0){null==(r=t[0])||r.appendTo(e,n);for(let r=1;r<s;r++)e.append(i),null==(o=t[r])||o.appendTo(e,n)}}var oi=class extends $t{constructor(e){super(),h(this,"values",e)}appendTo(e,t){ri(e,this.values," ",t)}visit(e){return e.visitSpaceList(this)}isSpaceList(){return!0}},si=class extends $t{constructor(e){super(),h(this,"values",e)}appendTo(e,t){ri(e,this.values,",",t)}visit(e){return e.visitCommaList(this)}},ai=class extends $t{constructor(e,t){super(),h(this,"name",e),h(this,"values",t)}appendTo(e,t){e.append(Ne(this.name)),e.append("("),ri(e,this.values,",",t),e.append(")")}visit(e){return e.visitFunc(this)}},li=class extends $t{constructor(e){super(),h(this,"expr",e)}toExpr(){return this.expr}appendTo(e,t){this.expr instanceof Rt||this.expr instanceof Et?this.expr.appendTo(e,0):(e.append("-epubx-expr("),this.expr.appendTo(e,0),e.append(")"))}visit(e){return e.visitExpr(this)}isExpr(){return!0}},hi=class extends $t{constructor(e){super(),h(this,"text",e)}appendTo(e,t){e.append(this.text||" ")}};function ui(e,t){if(e){if(e.isNumeric()){let i=e;return t.queryUnitSize(i.unit,!1)*i.num}if(e.isNum())return e.num}return 0}function ci(e,t){return new Jt(ui(e,t),"px")}var di={absolute:Zt("absolute"),all:Zt("all"),always:Zt("always"),anywhere:Zt("anywhere"),auto:Zt("auto"),avoid:Zt("avoid"),balance:Zt("balance"),balance_all:Zt("balance-all"),block:Zt("block"),block_end:Zt("block-end"),block_start:Zt("block-start"),both:Zt("both"),bottom:Zt("bottom"),border_box:Zt("border-box"),break_all:Zt("break-all"),break_word:Zt("break-word"),clip:Zt("clip"),crop:Zt("crop"),cross:Zt("cross"),column:Zt("column"),discard:Zt("discard"),exclusive:Zt("exclusive"),_false:Zt("false"),fixed:Zt("fixed"),flex:Zt("flex"),flow_root:Zt("flow-root"),footnote:Zt("footnote"),footer:Zt("footer"),grid:Zt("grid"),header:Zt("header"),hidden:Zt("hidden"),horizontal_tb:Zt("horizontal-tb"),inherit:Zt("inherit"),initial:Zt("initial"),inline:Zt("inline"),inline_block:Zt("inline-block"),inline_end:Zt("inline-end"),inline_start:Zt("inline-start"),inside:Zt("inside"),keep:Zt("keep"),landscape:Zt("landscape"),left:Zt("left"),line:Zt("line"),list_item:Zt("list-item"),ltr:Zt("ltr"),manual:Zt("manual"),max_content:Zt("max-content"),min_content:Zt("min-content"),none:Zt("none"),normal:Zt("normal"),oeb_page_foot:Zt("oeb-page-foot"),oeb_page_head:Zt("oeb-page-head"),outside:Zt("outside"),padding_box:Zt("padding-box"),page:Zt("page"),relative:Zt("relative"),revert:Zt("revert"),revert_layer:Zt("revert-layer"),revert_rule:Zt("revert-rule"),right:Zt("right"),same:Zt("same"),scale:Zt("scale"),snap_block:Zt("snap-block"),snap_inline:Zt("snap-inline"),solid:Zt("solid"),spread:Zt("spread"),_static:Zt("static"),rtl:Zt("rtl"),table:Zt("table"),table_caption:Zt("table-caption"),table_cell:Zt("table-cell"),table_footer_group:Zt("table-footer-group"),table_header_group:Zt("table-header-group"),table_row:Zt("table-row"),top:Zt("top"),transparent:Zt("transparent"),unset:Zt("unset"),vertical_lr:Zt("vertical-lr"),vertical_rl:Zt("vertical-rl"),visible:Zt("visible"),_true:Zt("true")},pi=new Jt(100,"%"),fi=new Jt(100,"pvw"),gi=new Jt(100,"pvh"),mi=new Jt(0,"px");new ni("U+0-10FFFF");var vi={"font-size":1,"line-height":2,color:3};function yi(e){return e===di.inherit||e===di.initial||e===di.unset||bi(e)}function bi(e){return e===di.revert||e===di.revert_layer||e===di.revert_rule}var wi=class extends Ut{constructor(){super(...arguments),h(this,"found",!1)}visitIdent(e){return bi(e)&&(this.found=!0),null}};function xi(e,t){return(vi[e]||Number.MAX_VALUE)-(vi[t]||Number.MAX_VALUE)}function Si(e){return null!=e&&e.length>2&&e.startsWith("--")}var Ci,ki,Pi,Ei=class e{constructor(t,i,n){f(this,Ci),f(this,ki),f(this,Pi),g(this,Ci,Math.round(Math.max(0,Math.min(t,e.MAX)))),g(this,ki,Math.round(Math.max(0,Math.min(i,e.MAX)))),g(this,Pi,Math.round(Math.max(0,Math.min(n,e.MAX))))}static fromInt(t,i,n){return new e(t,i,n)}offset(t,i,n){return new e(p(this,Ci)+t,p(this,ki)+i,p(this,Pi)+n)}toKey(){return JSON.stringify([p(this,Ci),p(this,ki),p(this,Pi)])}toColorFunc(t){return new ai("color",[new oi([Zt("srgb"),new Qt(p(this,Ci)/e.MAX),new Qt(p(this,ki)/e.MAX),new Qt(p(this,Pi)/e.MAX),...null!==t?[qt,new Qt(t)]:[]])])}};Ci=new WeakMap,ki=new WeakMap,Pi=new WeakMap,h(Ei,"MAX",1e4);var Ni,Ti,Ii,Ai,Fi=Ei,Ri=class e{constructor(t,i,n,r){f(this,Ni),f(this,Ti),f(this,Ii),f(this,Ai),g(this,Ni,Math.round(Math.max(0,Math.min(t,e.MAX)))),g(this,Ti,Math.round(Math.max(0,Math.min(i,e.MAX)))),g(this,Ii,Math.round(Math.max(0,Math.min(n,e.MAX)))),g(this,Ai,Math.round(Math.max(0,Math.min(r,e.MAX))))}static fromInt(t,i,n,r){return new e(t,i,n,r)}static fromNumber(t,i,n,r){return new e(t*e.MAX,i*e.MAX,n*e.MAX,r*e.MAX)}toSRGB(){let t=e.MAX-p(this,Ai);return Fi.fromInt(Fi.MAX-Math.min(Fi.MAX,Math.round(p(this,Ni)*t/e.MAX)+p(this,Ai)),Fi.MAX-Math.min(Fi.MAX,Math.round(p(this,Ti)*t/e.MAX)+p(this,Ai)),Fi.MAX-Math.min(Fi.MAX,Math.round(p(this,Ii)*t/e.MAX)+p(this,Ai)))}equals(e){return p(this,Ni)===p(e,Ni)&&p(this,Ti)===p(e,Ti)&&p(this,Ii)===p(e,Ii)&&p(this,Ai)===p(e,Ai)}toJSON(){return{c:p(this,Ni),m:p(this,Ti),y:p(this,Ii),k:p(this,Ai)}}};Ni=new WeakMap,Ti=new WeakMap,Ii=new WeakMap,Ai=new WeakMap,h(Ri,"MAX",1e4);var Oi=Ri;function Li(e){return e instanceof Qt?Math.max(0,Math.min(1,e.num)):e instanceof Jt&&"%"===e.unit?Math.max(0,Math.min(1,e.num/100)):null}function _i(e){if("device-cmyk"!==e.name&&"cmyk"!==e.name)return null;let t=1===e.values.length?e.values[0]:null,i=t instanceof oi?t.values:e.values;if(i.length<4||i.length>6)return null;let n=Li(i[0]),r=Li(i[1]),o=Li(i[2]),s=Li(i[3]);if(null===n||null===r||null===o||null===s)return null;let a=null;if(i.length>=5){if(i[4]===qt){if(6!==i.length)return null;a=Li(i[5])}else{if(5!==i.length)return null;a=Li(i[4])}if(null===a)return null}return{cmyk:Oi.fromNumber(n,r,o,s),alpha:a}}function*Bi(e){for(let t=-e;t<=e;t++)for(let i=-e;i<=e;i++)for(let n=-e;n<=e;n++)Math.abs(t)+Math.abs(i)+Math.abs(n)===e&&(yield[t,i,n])}var Mi,Di,zi,Vi,Ui=class{constructor(){f(this,Di),f(this,Mi,new Map)}registerDeviceCmyk(e){let t=_i(e);return t?m(this,Di,zi).call(this,t.cmyk).toColorFunc(t.alpha):null}registerCmykReserveMap(e){for(let[t,i]of e){let e=Fi.fromInt(t.r,t.g,t.b),n=Oi.fromInt(i.c,i.m,i.y,i.k);p(this,Mi).set(e.toKey(),n)}}toJSON(){let e={};return p(this,Mi).forEach((t,i)=>{e[i]=t.toJSON()}),e}};Mi=new WeakMap,Di=new WeakSet,zi=function(e){let t=e.toSRGB(),i=t.toKey(),n=p(this,Mi).get(i);return n?n.equals(e)?t:m(this,Di,Vi).call(this,e,t):(p(this,Mi).set(i,e),t)},Vi=function(e,t){for(let i=1;i<=Fi.MAX;i++)for(let[n,r,o]of Bi(i)){let i=t.offset(n,r,o),s=i.toKey();if(!p(this,Mi).has(s))return p(this,Mi).set(s,e),i}return R.warn(`CmykStore: Exceeded trackable color limit for ${JSON.stringify(e.toJSON())}`),t};var Hi,$i,ji,Wi=class extends Ht{constructor(e){super(),f(this,Hi),f(this,$i,new Map),f(this,ji,!1),g(this,Hi,null!=e?e:new Ui)}reset(){g(this,ji,!1)}hadDeviceCmyk(){return p(this,ji)}recordConversion(e,t){p(this,$i).set(e,t)}getConversions(){if(0===p(this,$i).size)return null;let e={};return p(this,$i).forEach((t,i)=>{e[i]=t}),e}visitFunc(e){let t=p(this,Hi).registerDeviceCmyk(e);return t?(g(this,ji,!0),t):super.visitFunc(e)}};function Gi(e){if(1==e.nodeType){let t=e.getAttribute("id");if(t)return t}return null}function qi(e){return`^${e}`}function Xi(e){return e.replace(/[\[\]\(\),=;^]/g,qi)}function Yi(e){return e.substr(1)}function Ki(e){return e&&e.replace(/\^[\[\]\(\),=;^]/g,Yi)}function Zi(e){let t=[];do{let i=e.match(/^(\^,|[^,])*/),n=Ki(i[0]);if(!(e=e.substr(i[0].length+1))&&!t.length)return n;t.push(n)}while(e);return t}function Ji(e){let t={};for(;e;){let i=e.match(/^;([^;=]+)=(([^;]|\^;)*)/);if(!i)return t;t[i[1]]=Zi(i[2]),e=e.substr(i[0].length)}return t}Hi=new WeakMap,$i=new WeakMap,ji=new WeakMap;var Qi=class{appendTo(e){e.append("!")}applyTo(e){return!1}},en=class{constructor(e,t,i){h(this,"index",e),h(this,"id",t),h(this,"sideBias",i)}appendTo(e){e.append("/"),e.append(this.index.toString()),(this.id||this.sideBias)&&(e.append("["),this.id&&e.append(this.id),this.sideBias&&(e.append(";s="),e.append(this.sideBias)),e.append("]"))}applyTo(e){if(1!=e.node.nodeType)throw new Error("E_CFI_NOT_ELEMENT");let t,i=e.node,n=i.children,r=n.length,o=Math.floor(this.index/2)-1;if(o<0||0==r)t=i.firstChild,e.node=t||i;else{if(t=n[Math.min(o,r-1)],1&this.index){let i=t.nextSibling;i&&1!=i.nodeType?t=i:e.after=!0}e.node=t}if(this.id&&(e.after||this.id!=Gi(e.node))){let t=i.ownerDocument.getElementById(this.id);t?e.node=t:R.warn("E_CFI_ID_MISMATCH:",this.id)}return e.sideBias=this.sideBias,!0}},tn=class{constructor(e,t,i,n){h(this,"offset",e),h(this,"textBefore",t),h(this,"textAfter",i),h(this,"sideBias",n)}applyTo(e){if(this.offset>0&&!e.after){let t=this.offset,i=e.node;for(;;){let e=i.nodeType;if(1==e)break;let n=i.nextSibling;if(3<=e&&e<=5){let e=i.textContent.length;if(t<=e)break;if(!n){t=e;break}t-=e}if(!n){t=0;break}i=n}e.node=i,e.offset=t}return e.sideBias=this.sideBias,!0}appendTo(e){e.append(":"),e.append(this.offset.toString()),(this.textBefore||this.textAfter||this.sideBias)&&(e.append("["),(this.textBefore||this.textAfter)&&(this.textBefore&&e.append(Xi(this.textBefore)),e.append(","),this.textAfter&&e.append(Xi(this.textAfter))),this.sideBias&&(e.append(";s="),e.append(this.sideBias)),e.append("]"))}},nn=class e{constructor(){h(this,"steps",null)}fromString(e){var t,i,n;let r=e.match(/^#?epubcfi\((.*)\)$/);if(!r)throw new Error("E_CFI_NOT_CFI");let o=decodeURIComponent(r[1]),s=0,a=[];for(;;){let e;switch(o.charAt(s)){case"/":{if(s++,r=o.substr(s).match(/^(0|[1-9][0-9]*)(\[(.*?)(;([^\]]|\^\])*)?\])?/),!r)throw new Error("E_CFI_NUMBER_EXPECTED");s+=r[0].length;let i=parseInt(r[1],10),n=null!=(t=r[3])?t:null;e=Ji(r[4]),a.push(new en(i,n,fe(e.s)));break}case":":{if(s++,r=o.substr(s).match(/^(0|[1-9][0-9]*)(\[((([^\];,]|\^[\];,])*)(,(([^\];,]|\^[\];,])*))?)(;([^]]|\^\])*)?\])?/),!r)throw new Error("E_CFI_NUMBER_EXPECTED");s+=r[0].length;let t=parseInt(r[1],10),l=null!=(i=r[4])?i:null;l&&(l=Ki(l));let h=null!=(n=r[7])?n:null;h&&(h=Ki(h)),e=Ji(r[10]),a.push(new tn(t,l,h,fe(e.s)));break}case"!":s++,a.push(new Qi);break;case"~":case"@":case"":return void(this.steps=a);default:throw new Error("E_CFI_PARSE_ERROR")}}}navigate(t){let i={node:t.documentElement,offset:0,after:!1,sideBias:null,ref:null};for(let t=0;t<this.steps.length;t++)if(!this.steps[t].applyTo(i)){i.ref=new e,i.ref.steps=this.steps.slice(t+1);break}return i}trim(e,t){return e.replace(/\s+/g," ").match(t?/^[ -\uD7FF\uE000-\uFFFF]{0,8}/:/[ -\uD7FF\uE000-\uFFFF]{0,8}$/)[0].replace(/^\s/,"").replace(/\s$/,"")}prependPathFromNode(e,t,i,n){let r=[],o=e.parentNode,s="",a="";for(;e;){switch(e.nodeType){case 3:case 4:case 5:{let n=e.textContent,r=n.length;i?(t+=r,s||(s=n)):(t>r&&(t=r),i=!0,s=n.substr(0,t),a=n.substr(t)),e=e.previousSibling;continue}case 8:e=e.previousSibling;continue}break}for((t>0||s||a)&&(s=this.trim(s,!1),a=this.trim(a,!0),r.push(new tn(t,s,a,n)),n=null);o&&o&&9!=o.nodeType;){let t=i?null:Gi(e),s=i?1:0;for(;e;)1==e.nodeType&&(s+=2),e=e.previousSibling;r.push(new en(s,t,n)),n=null,e=o,o=o.parentNode,i=!1}r.reverse(),this.steps?(r.push(new Qi),this.steps=r.concat(this.steps)):this.steps=r}toString(){if(!this.steps)return"";let e=new Pe;e.append("epubcfi(");for(let t=0;t<this.steps.length;t++)this.steps[t].appendTo(e);return e.append(")"),e.toString().replace(/%/g,"%25")}},rn=class{constructor(e,t,i,n){h(this,"x1",e),h(this,"y1",t),h(this,"x2",i),h(this,"y2",n)}},on=class{constructor(e,t){h(this,"x",e),h(this,"y",t)}},sn=class{constructor(e,t,i,n){h(this,"left",e),h(this,"top",t),h(this,"right",i),h(this,"bottom",n)}},an=class{constructor(e,t,i,n){h(this,"low",e),h(this,"high",t),h(this,"winding",i),h(this,"shapeId",n)}},ln=class{constructor(e,t,i,n){h(this,"y1",e),h(this,"y2",t),h(this,"x1",i),h(this,"x2",n),h(this,"left",null),h(this,"right",null)}};function hn(e,t){return e.low.y-t.low.y||e.low.x-t.low.x}var un=class e{constructor(e){h(this,"points",e)}addSegments(e,t){let i=this.points,n=i.length,r=i[n-1];for(let o=0;o<n;o++){let n,s=i[o];n=r.y<s.y?new an(r,s,1,t):new an(s,r,-1,t),e.push(n),r=s}}withOffset(t,i){let n=[];for(let e of this.points)n.push(new on(e.x+t,e.y+i));return new e(n)}};function cn(e,t,i,n){let r=[];for(let o=0;o<20;o++){let s=2*o*Math.PI/20;r.push(new on(e+i*Math.sin(s),t+n*Math.cos(s)))}return new un(r)}function dn(e,t,i,n){return new un([new on(e,t),new on(i,t),new on(i,n),new on(e,n)])}var pn=class{constructor(e,t,i,n){h(this,"x",e),h(this,"winding",t),h(this,"shapeId",i),h(this,"lowOrHigh",n)}};function fn(e,t){let i=e.low.x+(e.high.x-e.low.x)*(t-e.low.y)/(e.high.y-e.low.y);if(isNaN(i))throw new Error("Bad intersection");return i}function gn(e,t,i,n){let r,o,s,a;t.high.y<i&&R.warn("Error: inconsistent segment (1)"),t.low.y<=i?(r=fn(t,i),o=t.winding):(r=t.low.x,o=0),t.high.y>=n?(s=fn(t,n),a=t.winding):(s=t.high.x,a=0),r<s?(e.push(new pn(r,o,t.shapeId,-1)),e.push(new pn(s,a,t.shapeId,1))):(e.push(new pn(s,a,t.shapeId,-1)),e.push(new pn(r,o,t.shapeId,1)))}function mn(e,t,i){let n,r=t+i,o=Array(r),s=Array(r);for(n=0;n<=r;n++)o[n]=0,s[n]=0;let a=[],l=!1,h=e.length;for(let i=0;i<h;i++){let h=e[i];o[h.shapeId]+=h.winding,s[h.shapeId]+=h.lowOrHigh;let u=!1;for(n=0;n<t;n++)if(o[n]&&!s[n]){u=!0;break}if(u)for(n=t;n<=r;n++)if(o[n]||s[n]){u=!1;break}l!=u&&(a.push(h.x),l=u)}return a}function vn(e,t){return t?Math.ceil(e/t)*t:e}function yn(e,t){return t?Math.floor(e/t)*t:e}function bn(e){return new rn(e.y1,-e.x2,e.y2,-e.x1)}function wn(e){return new rn(-e.y2,e.x1,-e.y1,e.x2)}function xn(e){return new un(e.points.map(e=>function(e){return new on(e.y,-e.x)}(e)))}function Sn(e,t){let i=t.length-1,n=new ln(e.y2,e.y2,e.x1,e.x2);for(;i>=0;){let e=n;n=t[i],(n.y2-n.y1<1||n.x1==e.x1&&n.x2==e.x2)&&(e.y1=n.y1,t.splice(i,1),n=e),i--}}function Cn(e,t){let i=0,n=e.length;for(;i<n;){let r=Math.floor((i+n)/2);t>=e[r].y2?i=r+1:n=r}return i}function kn(e,t){if(!e.length)return t;let i,n,r=t.y1;for(n=0;n<e.length&&(i=e[n],!(i.y2>t.y1&&i.x1-.1<=t.x1&&i.x2+.1>=t.x2));n++)r=Math.max(r,i.y2);let o=r;for(;n<e.length&&(i=e[n],!(i.y1>=t.y2||i.x1-.1>t.x1||i.x2+.1<t.x2));n++)o=i.y2;return o=n===e.length?t.y2:Math.min(o,t.y2),o<=r?null:new rn(t.x1,r,t.x2,o)}function Pn(e,t){if(!e.length)return t;let i,n,r=t.y2;for(n=e.length-1;n>=0&&(i=e[n],!(n===e.length-1&&i.y2<t.y2))&&!(i.y1<t.y2&&i.x1-.1<=t.x1&&i.x2+.1>=t.x2);n--)r=Math.min(r,i.y1);let o=Math.min(r,i.y2);for(;n>=0&&(i=e[n],!(i.y2<=t.y1||i.x1-.1>t.x1||i.x2+.1<t.x2));n--)o=i.y1;return o=Math.max(o,t.y1),r<=o?null:new rn(t.x1,o,t.x2,r)}var En=class extends Ut{constructor(){super(),h(this,"propSet",{})}visitIdent(e){return this.propSet[e.name]=!0,e}visitSpaceList(e){return this.visitValues(e.values),e}},Nn=class extends Ut{constructor(e){super(),h(this,"value",e)}visitInt(e){return this.value=e.num,e}};function Tn(e,t){if(e){let i=new Nn(t);try{return e.visit(i),i.value}catch(e){R.warn(e,"toInt: ")}}return t}var In=class extends Ut{constructor(){super(),h(this,"collect",!1),h(this,"coords",[]),h(this,"name",null)}visitNumeric(e){return this.collect&&this.coords.push(e),null}visitNum(e){return this.collect&&0==e.num&&this.coords.push(new Jt(0,"px")),null}visitSpaceList(e){return this.visitValues(e.values),null}visitFunc(e){return this.collect||(this.collect=!0,this.visitValues(e.values),this.collect=!1,this.name=e.name.toLowerCase()),null}getShape(e,t,i,n,r){if(this.coords.length>0){let o=[];switch(this.coords.forEach((e,t)=>{if("%"==e.unit){let r=t%2==0?i:n;3==t&&"circle"==this.name&&(r=Math.sqrt((i*i+n*n)/2)),o.push(e.num*r/100)}else o.push(e.num*r.queryUnitSize(e.unit,!1))}),this.name){case"polygon":if(o.length%2==0){let i=[];for(let n=0;n<o.length;n+=2)i.push(new on(e+o[n],t+o[n+1]));return new un(i)}break;case"rectangle":if(4==o.length)return dn(e+o[0],t+o[1],e+o[0]+o[2],t+o[1]+o[3]);break;case"ellipse":if(4==o.length)return cn(e+o[0],t+o[1],o[2],o[3]);break;case"circle":if(3==o.length)return cn(e+o[0],t+o[1],o[2],o[2])}}return null}};function An(e,t,i,n,r,o){if(e){let s=new In;try{return e.visit(s),s.getShape(t,i,n,r,o)}catch(e){R.warn(e,"toShape:")}}return dn(t,i,t+n,i+r)}var Fn=class extends Ut{constructor(e,t){super(),h(this,"reset",e),h(this,"defaultValue",t),h(this,"counters",Object.create(null)),h(this,"name",null)}visitIdent(e){return this.name=e.toString(),this.reset?this.counters[this.name]=0:this.counters[this.name]=(this.counters[this.name]||0)+this.defaultValue,e}visitInt(e){return this.name&&(this.counters[this.name]+=e.num-(this.reset?0:this.defaultValue)),e}visitSpaceList(e){return this.visitValues(e.values),e}};function Rn(e,t){var i,n;let r=null!=(i=null==t?void 0:t.reset)&&i,o=null!=(n=null==t?void 0:t.defaultValue)?n:r?0:1,s=new Fn(r,o);try{e.visit(s)}catch(e){R.warn(e,"toCounters:")}return s.counters}var On=class extends Ht{constructor(e,t){super(),h(this,"baseUrl",e),h(this,"transformer",t)}visitURL(e){return new ii(he(this.transformer.transformURL(e.url,this.baseUrl)))}};function Ln(e){let t=Object.create(null);return Object.keys(e).forEach(i=>{t[i]=Array.from(e[i])}),t}function _n(e,t){var i;if("content"===t){let t=e.cloneNode(!0);return t.querySelectorAll("[data-adapt-pseudo]").forEach(e=>e.remove()),t.textContent||""}if("marker"===t){let t=e.querySelector('[data-adapt-pseudo="marker"], [data-adapt-pseudo="footnote-marker"]');if(t)return t.textContent||"";let n=null==(i=e.style)?void 0:i.getPropertyValue("--viv-marker-content");if(n){let e=n.match(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g);if(e&&e.length>0)return e.map(e=>function(e){return e.replace(/\\([0-9a-fA-F]{1,6})\s?|\\(.)/g,(e,t,i)=>t?String.fromCodePoint(parseInt(t,16)):i)}(e.substring(1,e.length-1))).join("")}return""}{let i=e.querySelector(`[data-adapt-pseudo="${t}"]`);return i&&i.textContent||""}}var Bn=class{constructor(e,t){h(this,"targetId",e),h(this,"resolved",t),h(this,"pageCounters",null),h(this,"spineIndex",-1),h(this,"pageIndex",-1)}equals(e){return this===e||!!e&&(this.targetId===e.targetId&&this.resolved===e.resolved&&this.spineIndex===e.spineIndex&&this.pageIndex===e.pageIndex)}isResolved(){return this.resolved}resolve(){this.resolved=!0}unresolve(){this.resolved=!1}},Mn=class{constructor(e,t){h(this,"counterStore",e),h(this,"baseURL",t)}countersOfId(e,t){e=this.counterStore.documentURLTransformer.transformFragment(e,this.baseURL),this.counterStore.countersById[e]=t}getExprContentListener(){return this.counterStore.getExprContentListener()}},Dn=class{constructor(e,t,i,n){h(this,"counterStore",e),h(this,"baseURL",t),h(this,"rootScope",i),h(this,"pageScope",n),h(this,"styler",null),h(this,"namedStringValues",Object.create(null)),h(this,"runningElements",Object.create(null))}setStyler(e){this.styler=e}getFragment(e){let t=e.match(/^[^#]*#(.*)$/);return t?t[1]:null}getTransformedId(e){let t=this.counterStore.documentURLTransformer.transformURL(ue(e,this.baseURL),this.baseURL);return"#"===t.charAt(0)&&(t=t.substring(1)),t}getPageCounterVal(e,t){let i=()=>{let t=this.counterStore.currentPageCounters[e];return t&&t.length?t[t.length-1]:null},n=new It(this.pageScope,()=>t(i()),`page-counter-${e}`);return this.counterStore.registerPageCounterExpr(e,e=>t(e[e.length-1]),n),n}getPageCountersVal(e,t){let i=()=>this.counterStore.currentPageCounters[e]||[],n=new It(this.pageScope,()=>t(i()),`page-counters-${e}`);return this.counterStore.registerPageCounterExpr(e,t,n),n}getTargetCounters(e,t,i){let n=this.counterStore.countersById[t];return!n&&i&&e&&(this.styler.styleUntilIdIsReached(e),n=this.counterStore.countersById[t]),n||null}getTargetPageCounters(e){return this.counterStore.currentPage.elementsById[e]?this.counterStore.currentPageCounters:this.counterStore.pageCountersById[e]||null}getTargetPageDocCounters(e){return this.counterStore.currentPage.elementsById[e]?this.counterStore.currentPageDocCounters:this.counterStore.pageDocCountersById[e]||null}adjustCountersForCrossScope(e,t,i,n){if(!this.counterStore.isPageControlledCounter(e)||!i)return t;let r=i[e]||[],o=r.length?r[r.length-1]:0,s=(null==n?void 0:n[e])||[],a=s.length?s[0]:0;return t.length?[o+(t[0]-a),...t.slice(1)]:[o]}getTargetPageText(e,t){if(this.counterStore.currentPage.elementsById[e]){let i=this.counterStore.currentPage.elementsById[e];if(i&&i.length>0){let e=i[0];return _n(e,"before"===t||"after"===t||"marker"===t?t:"content")}return""}if(e in this.counterStore.pageTextById){let i=this.counterStore.pageTextById[e];return void 0!==i[t]?i[t]:i.content||""}return null}getTargetCounterVal(e,t,i){let n=this.getFragment(e),r=this.getTransformedId(e),o=new It(this.pageScope,()=>{let e=this.getTargetCounters(n,r,!0);if(e){if(e[t]){let n=e[t],o=this.getTargetPageCounters(r),s=this.getTargetPageDocCounters(r),a=this.adjustCountersForCrossScope(t,n,o,s);return o&&this.counterStore.resolveReference(r),i(a[a.length-1]||null)}{let e=this.getTargetPageCounters(r);if(e){if(this.counterStore.resolveReference(r),e[t]){let n=e[t];return i(n[n.length-1]||null)}return i(0)}return this.counterStore.saveReferenceOfCurrentPage(r,!1),"??"}}return this.counterStore.saveReferenceOfCurrentPage(r,!1),"??"},`target-counter-${t}-of-${e}`);return this.counterStore.registerTargetCounterExpr(t,i,o,r),o}getTargetCountersVal(e,t,i){let n=this.getFragment(e),r=this.getTransformedId(e);return new It(this.pageScope,()=>{let e=this.getTargetPageCounters(r);if(e){this.counterStore.resolveReference(r);let o=this.getTargetCounters(n,r,!0),s=(null==o?void 0:o[t])||[],a=this.getTargetPageDocCounters(r),l=this.adjustCountersForCrossScope(t,s,e,a);if(l.length)return i(l);let h=e[t]||[];return i(h)}return this.counterStore.saveReferenceOfCurrentPage(r,!1),"??"},`target-counters-${t}-of-${e}`)}getTargetTextVal(e,t){let i=this.getTransformedId(e),n=new It(this.pageScope,()=>{if("first-letter"===t){let e=this.getTargetPageText(i,"before"),t=this.getTargetPageText(i,"content"),n=this.getTargetPageText(i,"after");if(null===e&&null===t&&null===n)return this.counterStore.saveReferenceOfCurrentPage(i,!1),"??";let r=(null!=e?e:"")+(null!=t?t:"")+(null!=n?n:"");this.counterStore.resolveReference(i);let o=r.match(Y);return o?o[0]:""}let e=this.getTargetPageText(i,t);return null!==e?(this.counterStore.resolveReference(i),e):(this.counterStore.saveReferenceOfCurrentPage(i,!1),"??")},`target-text-${t}-of-${e}`);return this.counterStore.registerTargetTextExpr(t,n,i),n}getNamedStringVal(e,t){let i=new It(this.pageScope,()=>this.getRunningValue(this.namedStringValues,e,t),`named-string-${t}-${e}`);return i.getContentList=()=>this.getRunningContentList(e,t),i}getRunningElementVal(e,t){return new It(this.pageScope,()=>this.getRunningValue(this.runningElements,e,t),`running-element-${t}-${e}`)}getRunningValue(e,t,i){let n=this.getRunningRawValue(e,t,i);return"string"==typeof n.value?n.value:this.contentListToString(this.resolveDeferredContentList(n.value,n.offset))}getRunningContentList(e,t){let i=this.getRunningRawValue(this.namedStringValues,e,t);return"string"==typeof i.value?null:this.resolveDeferredContentList(i.value,i.offset)}resolveDeferredContentList(e,t){return this.freezePageCounters(e,t)}freezePageCounters(e,t){if(e instanceof li){let i=e.expr;if(i instanceof It){let n=/^page-counters?-(.+)$/.exec(i.str);if(n){if("pages"===n[1])return e;let r=this.counterStore,o=n[1],s=r.getPageCounterFormat(i)||(e=>e.length?String(e[e.length-1]):""),a=r.getOrCreateNamedStringPageCounterExpr(this.pageScope,t,o,s);return new li(a)}}return e}return e instanceof oi?new oi(e.values.map(e=>this.freezePageCounters(e,t))):e instanceof si?new si(e.values.map(e=>this.freezePageCounters(e,t))):e}contentListToString(e){if(e instanceof Xt)return e.stringValue();if(e instanceof li){let t=e.expr;if(t instanceof It){let e=t.fn.call(null);return null==e?"":String(e)}return""}return e instanceof oi||e instanceof si?e.values.map(e=>this.contentListToString(e)).join(""):""}getRunningRawValue(e,t,i){let n=e[t];if(!n)return{value:"",offset:-1};let r=Object.keys(n).map(e=>parseInt(e,10)).sort(_e),o=this.counterStore.currentPage;if(!o)return{value:"",offset:-1};let s=o.isBlankPage?o.offset-1:o.offset,a=o.isBlankPage?s:Math.max(s,...Array.from(o.container.querySelectorAll(`[${K}]`)).map(e=>parseInt(e.getAttribute(K),10))),l=-1,h=-1,u=-1,c=-1;for(let e=0;e<r.length;e++){let t=r[e],i=e>0?r[e-1]:-1,n=e<r.length-1?r[e+1]:-1;if(t>a)break;if(t>=s){if(l<0&&(l=t,c=-1),h<0)if(t===s)h=t;else{i<l&&(h=i);let e=o.container.querySelector(`[${K}="${t}"]`);if(e){let i=o.container.querySelector(`[${K}="${s}"]`);if(i||(i=o.container.querySelector(`[${K}="0"]`)),i)for(let n=i;n;n=n.firstElementChild)if(n===e){h=t;break}}else h<0&&(h=t)}u=t}else(n>a||n<0)&&(l=h=u=c=t)}return{value:n[{first:l,start:h,last:u,"first-except":c}[i]]||"",offset:{first:l,start:h,last:u,"first-except":c}[i]}}setNamedString(e,t,i){(this.namedStringValues[e]||(this.namedStringValues[e]=Object.create(null)))[i]=t,"string"!=typeof t&&(this.counterStore.hasDeferredNamedStrings=!0)}setRunningElement(e,t){(this.runningElements[e]||(this.runningElements[e]=Object.create(null)))[t]=String(t)}},zn=class{constructor(e){h(this,"documentURLTransformer",e),h(this,"countersById",Object.create(null)),h(this,"pageCountersById",Object.create(null)),h(this,"pageDocCountersById",Object.create(null)),h(this,"pageTextById",Object.create(null)),h(this,"currentPageDocCounters",null),h(this,"previousPageDocCounters",null),h(this,"currentPageDocCounterChanges",Object.create(null)),h(this,"currentPageDocCounterChangeTypes",Object.create(null)),h(this,"currentPageCounters",Object.create(null)),h(this,"previousPageCounters",Object.create(null)),h(this,"pageCountersBeforeOverride",Object.create(null)),h(this,"hasDeferredNamedStrings",!1),h(this,"namedStringPageSnapshots",Object.create(null)),h(this,"namedStringPageCounterExprMap",Object.create(null)),h(this,"currentPageCountersStack",[]),h(this,"pageIndicesById",Object.create(null)),h(this,"currentPage",null),h(this,"newReferencesOfCurrentPage",[]),h(this,"referencesToSolve",[]),h(this,"referencesToSolveStack",[]),h(this,"unresolvedReferences",Object.create(null)),h(this,"resolvedReferences",Object.create(null)),h(this,"pageControlledCounterNames",Object.assign(Object.create(null),{page:!0})),h(this,"pagesCounterExprs",[]),h(this,"pageCounterExprs",[]),h(this,"targetCounterExprs",[]),h(this,"targetTextExprs",[]),this.currentPageCounters.page=[0]}createCounterListener(e){return new Mn(this,e)}createCounterResolver(e,t,i){return new Dn(this,e,t,i)}setCurrentPage(e){this.currentPage=e}setCurrentPageDocCounters(e,t,i){this.previousPageDocCounters=this.currentPageDocCounters?Ln(this.currentPageDocCounters):null,this.currentPageDocCounters=e?Ln(e):null,this.currentPageDocCounterChanges=Object.create(null),this.currentPageDocCounterChangeTypes=i?{...i}:Object.create(null),t&&t.forEach(e=>{this.currentPageDocCounterChanges[e]=!0})}setPageControlledCounterNames(e){let t=Object.assign(Object.create(null),{page:!0});e.forEach(e=>{t[e]=!0}),this.pageControlledCounterNames=t}isPageControlledCounter(e){return!!this.pageControlledCounterNames[e]}definePageCounter(e,t){this.currentPageCounters[e]?this.currentPageCounters[e].push(t):this.currentPageCounters[e]=[t]}forceSetPageCounter(e){let t=this.currentPageCounters.page;t&&t.length?t[t.length-1]=e:this.currentPageCounters.page=[e]}updatePageCounters(e,t){this.previousPageCounters=Ln(this.currentPageCounters);let i=this.currentPageDocCounterChanges||{},n=this.currentPageDocCounterChangeTypes||{},r=Object.create(null);if(this.currentPageDocCounters){let e=this.previousPageDocCounters||{};for(let t in this.currentPageDocCounters){if(!i[t])continue;let o=this.currentPageDocCounters[t],s=o.length?o[o.length-1]:0,a=e[t]||[],l=s-(a.length?a[a.length-1]:0),h=n[t],u="reset"===h||"set"===h;r[t]={delta:l,reset:u,value:s}}}let o,s=Object.create(null),a=!1,l=e["counter-reset"];if(l){let e=l.evaluate(t);e&&(a=e===di.none,a||(o=Rn(e,{reset:!0})))}o&&"pages"in o&&delete o.pages;let h,u=e["counter-set"];if(u){let e=u.evaluate(t);e&&(h=Rn(e,{defaultValue:0}))}h&&"pages"in h&&delete h.pages;let c=[];if(o)for(let e in o)c.push(e);if(h)for(let e in h)c.push(e);let d,p=e["counter-increment"];if(p){let e=p.evaluate(t);e&&(d=Rn(e))}d&&"pages"in d&&delete d.pages,d?!("page"in d)&&(!r.page||!r.page.reset)&&(d.page=1):(d=Object.create(null),r.page&&r.page.reset||(d.page=1));for(let e in d)c.push(e);this.setPageControlledCounterNames(c);let f=Ln(this.previousPageCounters);if(a)for(let e in this.pageCountersBeforeOverride)f[e]=Array.from(this.pageCountersBeforeOverride[e]);if(this.currentPageDocCounters)for(let e in this.currentPageDocCounters){if(this.isPageControlledCounter(e)){let t=r[e];if(t){if(t.reset)f[e]=[t.value],s[e]=!0;else if(0!==t.delta){f[e]||(f[e]=[0]);let i=f[e];i[i.length-1]+=t.delta}}else f[e]||(f[e]=Array.from(this.currentPageDocCounters[e]));continue}f[e]=Array.from(this.currentPageDocCounters[e])}this.currentPageCounters=f;let g=Object.create(null),m=e=>{if(!Object.prototype.hasOwnProperty.call(g,e)){let t=f[e];t&&(g[e]=Array.from(t))}};if(o)for(let e in o)m(e),this.definePageCounter(e,o[e]);for(let e in d){if(s[e])continue;this.currentPageCounters[e]||this.definePageCounter(e,0);let t=this.currentPageCounters[e];t[t.length-1]+=d[e]}if(h)for(let e in h)if(m(e),this.currentPageCounters[e]){let t=this.currentPageCounters[e];t[t.length-1]=h[e]}else this.definePageCounter(e,h[e]);for(let e in g)this.pageCountersBeforeOverride[e]=Array.from(g[e])}pushPageCounters(e){this.currentPageCountersStack.push(this.currentPageCounters),this.currentPageCounters=Ln(e)}popPageCounters(){this.currentPageCounters=this.currentPageCountersStack.pop()}resolveReference(e){let t=this.unresolvedReferences[e],i=this.resolvedReferences[e];i||(i=this.resolvedReferences[e]=[]);let n=!1;for(let r=0;r<this.referencesToSolve.length;){let o=this.referencesToSolve[r];if(o.targetId===e){if(o.resolve(),this.referencesToSolve.splice(r,1),t){let e=t.indexOf(o);e>=0&&t.splice(e,1)}i.push(o),n=!0}else r++}n||this.saveReferenceOfCurrentPage(e,!0)}saveReferenceOfCurrentPage(e,t){if(!this.newReferencesOfCurrentPage.some(t=>t.targetId===e)){let i=new Bn(e,t);this.newReferencesOfCurrentPage.push(i)}}finishPage(e,t){let i=Object.keys(this.currentPage.elementsById);if(i.length>0){let n=Ln(this.currentPageCounters),r=this.currentPageDocCounters?Ln(this.currentPageDocCounters):null;i.forEach(i=>{this.pageCountersById[i]=n,r&&(this.pageDocCountersById[i]=r);let o=this.currentPage.elementsById[i];if(o&&o.length>0){let e=o[0];this.pageTextById[i]={content:_n(e,"content"),before:_n(e,"before"),after:_n(e,"after"),marker:_n(e,"marker")}}let s=this.pageIndicesById[i];if(s&&s.pageIndex<t){let e=this.resolvedReferences[i];if(e){let t,n=this.unresolvedReferences[i];for(n||(n=this.unresolvedReferences[i]=[]);t=e.shift();)t.unresolve(),n.push(t)}}this.pageIndicesById[i]={spineIndex:e,pageIndex:t}})}let n,r=this.previousPageCounters;for(;n=this.newReferencesOfCurrentPage.shift();){let i;n.pageCounters=r,n.spineIndex=e,n.pageIndex=t,n.isResolved()?(i=this.resolvedReferences[n.targetId],i||(i=this.resolvedReferences[n.targetId]=[])):(i=this.unresolvedReferences[n.targetId],i||(i=this.unresolvedReferences[n.targetId]=[])),i.every(e=>!n.equals(e))&&i.push(n)}this.hasDeferredNamedStrings&&this.currentPage&&this.recordNamedStringPageSnapshot(e),this.currentPage=null}recordNamedStringPageSnapshot(e){let t=this.currentPage,i=t.isBlankPage?t.offset-1:t.offset,n=t.isBlankPage?i:Math.max(i,...Array.from(t.container.querySelectorAll(`[${K}]`)).map(e=>parseInt(e.getAttribute(K),10)));for(let e of Object.keys(this.namedStringPageSnapshots)){let t=parseInt(e,10);if(t<=i)continue;let r=this.namedStringPageSnapshots[t];t<=n&&i<=r.lastOffset&&delete this.namedStringPageSnapshots[t]}this.namedStringPageSnapshots[i]={lastOffset:n,spineIndex:e,counters:Ln(this.currentPageCounters)}}getPageCountersForOffset(e){for(let t of Object.keys(this.namedStringPageSnapshots)){let i=parseInt(t,10);if(i>e)break;let n=this.namedStringPageSnapshots[i];if(e<=n.lastOffset)return n.counters}return null}adjustPageCountersOfLaterSpines(e,t){if(t<=0)return;let i=new Set;for(let n of Object.keys(this.pageIndicesById))if(this.pageIndicesById[n].spineIndex>e){let e=this.pageCountersById[n];e&&e.page&&!i.has(e)&&(i.add(e),e.page=e.page.map(e=>e+t))}for(let n of Object.keys(this.namedStringPageSnapshots)){let r=this.namedStringPageSnapshots[parseInt(n,10)];r.spineIndex>e&&r.counters.page&&!i.has(r.counters)&&(i.add(r.counters),r.counters.page=r.counters.page.map(e=>e+t))}}updateTargetCounterNodesInPages(e){for(let t of e){if(!t||!t.container)continue;let e=t.container.querySelectorAll(`[${$n}]`);for(let t of e){let e=t.getAttribute($n),i=this.targetCounterExprs.find(t=>t.expr.key===e);if(i&&i.transformedId){let e=this.pageCountersById[i.transformedId];if(e){let n=e[i.name];n&&(t.textContent=i.format(n[n.length-1]))}}}}}getPageCountersForPage(e,t){let i=Object.keys(e.elementsById);for(let e of i){let t=this.pageCountersById[e];if(t)return t}return t||null}updatePageCounterNodesInPages(e,t){var i;for(let n=0;n<e.length;n++){let r=e[n];if(null==r||!r.container)continue;let o=r.container.querySelectorAll(`[${Hn}]`);for(let e of o){let t=e.getAttribute(Hn),i=this.namedStringPageCounterExprMap[t];if(!i)continue;let n=this.getPageCountersForOffset(i.offset),r=null==n?void 0:n[i.counterName];r&&(e.textContent=i.format(r))}let s=this.getPageCountersForPage(r,null==t?void 0:t[n]);if(!s)continue;let a=r.container.querySelectorAll(`[${Un}]`);for(let e of a){let t=e.getAttribute(Un),n=this.pageCounterExprs.find(e=>e.expr.key===t);if(!n)continue;let r=null==(i=n.expr)?void 0:i.str,o=s[null==r?void 0:r.replace(/^page-counters?-/,"")];o&&(e.textContent=n.format(o))}}}getUnresolvedRefsToPage(e){let t=[];Object.keys(e.elementsById).forEach(e=>{let i=this.unresolvedReferences[e];i&&(t=t.concat(i))}),t.sort((e,t)=>e.spineIndex-t.spineIndex||e.pageIndex-t.pageIndex);let i=[],n=null;return t.forEach(e=>{n&&n.spineIndex===e.spineIndex&&n.pageIndex===e.pageIndex?n.refs.push(e):(n={spineIndex:e.spineIndex,pageIndex:e.pageIndex,pageCounters:e.pageCounters,refs:[e]},i.push(n))}),i}pushReferencesToSolve(e){this.referencesToSolveStack.push(this.referencesToSolve),this.referencesToSolve=e}popReferencesToSolve(){this.referencesToSolve=this.referencesToSolveStack.pop()}registerPageCounterExpr(e,t,i){"pages"===e?this.pagesCounterExprs.push({expr:i,format:t}):this.pageCounterExprs.push({expr:i,format:t})}getPageCounterFormat(e){let t=this.pageCounterExprs.find(t=>t.expr===e);return t?t.format:null}getOrCreateNamedStringPageCounterExpr(e,t,i,n){for(let e in this.namedStringPageCounterExprMap){let n=this.namedStringPageCounterExprMap[e];if(n.offset===t&&n.counterName===i)return n.expr}let r=new It(e,()=>{let e=((t>=0?this.getPageCountersForOffset(t):null)||this.currentPageCounters)[i]||[];return n(e)},`named-string-page-counter-${i}`);return this.namedStringPageCounterExprMap[r.key]={expr:r,offset:t,counterName:i,format:n},r}registerTargetCounterExpr(e,t,i,n){this.targetCounterExprs.push({name:e,expr:i,format:t,transformedId:n})}registerTargetTextExpr(e,t,i){this.targetTextExprs.push({pseudoElement:e,expr:t,transformedId:i})}getExprContentListener(){return this.exprContentListener.bind(this)}exprContentListener(e,t,i){if(e instanceof It){if("viv-leader"==e.str){let n=i.createElementNS("http://www.w3.org/1999/xhtml","span");return n.textContent=t,n.setAttribute("data-viv-leader",e.key),n.setAttribute("data-viv-leader-value",t),n}if(e.str.startsWith("running-element-")){let e=t&&i.querySelectorAll(`[${K}="${t}"]`);if(!e||0===e.length)return null;let n=e[e.length-1].cloneNode(!0);return this.fixPageCounterInRunningElement(n),n.style.position="",n.style.visibility="",n}if(e.str.startsWith("target-counter-")){let n=i.createElementNS("http://www.w3.org/1999/xhtml","span");return n.textContent=t,n.setAttribute($n,e.key),n}if(e.str.startsWith("target-text-")){let n=i.createElementNS("http://www.w3.org/1999/xhtml","span");return n.textContent=t,n.setAttribute(jn,e.key),n}if(e.str.startsWith("named-string-page-counter-")){let n=i.createElementNS("http://www.w3.org/1999/xhtml","span");return n.textContent=t,n.setAttribute(Hn,e.key),n}}let n=this.pagesCounterExprs.findIndex(t=>t.expr===e)>=0,r=!n&&this.pageCounterExprs.findIndex(t=>t.expr===e)>=0;if(n||r){let r=i.createElementNS("http://www.w3.org/1999/xhtml","span");return r.textContent=t,r.setAttribute(n?Vn:Un,e.key),r}return null}fixPageCounterInRunningElement(e){let t=e.querySelectorAll(`[${Un}]`);for(let e of t){let t=e.getAttribute(Un),i=this.pageCounterExprs.find(e=>e.expr.key===t),n=(null==i?void 0:i.expr).str,r=null==n?void 0:n.replace(/^page-counters?-/,""),o=this.currentPageCounters[r];o&&(e.textContent=i.format(o))}let i=e.querySelectorAll(`[${$n}]`);for(let e of i)e.setAttribute(Wn,!0);let n=e.querySelectorAll(`[${jn}]`);for(let e of n)e.setAttribute(Gn,!0)}finishLastPage(e){var t;let i=e.root.querySelectorAll(`[${Vn}]`),n=e.contentContainer.childElementCount;for(let e of i){let t=e.getAttribute(Vn),i=this.pagesCounterExprs.findIndex(e=>e.expr.key===t);e.textContent=this.pagesCounterExprs[i].format([n])}let r=e.root.querySelectorAll(`[${Wn}]`);for(let e of r){let t=e.getAttribute($n),i=this.targetCounterExprs.find(e=>e.expr.key===t);if(i&&i.transformedId){let t=this.pageCountersById[i.transformedId];if(t){let n=t[i.name];n&&(e.textContent=i.format(n[n.length-1]))}}}let o=e.root.querySelectorAll(`[${Gn}]`);for(let e of o){let i=e.getAttribute(jn),n=this.targetTextExprs.find(e=>e.expr.key===i);if(n&&n.transformedId){let i=this.pageTextById[n.transformedId];i&&(e.textContent=null!=(t=i[n.pseudoElement])?t:"")}}}createLayoutConstraint(e){return new qn(this,e)}},Vn="data-vivliostyle-pages-counter",Un="data-vivliostyle-page-counter",Hn="data-vivliostyle-named-string-page-counter",$n="data-vivliostyle-target-counter",jn="data-vivliostyle-target-text",Wn="data-vivliostyle-target-counter-in-running",Gn="data-vivliostyle-target-text-in-running",qn=class{constructor(e,t){h(this,"counterStore",e),h(this,"pageIndex",t)}allowLayout(e){if(!e||e.after)return!0;let t=e.viewNode;if(!t||1!==t.nodeType)return!0;let i=t.getAttribute("data-vivliostyle-id")||t.getAttribute("id")||t.getAttribute("name");if(!i||!this.counterStore.resolvedReferences[i]&&!this.counterStore.unresolvedReferences[i])return!0;let n=this.counterStore.pageIndicesById[i];return!n||this.pageIndex>=n.pageIndex}},Xn=new Set(["before","after","first-line","first-letter"]),Yn=new Set(["media","supports","layer","-epubx-when"]),Kn=new Set([";","}"]),Zn=new Set(["{",";","}"]),Jn=new Set([";","{","}"]);function Qn(e){let{statements:t,changed:i}=er(e,0,e.length,null);return i?t.join("\n"):e}function er(e,t,i,n){let r=[],o=[],s=!1,a=t,l=()=>{0!==o.length&&(n?r.push(function(e,t){return`${e} { ${tr(t)} }`}(n,o)):r.push(tr(o)),o.length=0)};for(;a<i&&(a=vr(e,a,i),!(a>=i||"}"===e[a]));){if("@"===e[a]){let t=pr(e,a,i);if(!t)break;if(n&&!Yn.has(t.name)){o.push(Sr(e.slice(a,t.end))),a=t.end;continue}if(l(),t.hasBlock&&Yn.has(t.name)){let i=er(e,t.blockStart,t.blockEnd,n);s||(s=i.changed||null!=n),r.push(`${t.header} {${ir(i.statements)}}`)}else r.push(Sr(e.slice(a,t.end)));a=t.end;continue}if(n&&ar(e,a,i)){let t=hr(e,a,i);if(!t)break;o.push(Sr(t.text)),a=t.end;continue}l();let t=ur(e,a,i);if(!t){let t=fr(e,a,i);r.push(Sr(t.text)),a=t.end;continue}if(n&&cr(e,a,t)){let n=dr(e,a,t.end,i);o.push(Sr(n.text)),a=n.end;continue}let h=n?nr(n,t.prelude):rr(t.prelude);if(h){s||(s=null!=n);let i=er(e,t.blockStart,t.blockEnd,h);s||(s=i.changed),0===i.statements.length?r.push(`${h} {}`):r.push(...i.statements)}a=t.end}return l(),{statements:r,changed:s}}function tr(e){return e.map(e=>e.endsWith(";")?e:`${e};`).join(" ")}function ir(e){return 0===e.length?"":` ${e.join(" ")} `}function nr(e,t){let i=function(e){let t=sr(e,",").map(e=>e.trim()).filter(Boolean).filter(e=>!function(e){let t=0;for(;t<e.length;){let i=wr(e,t);if(null!=i){t=i;continue}let n=br(e,t,e.length);if(null==n){if(":"===e[t]){if(":"===e[t+1])return!0;let i=t+1,n=lr(e,i,e.length),r=e.slice(i,n).toLowerCase();if(Xn.has(r))return!0;t=n;continue}t++}else t=n}return!1}(e));return 0===t.length?null:`:is(${t.join(", ")})`}(e);if(!i)return null;let n=sr(t,",").map(e=>e.trim()).filter(Boolean).map(e=>{let t=or(e,i);return t.found?t.text:`${i} ${e}`}).filter(Boolean);return 0===n.length?null:n.join(", ")}function rr(e){return or(e.trim(),":where(:scope)").text}function or(e,t){let i=0,n=!1,r="",o=[],s=function(e){let t=0;for(;t<e.length;){let i=wr(e,t);if(null!=i){t=i;continue}let n=br(e,t,e.length);if(null==n){if(":"===e[t]&&":"!==e[t+1]){let i=t+1,n=lr(e,i,e.length);if(n>i&&"has"===e.slice(i,n).toLowerCase()&&"("===e[n])return!0;t=n;continue}t++}else t=n}return!1}(t);for(;i<e.length;){let a=wr(e,i);if(null!=a){r+=e.slice(i,a),i=a;continue}let l=br(e,i,e.length);if(null!=l){r+=e.slice(i,l),i=l;continue}let h=e[i];if(":"===h&&":"!==e[i+1]){let t=i+1,n=lr(e,t,e.length);if(n>t&&"("===e[n]){o.push(e.slice(t,n).toLowerCase()),r+=e.slice(i,n+1),i=n+1;continue}}"("!==h?")"!==h?"&"!==h?(r+=h,i++):(r+=s&&o.includes("has")?":where(:not(*))":t,n=!0,i++):(o.pop(),r+=h,i++):(o.push(""),r+=h,i++)}return{text:r,found:n}}function sr(e,t){let i=[],n=0,r=0,o=0,s=0;for(;r<e.length;){let a=wr(e,r);if(null!=a){r=a;continue}let l=br(e,r,e.length);if(null!=l){r=l;continue}let h=e[r];switch(h){case"(":o++;break;case")":o=Math.max(0,o-1);break;case"[":s++;break;case"]":s=Math.max(0,s-1);break;default:0===o&&0===s&&h===t&&(i.push(e.slice(n,r)),n=r+1)}r++}return i.push(e.slice(n)),i}function ar(e,t,i){let n=t,r=function(e,t,i){let n=t;return"-"===e[n]&&(n++,n<i&&"-"===e[n]&&n++),lr(e,n,i)}(e,n,i);if(r<=n)return!1;let o=vr(e,r,i);if(o>=i||":"!==e[o])return!1;let s=gr(e,o+1,i,Jn);return"{"!==(null==s?void 0:s.char)||!function(e,t,i,n,r){if(vr(e,i,r)!==n)return!1;let o=vr(e,n+1,r);if(o!==n+1||o>=r)return!1;let s=e[o];return":"===s||"\\"===s||/[A-Za-z_-]/.test(s)}(e,0,r,o,s.index)}function lr(e,t,i){let n=t;for(;n<i;){let t=e[n];if("\\"!==t){if(!/[0-9A-Za-z_-]/.test(t))break;n++}else n+=2}return n}function hr(e,t,i){let n=gr(e,t,i,Kn);if(!n){let n=e.slice(t,i).trim();return n?{text:n,end:i}:null}let r=";"===n.char?n.index+1:n.index;return{text:e.slice(t,r).trim(),end:r}}function ur(e,t,i){let n=gr(e,t,i,Zn);if(!n||"{"!==n.char)return null;let r=mr(e,n.index,i);return r<0?null:{prelude:Sr(e.slice(t,n.index)),blockStart:n.index+1,blockEnd:r,end:r+1}}function cr(e,t,i){if(!function(e,t,i){let n=vr(e,t,i);if(n>=i)return!1;let r=e[n];return"&"===r||"."===r||"#"===r||":"===r||"["===r||"|"===r||"*"===r||">"===r||"+"===r||"~"===r||"\\"===r||/[A-Za-z_-]/.test(r)}(e,t,i.blockStart-1))return!0;let n=vr(e,i.blockStart,i.blockEnd);return n<i.blockEnd&&";"===e[n]}function dr(e,t,i,n){let r=vr(e,i,n),o=r<n&&";"===e[r]?r+1:i;return{text:e.slice(t,o),end:o}}function pr(e,t,i){let n=gr(e,t,i,Zn);if(!n)return null;let r=lr(e,t+1,i),o=e.slice(t+1,r).toLowerCase(),s=Sr(e.slice(t,n.index));if("{"!==n.char)return{name:o,header:s,hasBlock:!1,blockStart:-1,blockEnd:-1,end:n.index+(";"===n.char?1:0)};let a=mr(e,n.index,i);return a<0?null:{name:o,header:s,hasBlock:!0,blockStart:n.index+1,blockEnd:a,end:a+1}}function fr(e,t,i){let n=gr(e,t,i,Kn);if(!n)return{text:e.slice(t,i),end:i};let r=";"===n.char?n.index+1:n.index;return{text:e.slice(t,r),end:r}}function gr(e,t,i,n){let r=t,o=0,s=0,a=0;for(;r<i;){let t=br(e,r,i);if(null!=t){r=t;continue}let l=e[r];switch(l){case"(":o++;break;case")":o=Math.max(0,o-1);break;case"[":s++;break;case"]":s=Math.max(0,s-1);break;case"{":if(0===o&&0===s&&0===a&&n.has(l))return{index:r,char:l};a++;break;case"}":if(0===o&&0===s&&0===a&&n.has(l))return{index:r,char:l};a=Math.max(0,a-1);break;default:if(0===o&&0===s&&0===a&&n.has(l))return{index:r,char:l}}r++}return null}function mr(e,t,i){let n=t+1,r=1;for(;n<i;){let t=br(e,n,i);if(null!=t){n=t;continue}let o=e[n];if("{"===o)r++;else if("}"===o&&(r--,0===r))return n;n++}return-1}function vr(e,t,i){let n=t;for(;n<i;){let t=e[n];if(xr(t))n++;else{if("/"!==t||"*"!==e[n+1])break;n=yr(e,n,i)}}return n}function yr(e,t,i){let n=e.indexOf("*/",t+2);return n<0||n+2>i?i:n+2}function br(e,t,i){let n=e[t];return'"'===n||"'"===n?function(e,t){let i=e[t],n=t+1;for(;n<e.length;){let t=e[n];if("\\"!==t){if(t===i)return n+1;n++}else n+=2}return e.length}(e,t):"/"===n&&"*"===e[t+1]?yr(e,t,i):null}function wr(e,t){return"\\"!==e[t]?null:t+1>=e.length?e.length:t+2}function xr(e){return" "===e||"\n"===e||"\r"===e||"\t"===e||"\f"===e}function Sr(e){let t="",i=0,n=!1;for(;i<e.length;){let r=br(e,i,e.length);if(null!=r&&"/"!==e[i]){n&&t.length>0&&(t+=" ",n=!1),t+=e.slice(i,r),i=r;continue}if(null!=r){n=t.length>0,i=r;continue}let o=e[i];xr(o)?(n=t.length>0,i++):(n&&t.length>0&&(t+=" ",n=!1),t+=o,i++)}return t}function Cr(e){if((e=e.substr(1)).match(/^[^0-9a-fA-F\n\r]$/))return e;let t=parseInt(e,16);return isNaN(t)?"":0===t||t>=55296&&t<=57343||t>1114111?"�":String.fromCodePoint(t)}function kr(e){return e.replace(/\\([0-9a-fA-F]{1,6}(\r\n|[ \n\r\t\f])?|[^0-9a-fA-F\n\r])/g,Cr)}var Pr=class{constructor(){h(this,"type"),h(this,"precededBySpace",!1),h(this,"num",0),h(this,"text",""),h(this,"position",0),this.type=0}toString(){switch(this.type){case 10:return"(";case 11:return")";case 12:return"{";case 13:return"}";case 14:return"[";case 15:return"]";case 16:return",";case 17:return";";case 18:return":";case 19:return"/";case 21:return"%";case 22:return"?";case 23:return"+";case 24:return"-";case 25:return"||";case 26:return"&&";case 31:return"!";case 32:return"$";case 33:return"^";case 34:return"|";case 35:return"~";case 36:return"*";case 37:return">";case 38:return"<";case 39:return"=";case 41:return"!=";case 42:return"$=";case 43:return"^=";case 44:return"|=";case 45:return"~=";case 46:return"*=";case 47:return">=";case 48:return"<=";case 49:return"==";case 50:return"::";case 51:return"\x3c!--";case 52:return"--\x3e";case 3:return this.num.toString()+this.text;case 4:case 5:return this.num.toString();case 20:return"@"+this.text;case 7:return"#"+this.text;case 6:return this.text+"(";case 9:return"."+this.text;case 0:return"/*EOF*/";default:return this.text}}};function Er(e,t){let i,n=Array(128);for(i=0;i<128;i++)n[i]=e;for(n.NaN=35==e?35:72,i=0;i<t.length;i+=2)n[t[i]]=t[i+1];return n}var Nr=[72,72,72,72,72,72,72,72,72,1,1,72,1,1,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,1,4,34,6,7,8,9,33,10,11,12,13,14,15,16,17,2,2,2,2,2,2,2,2,2,2,18,19,20,21,22,23,24,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,25,29,26,30,3,72,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,27,31,28,32,72];Nr.NaN=80;var Tr=[43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43,52,43,43,43,43,39,43,43,39,39,39,39,39,39,39,39,39,39,43,43,43,43,43,43,43,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,43,44,43,43,39,43,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,43,43,43,43,43];Tr.NaN=43;var Ir=[72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,72,78,59,72,59,59,59,59,59,59,59,59,59,59,72,72,72,72,72,72,72,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,72,61,72,72,78,72,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,78,72,72,72,72,72];Tr.NaN=43;var Ar=[35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,57,59,35,58,58,58,58,58,58,58,58,58,58,35,35,35,35,35,35,35,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,35,61,35,35,60,35,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,35,35,35,35,35];Ar.NaN=35;var Fr=[45,45,45,45,45,45,45,45,45,73,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,73,45,45,45,45,45,45,45,53,45,45,45,45,45,45,45,39,39,39,39,39,39,39,39,39,39,45,45,45,45,45,45,45,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,45,44,45,45,39,45,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,45,45,45,45,45];Fr.NaN=45;var Rr=[37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,41,37,37,37,37,37,37,37,37,42,37,39,39,39,39,39,39,39,39,39,39,37,37,37,37,37,37,37,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,37,37,37,37,40,37,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,37,37,37,37,37];Rr.NaN=37;var Or=[38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,41,38,38,38,38,38,38,38,38,38,38,39,39,39,39,39,39,39,39,39,39,38,38,38,38,38,38,38,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,38,38,38,38,40,38,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,38,38,38,38,38];Or.NaN=38;var Lr=Er(35,[61,36]),_r=Er(35,[58,77]),Br=Er(35,[61,36,124,50]),Mr=Er(35,[38,51]),Dr=Er(35,[42,54]),zr=Er(39,[42,55]),Vr=Er(54,[42,55,47,56]),Ur=Er(62,[62,82]),Hr=Er(35,[61,36,33,70]),$r=Er(62,[45,71]),jr=Er(63,[45,81]),Wr=Er(76,[10,72,13,72]),Gr=Er(39,[39,46,10,72,13,72,92,48]),qr=Er(39,[34,46,10,72,13,72,92,49]),Xr=Er(39,[39,47,10,74,13,74,92,48]),Yr=Er(39,[34,47,10,74,13,74,92,49]),Kr=Er(64,[9,39,32,39,34,66,39,65,41,72,10,39,13,39]),Zr=Er(39,[41,67,9,79,10,79,13,79,32,79,92,75,40,72,91,72,93,72,123,72,125,72,NaN,67]),Jr=Er(39,[39,68,10,74,13,74,92,75,NaN,67]),Qr=Er(39,[34,68,10,74,13,74,92,75,NaN,67]),eo=Er(72,[9,39,10,39,13,39,32,39,41,69]),to=class{constructor(e,t){h(this,"input",e),h(this,"handler",t),h(this,"indexMask"),h(this,"buffer"),h(this,"tail",0),h(this,"curr",0),h(this,"position",0),this.indexMask=15,this.buffer=Array(this.indexMask+1);for(let e=0;e<=this.indexMask;e++)this.buffer[e]=new Pr}token(){return this.tail==this.curr&&this.fillBuffer(),this.buffer[this.curr]}nthToken(e){return(this.tail-this.curr&this.indexMask)<=e&&this.fillBuffer(),this.buffer[this.curr+e&this.indexMask]}consume(){this.curr=this.curr+1&this.indexMask}fillBuffer(){let e=this.tail,t=this.curr,i=this.indexMask;if(e>=t?t+=i:t--,t==e)throw new Error("F_CSSTOK_INTERNAL");let n=Nr,r=this.input,o=this.position,s=this.buffer,a=0,l=0,h="",u=0,c=!1,d=s[e],p=-9;for(;;){let f=r.charCodeAt(o);switch(n[f]||n[65]){case 72:isNaN(f)?(h=r.substring(l,o),a=0):n===Nr&&0===a?(a=54,l=o,h=r.substring(o,o+1),o++):(h=r.substring(l,o),a=54),n=Nr;break;case 1:o++,c=!0;continue;case 2:l=o++,n=Rr;continue;case 3:a=1,l=o++,n=Tr;continue;case 4:l=o++,a=31,n=Lr;continue;case 33:a=2,l=++o,n=Gr;continue;case 34:a=2,l=++o,n=qr;continue;case 6:l=++o,a=7,n=Tr;continue;case 7:l=o++,a=32,n=Lr;continue;case 8:l=o++,a=21;break;case 9:l=o++,a=32,n=Mr;continue;case 10:l=o++,a=10;break;case 11:l=o++,a=11;break;case 12:l=o++,a=36,n=Lr;continue;case 13:l=o++,a=23;break;case 14:l=o++,a=16;break;case 15:a=24,l=o++,n=Ar;continue;case 16:l=o++,n=Ir;continue;case 78:l=o++,a=9,n=Tr;continue;case 17:l=o++,a=19,n=Dr;continue;case 18:l=o++,a=18,n=_r;continue;case 77:o++,a=50;break;case 19:l=o++,a=17;break;case 20:l=o++,a=38,n=Hr;continue;case 21:l=o++,a=39,n=Lr;continue;case 22:l=o++,a=37,n=Lr;continue;case 23:l=o++,a=22;break;case 24:l=++o,a=20,n=Tr;continue;case 25:l=o++,a=14;break;case 26:l=o++,a=15;break;case 27:l=o++,a=12;break;case 28:l=o++,a=13;break;case 29:l=o++,p=l,a=1,n=Wr;continue;case 30:l=o++,a=33,n=Lr;continue;case 31:l=o++,a=34,n=Br;continue;case 32:l=o++,a=35,n=Lr;continue;case 35:break;case 36:o++,a=a+41-31;break;case 37:a=5,u=parseInt(r.substring(l,o),10);break;case 38:a=4,u=parseFloat(r.substring(l,o));break;case 39:o++;continue;case 40:a=3,u=parseFloat(r.substring(l,o)),l=o++,n=Tr;continue;case 41:a=3,u=parseFloat(r.substring(l,o)),h="%",l=o++;break;case 42:o++,n=Or;continue;case 43:if(h=kr(r.substring(l,o)),27===a&&63===f||1===a&&"u"===h.toLowerCase()&&/^(\bu\+[?0-9a-f]+(-[?0-9a-f]+)?|,|\s+|\/\*([^*]|\*[^/])*\*\/)+[;}]/i.test(r.substring(o-1))){a=27,o++;continue}break;case 44:p=o++,n=Wr;continue;case 45:h=kr(r.substring(l,o));break;case 46:h=r.substring(l,o),o++;break;case 47:h=kr(r.substring(l,o)),o++;break;case 48:p=o,o+=2,n=Xr;continue;case 49:p=o,o+=2,n=Yr;continue;case 50:o++,a=25;break;case 51:o++,a=26;break;case 52:if(h=r.substring(l,o),1==a){if(o++,"url"==h.toLowerCase()){n=Kr;continue}a=6}break;case 53:if(h=kr(r.substring(l,o)),1==a){if(o++,"url"==h.toLowerCase()){n=Kr;continue}a=6}break;case 54:n=zr,o++;continue;case 55:n=Vr,o++;continue;case 56:n=Nr,o++;continue;case 57:n=Ur,o++,">"!==r[o]&&(a=1,n=Tr);continue;case 81:a=51,h=r.substring(l,++o),n=Nr;break;case 82:a=52,h=r.substring(l,++o),n=Nr;break;case 58:a=5,n=Rr,o++;continue;case 59:a=4,n=Or,o++;continue;case 60:a=1,n=Tr,o++;continue;case 61:a=1,n=Wr,p=o++;continue;case 62:o--;break;case 63:o-=2;break;case 64:l=o++,n=Zr;continue;case 65:l=++o,n=Jr;continue;case 66:l=++o,n=Qr;continue;case 67:a=8,h=kr(r.substring(l,o)),o++;break;case 69:o++;break;case 70:n=$r,o++;continue;case 71:n=jr,o++;continue;case 79:if(o-p<8&&r.substring(p+1,o+1).match(/^[0-9a-fA-F]{0,6}(\r\n|[\n\r])|[ \t]$/)){o++;continue}case 68:a=8,h=kr(r.substring(l,o)),o++,n=eo;continue;case 74:if(o++,o-p<9&&r.substring(p+1,o).match(/^[0-9a-fA-F]{0,6}(\r\n|[\n\r])$/))continue;a=54,h="E_CSS_UNEXPECTED_NEWLINE",n=Nr;break;case 73:if(o-p<9&&r.substring(p+1,o+1).match(/^[0-9a-fA-F]{0,6}[ \t]$/)){o++,n=Tr;continue}h=kr(r.substring(l,o));break;case 75:p=o++;continue;case 76:o++,n=Fr;continue;default:if(n!==Nr){a=54,h="E_CSS_UNEXPECTED_STATE";break}l=o,a=0}if(d.type=a,d.precededBySpace=c,d.num=u,d.text=h,d.position=l,e++,e>=t)break;n=Nr,c=!1,a=0,l=o,h="",u=0,d=s[e&i]}this.position=o,this.tail=e&i}},io=null,no=null;function ro(){return io}function oo(e){if(!io)throw new Error("E_TASK_NO_CONTEXT");io.name||(io.name=e);let t=io,i=new mo(t,t.top,e);return t.top=i,i.state=1,i}function so(e){return new fo(e)}function ao(e,t,i){let n=oo(e);n.handler=i;try{t(n)}catch(e){n.task.raise(e,n)}return n.result()}function lo(e,t){return(io?io.getScheduler():no||function(e){return new uo(e||new ho)}()).run(e,t)}var ho=class{currentTime(){return(new Date).valueOf()}setTimeout(e,t){return setTimeout(e,t)}clearTimeout(e){clearTimeout(e)}},uo=class{constructor(e){h(this,"timer",e),h(this,"timeout",1),h(this,"slice",25),h(this,"sliceOverTime",0),h(this,"queue"),h(this,"wakeupTime",null),h(this,"timeoutToken",null),h(this,"inTimeSlice",!1),h(this,"order",0),this.queue=new ge,no||(no=this)}setSlice(e){this.slice=e}setTimeout(e){this.timeout=e}isTimeSliceOver(){return this.timer.currentTime()>=this.sliceOverTime}arm(){if(this.inTimeSlice)return;let e=this.queue.peek().scheduledTime,t=this.timer.currentTime();if(null!=this.timeoutToken){if(t+this.timeout>this.wakeupTime)return;this.timer.clearTimeout(this.timeoutToken)}let i=e-t;i<=this.timeout&&(i=this.timeout),this.wakeupTime=t+i,this.timeoutToken=this.timer.setTimeout(()=>{this.timeoutToken=null,this.doTimeSlice()},i)}schedule(e,t){let i=this.timer.currentTime();e.order=this.order++,e.scheduledTime=i+(t||0),this.queue.add(e),this.arm()}doTimeSlice(){null!=this.timeoutToken&&(this.timer.clearTimeout(this.timeoutToken),this.timeoutToken=null),this.inTimeSlice=!0;try{let e=this.timer.currentTime();for(this.sliceOverTime=e+this.slice;this.queue.length();){let t=this.queue.peek();if(t.scheduledTime>e||(this.queue.remove(),t.canceled||t.resumeInternal(),e=this.timer.currentTime(),e>=this.sliceOverTime))break}}catch(e){R.error(e)}this.inTimeSlice=!1,this.queue.length()&&this.arm()}run(e,t){let i=new po(this,t||"");i.top=new mo(i,null,"bootstrap"),i.top.state=1,i.top.then(()=>{let t=()=>{i.running=!1;for(let e of i.callbacks)try{e()}catch(e){R.error(e)}};try{e().then(e=>{i.result=e,t()})}catch(e){i.raise(e),t()}});let n=io;return io=i,this.schedule(i.top.suspend("bootstrap")),io=n,i}},co=class{constructor(e){h(this,"task",e),h(this,"scheduledTime",0),h(this,"order",0),h(this,"result",null),h(this,"canceled",!1)}compare(e){let t=e;return t.scheduledTime-this.scheduledTime||t.order-this.order}getTask(){return this.task}schedule(e,t){this.result=e;let i=this.task;i&&i.scheduler.schedule(this,t)}resumeInternal(){let e=this.task;if(this.task=null,e&&e.continuation==this){e.continuation=null;let t=io;return io=e,e.top.finish(this.result),io=t,!0}return!1}cancel(){this.canceled=!0}},po=class{constructor(e,t){h(this,"scheduler",e),h(this,"name",t),h(this,"callbacks",[]),h(this,"exception",null),h(this,"running",!0),h(this,"result",null),h(this,"waitTarget",null),h(this,"top",null),h(this,"continuation",null)}getName(){return this.name}interrupt(e){if(this.raise(e||new Error("E_TASK_INTERRUPT")),this!==io&&this.continuation){this.continuation.cancel();let e=new co(this);this.waitTarget="interrupt",this.continuation=e,this.scheduler.schedule(e)}}getScheduler(){return this.scheduler}isRunning(){return this.running}whenDone(e){this.callbacks.push(e)}join(){let e=oo("Task.join");if(this.running){let t=e.suspend(this);this.whenDone(()=>{t.schedule(this.result)})}else e.finish(this.result);return e.result()}unwind(){for(;this.top&&!this.top.handler;)this.top=this.top.parent;if(this.top&&this.top.handler&&this.exception){let e=this.exception;this.exception=null,this.top.handler(this.top,e)}else this.exception&&R.error(this.exception,"Unhandled exception in task",this.name)}raise(e,t){if(this.fillStack(e),t){let e=this.top;for(;e&&e!=t;)e=e.parent;e==t&&(this.top=e)}this.exception=e,this.unwind()}fillStack(e){let t=e.frameTrace;if(!t){t=e.stack?`${e.stack}\n\t---- async ---\n`:"";for(let e=this.top;e;e=e.parent)t+="\t",t+=e.getName(),t+="\n";e.frameTrace=t}}},fo=class e{constructor(e){h(this,"value",e)}then(e){e(this.value)}thenAsync(e){return e(this.value)}thenReturn(t){return new e(t)}thenFinish(e){e.finish(this.value)}isPending(){return!1}get(){return this.value}},go=class{constructor(e){h(this,"frame",e)}then(e){this.frame.then(e)}thenAsync(e){if(this.isPending()){let t=new mo(this.frame.task,this.frame.parent,"AsyncResult.thenAsync");return t.state=1,this.frame.parent=t,this.frame.then(i=>{e(i).then(e=>{t.finish(e)})}),t.result()}return e(this.frame.res)}thenReturn(e){return this.isPending()?this.thenAsync(()=>new fo(e)):new fo(e)}thenFinish(e){this.isPending()?this.then(t=>{e.finish(t)}):e.finish(this.frame.res)}isPending(){return 1==this.frame.state}get(){if(this.isPending())throw new Error("Result is pending");return this.frame.res}},mo=class{constructor(e,t,i){h(this,"task",e),h(this,"parent",t),h(this,"name",i),h(this,"res",null),h(this,"state"),h(this,"callback",null),h(this,"handler",null),this.state=0}checkEnvironment(){if(!io)throw new Error("F_TASK_NO_CONTEXT");if(this!==io.top)throw new Error("F_TASK_NOT_TOP_FRAME")}result(){return new go(this)}finish(e){this.checkEnvironment(),io&&!io.exception&&(this.res=e),this.state=2;let t=this.parent;if(io&&(io.top=t),this.callback){try{this.callback(e)}catch(e){this.task.raise(e,t)}this.state=3}}getTask(){return this.task}getName(){return this.name}getScheduler(){return this.task.scheduler}then(e){switch(this.state){case 1:if(this.callback)throw new Error("F_TASK_FRAME_ALREADY_HAS_CALLBACK");this.callback=e;break;case 2:{let t=this.task,i=this.parent;try{e(this.res),this.state=3}catch(e){this.state=3,t.raise(e,i)}break}case 3:throw new Error("F_TASK_DEAD_FRAME");default:throw new Error(`F_TASK_UNEXPECTED_FRAME_STATE ${this.state}`)}}timeSlice(){let e=oo("Frame.timeSlice");return e.getScheduler().isTimeSliceOver()?(R.debug("-- time slice --"),e.suspend().schedule(!0)):e.finish(!0),e.result()}sleep(e){let t=oo("Frame.sleep");return t.suspend().schedule(!0,e),t.result()}loop(e){let t=oo("Frame.loop"),i=n=>{try{for(;n;){let t=e();if(t.isPending())return void t.then(i);t.then(e=>{n=e})}t.finish(!0)}catch(e){t.task.raise(e,t)}};return i(!0),t.result()}loopWithFrame(e){let t=io;if(!t)throw new Error("E_TASK_NO_CONTEXT");return this.loop(()=>{let i;do{let n=new vo(t,t.top);t.top=n,n.state=1,e(n),i=n.result()}while(!i.isPending()&&i.get());return i})}suspend(e){if(this.checkEnvironment(),this.task.continuation)throw new Error("E_TASK_ALREADY_SUSPENDED");let t=new co(this.task);return this.task.continuation=t,io=null,this.task.waitTarget=e||null,t}},vo=class extends mo{constructor(e,t){super(e,t,"loop")}continueLoop(){this.finish(!0)}breakLoop(){this.finish(!1)}},yo=class{constructor(e,t){h(this,"fetch",e),h(this,"name"),h(this,"arrived",!1),h(this,"resource",null),h(this,"task",null),h(this,"piggybacks",[]),this.name=t}start(){this.task||(this.task=ro().getScheduler().run(()=>{let e=oo("Fetcher.run");return this.fetch().then(t=>{let i=this.piggybacks;if(this.arrived=!0,this.resource=t,this.task=null,this.piggybacks=[],i)for(let e=0;e<i.length;e++)try{i[e](t)}catch(e){R.error(e,"Error:")}e.finish(t)}),e.result()},this.name))}piggyback(e){this.arrived?e(this.resource):this.piggybacks.push(e)}get(){return this.arrived?so(this.resource):(this.start(),this.task.join())}hasArrived(){return this.arrived}},bo=e=>{if(0==e.length)return so(!0);if(1==e.length)return e[0].get().thenReturn(!0);let t=oo("waitForFetches"),i=0;return t.loop(()=>{for(;i<e.length;){let t=e[i++];if(!t.hasArrived())return t.get().thenReturn(!0)}return so(!1)}).then(()=>{t.finish(!0)}),t.result()},wo='\n@media screen {\n [data-vivliostyle-viewer-viewport] {\n background: #aaaaaa;\n }\n\n [data-vivliostyle-page-container] {\n background: white;\n z-index: 0;\n }\n\n [data-vivliostyle-viewer-viewport] {\n box-sizing: border-box;\n display: flex;\n overflow: auto;\n position: relative;\n }\n\n [data-vivliostyle-outer-zoom-box] {\n margin: auto;\n overflow: hidden;\n flex: none;\n }\n\n [data-vivliostyle-viewer-viewport] [data-vivliostyle-spread-container] {\n display: flex;\n flex: none;\n justify-content: center;\n transform-origin: left top;\n }\n\n [data-vivliostyle-viewer-viewport][data-vivliostyle-page-progression="ltr"]\n [data-vivliostyle-spread-container] {\n flex-direction: row;\n }\n\n [data-vivliostyle-viewer-viewport][data-vivliostyle-page-progression="rtl"]\n [data-vivliostyle-spread-container] {\n flex-direction: row-reverse;\n }\n\n [data-vivliostyle-spread-container] [data-vivliostyle-page-container] {\n margin: 0 auto;\n flex: none;\n transform-origin: center top;\n }\n\n [data-vivliostyle-viewer-viewport][data-vivliostyle-spread-view="true"]\n [data-vivliostyle-spread-container]\n [data-vivliostyle-page-container][data-vivliostyle-page-side="left"] {\n margin-right: 1px;\n transform-origin: right top;\n }\n\n [data-vivliostyle-viewer-viewport][data-vivliostyle-spread-view="true"]\n [data-vivliostyle-spread-container]\n [data-vivliostyle-page-container][data-vivliostyle-page-side="right"] {\n margin-left: 1px;\n transform-origin: left top;\n }\n\n [data-vivliostyle-viewer-viewport][data-vivliostyle-spread-view="true"]\n [data-vivliostyle-spread-container]\n [data-vivliostyle-page-container][data-vivliostyle-unpaired-page="true"] {\n margin-left: auto;\n margin-right: auto;\n transform-origin: center top;\n }\n}\n',xo="\n[data-vivliostyle-layout-box] {\n position: absolute;\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n overflow: hidden;\n z-index: -1;\n transform-origin: left top;\n}\n\n[data-vivliostyle-debug] [data-vivliostyle-layout-box] {\n right: auto;\n bottom: auto;\n z-index: auto;\n overflow: visible;\n}\n\n[data-vivliostyle-layout-box] [data-vivliostyle-page-container] {\n margin: 0 auto 0 0;\n}\n\n[data-vivliostyle-spread-container] {\n transform: scale(var(--viv-outputScale,1));\n transform-origin: left top;\n}\n\n/* Emulate high pixel ratio using zoom & transform:scale() */\n@supports (zoom: 8) {\n [data-vivliostyle-layout-box] {\n zoom: calc(var(--viv-outputPixelRatio,1) / var(--viv-devicePixelRatio,1));\n transform: scale(calc(var(--viv-devicePixelRatio,1) / var(--viv-outputPixelRatio,1)));\n }\n [data-vivliostyle-spread-container] {\n zoom: calc(var(--viv-outputPixelRatio,1) / var(--viv-devicePixelRatio,1));\n transform: scale(calc(var(--viv-outputScale,1) * var(--viv-devicePixelRatio,1) / var(--viv-outputPixelRatio,1)));\n }\n /* Workaround for Chromium's default border etc. widths not zoomed but scaled down */\n [data-vivliostyle-spread-container] :where([style*=border],[style*=outline],[style*=rule]) {\n border-width: medium;\n outline-width: medium;\n column-rule-width: medium;\n }\n [data-vivliostyle-spread-container] ::-webkit-scrollbar {\n width: 8px;\n height: 8px;\n }\n [data-vivliostyle-spread-container] ::-webkit-scrollbar-track {\n background-color: #f4f4f4;\n }\n [data-vivliostyle-spread-container] ::-webkit-scrollbar-thumb {\n border-radius: 4px;\n background: #c7c7c7;\n }\n [data-vivliostyle-spread-container] ::-webkit-scrollbar-thumb:hover {\n background: #7d7d7d;\n }\n}\n\n[data-vivliostyle-page-container] {\n position: relative;\n}\n\n[data-vivliostyle-bleed-box] {\n position: absolute;\n overflow: hidden;\n background-origin: content-box !important;\n}\n\n[data-vivliostyle-page-box] ~ [data-vivliostyle-page-box] {\n display: none;\n}\n\n[data-vivliostyle-toc-box] {\n position: absolute;\n left: 3px;\n top: 3px;\n overflow: scroll;\n overflow-x: hidden;\n background: rgba(248, 248, 248, 0.9);\n border-radius: 2px;\n box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.4);\n}\n\n@media print {\n [data-vivliostyle-toc-box] {\n display: none;\n }\n\n [data-vivliostyle-outer-zoom-box],\n [data-vivliostyle-spread-container] {\n width: 100% !important;\n height: 100% !important;\n }\n\n [data-vivliostyle-spread-container] {\n --viv-outputScale: 1 !important;\n --viv-devicePixelRatio: 1 !important;\n zoom: normal !important;\n transform: none !important;\n print-color-adjust: exact;\n }\n\n @supports (zoom: 8) {\n [data-vivliostyle-spread-container] [data-vivliostyle-page-container] {\n zoom: var(--viv-outputPixelRatio,1);\n /* transform: scale(calc(1 / var(--viv-outputPixelRatio,1))); */\n /* Use matrix instead of scale (Workaround for issue #1555) */\n transform: matrix(calc(1 / var(--viv-outputPixelRatio,1)), 0, 5e-324, calc(1 / var(--viv-outputPixelRatio,1)), 0, 0);\n transform-origin: left top;\n }\n }\n\n [data-vivliostyle-spread-container] [data-vivliostyle-page-container] {\n display: block !important;\n max-height: 100vh;\n }\n\n [data-vivliostyle-spread-container] [data-vivliostyle-page-container]:not(:last-child) {\n break-after: page;\n }\n}\n",So="\n/*\n * Copyright 2013 Google, Inc.\n * Copyright 2015 Daishinsha Inc.\n * Copyright 2019 Vivliostyle Foundation\n *\n * CSS property validation.\n */\nNUM = POS_NUM | ZERO | NEGATIVE;\nNNEG_NUM = POS_NUM | ZERO;\nINT = POS_INT | ZERO | NEGATIVE;\nNNEG_INT = POS_INT | ZERO;\nPERCENTAGE = POS_PERCENTAGE | ZERO | NEGATIVE;\nSTRICT_PERCENTAGE = POS_PERCENTAGE | ZERO_PERCENTAGE | NEGATIVE;\nNNEG_PERCENTAGE = POS_PERCENTAGE | ZERO;\nLENGTH = POS_LENGTH | ZERO | NEGATIVE;\nNNEG_LENGTH = POS_LENGTH | ZERO;\nPLENGTH = LENGTH | PERCENTAGE;\nPPLENGTH = POS_LENGTH | ZERO | POS_PERCENTAGE;\nALENGTH = LENGTH | auto;\nAPLENGTH = PLENGTH | auto;\nPAPLENGTH = PPLENGTH | auto;\nANGLE = POS_ANGLE | ZERO | NEGATIVE;\nLENGTH_OR_NUM = LENGTH | NUM;\nANGLE_OR_NUM = ANGLE | NUM;\nMIN_MAX_FIT_CONTENT = min-content | max-content | fit-content;\nBG_POSITION_TERM = PLENGTH | left | center | right | top | bottom;\nURI_OR_NONE = URI | none;\nIMAGE = URI | IMAGE_FUNCTION | none;\nbackground-attachment = COMMA( [scroll | fixed | local]+ );\nbackground-color = COLOR;\nbackground-image = COMMA( IMAGE+ );\nbackground-position = COMMA( SPACE(BG_POSITION_TERM{1,4})+ ); /* relaxed */\nbackground-repeat = COMMA( [repeat | repeat-x | repeat-y | no-repeat]+ );\nborder-collapse = collapse | separate;\nBORDER_SIDE_COLOR = COLOR;\nBORDER_SIDE_STYLE = none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset;\nBORDER_SIDE_WIDTH = thin: 1px | medium: 3px | thick: 5px | NNEG_LENGTH;\nborder-spacing = LENGTH LENGTH?;\nborder-top-color = BORDER_SIDE_COLOR;\nborder-right-color = BORDER_SIDE_COLOR;\nborder-bottom-color = BORDER_SIDE_COLOR;\nborder-left-color = BORDER_SIDE_COLOR;\nborder-top-style = BORDER_SIDE_STYLE;\nborder-right-style = BORDER_SIDE_STYLE;\nborder-bottom-style = BORDER_SIDE_STYLE;\nborder-left-style = BORDER_SIDE_STYLE;\nborder-top-width = BORDER_SIDE_WIDTH;\nborder-right-width = BORDER_SIDE_WIDTH;\nborder-bottom-width = BORDER_SIDE_WIDTH;\nborder-left-width = BORDER_SIDE_WIDTH;\nBORDER_RADIUS = PLENGTH{1,2};\nborder-top-left-radius = BORDER_RADIUS;\nborder-top-right-radius = BORDER_RADIUS;\nborder-bottom-right-radius = BORDER_RADIUS;\nborder-bottom-left-radius = BORDER_RADIUS;\nborder-image-source = IMAGE;\nborder-image-slice = [NUM | PERCENTAGE]{1,4} || fill; /* relaxed */\nborder-image-width = [NUM | PLENGTH | auto]{1,4};\nborder-image-outset = [NUM | LENGTH]{1,4};\nborder-image-repeat = [ stretch | repeat | round | space ]{1,2};\nbottom = APLENGTH;\ncaption-side = top | bottom;\nclip = rect(ALENGTH{4}) | rect(SPACE(ALENGTH{4})) | auto;\ncolor = COLOR;\nLIST_STYLE_TYPE = IDENT;\nCONTENT_LIST = [ STRING | URI | counter(IDENT LIST_STYLE_TYPE?) |\n counters(IDENT STRING LIST_STYLE_TYPE?) | ATTR |\n target-counter([ STRING | URI ] IDENT LIST_STYLE_TYPE?) |\n target-counter(ATTR IDENT LIST_STYLE_TYPE?) |\n target-counters([ STRING | URI ] IDENT STRING LIST_STYLE_TYPE?) |\n target-counters(ATTR IDENT STRING LIST_STYLE_TYPE?) |\n target-text([ STRING | URI ] [content | before | after | first-letter | marker]?) |\n target-text(ATTR [content | before | after | first-letter | marker]?) |\n leader([ dotted | solid | space ] | STRING ) |\n open-quote | close-quote | no-open-quote | no-close-quote |\n content([ text | before | after | first-letter | marker ]?) |\n string(IDENT [first | start | last | first-except]?) |\n element(IDENT [first | start | last | first-except]?) ]+;\nCONTENT = normal | none | CONTENT_LIST;\ncontent = CONTENT;\nCOUNTER = [ IDENT INT? ]+ | none;\ncounter-increment = COUNTER;\ncounter-reset = COUNTER;\ncounter-set = COUNTER;\ncursor = COMMA(URI* [ auto | crosshair | default | pointer | move | e-resize | ne-resize | nw-resize |\n n-resize | se-resize | sw-resize | s-resize | w-resize | text | wait | help | progress ]);\ndirection = ltr | rtl;\ndisplay = inline | block | list-item | inline-block | table | inline-table | table-row-group |\n table-header-group | table-footer-group | table-row | table-column-group | table-column |\n table-cell | table-caption | none | oeb-page-head | oeb-page-foot | flex | inline-flex |\n ruby | ruby-base | ruby-text | ruby-base-container | ruby-text-container | run-in | compact | marker |\n flow-root | grid | inline-grid | contents;\nempty-cells = show | hide;\nFAMILY = SPACE(IDENT+) | STRING;\nFAMILY_LIST = COMMA( FAMILY+ );\nfont-family = FAMILY_LIST;\nfont-size = xx-small | x-small | small | medium | large | x-large | xx-large | larger | smaller | PPLENGTH;\nfont-style = normal | italic | oblique;\nfont-weight = normal | bold | bolder | lighter | POS_NUM;\nheight = PAPLENGTH | MIN_MAX_FIT_CONTENT;\nleft = APLENGTH;\nletter-spacing = normal | LENGTH_OR_NUM;\nline-height = normal | POS_NUM | PPLENGTH;\nlist-style-image = IMAGE;\nlist-style-position = inside | outside;\nlist-style-type = LIST_STYLE_TYPE | STRING | none;\nmargin-right = APLENGTH;\nmargin-left = APLENGTH;\nmargin-top = APLENGTH;\nmargin-bottom = APLENGTH;\nNPLENGTH = none | PLENGTH;\nmax-height = NPLENGTH | MIN_MAX_FIT_CONTENT;\nmax-width = NPLENGTH | MIN_MAX_FIT_CONTENT;\nmin-height = APLENGTH | MIN_MAX_FIT_CONTENT;\nmin-width = APLENGTH | MIN_MAX_FIT_CONTENT;\norphans = POS_INT;\noutline-offset = LENGTH;\noutline-color = COLOR | invert;\noutline-style = BORDER_SIDE_STYLE;\noutline-width = BORDER_SIDE_WIDTH;\noverflow = visible | hidden | scroll | auto | clip;\npadding-right = PPLENGTH;\npadding-left = PPLENGTH;\npadding-top = PPLENGTH;\npadding-bottom = PPLENGTH;\nPAGE_BREAK = auto | always | avoid | left | right | recto | verso;\npage-break-after = PAGE_BREAK;\npage-break-before = PAGE_BREAK;\npage-break-inside = avoid | auto;\nposition = static | relative | absolute | fixed | running(IDENT);\nquotes = [STRING STRING]+ | none | auto;\nright = APLENGTH;\ntable-layout = auto | fixed;\ntext-align = left | right | center | justify | start | end | match-parent | inside | outside;\ntext-indent = PLENGTH;\ntext-transform = capitalize | uppercase | lowercase | none;\ntop = APLENGTH;\nvertical-align = baseline | sub | super | top | text-top | middle | bottom | text-bottom | PLENGTH;\nvisibility = visible | hidden | collapse;\nwhite-space = normal | pre | nowrap | pre-wrap | pre-line | break-spaces;\nwidows = POS_INT;\nwidth = PAPLENGTH | MIN_MAX_FIT_CONTENT;\nword-spacing = normal | LENGTH_OR_NUM;\nz-index = auto | INT;\n\n[epub,moz,webkit]hyphens = auto | manual | none;\n[webkit]hyphenate-character = auto | STRING;\n\n/* css-logical */\nmargin-block-start = APLENGTH;\nmargin-block-end = APLENGTH;\nmargin-inline-start = APLENGTH;\nmargin-inline-end = APLENGTH;\npadding-block-start = APLENGTH;\npadding-block-end = APLENGTH;\npadding-inline-start = APLENGTH;\npadding-inline-end = APLENGTH;\nborder-block-start-color = BORDER_SIDE_COLOR;\nborder-block-end-color = BORDER_SIDE_COLOR;\nborder-inline-start-color = BORDER_SIDE_COLOR;\nborder-inline-end-color = BORDER_SIDE_COLOR;\nborder-block-start-style = BORDER_SIDE_STYLE;\nborder-block-end-style = BORDER_SIDE_STYLE;\nborder-inline-start-style = BORDER_SIDE_STYLE;\nborder-inline-end-style = BORDER_SIDE_STYLE;\nborder-block-start-width = BORDER_SIDE_WIDTH;\nborder-block-end-width = BORDER_SIDE_WIDTH;\nborder-inline-start-width = BORDER_SIDE_WIDTH;\nborder-inline-end-width = BORDER_SIDE_WIDTH;\nblock-start = APLENGTH;\nblock-end = APLENGTH;\ninline-start = APLENGTH;\ninline-end = APLENGTH;\nblock-size = PAPLENGTH | MIN_MAX_FIT_CONTENT;\ninline-size = PAPLENGTH | MIN_MAX_FIT_CONTENT;\nmax-block-size = NPLENGTH | MIN_MAX_FIT_CONTENT;\nmax-inline-size = NPLENGTH | MIN_MAX_FIT_CONTENT;\nmin-block-size = APLENGTH | MIN_MAX_FIT_CONTENT;\nmin-inline-size = APLENGTH | MIN_MAX_FIT_CONTENT;\n\nmargin-inside = auto | APLENGTH;\nmargin-outside = auto | APLENGTH;\npadding-inside = PPLENGTH;\npadding-outside = PPLENGTH;\nborder-inside-color = BORDER_SIDE_COLOR;\nborder-outside-color = BORDER_SIDE_COLOR;\nborder-inside-style = BORDER_SIDE_STYLE;\nborder-outside-style = BORDER_SIDE_STYLE;\nborder-inside-width = BORDER_SIDE_WIDTH;\nborder-outside-width = BORDER_SIDE_WIDTH;\ninside = APLENGTH;\noutside = APLENGTH;\n\nSHAPE = auto | rectangle( PLENGTH{4} ) | ellipse( PLENGTH{4} ) | circle( PLENGTH{3} ) |\n polygon( SPACE(PLENGTH+)+ );\n[epubx]shape-inside = SHAPE;\n[epubx,webkit]shape-outside = SHAPE;\n[epubx]wrap-flow = auto | both | start | end | maximum | clear | around /* epub al */;\n\nTRANSFORM_FUNCTION = matrix(NUM{6}) | translate(PLENGTH{1,2}) | translateX(PLENGTH) | translateY(PLENGTH) |\n scale(NUM{1,2}) | scaleX(NUM) | scaleY(NUM) | rotate(ANGLE) | skewX(ANGLE) | skewY(ANGLE);\n[epub]transform = none | TRANSFORM_FUNCTION+;\n[epub]transform-origin = [[[ top | bottom | left | right] PLENGTH?] | center | PLENGTH]{1,2}; /* relaxed */\n\nBOX = border-box | padding-box | content-box;\nSHADOW = SPACE(inset || LENGTH{2,4} || COLOR); /* relaxed */\n[webkit]background-size = COMMA( SPACE( [PLENGTH | auto ]{1,2} | cover | contain)+ );\n[webkit]background-origin = COMMA( BOX+ );\n[webkit]background-clip = COMMA( BOX+ );\n[webkit]box-shadow = none | COMMA( SHADOW+ );\ntext-shadow = none | COMMA( SHADOW+ );\n[webkit]box-decoration-break = slice | clone;\nFILTER_FUNCTION = blur(LENGTH) | brightness(NUM | PERCENTAGE) | contrast(NUM | PERCENTAGE) | drop-shadow(SPACE(LENGTH{2,3} COLOR?))\n | grayscale(NUM | PERCENTAGE) | hue-rotate(ANGLE) | invert(NUM | PERCENTAGE) | opacity(NUM | PERCENTAGE)\n | saturate(NUM | PERCENTAGE) | sepia(NUM | PERCENTAGE);\nFILTER_FUNCTION_LIST = FILTER_FUNCTION+;\n[webkit]filter = none | FILTER_FUNCTION_LIST;\n\nopacity = NUM;\n\n[moz,webkit]column-width = LENGTH | auto;\n[moz,webkit]column-count = INT | auto;\n[moz,webkit]column-gap = LENGTH | normal;\n[moz,webkit]column-rule-color = COLOR;\n[moz,webkit]column-rule-style = BORDER_SIDE_STYLE;\n[moz,webkit]column-rule-width = BORDER_SIDE_WIDTH;\nBREAK = auto | avoid | avoid-page | page | left | right | recto | verso | avoid-column | column | avoid-region | region;\nbreak-before = BREAK;\nbreak-after = BREAK;\nbreak-inside = auto | avoid | avoid-page | avoid-column | avoid-region;\n[webkit]column-span = none | auto | all;\n[moz]column-fill = auto | balance | balance-all;\nmargin-break = auto | keep | discard;\n\nsrc = COMMA([SPACE(URI format(STRING+)?) | local(FAMILY)]+); /* for font-face */\n\n[epubx,webkit]flow-from = IDENT;\n[epubx,webkit]flow-into = IDENT;\n[epubx]flow-linger = INT | none;\n[epubx]flow-priority = INT;\n[epubx]flow-options = none | [ exclusive || last || static ];\n[epubx]page = INT | auto | IDENT; /* page: IDENT is for CSS Paged Media */\n[epubx]min-page-width = LENGTH;\n[epubx]min-page-height = LENGTH;\n[epubx]required = true | false;\n[epubx]enabled = true | false;\n[epubx]conflicting-partitions = COMMA(IDENT+);\n[epubx]required-partitions = COMMA(IDENT+);\n[epubx]snap-height = LENGTH | none;\n[epubx]snap-width = LENGTH | none;\n[epubx]flow-consume = all | some;\n[epubx]utilization = NUM;\n[epubx]text-zoom = font-size | scale;\n\n[adapt]template = URI_OR_NONE | footnote;\n[adapt]behavior = IDENT;\n\n/* CSS Fonts */\nCOMMON_LIG_VALUES = [ common-ligatures | no-common-ligatures ];\nDISCRETIONARY_LIG_VALUES = [ discretionary-ligatures | no-discretionary-ligatures ];\nHISTORICAL_LIG_VALUES = [ historical-ligatures | no-historical-ligatures ];\nCONTEXTUAL_ALT_VALUES = [ contextual | no-contextual ];\nfont-variant-ligatures = normal | none | [ COMMON_LIG_VALUES || DISCRETIONARY_LIG_VALUES || HISTORICAL_LIG_VALUES || CONTEXTUAL_ALT_VALUES ];\nfont-variant-caps = normal | small-caps | all-small-caps | petite-caps | all-petite-caps | unicase | titling-caps;\nNUMERIC_FIGURE_VALUES = [ lining-nums | oldstyle-nums ];\nNUMERIC_SPACING_VALUES = [ proportional-nums | tabular-nums ];\nNUMERIC_FRACTION_VALUES = [ diagonal-fractions | stacked-fractions ];\nfont-variant-numeric = normal | [ NUMERIC_FIGURE_VALUES || NUMERIC_SPACING_VALUES || NUMERIC_FRACTION_VALUES || ordinal || slashed-zero ];\nEAST_ASIAN_VARIANT_VALUES = [ jis78 | jis83 | jis90 | jis04 | simplified | traditional ];\nEAST_ASIAN_WIDTH_VALUES = [ full-width | proportional-width ];\nfont-variant-east-asian = normal | [ EAST_ASIAN_VARIANT_VALUES || EAST_ASIAN_WIDTH_VALUES || ruby ];\nfont-variant_css2 = normal | small-caps; /* for font shorthand */\nfont-size-adjust = none | NNEG_NUM;\n[webkit]font-kerning = auto | normal | none;\nfont-feature-settings = COMMA( normal | SPACE( STRING [ on | off | INT ]? )+ );\nFONT_STRETCH_CSS3_VALUES = normal | wider | narrower | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded;\nfont-stretch = FONT_STRETCH_CSS3_VALUES | PERCENTAGE;\nfont-stretch_css3 = FONT_STRETCH_CSS3_VALUES; /* for font shorthand */\nfont-display = [ auto | block | swap | fallback | optional ];\nunicode-range = COMMA( URANGE+ );\n\n/* CSS Images */\nimage-resolution = RESOLUTION;\nobject-fit = fill | contain | cover | none | scale-down;\nobject-position = COMMA( SPACE(BG_POSITION_TERM{1,4})+ ); /* relaxed */\n\n/* CSS Paged Media */\nPAGE_SIZE = a10 | a9 | a8 | a7 | a6 | a5 | a4 | a3 | a2 | a1 | a0\n | b10 | b9 | b8 | b7 | b6 | b5 | b4 | b3 | b2 | b1 | b0\n | c10 | c9 | c8 | c7 | c6 | c5 | c4 | c3 | c2 | c1 | c0\n | jis-b10 | jis-b9 | jis-b8 | jis-b7 | jis-b6 | jis-b5 | jis-b4 | jis-b3 | jis-b2 | jis-b1 | jis-b0\n | letter | legal | ledger;\nbleed = auto | LENGTH;\nmarks = none | [ crop || cross ];\nsize = POS_LENGTH{1,2} | auto | [ PAGE_SIZE || [ portrait | landscape ] ];\ncrop-offset = auto | LENGTH;\ncrop-marks-line-color = auto | COLOR;\n\n/* CSS Page Floats */\nclear = none | left | right | top | bottom | inline-start | inline-end | block-start | block-end | inside | outside | both | all | same | column | region | page;\nfloat-reference = inline | column | region | page;\nfloat = none | footnote | [ block-start || block-end || inline-start || inline-end || snap-block || snap-inline || left || right || top || bottom || inside || outside ];\nfloat-min-wrap-block = PPLENGTH;\n\n/* CSS Ruby */\nruby-align = start | center | space-between | space-around;\nruby-position = over | under | inter-character;\n\n/* CSS Size Adjust */\n[moz,webkit]text-size-adjust = auto | none | POS_PERCENTAGE;\n\n/* CSS Text */\n[webkit]line-break = auto | loose | normal | strict | anywhere;\noverflow-wrap = normal | break-word | anywhere;\n[moz]tab-size = NNEG_INT | NNEG_LENGTH;\n[moz]text-align-last = auto | start | end | left | right | center | justify | inside | outside;\ntext-justify = auto | none | inter-word | inter-character;\nword-break = normal | keep-all | break-all | break-word;\ntext-spacing-trim = auto | normal | space-all | trim-both | trim-auto |\n [[ trim-start | space-start | space-first ] ||\n [ trim-end | space-end | allow-end ] ||\n [ trim-adjacent | space-adjacent ]];\ntext-autospace = normal | auto | no-autospace |\n [[ ideograph-alpha || ideograph-numeric || punctuation ] || [ insert | replace ]];\nhanging-punctuation = none | [ first || [ force-end | allow-end ] || last ];\n\n/* CSS Text Decoration */\n[webkit]text-decoration-color = COLOR;\n[webkit]text-decoration-line = none | [ underline || overline || line-through || blink ];\n[webkit]text-decoration-skip = none | [ objects || spaces || ink || edges || box-decoration ];\n[webkit]text-decoration-style = solid | double | dotted | dashed | wavy;\n[webkit]text-decoration-thickness = from-font | APLENGTH;\n[epub,webkit]text-emphasis-color = COLOR;\n[webkit]text-emphasis-position = [ over | under ] [ right | left ];\n[epub,webkit]text-emphasis-style = none | [[ filled | open ] || [ dot | circle | double-circle | triangle | sesame ]] | STRING;\n[webkit]text-underline-position = auto | [ under || [ left | right ]];\n\n[webkit]initial-letter = normal | [ POS_NUM POS_INT? ];\n\n/* CSS Transforms */\n[webkit]backface-visibility = visible | hidden;\n\n/* CSS UI */\n[moz,webkit]box-sizing = content-box | padding-box | border-box;\ntext-overflow = [clip | ellipsis | STRING]{1,2};\n\n/* CSS Writing Modes */\n[epub,webkit]text-combine = none | horizontal;\ntext-combine-upright = none | all; /* relaxed */\n[epub,webkit]text-orientation = mixed | upright | sideways-right | sideways-left | sideways | use-glyph-orientation /* the following values are kept for backward-compatibility */ | vertical-right | rotate-right | rotate-left | rotate-normal | auto;\nunicode-bidi = normal | embed | isolate | bidi-override | isolate-override | plaintext;\n[epub,webkit]writing-mode = horizontal-tb | vertical-rl | lr-tb | rl-tb | tb-rl | lr | rl | tb;\n\n/* CSS Flex box */\nFLEX_BASIS = content | PAPLENGTH;\nflex-direction = row | row-reverse | column | column-reverse;\nflex-wrap = nowrap | wrap | wrap-reverse;\norder = INT;\nflex-grow = NNEG_NUM;\nflex-shrink = NNEG_NUM;\nflex-basis = FLEX_BASIS;\nflex = none | [ [ NNEG_NUM NNEG_NUM? ] || FLEX_BASIS ];\njustify-content = flex-start | flex-end | center | space-between | space-around;\nalign-items = flex-start | flex-end | center | baseline | stretch;\nalign-self = auto | flex-start | flex-end | center | baseline | stretch;\nalign-content = flex-start | flex-end | center | space-between | space-around | stretch;\n\n/* Pointer Events */\ntouch-action = auto | none | [ pan-x || pan-y ] | manipulation;\n\n/* SVG 2 */\nOPACITY_VALUE = NUM | PERCENTAGE;\nDASH_ARRAY = COMMA( SPACE( [ LENGTH | PERCENTAGE | NUM ]+ )+ );\nPAINT = none | child | child(INT) | COLOR | SPACE( URI [none | COLOR]? ) | context-fill | context-stroke;\ncolor-interpolation = auto | sRGB | linearRGB;\ncolor-rendering = auto | optimizeSpeed | optimizeQuality;\nfill = PAINT;\nfill-opacity = OPACITY_VALUE;\nfill-rule = nonzero | evenodd;\nglyph-orientation-vertical = auto | NUM | ANGLE;\nimage-rendering = auto | optimizeSpeed | optimizeQuality | crisp-edges | pixelated;\nmarker-start = none | URI;\nmarker-mid = none | URI;\nmarker-end = none | URI;\npointer-events = bounding-box | visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all | none;\npaint-order = normal | [ fill || stroke || markers ];\nshape-rendering = auto | optimizeSpeed | crispEdges | geometricPrecision;\nstop-color = COLOR;\nstop-opacity = OPACITY_VALUE;\nstroke = PAINT;\nstroke-dasharray = none | DASH_ARRAY;\nstroke-dashoffset = PERCENTAGE | LENGTH_OR_NUM;\nstroke-linecap = butt | round | square;\nstroke-linejoin = miter | round | bevel;\nstroke-miterlimit = NUM;\nstroke-opacity = OPACITY_VALUE;\nstroke-width = PERCENTAGE | LENGTH_OR_NUM;\ntext-anchor = start | middle | end;\ntext-rendering = auto | optimizeSpeed | optimizeLegibility | geometricPrecision;\nvector-effect = none | SPACE( [ non-scaling-stroke | non-scaling-size | non-rotation | fixed-position ]+ [ viewport | screen ]? );\n\n/* SVG 1.1 */\nalignment-baseline = auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical;\nbaseline-shift = baseline | sub | super | PERCENTAGE | LENGTH_OR_NUM;\ndominant-baseline = auto | use-script | no-change | reset-size | ideographic | alphabetic | hanging | mathematical | central | middle | text-after-edge | text-before-edge;\nmask = none | URI;\n\n/* css-masking-1 */\nSHAPE_RADIUS = PLENGTH | closest-side | farthest-side;\nFILL_RULE = nonzero | evenodd;\nSHAPE_BOX = BOX | margin-box;\nGEOMETRY_BOX = SHAPE_BOX | fill-box | stroke-box | view-box;\nBASIC_SHAPE =\n inset( SPACE( PLENGTH{1,4} [ round PLENGTH{1,4} [ SLASH PLENGTH{1,4} ]? ]? ) )\n | circle( SPACE( [SHAPE_RADIUS]? [at BG_POSITION_TERM{1,4}]? ) )\n | ellipse( SPACE( SHAPE_RADIUS{2}? [at BG_POSITION_TERM{1,4}]? ) )\n | polygon( FILL_RULE? COMMA( SPACE( PLENGTH{2} )+ )+ );\n[webkit]clip-path = none | URI | [ BASIC_SHAPE || GEOMETRY_BOX ];\nclip-rule = nonzero | evenodd;\n\n/* filters */\nflood-color = COLOR;\nflood-opacity = OPACITY_VALUE;\nlighting-color = COLOR;\n\n/* compositing-1 */\nBLEND_MODE = normal | multiply | screen | overlay | darken | lighten | color-dodge | color-burn | hard-light | soft-light | difference | exclusion | hue | saturation | color | luminosity;\nmix-blend-mode = BLEND_MODE;\nisolation = auto | isolate;\nbackground-blend-mode = COMMA( BLEND_MODE+ );\n\n/* CSS GCPM */\nstring-set = COMMA( SPACE( IDENT CONTENT_LIST )+ | none );\nfootnote-display = block | inline | compact;\nfootnote-policy = auto | line;\n\n/* CSS Repeated Headers and Footers */\n[viv]repeat-on-break = auto | none | header | footer;\n\n/* Compatibility */\n[webkit]text-fill-color = COLOR;\n[webkit]text-stroke-color = COLOR;\n[webkit]text-stroke-width = BORDER_SIDE_WIDTH;\n\nDEFAULTS\n\nbackground-attachment: scroll;\nbackground-color: transparent;\nbackground-image: none;\nbackground-repeat: repeat;\nbackground-position: 0% 0%;\nbackground-clip: border-box;\nbackground-origin: padding-box;\nbackground-size: auto;\nborder-top-color: currentColor;\nborder-right-color: currentColor;\nborder-bottom-color: currentColor;\nborder-left-color: currentColor;\nborder-top-style: none;\nborder-right-style: none;\nborder-bottom-style: none;\nborder-left-style: none;\nborder-top-width: 3px;\nborder-right-width: 3px;\nborder-bottom-width: 3px;\nborder-left-width: 3px;\nborder-top-left-radius: 0;\nborder-top-right-radius: 0;\nborder-bottom-right-radius: 0;\nborder-bottom-left-radius: 0;\nborder-image-source: none;\nborder-image-slice: 100%;\nborder-image-width: 1;\nborder-image-outset: 0;\nborder-image-repeat: stretch;\ncolumn-count: auto;\ncolumn-gap: normal;\ncolumn-width: auto;\ncolumn-rule-color: currentColor;\ncolumn-rule-style: none;\ncolumn-rule-width: 3px;\ncolumn-fill: balance;\noutline-color: currentColor;\noutline-style: none;\noutline-width: 3px;\nflex-direction: row;\nflex-wrap: nowrap;\nfont-family: serif;\nfont-style: normal;\nfont-size: medium;\nfont-size-adjust: none;\nfont-kerning: auto;\nfont-feature-settings: normal;\nfont-variant-ligatures: normal;\nfont-variant-caps: normal;\nfont-variant-numeric: normal;\nfont-variant-east-asian: normal;\nfont-weight: normal;\nfont-stretch: normal;\nline-height: normal;\nlist-style-image: none;\nlist-style-position: outside;\nlist-style-type: disc;\nmargin-bottom: auto;\nmargin-left: auto;\nmargin-right: auto;\nmargin-top: auto;\npadding-bottom: auto;\npadding-left: auto;\npadding-right: auto;\npadding-top: auto;\ntext-autospace: normal;\ntext-emphasis-color: currentColor;\ntext-emphasis-style: none;\ntext-spacing-trim: normal;\ntext-stroke-color: currentColor;\ntext-stroke-width: 0;\nmarker-start: none;\nmarker-mid: none;\nmarker-end: none;\n\n/* css-logical */\nborder-block-start-color: currentColor;\nborder-block-end-color: currentColor;\nborder-inline-start-color: currentColor;\nborder-inline-end-color: currentColor;\nborder-inside-color: currentColor;\nborder-outside-color: currentColor;\nborder-block-start-style: none;\nborder-block-end-style: none;\nborder-inline-start-style: none;\nborder-inline-end-style: none;\nborder-inside-style: none;\nborder-outside-style: none;\nborder-block-start-width: 3px;\nborder-block-end-width: 3px;\nborder-inline-start-width: 3px;\nborder-inline-end-width: 3px;\nborder-inside-width: 3px;\nborder-outside-width: 3px;\n\nSHORTHANDS\n\nall = ALL;\nbackground = COMMA background-image [background-position [ / background-size ]] background-repeat\n background-attachment [background-origin background-clip] background-color; /* background-color is a special case, see the code */\nborder-top = border-top-width border-top-style border-top-color;\nborder-right = border-right-width border-right-style border-right-color;\nborder-bottom = border-bottom-width border-bottom-style border-bottom-color;\nborder-left = border-left-width border-left-style border-left-color;\nborder-inside = border-inside-width border-inside-style border-inside-color;\nborder-outside = border-outside-width border-outside-style border-outside-color;\nborder-width = INSETS border-top-width border-right-width border-bottom-width border-left-width;\nborder-style = INSETS border-top-style border-right-style border-bottom-style border-left-style;\nborder-color = INSETS border-top-color border-right-color border-bottom-color border-left-color;\nborder = border-width border-style border-color;\nborder-image = border-image-source border-image-slice [ / border-image-width [ / border-image-outset ] ]\n border-image-repeat;\nborder-radius = INSETS_SLASH border-top-left-radius border-top-right-radius\n border-bottom-right-radius border-bottom-left-radius;\n[moz,webkit]columns = column-width column-count;\n[moz,webkit]column-rule = column-rule-width column-rule-style column-rule-color;\nflex-flow = flex-direction flex-wrap;\noeb-column-number = column-count;\noutline = outline-width outline-style outline-color;\nlist-style = list-style-position list-style-type list-style-image;\nmargin = INSETS margin-top margin-right margin-bottom margin-left;\npadding = INSETS padding-top padding-right padding-bottom padding-left;\nfont = FONT font-style font-variant_css2 font-weight font-stretch_css3 /* font-size line-height font-family are special-cased */;\nfont-variant = font-variant-ligatures font-variant-caps font-variant-numeric font-variant-east-asian;\n[epub,webkit]text-emphasis = text-emphasis-style text-emphasis-color;\nmarker = INSETS marker-start marker-mid marker-end;\n[webkit]text-stroke = text-stroke-width text-stroke-color;\ntext-decoration = text-decoration-line text-decoration-color text-decoration-style text-decoration-thickness;\ntext-spacing = TEXT_SPACING text-autospace text-spacing-trim;\n\n/* css-logical */\nmargin-block = INSETS margin-block-start margin-block-end;\nmargin-inline = INSETS margin-inline-start margin-inline-end;\npadding-block = INSETS padding-block-start padding-block-end;\npadding-inline = INSETS padding-inline-start padding-inline-end;\nborder-block-width = INSETS border-block-start-width border-block-end-width;\nborder-block-style = INSETS border-block-start-style border-block-end-style;\nborder-block-color = INSETS border-block-start-color border-block-end-color;\nborder-inline-width = INSETS border-inline-start-width border-inline-end-width;\nborder-inline-style = INSETS border-inline-start-style border-inline-end-style;\nborder-inline-color = INSETS border-inline-start-color border-inline-end-color;\nborder-block = border-block-width border-block-style border-block-color;\nborder-inline = border-inline-width border-inline-style border-inline-color;\nborder-block-start = border-block-start-width border-block-start-style border-block-start-color;\nborder-block-end = border-block-end-width border-block-end-style border-block-end-color;\nborder-inline-start = border-inline-start-width border-inline-start-style border-inline-start-color;\nborder-inline-end = border-inline-end-width border-inline-end-style border-inline-end-color;\ninset-block-start = block-start;\ninset-block-end = block-end;\ninset-inline-start = inline-start;\ninset-inline-end = inline-end;\ninset-inside = inside;\ninset-outside = outside;\ninset-block = INSETS block-start block-end;\ninset-inline = INSETS inline-start inline-end;\ninset = INSETS top right bottom left;\n\n/* old names */\nword-wrap = overflow-wrap;\n[adapt,webkit]margin-before = margin-block-start;\n[adapt,webkit]margin-after = margin-block-end;\n[adapt,webkit]margin-start = margin-inline-start;\n[adapt,webkit]margin-end = margin-inline-end;\n[adapt,webkit]padding-before = padding-block-start;\n[adapt,webkit]padding-after = padding-block-end;\n[adapt,webkit]padding-start = padding-inline-start;\n[adapt,webkit]padding-end = padding-inline-end;\n[adapt,webkit]border-before-color = border-block-start-color;\n[adapt,webkit]border-after-color = border-block-end-color;\n[adapt,webkit]border-start-color = border-inline-start-color;\n[adapt,webkit]border-end-color = border-inline-end-color;\n[adapt,webkit]border-before-style = border-block-start-style;\n[adapt,webkit]border-after-style = border-block-end-style;\n[adapt,webkit]border-start-style = border-inline-start-style;\n[adapt,webkit]border-end-style = border-inline-end-style;\n[adapt,webkit]border-before-width = border-block-start-width;\n[adapt,webkit]border-after-width = border-block-end-width;\n[adapt,webkit]border-start-width = border-inline-start-width;\n[adapt,webkit]border-end-width = border-inline-end-width;\n[adapt,webkit]before = block-start;\n[adapt,webkit]after = block-end;\n[adapt,webkit]start = inline-start;\n[adapt,webkit]end = inline-end;\n\n",Co='\n<!DOCTYPE html>\n<html xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://www.pyroxy.com/ns/shadow">\n<head>\n<style><![CDATA[\n\n.-vivliostyle-footnote-content {\n float: footnote;\n --viv-semantic-footnote-content: 1;\n}\n\n.-vivliostyle-table-cell-container {\n display: block;\n}\n\n]]></style>\n</head>\n<body>\n\n<s:template id="footnote"><s:content/><s:include class="-vivliostyle-footnote-content"/></s:template>\n\n<s:template id="table-cell"><div data-vivliostyle-flow-root="true" class="-vivliostyle-table-cell-container"><s:content/></div></s:template>\n\n</body>\n</html>',ko='\n@namespace "http://www.w3.org/1999/xhtml";\n\n:root {\n hyphens: -epubx-expr(pref-hyphenate? "auto": "manual");\n}\n:root[data-vivliostyle-epub-spine-properties~="page-spread-left"] {\n break-before: left;\n}\n:root[data-vivliostyle-epub-spine-properties~="page-spread-right"] {\n break-before: right;\n}\n\n@footnote {\n margin-block-start: 0.5em;\n}\n@footnote ::before {\n border-block-start-width: 1px;\n border-block-start-style: solid;\n border-block-start-color: black;\n margin-block-end: 0.4em;\n margin-inline-start: 0;\n margin-inline-end: 60%;\n}\n\n/* default page master */\n@-epubx-page-master :background-host {\n @-epubx-partition :layout-host {\n -epubx-flow-from: body;\n top: -epubx-expr(header.margin-bottom-edge);\n bottom: -epubx-expr(page-height - footer.margin-top-edge);\n left: 0px;\n right: 0px;\n column-width: 25em;\n }\n @-epubx-partition footer :oeb-page-foot {\n writing-mode: horizontal-tb;\n -epubx-flow-from: oeb-page-foot;\n bottom: 0px;\n left: 0px;\n right: 0px;\n }\n @-epubx-partition header :oeb-page-head {\n writing-mode: horizontal-tb;\n -epubx-flow-from: oeb-page-head;\n top: 0px;\n left: 0px;\n right: 0px;\n }\n}\n\n@page {\n @top-left-corner {\n text-align: right;\n vertical-align: middle;\n }\n @top-left {\n text-align: left;\n vertical-align: middle;\n }\n @top-center {\n text-align: center;\n vertical-align: middle;\n }\n @top-right {\n text-align: right;\n vertical-align: middle;\n }\n @top-right-corner {\n text-align: left;\n vertical-align: middle;\n }\n @left-top {\n text-align: center;\n vertical-align: top;\n }\n @left-middle {\n text-align: center;\n vertical-align: middle;\n }\n @left-bottom {\n text-align: center;\n vertical-align: bottom;\n }\n @right-top {\n text-align: center;\n vertical-align: top;\n }\n @right-middle {\n text-align: center;\n vertical-align: middle;\n }\n @right-bottom {\n text-align: center;\n vertical-align: bottom;\n }\n @bottom-left-corner {\n text-align: right;\n vertical-align: middle;\n }\n @bottom-left {\n text-align: left;\n vertical-align: middle;\n }\n @bottom-center {\n text-align: center;\n vertical-align: middle;\n }\n @bottom-right {\n text-align: right;\n vertical-align: middle;\n }\n @bottom-right-corner {\n text-align: left;\n vertical-align: middle;\n }\n}\n\n@media print {\n @page {\n margin: 10%;\n }\n}\n',Po=String.raw`
15
+ @namespace "http://www.w3.org/1999/xhtml";
16
+ @namespace m "http://www.w3.org/1998/Math/MathML";
17
+ @namespace epub "http://www.idpf.org/2007/ops";
18
+
19
+ html,
20
+ address,
21
+ blockquote,
22
+ body,
23
+ dd,
24
+ div,
25
+ dl,
26
+ dt,
27
+ fieldset,
28
+ form,
29
+ frame,
30
+ frameset,
31
+ h1,
32
+ h2,
33
+ h3,
34
+ h4,
35
+ h5,
36
+ h6,
37
+ noframes,
38
+ ol,
39
+ p,
40
+ ul,
41
+ center,
42
+ dir,
43
+ hr,
44
+ menu,
45
+ pre,
46
+ details,
47
+ dialog,
48
+ legend,
49
+ listing,
50
+ optgroup,
51
+ option,
52
+ plaintext,
53
+ search,
54
+ xmp,
55
+ article,
56
+ section,
57
+ nav,
58
+ aside,
59
+ hgroup,
60
+ footer,
61
+ header,
62
+ figure,
63
+ figcaption,
64
+ main {
65
+ display: block;
66
+ }
67
+ li {
68
+ display: list-item;
69
+ }
70
+ head {
71
+ display: none !important;
72
+ }
73
+ table {
74
+ display: table;
75
+ }
76
+ tr {
77
+ display: table-row;
78
+ }
79
+ thead {
80
+ display: table-header-group;
81
+ break-after: avoid;
82
+ }
83
+ tbody {
84
+ display: table-row-group;
85
+ }
86
+ tfoot {
87
+ display: table-footer-group;
88
+ break-before: avoid;
89
+ }
90
+ col {
91
+ display: table-column;
92
+ }
93
+ colgroup {
94
+ display: table-column-group;
95
+ }
96
+ td,
97
+ th {
98
+ display: table-cell;
99
+ }
100
+ caption {
101
+ display: table-caption;
102
+ text-align: center;
103
+ }
104
+ th {
105
+ font-weight: bolder;
106
+ text-align: center;
107
+ }
108
+ *[hidden],
109
+ link,
110
+ style,
111
+ script {
112
+ display: none;
113
+ }
114
+ h1 {
115
+ font-size: 2em;
116
+ margin-block: 0.67em;
117
+ }
118
+ h2 {
119
+ font-size: 1.5em;
120
+ margin-block: 0.83em;
121
+ }
122
+ h3 {
123
+ font-size: 1.17em;
124
+ margin-block: 1em;
125
+ }
126
+ h4 {
127
+ font-size: 1em;
128
+ margin-block: 1.33em;
129
+ }
130
+ h5 {
131
+ font-size: 0.83em;
132
+ margin-block: 1.67em;
133
+ }
134
+ h6 {
135
+ font-size: 0.67em;
136
+ margin-block: 2.33em;
137
+ }
138
+ h1,
139
+ h2,
140
+ h3,
141
+ h4,
142
+ h5,
143
+ h6 {
144
+ font-weight: bold;
145
+ break-after: avoid;
146
+ }
147
+ p,
148
+ blockquote,
149
+ figure,
150
+ ul,
151
+ ol,
152
+ dl,
153
+ dir,
154
+ menu {
155
+ margin-block: 1em;
156
+ }
157
+ b,
158
+ strong {
159
+ font-weight: bolder;
160
+ }
161
+ blockquote,
162
+ figure {
163
+ margin-inline: 40px;
164
+ }
165
+ i,
166
+ cite,
167
+ dfn,
168
+ em,
169
+ var,
170
+ address {
171
+ font-style: italic;
172
+ }
173
+ pre,
174
+ tt,
175
+ code,
176
+ kbd,
177
+ samp {
178
+ font-family: monospace;
179
+ text-spacing: none;
180
+ hanging-punctuation: none;
181
+ }
182
+ listing,
183
+ plaintext,
184
+ xmp,
185
+ pre {
186
+ white-space: pre;
187
+ }
188
+ pre[wrap] {
189
+ white-space: pre-wrap;
190
+ }
191
+ button,
192
+ textarea,
193
+ input,
194
+ select {
195
+ display: inline-block;
196
+ }
197
+ big {
198
+ font-size: 1.17em;
199
+ }
200
+ small,
201
+ sub,
202
+ sup {
203
+ font-size: 0.83em;
204
+ }
205
+ sub {
206
+ vertical-align: sub;
207
+ }
208
+ sup {
209
+ vertical-align: super;
210
+ }
211
+ sub,
212
+ sup {
213
+ line-height: 1;
214
+ }
215
+ table {
216
+ box-sizing: border-box;
217
+ border-spacing: 2px;
218
+ border-collapse: separate;
219
+ text-indent: initial;
220
+ }
221
+ thead,
222
+ tbody,
223
+ tfoot,
224
+ table > tr {
225
+ vertical-align: middle;
226
+ }
227
+ tr,
228
+ td,
229
+ th {
230
+ vertical-align: inherit;
231
+ }
232
+ s,
233
+ strike,
234
+ del {
235
+ text-decoration: line-through;
236
+ }
237
+ hr {
238
+ border-style: inset;
239
+ border-width: 1px;
240
+ margin-block: 0.5em;
241
+ }
242
+ hr[color],
243
+ hr[noshade] {
244
+ border-style: solid;
245
+ }
246
+ ol,
247
+ ul,
248
+ dir,
249
+ menu {
250
+ padding-inline-start: 40px;
251
+ }
252
+ dd {
253
+ margin-inline-start: 40px;
254
+ }
255
+ ol ul,
256
+ ul ol,
257
+ ul ul,
258
+ ol ol {
259
+ margin-block: 0;
260
+ }
261
+ ul {
262
+ list-style-type: disc;
263
+ }
264
+ ol ul,
265
+ ul ul {
266
+ list-style-type: circle;
267
+ }
268
+ ol ol ul,
269
+ ol ul ul,
270
+ ul ol ul,
271
+ ul ul ul {
272
+ list-style-type: square;
273
+ }
274
+ ol { list-style-type: decimal; }
275
+ ol[type="1"], li[type="1"] { list-style-type: decimal; }
276
+ ol[type=a], li[type=a] { list-style-type: lower-alpha; }
277
+ ol[type=A], li[type=A] { list-style-type: upper-alpha; }
278
+ ol[type=i], li[type=i] { list-style-type: lower-roman; }
279
+ ol[type=I], li[type=I] { list-style-type: upper-roman; }
280
+ ul[type=none i], li[type=none i] { list-style-type: none; }
281
+ ul[type=disc i], li[type=disc i] { list-style-type: disc; }
282
+ ul[type=circle i], li[type=circle i] { list-style-type: circle; }
283
+ ul[type=square i], li[type=square i] { list-style-type: square; }
284
+ u,
285
+ ins {
286
+ text-decoration: underline;
287
+ }
288
+ center {
289
+ text-align: center;
290
+ }
291
+ q::before {
292
+ content: open-quote;
293
+ }
294
+ q::after {
295
+ content: close-quote;
296
+ }
297
+
298
+ ruby {
299
+ display: ruby;
300
+ }
301
+ rp {
302
+ display: none;
303
+ }
304
+ rbc {
305
+ display: ruby-base-container;
306
+ }
307
+ rtc {
308
+ display: ruby-text-container;
309
+ }
310
+ rb {
311
+ display: ruby-base;
312
+ white-space: nowrap;
313
+ }
314
+ rt {
315
+ display: ruby-text;
316
+ }
317
+ rtc,
318
+ rt {
319
+ text-emphasis: none;
320
+ white-space: nowrap;
321
+ line-height: 1;
322
+ }
323
+ rtc,
324
+ rt {
325
+ font-size: 50%;
326
+ }
327
+ rtc:lang(zh-TW),
328
+ rt:lang(zh-TW) {
329
+ font-size: 30%;
330
+ }
331
+ rtc > rt,
332
+ rtc > rt:lang(zh-TW) {
333
+ font-size: 100%;
334
+ }
335
+
336
+ /* Bidi settings */
337
+ bdo[dir="ltr"] {
338
+ direction: ltr;
339
+ unicode-bidi: bidi-override;
340
+ }
341
+ bdo[dir="rtl"] {
342
+ direction: rtl;
343
+ unicode-bidi: bidi-override;
344
+ }
345
+ *[dir="ltr"] {
346
+ direction: ltr;
347
+ unicode-bidi: isolate;
348
+ }
349
+ *[dir="rtl"] {
350
+ direction: rtl;
351
+ unicode-bidi: isolate;
352
+ }
353
+
354
+ /* MathML */
355
+ m|math[display="block"] {
356
+ display: block;
357
+ display: block math;
358
+ }
359
+
360
+ /* CSS GCPM footnotes */
361
+ ::footnote-marker {
362
+ list-style-position: inside;
363
+ }
364
+ /* Semantic DPUB/EPUB footnotes provide their own default call/marker path. */
365
+ :not(aside[epub|type~="footnote"], aside[epub\:type~="footnote"], aside[role~="doc-footnote"])::footnote-marker {
366
+ content: counter(footnote) ". ";
367
+ }
368
+ :not(a[epub|type~="noteref"], a[epub\:type~="noteref"], a[role~="doc-noteref"])::footnote-call {
369
+ content: counter(footnote);
370
+ font-size: 0.75em;
371
+ vertical-align: super;
372
+ line-height: 0;
373
+ }
374
+
375
+ /* EPUB/DPUB footnotes */
376
+
377
+ a[epub|type="noteref"]:not(sup > *, :has(> sup)),
378
+ a[epub\:type="noteref"]:not(sup > *, :has(> sup)),
379
+ a[role="doc-noteref"]:not(sup > *, :has(> sup)) {
380
+ font-size: 0.75em;
381
+ vertical-align: super;
382
+ line-height: 0;
383
+ }
384
+
385
+ a[epub|type="noteref"][data-vivliostyle-footnote-first-ref],
386
+ a[epub\:type="noteref"][data-vivliostyle-footnote-first-ref],
387
+ a[role="doc-noteref"][data-vivliostyle-footnote-first-ref] {
388
+ counter-increment: footnote;
389
+ }
390
+
391
+ a[epub|type="noteref"]:href-epub-type(footnote, aside),
392
+ a[epub\:type="noteref"]:href-epub-type(footnote, aside),
393
+ a[role="doc-noteref"]:href-role-type(doc-footnote, aside) {
394
+ -adapt-template: footnote;
395
+ text-decoration: none;
396
+ }
397
+
398
+ aside[epub|type="footnote"][data-vivliostyle-footnote-referenced],
399
+ aside[epub\:type="footnote"][data-vivliostyle-footnote-referenced],
400
+ aside[role="doc-footnote"][data-vivliostyle-footnote-referenced] {
401
+ display: none;
402
+ }
403
+
404
+ aside[epub|type="footnote"]:footnote-content,
405
+ aside[epub\:type="footnote"]:footnote-content,
406
+ aside[role="doc-footnote"]:footnote-content {
407
+ display: block;
408
+ font-size: 0.9em;
409
+ }
410
+
411
+ aside[epub|type="footnote"]:footnote-content a[epub|type="backlink"],
412
+ aside[epub\:type="footnote"]:footnote-content a[epub\:type="backlink"],
413
+ aside[role="doc-footnote"]:footnote-content a[role="doc-backlink"] {
414
+ text-decoration: none;
415
+ }
416
+
417
+ /* EPUB-specific */
418
+ epub|trigger {
419
+ display: none;
420
+ }
421
+
422
+ epub|switch {
423
+ display: inline;
424
+ }
425
+
426
+ epub|default {
427
+ display: inline;
428
+ }
429
+
430
+ epub|case {
431
+ display: none;
432
+ }
433
+
434
+ epub|case[required-namespace::supported] {
435
+ display: inline;
436
+ }
437
+
438
+ epub|case[required-namespace::supported] ~ epub|case {
439
+ display: none;
440
+ }
441
+
442
+ epub|case[required-namespace::supported] ~ epub|default {
443
+ display: none;
444
+ }
445
+ `,Eo="\n@namespace \"http://www.w3.org/1999/xhtml\";\n\n*:not([data-vivliostyle-role=doc-toc],\n [data-vivliostyle-role=doc-toc] *,\n :has([data-vivliostyle-role=doc-toc]),\n :is(h1,h2,h3,h4,h5,h6):has(+:not(nav)[data-vivliostyle-role=doc-toc])) {\n display: none;\n}\n\n/* An entry hidden from the printed table of contents is still listed in the\n viewer's TOC menu (see PR #1269). Nothing in Vivliostyle's own cascade is\n left to roll back to here, so the keyword reaches the browser, which reverts\n to the display of the element itself. */\n[hidden] {\n display: revert;\n}\n\n[data-vivliostyle-role=doc-toc] li a {\n -adapt-behavior: toc-node-anchor;\n}\n\n[data-vivliostyle-role=doc-toc] li {\n -adapt-behavior: toc-node;\n}\n\n[data-vivliostyle-role=doc-toc] li > :not(ul,ol):first-child {\n -adapt-behavior: toc-node-first-child;\n}\n\n[data-vivliostyle-role=doc-toc] :is(ol,ul),\n[data-vivliostyle-role=doc-toc]:is(ol,ul) {\n -adapt-behavior: toc-container;\n}\n",No='\n[data-viv-margin-discard~="block-start"] {\n margin-block-start: 0 !important;\n}\n[data-viv-margin-discard~="block-end"] {\n margin-block-end: 0 !important;\n}\n[data-viv-margin-discard~="inline-start"] {\n margin-inline-start: 0 !important;\n}\n[data-viv-margin-discard~="inline-end"] {\n margin-inline-end: 0 !important;\n}\n\n[data-viv-box-break~="inline-start"]:not([data-viv-box-break~="clone"]) {\n margin-inline-start: 0 !important;\n padding-inline-start: 0 !important;\n border-inline-start-width: 0 !important;\n border-start-start-radius: 0 !important;\n border-end-start-radius: 0 !important;\n}\n[data-viv-box-break~="inline-end"]:not([data-viv-box-break~="clone"]) {\n margin-inline-end: 0 !important;\n padding-inline-end: 0 !important;\n border-inline-end-width: 0 !important;\n border-start-end-radius: 0 !important;\n border-end-end-radius: 0 !important;\n}\n[data-viv-box-break~="block-start"]:not([data-viv-box-break~="clone"]):not(table[style*="border-collapse: collapse"]:has(>thead)) {\n margin-block-start: 0 !important;\n padding-block-start: 0 !important;\n border-block-start-width: 0 !important;\n border-start-start-radius: 0 !important;\n border-start-end-radius: 0 !important;\n}\n[data-viv-box-break~="block-end"]:not([data-viv-box-break~="clone"]):not(table[style*="border-collapse: collapse"]:has(>tfoot)) {\n margin-block-end: 0 !important;\n padding-block-end: 0 !important;\n border-block-end-width: 0 !important;\n border-end-start-radius: 0 !important;\n border-end-end-radius: 0 !important;\n}\n[data-viv-box-break~="block-start"][data-viv-box-break~="text-start"] {\n text-indent: 0 !important;\n}\n[data-viv-box-break~="block-end"][data-viv-box-break~="text-end"][data-viv-box-break~="justify"] {\n text-align-last: justify !important;\n}\n[data-viv-box-break~="block-end"][data-viv-box-break~="text-end"][data-viv-box-break~="justify"] > * {\n text-align-last: auto;\n}\n[data-viv-box-break~="block-end"][data-viv-box-break~="text-end"]:not([data-viv-box-break~="justify"]) {\n text-align-last: auto !important;\n}\n\nspan.viv-anonymous-block {\n display: block;\n}\n\n[data-vivliostyle-page-container] {\n text-spacing-trim: space-all;\n text-autospace: no-autospace;\n}\n/* see #2034 */\n@font-face {\n font-family: "-viv-ts-sp";\n src: url("data:font/woff2;base64,d09GMgABAAAAAADsAAoAAAAAAhwAAACkAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAABmAANAoUNgE2AiQDDAsIAAQgBQYHLhuDATAvDuxmH09wwcdQfVXDjoN4/uuenbvv/WombeKVxJoJmsgSDAIMQBNI2364+oJVIbt1VpdteYNucBxRTKkHHAAtsOCiG02Dh+ybQCFXG3XLx6aFAW6lt2nu/R/sYAIAJhgonJTgpE20Fsy1eGx9BUCBHYJCAxpAKsezAIKwvzuuv0MdwOvy2w0RlAHC9crGWiIAgIIGCEoJGCTsDC4sx/ZMAAA=") format("woff2");\n}\nviv-ts-open.viv-ts-auto > viv-ts-inner,\nviv-ts-open.viv-ts-trim > viv-ts-inner {\n margin-inline-start: -0.5em;\n}\nviv-ts-close.viv-ts-auto > viv-ts-inner,\nviv-ts-close.viv-ts-trim > viv-ts-inner {\n letter-spacing: -0.5em;\n}\nviv-ts-close.viv-hang-end > viv-ts-inner,\nviv-ts-close.viv-hang-last > viv-ts-inner {\n letter-spacing: -1em;\n}\nviv-ts-open.viv-ts-auto::before,\nviv-ts-close.viv-ts-auto::after,\nviv-ts-close.viv-hang-end::after {\n content: " ";\n font: 1em/0 "-viv-ts-sp";\n text-rendering: geometricPrecision;\n word-spacing: normal;\n letter-spacing: normal;\n text-orientation: mixed;\n visibility: hidden;\n}\nviv-ts-close.viv-hang-end:not(.viv-hang-hw)::after {\n /* 0.5em space + 0.5em = 1em */\n letter-spacing: 0.5em;\n}\nviv-ts-close.viv-hang-hw > viv-ts-inner {\n letter-spacing: -0.5em;\n}\nviv-ts-open.viv-hang-first > viv-ts-inner {\n display: inline-block;\n line-height: 1;\n inline-size: 1em;\n text-indent: 0;\n text-align: end;\n text-align-last: end;\n margin-inline-start: -1em;\n}\nviv-ts-thin-sp::after {\n content: " ";\n font: 1em/0 "-viv-ts-sp";\n /* 0.5em space - 0.375em = 0.125em */\n letter-spacing: -0.375em;\n text-rendering: geometricPrecision;\n word-spacing: normal;\n text-orientation: mixed;\n visibility: hidden;\n}\n[style*=text-decoration] :is(viv-ts-thin-sp, viv-ts-close.viv-ts-auto)::after {\n visibility: visible;\n}\n\nspan[data-viv-leader] {\n text-combine-upright: none;\n text-orientation: mixed;\n white-space: pre;\n}\n\n/* ::marker */\n[style*="--viv-marker-content"]::marker {\n content: var(--viv-marker-content);\n unicode-bidi: isolate;\n font-variant-numeric: tabular-nums;\n white-space: pre;\n text-transform: none;\n}\n/* ::footnote-marker inherits --viv-marker-content from the footnote element */\n.-vivliostyle-footnote-content::marker {\n content: var(--viv-marker-content);\n unicode-bidi: isolate;\n font-variant-numeric: tabular-nums;\n white-space: pre;\n text-transform: none;\n}\n[style*="--viv-footnote-white-space"] {\n white-space: var(--viv-footnote-white-space);\n}\n[style*="--viv-marker-color"]::marker {\n color: var(--viv-marker-color);\n}\n[style*="--viv-marker-font-size"]::marker {\n font-size: var(--viv-marker-font-size);\n}\n[style*="--viv-marker-font-family"]::marker {\n font-family: var(--viv-marker-font-family);\n}\n[style*="--viv-marker-font-style"]::marker {\n font-style: var(--viv-marker-font-style);\n}\n[style*="--viv-marker-font-weight"]::marker {\n font-weight: var(--viv-marker-font-weight);\n}\n[style*="--viv-marker-font-variant"]::marker {\n font-variant: var(--viv-marker-font-variant);\n}\n[style*="--viv-marker-unicode-bidi"]::marker {\n unicode-bidi: var(--viv-marker-unicode-bidi);\n}\n[style*="--viv-marker-direction"]::marker {\n direction: var(--viv-marker-direction);\n}\n[style*="--viv-marker-white-space"]::marker {\n white-space: var(--viv-marker-white-space);\n}\n[style*="--viv-marker-text-transform"]::marker {\n text-transform: var(--viv-marker-text-transform);\n}\n[style*="--viv-marker-text-combine-upright"]::marker {\n text-combine-upright: var(--viv-marker-text-combine-upright);\n}\n[style*="--viv-marker-text-orientation"]::marker {\n text-orientation: var(--viv-marker-text-orientation);\n}\n[style*="--viv-marker-hyphens"]::marker {\n hyphens: var(--viv-marker-hyphens);\n}\n[style*="--viv-marker-line-height"]::marker {\n line-height: var(--viv-marker-line-height);\n}\n[style*="--viv-marker-tab-size"]::marker {\n tab-size: var(--viv-marker-tab-size);\n}\n[style*="--viv-marker-text-emphasis-style"]::marker {\n text-emphasis-style: var(--viv-marker-text-emphasis-style);\n}\n[style*="--viv-marker-text-emphasis-color"]::marker {\n text-emphasis-color: var(--viv-marker-text-emphasis-color);\n}\n[style*="--viv-marker-text-emphasis-position"]::marker {\n text-emphasis-position: var(--viv-marker-text-emphasis-position);\n}\n[style*="--viv-marker-text-shadow"]::marker {\n text-shadow: var(--viv-marker-text-shadow);\n}\n\n/* initial-letter */\n[style*="--viv-initialLetter"]:has(>[data-adapt-pseudo="first-letter"])::first-letter {\n -webkit-initial-letter: var(--viv-initialLetter);\n initial-letter: var(--viv-initialLetter);\n}\n',To=String.raw`
446
+ @counter-style decimal-leading-zero {
447
+ system: extends decimal;
448
+ pad: 2 '0';
449
+ }
450
+ @counter-style arabic-indic {
451
+ system: numeric;
452
+ symbols: ٠ ١ ٢ ٣ ٤ ٥ ٦ ٧ ٨ ٩;
453
+ }
454
+ @counter-style armenian {
455
+ system: additive;
456
+ range: 1 9999;
457
+ additive-symbols: 9000 Ք, 8000 Փ, 7000 Ւ, 6000 Ց, 5000 Ր, 4000 Տ, 3000 Վ, 2000 Ս, 1000 Ռ, 900 Ջ, 800 Պ, 700 Չ, 600 Ո, 500 Շ, 400 Ն, 300 Յ, 200 Մ, 100 Ճ, 90 Ղ, 80 Ձ, 70 Հ, 60 Կ, 50 Ծ, 40 Խ, 30 Լ, 20 Ի, 10 Ժ, 9 Թ, 8 Ը, 7 Է, 6 Զ, 5 Ե, 4 Դ, 3 Գ, 2 Բ, 1 Ա;
458
+ }
459
+ @counter-style upper-armenian {
460
+ system: extends armenian;
461
+ }
462
+ @counter-style lower-armenian {
463
+ system: additive;
464
+ range: 1 9999;
465
+ additive-symbols: 9000 ք, 8000 փ, 7000 ւ, 6000 ց, 5000 ր, 4000 տ, 3000 վ, 2000 ս, 1000 ռ, 900 ջ, 800 պ, 700 չ, 600 ո, 500 շ, 400 ն, 300 յ, 200 մ, 100 ճ, 90 ղ, 80 ձ, 70 հ, 60 կ, 50 ծ, 40 խ, 30 լ, 20 ի, 10 ժ, 9 թ, 8 ը, 7 է, 6 զ, 5 ե, 4 դ, 3 գ, 2 բ, 1 ա;
466
+ }
467
+ @counter-style bengali {
468
+ system: numeric;
469
+ symbols: ০ ১ ২ ৩ ৪ ৫ ৬ ৭ ৮ ৯;
470
+ }
471
+ @counter-style cambodian {
472
+ system: numeric;
473
+ symbols: ០ ១ ២ ៣ ៤ ៥ ៦ ៧ ៨ ៩;
474
+ }
475
+ @counter-style khmer {
476
+ system: extends cambodian;
477
+ }
478
+ @counter-style cjk-decimal {
479
+ system: numeric;
480
+ range: 0 infinite;
481
+ symbols: 〇 一 二 三 四 五 六 七 八 九;
482
+ suffix: "、";
483
+ }
484
+ @counter-style devanagari {
485
+ system: numeric;
486
+ symbols: ० १ २ ३ ४ ५ ६ ७ ८ ९;
487
+ }
488
+ @counter-style georgian {
489
+ system: additive;
490
+ range: 1 19999;
491
+ additive-symbols: 10000 ჵ, 9000 ჰ, 8000 ჯ, 7000 ჴ, 6000 ხ, 5000 ჭ, 4000 წ, 3000 ძ, 2000 ც, 1000 ჩ, 900 შ, 800 ყ, 700 ღ, 600 ქ, 500 ფ, 400 ჳ, 300 ტ, 200 ს, 100 რ, 90 ჟ, 80 პ, 70 ო, 60 ჲ, 50 ნ, 40 მ, 30 ლ, 20 კ, 10 ი, 9 თ, 8 ჱ, 7 ზ, 6 ვ, 5 ე, 4 დ, 3 გ, 2 ბ, 1 ა;
492
+ }
493
+ @counter-style gujarati {
494
+ system: numeric;
495
+ symbols: ૦ ૧ ૨ ૩ ૪ ૫ ૬ ૭ ૮ ૯;
496
+ }
497
+ @counter-style gurmukhi {
498
+ system: numeric;
499
+ symbols: ੦ ੧ ੨ ੩ ੪ ੫ ੬ ੭ ੮ ੯;
500
+ }
501
+ @counter-style hebrew {
502
+ system: additive;
503
+ range: 1 10999;
504
+ additive-symbols: 10000 \5D9\5F3, 9000 \5D8\5F3, 8000 \5D7\5F3, 7000 \5D6\5F3, 6000 \5D5\5F3, 5000 \5D4\5F3, 4000 \5D3\5F3, 3000 \5D2\5F3, 2000 \5D1\5F3, 1000 \5D0\5F3, 400 \5EA, 300 \5E9, 200 \5E8, 100 \5E7, 90 \5E6, 80 \5E4, 70 \5E2, 60 \5E1, 50 \5E0, 40 \5DE, 30 \5DC, 20 \5DB, 19 \5D9\5D8, 18 \5D9\5D7, 17 \5D9\5D6, 16 \5D8\5D6, 15 \5D8\5D5, 10 \5D9, 9 \5D8, 8 \5D7, 7 \5D6, 6 \5D5, 5 \5D4, 4 \5D3, 3 \5D2, 2 \5D1, 1 \5D0;
505
+ }
506
+ @counter-style kannada {
507
+ system: numeric;
508
+ symbols: ೦ ೧ ೨ ೩ ೪ ೫ ೬ ೭ ೮ ೯;
509
+ }
510
+ @counter-style lao {
511
+ system: numeric;
512
+ symbols: ໐ ໑ ໒ ໓ ໔ ໕ ໖ ໗ ໘ ໙;
513
+ }
514
+ @counter-style malayalam {
515
+ system: numeric;
516
+ symbols: ൦ ൧ ൨ ൩ ൪ ൫ ൬ ൭ ൮ ൯;
517
+ }
518
+ @counter-style mongolian {
519
+ system: numeric;
520
+ symbols: ᠐ ᠑ ᠒ ᠓ ᠔ ᠕ ᠖ ᠗ ᠘ ᠙;
521
+ }
522
+ @counter-style myanmar {
523
+ system: numeric;
524
+ symbols: ၀ ၁ ၂ ၃ ၄ ၅ ၆ ၇ ၈ ၉;
525
+ }
526
+ @counter-style oriya {
527
+ system: numeric;
528
+ symbols: ୦ ୧ ୨ ୩ ୪ ୫ ୬ ୭ ୮ ୯;
529
+ }
530
+ @counter-style persian {
531
+ system: numeric;
532
+ symbols: ۰ ۱ ۲ ۳ ۴ ۵ ۶ ۷ ۸ ۹;
533
+ }
534
+ @counter-style lower-roman {
535
+ system: additive;
536
+ range: 1 3999;
537
+ additive-symbols: 1000 m, 900 cm, 500 d, 400 cd, 100 c, 90 xc, 50 l, 40 xl, 10 x, 9 ix, 5 v, 4 iv, 1 i;
538
+ }
539
+ @counter-style upper-roman {
540
+ system: additive;
541
+ range: 1 3999;
542
+ additive-symbols: 1000 M, 900 CM, 500 D, 400 CD, 100 C, 90 XC, 50 L, 40 XL, 10 X, 9 IX, 5 V, 4 IV, 1 I;
543
+ }
544
+ @counter-style tamil {
545
+ system: numeric;
546
+ symbols: ௦ ௧ ௨ ௩ ௪ ௫ ௬ ௭ ௮ ௯;
547
+ }
548
+ @counter-style telugu {
549
+ system: numeric;
550
+ symbols: ౦ ౧ ౨ ౩ ౪ ౫ ౬ ౭ ౮ ౯;
551
+ }
552
+ @counter-style thai {
553
+ system: numeric;
554
+ symbols: ๐ ๑ ๒ ๓ ๔ ๕ ๖ ๗ ๘ ๙;
555
+ }
556
+ @counter-style tibetan {
557
+ system: numeric;
558
+ symbols: ༠ ༡ ༢ ༣ ༤ ༥ ༦ ༧ ༨ ༩;
559
+ }
560
+ @counter-style lower-alpha {
561
+ system: alphabetic;
562
+ symbols: a b c d e f g h i j k l m n o p q r s t u v w x y z;
563
+ }
564
+ @counter-style lower-latin {
565
+ system: extends lower-alpha;
566
+ }
567
+ @counter-style upper-alpha {
568
+ system: alphabetic;
569
+ symbols: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z;
570
+ }
571
+ @counter-style upper-latin {
572
+ system: extends upper-alpha;
573
+ }
574
+ @counter-style lower-greek {
575
+ system: alphabetic;
576
+ symbols: α β γ δ ε ζ η θ ι κ λ μ ν ξ ο π ρ σ τ υ φ χ ψ ω;
577
+ }
578
+ @counter-style hiragana {
579
+ system: alphabetic;
580
+ symbols: あ い う え お か き く け こ さ し す せ そ た ち つ て と な に ぬ ね の は ひ ふ へ ほ ま み む め も や ゆ よ ら り る れ ろ わ ゐ ゑ を ん;
581
+ suffix: "、";
582
+ }
583
+ @counter-style hiragana-iroha {
584
+ system: alphabetic;
585
+ symbols: い ろ は に ほ へ と ち り ぬ る を わ か よ た れ そ つ ね な ら む う ゐ の お く や ま け ふ こ え て あ さ き ゆ め み し ゑ ひ も せ す;
586
+ suffix: "、";
587
+ }
588
+ @counter-style katakana {
589
+ system: alphabetic;
590
+ symbols: ア イ ウ エ オ カ キ ク ケ コ サ シ ス セ ソ タ チ ツ テ ト ナ ニ ヌ ネ ノ ハ ヒ フ ヘ ホ マ ミ ム メ モ ヤ ユ ヨ ラ リ ル レ ロ ワ ヰ ヱ ヲ ン;
591
+ suffix: "、";
592
+ }
593
+ @counter-style katakana-iroha {
594
+ system: alphabetic;
595
+ symbols: イ ロ ハ ニ ホ ヘ ト チ リ ヌ ル ヲ ワ カ ヨ タ レ ソ ツ ネ ナ ラ ム ウ ヰ ノ オ ク ヤ マ ケ フ コ エ テ ア サ キ ユ メ ミ シ ヱ ヒ モ セ ス;
596
+ suffix: "、";
597
+ }
598
+ @counter-style cjk-earthly-branch {
599
+ system: fixed;
600
+ symbols: 子 丑 寅 卯 辰 巳 午 未 申 酉 戌 亥;
601
+ suffix: "、";
602
+ fallback: cjk-decimal;
603
+ }
604
+ @counter-style cjk-heavenly-stem {
605
+ system: fixed;
606
+ symbols: 甲 乙 丙 丁 戊 己 庚 辛 壬 癸;
607
+ suffix: "、";
608
+ fallback: cjk-decimal;
609
+ }
610
+ @counter-style japanese-informal {
611
+ system: additive;
612
+ range: -9999 9999;
613
+ additive-symbols: 9000 九千, 8000 八千, 7000 七千, 6000 六千, 5000 五千, 4000 四千, 3000 三千, 2000 二千, 1000 千, 900 九百, 800 八百, 700 七百, 600 六百, 500 五百, 400 四百, 300 三百, 200 二百, 100 百, 90 九十, 80 八十, 70 七十, 60 六十, 50 五十, 40 四十, 30 三十, 20 二十, 10 十, 9 九, 8 八, 7 七, 6 六, 5 五, 4 四, 3 三, 2 二, 1 一, 0 〇;
614
+ suffix: "、";
615
+ negative: マイナス;
616
+ fallback: cjk-decimal;
617
+ }
618
+ @counter-style japanese-formal {
619
+ system: additive;
620
+ range: -9999 9999;
621
+ additive-symbols: 9000 九阡, 8000 八阡, 7000 七阡, 6000 六阡, 5000 伍阡, 4000 四阡, 3000 参阡, 2000 弐阡, 1000 壱阡, 900 九百, 800 八百, 700 七百, 600 六百, 500 伍百, 400 四百, 300 参百, 200 弐百, 100 壱百, 90 九拾, 80 八拾, 70 七拾, 60 六拾, 50 伍拾, 40 四拾, 30 参拾, 20 弐拾, 10 壱拾, 9 九, 8 八, 7 七, 6 六, 5 伍, 4 四, 3 参, 2 弐, 1 壱, 0 零;
622
+ suffix: "、";
623
+ negative: マイナス;
624
+ fallback: cjk-decimal;
625
+ }
626
+ @counter-style korean-hangul-formal {
627
+ system: additive;
628
+ range: -9999 9999;
629
+ additive-symbols: 9000 구천, 8000 팔천, 7000 칠천, 6000 육천, 5000 오천, 4000 사천, 3000 삼천, 2000 이천, 1000 일천, 900 구백, 800 팔백, 700 칠백, 600 육백, 500 오백, 400 사백, 300 삼백, 200 이백, 100 일백, 90 구십, 80 팔십, 70 칠십, 60 육십, 50 오십, 40 사십, 30 삼십, 20 이십, 10 일십, 9 구, 8 팔, 7 칠, 6 육, 5 오, 4 사, 3 삼, 2 이, 1 일, 0 영;
630
+ suffix: ', ';
631
+ negative: "마이너스 ";
632
+ fallback: cjk-decimal;
633
+ }
634
+ @counter-style korean-hanja-informal {
635
+ system: additive;
636
+ range: -9999 9999;
637
+ additive-symbols: 9000 九千, 8000 八千, 7000 七千, 6000 六千, 5000 五千, 4000 四千, 3000 三千, 2000 二千, 1000 千, 900 九百, 800 八百, 700 七百, 600 六百, 500 五百, 400 四百, 300 三百, 200 二百, 100 百, 90 九十, 80 八十, 70 七十, 60 六十, 50 五十, 40 四十, 30 三十, 20 二十, 10 十, 9 九, 8 八, 7 七, 6 六, 5 五, 4 四, 3 三, 2 二, 1 一, 0 零;
638
+ suffix: ', ';
639
+ negative: "마이너스 ";
640
+ fallback: cjk-decimal;
641
+ }
642
+ @counter-style korean-hanja-formal {
643
+ system: additive;
644
+ range: -9999 9999;
645
+ additive-symbols: 9000 九仟, 8000 八仟, 7000 七仟, 6000 六仟, 5000 五仟, 4000 四仟, 3000 參仟, 2000 貳仟, 1000 壹仟, 900 九百, 800 八百, 700 七百, 600 六百, 500 五百, 400 四百, 300 參百, 200 貳百, 100 壹百, 90 九拾, 80 八拾, 70 七拾, 60 六拾, 50 五拾, 40 四拾, 30 參拾, 20 貳拾, 10 壹拾, 9 九, 8 八, 7 七, 6 六, 5 五, 4 四, 3 參, 2 貳, 1 壹, 0 零;
646
+ suffix: ', ';
647
+ negative: "마이너스 ";
648
+ fallback: cjk-decimal;
649
+ }
650
+ `+"\n@counter-style lower-armenian {\n system: additive;\n range: 1 9999;\n additive-symbols: 9000 ք, 8000 փ, 7000 ւ, 6000 ց, 5000 ր, 4000 տ, 3000 վ, 2000 ս, 1000 ռ, 900 ջ, 800 պ, 700 չ, 600 ո, 500 շ, 400 ն, 300 յ, 200 մ, 100 ճ, 90 ղ, 80 ձ, 70 հ, 60 կ, 50 ծ, 40 խ, 30 լ, 20 ի, 10 ժ, 9 թ, 8 ը, 7 է, 6 զ, 5 ե, 4 դ, 3 գ, 2 բ, 1 ա;\n}\n@counter-style upper-armenian {\n system: additive;\n range: 1 9999;\n additive-symbols: 9000 Ք, 8000 Փ, 7000 Ւ, 6000 Ց, 5000 Ր, 4000 Տ, 3000 Վ, 2000 Ս, 1000 Ռ, 900 Ջ, 800 Պ, 700 Չ, 600 Ո, 500 Շ, 400 Ն, 300 Յ, 200 Մ, 100 Ճ, 90 Ղ, 80 Ձ, 70 Հ, 60 Կ, 50 Ծ, 40 Խ, 30 Լ, 20 Ի, 10 Ժ, 9 Թ, 8 Ը, 7 Է, 6 Զ, 5 Ե, 4 Դ, 3 Գ, 2 Բ, 1 Ա;\n}\n@counter-style lower-russian {\n system: alphabetic;\n symbols: а б в г д е ж з и к л м н о п р с т у ф х ц ч ш щ э ю я;\n suffix: ') ';\n}\n@counter-style upper-russian {\n system: alphabetic;\n symbols: А Б В Г Д Е Ж З И К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Э Ю Я;\n}";function Io(e,t,i){let n=oo("fetchFromURL"),r={method:i||"GET",mode:"cors"},o=n.suspend(),s={status:0,statusText:"",url:e,contentType:null,responseText:null,responseXML:null,responseBlob:null};return fetch(e,r).then(i=>{var n,r;if(s.status=i.status,s.url=i.url,s.statusText=i.statusText,s.contentType=null!=(r=null==(n=i.headers.get("Content-Type"))?void 0:n.replace(/;.*$/,"").toLowerCase())?r:null,!i.ok)throw new Error(`HTTP ${i.status}${i.statusText?` ${i.statusText}`:""}`);return"blob"===t?i.blob():"arraybuffer"===t?i.arrayBuffer():"json"===t?i.json():/\/aozorabunko\/[^/]+\/cards\/[^/]+\/files\/[^/.]+\.html$/.test(e)?(s.contentType="text/html",i.arrayBuffer().then(e=>new TextDecoder("Shift_JIS").decode(e))):(/^data:,(<|%3c)/i.test(e)&&(s.contentType="text/html"),i.text())}).then(e=>{"blob"===t&&e instanceof Blob?s.responseBlob=e:"arraybuffer"===t&&e instanceof ArrayBuffer?s.responseBlob=Ao([e]):"json"===t?s.responseText=JSON.stringify(e):"string"==typeof e&&(s.responseText=e),o.schedule(s)}).catch(t=>{s.status>=400?R.warn(`Error fetching ${e} (${s.status}${s.statusText?" "+s.statusText:""})`):R.warn(t,`Error fetching ${e}`),o.schedule(s)}),n.result()}function Ao(e,t){return new Blob(e,{type:t||"application/octet-stream"})}var Fo=class{constructor(e,t){h(this,"parser",e),h(this,"type",t),h(this,"resources",{}),h(this,"fetchers",{})}load(e,t,i){e=Q(e);let n=this.resources[e];return void 0!==n?so(n):this.fetch(e,t,i).get()}fetchInner(e,t,i){let n=oo("fetch"),r=ie(e);r&&(e=ne(e));let o=ue("user-agent.xml",ae),s=!r&&e===o;return s&&(e=`data:application/xml,${encodeURIComponent(Co)}`),Io(e,this.type).then(a=>{if(a.status>=400&&t)throw new Error((i||`Failed to fetch required resource: ${e}`)+` (${a.status}${a.statusText?" "+a.statusText:""})`);r?(e=re(e),a.url=re(a.url)):s&&(a.url=e=o),this.parser(a,this).then(t=>{delete this.fetchers[e],this.resources[e]=t,n.finish(t)})}),n.result()}fetch(e,t,i){if(e=Q(e),this.resources[e])return null;let n=this.fetchers[e];return n||(n=new yo(()=>this.fetchInner(e,t,i),`Fetch ${e}`),this.fetchers[e]=n,n.start()),n}get(e){return this.resources[Q(e)]}delete(e){delete this.resources[Q(e)]}};function Ro(e,t){let i=e.responseText;return so(i?J(i):null)}function Oo(e,t,i){let n=new yo(()=>{let n=oo("loadElement"),r=n.suspend(e),o=!1,s=null,a=e=>{o||(o=!0,null!==s&&(clearTimeout(s),s=null),r.schedule(e?e.type:"timeout"))};if(e.addEventListener("load",a,!1),e.addEventListener("error",a,!1),e.addEventListener("abort",a,!1),"http://www.w3.org/2000/svg"==e.namespaceURI)t&&e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",t),s=setTimeout(a,300);else if("script"===e.localName)s=setTimeout(a,3e3);else if(t)if("img"===e.localName){let n=e;"lazy"===n.loading&&(n.loading="eager"),n.src=t,i&&(n.alt=i),n.complete?setTimeout(()=>a(new Event("load")),0):s=setTimeout(a,3e4)}else e.src=t,i&&(e.alt=i);else("img"===e.localName||"embed"===e.localName||"object"===e.localName||"iframe"===e.localName)&&(e.complete?setTimeout(()=>a(new Event("load")),0):s=setTimeout(a,3e4));return n.result()},`loadElement ${t||e.localName}`);return n.start(),n}var Lo=33554432,_o=50331648,Bo=67108864,Mo=class{constructor(e){h(this,"scope",e),h(this,"flavor"),this.flavor="Author"}getCurrentToken(){return null}getScope(){return this.scope}error(e,t){}startStylesheet(e){this.flavor=e}tagSelector(e,t){}classSelector(e){}pseudoclassSelector(e,t){}pseudoelementSelector(e,t){}idSelector(e){}attributeSelector(e,t,i,n,r){}descendantSelector(){}childSelector(){}adjacentSiblingSelector(){}followingSiblingSelector(){}nextSelector(){}startSelectorRule(){}startFontFaceRule(){}startCounterStyleRule(e){}startFootnoteRule(e){}startViewportRule(){}startDefineRule(){}startRegionRule(){}startPageRule(){}startPageMarginBoxRule(e){}startWhenRule(e){}startMediaRule(e){this.startWhenRule(e)}startLayerRule(e){}layerStatementRule(e){}startFlowRule(e){}startPageTemplateRule(){}startPageMasterRule(e,t,i){}startPartitionRule(e,t,i){}startPartitionGroupRule(e,t,i){}startRuleBody(){}property(e,t,i){}endRule(){}startFuncWithSelector(e,t){}endFuncWithSelector(){}pushSelectorText(e){}getImportantSpecificity(){switch(this.flavor){case"UA":return 0;case"User":return 100663296;default:return 83886080}}getBaseSpecificity(){switch(this.flavor){case"UA":return 0;case"User":return 16777216;default:return Lo}}},Do=class{constructor(e){h(this,"outer",e)}},zo=class extends Mo{constructor(e,t){super(e),h(this,"tokenizer",null),h(this,"initialSlave"),h(this,"slave"),this.initialSlave=this.slave=t(this)}delegateTo(e){let t=e(new Do(this.slave));return this.slave=t,t}takeBack(e){this.slave=e.outer}getCurrentToken(){return this.tokenizer?this.tokenizer.token():null}getScope(){return this.slave.getScope()}error(e,t){this.slave.error(e,t)}errorMsg(e,t){var i;R.warn(e,null!=(i=null==t?void 0:t.toString())?i:"")}startStylesheet(e){super.startStylesheet(e),this.slave=this.initialSlave,this.slave.startStylesheet(e)}tagSelector(e,t){this.slave.tagSelector(e,t)}classSelector(e){this.slave.classSelector(e)}pseudoclassSelector(e,t){this.slave.pseudoclassSelector(e,t)}pseudoelementSelector(e,t){this.slave.pseudoelementSelector(e,t)}idSelector(e){this.slave.idSelector(e)}attributeSelector(e,t,i,n,r){this.slave.attributeSelector(e,t,i,n,r)}descendantSelector(){this.slave.descendantSelector()}childSelector(){this.slave.childSelector()}adjacentSiblingSelector(){this.slave.adjacentSiblingSelector()}followingSiblingSelector(){this.slave.followingSiblingSelector()}nextSelector(){this.slave.nextSelector()}startSelectorRule(){this.slave.startSelectorRule()}startFontFaceRule(){this.slave.startFontFaceRule()}startCounterStyleRule(e){this.slave.startCounterStyleRule(e)}startFootnoteRule(e){this.slave.startFootnoteRule(e)}startViewportRule(){this.slave.startViewportRule()}startDefineRule(){this.slave.startDefineRule()}startRegionRule(){this.slave.startRegionRule()}startPageRule(){this.slave.startPageRule()}startPageMarginBoxRule(e){this.slave.startPageMarginBoxRule(e)}startWhenRule(e){this.slave.startWhenRule(e)}startLayerRule(e){this.slave.startLayerRule(e)}layerStatementRule(e){this.slave.layerStatementRule(e)}startFlowRule(e){this.slave.startFlowRule(e)}startPageTemplateRule(){this.slave.startPageTemplateRule()}startPageMasterRule(e,t,i){this.slave.startPageMasterRule(e,t,i)}startPartitionRule(e,t,i){this.slave.startPartitionRule(e,t,i)}startPartitionGroupRule(e,t,i){this.slave.startPartitionGroupRule(e,t,i)}startRuleBody(){this.slave.startRuleBody()}property(e,t,i){this.slave.property(e,t,i)}endRule(){this.slave.endRule()}startFuncWithSelector(e,t){this.slave.startFuncWithSelector(e,t)}endFuncWithSelector(){this.slave.endFuncWithSelector()}pushSelectorText(e){this.slave.pushSelectorText(e)}},Vo=class extends Mo{constructor(e,t,i){super(e),h(this,"owner",t),h(this,"delegation",i),h(this,"depth",0),this.flavor=t.flavor}getCurrentToken(){return this.owner.getCurrentToken()}error(e,t){this.owner.errorMsg(e,t)}startRuleBody(){this.depth++}endDelegation(){this.delegation&&this.owner.takeBack(this.delegation)}endRule(){0==--this.depth&&this.endDelegation()}},Uo=class extends Vo{constructor(e,t,i){super(e,t,i)}report(e){this.error(e,this.getCurrentToken())}reportAndSkip(e){this.report(e),this.owner.delegateTo(e=>new Vo(this.scope,this.owner,e))}startSelectorRule(){this.reportAndSkip("E_CSS_UNEXPECTED_SELECTOR")}startFontFaceRule(){this.reportAndSkip("E_CSS_UNEXPECTED_FONT_FACE")}startCounterStyleRule(e){this.reportAndSkip("E_CSS_UNEXPECTED_COUNTER_STYLE")}startFootnoteRule(e){this.reportAndSkip("E_CSS_UNEXPECTED_FOOTNOTE")}startViewportRule(){this.reportAndSkip("E_CSS_UNEXPECTED_VIEWPORT")}startDefineRule(){this.reportAndSkip("E_CSS_UNEXPECTED_DEFINE")}startRegionRule(){this.reportAndSkip("E_CSS_UNEXPECTED_REGION")}startPageRule(){this.reportAndSkip("E_CSS_UNEXPECTED_PAGE")}startWhenRule(e){this.reportAndSkip("E_CSS_UNEXPECTED_WHEN")}startLayerRule(e){this.reportAndSkip("E_CSS_UNEXPECTED_LAYER")}layerStatementRule(e){this.report("E_CSS_UNEXPECTED_LAYER")}startFlowRule(e){this.reportAndSkip("E_CSS_UNEXPECTED_FLOW")}startPageTemplateRule(){this.reportAndSkip("E_CSS_UNEXPECTED_PAGE_TEMPLATE")}startPageMasterRule(e,t,i){this.reportAndSkip("E_CSS_UNEXPECTED_PAGE_MASTER")}startPartitionRule(e,t,i){this.reportAndSkip("E_CSS_UNEXPECTED_PARTITION")}startPartitionGroupRule(e,t,i){this.reportAndSkip("E_CSS_UNEXPECTED_PARTITION_GROUP")}startFuncWithSelector(e,t){this.reportAndSkip("E_CSS_UNEXPECTED_SELECTOR_FUNC")}endFuncWithSelector(){this.reportAndSkip("E_CSS_UNEXPECTED_END_SELECTOR_FUNC")}property(e,t,i){this.error("E_CSS_UNEXPECTED_PROPERTY",this.getCurrentToken())}},Ho=[],$o=[],jo=[],Wo=[],Go=[],qo=[],Xo=[],Yo=[],Ko=[],Zo=[],Jo=[],Qo=[],es=[],ts=55,is=56;Ho[1]=28,Ho[36]=29,Ho[7]=29,Ho[9]=29,Ho[14]=29,Ho[18]=29,Ho[50]=29,Ho[20]=30,Ho[13]=27,Ho[0]=200,$o[1]=46,$o[0]=200,qo[1]=2,qo[36]=4,qo[7]=6,qo[9]=8,qo[14]=10,qo[18]=14,qo[50]=42,jo[37]=11,jo[23]=12,jo[35]=56,jo[1]=1,jo[36]=3,jo[7]=5,jo[9]=7,jo[14]=9,jo[12]=13,jo[18]=55,jo[50]=58,jo[16]=41,Wo[37]=11,Wo[23]=12,Wo[35]=56,Wo[1]=1,Wo[36]=3,Wo[7]=5,Wo[9]=7,Wo[14]=9,Wo[18]=55,Go[1]=2,Go[36]=4,Go[7]=6,Go[9]=8,Go[18]=14,Go[50]=42,Go[14]=10,Go[12]=13,Xo[1]=15,Xo[7]=16,Xo[4]=17,Xo[5]=18,Xo[3]=19,Xo[2]=20,Xo[8]=21,Xo[27]=57,Xo[16]=22,Xo[19]=23,Xo[6]=24,Xo[11]=25,Xo[17]=26,Xo[13]=48,Xo[31]=47,Xo[23]=54,Xo[0]=44,Yo[1]=31,Yo[4]=32,Yo[5]=32,Yo[3]=33,Yo[2]=34,Yo[10]=40,Yo[6]=38,Yo[31]=36,Yo[24]=36,Yo[32]=35,Ko[1]=45,Ko[16]=37,Ko[37]=37,Ko[38]=37,Ko[47]=37,Ko[48]=37,Ko[39]=37,Ko[49]=37,Ko[41]=37,Ko[26]=37,Ko[25]=37,Ko[23]=37,Ko[24]=37,Ko[19]=37,Ko[21]=37,Ko[36]=37,Ko[18]=37,Ko[22]=37,Ko[11]=39,Ko[12]=43,Ko[17]=49,Zo[0]=200,Zo[12]=50,Zo[13]=51,Zo[14]=50,Zo[15]=51,Zo[10]=50,Zo[11]=51,Zo[17]=53,Jo[0]=200,Jo[12]=50,Jo[13]=52,Jo[14]=50,Jo[15]=51,Jo[10]=50,Jo[11]=51,Jo[17]=53,Qo[0]=200,Qo[12]=50,Qo[13]=51,Qo[14]=50,Qo[15]=51,Qo[10]=50,Qo[11]=51,es[11]=0,es[16]=0,es[22]=1,es[18]=1,es[26]=2,es[25]=2,es[38]=3,es[37]=3,es[48]=3,es[47]=3,es[39]=3,es[49]=3,es[41]=3,es[23]=4,es[24]=4,es[36]=5,es[19]=5,es[21]=5,es[0]=6,es[ts]=2,es[is]=2;var ns=class{constructor(e,t,i,n){h(this,"actions",e),h(this,"tokenizer",t),h(this,"handler",i),h(this,"baseURL",n),h(this,"valStack",[]),h(this,"namespacePrefixToURI",{}),h(this,"defaultNamespaceURI",null),h(this,"propName",null),h(this,"propImportant",!1),h(this,"exprContext"),h(this,"result",null),h(this,"importReady",!1),h(this,"importURL",null),h(this,"importCondition",null),h(this,"importHasLayer",!1),h(this,"importLayerNames",null),h(this,"errorBrackets",[]),h(this,"ruleStack",[]),h(this,"regionRule",!1),h(this,"pageRule",!1),h(this,"inStyleDeclaration",!1),this.exprContext=2}extractVals(e,t){let i=[],n=this.valStack;for(;t<n.length&&(i.push(n[t++]),t!==n.length);){if(n[t++]!==e)throw new Error("Unexpected state");t===n.length&&i.push(Wt)}return i}valStackReduce(e,t){let i,n=this.valStack,r=n.length,o=0;do{if(i=n[--r],")"===e&&i instanceof hi)if(")"===i.text)o++;else if("("===i.text){if(0===o)return null;o--}}while(void 0!==i&&"string"!=typeof i);let s=n.length-(r+1);if(s>1&&n.splice(r+1,s,new oi(n.slice(r+1,n.length))),","==e)return null;r++;do{i=n[--r]}while(void 0!==i&&("string"!=typeof i||","==i));if(s=n.length-(r+1),"("==i){if(")"!=e&&0!==t.type)return this.handler.error("E_CSS_MISMATCHED_C_PAR",t),this.actions=Jo,null;let i=new ai(n[r-1],this.extractVals(",",r+1));if(n.splice(r-1,s+2,i),"var"===i.name){Si(i.values[0]instanceof Kt&&i.values[0].name||void 0)||(this.handler.error(`E_CSS_INVALID_VAR ${i.toString()}`,t),this.actions=Jo)}return i}if(";"!=e||r>=0)return this.handler.error("E_CSS_UNEXPECTED_VAL_END",t),this.actions=Jo,null;if(s>1)return new si(this.extractVals(",",r+1));let a=n[0];return a instanceof $t?a:a?new hi(a.toString()):Wt}exprError(e,t){this.actions=this.propName?Jo:Zo,R.warn(e,t.toString())}exprStackReduce(e,t){let i,n=this.valStack,r=this.handler,o=n.pop();for(;;){let s=n.pop();if(11==e){let t=[o];for(;16==s;)t.unshift(n.pop()),s=n.pop();if("string"==typeof s){if("{"==s){for(;t.length>=2;){let e=t.shift(),i=t.shift(),n=new pt(r.getScope(),e,i);t.unshift(n)}return n.push(new li(t[0])),!0}if("("==s){let i=n.pop(),s=n.pop();o=new At(r.getScope(),Ge(s,i),t),e=0;continue}}if(10==s){o.isMediaName()&&(o=new Ot(r.getScope(),o,null)),e=0;continue}}else if("string"==typeof s){n.push(s);break}if(s<0)if(-31==s)o=new at(r.getScope(),o);else if(-24==s)o=new ht(r.getScope(),o);else{if(-57!=s)return this.exprError("F_UNEXPECTED_STATE",t),!1;o=new lt(r.getScope(),o)}else{if(es[e]>es[s]){n.push(s);break}switch(i=n.pop(),s){case 26:o=new ut(r.getScope(),i,o);break;case ts:o=new ct(r.getScope(),i,o);break;case is:o=new ft(r.getScope(),i,o);break;case 25:o=new dt(r.getScope(),i,o);break;case 38:o=new gt(r.getScope(),i,o);break;case 37:o=new vt(r.getScope(),i,o);break;case 48:o=new mt(r.getScope(),i,o);break;case 47:o=new yt(r.getScope(),i,o);break;case 39:case 49:o=new bt(r.getScope(),i,o);break;case 41:o=new wt(r.getScope(),i,o);break;case 23:o=new xt(r.getScope(),i,o);break;case 24:o=new St(r.getScope(),i,o);break;case 36:o=new Ct(r.getScope(),i,o);break;case 19:o=new kt(r.getScope(),i,o);break;case 21:o=new Pt(r.getScope(),i,o);break;case 18:if(!(n.length>1))return this.exprError("E_CSS_EXPR_COND",t),!1;switch(n[n.length-1]){case 22:n.pop(),o=new Ft(r.getScope(),n.pop(),i,o);break;case 10:if(!i.isMediaName())return this.exprError("E_CSS_MEDIA_TEST",t),!1;o=new Ot(r.getScope(),i,o)}break;case 22:if(18!=e)return this.exprError("E_CSS_EXPR_COND",t),!1;case 10:return n.push(i),n.push(s),n.push(o),!1;default:return this.exprError("F_UNEXPECTED_STATE",t),!1}}}return n.push(o),!1}readLayerName(){let e=this.tokenizer,t=e.token();if(1!==t.type)return null;let i=[t.text];for(e.consume();;){if(t=e.token(),9!==t.type||t.precededBySpace)return i;i.push(t.text),e.consume()}}readSupportsTest(e){let t,i=6===e.type,n=this.tokenizer,r="";if(i)r=e.text,t=e.position+r.length+1;else{if(10!==e.type)return null;{let i=n.nthToken(1),o=n.nthToken(2);if(1===i.type&&18===o.type)n.consume(),n.consume(),r=i.text,t=o.position+1;else{if(10===i.type||6===i.type||1===i.type&&"not"===i.text.toLowerCase()&&(10===o.type||6===o.type))return null;t=e.position+1}}}let o,s=0,a=0;for(;s>=0;)switch(n.consume(),o=n.token(),o.type){case 11:s--;break;case 10:case 6:s++;break;case 16:0===s&&a++;break;case 0:return this.exprError("E_CSS_UNEXPECTED_EOF",o),null}n.consume();let l=o.position,h=n.input.substring(t,l),u=i&&"selector"===r&&a>0?"":Si(r)?h:h.trim();return new Lt(this.handler.getScope(),r,u,i)}readPseudoParams(){let e=[];for(;;){let t=this.tokenizer.token();switch(t.type){case 1:e.push(t.text);break;case 23:e.push("+");break;case 4:case 5:e.push(t.num);break;default:return e}this.tokenizer.consume()}}skipPseudoFunctionContents(){let e=0;for(;;){switch(this.tokenizer.token().type){case 0:return!1;case 11:if(0===e)return!0;e--;break;case 10:case 6:e++}this.tokenizer.consume()}}readNthPseudoParams(){let e=!1,t=this.tokenizer.token();if(23===t.type)e=!0,this.tokenizer.consume(),t=this.tokenizer.token();else if(1===t.type&&("even"===t.text||"odd"===t.text))return this.tokenizer.consume(),[2,"odd"===t.text?1:0];switch(t.type){case 3:if(e&&t.num<0)return null;case 1:if(e&&"-"===t.text.charAt(0))return null;if("n"===t.text||"-n"===t.text){if(e&&t.precededBySpace)return null;let i="-n"===t.text?-1:1;3===t.type&&(i=t.num);let n=0;this.tokenizer.consume(),t=this.tokenizer.token();let r=24===t.type,o=23===t.type||r;if(o&&(this.tokenizer.consume(),t=this.tokenizer.token()),5===t.type){if(n=t.num,1/n==-1/0){if(n=0,o)return null}else if(n<0){if(o)return null}else if(n>=0&&!o)return null;this.tokenizer.consume()}else if(o)return null;return[i,r&&n>0?-n:n]}if("n-"===t.text||"-n-"===t.text){if(e&&t.precededBySpace)return null;let i="-n-"===t.text?-1:1;if(3===t.type&&(i=t.num),this.tokenizer.consume(),t=this.tokenizer.token(),5===t.type)return t.num<0||1/t.num==-1/0?null:(this.tokenizer.consume(),[i,t.num])}else{let i=t.text.match(/^n(-[0-9]+)$/);if(i)return e&&t.precededBySpace?null:(this.tokenizer.consume(),[3===t.type?t.num:1,parseInt(i[1],10)]);if(i=t.text.match(/^-n(-[0-9]+)$/),i)return this.tokenizer.consume(),[-1,parseInt(i[1],10)]}return null;case 5:return e&&(t.precededBySpace||t.num<0)?null:(this.tokenizer.consume(),[0,t.num])}return null}makeCondition(e,t){let i=this.handler.getScope();if(t=t||i._true,e){let n=e.split(/\s+/);for(let e of n)switch(e){case"vertical":t=Bt(i,t,new at(i,new Nt(i,"pref-horizontal")));break;case"horizontal":t=Bt(i,t,new Nt(i,"pref-horizontal"));break;case"day":t=Bt(i,t,new at(i,new Nt(i,"pref-night-mode")));break;case"night":t=Bt(i,t,new Nt(i,"pref-night-mode"));break;default:t=i._false}}return t===i._true?null:new li(t)}isInsidePropertyOnlyRule(){switch(this.ruleStack[this.ruleStack.length-1]){case"[selector]":case"font-face":case"counter-style":case"-epubx-flow":case"-epubx-viewport":case"-epubx-define":case"-adapt-footnote-area":case"footnote":return!0}return!1}runParser(e,t,i,n,r,o){let s,a,l,h,u,c,d=this.handler,p=this.tokenizer,f=this.valStack,g=null,m=null;for(i&&(this.inStyleDeclaration=!0),n&&(this.exprContext=2,this.valStack.push("{"));e>0;--e)if(s=p.token(),r&&null===m&&(m=s.position-1,"("===p.input[m]&&m++),this.actions===Xo&&this.errorBrackets.length>0&&(s.type===this.errorBrackets[this.errorBrackets.length-1]||17===s.type||31===s.type)){if(s.type===this.errorBrackets[this.errorBrackets.length-1]&&(this.errorBrackets.pop(),11===s.type&&this.valStackReduce(")",s))){p.consume();continue}f.push(new hi(s.toString())),p.consume()}else switch(this.actions[s.type]){case 28:if(!this.inStyleDeclaration||18!=p.nthToken(1).type){this.isInsidePropertyOnlyRule()?(d.error("E_CSS_COLON_EXPECTED",p.nthToken(1)),this.actions=Jo):(this.actions=qo,d.startSelectorRule());continue}this.propName=s.text,this.propImportant=!1,p.consume(),p.consume(),this.actions=Xo,f.splice(0,f.length);continue;case 46:if(18!=p.nthToken(1).type){this.actions=Jo,d.error("E_CSS_COLON_EXPECTED",p.nthToken(1));continue}this.propName=s.text,this.propImportant=!1,p.consume(),p.consume(),this.actions=Xo,f.splice(0,f.length);continue;case 29:this.actions=qo,d.startSelectorRule();continue;case 1:if(!s.precededBySpace){this.actions=Qo,d.error("E_CSS_SPACE_EXPECTED",s);continue}d.descendantSelector();case 2:if(34==p.nthToken(1).type)if(p.consume(),p.consume(),l=this.namespacePrefixToURI[s.text],null!=l)switch(s=p.token(),s.type){case 1:d.tagSelector(l,s.text),this.actions=r?Wo:jo,p.consume();break;case 36:d.tagSelector(l,null),this.actions=r?Wo:jo,p.consume();break;default:this.actions=Zo,d.error("E_CSS_NAMESPACE",s)}else this.actions=Zo,d.error("E_CSS_UNDECLARED_PREFIX",s);else d.tagSelector(this.defaultNamespaceURI,s.text),this.actions=r?Wo:jo,p.consume();continue;case 3:if(!s.precededBySpace){this.actions=Qo,d.error("E_CSS_SPACE_EXPECTED",s);continue}d.descendantSelector();case 4:if(34==p.nthToken(1).type)switch(p.consume(),p.consume(),s=p.token(),s.type){case 1:d.tagSelector(null,s.text),this.actions=r?Wo:jo,p.consume();break;case 36:d.tagSelector(null,null),this.actions=r?Wo:jo,p.consume();break;default:this.actions=Zo,d.error("E_CSS_NAMESPACE",s)}else d.tagSelector(this.defaultNamespaceURI,null),this.actions=r?Wo:jo,p.consume();continue;case 5:s.precededBySpace&&d.descendantSelector();case 6:if(!s.text){d.error("E_CSS_SYNTAX",s),p.consume();continue}d.idSelector(s.text),this.actions=r?Wo:jo,p.consume();continue;case 7:s.precededBySpace&&d.descendantSelector();case 8:d.classSelector(s.text),this.actions=r?Wo:jo,p.consume();continue;case 55:s.precededBySpace&&d.descendantSelector();case 14:p.consume(),s=p.token();e:switch(s.type){case 1:d.pseudoclassSelector(s.text,null),p.consume(),this.actions=r?Wo:jo;continue;case 6:switch(h=s.text.toLowerCase(),p.consume(),h){case"is":case"not":case"where":case"has":this.actions=qo,d.startFuncWithSelector(h),this.runParser(Number.POSITIVE_INFINITY,!1,!1,!1,!0,"has"===h)?this.actions=jo:this.actions=Qo;continue;case"lang":case"href-epub-type":case"href-role-type":if(s=p.token(),1===s.type){c=[s.text],p.consume(),("href-epub-type"===h||"href-role-type"===h)&&16===p.token().type&&(p.consume(),s=p.token(),1===s.type&&(c.push(s.text),p.consume()));break}break e;case"nth-child":case"nth-of-type":case"nth-last-child":case"nth-last-of-type":case"nth":if(c=this.readNthPseudoParams(),c){if("nth-child"===h||"nth-last-child"===h){if(a=p.nthToken(0),1===a.type&&"of"===a.text){p.consume(),this.actions=qo,d.startFuncWithSelector(h,c),this.runParser(Number.POSITIVE_INFINITY,!1,!1,!1,!0,!1)?this.actions=r?Wo:jo:this.actions=Qo;continue}break}if("nth"===h){if(a=p.nthToken(0),1===a.type&&"of"===a.text){if(p.consume(),a=p.token(),1!==a.type)break e;c.push(a.text),p.consume()}break}break}break e;case"dir":if(s=p.token(),1===s.type&&11===p.nthToken(1).type){c=[s.text],p.consume();break}default:if(c=[],!this.skipPseudoFunctionContents())break e}if(s=p.token(),11==s.type){d.pseudoclassSelector(h,c),p.consume(),this.actions=r?Wo:jo;continue}}d.error("E_CSS_PSEUDOCLASS_SYNTAX",s),this.actions=Zo;continue;case 58:s.precededBySpace&&d.descendantSelector();case 42:switch(p.consume(),s=p.token(),s.type){case 1:d.pseudoelementSelector(s.text,null),this.actions=r?Wo:jo,p.consume();continue;case 6:if(h=s.text.toLowerCase(),p.consume(),"nth-fragment"==h){if(c=this.readNthPseudoParams(),null===c)break}else c=this.readPseudoParams();if(s=p.token(),11==s.type){d.pseudoelementSelector(h,c),this.actions=r?Wo:jo,p.consume();continue}}d.error("E_CSS_PSEUDOELEM_SYNTAX",s),this.actions=Zo;continue;case 9:s.precededBySpace&&d.descendantSelector();case 10:{if(p.consume(),s=p.token(),1==s.type)h=s.text,p.consume();else if(36==s.type)h=null,p.consume();else{if(34!=s.type){this.actions=Qo,d.error("E_CSS_ATTR",s),p.consume();continue}h=""}if(s=p.token(),34==s.type){if(l=h&&this.namespacePrefixToURI[h],void 0===l){this.actions=Qo,d.error("E_CSS_UNDECLARED_PREFIX",s),p.consume();continue}if(p.consume(),s=p.token(),1!=s.type){this.actions=Qo,d.error("E_CSS_ATTR_NAME_EXPECTED",s);continue}h=s.text,p.consume(),s=p.token()}else l="";switch(s.type){case 39:case 45:case 44:case 43:case 42:case 46:case 50:u=s.type,p.consume(),s=p.token();break;case 15:d.attributeSelector(l,h,0,null,null),this.actions=r?Wo:jo,p.consume();continue;default:this.actions=Qo,d.error("E_CSS_ATTR_OP_EXPECTED",s);continue}let e=h,t=null;switch(s.type){case 1:case 2:{let i=s.text;if(p.consume(),s=p.token(),1==s.type){let e=s.text.toLowerCase();("i"==e||"s"==e)&&(t=e,p.consume(),s=p.token())}d.attributeSelector(l,e,u,i,t);break}default:this.actions=Qo,d.error("E_CSS_ATTR_VAL_EXPECTED",s);continue}if(15!=s.type){this.actions=Qo,d.error("E_CSS_ATTR",s);continue}this.actions=r?Wo:jo,p.consume();continue}case 11:d.childSelector(),this.actions=Go,p.consume();continue;case 12:d.adjacentSiblingSelector(),this.actions=Go,p.consume();continue;case 56:d.followingSiblingSelector(),this.actions=Go,p.consume();continue;case 13:this.regionRule?(this.ruleStack.push("-epubx-region"),this.regionRule=!1):this.pageRule?(this.ruleStack.push("page"),this.pageRule=!1,this.inStyleDeclaration=!0):(this.ruleStack.push("[selector]"),this.inStyleDeclaration=!0),d.startRuleBody(),this.actions=Ho,p.consume();continue;case 41:d.nextSelector(),this.actions=qo,p.consume();continue;case 15:f.push(Zt(s.text)),p.consume();continue;case 16:u=parseInt(s.text,16),f.push(new ti(s.text)),p.consume();continue;case 17:f.push(new Qt(s.num)),p.consume();continue;case 18:f.push(new ei(s.num)),p.consume();continue;case 19:f.push(new Jt(s.num,s.text)),p.consume();continue;case 20:f.push(new Xt(s.text)),p.consume();continue;case 21:f.push(new ii(ue(s.text,this.baseURL))),p.consume();continue;case 57:f.push(new ni(s.text)),p.consume();continue;case 22:this.valStackReduce(",",s),f.push(","),p.consume();continue;case 23:f.push(qt),p.consume();continue;case 24:h=s.text.toLowerCase(),"-epubx-expr"==h||"env"==h?(this.actions=Yo,this.exprContext=0,f.push("{")):(f.push(h),f.push("("),this.errorBrackets.length>0&&this.errorBrackets.push(11)),p.consume();continue;case 25:this.valStackReduce(")",s),p.consume();continue;case 47:if(p.consume(),s=p.token(),a=p.nthToken(1),1==s.type&&"important"==s.text.toLowerCase()&&(17==a.type||0==a.type||13==a.type)){p.consume(),this.propImportant=!0;continue}this.exprError("E_CSS_SYNTAX",s);continue;case 54:switch(a=p.nthToken(1),a.type){case 4:case 3:case 5:if(!a.precededBySpace){p.consume();continue}}f.push(new hi("+")),p.consume();continue;case 26:p.consume();case 48:g=this.valStackReduce(";",s),g&&this.propName&&d.property(this.propName,g,this.propImportant),this.actions=i?$o:Ho;continue;case 44:for(p.consume();f.length>0;){let e=f.length;if(g=this.valStackReduce(";",s),!g||f.length===e)break}return t?(this.result=g,!0):(this.propName&&g&&d.property(this.propName,g,this.propImportant),!0);case 31:if(a=p.nthToken(1),9==a.type)10!=p.nthToken(2).type||p.nthToken(2).precededBySpace?(f.push(new Nt(d.getScope(),Ge(s.text,a.text))),this.actions=Ko):(f.push(s.text,a.text,"("),p.consume()),p.consume();else{if(2==this.exprContext||3==this.exprContext)"not"==s.text.toLowerCase()?(p.consume(),f.push(new Tt(d.getScope(),!0,a.text))):("only"==s.text.toLowerCase()&&(p.consume(),s=a),f.push(new Tt(d.getScope(),!1,s.text)));else{if(4===this.exprContext&&"not"===s.text.toLowerCase()&&f[f.length-1]!==ts&&f[f.length-1]!==is&&(10===a.type||6===a.type)){f.push(-57),p.consume();continue}f.push(new Nt(d.getScope(),s.text))}this.actions=Ko}p.consume();continue;case 38:if(4===this.exprContext){f.push(this.readSupportsTest(s)),this.actions=Ko;continue}f.push(null,s.text,"("),p.consume();continue;case 32:f.push(new Rt(d.getScope(),s.num)),p.consume(),this.actions=Ko;continue;case 33:h=s.text,"%"==h&&(h=this.propName&&this.propName.match(/height|^(top|bottom)$/)?"vh":"vw"),f.push(new Et(d.getScope(),s.num,h)),p.consume(),this.actions=Ko;continue;case 34:f.push(new Rt(d.getScope(),s.text)),p.consume(),this.actions=Ko;continue;case 35:p.consume(),s=p.token(),5!=s.type||s.precededBySpace?this.exprError("E_CSS_SYNTAX",s):(f.push(new _t(d.getScope(),s.num)),p.consume(),this.actions=Ko);continue;case 36:f.push(-s.type),p.consume();continue;case 37:this.actions=Yo,this.exprStackReduce(s.type,s),f.push(s.type),p.consume();continue;case 45:"and"===s.text.toLowerCase()&&f[f.length-2]!==is&&-57!==f[f.length-2]?(this.actions=Yo,this.exprStackReduce(ts,s),f.push(ts),p.consume()):"or"===s.text.toLowerCase()&&f[f.length-2]!==ts&&-57!==f[f.length-2]?(this.actions=Yo,this.exprStackReduce(is,s),f.push(is),p.consume()):this.exprError("E_CSS_SYNTAX",s);continue;case 39:this.exprStackReduce(s.type,s)&&(this.actions=Xo),p.consume();continue;case 43:this.exprStackReduce(11,s)&&(this.propName||3==this.exprContext?this.exprError("E_CSS_UNEXPECTED_BRC",s):(1==this.exprContext?d.startWhenRule(f.pop()):d.startMediaRule(f.pop()),this.ruleStack.push("media"),d.startRuleBody(),this.actions=Ho)),p.consume();continue;case 49:if(this.exprStackReduce(11,s))return this.propName||3!=this.exprContext?(this.exprError("E_CSS_UNEXPECTED_SEMICOL",s),this.actions=Ho,p.consume(),!1):(this.importCondition=f.pop(),this.importReady=!0,this.actions=Ho,p.consume(),!1);p.consume();continue;case 40:if(4===this.exprContext){let e=this.readSupportsTest(s);if(e){f.push(e),this.actions=Ko;continue}}f.push(s.type),p.consume();continue;case 27:if(this.actions=Ho,p.consume(),d.endRule(),this.inStyleDeclaration=!1,this.ruleStack.length)switch(this.ruleStack.pop(),this.ruleStack[this.ruleStack.length-1]){case"page":case"-epubx-page-master":case"-epubx-partition-group":this.inStyleDeclaration=!0}continue;case 30:switch(h=s.text.toLowerCase(),h){case"import":if(p.consume(),s=p.token(),2==s.type||8==s.type){if(this.importURL=s.text,p.consume(),s=p.token(),1==s.type&&"layer"==s.text.toLowerCase())this.importHasLayer=!0,this.importLayerNames=null,p.consume(),s=p.token();else if(6==s.type&&"layer"==s.text.toLowerCase()){p.consume();let e=this.readLayerName();if(s=p.token(),!e||11!=s.type){d.error("E_CSS_IMPORT_SYNTAX",s),this.actions=Zo;continue}this.importHasLayer=!0,this.importLayerNames=e,p.consume(),s=p.token()}if(17==s.type||0==s.type)return this.importReady=!0,p.consume(),!1;this.propName=null,this.exprContext=3,this.actions=Yo,f.push("{");continue}d.error("E_CSS_IMPORT_SYNTAX",s),this.actions=Zo;continue;case"namespace":switch(p.consume(),s=p.token(),s.type){case 1:if(h=s.text,p.consume(),s=p.token(),(2==s.type||8==s.type)&&17==p.nthToken(1).type){this.namespacePrefixToURI[h]=s.text,p.consume(),p.consume();continue}break;case 2:case 8:if(17==p.nthToken(1).type){this.defaultNamespaceURI=s.text,p.consume(),p.consume();continue}}d.error("E_CSS_NAMESPACE_SYNTAX",s),this.actions=Zo;continue;case"charset":if(p.consume(),s=p.token(),2==s.type&&17==p.nthToken(1).type){h=s.text.toLowerCase(),"utf-8"!=h&&"utf-16"!=h&&d.error(`E_CSS_UNEXPECTED_CHARSET ${h}`,s),p.consume(),p.consume();continue}d.error("E_CSS_CHARSET_SYNTAX",s),this.actions=Zo;continue;case"font-face":case"-epubx-page-template":case"-epubx-define":case"-epubx-viewport":if(12==p.nthToken(1).type){switch(p.consume(),p.consume(),h){case"font-face":d.startFontFaceRule(),this.inStyleDeclaration=!0;break;case"-epubx-page-template":d.startPageTemplateRule();break;case"-epubx-define":d.startDefineRule(),this.inStyleDeclaration=!0;break;case"-epubx-viewport":d.startViewportRule(),this.inStyleDeclaration=!0}this.ruleStack.push(h),d.startRuleBody();continue}break;case"-epubx-region":p.consume(),d.startRegionRule(),this.regionRule=!0,this.actions=qo;continue;case"page":p.consume(),d.startPageRule(),this.pageRule=!0,this.actions=Go;continue;case"-adapt-footnote-area":case"footnote":switch(p.consume(),s=p.token(),s.type){case 12:p.consume(),d.startFootnoteRule(null),this.ruleStack.push(h),d.startRuleBody(),this.inStyleDeclaration=!0;continue;case 50:if(p.consume(),s=p.token(),1==s.type&&12==p.nthToken(1).type){let e=s.text;p.consume(),p.consume(),d.startFootnoteRule(e),this.ruleStack.push("footnote"===h?"footnote":"-adapt-footnote-area"),d.startRuleBody(),this.inStyleDeclaration=!0;continue}}break;case"top-left-corner":case"top-left":case"top-center":case"top-right":case"top-right-corner":case"right-top":case"right-middle":case"right-bottom":case"bottom-right-corner":case"bottom-right":case"bottom-center":case"bottom-left":case"bottom-left-corner":case"left-bottom":case"left-middle":case"left-top":if(p.consume(),s=p.token(),12==s.type){p.consume(),d.startPageMarginBoxRule(h),this.ruleStack.push(h),d.startRuleBody(),this.inStyleDeclaration=!0;continue}break;case"-epubx-when":p.consume(),this.propName=null,this.exprContext=1,this.actions=Yo,f.push("{");continue;case"media":p.consume(),this.propName=null,this.exprContext=2,this.actions=Yo,f.push("{");continue;case"supports":p.consume(),this.propName=null,this.exprContext=4,this.actions=Yo,f.push("{");continue;case"layer":{if(p.consume(),s=p.token(),12==s.type){p.consume(),d.startLayerRule(null),this.ruleStack.push(h),d.startRuleBody();continue}let e=[];for(;;){let t=this.readLayerName();if(!t){e.length=0;break}if(e.push(t),16!=p.token().type)break;p.consume()}if(e.length>0){if(s=p.token(),17==s.type){p.consume(),d.layerStatementRule(e);continue}if(12==s.type&&1==e.length){p.consume(),d.startLayerRule(e[0]),this.ruleStack.push(h),d.startRuleBody();continue}}break}case"-epubx-flow":if(1==p.nthToken(1).type&&12==p.nthToken(2).type){d.startFlowRule(p.nthToken(1).text),p.consume(),p.consume(),p.consume(),this.ruleStack.push(h),d.startRuleBody(),this.inStyleDeclaration=!0;continue}break;case"counter-style":if(1==p.nthToken(1).type&&12==p.nthToken(2).type){d.startCounterStyleRule(p.nthToken(1).text),p.consume(),p.consume(),p.consume(),this.ruleStack.push(h),d.startRuleBody(),this.inStyleDeclaration=!0;continue}break;case"-epubx-page-master":case"-epubx-partition":case"-epubx-partition-group":{p.consume(),s=p.token();let e=null,t=null,i=[];for(1==s.type&&(e=s.text,p.consume(),s=p.token()),18==s.type&&1==p.nthToken(1).type&&(t=p.nthToken(1).text,p.consume(),p.consume(),s=p.token());6==s.type&&"class"==s.text.toLowerCase()&&1==p.nthToken(1).type&&11==p.nthToken(2).type;)i.push(p.nthToken(1).text),p.consume(),p.consume(),p.consume(),s=p.token();if(12==s.type){switch(p.consume(),h){case"-epubx-page-master":d.startPageMasterRule(e,t,i);break;case"-epubx-partition":d.startPartitionRule(e,t,i);break;case"-epubx-partition-group":d.startPartitionGroupRule(e,t,i)}this.ruleStack.push(h),d.startRuleBody(),this.inStyleDeclaration=!0;continue}break}case"":d.error(`E_CSS_UNEXPECTED_AT${h}`,s),this.actions=Qo;continue;default:d.error(`E_CSS_AT_UNKNOWN ${h}`,s),this.actions=Zo;continue}d.error(`E_CSS_AT_SYNTAX ${h}`,s),this.actions=Zo;continue;case 50:this.errorBrackets.push(s.type+1),p.consume();continue;case 52:if(0==this.errorBrackets.length){this.actions=Ho;continue}case 51:if(r&&0==this.errorBrackets.length&&11==s.type)return p.consume(),d.endFuncWithSelector(),!0;this.errorBrackets.length>0&&this.errorBrackets[this.errorBrackets.length-1]==s.type&&this.errorBrackets.pop(),0==this.errorBrackets.length&&13==s.type&&(this.actions=Ho),p.consume();continue;case 53:if(r&&0==this.errorBrackets.length&&16==s.type){d.nextSelector(),this.actions=qo,m=s.position+1,p.consume();continue}0==this.errorBrackets.length&&(this.actions=Ho),p.consume();continue;case 200:return!0;default:if(n)return!!this.exprStackReduce(11,s)&&(this.result=f.pop(),!0);if(r){if(this.actions===Qo)switch(s.type){case 16:0==this.errorBrackets.length&&(d.nextSelector(),m=s.position+1,this.actions=qo),p.consume();continue;case 11:if(0==this.errorBrackets.length)return d.endFuncWithSelector(),p.consume(),!0;this.errorBrackets.length>0&&this.errorBrackets[this.errorBrackets.length-1]==s.type&&this.errorBrackets.pop(),p.consume();continue;case 12:case 14:case 10:this.errorBrackets.push(s.type+1),p.consume();continue;case 6:this.errorBrackets.push(11),p.consume();continue;case 13:case 15:this.errorBrackets.length>0&&this.errorBrackets[this.errorBrackets.length-1]==s.type&&this.errorBrackets.pop(),p.consume();continue;default:p.consume();continue}switch(s.type){case 16:case 11:if(this.actions===qo)d.error("E_CSS_SYNTAX",s);else{let e=p.input.substring(m,s.position);d.pushSelectorText(e),m=s.position+1}if(16===s.type){d.nextSelector(),this.actions=qo,p.consume();continue}return d.endFuncWithSelector(),p.consume(),!0;case 37:case 23:case 35:if(o){this.actions=jo;continue}break;case 12:case 14:case 10:this.errorBrackets.push(s.type+1)}d.error("E_CSS_SYNTAX",s),p.consume(),this.actions=Qo;continue}if(this.actions!==Zo&&this.actions!==Qo&&this.actions!==Jo){if(54==s.type)d.error("E_CSS_SYNTAX",s);else{if(this.actions===Xo){switch(s.type){case 10:case 12:case 14:this.errorBrackets.push(s.type+1)}f.push(new hi(s.toString())),p.consume();continue}if(12===s.type&&this.actions==Yo&&f.length>0){d.startMediaRule(f.pop()),this.ruleStack.push("media"),d.startRuleBody(),this.actions=Ho,p.consume();continue}if(17===s.type&&this.actions==Yo)return this.actions=Ho,p.consume(),!1;d.error("E_CSS_SYNTAX",s)}this.isInsidePropertyOnlyRule()?this.actions=Jo:this.actions=Qo;continue}p.consume();continue}return!1}},rs=class extends Mo{constructor(e){super(e)}error(e,t){R.warn(e,t.toString())}};function os(e,t,i,n,r){let o=oo("parseStylesheet"),s=new ns(Ho,e,t,i),a=null;return r&&(a=hs(new to(r,t),t,i)),a=s.makeCondition(n,a&&a.toExpr()),a&&(t.startMediaRule(a),t.startRuleBody()),o.loop(()=>{for(;!s.runParser(100,!1,!1,!1,!1);){if(s.importReady){let e=ue(s.importURL,i);s.importHasLayer&&(t.startLayerRule(s.importLayerNames),t.startRuleBody()),s.importCondition&&(t.startMediaRule(s.importCondition),t.startRuleBody());let n=oo("parseStylesheet.import");return as(e,t,null,null).then(()=>{s.importCondition&&t.endRule(),s.importHasLayer&&t.endRule(),s.importReady=!1,s.importURL=null,s.importCondition=null,s.importHasLayer=!1,s.importLayerNames=null,n.finish(!0)}),n.result()}let e=o.timeSlice();if(e.isPending)return e}return so(!1)}).then(()=>{a&&t.endRule(),o.finish(!0)}),o.result()}function ss(e,t,i,n,r){return ao("parseStylesheetFromText",o=>{(function(e,t,i,n,r){let o=null!=i?i:"",s=Qn(e.input);return s!==e.input?os(new to(s,t),t,o,n,r):os(e,t,o,n,r)})(new to(e,t),t,i,n,r).thenFinish(o)},(t,i)=>{R.warn(i,`Failed to parse stylesheet text: ${e}`),t.finish(!1)})}function as(e,t,i,n){return ao("parseStylesheetFromURL",r=>{Io(e).then(o=>{o.responseText?ss(o.responseText,t,e,i,n).then(t=>{t||R.warn(`Failed to parse stylesheet from ${e}`),r.finish(!0)}):r.finish(!0)})},(t,i)=>{R.warn(i,"Exception while fetching and parsing:",e),t.finish(!0)})}function ls(e,t,i){let n=new ns(Xo,t,new rs(e),i);return n.runParser(Number.POSITIVE_INFINITY,!0,!1,!1,!1),n.result}function hs(e,t,i){let n=new ns(Yo,e,t,i);return n.runParser(Number.POSITIVE_INFINITY,!1,!1,!0,!1),n.result}var us={"z-index":!0,"column-count":!0,"flow-linger":!0,opacity:!0,page:!0,"flow-priority":!0,utilization:!0};function cs(e,t,i){if(t instanceof It&&"viv-leader"===t.str)return new li(t);if("content"===i&&t instanceof It)return new li(t);let n=t.evaluate(e);switch(typeof n){case"number":return function(e){return!(!e||!us[e])}(i)?n==Math.round(n)?new ei(n):new Qt(n):new Jt(n,"px");case"string":return n?"content"===i?new Xt(n):ls(t.scope,new to(n,null),""):Wt;case"boolean":return n?di._true:di._false;case"undefined":return Wt}throw new Error("E_UNEXPECTED")}function ds(e){let t,i=(null==e?void 0:e.toString())||"block";switch(i){case"inline-flex":t="flex";break;case"inline-grid":t="grid";break;case"inline-table":t="table";break;case"initial":case"unset":case"inline":case"table-row-group":case"table-column":case"table-column-group":case"table-header-group":case"table-footer-group":case"table-row":case"table-cell":case"table-caption":case"inline-block":t="block";break;default:t=i}return Zt(t)}function ps(e){return e===di.absolute||e===di.fixed}function fs(e){return e instanceof ai&&"running"===e.name}function gs(e,t,i,n){return e===di.none||(ps(t)?(i=di.none,e=ds(e)):(i&&i!==di.none&&!yi(i)||n)&&(e=ds(e))),{display:e,position:t,float:i}}function ms(e){return e instanceof Kt||e instanceof oi||"string"==typeof e}function vs(e){if(!ms(e))return!1;let t=e.toString();switch(t){case"inline":case"inline-block":case"inline-flex":case"inline-grid":case"ruby":case"inline-table":return!0;default:return t.includes("inline")}}function ys(e){return!!ms(e)&&e.toString().includes("list-item")}function bs(e){if(!ms(e))return!1;switch(e.toString()){case"block":case"flex":case"grid":case"table":case"list-item":case"flow-root":return!0;default:return!1}}function ws(e){if(!ms(e))return!1;switch(e.toString()){case"ruby-base":case"ruby-text":case"ruby-base-container":case"ruby-text-container":return!0;default:return!1}}function xs(e){var t,i;return"clone"===(null==(t=null==e?void 0:e.style)?void 0:t["box-decoration-break"])||"clone"===(null==(i=null==e?void 0:e.style)?void 0:i["-webkit-box-decoration-break"])}function Ss(e){let t=e.getAttribute("data-viv-box-break");return t?t.split(" "):[]}function Cs(e,t){e.setAttribute("data-viv-box-break",t.join(" "))}function ks(e,t){let i=Ss(e);i.includes(t)||(i.push(t),Cs(e,i))}function Ps(e,t){let i=function(e){let t=e.getAttribute("data-viv-margin-discard");return t?t.split(" "):[]}(e);i.includes(t)||(i.push(t),function(e,t){e.setAttribute("data-viv-margin-discard",t.join(" "))}(e,i))}var Es={page:!0,left:!0,right:!0,recto:!0,verso:!0,column:!0,region:!0};function Ns(e){return null!=e&&!!Es[e]}var Ts={left:!0,right:!0,recto:!0,verso:!0};function Is(e){return null!=e&&!!Ts[e]}function As(e){return Ns(e)&&"column"!==e&&"region"!==e}var Fs={avoid:!0,"avoid-page":!0,"avoid-column":!0,"avoid-region":!0};function Rs(e){return null!=e&&!!Fs[e]}function Os(e,t){if(!e)return t;if(!t)return e;if(Is(t))return t;if(Is(e))return e;{let i=Ns(e),n=Ns(t);if(!i||!n)return n?t:i?e:Rs(t)?t:Rs(e)?e:t;switch(t){case"column":return e;case"region":return"column"===e?t:e;default:return t}}}function Ls(e){return null!=e&&Ns(e)?e:"auto"}_("SIMPLE_PROPERTY",function(e){let t=e.name,i=e.value;switch(t){case"page-break-before":case"page-break-after":case"page-break-inside":return{name:t.replace(/^page-/,""),value:i===di.always?di.page:i,important:e.important};default:return e}});var _s,Bs,Ms,Ds,zs,Vs,Us=((e,n,r)=>(r=null!=e?t(o(e)):{},l(!n&&e&&e.__esModule?r:i(r,"default",{value:e,enumerable:!0}),e)))(v());function Hs(e){return e.reduce((e,t)=>t[0]===Us.default.DELETE?e:e+t[1],"")}function $s(e,t,i){let n=0,r=0;return e.some(e=>{for(let o=0;o<e[1].length;o++){switch(e[0]*i){case Us.default.INSERT:n++;break;case Us.default.DELETE:n--,r++;break;case Us.default.EQUAL:r++}if(r>t)return!0}return!1}),Math.max(Math.min(t,r-1)+n,0)}(e=>{e.isInstanceOfBlockFormattingContext=function(e){return"Block"===e.formattingContextType}})(_s||(_s={})),(e=>{var t;(t=e.FloatReference||(e.FloatReference={})).INLINE="inline",t.COLUMN="column",t.REGION="region",t.PAGE="page"})(Bs||(Bs={})),(e=>{e.isInstanceOfAfterIfContinuesLayoutConstraint=function(e){return e&&"AfterIfContinue"==e.flagmentLayoutConstraintType}})(Ms||(Ms={})),(e=>{e.isInstanceOfRepetitiveElementsOwnerFormattingContext=function(e){return"RepetitiveElementsOwner"===e.formattingContextType||zs.isInstanceOfTableFormattingContext(e)},e.isInstanceOfRepetitiveElementsOwnerLayoutConstraint=function(e){return!!e&&("RepetitiveElementsOwner"===e.flagmentLayoutConstraintType||zs.isInstanceOfTableRowLayoutConstraint(e))}})(Ds||(Ds={})),(e=>{e.isInstanceOfTableFormattingContext=function(e){return"Table"===e.formattingContextType},e.isInstanceOfTableRowLayoutConstraint=function(e){return e&&"TableRow"===e.flagmentLayoutConstraintType}})(zs||(zs={})),(e=>{var t,i;(t=e.Whitespace||(e.Whitespace={}))[t.IGNORE=0]="IGNORE",t[t.NEWLINE=1]="NEWLINE",t[t.PRESERVE=2]="PRESERVE",(i=e.ShadowType||(e.ShadowType={}))[i.NONE=0]="NONE",i[i.CONTENT=1]="CONTENT",i[i.ROOTLESS=2]="ROOTLESS",i[i.ROOTED=3]="ROOTED"})(Vs||(Vs={}));var js={transform:!0,"transform-origin":!0},Ws={top:!0,bottom:!0,left:!0,right:!0},Gs=class{constructor(e,t,i){h(this,"target",e),h(this,"name",t),h(this,"value",i)}},qs={show:function(e){e.style.visibility="visible"},hide:function(e){e.style.visibility="hidden"},play:function(e){e.currentTime=0,e.play()},pause:function(e){e.pause()},resume:function(e){e.play()},mute:function(e){e.muted=!0},unmute:function(e){e.muted=!1}};function Xs(e,t){let i=qs[t];return i?()=>{for(let t=0;t<e.length;t++)try{i(e[t])}catch{}}:null}var Ys=class e extends De{constructor(e,t){super(),h(this,"container",e),h(this,"bleedBox",t),h(this,"pageAreaElement",null),h(this,"delayedItems",[]),h(this,"hrefHandler"),h(this,"elementsById",{}),h(this,"dimensions",{width:0,height:0}),h(this,"isFirstPage",!1),h(this,"isLastPage",!1),h(this,"isBlankPage",!1),h(this,"isAutoPageWidth",!0),h(this,"isAutoPageHeight",!0),h(this,"spineIndex",0),h(this,"position",null),h(this,"offset",-1),h(this,"side",null),h(this,"fetchers",[]),h(this,"marginBoxes",{top:{},bottom:{},left:{},right:{}}),h(this,"pageFloatLayoutContext",null),h(this,"pageType",null),this.hrefHandler=e=>{let t=e.currentTarget,i=t.getAttribute("href")||t.getAttributeNS("http://www.w3.org/1999/xlink","href");if(i){let n={type:"hyperlink",target:null,currentTarget:null,anchorElement:t,href:i,preventDefault(){e.preventDefault()}};this.dispatchEvent(n)}}}setAutoPageWidth(t){this.isAutoPageWidth=t,t?this.container.setAttribute(e.AUTO_PAGE_WIDTH_ATTRIBUTE,"true"):this.container.removeAttribute(e.AUTO_PAGE_WIDTH_ATTRIBUTE)}setAutoPageHeight(t){this.isAutoPageHeight=t,t?this.container.setAttribute(e.AUTO_PAGE_HEIGHT_ATTRIBUTE,"true"):this.container.removeAttribute(e.AUTO_PAGE_HEIGHT_ATTRIBUTE)}registerElementWithId(e,t){let i=this.elementsById[t];i?i.push(e):this.elementsById[t]=[e]}finish(e,t){Object.keys(this.elementsById).forEach(e=>{let t=this.elementsById[e];for(let e=0;e<t.length;)this.container.contains(t[e])?e++:t.splice(e,1);0===t.length&&delete this.elementsById[e]});let i=this.delayedItems;for(let e=0;e<i.length;e++){let t=i[e];t.target===this.container&&"transform"===t.name&&!this.isAutoPageWidth&&!this.isAutoPageHeight||be(t.target,t.name,t.value.toString())}let n=t.getElementClientRect(this.container);this.dimensions.width=n.width,this.dimensions.height=n.height;for(let t=0;t<e.length;t++){let i=e[t],n=this.elementsById[i.ref],r=this.elementsById[i.observer];if(n&&r){let e=Xs(n,i.action);if(e)for(let t=0;t<r.length;t++)r[t].addEventListener(i.event,e,!1)}}}};h(Ys,"AUTO_PAGE_WIDTH_ATTRIBUTE","data-vivliostyle-auto-page-width"),h(Ys,"AUTO_PAGE_HEIGHT_ATTRIBUTE","data-vivliostyle-auto-page-height");var Ks=Ys,Zs=Vs.Whitespace;function Js(e){switch(e){case"normal":case"nowrap":return Zs.IGNORE;case"pre-line":return Zs.NEWLINE;case"pre":case"pre-wrap":case"break-spaces":return Zs.PRESERVE;default:return null}}function Qs(e,t){return!e||1!=e.nodeType&&ea(e.textContent,t)}function ea(e,t){switch(t){case Zs.PRESERVE:return 0==e.length;case Zs.NEWLINE:return!!e.match(/^[ \t]*$/);case Zs.IGNORE:default:return!!e.match(/^[ \t\r\n\f]*$/)}}var ta=class{constructor(e,t,i){h(this,"flowName",e),h(this,"parentFlowName",t),h(this,"formattingContext",i),h(this,"forcedBreakOffsets",[])}},ia=class{constructor(e,t,i,n,r,o,s,a,l){h(this,"flowName",e),h(this,"element",t),h(this,"startOffset",i),h(this,"priority",n),h(this,"linger",r),h(this,"exclusive",o),h(this,"repeated",s),h(this,"last",a),h(this,"breakBefore",l),h(this,"startPage",-1)}isBetter(e){return!!this.exclusive&&(!e.exclusive||this.priority>e.priority||this.last)}};function na(e,t){return e.top-t.top}function ra(e,t){return t.right-e.right}function oa(e,t){var i,n;return e===t||!(!e||!t)&&((e.node===t.node||!!e.shadowContext&&!!t.shadowContext&&e.shadowType===Vs.ShadowType.ROOTLESS&&t.shadowType===Vs.ShadowType.ROOTLESS&&(null==(i=e.node)?void 0:i.outerHTML)===(null==(n=t.node)?void 0:n.outerHTML))&&e.shadowType===t.shadowType&&fa(e.shadowContext,t.shadowContext)&&fa(e.nodeShadow,t.nodeShadow)&&oa(e.shadowSibling,t.shadowSibling))}function sa(e,t){if(e===t)return!0;if(!e||!t||e.offsetInNode!==t.offsetInNode||e.after!==t.after||e.steps.length!==t.steps.length)return!1;for(let i=0;i<e.steps.length;i++)if(!oa(e.steps[i],t.steps[i]))return!1;return!0}function aa(e,t){return{steps:[{node:e.sourceNode,shadowType:da.NONE,shadowContext:e.shadowContext,nodeShadow:null,shadowSibling:null,formattingContext:e.formattingContext,fragmentIndex:null!=t?t:e.fragmentIndex}],offsetInNode:0,after:!1,preprocessedTextContent:e.preprocessedTextContent}}function la(e,t){var i;let n=t,r=new ma(e.node,n,0,null!=(i=e.formattingContext)?i:n.formattingContext);return r.blockContainer=Pa(n),ua(r,e),r.shadowSibling=e.shadowSibling?la(e.shadowSibling,t.copy()):null,r}function ha(e,t){var i;let n=new ma(e.node,null,0,null!=(i=e.formattingContext)?i:t);return ua(n,e),n.shadowSibling=e.shadowSibling,n}function ua(e,t){e.shadowType=t.shadowType,e.shadowContext=t.shadowContext,e.nodeShadow=t.nodeShadow,e.fragmentIndex=t.fragmentIndex+1}function ca(e){return e.steps[e.steps.length-1]}var da=Vs.ShadowType,pa=class{constructor(e,t,i,n,r,o,s){h(this,"owner",e),h(this,"root",t),h(this,"xmldoc",i),h(this,"parentShadow",n),h(this,"type",o),h(this,"styler",s),h(this,"subShadow",null),r&&(r.subShadow=this)}equals(e){return!!e&&(this.owner===e.owner&&this.xmldoc===e.xmldoc&&this.type===e.type&&fa(this.parentShadow,e.parentShadow))}};function fa(e,t){return e===t||!!e&&!!t&&e.equals(t)}var ga=class{constructor(e,t){h(this,"outer",e),h(this,"count",t)}},ma=class e{constructor(e,t,i,n){h(this,"sourceNode",e),h(this,"parent",t),h(this,"boxOffset",i),h(this,"formattingContext",n),h(this,"offsetInNode",0),h(this,"after",!1),h(this,"shadowType"),h(this,"shadowContext"),h(this,"nodeShadow",null),h(this,"shadowSibling",null),h(this,"shared",!1),h(this,"inline",!0),h(this,"overflow",!1),h(this,"breakPenalty"),h(this,"display",null),h(this,"floatReference"),h(this,"floatSide",null),h(this,"clearSide",null),h(this,"floatMinWrapBlock",null),h(this,"columnSpan",null),h(this,"captionSide","top"),h(this,"inlineBorderSpacing",0),h(this,"blockBorderSpacing",0),h(this,"flexContainer",!1),h(this,"whitespace"),h(this,"hyphenateCharacter"),h(this,"breakWord"),h(this,"establishesBFC",!1),h(this,"containingBlockForAbsolute",!1),h(this,"breakBefore",null),h(this,"breakAfter",null),h(this,"viewNode",null),h(this,"clearSpacer",null),h(this,"inheritedProps"),h(this,"vertical"),h(this,"direction"),h(this,"firstPseudo"),h(this,"lang",null),h(this,"preprocessedTextContent",null),h(this,"repeatOnBreak",null),h(this,"pluginProps",{}),h(this,"fragmentIndex",1),h(this,"afterIfContinues",null),h(this,"footnotePolicy",null),h(this,"pageType"),h(this,"blockContainer",null),this.shadowType=da.NONE,this.shadowContext=t?t.shadowContext:null,this.breakPenalty=t?t.breakPenalty:0,this.floatReference=Bs.FloatReference.INLINE,this.whitespace=t?t.whitespace:Zs.IGNORE,this.hyphenateCharacter=t?t.hyphenateCharacter:null,this.breakWord=!!t&&t.breakWord,this.inheritedProps=t?t.inheritedProps:{},this.vertical=!!t&&t.vertical,this.direction=t?t.direction:"ltr",this.firstPseudo=t?t.firstPseudo:null,this.pageType=t?t.pageType:null}static childOf(t,i,n){let r=new e(t,i,n,i.formattingContext);return r.blockContainer=Pa(i),r}static siblingOf(t,i,n){let r=i.parent,o=new e(t,r,n,(null!=r?r:i).formattingContext);return o.blockContainer=i.blockContainer,o}resetView(){this.inline=!0,this.breakPenalty=this.parent?this.parent.breakPenalty:0,this.viewNode=null,this.clearSpacer=null,this.offsetInNode=0,this.after=!1,this.display=null,this.floatReference=Bs.FloatReference.INLINE,this.floatSide=null,this.clearSide=null,this.floatMinWrapBlock=null,this.columnSpan=null,this.flexContainer=!1,this.whitespace=this.parent?this.parent.whitespace:Zs.IGNORE,this.hyphenateCharacter=this.parent?this.parent.hyphenateCharacter:null,this.breakWord=!!this.parent&&this.parent.breakWord,this.breakBefore=null,this.breakAfter=null,this.nodeShadow=null,this.establishesBFC=!1,this.containingBlockForAbsolute=!1,this.vertical=!!this.parent&&this.parent.vertical,this.nodeShadow=null,this.preprocessedTextContent=null,this.parent&&(this.formattingContext=this.parent.formattingContext),this.repeatOnBreak=null,this.pluginProps={},this.fragmentIndex=1,this.afterIfContinues=null,this.footnotePolicy=null,this.pageType=this.parent?this.parent.pageType:null}cloneItem(){let t=new e(this.sourceNode,this.parent,this.boxOffset,this.formattingContext);return t.offsetInNode=this.offsetInNode,t.after=this.after,t.nodeShadow=this.nodeShadow,t.shadowType=this.shadowType,t.shadowContext=this.shadowContext,t.shadowSibling=this.shadowSibling,t.inline=this.inline,t.breakPenalty=this.breakPenalty,t.display=this.display,t.floatReference=this.floatReference,t.floatSide=this.floatSide,t.clearSide=this.clearSide,t.floatMinWrapBlock=this.floatMinWrapBlock,t.columnSpan=this.columnSpan,t.captionSide=this.captionSide,t.inlineBorderSpacing=this.inlineBorderSpacing,t.blockBorderSpacing=this.blockBorderSpacing,t.establishesBFC=this.establishesBFC,t.containingBlockForAbsolute=this.containingBlockForAbsolute,t.flexContainer=this.flexContainer,t.whitespace=this.whitespace,t.hyphenateCharacter=this.hyphenateCharacter,t.breakWord=this.breakWord,t.breakBefore=this.breakBefore,t.breakAfter=this.breakAfter,t.viewNode=this.viewNode,t.clearSpacer=this.clearSpacer,t.firstPseudo=this.firstPseudo,t.vertical=this.vertical,t.overflow=this.overflow,t.preprocessedTextContent=this.preprocessedTextContent,t.repeatOnBreak=this.repeatOnBreak,t.pluginProps=Object.create(this.pluginProps),t.fragmentIndex=this.fragmentIndex,t.afterIfContinues=this.afterIfContinues,t.footnotePolicy=this.footnotePolicy,t.pageType=this.pageType,t.blockContainer=this.blockContainer,t}modify(){return this.shared?this.cloneItem():this}copy(){let e=this;do{if(e.shared)break;e.shared=!0,e=e.parent}while(e);return this}clone(){let e,t=this.cloneItem(),i=[t],n=t;for(;null!=(e=n.parent);)e=e.cloneItem(),n.parent=e,n=e,i.push(e);for(let e=i.length-2;e>=0;e--)i[e].blockContainer=Pa(i[e+1]);return t}toNodePositionStep(){var e;return{node:this.sourceNode,shadowType:this.shadowType,shadowContext:this.shadowContext,nodeShadow:this.nodeShadow,shadowSibling:this.shadowSibling?this.shadowSibling.toNodePositionStep():null,formattingContext:this.formattingContext,fragmentIndex:null===(null==(e=this.viewNode)?void 0:e.parentNode)?0:this.fragmentIndex}}toNodePosition(){var e,t,i;let n=this.shadowType!==Vs.ShadowType.ROOTLESS||this.floatReference===Bs.FloatReference.INLINE&&"footnote"!==this.floatSide||null==(i=null==(t=null==(e=this.shadowContext)?void 0:e.styler)?void 0:t.style)||!i._pseudos?null:this,r=[],o=ya(n?n.parent:this);for(;ba(o);)(!o.firstPseudo||o.parent.firstPseudo===o.firstPseudo)&&r.push(o.toNodePositionStep()),o=ya(o.parent);let s=this.preprocessedTextContent?function(e,t){return $s(e,t,-1)}(this.preprocessedTextContent,this.offsetInNode):this.offsetInNode;return{steps:[...r,wa(o)],offsetInNode:s,after:this.after,preprocessedTextContent:this.preprocessedTextContent}}isInsideBFC(){let e=this.parent;for(;e;){if(e.establishesBFC)return!0;e=e.parent}return!1}getContainingBlockForAbsolute(){let e=this.parent;for(;e;){if(e.containingBlockForAbsolute)return Sa(e);e=e.parent}return null}belongsTo(e){return this.formattingContext===e&&!!this.parent&&this.parent.formattingContext===e}};function va(e){return null!==e.parent?e:null}function ya(e){return e.parent,e}function ba(e){return null!==e.parent}function wa(e){return{...e.toNodePositionStep(),shadowSibling:e.shadowSibling}}function xa(e){var t;return null!==e.parent&&3===(null==(t=e.viewNode)?void 0:t.nodeType)?e:null}function Sa(e){return null!==e.viewNode&&1===e.viewNode.nodeType?e:null}function Ca(e){var t;return null!==e.clearSide&&1===(null==(t=e.viewNode)?void 0:t.nodeType)?e:null}function ka(e){var t;return null!=(t=Sa(e))?t:xa(e)}function Pa(e){let t=Sa(e);return!t||e.inline&&e.blockContainer?e.blockContainer:t}var Ea=class e{constructor(e){h(this,"primary",e),h(this,"floats",null)}clone(){let t=new e(this.primary);if(this.floats){t.floats=[];for(let e=0;e<this.floats.length;++e)t.floats[e]=this.floats[e]}return t}isSamePosition(e){if(!e)return!1;if(this===e)return!0;if(!sa(this.primary,e.primary))return!1;if(this.floats){if(!e.floats||this.floats.length!==e.floats.length)return!1;for(let t=0;t<this.floats.length;t++)if(!sa(this.floats[t],e.floats[t]))return!1}else if(e.floats)return!1;return!0}},Na=class e{constructor(e,t){h(this,"chunkPosition",e),h(this,"flowChunk",t)}clone(){return new e(this.chunkPosition.clone(),this.flowChunk)}isSamePosition(e){return!!e&&(this===e||this.chunkPosition.isSamePosition(e.chunkPosition))}},Ta=class e{constructor(){h(this,"positions",[]),h(this,"startBreakType",null),h(this,"breakAfter",null)}clone(){let t=new e,i=this.positions,n=t.positions;for(let e=0;e<i.length;e++)n[e]=i[e].clone();return t.startBreakType=this.startBreakType,t.breakAfter=this.breakAfter,t}isSamePosition(e){if(this===e)return!0;if(!e||this.positions.length!==e.positions.length)return!1;for(let t=0;t<this.positions.length;t++)if(!this.positions[t].isSamePosition(e.positions[t]))return!1;return!0}hasContent(e){return this.positions.length>0&&this.positions[0].flowChunk.startOffset<=e}},Ia=class e{constructor(){h(this,"page",0),h(this,"flows",{}),h(this,"flowPositions",{}),h(this,"isBlankPage",!1),h(this,"highestSeenOffset",0),h(this,"highestSeenNode",null),h(this,"lookupPositionOffset",null)}clone(){let t=new e;t.page=this.page,t.isBlankPage=this.isBlankPage,t.highestSeenNode=this.highestSeenNode,t.highestSeenOffset=this.highestSeenOffset,t.lookupPositionOffset=this.lookupPositionOffset,t.flows=this.flows;for(let e in this.flowPositions)t.flowPositions[e]=this.flowPositions[e].clone();return t}isSamePosition(e){if(this===e)return!0;if(!e||this.page!==e.page)return!1;let t=Object.keys(this.flowPositions),i=Object.keys(e.flowPositions);if(t.length!==i.length)return!1;for(let i of t)if(!this.flowPositions[i].isSamePosition(e.flowPositions[i]))return!1;return!0}hasContent(e,t){let i=this.flowPositions[e];return!!i&&i.hasContent(t)}startSideOfFlow(e){var t;let i=null==(t=this.flowPositions[e])?void 0:t.startBreakType;return i&&Is(i)?i:"any"}firstFlowChunkOfFlow(e){let t=this.flowPositions[e];if(!t)return null;let i=t.positions[0];return i?i.flowChunk:null}};function Aa(e,t){t.left=e.left,t.top=e.top,t.marginLeft=e.marginLeft,t.marginRight=e.marginRight,t.marginTop=e.marginTop,t.marginBottom=e.marginBottom,t.borderLeft=e.borderLeft,t.borderRight=e.borderRight,t.borderTop=e.borderTop,t.borderBottom=e.borderBottom,t.paddingLeft=e.paddingLeft,t.paddingRight=e.paddingRight,t.paddingTop=e.paddingTop,t.paddingBottom=e.paddingBottom,t.width=e.width,t.height=e.height,t.originX=e.originX,t.originY=e.originY,t.snapWidth=e.snapWidth,t.snapHeight=e.snapHeight,t.vertical=e.vertical,t.rtl=e.rtl,t.borderBoxSizing=e.borderBoxSizing}var Fa=class{constructor(e){h(this,"element",e),h(this,"left",0),h(this,"top",0),h(this,"marginLeft",0),h(this,"marginRight",0),h(this,"marginTop",0),h(this,"marginBottom",0),h(this,"borderLeft",0),h(this,"borderRight",0),h(this,"borderTop",0),h(this,"borderBottom",0),h(this,"paddingLeft",0),h(this,"paddingRight",0),h(this,"paddingTop",0),h(this,"paddingBottom",0),h(this,"width",0),h(this,"height",0),h(this,"originX",0),h(this,"originY",0),h(this,"exclusions",null),h(this,"innerShape",null),h(this,"computedBlockSize",0),h(this,"snapWidth",0),h(this,"snapHeight",0),h(this,"snapOffsetX",0),h(this,"snapOffsetY",0),h(this,"vertical",!1),h(this,"rtl",!1),h(this,"borderBoxSizing",!1)}getInsetTop(){return this.marginTop+(this.borderBoxSizing?0:this.borderTop+this.paddingTop)}getInsetBottom(){return this.marginBottom+(this.borderBoxSizing?0:this.borderBottom+this.paddingBottom)}getInsetLeft(){return this.marginLeft+(this.borderBoxSizing?0:this.borderLeft+this.paddingLeft)}getInsetRight(){return this.marginRight+(this.borderBoxSizing?0:this.borderRight+this.paddingRight)}getInsetBefore(){return this.vertical?this.getInsetRight():this.getInsetTop()}getInsetAfter(){return this.vertical?this.getInsetLeft():this.getInsetBottom()}getInsetStart(){return this.vertical?this.getInsetTop():this.getInsetLeft()}getInsetEnd(){return this.vertical?this.getInsetBottom():this.getInsetRight()}getBeforeEdge(e){return this.vertical?e.right:e.top}getAfterEdge(e){return this.vertical?e.left:e.bottom}getStartEdge(e){return this.vertical?this.rtl?e.bottom:e.top:this.rtl?e.right:e.left}getEndEdge(e){return this.vertical?this.rtl?e.top:e.bottom:this.rtl?e.left:e.right}getInlineSize(e){return this.vertical?e.bottom-e.top:e.right-e.left}getBoxSize(e){return this.vertical?e.right-e.left:e.bottom-e.top}getBoxDir(){return this.vertical?-1:1}getInlineDir(){return this.rtl?-1:1}copyFrom(e){this.element=e.element,Aa(e,this),this.innerShape=e.innerShape,this.exclusions=e.exclusions,this.computedBlockSize=e.computedBlockSize}setVerticalPosition(e,t){this.top=e,this.height=t,be(this.element,"top",`${e}px`),be(this.element,"height",`${t}px`)}setHorizontalPosition(e,t){this.left=e,this.width=t,be(this.element,"left",`${e}px`),be(this.element,"width",`${t}px`)}setBlockPosition(e,t){if(this.vertical){let i=t+this.marginLeft+this.marginRight+(this.borderBoxSizing?0:this.paddingLeft+this.paddingRight+this.borderLeft+this.borderRight);this.setHorizontalPosition(e+i*this.getBoxDir(),t)}else this.setVerticalPosition(e,t)}setInlinePosition(e,t){if(this.vertical)if(this.rtl){let i=t+this.marginTop+this.marginBottom+(this.borderBoxSizing?0:this.paddingTop+this.paddingBottom+this.borderTop+this.borderBottom);this.setVerticalPosition(e+i*this.getInlineDir(),t)}else this.setVerticalPosition(e,t);else if(this.rtl){let i=t+this.marginLeft+this.marginRight+(this.borderBoxSizing?0:this.paddingLeft+this.paddingRight+this.borderLeft+this.borderRight);this.setHorizontalPosition(e+i*this.getInlineDir(),t)}else this.setHorizontalPosition(e,t)}clear(){let e,t=this.element;for(;e=t.lastChild;)t.removeChild(e)}getInnerShape(){let e=this.getInnerRect();return this.innerShape?this.innerShape.withOffset(e.x1,e.y1):dn(e.x1,e.y1,e.x2,e.y2)}getInnerRect(){let e=this.originX+this.left+this.getInsetLeft(),t=this.originY+this.top+this.getInsetTop();return new rn(e,t,e+this.width,t+this.height)}getPaddingRect(){let e=this.originX+this.left+this.marginLeft+this.borderLeft,t=this.originY+this.top+this.marginTop+this.borderTop,i=this.paddingLeft+this.width+this.paddingRight,n=this.paddingTop+this.height+this.paddingBottom;return new rn(e,t,e+i,t+n)}getOuterShape(e,t){let i=this.getOuterRect();return An(e,i.x1,i.y1,i.x2-i.x1,i.y2-i.y1,t)}getOuterRect(){let e=this.originX+this.left,t=this.originY+this.top,i=this.getInsetLeft()+this.width+this.getInsetRight(),n=this.getInsetTop()+this.height+this.getInsetBottom();return new rn(e,t,e+i,t+n)}},Ra=class extends Ut{constructor(e,t,i,n){super(),h(this,"elem",e),h(this,"context",t),h(this,"rootContentValue",i),h(this,"exprContentListener",n)}visitStrInner(e,t){var i;if(!t){if(3===(null==(i=this.elem.lastChild)?void 0:i.nodeType))return void(this.elem.lastChild.textContent+=e);t=this.elem.ownerDocument.createTextNode(e)}this.elem.appendChild(t)}visitStr(e){return this.visitStrInner(e.str),null}visitURL(e){if(this.rootContentValue instanceof ii)this.elem.setAttribute("src",e.url);else{let t=this.elem.ownerDocument.createElementNS("http://www.w3.org/1999/xhtml","img");t.setAttribute("src",e.url),this.elem.appendChild(t)}return null}visitSpaceList(e){return this.visitValues(e.values),null}visitExpr(e){let t=e.toExpr();if(t instanceof It){let e=t;if("function"==typeof e.getContentList){let t=e.getContentList();if(t)return t.visit(this),null}}let i=t.evaluate(this.context);if("string"==typeof i){this.elem.ownerDocument;let e=this.exprContentListener(t,i,this.elem.ownerDocument);!e&&i&&t instanceof It&&t.str.startsWith("running-element-")&&(i=""),this.visitStrInner(i,e)}return null}};function Oa(e){return null!=e&&e!==Wt&&e!==di.normal&&e!==di.none&&!yi(e)}var La=1e5;function _a(e){let t=e.element.style;t.columnGap=La-(e.vertical?e.height:e.width)+"px",t.columnFill="auto",t.columnCount="1",t.columnWidth="0"}function Ba(e){let t=("element"in e?e.element:e).style;t.columnWidth="",t.columnCount="",t.columnGap="",t.columnFill=""}function Ma(e){return"1"===e.element.style.columnCount}function Da(e,t){let i=t?e.bottom:Math.max(Math.abs(e.left),Math.abs(e.right));return Math.round(i/La)}function za(e,t){let i=Da(e,t);if(0===i)return 0;let n=t?e.top:Math.min(Math.abs(e.left),Math.abs(e.right)),r=Math.round(n/La),o=r*La,s=i*La;return t?(e.top-=o,e.bottom-=s,e.bottom<e.top&&(e.bottom+=La),e.right-=o,e.left-=s):e.left<-La/2?(e.right+=o,e.left+=s,e.left>e.right&&(e.left-=La),e.top+=o,e.bottom+=s):(e.left-=o,e.right-=s,e.right<e.left&&(e.right+=La),e.top+=o,e.bottom+=s),e.width=e.right-e.left,e.height=e.bottom-e.top,r}function Va(e,t){for(let i=0;i<e.length;i++)za(e[i],t)}function Ua(e,t,i){let n=e.getElementClientRect(t);if(za(n,i)>0&&e.getElementComputedStyle(t).display.startsWith("table")&&!ja(t)){let i=t.closest("[data-vivliostyle-column]");if(i)return Ba(i),e.getElementClientRect(t)}return n}function Ha(e,t){var i,n;if(1===e.nodeType){let t=e;"column"===(null==(i=t.style)?void 0:i.breakAfter)&&(t.style.breakAfter="")}if(1===t.nodeType){let e=t;"column"===(null==(n=e.style)?void 0:n.breakBefore)&&(e.style.breakBefore="")}}function $a(e){let t=e.style;return!!t&&(!isNaN(parseFloat(t.columnCount))||!isNaN(parseFloat(t.columnWidth)))}function ja(e){for(let t=1===e.nodeType?e:e.parentElement;t;t=t.parentElement){let e=t.style;if(!e||t.hasAttribute("data-vivliostyle-column"))break;if($a(t))return t;if("absolute"===e.position)break}return null}function Wa(e){let t=e.element.lastElementChild,i=t&&e.clientLayout.getElementClientRect(t);return i?Da(i,e.vertical):0}function Ga(e,t){if("auto"!==e.getAttribute("data-viv-saved-column-fill")||Wa(t))return;let i=t.clientLayout.getElementComputedStyle(e),n=parseFloat(i.blockSize);e.style.columnFill="auto";let r=parseFloat(i.blockSize);if(r<=0||e.parentElement&&ja(e.parentElement))return void e.removeAttribute("data-viv-saved-column-fill");let o=NaN;if(e.style.blockSize=`${r}px`,Wa(t)){if(e.style.blockSize=`${n}px`,!Wa(t)){let i=1/(t.clientLayout.pixelRatio||1),s=n,a=r;for(;a-s>i;){let i=(s+a)/2;e.style.blockSize=`${i}px`,Wa(t)?a=i:s=i}o=s,e.style.blockSize=`${o}px`}}else if(o=parseFloat(i.blockSize),o<r){o=r+1/t.clientLayout.layoutUnitPerPixel,e.style.blockSize=`${o}px`}if(isNaN(o))return e.style.blockSize="",void(e.style.columnFill="balance");e.removeAttribute("data-viv-saved-column-fill")}function qa(e,t,i,n){let r=e.viewNode;if(!r)return NaN;let o=1===r.nodeType?r:r.parentElement;if(o&&"http://www.w3.org/1999/xhtml"===o.namespaceURI){let e=o.style;if("wbr"===o.localName||e&&vs(e.display)&&/^([\d\.]|super|(text-)?top)/.test(e.verticalAlign))return NaN}if(r===o){if("br"===o.localName){let e=o.ownerDocument.createElement("span");o.before(e);let i=t.getElementClientRect(e);if(e.remove(),i){let e=[i];Va(e,n);let t=e[0],r=n?t.left:t.bottom;if(!isNaN(r)&&0!==r)return r}return NaN}if(e.after||!e.inline){if(e.after&&!e.inline&&o.querySelector("ruby")){let e=o.parentNode,t=o.nextSibling;e.removeChild(o),e.insertBefore(o,t)}let i=Ua(t,o,n);if(0===i.left&&0===i.top&&0===i.right&&0===i.bottom)return NaN;if(i.right>=i.left&&i.bottom>=i.top)return e.after?n?i.left:i.bottom:n?i.right:i.top}return NaN}{let s=NaN,a=r.ownerDocument.createRange(),l=r.textContent.length;if(!l)return NaN;e.after&&(i+=l),i>=l&&(i=l-1),a.setStart(r,i),a.setEnd(r,i+1);let h=t.getRangeClientRects(a);Va(h,n);let u=h.filter(e=>e.right>e.left&&e.bottom>e.top);if(u.length>0)h=u;else{let e=o?t.getElementComputedStyle(o).whiteSpace:"";h="pre"===e||"pre-wrap"===e||"pre-line"===e||"break-spaces"===e?h.filter(e=>n?e.right>e.left:e.bottom>e.top):[]}return h.length?(s=n?Math.min.apply(null,h.map(e=>e.left)):Math.max.apply(null,h.map(e=>e.bottom)),s):NaN}}function Xa(e,t,i){let n=Ma(t);n&&Ba(t);let r=t.clientLayout.getElementClientRect(e);n&&_a(t);let o=t.getComputedMargin(e);return i?r.width+o.left+o.right:r.height+o.top+o.bottom}function Ya(e){for(;e;){if(e.parentNode===e.ownerDocument)return!1;e=e.parentNode}return!0}function Ka(e,t){var i;if(e)for(let n=e.lastChild,r=n;n!==t;n=r)r=n.previousSibling,(1!==n.nodeType||!n.hasAttribute("data-vivliostyle-float-box-moved")||"inline"!==(null==(i=t.style)?void 0:i.display))&&e.removeChild(n)}var Za="data-adapt-spec";function Ja(e){return!!e.getAttribute(Za)}function Qa(e){return 1===(null==e?void 0:e.nodeType)&&(!!Ja(e)||el(e))}function el(e){var t,i;if(1!==(null==e?void 0:e.nodeType))return!1;let n=e,r=null==(t=n.style)?void 0:t.position;if("absolute"===r||"fixed"===r)return!0;let o=null==(i=n.style)?void 0:i.float;return"left"===o||"right"===o||"inline-start"===o||"inline-end"===o}function tl(e){var t;return 1===(null==e?void 0:e.nodeType)&&"fixed"===(null==(t=e.style)?void 0:t.position)}function il(e){let t=null==e?void 0:e.viewNode;return 1===(null==t?void 0:t.nodeType)&&Ja(t)}function nl(e){return"inline"!==e&&(vs(e)||ws(e))}function rl(e){var t;for(let i=e.parent;i;i=i.parent)if(("inline"!==i.display||i.vertical!==(null==(t=i.parent)?void 0:t.vertical))&&vs(i.display))return Sa(i);return null}function ol(e){let t=e.parentElement;return"viv-ts-inner"===(null==t?void 0:t.localName)?t.parentElement:null}function sl(e){let t=e;for(;t;){if(t.nodeType===Node.TEXT_NODE&&t.textContent.length>0)return t;if(t.lastChild)t=t.lastChild;else{for(;t&&!t.previousSibling;)if(t=t.parentNode,t===e||!t)return null;t=(null==t?void 0:t.previousSibling)||null}}return null}function al(e,t){let i={};return Object.keys(e).forEach(n=>{let r=i[n]={},o=e[n];Object.keys(o).forEach(e=>{r[e]=o[e].map(e=>{let i=t?e.logical:e.physical,n=t?e.physical:e.logical;return{regexp:new RegExp(`(-?)${i}(-?)`),to:`$1${n}$2`}})})}),i}function ll(e,t,i,n){let r=n[t];if(!r)throw new Error(`unknown writing-mode: ${t}`);let o=r[i||"ltr"];if(!o)throw new Error(`unknown direction: ${i}`);for(let t of o){let i=e.replace(t.regexp,t.to);if(i!==e)return i}return e}var hl={"horizontal-tb":{ltr:[{logical:"inline-start",physical:"left"},{logical:"inline-end",physical:"right"},{logical:"block-start",physical:"top"},{logical:"block-end",physical:"bottom"},{logical:"inline-size",physical:"width"},{logical:"block-size",physical:"height"}],rtl:[{logical:"inline-start",physical:"right"},{logical:"inline-end",physical:"left"},{logical:"block-start",physical:"top"},{logical:"block-end",physical:"bottom"},{logical:"inline-size",physical:"width"},{logical:"block-size",physical:"height"}]},"vertical-rl":{ltr:[{logical:"inline-start",physical:"top"},{logical:"inline-end",physical:"bottom"},{logical:"block-start",physical:"right"},{logical:"block-end",physical:"left"},{logical:"inline-size",physical:"height"},{logical:"block-size",physical:"width"}],rtl:[{logical:"inline-start",physical:"bottom"},{logical:"inline-end",physical:"top"},{logical:"block-start",physical:"right"},{logical:"block-end",physical:"left"},{logical:"inline-size",physical:"height"},{logical:"block-size",physical:"width"}]},"vertical-lr":{ltr:[{logical:"inline-start",physical:"top"},{logical:"inline-end",physical:"bottom"},{logical:"block-start",physical:"left"},{logical:"block-end",physical:"right"},{logical:"inline-size",physical:"height"},{logical:"block-size",physical:"width"}],rtl:[{logical:"inline-start",physical:"bottom"},{logical:"inline-end",physical:"top"},{logical:"block-start",physical:"left"},{logical:"block-end",physical:"right"},{logical:"inline-size",physical:"height"},{logical:"block-size",physical:"width"}]}},ul=al(hl,!0);function cl(e,t,i){return ll(e,t,i||null,ul)}var dl=al(hl,!1);function pl(e,t,i){return ll(e,t,i||null,dl)}var fl={"horizontal-tb":[{logical:"line-left",physical:"left"},{logical:"line-right",physical:"right"},{logical:"over",physical:"top"},{logical:"under",physical:"bottom"}],"vertical-rl":[{logical:"line-left",physical:"top"},{logical:"line-right",physical:"bottom"},{logical:"over",physical:"right"},{logical:"under",physical:"left"}],"vertical-lr":[{logical:"line-left",physical:"top"},{logical:"line-right",physical:"bottom"},{logical:"over",physical:"right"},{logical:"under",physical:"left"}]};function gl(e,t,i){var n;let r=t,o={width:r.style.width,height:r.style.height};function s(i){return e.getElementComputedStyle(t).getPropertyValue(i)}let a="horizontal-tb"!==s("writing-mode"),l=a?"height":"width",h=a?"width":"height";function u(e,t){r.style[e]=t;let i=s(e);return r.style[e]=o[e],i}let c={};for(let e of i){let i;switch(e){case"max-content inline size":i=u(l,"max-content");break;case"min-content inline size":i=u(l,"min-content");break;case"fit-content inline size":i=u(l,"fit-content");break;case"max-content block size":i=u(h,"max-content");break;case"min-content block size":i=u(h,"min-content");break;case"fit-content block size":i=u(h,"fit-content");break;case"max-content width":i=u("width","max-content");break;case"max-content height":i=u("height","max-content");break;case"min-content width":i=u("width","min-content");break;case"min-content height":i=u("height","min-content");break;case"fit-content width":i=u("width","fit-content");break;case"fit-content height":i=u("height","fit-content")}"0px"===i&&1===t.childNodes.length&&"img"===(null==(n=t.firstElementChild)?void 0:n.localName)&&!t.firstElementChild.complete&&(i="1px"),c[e]=parseFloat(i)}return c}var ml=Bs.FloatReference;function vl(e){switch(e){case ml.INLINE:return!1;case ml.COLUMN:case ml.REGION:case ml.PAGE:return!0;default:throw new Error(`Unknown float-reference: ${e}`)}}function yl(e,t,i,n){let r=t?"vertical-rl":"horizontal-tb";if(("top"===e||"bottom"===e)&&(e=pl(e,r,i)),"block-start"===e&&(e="inline-start"),"block-end"===e&&(e="inline-end"),"inline-start"===e||"inline-end"===e){let t=function(e,t){let i=fl[t];if(!i)throw new Error(`unknown writing-mode: ${t}`);for(let t=0;t<i.length;t++)if(i[t].physical===e)return i[t].logical;return e}(cl(e,r,i),r);"line-left"===t?e="left":"line-right"===t&&(e="right")}else"inside"===e?e="left"===n?"right":"left":"outside"===e&&(e="left"===n?"left":"right");return"left"!==e&&"right"!==e&&(R.warn(`Invalid float value: ${e}. Fallback to left.`),e="left"),e}var bl=class{constructor(e,t,i,n,r,o){h(this,"nodePosition",e),h(this,"floatReference",t),h(this,"floatSide",i),h(this,"clearSide",n),h(this,"flowName",r),h(this,"floatMinWrapBlock",o),h(this,"order",null),h(this,"id",null),h(this,"insidePageFloatArea",!1),h(this,"parentPageFloat",null)}getOrder(){if(null===this.order)throw new Error("The page float is not yet added");return this.order}getId(){if(!this.id)throw new Error("The page float is not yet added");return this.id}isAllowedOnContext(e){return!!e.isAnchorAlreadyAppeared(this.getId())||!(!this.insidePageFloatArea||!this.parentPageFloat)&&!!e.findPageFloatFragment(this.parentPageFloat)}isAllowedToPrecede(e){return!1}},wl=class{constructor(){h(this,"floats",[]),h(this,"nextPageFloatIndex",0)}nextOrder(){return this.nextPageFloatIndex++}createPageFloatId(e){return`pf${e}`}addPageFloat(e){if(this.floats.findIndex(t=>sa(t.nodePosition,e.nodePosition))>=0)throw new Error("A page float with the same source node is already registered");{let t=e.order=this.nextOrder();e.id=this.createPageFloatId(t),this.floats.push(e)}}findPageFloatByNodePosition(e){let t=this.floats.findIndex(t=>sa(t.nodePosition,e));if(t>=0)return this.floats[t];let i=null==e?void 0:e.steps;if(null!=i&&i.length){let t=this.floats.findIndex(t=>{let n=t.nodePosition.steps;if(null==n||!n.length||n.length===i.length||t.nodePosition.offsetInNode!==e.offsetInNode||t.nodePosition.after!==e.after)return!1;let r=Math.min(n.length,i.length);for(let e=0;e<r;e++)if(n[e].node!==i[e].node)return!1;return!0});if(t>=0)return this.floats[t]}return null}findPageFloatById(e){let t=this.floats.findIndex(t=>t.id===e);return t>=0?this.floats[t]:null}},xl=class{constructor(e,t,i,n,r,o){h(this,"floatReference",e),h(this,"floatSide",t),h(this,"clearSide",i),h(this,"continuations",n),h(this,"area",r),h(this,"continues",o)}hasFloat(e){return this.continuations.some(t=>t.float===e)}findNotAllowedFloat(e){for(let t=this.continuations.length-1;t>=0;t--){let i=this.continuations[t].float;if(!i.isAllowedOnContext(e))return i}return null}getOuterShape(){return this.area.getOuterShape(null,null)}getOuterRect(){return this.area.getOuterRect()}getOrder(){let e=this.continuations.map(e=>e.float);return Math.min.apply(null,e.map(e=>e.getOrder()))}shouldBeStashedBefore(e){return this.getOrder()<e.getOrder()}addContinuations(e){e.forEach(e=>{this.continuations.push(e)})}getFlowName(){let e=this.continuations[0].float.flowName;return this.continuations.every(t=>t.float.flowName===e),e}},Sl=class{constructor(e,t){h(this,"float",e),h(this,"nodePosition",t)}equals(e){return!!e&&(this===e||this.float===e.float&&sa(this.nodePosition,e.nodePosition))}};function Cl(e,t){if("inside"===e||"outside"===e){let i="left"===t.pageSide;e="inside"===e?i?"right":"left":i?"left":"right"}return pl(e,t.writingMode.toString(),t.direction.toString())}var kl=class e{constructor(e,t){h(this,"parent"),h(this,"floatReference"),h(this,"flowName"),h(this,"generatingNodePosition"),h(this,"writingMode"),h(this,"direction"),h(this,"pageSide"),h(this,"outerContext"),h(this,"floatStore"),h(this,"state"),this.parent=e.parent,this.floatReference=e.floatReference,this.flowName=e.flowName,this.generatingNodePosition=e.generatingNodePosition,this.writingMode=e.writingMode,this.direction=e.direction,this.pageSide=e.pageSide,this.outerContext=e.outerContext,this.floatStore=e.floatStore,this.state=null!=t?t:this.newState()}static buildIdentity(e,t,i,n,r,o,s,a){var l,h,u;return{parent:e,floatReference:t,flowName:i,generatingNodePosition:n,writingMode:!yi(r)&&r||(null==e?void 0:e.writingMode)||di.horizontal_tb,direction:!yi(o)&&o||(null==e?void 0:e.direction)||di.ltr,pageSide:null!=(h=null!=(l=null!=a?a:null==e?void 0:e.pageSide)?l:null==s?void 0:s.pageSide)?h:null,outerContext:s,floatStore:e?e.floatStore:null!=(u=null==s?void 0:s.floatStore)?u:new wl}}newState(){let e=this.getPreviousSibling();return{children:[],floatAnchors:{},invalidated:!1,locked:!1,forbiddenFloats:[],floatFragments:[],stashedFloatFragments:[],floatsDeferredToNext:[],floatsDeferredFromPrevious:e?[...e.state.floatsDeferredToNext]:[],layoutConstraints:[],footnoteMaxBlockSize:null,ignoreFootnoteAreaMaxHeight:!1,footnoteAnchorsSeen:new Set,lineFootnoteInvalidationMaxBlockSize:new Map,lineFootnoteFinishInvalidatedOnce:new Set}}static createDetached(t,i,n,r){return new Pl(e.buildIdentity(null,i,n,r,null,null,t,null))}static create(t,i,n,r,o,s,a=null,l=null){let h=e.buildIdentity(t,i,n,r,o,s,a,l);return new Pl(h)}static createWithContainer(t,i,n,r,o,s,a,l=null,h=null){let u=e.buildIdentity(i,n,r,o,s,a,l,h);return new Tl(u,t)}static register(e,t){if(!e)return;let i=e.state.children.findIndex(e=>e.state===t.state);i>=0?e.state.children[i]=t:e.state.children.push(t)}identity(){return{parent:this.parent,floatReference:this.floatReference,flowName:this.flowName,generatingNodePosition:this.generatingNodePosition,writingMode:this.writingMode,direction:this.direction,pageSide:this.pageSide,outerContext:this.outerContext,floatStore:this.floatStore}}get floatFragments(){return this.state.floatFragments}get footnoteMaxBlockSize(){return this.state.footnoteMaxBlockSize}set footnoteMaxBlockSize(e){this.state.footnoteMaxBlockSize=e}get ignoreFootnoteAreaMaxHeight(){return this.state.ignoreFootnoteAreaMaxHeight}set ignoreFootnoteAreaMaxHeight(e){this.state.ignoreFootnoteAreaMaxHeight=e}get effectiveParent(){var e;return null!=(e=this.parent)?e:this.outerContext}getParent(e){if(this.parent)return this.parent;if(this.outerContext)return this.outerContext;throw new Error(`No PageFloatLayoutContext for ${e}`)}getPreviousSibling(){let e,t=this,i=this.parent;for(;i;){if(e=i.getPreviousSiblingOf(t,this.floatReference,this.flowName,this.generatingNodePosition),e)return e;t=i,i=i.parent}return null}addPageFloat(e){this.floatStore.addPageFloat(e)}getPageFloatLayoutContext(e){return e===this.floatReference?this:this.getParent(e).getPageFloatLayoutContext(e)}findPageFloatByNodePosition(e){return this.floatStore.findPageFloatByNodePosition(e)}isForbidden(e){let t=e.getId(),i=e.floatReference;return i===this.floatReference?this.state.forbiddenFloats.includes(t):this.getParent(i).isForbidden(e)}findPageFloatFragment(e){if(e.floatReference!==this.floatReference)return this.getParent(e.floatReference).findPageFloatFragment(e);let t=this.floatFragments.findIndex(t=>t.hasFloat(e));return t>=0?this.floatFragments[t]:null}hasFloatFragments(e){return!(!(this.floatFragments.length>0)||e&&!this.floatFragments.some(e))||!!this.parent&&this.parent.hasFloatFragments(e)}hasContinuingFloatFragmentsInFlow(e){return this.hasFloatFragments(t=>t.continues&&t.getFlowName()===e&&"block-end"!==t.floatSide)}markPageFloatAnchorSeen(e){var t;if(!("footnotePolicy"in e))return;let i=this;for(;i;)i.state.footnoteAnchorsSeen.add(e.getId()),i=null!=(t=i.parent)?t:i.outerContext}registerPageFloatAnchor(e,t){this.state.floatAnchors[e.getId()]=t,this.markPageFloatAnchorSeen(e)}hasInvalidatedForLineFootnote(e){return e.floatReference===this.floatReference?this.state.lineFootnoteInvalidationMaxBlockSize.get(e.getId())===this.footnoteMaxBlockSize:this.getParent(e.floatReference).hasInvalidatedForLineFootnote(e)}markInvalidatedForLineFootnote(e){e.floatReference===this.floatReference?this.state.lineFootnoteInvalidationMaxBlockSize.set(e.getId(),this.footnoteMaxBlockSize):this.getParent(e.floatReference).markInvalidatedForLineFootnote(e)}deferPageFloat(e){let t=e.float;if(t.floatReference===this.floatReference){let i=this.state.floatsDeferredToNext.findIndex(e=>e.float===t);i>=0?this.state.floatsDeferredToNext.splice(i,1,e):this.state.floatsDeferredToNext.push(e)}else this.getParent(t.floatReference).deferPageFloat(e)}removeFloatDeferredToNext(e){let t=this.state.floatsDeferredToNext.findIndex(t=>t.float===e);t>=0&&this.state.floatsDeferredToNext.splice(t,1)}hasPrecedingFloatsDeferredToNext(e,t){if(!t&&e.floatReference!==this.floatReference)return this.getParent(e.floatReference).hasPrecedingFloatsDeferredToNext(e,!1);let i=e.getOrder();return!!this.state.floatsDeferredToNext.some(t=>t.float.getOrder()<i&&!e.isAllowedToPrecede(t.float))||!!this.parent&&this.parent.hasPrecedingFloatsDeferredToNext(e,!0)}getLastFollowingFloatInFragments(e){let t=e.getOrder(),i=null;if(this.floatFragments.forEach(e=>{e.continuations.forEach(e=>{let n=e.float,r=n.getOrder();r>t&&(!i||r>i.getOrder())&&(i=n)})}),this.parent){let t=this.parent.getLastFollowingFloatInFragments(e);t&&(!i||t.getOrder()>i.getOrder())&&(i=t)}return i}getDeferredPageFloatContinuations(e){e=e||this.flowName;let t=this.state.floatsDeferredFromPrevious.filter(t=>!e||t.float.flowName===e);return this.parent&&(t=this.parent.getDeferredPageFloatContinuations(e).concat(t)),t.sort((e,t)=>e.float.getOrder()-t.float.getOrder())}getPageFloatContinuationsDeferredToNext(e){e=e||this.flowName;let t=this.state.floatsDeferredToNext.filter(t=>!e||t.float.flowName===e);return this.parent?this.parent.getPageFloatContinuationsDeferredToNext(e).concat(t):t}trySetFootnoteRetryMaxBlockSize(e){let t=null!=this.footnoteMaxBlockSize?this.footnoteMaxBlockSize/2:e/2;return!(t<20)&&(this.footnoteMaxBlockSize=t,!0)}isInvalidated(){return this.state.invalidated||!!this.parent&&this.parent.isInvalidated()}validate(){this.state.invalidated=!1}toLogical(e){return Cl(e,this)}toPhysical(e){return function(e,t){return cl(e,t.writingMode.toString(),t.direction.toString())}(e,this)}toLogicalFloatSides(e){return function(e,t){let i=e.split(" "),n=[];for(let e of i){let i=Cl(e,t);n.includes(i)||n.push(i)}let r=[],o=!1,s=!1;for(let e=0;e<n.length;e++){let t=n[e];t.includes("block")?o||(n.slice(e+1).some(e=>e.includes("block"))?(r.push("snap-block"),o=!0):r.push(t)):t.includes("inline")&&(s||(n.slice(e+1).some(e=>e.includes("inline"))?(r.push("snap-inline"),s=!0):r.push(t)))}return r}(e,this)}discardStashedFragments(e){e===this.floatReference?this.state.stashedFloatFragments.splice(0):this.getParent(e).discardStashedFragments(e)}getStashedFloatFragments(e){return e===this.floatReference?this.state.stashedFloatFragments.concat().sort((e,t)=>t.getOrder()-e.getOrder()):this.getParent(e).getStashedFloatFragments(e)}getFloatFragmentExclusions(){let e=this.floatFragments.map(e=>e.getOuterShape());return this.parent?this.parent.getFloatFragmentExclusions().concat(e):e}getLayoutConstraints(){return(this.parent?this.parent.getLayoutConstraints():[]).concat(this.state.layoutConstraints)}addLayoutConstraint(e,t){t===this.floatReference?this.state.layoutConstraints.push(e):this.getParent(t).addLayoutConstraint(e,t)}lock(){this.state.locked=!0}unlock(){this.state.locked=!1}isLocked(){return this.state.locked}},Pl=class extends kl{withContainer(e){return new Tl(this.identity(),e,this.state)}},El=class extends kl{get children(){return this.state.children}attachChildren(e){e.forEach(e=>{this.state.children.push(e),e.reattachFloatFragments()})}detachChildren(){let e=this.state.children.splice(0);return e.forEach(e=>{e.floatFragments.forEach(e=>{let t=e.area.element;t&&t.parentNode&&t.parentNode.removeChild(t)})}),e}collectPageFloatAnchors(){let e=Object.assign({},this.state.floatAnchors);return this.state.children.reduce((e,t)=>Object.assign(e,t.collectPageFloatAnchors()),e)}getFloatsDeferredToNextInChildContexts(){let e=[],t=[];for(let i=this.state.children.length-1;i>=0;i--){let n=this.state.children[i];t.includes(n.flowName)||(t.push(n.flowName),e=e.concat(n.state.floatsDeferredToNext.map(e=>e.float)),e=e.concat(n.getFloatsDeferredToNextInChildContexts()))}return e}findPageFloatAnchor(e){var t;for(let t=this.state.children.length-1;t>=0;t--){let i=this.state.children[t].findPageFloatAnchor(e);if(i)return i}return null!=(t=this.state.floatAnchors[e])?t:null}hasRootMultiColumnFootnoteContext(){return this.state.children.some(e=>{let t=0;for(let i of e.state.children)if(!i.generatingNodePosition&&(t+=1,t>1))return!0;return!1})}getPreviousSiblingOf(e,t,i,n){let r=this.state.children.indexOf(e);r<0&&(r=this.state.children.length);for(let e=r-1;e>=0;e--){let r=this.state.children[e];if(r.floatReference===t&&r.flowName===i&&sa(r.generatingNodePosition,n))return r;if(r=r.getPreviousSiblingOf(null,t,i,n),r)return r}return null}},Nl=class e extends El{asAttached(){return null}addPageFloatLayoutContextAsPreviousSibling(e){this.state.children.push(e)}static createRoot(){return new e(kl.buildIdentity(null,null,null,null,null,null,null,null))}},Tl=class extends El{constructor(e,t,i){var n,r;super(e,i),h(this,"container",t),h(this,"attachedParent"),h(this,"attachedOuter"),this.attachedParent=null!=(r=null==(n=e.parent)?void 0:n.asAttached())?r:null,this.attachedOuter=e.outerContext,this.reattachFloatFragments(),kl.register(this.parent,this)}asAttached(){return this}getParent(e){var t;let i=null!=(t=this.attachedParent)?t:this.attachedOuter;if(i)return i;throw new Error(`No PageFloatLayoutContext for ${e}`)}getPageFloatLayoutContext(e){return e===this.floatReference?this:this.getParent(e).getPageFloatLayoutContext(e)}forbid(e){let t=e.getId(),i=e.floatReference;i===this.floatReference?this.state.forbiddenFloats.includes(t)||(this.state.forbiddenFloats.push(t),(new Al).findByFloat(e).forbid(e,this)):this.getParent(i).forbid(e)}addPageFloatFragment(e,t){let i=e.floatReference;i!==this.floatReference?this.getParent(i).addPageFloatFragment(e,t):this.floatFragments.includes(e)||(this.floatFragments.push(e),this.floatFragments.sort((e,t)=>e.getOrder()-t.getOrder())),t||this.invalidate()}removePageFloatFragment(e,t){let i=e.floatReference;if(i!==this.floatReference)this.getParent(i).removePageFloatFragment(e,t);else{let i=this.floatFragments.indexOf(e);if(i>=0){let e=this.floatFragments.splice(i,1)[0],n=e.area&&e.area.element;n&&n.parentNode&&n.parentNode.removeChild(n),t||this.invalidate()}}}hasCurrentAnchor(e){let t=this.findPageFloatAnchor(e);return!!t&&this.container.element.contains(t)}isAnchorAlreadyAppeared(e){if(this.getDeferredPageFloatContinuations().some(t=>t.float.getId()===e))return!0;let t=this.findPageFloatAnchor(e);return!!t&&this.container.element.contains(t)}hasNonRootMultiColumnFootnoteContext(){return this.state.children.some(e=>e.state.children.some(e=>function(e){if(!e.hasAttribute("data-vivliostyle-column")&&$a(e))return!0;for(let t of e.querySelectorAll("*"))if(!t.hasAttribute("data-vivliostyle-column")&&$a(t))return!0;return!1}(e.container.element)))}hasMultiColumnFootnoteContext(){return this.hasRootMultiColumnFootnoteContext()||this.hasNonRootMultiColumnFootnoteContext()}initFootnoteRetryFromEmptyFragment(e,t){if(!("footnotePolicy"in e&&null==this.footnoteMaxBlockSize&&this.state.footnoteAnchorsSeen.has(e.getId())&&this.hasMultiColumnFootnoteContext()))return!1;let i=(t.vertical?t.width:t.height)+t.getInsetBefore()+t.getInsetAfter();return this.trySetFootnoteRetryMaxBlockSize(i)}checkAndForbidNotAllowedFloat(){var e;if(this.checkAndForbidFloatFollowingDeferredFloat())return!0;for(let e=this.floatFragments.length-1;e>=0;e--){let t=this.floatFragments[e],i=t.findNotAllowedFloat(this);if(i){let e=t.area&&"isFootnote"in t.area&&t.area.isFootnote;if(this.state.locked)this.invalidate();else{let n=e&&"footnotePolicy"in i&&i.footnotePolicy===di.line;if(e&&this.state.footnoteAnchorsSeen.has(i.getId())&&(n||this.hasMultiColumnFootnoteContext())){let e=t.area.computedBlockSize+t.area.getInsetBefore()+t.area.getInsetAfter();if(this.trySetFootnoteRetryMaxBlockSize(e))return this.removePageFloatFragment(t),this.removeEndFloatFragments(t.floatSide),!0}this.removePageFloatFragment(t),this.forbid(i),this.removeEndFloatFragments(t.floatSide)}return!0}}return!(this.floatReference!==ml.REGION||null==(e=this.attachedParent)||!e.isLocked())&&this.attachedParent.checkAndForbidNotAllowedFloat()}checkAndForbidFloatFollowingDeferredFloat(){let e=this.getFloatsDeferredToNextInChildContexts(),t=this.floatFragments.reduce((e,t)=>e.concat(t.continuations.map(e=>e.float)),[]);t.sort((e,t)=>t.getOrder()-e.getOrder());for(let i of t){let t=i.getOrder();if(e.some(e=>!i.isAllowedToPrecede(e)&&t>e.getOrder())){if(this.state.locked)this.invalidate();else{this.forbid(i);let e=this.findPageFloatFragment(i);this.removePageFloatFragment(e)}return!0}}return!1}finish(){for(let e=this.floatFragments.length-1;e>=0;e--){let t=this.floatFragments[e];if(t.continuations.some(e=>{let t=e.float;return"footnotePolicy"in t&&t.footnotePolicy===di.line&&!this.hasCurrentAnchor(t.getId())&&!this.state.floatsDeferredFromPrevious.some(e=>e.float===t)}))return this.state.locked?void this.invalidate():void this.removePageFloatFragment(t)}if(!this.checkAndForbidNotAllowedFloat()){for(let e=this.state.floatsDeferredToNext.length-1;e>=0;e--){let t=this.state.floatsDeferredToNext[e].float,i=this.findPageFloatFragment(t);if("footnotePolicy"in t&&t.footnotePolicy===di.line&&this.hasCurrentAnchor(t.getId())&&!i&&!this.state.lineFootnoteFinishInvalidatedOnce.has(t.getId()))return this.state.locked||(this.state.lineFootnoteFinishInvalidatedOnce.add(t.getId()),this.removeFloatDeferredToNext(t),this.forbid(t)),void this.invalidate()}for(let e=this.state.floatsDeferredToNext.length-1;e>=0;e--)if(!this.state.floatsDeferredToNext[e].float.isAllowedOnContext(this)){if(this.state.locked)return void this.invalidate();this.state.floatsDeferredToNext.splice(e,1)}this.state.floatsDeferredFromPrevious.forEach(e=>{this.state.floatsDeferredToNext.findIndex(t=>e.equals(t))>=0||this.floatFragments.some(t=>t.hasFloat(e.float))||this.state.floatsDeferredToNext.push(e)})}}restoreStashedFragments(e){e===this.floatReference?(this.state.stashedFloatFragments.forEach(e=>{this.addPageFloatFragment(e,!0)}),this.state.stashedFloatFragments.splice(0)):this.getParent(e).restoreStashedFragments(e)}hasSameContainerAs(e){return this.container.element===e.container.element}invalidate(){this.state.invalidated=!0,!this.state.locked&&(this.state.children.forEach(e=>{this.hasSameContainerAs(e)&&e.floatFragments.forEach(e=>{let t=e.area.element;t&&t.parentNode&&t.parentNode.removeChild(t)})}),this.container.clear(),this.state.children.forEach(e=>{e.state.layoutConstraints.splice(0)}),this.state.children.splice(0),Object.keys(this.state.floatAnchors).forEach(e=>{delete this.state.floatAnchors[e]}))}removeEndFloatFragments(e){let t=this.toLogicalFloatSides(e)[0];if("block-end"===t||"inline-end"===t){let e=0;for(;e<this.floatFragments.length;){let i=this.floatFragments[e];this.toLogicalFloatSides(i.floatSide)[0]===t?this.removePageFloatFragment(i):e++}}}isFragmentInCurrentContainer(e){if(this.floatReference!==ml.REGION)return!0;let t=e.area;return!t.parentElement||t.parentElement===this.container.element}stashEndFloatFragments(e){let t=e.floatReference;if(t!==this.floatReference)return void this.getParent(t).stashEndFloatFragments(e);let i=this.toLogicalFloatSides(e.floatSide)[0];if("block-end"===i||"snap-block"===i||"inline-end"===i||"snap-inline"===i){let t=0;for(;t<this.floatFragments.length;){let n=this.floatFragments[t],r=this.toLogicalFloatSides(n.floatSide)[0];this.isFragmentInCurrentContainer(n)&&(r===i||"snap-block"===i&&"block-end"===r||"snap-inline"===i&&"inline-end"===r)&&n.shouldBeStashedBefore(e)?(this.state.stashedFloatFragments.push(n),this.floatFragments.splice(t,1)):t++}}}getLimitValue(e,t,i,n,r,o=!0,s){let a=this.toLogical(e),l=this.toPhysical(e),h=t&&this.toLogical(t),u=t&&this.toPhysical(t),c=this.getLimitValueInner(a,h,i,n,r,s),d=this.attachedParent;if(o&&d){let e=d.getLimitValue(l,u,i,n,r,o,s);switch(l){case"top":case"left":return Math.max(c,e);case"bottom":case"right":return Math.min(c,e)}}return c}getLimitValueInner(e,t,i,n,r,o){let s=this.getLimitValuesInner(i,n,r,e,t,o);switch(e){case"block-start":return this.container.vertical?s.right:s.top;case"block-end":return this.container.vertical?s.left:s.bottom;case"inline-start":return this.container.vertical?this.container.rtl?s.bottom:s.top:this.container.rtl?s.right:s.left;case"inline-end":return this.container.vertical?this.container.rtl?s.top:s.bottom:this.container.rtl?s.left:s.right;default:throw new Error(`Unknown logical side: ${e}`)}}getLimitValuesInner(e,t,i,n,r,o){var s,a,l,h;let u=this.container.originX,c=this.container.originY,d=this.container.getPaddingRect(),p={top:d.y1-c,left:d.x1-u,bottom:d.y2-c,right:d.x2-u,floatMinWrapBlockStart:0,floatMinWrapBlockEnd:0};if(this.container.vertical){let e=parseFloat(null==(a=null==(s=this.container.element)?void 0:s.style)?void 0:a.width);isFinite(e)&&e>this.container.width&&(p.right+=e-this.container.width)}else{let e=parseFloat(null==(h=null==(l=this.container.element)?void 0:l.style)?void 0:h.height);isFinite(e)&&e>this.container.height&&(p.bottom+=e-this.container.height)}function f(i,n,r){return"%"===i.unit?r*i.num/100:e.convertLengthToPx(i,n,t)}let g=this.floatFragments;return g.length>0&&(p=g.reduce((e,t)=>{if(t.area===o||!this.isFragmentInCurrentContainer(t)||i&&!i(t,this))return e;let[s,a]=this.toLogicalFloatSides(t.floatSide);if(a&&(n&&a.includes("block")===n.includes("block")&&a!==n||r&&a.includes("block")===r.includes("block")&&a!==r))return e;let l=t.area,h=t.continuations[0].float.floatMinWrapBlock,u=l.vertical?l.left+l.getInsetLeft()+l.width+l.getInsetRight():l.top+l.getInsetTop()+l.height+l.getInsetBottom(),c=l.vertical?l.top+l.getInsetTop()+l.height+l.getInsetBottom():l.left+l.getInsetLeft()+l.width+l.getInsetRight(),p=e.top,g=e.left,m=e.bottom,v=e.right,y=e.floatMinWrapBlockStart,b=e.floatMinWrapBlockEnd;switch(s){case"inline-start":l.vertical?p=Math.max(p,c):g=Math.max(g,c);break;case"block-start":l.vertical?(h&&l.left<v&&(y=f(h,l.rootViewNodes[0],d.x2-d.x1)),v=Math.min(v,l.left)):(h&&u>p&&(y=f(h,l.rootViewNodes[0],d.y2-d.y1)),p=Math.max(p,u));break;case"inline-end":l.vertical?m=Math.min(m,l.top):v=Math.min(v,l.left);break;case"block-end":l.vertical?(h&&u>g&&(b=f(h,l.rootViewNodes[0],d.x2-d.x1)),g=Math.max(g,u)):(h&&l.top<m&&(b=f(h,l.rootViewNodes[0],d.y2-d.y1)),m=Math.min(m,l.top));break;default:throw new Error(`Unknown logical float side: ${s}`)}return{top:p,left:g,bottom:m,right:v,floatMinWrapBlockStart:y,floatMinWrapBlockEnd:b}},p)),p.left+=u,p.right+=u,p.top+=c,p.bottom+=c,p}setFloatAreaDimensions(e,t,i,n,r,o,s){if(t!==this.floatReference)return this.getParent(t).setFloatAreaDimensions(e,t,i,n,r,o,s);let a=this.toLogicalFloatSides(i);if("snap-block"===a[0]){if(!s["block-start"]&&!s["block-end"])return null}else if(a[0].includes("block")&&!s[a[0]])return null;let l,h,u,c,d=a.find(e=>e.includes("inline")&&s["inline-start"===e?"inline-end":"inline-start"]),p=a.find(e=>e.includes("block")),f=!0,g=this.getLimitValue("block-start",d,e.layoutContext,e.clientLayout,void 0,f,e),m=this.getLimitValue("block-end",d,e.layoutContext,e.clientLayout,void 0,f,e),v=this.getLimitValue("inline-start",p,e.layoutContext,e.clientLayout,void 0,f,e),y=this.getLimitValue("inline-end",p,e.layoutContext,e.clientLayout,void 0,f,e),b=e.vertical?e.originX:e.originY,w=e.vertical?e.originY:e.originX;function x(t,i){let n=t(e.bands,i);return n?(e.vertical&&(n=wn(n)),g=e.vertical?Math.min(g,n.x2):Math.max(g,n.y1),m=e.vertical?Math.max(m,n.x1):Math.min(m,n.y2),!0):o}if(e.isFootnote||(g=e.vertical?Math.min(g,e.left+e.getInsetLeft()+e.width+e.getInsetRight()+b):Math.max(g,e.top+b),m=e.vertical?Math.max(m,e.left+b):Math.min(m,e.top+e.getInsetTop()+e.height+e.getInsetBottom()+b)),r){let t=e.vertical?bn(new rn(m,v,g,y)):new rn(v,g,y,m);if(("block-start"===a[0]||"snap-block"===a[0]||"inline-start"===a[0]||"snap-inline"===a[0])&&!x(kn,t)||("block-end"===a[0]||"snap-block"===a[0]||"inline-end"===a[0]||"snap-inline"===a[0])&&!x(Pn,t)||(e.isFootnote&&null!==n&&isFinite(n)&&"block-end"===a[0]&&(g=e.vertical?Math.min(g,n):Math.max(g,n)),u=(m-g)*e.getBoxDir(),e.isFootnote&&null!=this.footnoteMaxBlockSize&&(u=Math.min(u,this.footnoteMaxBlockSize),g=e.vertical?m+u:m-u),l=Math.max(0,u-e.getInsetBefore()-e.getInsetAfter()),c=(y-v)*e.getInlineDir(),h=c-e.getInsetStart()-e.getInsetEnd(),!o&&(l<=0||h<=0)))return null}else{let t=e.getContentBlockMarginAfter();l=Math.max(0,e.computedBlockSize+Math.min(0,t)),u=l+e.getInsetBefore()+e.getInsetAfter();let i=(m-g)*e.getBoxDir();if("snap-block"===a[0]){if(null===n)a[0]="block-start";else{let e=this.container.getPaddingRect(),t=this.container.getBoxDir()*(n-(this.container.vertical?e.x2:e.y1)),i=this.container.getBoxDir()*((this.container.vertical?e.x1:e.y2)-n-u);a[0]=t<=i?"block-start":"block-end"}if(!s[a[0]]){if(!s["block-end"])return null;a[0]="block-end"}}else if("snap-inline"===a[0])if(null===n)a[0]="inline-start";else if(s["inline-start"])a[0]="inline-start";else{if(!s["inline-end"])return null;a[0]="inline-end"}if(!o&&i<u)return null;h="inline-start"===a[0]||"inline-end"===a[0]||a[1]?gl(e.clientLayout,e.element,["fit-content inline size"])["fit-content inline size"]:e.adjustContentRelativeSize?e.getContentInlineSize():e.vertical?e.height:e.width,c=h+e.getInsetStart()+e.getInsetEnd();let r=(y-v)*e.getInlineDir();if(!o&&r<c)return null}if(g-=b,m-=b,v-=w,y-=w,a.some(e=>"inline-start"===e||"snap-inline"===e)||1===a.length&&("block-start"===a[0]||"snap-block"===a[0])?e.setInlinePosition(v,h):(a.some(e=>"inline-end"===e)||1===a.length&&"block-end"===a[0])&&e.setInlinePosition(y-c*e.getInlineDir(),h),a.some(e=>"block-start"===e||"snap-block"===e)||1===a.length&&("inline-start"===a[0]||"snap-inline"===a[0]))e.setBlockPosition(g,l);else if(a.some(e=>"block-end"===e)||1===a.length&&"inline-end"===a[0]){let t=m-u*e.getBoxDir();e.setBlockPosition(t,l)}return a.join(" ")}reattachFloatFragments(){let e=this.container.element&&this.container.element.parentNode;e&&this.floatFragments.forEach(t=>{e.appendChild(t.area.element)})}getMaxReachedAfterEdge(){let e=this.container.vertical;return this.floatFragments.reduce((t,i)=>{let n=i.getOuterRect();return e?Math.min(t,n.x1):Math.max(t,n.y2)},e?1/0:0)}getBlockEndEdgeOfBlockStartFloats(e){let t=this.container.vertical,i=NaN;this.floatFragments.filter(e=>e.floatSide.includes("block-start")).filter(i=>{if(void 0===e||!isFinite(e))return!0;let n=i.getOuterRect();return t?n.y1<=e&&e<=n.y2:n.x1<=e&&e<=n.x2}).forEach(e=>{let n=e.getOuterRect(),r=t?n.x1:n.y2;i=isFinite(i)?t?Math.min(i,r):Math.max(i,r):r});let n=this.attachedParent;if(n){let r=n.getBlockEndEdgeOfBlockStartFloats(e);isFinite(r)&&(i=isFinite(i)?t?Math.min(i,r):Math.max(i,r):r)}return i}getBlockStartEdgeOfBlockEndFloats(e){let t=this.container.vertical,i=NaN;this.floatFragments.filter(e=>e.floatSide.includes("block-end")).filter(i=>{if(void 0===e||!isFinite(e))return!0;let n=i.getOuterRect();return t?n.y1<=e&&e<=n.y2:n.x1<=e&&e<=n.x2}).forEach(e=>{let n=e.getOuterRect(),r=t?n.x2:n.y1;i=isFinite(i)?t?Math.max(i,r):Math.min(i,r):r});let n=this.attachedParent;if(n){let r=n.getBlockStartEdgeOfBlockEndFloats(e);isFinite(r)&&(i=isFinite(i)?t?Math.max(i,r):Math.min(i,r):r)}return i}getPageFloatClearEdge(e,t){let i=t=>{let i=this.toLogicalFloatSides(t),n=i[0];return"both"===e?"block-end"===n:"inline-start"===e?i.includes("inline-end")||"block-end"===n:"inline-end"===e&&(i.includes("inline-start")||"block-start"===n||"block-end"===n)};function n(e){return t=>!i(t.float.floatSide)&&e.isAnchorAlreadyAppeared(t.float.getId())}function r(e,t){return!i(e.floatSide)&&e.continuations.some(n(t))}let o=t.getPaddingRect(),s=t.vertical?o.x1:o.y2,a=this;for(;a;){if(a.state.floatsDeferredToNext.some(n(a)))return s;a=a.attachedParent}function l(e){return e.floatFragments.some(t=>r(t,e))||e.state.children.some(e=>l(e))}if("column"===e||"region"===e||"page"===e)for(a=this;a;a=a.attachedParent)if(a.floatReference===e){if(l(a))return s;break}let h=this.getLimitValue("block-start",null,t.layoutContext,t.clientLayout,r);return this.getLimitValue("block-end",null,t.layoutContext,t.clientLayout,r)*t.getBoxDir()<s*t.getBoxDir()?s:h}getPageFloatPlacementCondition(e,t,i){if(e.floatReference!==this.floatReference)return this.getParent(e.floatReference).getPageFloatPlacementCondition(e,t,i);let n={"block-start":!0,"block-end":!0,"inline-start":!0,"inline-end":!0};if(!i)return n;let r,o=this.toLogicalFloatSides(t)[0],s=this.toLogical(i);r="all"===s?["block-start","block-end","inline-start","inline-end"]:"both"===s?["inline-start","inline-end"]:"same"===s?"snap-block"===o?["block-start","block-end"]:[o]:[s];let a=e.getOrder();function l(e){return t=>(!e||t.floatSide.includes(e))&&t.getOrder()<a}function h(e,t){return e.state.children.some(e=>e.floatFragments.some(l(t))||h(e,t))}function u(e,t){let i=e.parent;return!!i&&(i.floatFragments.some(l(t))||u(i,t))}if("column"===i||"region"===i||"page"===i){for(let e=this;e;e=e.attachedParent)if(e.floatReference===i){(e.floatFragments.some(l(null))||h(e,null))&&(n["block-start"]=!1,n["block-end"]=!1,n["inline-start"]=!1,n["inline-end"]=!1);break}return n}return r.forEach(e=>{switch(e){case"block-start":n[e]=!h(this,e);break;case"block-end":n[e]=!u(this,e);break;case"inline-start":case"inline-end":n[e]=!this.floatFragments.some(l(e));break;default:throw new Error(`Unexpected side: ${e}`)}}),n}isColumnFullWithPageFloats(e){let t=e.layoutContext,i=e.clientLayout,n=this.getLimitValuesInner(t,i);for(let r=this.attachedParent;r;r=r.attachedParent){let o=r.getLimitValuesInner(t,i);e.vertical?(o.right<n.right&&(n.right=o.right,n.floatMinWrapBlockStart=o.floatMinWrapBlockStart),o.left>n.left&&(n.left=o.left,n.floatMinWrapBlockEnd=o.floatMinWrapBlockEnd)):(o.top>n.top&&(n.top=o.top,n.floatMinWrapBlockStart=o.floatMinWrapBlockStart),o.bottom<n.bottom&&(n.bottom=o.bottom,n.floatMinWrapBlockEnd=o.floatMinWrapBlockEnd))}let r=Math.max(n.floatMinWrapBlockStart,n.floatMinWrapBlockEnd);return(e.vertical?n.right-n.left:n.bottom-n.top)<=r}getMaxBlockSizeOfPageFloats(){let e=this.container.vertical;return this.floatFragments.length?Math.max.apply(null,this.floatFragments.map(t=>{let i=t.area;return e?i.width:i.height})):0}},Il=[],Al=class{static register(e){Il.push(e)}findByNodeContext(e){for(let t=Il.length-1;t>=0;t--){let i=Il[t];if(i.appliesToNodeContext(e))return i}throw new Error(`No PageFloatLayoutStrategy found for ${e}`)}findByFloat(e){for(let t=Il.length-1;t>=0;t--){let i=Il[t];if(i.appliesToFloat(e))return i}throw new Error(`No PageFloatLayoutStrategy found for ${e}`)}};Al.register(new class{appliesToNodeContext(e){return vl(e.floatReference)}appliesToFloat(e){return!0}createPageFloat(e,t,i){let n=e.floatReference,r=e.floatSide,o=e.toNodePosition(),s=!!t.generatingNodePosition;return i.resolveFloatReferenceFromColumnSpan(n,e.columnSpan,e).thenAsync(i=>{n=i,t.flowName;let a=new bl(o,n,r,e.clearSide,t.flowName,e.floatMinWrapBlock);if(a.insidePageFloatArea=s,s){let e=t.generatingNodePosition;e&&(a.parentPageFloat=t.findPageFloatByNodePosition(e))}return t.addPageFloat(a),so(a)})}createPageFloatFragment(e,t,i,n,r){let o=e[0].float;return new xl(o.floatReference,t,i,e,n,r)}findPageFloatFragment(e,t){return t.findPageFloatFragment(e)}adjustPageFloatArea(e,t,i){return so(void 0)}forbid(e,t){}});var Fl="data-vivliostyle-footnote-first-ref",Rl="data-vivliostyle-footnote-referenced";function Ol(e,t){return!(!e||!e.match(new RegExp(`(^|\\s)${t}($|\\s)`)))}function Ll(e){if("aside"!==e.localName)return!1;if(Ol(e.getAttribute("role"),"doc-footnote"))return!0;return Ol(e.getAttributeNS("http://www.idpf.org/2007/ops","type")||e.getAttribute("epub:type"),"footnote")}function _l(e){if("a"!==e.localName)return!1;if(Ol(e.getAttribute("role"),"doc-noteref"))return!0;return Ol(e.getAttributeNS("http://www.idpf.org/2007/ops","type")||e.getAttribute("epub:type"),"noteref")}function Bl(e,t){if(!_l(e))return null;let i=e.getAttribute("href")||e.getAttributeNS("http://www.w3.org/1999/xlink","href");if(!i)return null;let n=ce(i,t);return"#"===n?null:n}function Ml(e,t,i){let n=Bl(e,t);if(!n)return null;let r=i(n);return r&&Ll(r)?r:null}function Dl(e,t,i,n,r){if("a"!==e.localName||!_l(e))return!0;let o=Bl(e,t);if(!o)return!0;!function(e,t,i,n,r){if(r.value)return;let o=e.getElementsByTagName("a");for(let e=0;e<o.length;e++){let r=o.item(e),s=Bl(r,t);!s||n.has(s)||n.set(s,i(r))}r.value=!0}(e.ownerDocument,t,i,n,r);let s=n.get(o);return null==s||i(e)===s}function zl(e,t){let i=t.getProp(e,"footnote-display");if(i)return i;let n=t.getProp(e,"display");return(null==n?void 0:n.value)===di.inline?t.createCascadeValue(di.inline,n.priority):null}function Vl(e,t){if(e instanceof li){let i=e.expr.evaluate(t);return"string"==typeof i?new Xt(i):"number"==typeof i?new Xt(String(i)):e}return e instanceof oi?new oi(e.values.map(e=>Vl(e,t))):e}function Ul(e,t,i){let n=null==e?void 0:e["_footnote-marker-content"];n&&(t["--viv-marker-content"]=Vl(n.value,i))}_("PREPROCESS_SINGLE_DOCUMENT",function(e){let t=e.getElementsByTagName("a"),i=new Set;for(let n=0;n<t.length;n++){let r=t.item(n);if(!(_l(r)&&r instanceof HTMLAnchorElement&&r.hash&&r.href===r.baseURI.replace(/#.*$/,"")+r.hash))continue;let o=r.hash.substring(1),s=e.getElementById(o);if(s&&Ll(s)){let e=r.baseURI.replace(/#.*$/,"")+r.hash;i.has(e)||(i.add(e),r.setAttribute(Fl,"true")),s.setAttribute(Rl,"true")}}});var Hl=xl,$l=class e extends bl{constructor(e,t,i,n,r,o){super(e,t,"block-end",null,i,r),h(this,"footnotePolicy",n),h(this,"policyAnchorNode",o)}isAllowedToPrecede(t){return!(t instanceof e)}};function jl(e){return e?-1:1}function Wl(e,t){return t?e.right:e.top}function Gl(e,t){return t?e.left:e.bottom}function ql(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom,width:e.width,height:e.height}}function Xl(e,t){let i=ql(e.getBoundingClientRect());return za(i,t),i.right<i.left||i.bottom<i.top?null:i}function Yl(e,t){let i=Array.from(e,ql);return Va(i,t),i.filter(e=>e.right>e.left&&e.bottom>e.top)}function Kl(e,t){return e.length?t?Math.min(...e.map(e=>e.left)):Math.max(...e.map(e=>e.bottom)):NaN}function Zl(e,t){let i=e.viewNode;if(!i)return NaN;if(i.nodeType===Node.ELEMENT_NODE){let n=i;if(e.after||!e.inline){let i=Xl(n,t);if(i)return e.after?Gl(i,t):Wl(i,t)}return function(e,t){if(!e.length)return NaN;let i=jl(t),n=e.reduce((e,n)=>Wl(n,t)*i<Wl(e,t)*i?n:e);return Gl(n,t)}(Yl(n.getClientRects(),t),t)}let n=i.textContent||"";if(!n.length)return NaN;let r=e.offsetInNode;e.after&&(r+=n.length),r=Math.max(0,Math.min(r,n.length-1));let o=i.ownerDocument.createRange();return o.setStart(i,r),o.setEnd(i,r+1),Kl(Yl(o.getClientRects(),t),t)}var Jl=class extends Hl{constructor(e,t,i,n){super(e,"block-end",null,t,i,n)}getOrder(){return 1/0}shouldBeStashedBefore(e){return e instanceof $l||this.getOrder()<e.getOrder()}},Ql=class{constructor(e,t,i){h(this,"footnote",e),h(this,"vertical",i),h(this,"anchorEdge"),this.anchorEdge=function(e,t){if(!e)return NaN;if(e.nodeType===Node.ELEMENT_NODE){let i=Xl(e,t);return i?Gl(i,t):NaN}let i=e.textContent||"";if(!i.length)return NaN;let n=e.ownerDocument.createRange();return n.setStart(e,0),n.setEnd(e,i.length),Kl(Yl(n.getClientRects(),t),t)}(t,i)}allowLayout(e){if(!isNaN(this.anchorEdge)){let t=Zl(e,this.vertical);if(!isNaN(t)){let e=jl(this.vertical);return t*e<this.anchorEdge*e-.1}}return!sa(e.toNodePosition(),this.footnote.nodePosition)}};Al.register(new class{appliesToNodeContext(e){return"footnote"===e.floatSide}appliesToFloat(e){return e instanceof $l}createPageFloat(e,t,i){var n;let r=ml.REGION,o=t.getPageFloatLayoutContext(r);t.getPageFloatLayoutContext(ml.PAGE).hasSameContainerAs(o)&&(r=ml.PAGE);let s=!!t.generatingNodePosition;s&&r!==ml.PAGE&&(r=ml.PAGE);let a=e.toNodePosition();t.flowName;let l=e.sourceNode,h=null==(n=e.shadowContext)?void 0:n.owner;h instanceof Element&&_l(h)&&(l=h),l=function(e){let t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;for(;t;){if(/^(p|li|dd|dt|td|th|blockquote)$/i.test(t.localName)&&!t.querySelector("br"))return t;t=t.parentElement}return e}(l);let u=new $l(a,r,t.flowName,e.footnotePolicy,e.floatMinWrapBlock,l);if(u.insidePageFloatArea=s,s){let e=t.generatingNodePosition;e&&(u.parentPageFloat=t.findPageFloatByNodePosition(e))}return t.addPageFloat(u),so(u)}createPageFloatFragment(e,t,i,n,r){let o=e[0].float;return new Jl(o.floatReference,e,n,r)}findPageFloatFragment(e,t){let i=t.getPageFloatLayoutContext(e.floatReference),n=i.container.element,r=i.floatFragments.filter(t=>t instanceof Jl&&(e.floatReference!==ml.REGION||!t.area.parentElement||t.area.parentElement===n));return r.find(t=>t.hasFloat(e))||r[0]||null}adjustPageFloatArea(e,t,i){e.isFootnote=!0,e.adjustContentRelativeSize=!1;let n=e.element;return i.layoutContext.applyFootnoteStyle(t.vertical,i.layoutContext.nodeContext&&"rtl"===i.layoutContext.nodeContext.direction,n).thenAsync(t=>{var r,o;if(e.vertical=t,e.convertPercentageSizesToPx(n),i.setComputedInsets(n,e),i.setComputedWidthAndHeight(n,e),"border-box"===(null==(r=i.clientLayout.getElementComputedStyle(n))?void 0:r.boxSizing)){let t=e.vertical?e.paddingLeft+e.paddingRight+e.borderLeft+e.borderRight:e.paddingTop+e.paddingBottom+e.borderTop+e.borderBottom,i=e.vertical?["max-width","min-width","width"]:["max-height","min-height","height"],r=getComputedStyle(n);for(let e of i){let i=r.getPropertyValue(e);if(i&&"none"!==i){let r=parseFloat(i);isNaN(r)||be(n,e,`${Math.max(0,r-t)}px`)}}be(n,"box-sizing","content-box")}let s=i.pageFloatLayoutContext;for(;s;){if(s.ignoreFootnoteAreaMaxHeight){be(n,"max-block-size",""),be(n,e.vertical?"max-width":"max-height","");break}s=null!=(o=s.parent)?o:null}return so(void 0)})}forbid(e,t){let i=e;if(i.footnotePolicy===di.line){let e=t.collectPageFloatAnchors()[i.getId()]||null,n=new Ql(i,e,t.getPageFloatLayoutContext(i.floatReference).container.vertical);t.addLayoutConstraint(n,i.floatReference)}}});var eh=class{calculateOffset(e){return th(this.getNodeContext(),e.collectElementsOffset())}breakPositionChosen(e){}getNodeContext(){return null}};function th(e,t){return{current:t.reduce((t,i)=>t+i.calculateOffset(e),0),minimum:t.reduce((t,i)=>t+i.calculateMinimumOffset(e),0)}}var ih=class extends eh{constructor(e,t,i,n){super(),h(this,"position",e),h(this,"breakOnEdge",t),h(this,"overflows",i),h(this,"computedBlockSize",n),h(this,"overflowIfRepetitiveElementsDropped"),h(this,"isEdgeUpdated",!1),h(this,"edge",0),this.overflowIfRepetitiveElementsDropped=i}findAcceptableBreak(e,t){return this.updateOverflows(e),t<this.getMinBreakPenalty()?null:e.findEdgeBreakPosition(this)}getMinBreakPenalty(){if(!this.isEdgeUpdated)throw new Error("EdgeBreakPosition.prototype.updateEdge not called");let e=this.isFirstContentOfRepetitiveElementsOwner()&&!this.overflowIfRepetitiveElementsDropped;return(Rs(this.breakOnEdge)?1:0)+(this.overflows&&!e?3:0)+(this.position.parent?this.position.parent.breakPenalty:0)}updateEdge(e){var t;let i=e.calculateClonedPaddingBorder(this.position);if(this.edge=qa(this.position,e.clientLayout,0,e.vertical)+i,this.position.after||this.position.inline){if(this.position.after&&"table-cell"===(null==(t=this.position.shadowContext)?void 0:t.root.id)){let t=e.element.parentElement,i=null==t?void 0:t.closest("table, [style*='display: table;']");if(i){let n="collapse"===i.style.borderCollapse,r=0,o=0;for(let s=t;s;s=s.parentElement){let a=e.clientLayout.getElementComputedStyle(s);if((s===t||s===i&&!n)&&(r+=e.parseComputedLength(a.paddingBlockEnd)),s===i&&!n&&(r+=e.parseComputedLength(a.borderSpacing.replace(/^\S+ (\S+)$/,"$1"))),n?o=Math.max(o,e.parseComputedLength(a.borderBlockEndWidth)):(s===t||s===i)&&(o+=e.parseComputedLength(a.borderBlockEndWidth)),s===i)break}this.edge+=(e.vertical?-1:1)*(r+o)}}}else{let t=e.parseComputedLength(e.clientLayout.getElementComputedStyle(this.position.viewNode).marginBlockStart);this.edge-=(e.vertical?-1:1)*t}this.isEdgeUpdated=!0}updateOverflows(e){this.isEdgeUpdated||this.updateEdge(e);let t=this.edge,i=this.calculateOffset(e);this.overflowIfRepetitiveElementsDropped=e.isOverflown(t+(e.vertical?-1:1)*i.minimum),this.overflows=this.position.overflow=e.isOverflown(t+(e.vertical?-1:1)*i.current)}getNodeContext(){return this.position}isFirstContentOfRepetitiveElementsOwner(){let e=this.getNodeContext();if(!e||!e.parent)return!1;let{formattingContext:t}=e.parent;if(!Ds.isInstanceOfRepetitiveElementsOwnerFormattingContext(t))return!1;let i=t.getRepetitiveElements();return!!i&&i.isFirstContentNode(e)}},nh=class{find(e){let t=M("RESOLVE_LAYOUT_PROCESSOR");for(let i=0;i<t.length;i++){let n=t[i](e);if(n)return n}throw new Error(`No processor found for a formatting context: ${e.getName()}`)}},rh=class{layout(e,t,i){let n=t.asFloatNodeContext(e);return n?t.layoutFloatOrFootnote(n):t.isBreakable(e)?t.layoutBreakableBlock(e):t.layoutUnbreakable(e)}createEdgeBreakPosition(e,t,i,n){return new ih(e.copy(),t,i,n)}startNonInlineElementNode(e){return!1}afterNonInlineElementNode(e,t){return!1}clearOverflownViewNodes(e,t,i,n){var r;if(!i.viewNode||!i.viewNode.parentNode||i.shadowType===Vs.ShadowType.ROOTLESS&&il(i))return;let o=i.viewNode;o=null!=(r=ol(o))?r:o,Ka(o.parentNode,o),n&&o.remove()}finishBreak(e,t,i,n){let r=i||null!=t.viewNode&&1==t.viewNode.nodeType&&!t.after;return e.clearOverflownViewNodes(t,r),n&&e.layoutContext.processFragmentedBlockEdge(t),so(!0)}},oh=class{constructor(e){h(this,"parent",e),h(this,"formattingContextType","Block")}getName(){return"Block formatting context (BlockFormattingContext)"}isFirstTime(e,t){return t}getParent(){return this.parent}saveState(){}restoreState(e){}},sh=new rh,ah=_s.isInstanceOfBlockFormattingContext;_("RESOLVE_FORMATTING_CONTEXT",e=>{let t=e.parent;return t&&e.formattingContext===t.formattingContext&&e.establishesBFC?new oh(t.formattingContext):null}),_("RESOLVE_LAYOUT_PROCESSOR",e=>e instanceof oh?sh:null);var lh=class{constructor(){h(this,"initialBreakPositions",null),h(this,"initialStateOfFormattingContext",null),h(this,"initialPosition",null),h(this,"initialFragmentLayoutConstraints",null)}layout(e,t){return this.prepareLayout(e,t),this.tryLayout(e,t)}tryLayout(e,t){let i=oo("AbstractLayoutRetryer.tryLayout");this.saveState(e,t);let n=this.resolveLayoutMode(e);return n.doLayout(e,t).then(r=>{let o=n.accept(r,t);o=n.postLayout(r,this.initialPosition,t,o),o?i.finish(r):(this.initialPosition,this.clearNodes(this.initialPosition),this.restoreState(e,t),this.tryLayout(this.initialPosition,t).thenFinish(i))}),i.result()}prepareLayout(e,t){}clearNodes(e){var t,i;let n,r,o=null!=(i=e.viewNode)?i:null==(t=e.parent)?void 0:t.viewNode;if(o){for(;n=o.lastChild;)o.removeChild(n);for(;r=o.nextSibling;)r.remove()}}saveState(e,t){this.initialPosition=e.copy(),this.initialBreakPositions=[].concat(t.breakPositions),this.initialFragmentLayoutConstraints=[].concat(t.fragmentLayoutConstraints),this.initialStateOfFormattingContext=e.formattingContext.saveState()}restoreState(e,t){t.breakPositions=this.initialBreakPositions,t.fragmentLayoutConstraints=this.initialFragmentLayoutConstraints,e.formattingContext.restoreState(this.initialStateOfFormattingContext)}};function hh(e){return null!==e.nodeContext?e:null}var uh,ch=class{initialState(e){return{nodeContext:e,atUnforcedBreak:!1,break:!1}}startNonDisplayableNode(e){}afterNonDisplayableNode(e){}startIgnoredTextNode(e){}afterIgnoredTextNode(e){}startNonElementNode(e){}afterNonElementNode(e){}startInlineElementNode(e){}afterInlineElementNode(e){}startNonInlineElementNode(e){}afterNonInlineElementNode(e){}finish(e){}},dh=class{constructor(e,t){h(this,"strategy",e),h(this,"layoutContext",t)}iterate(e){let t=this.strategy,i=t.initialState(e),n=oo("LayoutIterator");return n.loopWithFrame(e=>{for(;;){let t=hh(i);if(!t)break;let n=this.step(t);if(n.isPending())return void n.then(t=>{i.break?e.breakLoop():(i.nodeContext=t,e.continueLoop())});if(i.break)return void e.breakLoop();i.nodeContext=n.get()}t.finish(i),e.breakLoop()}).then(()=>{n.finish(i.nodeContext)}),n.result()}step(e){let t,i=this.strategy,n=function(e){return null!==ka(e.nodeContext)?e:null}(e);return t=n?1!==n.nodeContext.viewNode.nodeType?Qs(n.nodeContext.viewNode,n.nodeContext.whitespace)?n.nodeContext.after?i.afterIgnoredTextNode(n):i.startIgnoredTextNode(n):n.nodeContext.after?i.afterNonElementNode(n):i.startNonElementNode(n):n.nodeContext.inline?n.nodeContext.after?i.afterInlineElementNode(n):i.startInlineElementNode(n):n.nodeContext.after?i.afterNonInlineElementNode(n):i.startNonInlineElementNode(n):e.nodeContext.after?i.afterNonDisplayableNode(e):i.startNonDisplayableNode(e),(t&&t.isPending()?t:so(!0)).thenAsync(()=>e.break?so(null):this.layoutContext.nextInTree(e.nodeContext,e.atUnforcedBreak))}},ph=class extends ch{constructor(e){super(),h(this,"leadingEdge",e)}startNonInlineBox(e){}endEmptyNonInlineBox(e){}endNonInlineBox(e){}initialState(e){return{nodeContext:e,atUnforcedBreak:!!this.leadingEdge&&e.after,break:!1,leadingEdge:this.leadingEdge,breakAtTheEdge:null,onStartEdges:!1,leadingEdgeContexts:[],lastAfterNodeContext:null}}processForcedBreak(e,t){let i=!e.leadingEdge&&Ns(e.breakAtTheEdge);return i&&((e.nodeContext=e.leadingEdgeContexts[0]||e.nodeContext).viewNode.remove(),t.pageBreakType=e.breakAtTheEdge),i}saveEdgeAndProcessOverflow(e,t){let i=t.checkOverflowAndSaveEdgeAndBreakPosition(e.lastAfterNodeContext,null,!0,e.breakAtTheEdge);return i&&(e.nodeContext=(e.lastAfterNodeContext||e.nodeContext).modify(),e.nodeContext.overflow=!0),i}processLayoutConstraint(e,t,i){let n=e.nodeContext,r=!t.allowLayout(n);return r&&(i.checkOverflowAndSaveEdgeAndBreakPosition(e.lastAfterNodeContext,null,!1,e.breakAtTheEdge),n=e.nodeContext=n.modify(),n.overflow=!0),r}startNonElementNode(e){e.onStartEdges=!1}startNonInlineElementNode(e){return e.leadingEdgeContexts.push(e.nodeContext.copy()),e.breakAtTheEdge=Os(e.breakAtTheEdge,e.nodeContext.breakBefore),e.onStartEdges=!0,this.startNonInlineBox(e)}afterNonInlineElementNode(e){let t,i;return e.onStartEdges?(t=this.endEmptyNonInlineBox(e),i=t&&t.isPending()?t:so(!0),i=i.thenAsync(()=>(e.break||(e.leadingEdgeContexts=[],e.leadingEdge=!1,e.atUnforcedBreak=!1,e.breakAtTheEdge=null),so(!0)))):(t=this.endNonInlineBox(e),i=t&&t.isPending()?t:so(!0)),i.thenAsync(()=>(e.break||(e.onStartEdges=!1,e.lastAfterNodeContext=e.nodeContext.copy(),e.breakAtTheEdge=Os(e.breakAtTheEdge,e.nodeContext.breakAfter)),so(!0)))}},fh=[];function gh(e){if(""===e)return 0;if(void 0===uh){let e=Intl.Segmenter;uh="function"==typeof e?new e(void 0,{granularity:"grapheme"}):null}if(null===uh)return[...e].length;let t=0;for(let i of uh.segment(e))t++;return t}var mh=new Set(["decimal","disc","square","circle","disclosure-open","disclosure-closed"]),vh=new Set(["cyclic","numeric","alphabetic","symbolic","additive","fixed"]),yh=new Set(["fixed","extends"]);function bh(e){return e instanceof Kt&&"none"!==e.name.toLowerCase()}function wh(e){return e.name}function xh(e){return e instanceof Xt||e instanceof Kt}function Sh(e){return e instanceof Xt?e.str:e.name}function Ch(e){if(xh(e))return!0;if(e instanceof oi&&2===e.values.length){let t=e.values[0],i=e.values[1];return xh(t)&&xh(i)}return!1}function kh(e){return e instanceof ei||e instanceof Kt&&"infinite"===e.name}function Ph(e,t){return e instanceof ei?e.num:t?-1/0:1/0}function Eh(e){if(!(e instanceof oi&&2===e.values.length))return!1;let t=e.values[0],i=e.values[1];return!(!kh(t)||!kh(i))&&!(Ph(t,!0)>Ph(i,!1))}function Nh(e){return e instanceof Kt&&"auto"===e.name||Eh(e)||e instanceof si&&e.values.length>=1&&e.values.every(e=>Eh(e))}function Th(e){return e instanceof Kt?null:(Eh(e)?[e]:e.values).map(e=>function(e){return{lower:Ph(e.values[0],!0),upper:Ph(e.values[1],!1)}}(e))}function Ih(e){if(!(e instanceof oi&&2===e.values.length))return!1;let t=e.values[0],i=e.values[1];return t instanceof ei&&t.num>=0&&xh(i)||xh(t)&&i instanceof ei&&i.num>=0}function Ah(e){let[t,i]=e.values;return t instanceof ei?[t.num,Sh(i)]:[i.num,Sh(t)]}function Fh(e){return Ih(e)}function Rh(e){return xh(e)||e instanceof oi&&e.values.length>=1&&e.values.every(e=>xh(e))}function Oh(e){if(Ih(e))return!0;if(e instanceof si&&e.values.length>=1){let t=1/0;for(let i of e.values){if(!Ih(i))return!1;let[e]=Ah(i);if(e>=t)return!1;t=e}return!0}return!1}var Lh=new Set(["auto","bullets","numbers","words","spell-out"]);function _h(e,t){switch(e){case"system":return function(e){if(e instanceof Kt)return vh.has(e.name);if(e instanceof oi&&2===e.values.length){let t=e.values[0],i=e.values[1];if(t instanceof Kt){let e=t.name;return yh.has(e)&&("fixed"===e&&i instanceof ei||"extends"===e&&bh(i))}}return!1}(t);case"negative":return Ch(t);case"prefix":case"suffix":return xh(t);case"range":return Nh(t);case"pad":return Fh(t);case"fallback":return bh(t);case"symbols":return Rh(t);case"additive-symbols":return Oh(t);case"speak-as":return function(e){return e instanceof Kt&&Lh.has(e.name)||bh(e)}(t);default:return!0}}function Bh(e,t){var i;let n=null==(i=e[t])?void 0:i.value;return null==n?null:n}function Mh(e){let t=e.get("decimal");return t||(t=yu.createDecimal(e),e.set("decimal",t)),t}var Dh,zh,Vh,Uh,Hh,$h,jh,Wh,Gh,qh,Xh,Yh,Kh,Zh,Jh,Qh,eu,tu,iu,nu,ru,ou,su,au,lu,hu,uu,cu,du,pu,fu,gu,mu=class e{constructor(e,t){f(this,au),h(this,"_store"),f(this,Dh),f(this,zh),f(this,Vh),f(this,Uh),f(this,Hh),f(this,$h),f(this,jh),f(this,Wh),this._store=e;let i=Bh(t,"negative");g(this,Dh,i&&Ch(i)?function(e){if(xh(e))return{prefix:Sh(e),suffix:null};{let t=e.values[0],i=e.values[1];return{prefix:Sh(t),suffix:Sh(i)}}}(i):null);let n=Bh(t,"prefix");g(this,zh,n&&xh(n)?Sh(n):null);let r=Bh(t,"suffix");g(this,Vh,r&&xh(r)?Sh(r):null);let o=Bh(t,"range");g(this,Uh,o&&Nh(o)?Th(o):null);let s=Bh(t,"pad");g(this,Hh,s&&Fh(s)?function(e){let[t,i]=Ah(e);return{minLength:t,symbol:i}}(s):null);let a=Bh(t,"fallback");g(this,$h,a&&bh(a)?wh(a):null);let l=Bh(t,"symbols");g(this,jh,l&&Rh(l)?function(e){return xh(e)?[Sh(e)]:e.values.map(e=>Sh(e))}(l):null);let u=Bh(t,"additive-symbols");g(this,Wh,u&&Oh(u)?function(e){if(Ih(e)){let[t,i]=Ah(e);return[{weight:t,symbol:i}]}return e.values.map(e=>{let[t,i]=Ah(e);return{weight:t,symbol:i}})}(u):null)}static create(e,t){return function(e){let t=Bh(e,"system");return t instanceof Kt&&"cyclic"===t.name}(t)?new bu(e,t):function(e){let t=Bh(e,"system");if(t instanceof Kt&&"fixed"===t.name)return!0;if(t instanceof oi&&2===t.values.length){let[e,i]=t.values;return e instanceof Kt&&"fixed"===e.name&&i instanceof ei}return!1}(t)?new wu(e,t):function(e){let t=Bh(e,"system");return t instanceof Kt&&"alphabetic"===t.name}(t)?new Pu(e,t):function(e){let t=Bh(e,"system");return t instanceof Kt&&"numeric"===t.name}(t)?new Eu(e,t):function(e){let t=Bh(e,"system");return t instanceof Kt&&"additive"===t.name}(t)?new Nu(e,t):function(e){let t=Bh(e,"system");if(t instanceof oi&&2===t.values.length){let[e,i]=t.values;return e instanceof Kt&&"extends"===e.name&&bh(i)}return!1}(t)?new Iu(e,t):new ku(e,t)}static createDecimal(t){var i;return new Eu(t,m(i=e,qh,Xh).call(i))}static createDisc(t){var i;return new bu(t,m(i=e,qh,Kh).call(i))}static createSquare(t){var i;return new bu(t,m(i=e,qh,Jh).call(i))}static createCircle(t){var i;return new bu(t,m(i=e,qh,eu).call(i))}static createDisclosureOpen(t){var i;return new bu(t,m(i=e,qh,iu).call(i))}static createDisclosureClosed(e){return new bu(e,m(this,qh,ru).call(this))}static createNone(t){var i;return new bu(t,m(i=e,qh,su).call(i))}static get CHINESE_LONGHAND_NAMES(){return qu.NAMES}static createChineseLonghand(e,t){return new qu(e,t)}static createEthiopicNumeric(e){return new Zu(e)}_getNegative(){return p(this,Dh)}static _getNegativeFrom(e){return e._getNegative()}_getPrefix(){return p(this,zh)}static _getPrefixFrom(e){return e._getPrefix()}_getSuffix(){return p(this,Vh)}static _getSuffixFrom(e){return e._getSuffix()}static _getAutoRangeFrom(e){return e._getAutoRange()}_getRange(){return p(this,Uh)}static _getRangeFrom(e){return e._getRange()}_getPad(){return p(this,Hh)}static _getPadFrom(e){return e._getPad()}_getFallback(){var e;return null!=p(this,$h)&&null!=(e=this._store.get(p(this,$h)))?e:null}static _getFallbackFrom(e){return e._getFallback()}_getSymbols(){return p(this,jh)}static _getSymbolsFrom(e){return e._getSymbols()}_getAdditiveSymbols(){return p(this,Wh)}static _getAdditiveSymbolsFrom(e){return e._getAdditiveSymbols()}static _useNegativeSignFrom(e,t){return e._usesNegativeSign(t)}static _generateInitialRepresentationFrom(e,t){return e._generateInitialRepresentation(t)}format(e){return m(this,au,gu).call(this,e,new Set)}formatMarker(e){return m(this,au,hu).call(this)+this.format(e)+m(this,au,uu).call(this)}};Dh=new WeakMap,zh=new WeakMap,Vh=new WeakMap,Uh=new WeakMap,Hh=new WeakMap,$h=new WeakMap,jh=new WeakMap,Wh=new WeakMap,Gh=new WeakMap,qh=new WeakSet,Xh=function(){var e;return null!=(e=p(mu,Gh))?e:g(mu,Gh,{system:new Cd(Zt("numeric"),0),symbols:new Cd(new oi([new Xt("0"),new Xt("1"),new Xt("2"),new Xt("3"),new Xt("4"),new Xt("5"),new Xt("6"),new Xt("7"),new Xt("8"),new Xt("9")]),0)})},Yh=new WeakMap,Kh=function(){var e;return null!=(e=p(mu,Yh))?e:g(mu,Yh,{system:new Cd(Zt("cyclic"),0),symbols:new Cd(new Xt("•"),0),suffix:new Cd(new Xt(" "),0)})},Zh=new WeakMap,Jh=function(){var e;return null!=(e=p(mu,Zh))?e:g(mu,Zh,{system:new Cd(Zt("cyclic"),0),symbols:new Cd(new Xt("▪"),0),suffix:new Cd(new Xt(" "),0)})},Qh=new WeakMap,eu=function(){var e;return null!=(e=p(mu,Qh))?e:g(mu,Qh,{system:new Cd(Zt("cyclic"),0),symbols:new Cd(new Xt("◦"),0),suffix:new Cd(new Xt(" "),0)})},tu=new WeakMap,iu=function(){var e;return null!=(e=p(mu,tu))?e:g(mu,tu,{system:new Cd(Zt("cyclic"),0),symbols:new Cd(new Xt("▾"),0),suffix:new Cd(new Xt(" "),0)})},nu=new WeakMap,ru=function(){var e;return null!=(e=p(mu,nu))?e:g(mu,nu,{system:new Cd(Zt("cyclic"),0),symbols:new Cd(new Xt("▸"),0),suffix:new Cd(new Xt(" "),0)})},ou=new WeakMap,su=function(){var e;return null!=(e=p(mu,ou))?e:g(mu,ou,{system:new Cd(Zt("cyclic"),0),symbols:new Cd(new Xt(""),0),suffix:new Cd(new Xt(""),0)})},au=new WeakSet,lu=function(){var e;return null!=(e=this._getNegative())?e:{prefix:"-",suffix:null}},hu=function(){var e;return null!=(e=this._getPrefix())?e:""},uu=function(){var e;return null!=(e=this._getSuffix())?e:". "},cu=function(){var e;return null!=(e=this._getRange())?e:this._getAutoRange()},du=function(){var e;return null!=(e=this._getPad())?e:{minLength:0,symbol:""}},pu=function(){var e;return null!=(e=this._getFallback())?e:Mh(this._store)},fu=function(e,t){let{minLength:i,symbol:n}=m(this,au,du).call(this);if(0===i||""===n)return e;let{prefix:r,suffix:o}=m(this,au,lu).call(this),s=t?gh(r)+(o?gh(o):0):0,a=i-gh(e)-s;if(a<=0)return e;let l=gh(n),h=Math.ceil(a/l);return n.repeat(h)+e},gu=function(e,t){var i,n,r;if(t.has(this))return m(i=Mh(this._store),au,gu).call(i,e,new Set);if(t.add(this),!function(e,t){return t.some(({lower:t,upper:i})=>e>=t&&e<=i)}(e,m(this,au,cu).call(this))){let i=m(this,au,pu).call(this);return m(n=i,au,gu).call(n,e,t)}let o=this._usesNegativeSign(e),s=o?Math.abs(e):e,a=this._generateInitialRepresentation(s);if(null===a){let i=m(this,au,pu).call(this);return m(r=i,au,gu).call(r,e,t)}let l=m(this,au,fu).call(this,a,o);if(o){let{prefix:e,suffix:t}=m(this,au,lu).call(this);l=e+l+(null!=t?t:"")}return l},f(mu,qh),f(mu,Gh,null),f(mu,Yh,null),f(mu,Zh,null),f(mu,Qh,null),f(mu,tu,null),f(mu,nu,null),f(mu,ou,null);var vu,yu=mu,bu=class extends yu{constructor(e,t){super(e,t)}_getAutoRange(){return[{lower:-1/0,upper:1/0}]}_usesNegativeSign(e){return!1}_generateInitialRepresentation(e){let t=this._getSymbols();if(!t||0===t.length)return null;let i=t.length;return t[((e-1)%i+i)%i]}},wu=class extends yu{constructor(e,t){super(e,t),f(this,vu),g(this,vu,function(e){let t=Bh(e,"system");return t instanceof Kt?1:t.values[1].num}(t))}_getAutoRange(){return[{lower:-1/0,upper:1/0}]}_usesNegativeSign(e){return!1}_generateInitialRepresentation(e){var t;let i=this._getSymbols();return i&&0!==i.length&&null!=(t=i[e-p(this,vu)])?t:null}};vu=new WeakMap;var xu,Su,Cu,ku=class extends yu{constructor(e,t){super(e,t)}_getAutoRange(){return[{lower:1,upper:1/0}]}_usesNegativeSign(e){return e<0}_generateInitialRepresentation(e){let t=this._getSymbols();if(!t||0===t.length||e<1)return null;let i=t.length,n=t[(e-1)%i],r=Math.ceil(e/i);return n.repeat(r)}},Pu=class extends yu{constructor(e,t){super(e,t)}_getAutoRange(){return[{lower:1,upper:1/0}]}_usesNegativeSign(e){return e<0}_generateInitialRepresentation(e){let t=this._getSymbols();if(!t||t.length<2||e<1)return null;let i=t.length,n="",r=e;for(;0!==r;)r-=1,n=t[r%i]+n,r=Math.floor(r/i);return n}},Eu=class extends yu{constructor(e,t){super(e,t)}_getAutoRange(){return[{lower:-1/0,upper:1/0}]}_usesNegativeSign(e){return e<0}_generateInitialRepresentation(e){let t=this._getSymbols();if(!t||t.length<2)return null;let i=t.length;if(0===e)return t[0];let n="",r=e;for(;0!==r;)n=t[r%i]+n,r=Math.floor(r/i);return n}},Nu=class extends yu{constructor(e,t){super(e,t)}_getAutoRange(){return[{lower:0,upper:1/0}]}_usesNegativeSign(e){return e<0}_generateInitialRepresentation(e){let t=this._getAdditiveSymbols();if(!t||0===t.length)return null;let i="";if(0===e){let e=t.find(e=>0===e.weight);return e?e.symbol:null}let n=e;for(let e of t){let{weight:t,symbol:r}=e;if(0===t||t>n)continue;let o=Math.floor(n/t);if(i+=r.repeat(o),n-=t*o,0===n)return i}return null}},Tu=class extends yu{constructor(e,t){super(e,t),f(this,Su),f(this,xu);let i=function(e){return wh(Bh(e,"system").values[1])}(t),n=i.toLowerCase();g(this,xu,"disc"===n||"circle"===n||"square"===n||"disclosure-open"===n||"disclosure-closed"===n?n:i)}_getNegative(){var e;return null!=(e=super._getNegative())?e:yu._getNegativeFrom(m(this,Su,Cu).call(this))}_getPrefix(){var e;return null!=(e=super._getPrefix())?e:yu._getPrefixFrom(m(this,Su,Cu).call(this))}_getSuffix(){var e;return null!=(e=super._getSuffix())?e:yu._getSuffixFrom(m(this,Su,Cu).call(this))}_getAutoRange(){return yu._getAutoRangeFrom(m(this,Su,Cu).call(this))}_getRange(){var e;return null!=(e=super._getRange())?e:yu._getRangeFrom(m(this,Su,Cu).call(this))}_getPad(){var e;return null!=(e=super._getPad())?e:yu._getPadFrom(m(this,Su,Cu).call(this))}_getFallback(){var e;return null!=(e=super._getFallback())?e:yu._getFallbackFrom(m(this,Su,Cu).call(this))}_getSymbols(){var e;return null!=(e=super._getSymbols())?e:yu._getSymbolsFrom(m(this,Su,Cu).call(this))}_getAdditiveSymbols(){var e;return null!=(e=super._getAdditiveSymbols())?e:yu._getAdditiveSymbolsFrom(m(this,Su,Cu).call(this))}_usesNegativeSign(e){return yu._useNegativeSignFrom(m(this,Su,Cu).call(this),e)}_generateInitialRepresentation(e){return super._getSymbols()||super._getAdditiveSymbols()?null:yu._generateInitialRepresentationFrom(m(this,Su,Cu).call(this),e)}};xu=new WeakMap,Su=new WeakSet,Cu=function(e=new Set){var t;if(e.has(this))return Mh(this._store);e.add(this);let i=this._store.get(p(this,xu));return i?i instanceof Tu?m(t=i,Su,Cu).call(t,e):i:Mh(this._store)};var Iu=Tu;function Au(e){return{suffix:new Cd(new Xt("、"),0),fallback:new Cd(Zt("cjk-decimal"),0),range:new Cd(new oi([new ei(-9999),new ei(9999)]),0),negative:new Cd(new Xt(e),0)}}var Fu,Ru,Ou,Lu,_u,Bu,Mu,Du,zu=class e extends yu{constructor(t,i){var n;let{chars:r,descriptors:o}=m(n=e,Bu,Mu).call(n).get(i);super(t,o),f(this,Du),g(this,Du,r)}_getAutoRange(){return[{lower:-9999,upper:9999}]}_usesNegativeSign(e){return e<0}_generateInitialRepresentation(e){let t=p(this,Du);if(0===e)return t.digits[0];let i=[],n=0,r=e;for(;r>0;)i.unshift({digit:r%10,position:n}),r=Math.floor(r/10),n++;let o=t.informal&&e>=10&&e<=19,s="",a=!1;for(let e=0;e<i.length;e++){let{digit:n,position:r}=i[e],l=e===i.length-1;0===n?!l&&!a&&(a=!0):(a&&(s+=t.digits[0],a=!1),o&&1===r?s+=t.markers[r]:(s+=t.digits[n],r>0&&(s+=t.markers[r])))}return s}};Fu=new WeakMap,Ru=new WeakMap,Ou=new WeakMap,Lu=new WeakMap,_u=new WeakMap,Bu=new WeakSet,Mu=function(){var e;return null!=(e=p(zu,_u))?e:g(zu,_u,new Map([["simp-chinese-informal",{chars:p(zu,Fu),descriptors:Au("负")}],["simp-chinese-formal",{chars:p(zu,Ru),descriptors:Au("负")}],["trad-chinese-informal",{chars:p(zu,Ou),descriptors:Au("負")}],["trad-chinese-formal",{chars:p(zu,Lu),descriptors:Au("負")}],["cjk-ideographic",{chars:p(zu,Ou),descriptors:Au("負")}]]))},Du=new WeakMap,f(zu,Bu),f(zu,Fu,{digits:["零","一","二","三","四","五","六","七","八","九"],markers:["","十","百","千"],informal:!0}),f(zu,Ru,{digits:["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],markers:["","拾","佰","仟"],informal:!1}),f(zu,Ou,{digits:["零","一","二","三","四","五","六","七","八","九"],markers:["","十","百","千"],informal:!0}),f(zu,Lu,{digits:["零","壹","貳","參","肆","伍","陸","柒","捌","玖"],markers:["","拾","佰","仟"],informal:!1}),h(zu,"NAMES",new Set(["simp-chinese-informal","simp-chinese-formal","trad-chinese-informal","trad-chinese-formal","cjk-ideographic"])),f(zu,_u,null);var Vu,Uu,Hu,$u,ju,Wu,Gu,qu=zu,Xu=class e extends yu{constructor(t){var i;super(t,m(i=e,Uu,Hu).call(i))}_getAutoRange(){return[{lower:1,upper:1/0}]}_usesNegativeSign(e){return!1}_generateInitialRepresentation(t){if(t<1)return null;if(1===t)return p(e,ju)[1];let i=[],n=t;for(;n>0;)i.push(n%100),n=Math.floor(n/100);let r=i.length,o="";for(let t=r-1;t>=0;t--){let n=i[t],s=t%2==1;if(!(0===n||t===r-1&&1===n||s&&1===n)){let t=Math.floor(n/10),i=n%10;o+=p(e,$u)[t]+p(e,ju)[i]}s?0!==n&&(o+=p(e,Wu)):0!==t&&(o+=p(e,Gu))}return o}};Vu=new WeakMap,Uu=new WeakSet,Hu=function(){var e;return null!=(e=p(Xu,Vu))?e:g(Xu,Vu,{range:new Cd(new oi([new ei(1),Zt("infinite")]),0),suffix:new Cd(new Xt("/ "),0)})},$u=new WeakMap,ju=new WeakMap,Wu=new WeakMap,Gu=new WeakMap,f(Xu,Uu),f(Xu,Vu,null),f(Xu,$u,["","፲","፳","፴","፵","፶","፷","፸","፹","፺"]),f(Xu,ju,["","፩","፪","፫","፬","፭","፮","፯","፰","፱"]),f(Xu,Wu,"፻"),f(Xu,Gu,"፼");var Yu,Ku,Zu=Xu,Ju=class{constructor(){f(this,Yu),f(this,Ku,new Map),g(this,Yu,new Map),p(this,Yu).set("none",yu.createNone(p(this,Yu))),p(this,Yu).set("decimal",yu.createDecimal(p(this,Yu))),p(this,Yu).set("disc",yu.createDisc(p(this,Yu))),p(this,Yu).set("square",yu.createSquare(p(this,Yu))),p(this,Yu).set("circle",yu.createCircle(p(this,Yu))),p(this,Yu).set("disclosure-open",yu.createDisclosureOpen(p(this,Yu))),p(this,Yu).set("disclosure-closed",yu.createDisclosureClosed(p(this,Yu)));for(let e of yu.CHINESE_LONGHAND_NAMES)p(this,Yu).set(e,yu.createChineseLonghand(p(this,Yu),e));p(this,Yu).set("ethiopic-numeric",yu.createEthiopicNumeric(p(this,Yu)))}define(e,t,i){if(!function(e){return!("none"===e.toLowerCase()||mh.has(e))}(e))return null;let n=yu.create(p(this,Yu),t),r=i&&p(this,Ku).get(e);return r&&Sd(i,r)<0||(i?p(this,Ku).set(e,i):p(this,Ku).delete(e),p(this,Yu).set(e,n)),n}getStyle(e){var t;return null!=(t=p(this,Yu).get(e))?t:null}format(e,t){var i;return(null!=(i=this.getStyle(e))?i:Mh(p(this,Yu))).format(t)}formatMarker(e,t){var i;return(null!=(i=this.getStyle(e))?i:Mh(p(this,Yu))).formatMarker(t)}};Yu=new WeakMap,Ku=new WeakMap;var Qu=class{constructor(e){h(this,"validator",e),h(this,"success",null),h(this,"failure",null),h(this,"code",0)}isSpecial(){return 0!=this.code}markAsStartGroup(){this.code=-1}isStartGroup(){return-1==this.code}markAsEndGroup(){this.code=-2}isEndGroup(){return-2==this.code}markAsStartAlternate(e){this.code=2*e+1}isStartAlternate(){return this.code>0&&this.code%2!=0}markAsEndAlternate(e){this.code=2*e+2}isEndAlternate(){return this.code>0&&this.code%2==0}getAlternate(){return Math.floor((this.code-1)/2)}},ec=class{constructor(e,t){h(this,"where",e),h(this,"success",t),h(this,"what",-1)}},tc=class e{constructor(){h(this,"nodes",[]),h(this,"connections",[]),h(this,"match",[]),h(this,"nomatch",[]),h(this,"error",[]),h(this,"emptyHead",!0)}connect(e,t){for(let i=0;i<e.length;i++)this.connections[e[i]].what=t;e.splice(0,e.length)}clone(){let t=new e;for(let e=0;e<this.nodes.length;e++){let i=this.nodes[e],n=new Qu(i.validator);n.code=i.code,t.nodes.push(n)}for(let e=0;e<this.connections.length;e++){let i=this.connections[e],n=new ec(i.where,i.success);n.what=i.what,t.connections.push(n)}return t.match.push(...this.match),t.nomatch.push(...this.nomatch),t.error.push(...this.error),t}addSpecialToArr(e,t,i){let n=this.nodes.length,r=new Qu(Ec);i>=0?t?r.markAsStartAlternate(i):r.markAsEndAlternate(i):t?r.markAsStartGroup():r.markAsEndGroup(),this.nodes.push(r),this.connect(e,n);let o=new ec(n,!0),s=new ec(n,!1);e.push(this.connections.length),this.connections.push(s),e.push(this.connections.length),this.connections.push(o)}endSpecialGroup(){let e=[this.match,this.nomatch,this.error];for(let t=0;t<e.length;t++)this.addSpecialToArr(e[t],!1,-1)}startSpecialGroup(){if(this.nodes.length)throw new Error("invalid call");this.addSpecialToArr(this.match,!0,-1)}endClause(e){this.addSpecialToArr(this.match,!1,e)}startClause(e){if(this.nodes.length)throw new Error("invalid call");let t=new Qu(Ec);t.markAsStartAlternate(e),this.nodes.push(t);let i=new ec(0,!0),n=new ec(0,!1);this.nomatch.push(this.connections.length),this.connections.push(n),this.match.push(this.connections.length),this.connections.push(i)}addPrimitive(e){let t=this.nodes.length;this.nodes.push(new Qu(e));let i=new ec(t,!0),n=new ec(t,!1);this.connect(this.match,t),this.emptyHead?(this.nomatch.push(this.connections.length),this.emptyHead=!1):this.error.push(this.connections.length),this.connections.push(n),this.match.push(this.connections.length),this.connections.push(i)}isSimple(){return 1==this.nodes.length&&!this.nodes[0].isSpecial()}isPrimitive(){return this.isSimple()&&this.nodes[0].validator instanceof cc}addGroup(e,t){if(0==e.nodes.length)return;let i=this.nodes.length;if(4==t&&1==i&&e.isPrimitive()&&this.isPrimitive())return void(this.nodes[0].validator=this.nodes[0].validator.combine(e.nodes[0].validator));for(let t=0;t<e.nodes.length;t++)this.nodes.push(e.nodes[t]);4==t?(this.emptyHead=!0,this.connect(this.nomatch,i)):this.connect(this.match,i);let n=this.connections.length;for(let t=0;t<e.connections.length;t++){let n=e.connections[t];n.where+=i,n.what>=0&&(n.what+=i),this.connections.push(n)}for(let t=0;t<e.match.length;t++)this.match.push(e.match[t]+n);if(3==t&&this.connect(this.match,i),2==t||3==t)for(let t=0;t<e.nomatch.length;t++)this.match.push(e.nomatch[t]+n);else if(this.emptyHead){for(let t=0;t<e.nomatch.length;t++)this.nomatch.push(e.nomatch[t]+n);this.emptyHead=e.emptyHead}else for(let t=0;t<e.nomatch.length;t++)this.error.push(e.nomatch[t]+n);for(let t=0;t<e.error.length;t++)this.error.push(e.error[t]+n);e.nodes=null,e.connections=null}finish(e,t){let i=this.nodes.length;this.nodes.push(e),this.nodes.push(t),this.connect(this.match,i),this.connect(this.nomatch,i+1),this.connect(this.error,i+1);for(let e of this.connections)e.success?this.nodes[e.where].success=this.nodes[e.what]:this.nodes[e.where].failure=this.nodes[e.what];for(let e=0;e<i;e++)if(null==this.nodes[e].failure||null==this.nodes[e].success)throw new Error("Invalid validator state");return this.nodes[0]}},ic=16,nc=32,rc=64,oc=128,sc=256,ac=512,lc=1024,hc=8192,uc=class extends Ut{constructor(){super()}validateForShorthand(e,t){let i=e[t].visit(this);return i?[i]:null}},cc=class e extends uc{constructor(e,t,i){super(),h(this,"allowed",e),h(this,"idents",t),h(this,"units",i)}visitEmpty(e){return 1&this.allowed?e:null}visitSlash(e){return 2048&this.allowed?e:null}visitStr(e){return 2&this.allowed?e:null}visitIdent(e){return this.idents[e.name.toLowerCase()]||(4&this.allowed||this.allowed&rc&&CSS.supports("color",e.name)?e:null)}visitNumeric(e){return 0!=e.num||this.allowed&ac?e.num<0&&!(this.allowed&sc)?null:this.units[e.unit]?e:null:"%"==e.unit&&this.allowed&lc?e:null}visitNum(e){return 0==e.num?this.allowed&ac?e:null:e.num<=0&&!(this.allowed&sc)?null:this.allowed&ic?e:null}visitInt(e){if(0==e.num)return this.allowed&ac?e:null;if(e.num<=0&&!(this.allowed&sc))return null;if(48&this.allowed)return e;return this.idents[`${e.num}`]||null}visitHexColor(e){return this.allowed&rc&&/^([0-9A-F]{3,4}|([0-9A-F]{2}){3,4})$/i.test(e.hex)?e:null}visitURL(e){return this.allowed&oc?e:null}visitURange(e){return 4096&this.allowed?e:null}visitSpaceList(e){return null}visitCommaList(e){return null}visitFunc(e){if("attr"===e.name.toLowerCase()){let t=Sc(e);if(t&&function(e,t,i){switch(e.kind){case"string":return!!(2&t);case"url":return!!(8320&t);case"unit":return Cc(i,e.unit);case"syntax":switch(e.syntax){case"<string>":return!!(2&t);case"<url>":return!!(8320&t);case"<color>":return!!(t&rc);case"<integer>":case"<number>":return!!(816&t);case"<length>":return kc(i,mc);case"<length-percentage>":return kc(i,vc);case"<percentage>":return kc(i,gc);case"<angle>":return kc(i,yc);case"<time>":return kc(i,bc);case"<frequency>":return kc(i,wc);default:return!1}}return!1}(t.type,this.allowed,this.units))return e}if(this.allowed&rc){if("device-cmyk"===e.name||"cmyk"===e.name)return CSS.supports("color","color(srgb 0 0 0)")&&null!==_i(e)?e:null;if(CSS.supports("color",e.toString()))return e}if(this.allowed&hc){let t=e.visit(new Wi);if(CSS.supports("background-image",t.toString()))return e}return"calc"===e.name&&1848&this.allowed?e:null}visitExpr(e){return 2046&this.allowed?e:null}combine(t){let i={},n={};for(let e in this.idents)i[e]=this.idents[e];for(let e in t.idents)i[e]=t.idents[e];for(let e in this.units)n[e]=this.units[e];for(let e in t.units)n[e]=t.units[e];return new e(this.allowed|t.allowed,i,n)}},dc=Object.create(null),pc=1800;function fc(e){let t=Object.create(null);for(let i of e)t[i]=Wt;return t}var gc=fc(["%"]),mc=fc(["em","ex","ch","rem","lh","rlh","vw","vh","vi","vb","vmin","vmax","pvw","pvh","pvi","pvb","pvmin","pvmax","cm","mm","in","px","pt","pc","q"]),vc={...mc,...gc},yc=fc(["deg","grad","rad","turn"]),bc=fc(["s","ms"]),wc=fc(["hz","khz"]);function xc(e){return e.toLowerCase()}function Sc(e){var t;if("attr"!==e.name.toLowerCase()||e.values.length<1||e.values.length>2)return null;let i,n={kind:"string"},r=e.values[0];if(r instanceof Kt)i=r.name;else{if(!(r instanceof oi))return null;{let e=r.values;if(e.length<1||e.length>2||!(e[0]instanceof Kt)||(i=e[0].name,2===e.length&&(n=function(e){if(e instanceof Kt)switch(e.name.toLowerCase()){case"string":case"raw-string":return{kind:"string"};case"url":return{kind:"url"};case"color":case"integer":case"number":case"length":case"angle":case"time":case"frequency":return{kind:"syntax",syntax:`<${e.name.toLowerCase()}>`};default:return{kind:"unit",unit:xc(e.name)}}if(e instanceof ai&&"type"===e.name.toLowerCase()){if(1!==e.values.length)return null;let t=function(e){return e.replace(/\s+/g,"").toLowerCase()}(e.values[0].stringValue());return t?{kind:"syntax",syntax:t}:null}return null}(e[1]),!n)))return null}}return{attributeName:i,type:n,fallback:null!=(t=e.values[1])?t:null}}function Cc(e,t){return!!e[xc(t)]}function kc(e,t){return Object.keys(t).some(t=>Cc(e,t))}function Pc(e){switch(e.kind){case"string":case"url":return null;case"unit":return new cc(pc,dc,{[xc(e.unit)]:Wt});case"syntax":switch(e.syntax){case"<color>":return new cc(rc,dc,dc);case"<integer>":return new cc(800,dc,dc);case"<number>":return new cc(784,dc,dc);case"<length>":return new cc(pc,dc,mc);case"<length-percentage>":return new cc(pc,dc,vc);case"<percentage>":return new cc(pc,dc,gc);case"<angle>":return new cc(pc,dc,yc);case"<time>":return new cc(pc,dc,bc);case"<frequency>":return new cc(pc,dc,wc);default:return null}}return null}var Ec=new cc(0,dc,dc),Nc=class extends uc{constructor(e){super(),h(this,"successTerminal"),h(this,"failureTerminal"),h(this,"first"),this.successTerminal=new Qu(null),this.failureTerminal=new Qu(null),this.first=e.finish(this.successTerminal,this.failureTerminal)}validateList(e,t,i){let n=t?[]:e,r=this.first,o=i,s=null,a=null;for(;r!==this.successTerminal&&r!==this.failureTerminal;){if(o>=e.length){r=r.failure;continue}let l=e[o],h=l;if(r.isSpecial()){let e=!0;r.isStartGroup()?(s?s.push(a):s=[a],a=[]):r.isEndGroup()?a=s.length>0?s.pop():null:r.isEndAlternate()?a[r.getAlternate()]="taken":e=null==a[r.getAlternate()],r=e?r.success:r.failure}else{if(0==o&&!t&&r.validator instanceof Tc&&this instanceof Tc){if(h=new oi(e).visit(r.validator),h){o=e.length,r=r.success;continue}}else if(0==o&&!t&&r.validator instanceof Ic&&this instanceof Tc){if(h=new si(e).visit(r.validator),h){o=e.length,r=r.success;continue}}else h=l.visit(r.validator);if(!h){r=r.failure;continue}if(h!==l&&e===n){n=[];for(let t=0;t<o;t++)n[t]=e[t]}e!==n&&(n[o-i]=h),o++,r=r.success}}return r===this.successTerminal&&(t?n.length>0:o==e.length)?n:null}validateSingle(e){let t=this.validateList([e],!1,0);return t?t[0]:null}visitEmpty(e){return this.validateSingle(e)}visitSlash(e){return this.validateSingle(e)}visitStr(e){return this.validateSingle(e)}visitIdent(e){return this.validateSingle(e)}visitNumeric(e){return this.validateSingle(e)}visitNum(e){return this.validateSingle(e)}visitInt(e){return this.validateSingle(e)}visitHexColor(e){return this.validateSingle(e)}visitURL(e){return this.validateSingle(e)}visitURange(e){return this.validateSingle(e)}visitSpaceList(e){return null}visitCommaList(e){return null}visitFunc(e){return this.validateSingle(e)}visitExpr(e){return null}},Tc=class extends Nc{constructor(e){super(e)}visitSpaceList(e){let t=this.validateList(e.values,!1,0);return t===e.values?e:t?new oi(t):null}visitCommaList(e){let t=this.first,i=!1;for(;t;){if(t.validator instanceof Ic){i=!0;break}t=t.failure}if(i){let t=this.validateList(e.values,!1,0);return t===e.values?e:t?new si(t):null}return null}validateForShorthand(e,t){return this.validateList(e,!0,t)}},Ic=class extends Nc{constructor(e){super(e)}visitSpaceList(e){return this.validateSingle(e)}visitCommaList(e){let t=this.validateList(e.values,!1,0);return t===e.values?e:t?new si(t):null}validateForShorthand(e,t){let i,n=this.first;for(;n!==this.failureTerminal;){if(i=n.validator.validateForShorthand(e,t),i)return i;n=n.failure}return null}},Ac=class extends Nc{constructor(e,t){super(t),h(this,"name",e)}validateSingle(e){return null}visitFunc(e){if(e.name.toLowerCase()!=this.name)return null;let t=this.validateList(e.values,!1,0);return t===e.values?e:t?new ai(e.name,t):null}},Fc=class extends uc{validateSingle(e){return null}visitFunc(e){let t=Sc(e);return t&&function(e){switch(e.kind){case"string":case"url":case"unit":return!0;case"syntax":return"<string>"===e.syntax||"<url>"===e.syntax||!!Pc(e)}return!1}(t.type)?e:null}},Rc=class{tryParse(e,t,i){return t}success(e,t){}},Oc=class extends Rc{constructor(e,t){super(),h(this,"name",t),h(this,"validator"),this.validator=e.validators[this.name]}tryParse(e,t,i){if(i.values[this.name])return t;let n=this.validator.validateForShorthand(e,t);if(n){let e=n.length,r=e>1?new oi(n):n[0];return this.success(r,i),t+e}return t}success(e,t){t.values[this.name]=e}},Lc=class extends Oc{constructor(e,t){super(e,t[0]),h(this,"names",t)}success(e,t){for(let i=0;i<this.names.length;i++)t.values[this.names[i]]=e}},_c=class extends Rc{constructor(e,t){super(),h(this,"nodes",e),h(this,"slash",t)}tryParse(e,t,i){let n=t;if(this.slash){if(e[t]!=qt)return n;if(++t==e.length)return n}let r=this.nodes[0].tryParse(e,t,i);if(r==t)return n;t=r;for(let n=1;n<this.nodes.length&&t<e.length&&(r=this.nodes[n].tryParse(e,t,i),r!=t);n++)t=r;return t}},Bc=class extends Ut{constructor(e,t,i){super(),h(this,"validatorSet",e),h(this,"syntax",t),h(this,"propList",i),h(this,"error",!1),h(this,"values",{})}static create(e,t,i){return new this(e,t,i)}clone(e){return new this.constructor(this.validatorSet,this.syntax,this.propList)}finish(e,t){var i,n;if(!this.error){for(let r of this.propList)t.simpleProperty(r,null!=(n=null!=(i=this.values[r])?i:this.validatorSet.defaultValues[r])?n:di.initial,e);return!0}return!1}propagateDefaultingValue(e,t,i){for(let n of this.propList)i.simpleProperty(n,e,t)}validateList(e){return this.error=!0,0}validateSingle(e){return this.validateList([e]),null}visitEmpty(e){return this.validateSingle(e)}visitStr(e){return this.validateSingle(e)}visitIdent(e){return this.validateSingle(e)}visitNumeric(e){return this.validateSingle(e)}visitNum(e){return this.validateSingle(e)}visitInt(e){return this.validateSingle(e)}visitHexColor(e){return this.validateSingle(e)}visitURL(e){return this.validateSingle(e)}visitSpaceList(e){return this.validateList(e.values),null}visitCommaList(e){return this.error=!0,null}visitFunc(e){return this.validateSingle(e)}visitExpr(e){return this.validateSingle(e)}},Mc=class extends Bc{validateList(e){let t=0,i=0;for(;t<e.length;){let n=this.syntax[i].tryParse(e,t,this);if(n>t)t=n,i=0;else if(++i==this.syntax.length){this.error=!0;break}}return t}},Dc=class extends Bc{validateList(e){if(e.length>this.syntax.length||0==e.length)return this.error=!0,0;for(let t=0;t<this.syntax.length;t++){let i=t;for(;i>=e.length;)i=1==i?0:i-2;if(this.syntax[t].tryParse(e,i,this)!=i+1)return this.error=!0,0}return e.length}createSyntaxNode(){return new Lc(this.validatorSet,this.propList)}},zc=class extends Bc{constructor(e,t,i=[]){super(e,[],i),h(this,"name",t)}clone(e){return new Vc(this.validatorSet,this.name,[...this.propList],e)}},Vc=class extends zc{constructor(e,t,i,n){super(e,t,i),h(this,"scope",n)}validateValueText(e){let t=this.validatorSet.expandBrowserShorthand(this.name,e);if(!t)return this.error=!0,!1;this.propList=t.propList,this.values={};for(let e of t.propList){let i=t.values[e];if(!i)continue;let n=ls(this.scope,new to(i,null),"");if(!n)return this.error=!0,!1;this.values[e]=n}return this.error=!1,!0}validateList(e){let t=1===e.length?e[0].toString():new oi(e).toString();return this.validateValueText(t)?e.length:0}visitCommaList(e){return this.validateValueText(e.toString()),null}},Uc=["unicode-bidi","direction","margin-block-start","margin-block-end","margin-inline-start","margin-inline-end","padding-block-start","padding-block-end","padding-inline-start","padding-inline-end","border-block-start-color","border-block-end-color","border-inline-start-color","border-inline-end-color","border-block-start-style","border-block-end-style","border-inline-start-style","border-inline-end-style","border-block-start-width","border-block-end-width","border-inline-start-width","border-inline-end-width","block-start","block-end","inline-start","inline-end","inset-block-start","inset-block-end","inset-inline-start","inset-inline-end","block-size","inline-size","max-block-size","max-inline-size","min-block-size","min-inline-size","behavior","bleed","conflicting-partitions","crop-offset","crop-marks-line-color","enabled","flow-consume","flow-from","flow-into","flow-linger","flow-options","flow-priority","font-display","font-size-adjust","font-stretch_css3","font-variant_css2","glyph-orientation-vertical","marks","min-page-height","min-page-width","repeat-on-break","required","required-partitions","ruby-align","shape-inside","snap-height","snap-width","src","template","text-decoration-skip","text-justify","text-zoom","unicode-range","utilization","wrap-flow"],Hc=class extends Mc{refreshPropList(){this.propList=this.validatorSet.getPropertiesForAll()}validateList(e){return this.error=!0,0}},$c={SIMPLE:Mc,INSETS:Dc,INSETS_SLASH:class extends Bc{validateList(e){let t=e.length;for(let i=0;i<e.length;i++)if(e[i]===qt){t=i;break}if(t>this.syntax.length||0==e.length)return this.error=!0,0;for(let i=0;i<this.syntax.length;i++){let n,r=i;for(;r>=t;)r=1==r?0:r-2;if(t+1<e.length)for(n=t+i+1;n>=e.length;)n-=n==t+2?1:2;else n=r;let o=[e[r],e[n]];if(2!=this.syntax[i].tryParse(o,0,this))return this.error=!0,0}return e.length}},COMMA:class extends Mc{mergeIn(e,t){var i,n;for(let r of this.propList){let o=null!=(n=null!=(i=t[r])?i:this.validatorSet.defaultValues[r])?n:di.initial,s=e[r];s||(s=[],e[r]=s),s.push(o)}}visitCommaList(e){let t={};for(let i=0;i<e.values.length;i++)if(this.values={},e.values[i]instanceof si?this.error=!0:(e.values[i].visit(this),this.mergeIn(t,this.values),this.values["background-color"]&&i!=e.values.length-1&&(this.error=!0)),this.error)return null;this.values={};for(let e in t)this.values[e]="background-color"==e?t[e].pop():new si(t[e]);return null}},FONT:class e extends Mc{static create(t,i,n){return new e(t,i,[...n,"font-family","line-height","font-size","font-stretch","font-variant-ligatures","font-variant-caps","font-variant-numeric","font-variant-east-asian"])}validateList(e){let t=super.validateList(e),i=this.values["font-variant_css2"];i&&(delete this.values["font-variant_css2"],this.values["font-variant-caps"]=i);let n=this.values["font-stretch_css3"];if(n&&(delete this.values["font-stretch_css3"],this.values["font-stretch"]=n),t+2>e.length)return this.error=!0,t;this.error=!1;let r=this.validatorSet.validators;if(!e[t].visit(r["font-size"])){let i=this.values["font-weight"],n=i instanceof ai&&"calc"===i.name?e.indexOf(i):-1;if(!(n>=0&&e[n].visit(r["font-size"])))return this.error=!0,t;delete this.values["font-weight"],t=n}if(this.values["font-size"]=e[t++],e[t]===qt){if(t++,t+2>e.length)return this.error=!0,t;if(!e[t].visit(r["line-height"]))return this.error=!0,t;this.values["line-height"]=e[t++]}let o=t==e.length-1?e[t]:new oi(e.slice(t,e.length));return o.visit(r["font-family"])?(this.values["font-family"]=o,e.length):(this.error=!0,t)}visitCommaList(e){if(e.values[0].visit(this),this.error)return null;let t=[this.values["font-family"]];for(let i=1;i<e.values.length;i++)t.push(e.values[i]);let i=new si(t);return i.visit(this.validatorSet.validators["font-family"])?this.values["font-family"]=i:this.error=!0,null}visitIdent(e){let t=this.validatorSet.systemFonts[e.name];if(t)for(let e in t)this.values[e]=t[e];else this.error=!0;return null}},TEXT_SPACING:class extends Mc{validateList(e){if(1===e.length&&e[0]instanceof Kt)switch(e[0].name.toLowerCase()){case"normal":e=[this.validatorSet.defaultValues["text-autospace"],this.validatorSet.defaultValues["text-spacing-trim"]];break;case"auto":e=[di.auto,di.auto];break;case"none":e=[Zt("no-autospace"),Zt("space-all")]}return super.validateList(e)}},ALL:Hc},jc=["initial-letter"],Wc=class{constructor(){h(this,"validators",{}),h(this,"prefixes",{}),h(this,"defaultValues",{}),h(this,"namedValidators",{}),h(this,"systemFonts",{}),h(this,"shorthands",{}),h(this,"layoutProps",{}),h(this,"backgroundProps",{}),h(this,"browserShorthandStyle",null),h(this,"browserShorthandMisses",{}),h(this,"browserPropertyNamesForAll",null),h(this,"allPropertyNames",null)}invalidateAllPropertyNames(){this.allPropertyNames=null}getBrowserPropertyNamesForAll(){if(this.browserPropertyNamesForAll)return this.browserPropertyNamesForAll;if("undefined"==typeof document||"function"!=typeof getComputedStyle)return null;let e=document.documentElement;if(!e)return null;let t=getComputedStyle(e),i=[];for(let e=0;e<t.length;e++){let n=t.item(e);!n||Si(n)||Uc.includes(n)||i.push(n)}return this.browserPropertyNamesForAll=i,this.browserPropertyNamesForAll}getPropertiesForAll(){if(this.allPropertyNames)return this.allPropertyNames;let e=new Set;for(let t in this.validators)Uc.includes(t)||e.add(t);let t=this.getBrowserPropertyNamesForAll();if(t)for(let i of t)this.shorthands[i]||e.add(i);let i=Array.from(e);return t&&(this.allPropertyNames=i),i}getBrowserShorthandStyle(){return null!==this.browserShorthandStyle?this.browserShorthandStyle:"undefined"==typeof document?null:(this.browserShorthandStyle=document.createElement("div").style,this.browserShorthandStyle)}expandBrowserShorthand(e,t){let i=this.getBrowserShorthandStyle();if(!i)return null;i.cssText="",i.setProperty(e,t);let n=Array.from({length:i.length},(e,t)=>i.item(t)).filter(e=>!!e);if(!n.length||1===n.length&&n[0]===e.toLowerCase())return null;let r={};for(let e of n)r[e]=i.getPropertyValue(e);return{propList:n,values:r}}getShorthand(e,t){if(Si(e))return null;e=e.toLowerCase();let i=this.shorthands[e];if(i)return i instanceof Hc&&!this.allPropertyNames&&i.refreshPropList(),i;if(this.validators[e]||this.browserShorthandMisses[e]||null==t)return null;let n=this.expandBrowserShorthand(e,"string"==typeof t?t:t.toString());if(!n)return("string"==typeof t?!/\bvar\(/i.test(t):!qc(t))&&(this.browserShorthandMisses[e]=!0),null;let r=new zc(this,e,n.propList);return this.shorthands[e]=r,this.invalidateAllPropertyNames(),r}addReplacement(e,t){let i;if(3==t.type)i=new Jt(t.num,t.text);else if(7==t.type)i=new ti(t.text);else{if(1!=t.type)throw new Error("unexpected replacement");i=Zt(t.text)}if(e.isPrimitive()){let t=e.nodes[0].validator.idents;for(let e in t)t[e]=i;return e}throw new Error("unexpected replacement")}newGroup(e,t){let i=new tc;if("||"==e){for(let e=0;e<t.length;e++){let n=new tc;n.startClause(e),n.addGroup(t[e],1),n.endClause(e),i.addGroup(n,0==e?1:4)}let e=new tc;return e.startSpecialGroup(),e.addGroup(i,3),e.endSpecialGroup(),e}{let n;switch(e){case" ":n=1;break;case"|":case"||":n=4;break;default:throw new Error("unexpected op")}for(let e=0;e<t.length;e++)i.addGroup(t[e],0==e?1:n);return i}}addCounts(e,t,i){let n=new tc;for(let i=0;i<t;i++)n.addGroup(e.clone(),1);if(i==Number.POSITIVE_INFINITY)n.addGroup(e,3);else for(let r=t;r<i;r++)n.addGroup(e.clone(),2);return n}primitive(e){let t=new tc;return t.addPrimitive(e),t}newFunc(e,t){let i;switch(e){case"COMMA":i=new Ic(t);break;case"SPACE":i=new Tc(t);break;case"attr":i=new Fc;break;default:i=new Ac(e.toLowerCase(),t)}return this.primitive(i)}initBuiltInValidators(){this.namedValidators.COLOR=this.primitive(new cc(rc,dc,dc)),this.namedValidators.ATTR=this.primitive(new Fc),this.namedValidators.IMAGE_FUNCTION=this.primitive(new cc(hc,dc,dc)),this.namedValidators.POS_INT=this.primitive(new cc(nc,dc,dc)),this.namedValidators.POS_NUM=this.primitive(new cc(ic,dc,dc)),this.namedValidators.POS_PERCENTAGE=this.primitive(new cc(8,dc,gc)),this.namedValidators.NEGATIVE=this.primitive(new cc(sc,dc,dc)),this.namedValidators.ZERO=this.primitive(new cc(ac,dc,dc)),this.namedValidators.ZERO_PERCENTAGE=this.primitive(new cc(lc,dc,dc)),this.namedValidators.POS_LENGTH=this.primitive(new cc(8,dc,mc)),this.namedValidators.POS_ANGLE=this.primitive(new cc(8,dc,yc)),this.namedValidators.POS_TIME=this.primitive(new cc(8,dc,bc)),this.namedValidators.FREQUENCY=this.primitive(new cc(8,dc,wc)),this.namedValidators.RESOLUTION=this.primitive(new cc(8,dc,{dpi:Wt,dpcm:Wt,dppx:Wt})),this.namedValidators.URI=this.primitive(new cc(oc,dc,dc)),this.namedValidators.URANGE=this.primitive(new cc(4096,dc,dc)),this.namedValidators.IDENT=this.primitive(new cc(4,dc,dc)),this.namedValidators.STRING=this.primitive(new cc(2,dc,dc)),this.namedValidators.SLASH=this.primitive(new cc(2048,dc,dc));let e={"font-family":Zt("sans-serif")};this.systemFonts.caption=e,this.systemFonts.icon=e,this.systemFonts.menu=e,this.systemFonts["message-box"]=e,this.systemFonts["small-caption"]=e,this.systemFonts["status-bar"]=e}isBuiltIn(e){return!!e.match(/^[A-Z_0-9]+$/)}readNameAndPrefixes(e,t){let i=e.token();if(0==i.type)return null;let n={"":!0};if(14==i.type){do{if(e.consume(),i=e.token(),1!=i.type)throw new Error("Prefix name expected");n[i.text]=!0,e.consume(),i=e.token()}while(16==i.type);if(15!=i.type)throw new Error("']' expected");e.consume(),i=e.token()}if(1!=i.type)throw new Error("Property name expected");if(2==t?"SHORTHANDS"==i.text:"DEFAULTS"==i.text)return e.consume(),null;let r=i.text;if(e.consume(),2!=t){if(39!=e.token().type)throw new Error("'=' expected");this.isBuiltIn(r)||(this.prefixes[r]=n)}else if(18!=e.token().type)throw new Error("':' expected");return r}parseValidators(e){for(;;){let t=this.readNameAndPrefixes(e,1);if(!t)return;let i,n=[],r=[],o="",s=!0,a=()=>{if(0==n.length)throw new Error("No values");return 1==n.length?n[0]:this.newGroup(o,n)},l=e=>{if(s)throw new Error(`'${e}': unexpected`);if(o&&o!=e)throw new Error(`mixed operators: '${e}' and '${o}'`);o=e,s=!0},h=null;for(;!h;){e.consume();let t=e.token();switch(t.type){case 1:if(s||l(" "),this.isBuiltIn(t.text)){let e=this.namedValidators[t.text];if(!e)throw new Error(`'${t.text}' unexpected`);n.push(e.clone())}else{let e={};e[t.text.toLowerCase()]=Zt(t.text),n.push(this.primitive(new cc(0,e,dc)))}s=!1;break;case 5:{let e={};e[`${t.num}`]=new ei(t.num),n.push(this.primitive(new cc(0,e,dc))),s=!1;break}case 34:l("|");break;case 25:l("||");break;case 14:s||l(" "),r.push({vals:n,op:o,b:"["}),o="",n=[],s=!0;break;case 6:s||l(" "),r.push({vals:n,op:o,b:"(",fn:t.text}),o="",n=[],s=!0;break;case 15:{i=a();let e=r.pop();if("["!=e.b)throw new Error("']' unexpected");n=e.vals,n.push(i),o=e.op,s=!1;break}case 11:{i=a();let e=r.pop();if("("!=e.b)throw new Error("')' unexpected");n=e.vals,n.push(this.newFunc(e.fn,i)),o=e.op,s=!1;break}case 18:if(s)throw new Error("':' unexpected");e.consume(),n.push(this.addReplacement(n.pop(),e.token()));break;case 22:if(s)throw new Error("'?' unexpected");n.push(this.addCounts(n.pop(),0,1));break;case 36:if(s)throw new Error("'*' unexpected");n.push(this.addCounts(n.pop(),0,Number.POSITIVE_INFINITY));break;case 23:if(s)throw new Error("'+' unexpected");n.push(this.addCounts(n.pop(),1,Number.POSITIVE_INFINITY));break;case 12:{if(e.consume(),t=e.token(),5!=t.type)throw new Error("<int> expected");let i=t.num,r=i;if(e.consume(),t=e.token(),16==t.type){if(e.consume(),t=e.token(),5!=t.type)throw new Error("<int> expected");r=t.num,e.consume(),t=e.token()}if(13!=t.type)throw new Error("'}' expected");n.push(this.addCounts(n.pop(),i,r));break}case 17:if(h=a(),r.length>0)throw new Error(`unclosed '${r.pop().b}'`);break;default:throw new Error("unexpected token")}}e.consume(),this.isBuiltIn(t)?this.namedValidators[t]=h:h.isSimple()?this.validators[t]=h.nodes[0].validator:this.validators[t]=new Tc(h)}}parseDefaults(e){for(;;){let t=this.readNameAndPrefixes(e,2);if(!t)return;let i=[];for(;;){e.consume();let t=e.token();if(17==t.type){e.consume();break}switch(t.type){case 1:i.push(Zt(t.text));break;case 4:i.push(new Qt(t.num));break;case 5:i.push(new ei(t.num));break;case 3:i.push(new Jt(t.num,t.text));break;default:throw new Error("unexpected token")}}this.defaultValues[t]=i.length>1?new oi(i):i[0]}}parseShorthands(e){for(;;){let t=this.readNameAndPrefixes(e,3);if(!t)return;let i,n=e.nthToken(1);1==n.type&&$c[n.text]?(i=$c[n.text],e.consume()):i=Mc;let r=!1,o=[],s=!1,a=[],l=[];for(;!r;)switch(e.consume(),n=e.token(),n.type){case 1:if(this.validators[n.text])o.push(new Oc(this,n.text)),n.text.includes("_")||l.push(n.text);else{if(!(this.shorthands[n.text]instanceof Dc))throw new Error(`'${n.text}' is neither a simple property nor an inset shorthand`);{let e=this.shorthands[n.text];o.push(e.createSyntaxNode()),l.push(...e.propList)}}break;case 19:if(o.length>0||s)throw new Error("unexpected slash");s=!0;break;case 14:a.push({slash:s,syntax:o}),o=[],s=!1;break;case 15:{let e=new _c(o,s),t=a.pop();o=t.syntax,s=t.slash,o.push(e);break}case 17:r=!0,e.consume();break;default:throw new Error("unexpected token")}let h=i.create(this,o,l);this.shorthands[t]=h,this.invalidateAllPropertyNames()}}parse(e){let t=new to(e,null);this.parseValidators(t),this.parseDefaults(t),this.parseShorthands(t),this.backgroundProps=this.makePropSet(["background"]),this.layoutProps=this.makePropSet(["margin","border","padding","columns","column-gap","column-rule","column-fill"])}makePropSet(e){var t;let i={};for(let n of e){let e=this.shorthands[n],r=e?e.propList:[n];for(let e of r)i[e]=null!=(t=this.defaultValues[e])?t:di.initial}return i}validatePropertyAndHandleShorthand(e,t,i,n,r){var o,s;let a=r.ruleType;if(Si(e)||"font-face"===a)return void r.simpleProperty(e,t,i);if("counter-style"===a)return void(_h(e,t)?r.simpleProperty(e,t,i):r.invalidPropertyValue(e,t));let l="",h=e,u=(e=e.toLowerCase()).match(/^-([a-z]+)-([-a-z0-9]+)$/);u&&(l=u[1],e=u[2]);let c=l?h:e;if(qc(t))return this.getShorthand(c,t),void r.simpleProperty(c,t,i);let d=this.prefixes[e],p=bi(t)?"unset":t.toString();if(!d||!d[l]){if(CSS.supports(h,p)){let e=null==(o=this.getShorthand(c,p))?void 0:o.clone(n);e?yi(t)?e.propagateDefaultingValue(t,i,r):(t.visit(e),e.finish(i,r)||r.invalidPropertyValue(h,t)):r.simpleProperty(h,t,i)}else l&&!me.includes(`-${l}-`)||r.unknownProperty(h,t);return}if(jc.includes(e)&&!Object.keys(d).some(t=>ye(t?`-${t}-`:"",e)))return void r.unknownProperty(h,t);let f=this.validators[e];if(f){let n=yi(t)||t.isExpr()?t:t.visit(f);n?r.simpleProperty(e,n,i):!l&&CSS.supports(e,t.toString())?r.simpleProperty(e,t,i):r.invalidPropertyValue(h,t)}else{let o=null==(s=this.getShorthand(e,t))?void 0:s.clone(n);if(!o)return void r.unknownProperty(h,t);yi(t)?o.propagateDefaultingValue(t,i,r):(t.visit(o),o.finish(i,r)||r.invalidPropertyValue(h,t))}}},Gc=class extends Ut{constructor(){super(...arguments),h(this,"varFound",!1)}visitFunc(e){return"var"===e.name?this.varFound=!0:this.varFound||this.visitValues(e.values),null}};function qc(e){let t=new Gc;return e.visit(t),t.varFound}function Xc(e,t,i){return e-=i,0===t?0===e:e%t===0&&e/t>=0}var Yc=class{constructor(e){h(this,"matchers",e)}matches(){return this.matchers.some(e=>e.matches())}},Kc=class{constructor(e){h(this,"matchers",e)}matches(){return this.matchers.every(e=>e.matches())}},Zc=class e{constructor(e,t,i){h(this,"elementOffset",e),h(this,"a",t),h(this,"b",i)}static registerFragmentIndex(t,i,n){let r=e.fragmentIndices;(!r[t]||r[t].priority<=n)&&(r[t]={fragmentIndex:i,priority:n})}static clearFragmentIndices(){e.fragmentIndices={}}matches(){let t=e.fragmentIndices[this.elementOffset];return null!=t&&null!=t.fragmentIndex&&Xc(t.fragmentIndex,this.a,this.b)}};h(Zc,"fragmentIndices",{});var Jc=Zc,Qc=class{static buildViewConditionMatcher(e,t){let i=t.split("_");return"NFS"==i[0]?new Jc(e,parseInt(i[1],10),parseInt(i[2],10)):null}static buildAllMatcher(e){return new Kc(e)}static buildAnyMatcher(e){return new Yc(e)}},ed={"border-collapse":!0,"border-spacing":!0,"caption-side":!0,"clip-rule":!0,color:!0,"color-interpolation":!0,"color-rendering":!0,cursor:!0,direction:!0,"empty-cells":!0,fill:!0,"fill-opacity":!0,"fill-rule":!0,"font-kerning":!0,"font-size":!0,"font-size-adjust":!0,"font-family":!0,"font-feature-settings":!0,"font-style":!0,"font-stretch":!0,"font-variant-ligatures":!0,"font-variant-caps":!0,"font-variant-numeric":!0,"font-variant-east-asian":!0,"font-weight":!0,"glyph-orientation-vertical":!0,"hanging-punctuation":!0,hyphens:!0,"hyphenate-character":!0,"hyphenate-limit-chars":!0,"hyphenate-limit-last":!0,"image-rendering":!0,"image-resolution":!0,"letter-spacing":!0,"line-break":!0,"line-height":!0,"list-style-image":!0,"list-style-position":!0,"list-style-type":!0,marker:!0,"marker-end":!0,"marker-mid":!0,"marker-start":!0,orphans:!0,"overflow-wrap":!0,"paint-order":!0,"pointer-events":!0,quotes:!0,"ruby-align":!0,"ruby-position":!0,"shape-rendering":!0,stroke:!0,"stroke-dasharray":!0,"stroke-dashoffset":!0,"stroke-linecap":!0,"stroke-linejoin":!0,"stroke-miterlimit":!0,"stroke-opacity":!0,"stroke-width":!0,"tab-size":!0,"text-align":!0,"text-align-last":!0,"text-anchor":!0,"text-autospace":!0,"text-decoration-skip":!0,"text-decoration-skip-ink":!0,"text-emphasis-color":!0,"text-emphasis-position":!0,"text-emphasis-style":!0,"text-fill-color":!0,"text-combine-upright":!0,"text-indent":!0,"text-justify":!0,"text-orientation":!0,"text-rendering":!0,"text-shadow":!0,"text-size-adjust":!0,"text-spacing-trim":!0,"text-stroke-color":!0,"text-stroke-width":!0,"text-transform":!0,"text-underline-offset":!0,"text-underline-position":!0,"text-wrap":!0,"text-wrap-mode":!0,"text-wrap-style":!0,visibility:!0,"white-space":!0,widows:!0,"word-break":!0,"word-spacing":!0,"writing-mode":!0},td=["image-resolution","orphans","widows"],id={"http://www.idpf.org/2007/ops":!0,"http://www.w3.org/1999/xhtml":!0,"http://www.w3.org/2000/svg":!0,"http://www.w3.org/1998/Math/MathML":!0},nd=["margin-%","padding-%","border-%-width","border-%-style","border-%-color","%"],rd=["max-%","min-%","%"],od=(()=>{let e=["left","right","top","bottom"],t={width:!0,height:!0,"max-width":!0,"max-height":!0,"min-width":!0,"min-height":!0};for(let i=0;i<nd.length;i++)for(let n=0;n<e.length;n++){t[nd[i].replace("%",e[n])]=!0}return t})();function sd(e,t){let i={};for(let t of nd)for(let n in e){let r=t.replace("%",n),o=t.replace("%",e[n]);i[r]=o,i[o]=r}for(let e of rd)for(let n in t){let r=e.replace("%",n),o=e.replace("%",t[n]);i[r]=o,i[o]=r}return i}var ad=sd({"block-start":"right","block-end":"left","inline-start":"top","inline-end":"bottom"},{"block-size":"width","inline-size":"height"}),ld=sd({"block-start":"top","block-end":"bottom","inline-start":"left","inline-end":"right"},{"block-size":"height","inline-size":"width"}),hd=sd({"block-start":"right","block-end":"left","inline-start":"bottom","inline-end":"top"},{"block-size":"width","inline-size":"height"}),ud=sd({"block-start":"top","block-end":"bottom","inline-start":"right","inline-end":"left"},{"block-size":"height","inline-size":"width"}),cd=sd({inside:"right",outside:"left"},{}),dd=sd({inside:"left",outside:"right"},{}),pd=class{constructor(e,t){h(this,"name",e),h(this,"parent",t),h(this,"order",0),h(this,"children",[])}},fd=class{constructor(){h(this,"root",new pd(null,null))}register(e,t){let i=null!=e?e:this.root;if(t)for(let e of t){let t=i.children.find(t=>t.name===e);t||(t=new pd(e,i),i.children.push(t)),i=t}else{let e=new pd(null,i);i.children.push(e),i=e}return this.renumber(),i}renumber(){let e=0,t=i=>{for(let e of i.children)t(e);i.order=e++};for(let e of this.root.children)t(e)}},gd=16777216,md=4,vd=0;function yd(){return++vd}function bd(e){switch(Math.floor(e.priority/gd)){case 0:return 0;case 1:case 6:return 1;default:return 2}}function wd(e){switch(Math.floor(e.priority/gd)){case 0:return 0;case 1:case 6:return 1;case 3:case 4:return 3;default:return 2}}function xd(e){return e.layer?e.layer.order:1/0}function Sd(e,t){let i=Math.floor(e.priority/gd),n=Math.floor(t.priority/gd);if(i!==n)return i-n;if(e.layer!==t.layer){let n=xd(e),r=xd(t);if(n!==r){let e=n>r?1:-1;return i>=md?-e:e}}return e.priority-t.priority}var Cd=class e{constructor(e,t,i=null,n=0){h(this,"value",e),h(this,"priority",t),h(this,"layer",i),h(this,"ruleId",n)}getBaseValue(){return this}withValue(t){return t===this.value?this:new e(t,this.priority,this.layer,this.ruleId)}filterValue(e){return this.withValue(this.value.visit(e))}increaseSpecificity(t){return 0==t?this:new e(this.value,this.priority+t,this.layer,this.ruleId)}evaluate(e,t,i,n){return t&&Si(t)?this.value:Vf(e,this.value,t,i,n)}isEnabled(e){return!0}},kd=class e extends Cd{constructor(e,t,i,n=null,r=0){super(e,t,n,r),h(this,"condition",i)}getBaseValue(){return new Cd(this.value,this.priority,this.layer,this.ruleId)}withValue(t){return t===this.value?this:new e(t,this.priority,this.condition,this.layer,this.ruleId)}increaseSpecificity(t){return 0==t?this:new e(this.value,this.priority+t,this.condition,this.layer,this.ruleId)}isEnabled(e){try{return!!this.condition.evaluate(e)}catch(e){R.warn(e)}return!1}};function Pd(e,t,i){return(!t||Sd(i,t)>=0)&&i.isEnabled(e)?i.getBaseValue():t}function Ed(e,t,i,n){if(!e)return;if(!i)return void delete e[t];if(n&&!i.isEnabled(n))return;!function(e,t,i){if(!Nd.has(t)||i.value===Wt)return;let n=Id.get(e);n||(n={},Id.set(e,n));let r=n[t];if(!r){r=n[t]=[];let i=e[t];i&&i.value!==Wt&&r.push(i)}r.push(i)}(e,t,i);let r=e[t];(!r||Sd(i,r)>=0)&&(e[t]=n?i.getBaseValue():i)}var Nd=new Set;function Td(e,t,i){var n;if(bi(t))return void Nd.add(e);if(!function(e){let t=new wi;return e.visit(t),t.found}(t))return;Nd.add(e);let r=null==(n=null==i?void 0:i.getShorthand(e,t))?void 0:n.propList;if(r)for(let e of r)Nd.add(e)}var Id=new WeakMap;function Ad(e,t){switch(t.value){case di.revert_rule:return e.ruleId===t.ruleId;case di.revert_layer:return wd(e)===wd(t)&&xd(e)>=xd(t);default:return bd(e)>=bd(t)}}function Fd(e,t,i){let n=i;for(;bi(t.value);){n=n.filter(e=>!Ad(e,t));let i=null;for(let e of n)(!i||Sd(e,i)>=0)&&(i=e);if(!i)return Si(e)?di.initial:t.value;t=i}return t.value}function Rd(e,t=!1){var i;if(!Nd.size)return!1;let n=Id.get(e),r=!1;for(let o in e)if(zd(o)){let i=jd(e,o);for(let e in i)Rd(i[e],t)&&(r=!0)}else if("_viewConditionalStyles"===o)for(let i of Gd(e))Rd(i.styles,t)&&(r=!0);else if(Vd(o)){let s=Hd(e,o);if(!s||!bi(s.value))continue;if(t&&Si(o)){e[o]=s.withValue(di.initial);continue}let a=Fd(o,s,null!=(i=null==n?void 0:n[o])?i:[]);e[o]=s.withValue(a),qc(a)&&(r=!0)}return t&&Id.delete(e),r}var Od={"region-id":!0,"fragment-selector-id":!0},Ld="data-viv-footnote-counter";function _d(e){let t,i=e.getAttribute(Ld);if(!i)return Object.create(null);try{t=JSON.parse(i)}catch{return Object.create(null)}if(!t||"object"!=typeof t||Array.isArray(t))return Object.create(null);let n=Object.create(null);return Object.entries(t).forEach(([e,t])=>{if(Array.isArray(t)){let i=t.filter(e=>"number"==typeof e&&isFinite(e));n[e]=i}else"number"==typeof t&&isFinite(t)&&(n[e]=[t])}),n}function Bd(e,t,i){let n=_d(e);n[t]=i,e.setAttribute(Ld,JSON.stringify(n))}function Md(e){let t=Hd(e,"content");return!!t&&Oa(t.value)}function Dd(e){return!!Od[e]}function zd(e){return"_"===e.charAt(0)&&"_viewConditionalStyles"!==e}function Vd(e){return"_"!==e.charAt(0)&&!Od[e]}function Ud(e){return!!ed[e]||Si(e)}function Hd(e,t){return e[t]}function $d(e,t,i){i?e[t]=i:delete e[t]}function jd(e,t){return e[t]}function Wd(e,t){let i=e[t];return i||(i={},e[t]=i),i}var Gd=e=>{let t=e._viewConditionalStyles;return t||(t=[],e._viewConditionalStyles=t),t};function qd(e,t){return e[t]}function Xd(e,t){let i=e[t];return i||(i=[],e[t]=i),i}function Yd(e,t,i,n,r,o,s,a){var l;if([{id:r,styleKey:"_pseudos"},{id:o,styleKey:"_regions"}].forEach(e=>{if(e.id){let i=Wd(t,e.styleKey);(t=i[e.id])||(t={},i[e.id]=t)}}),s){let e=Gd(t);t={},e.push({styles:t,matcher:s})}for(let r in i)if(!zd(r))if(Dd(r)){let e=qd(i,r),n=Xd(t,r);Array.prototype.push.apply(n,e)}else{let o=Hd(i,r);if(!o.isEnabled(e))continue;let s=o.increaseSpecificity(n);Ed(t,r,s,e);let h=null==(l=null==a?void 0:a.getShorthand(r,s.value))?void 0:l.propList;if(h)for(let i of h){let n=s.withValue(Wt);Ed(t,i,n,e)}}}function Kd(e,t){if(e.length>0){e.sort((e,t)=>t.getPriority()-e.getPriority());for(let i=e.length-1;i>=0;i--)t=e[i].wire(t)}return t}var Zd=class extends Ht{constructor(e,t){super(),h(this,"props",e),h(this,"context",t),h(this,"propName","")}setPropName(e){this.propName=e}getFontSize(){let e=Hd(this.props,"font-size");if(!e.value.isNumeric())return Ke.em;let t=e.value;if(!function(e){switch(null==e?void 0:e.toLowerCase()){case"px":case"in":case"pt":case"pc":case"cm":case"mm":case"q":return!0;default:return!1}}(t.unit))throw new Error("Unexpected state");return t.num*Ke[t.unit]}visitNumeric(e){return"font-size"===this.propName?Qd(e,this.getFontSize(),this.context):"em"===e.unit||"rem"===e.unit||"lh"===e.unit||"rlh"===e.unit?Jd(e,this.getFontSize(),this.context):e}visitExpr(e){return"font-size"==this.propName?Vf(this.context,e,this.propName).visit(this):e}};function Jd(e,t,i){let n=e.unit,r=e.num;return"em"===n?new Jt(r*t,"px"):"rem"===n?new Jt(r*i.fontSize(),"px"):"rlh"===n?new Jt(r*i.rootLineHeight,"px"):e}function Qd(e,t,i){let n=(e=Jd(e,null!=t?t:0,i)).unit,r=e.num;return"px"===n?e:new Jt("%"===n?r/100*(null!=t?t:0):r*i.queryUnitSize(n,!1),"px")}var ep=class{constructor(e,t,i,n){h(this,"instance",e),h(this,"currentStyle",t),h(this,"currentClassNames",i),h(this,"currentEpubTypes",n)}},tp=class extends ep{constructor(e,t,i,n,r){super(e,t,i,n),h(this,"currentElement",r)}},ip=class{apply(e){}mergeWith(e){return new rp([this,e])}clone(){return this}},np=class extends ip{constructor(e){super(),h(this,"conditionItem",e)}apply(e){e.instance.pushConditionItem(this.conditionItem.fresh(e.instance))}},rp=class e extends ip{constructor(e){super(),h(this,"list",e)}apply(e){for(let t=0;t<this.list.length;t++)this.list[t].apply(e)}mergeWith(e){return this.list.push(e),this}clone(){return new e([].concat(this.list))}},op=class extends ip{constructor(e,t,i,n,r){super(),h(this,"style",e),h(this,"specificity",t),h(this,"pseudoelement",i),h(this,"regionId",n),h(this,"viewConditionId",r)}apply(e){Yd(e.instance.context,e.currentStyle,this.style,this.specificity,this.pseudoelement,this.regionId,e.instance.buildViewConditionMatcher(this.viewConditionId),e.instance.mergeValidatorSet)}},sp=class{getPriority(){return 0}primarySlot(e){return null}wire(e){return new lp(this,e)}},ap=class extends ip{constructor(e,t){super(),h(this,"condition",e),h(this,"chained",t)}makePrimary(e){let t=this.condition.primarySlot(e);return!!t&&(e.insertInTable(t.table,t.key,this.chained),!0)}},lp=class extends ap{apply(e){this.condition.matches(e)&&this.chained.apply(e)}},hp=class extends ap{apply(e){if(this.condition.matches(e)){e.instance.dependentConditions.push(this.condition.condition);try{this.chained.apply(e)}finally{e.instance.dependentConditions.pop()}}}},up=class extends sp{constructor(e){super(),h(this,"className",e)}matches(e){return e.currentClassNames.includes(this.className)}getPriority(){return 10}primarySlot(e){return{table:e.classes,key:this.className}}},cp=class extends sp{constructor(e){super(),h(this,"id",e)}matches(e){return e.instance.currentId==this.id||e.instance.currentXmlId==this.id}getPriority(){return 11}primarySlot(e){return{table:e.ids,key:this.id}}},dp=class extends sp{constructor(e){super(),h(this,"localName",e)}matches(e){return e.instance.currentLocalName==this.localName}getPriority(){return 8}primarySlot(e){return{table:e.tags,key:this.localName}}},pp=class extends sp{constructor(e,t){super(),h(this,"ns",e),h(this,"localName",t)}matches(e){return e.instance.currentLocalName==this.localName&&e.instance.currentNamespace==this.ns}getPriority(){return 8}primarySlot(e){let t=e.nsPrefix[this.ns];return t||(t=`ns${e.nsCount++}:`,e.nsPrefix[this.ns]=t),{table:e.nstags,key:t+this.localName}}},fp=class extends sp{constructor(e,t,i=!1){super(),h(this,"epubTypePatt",e),h(this,"targetLocalName",t),h(this,"useRoleAttr",i)}matches(e){let t=e.currentElement;if(t instanceof HTMLAnchorElement&&t.hash&&t.href==t.baseURI.replace(/#.*$/,"")+t.hash){let e=t.hash.substring(1),i=t.ownerDocument.getElementById(e);if(i&&(!this.targetLocalName||i.localName==this.targetLocalName)){let e=this.useRoleAttr?i.getAttribute("role"):i.getAttributeNS("http://www.idpf.org/2007/ops","type")||i.getAttribute("epub:type");if(e&&e.match(this.epubTypePatt))return!0}}return!1}},gp=class extends sp{constructor(e){super(),h(this,"ns",e)}matches(e){return e.instance.currentNamespace==this.ns}};function mp(e,t,i,n){var r;if(!e)return!1;let o="text/html"===(null==(r=e.ownerDocument)?void 0:r.contentType),s=o?vp(i):i;if(null!==t){let i=e.getAttributeNodeNS(t||null,s);return!!i&&n(i)}for(let t of Array.from(e.attributes))if((o?vp(t.localName):t.localName)===s&&n(t))return!0;return!1}function vp(e){return e.replace(/[A-Z]/g,e=>e.toLowerCase())}function yp(e){return"i"===e}function bp(e,t){return Array.from(e,e=>{let i=Re(e);if(!yp(t))return i;let n=vp(e),r=n.toUpperCase();return n!==r&&/^[a-z]$/i.test(e)?`[${n}${r}]`:i}).join("")}function wp(e){return new RegExp(e)}var xp=class extends sp{constructor(e,t){super(),h(this,"ns",e),h(this,"name",t)}matches(e){return mp(e.currentElement,this.ns,this.name,()=>!0)}},Sp=class extends sp{constructor(e,t,i,n=null){super(),h(this,"ns",e),h(this,"name",t),h(this,"value",i),h(this,"caseSensitivity",n)}matches(e){return mp(e.currentElement,this.ns,this.name,e=>function(e,t,i){return yp(i)?vp(e)===vp(t):e===t}(e.value,this.value,this.caseSensitivity))}getPriority(){return"type"==this.name&&"http://www.idpf.org/2007/ops"==this.ns?9:0}primarySlot(e){return"type"==this.name&&"http://www.idpf.org/2007/ops"==this.ns?{table:e.epubtypes,key:this.value}:null}},Cp=class extends sp{constructor(e,t){super(),h(this,"ns",e),h(this,"name",t)}matches(e){return mp(e.currentElement,this.ns,this.name,e=>!!id[e.value])}getPriority(){return 0}primarySlot(e){return null}},kp=class extends sp{constructor(e,t,i,n=null){super(),h(this,"ns",e),h(this,"name",t),h(this,"regexp",i),h(this,"caseSensitivity",n)}matches(e){return mp(e.currentElement,this.ns,this.name,e=>!!e.value.match(this.regexp))}},Pp=class extends sp{constructor(e){super(),h(this,"langRegExp",e)}matches(e){return!!e.instance.lang.match(this.langRegExp)}},Ep=class extends sp{constructor(){super()}matches(e){return e.instance.isFirst}getPriority(){return 6}},Np=class extends sp{constructor(){super()}matches(e){return e.instance.isRoot}getPriority(){return 12}},Tp=class extends sp{constructor(e,t){super(),h(this,"a",e),h(this,"b",t)}matchANPlusB(e){return Xc(e,this.a,this.b)}};function Ip(e,t){let i=null!==t?e.byNamespace[t]:e.noNamespace;return i||(i={},null!==t?e.byNamespace[t]=i:e.noNamespace=i),i}var Ap=class extends Tp{constructor(e,t){super(e,t)}matches(e){let t=Ip(e.instance.currentSiblingTypeCounts,e.instance.currentNamespace)[e.instance.currentLocalName];return this.matchANPlusB(t)}getPriority(){return 5}},Fp=class extends Tp{constructor(e,t){super(e,t)}matches(e){let t=e.instance.currentFollowingSiblingOrder;return null===t&&(t=e.instance.currentFollowingSiblingOrder=e.currentElement.parentNode.childElementCount-e.instance.currentSiblingOrder+1),this.matchANPlusB(t)}getPriority(){return 4}},Rp=class extends Tp{constructor(e,t){super(e,t)}matches(e){let t=e.instance.currentFollowingSiblingTypeCounts,i=null!==e.instance.currentNamespace?t.byNamespace[e.instance.currentNamespace]:t.noNamespace;if(!i){let n=e.currentElement;do{let e=n.namespaceURI,i=n.localName,r=Ip(t,e);r[i]=(r[i]||0)+1}while(n=xe(n));i=Ip(t,e.instance.currentNamespace)}return this.matchANPlusB(i[e.instance.currentLocalName])}getPriority(){return 4}},Op=class extends sp{constructor(){super()}matches(e){let t=e.currentElement.firstChild;for(;t;){switch(t.nodeType){case Node.ELEMENT_NODE:return!1;case Node.TEXT_NODE:if(t.length>0)return!1}t=t.nextSibling}return!0}getPriority(){return 4}},Lp=class extends sp{constructor(){super()}matches(e){return!1===e.currentElement.disabled}getPriority(){return 5}},_p=class extends sp{constructor(){super()}matches(e){return!0===e.currentElement.disabled}getPriority(){return 5}},Bp=class extends sp{constructor(){super()}matches(e){let t=e.currentElement;return!0===t.selected||!0===t.checked}getPriority(){return 5}},Mp=class extends sp{constructor(e){super(),h(this,"selector",e)}matches(e){let t=e.currentElement;try{return!!t&&t.matches(this.selector)}catch{return!1}}},Dp=class extends sp{constructor(e){super(),h(this,"condition",e)}matches(e){return!!e.instance.conditions[this.condition]}wire(e){return new hp(this,e)}getPriority(){return 5}},zp=class e extends ip{constructor(){super(),h(this,"applied",!1)}apply(e){this.applied=!0}clone(){let t=new e;return t.applied=this.applied,t}},Vp=class extends sp{constructor(e){super(),h(this,"checkAppliedAction"),h(this,"firstActions",[]),h(this,"priority"),this.checkAppliedAction=new zp,this.priority=Math.max(...e.map(e=>e.length>0?Math.max(...e.map(e=>e.getPriority())):0));for(let t of e)this.firstActions.push(Kd(t,this.checkAppliedAction))}matches(e){for(let t of this.firstActions)if(t.apply(e),this.checkAppliedAction.applied)break;let t=this.checkAppliedAction.applied;return this.checkAppliedAction.applied=!1,t===this.positive()}getPriority(){return this.priority}positive(){return!0}relational(){return!1}},Up=class extends Vp{positive(){return!1}},Hp=class extends Vp{constructor(e){super([]),h(this,"selectorTexts",e)}matches(e){for(let t of this.selectorTexts){let i,n;/^\s*[+~]/.test(t)?(n=e.currentElement.parentNode,i=`:scope > :nth-child(${Array.from(n.children).indexOf(e.currentElement)+1}) ${t}`):(n=e.currentElement,i=`:scope ${t}`);try{if(n.querySelector(i)){this.checkAppliedAction.apply(e);break}}catch{}}let t=this.checkAppliedAction.applied;return this.checkAppliedAction.applied=!1,t}relational(){return!0}},$p=class extends Tp{constructor(e,t,i){super(e,t),h(this,"checkAppliedAction"),h(this,"firstActions",[]),this.checkAppliedAction=new zp;for(let e of i)this.firstActions.push(Kd(e,this.checkAppliedAction))}matches(e){for(let t of this.firstActions)if(t.apply(e),this.checkAppliedAction.applied)break;if(!this.checkAppliedAction.applied)return!1;this.checkAppliedAction.applied=!1;let t=1,i=Se(e.currentElement);for(;i;)this.matchesSelector(i,e)&&t++,i=Se(i);return this.matchANPlusB(t)}matchesSelector(e,t){let i=t.instance,n=i.currentNamespace,r=i.currentLocalName,o=i.currentId,s=i.currentSiblingOrder;i.currentNamespace=e.namespaceURI,i.currentLocalName=e.localName,i.currentId=e.getAttribute("id");let a=1,l=e.previousElementSibling;for(;l;)a++,l=l.previousElementSibling;i.currentSiblingOrder=a;let h=new tp(i,t.currentStyle,e.classList?Array.from(e.classList):[],t.currentEpubTypes,e);for(let e of this.firstActions)if(e.apply(h),this.checkAppliedAction.applied)break;let u=this.checkAppliedAction.applied;return this.checkAppliedAction.applied=!1,i.currentNamespace=n,i.currentLocalName=r,i.currentId=o,i.currentSiblingOrder=s,u}getPriority(){return 5}},jp=class extends $p{constructor(e,t,i){super(e,t,i)}matches(e){for(let t of this.firstActions)if(t.apply(e),this.checkAppliedAction.applied)break;if(!this.checkAppliedAction.applied)return!1;this.checkAppliedAction.applied=!1;let t=1,i=xe(e.currentElement);for(;i;)this.matchesSelector(i,e)&&t++,i=xe(i);return this.matchANPlusB(t)}getPriority(){return 4}},Wp=class{constructor(e,t,i){h(this,"condition",e),h(this,"viewConditionId",t),h(this,"viewCondition",i)}increment(e){e.increment(this.condition,this.viewCondition)}decrement(e){e.decrement(this.condition,this.viewCondition)}buildViewConditionMatcher(e){return e.buildViewConditionMatcher(this.viewConditionId)}},Gp=class e extends Wp{constructor(e,t,i){super(e,t,i)}fresh(t){return new e(this.condition,this.viewConditionId,this.buildViewConditionMatcher(t))}push(e,t){return 0==t&&this.increment(e),!1}pop(e,t){return 0==t&&(this.decrement(e),!0)}},qp=class e extends Wp{constructor(e,t,i){super(e,t,i)}fresh(t){return new e(this.condition,this.viewConditionId,this.buildViewConditionMatcher(t))}push(e,t){return 0==t?this.increment(e):1==t&&this.decrement(e),!1}pop(e,t){return 0==t?(this.decrement(e),!0):(1==t&&this.increment(e),!1)}},Xp=class e extends Wp{constructor(e,t,i){super(e,t,i),h(this,"fired",!1)}fresh(t){return new e(this.condition,this.viewConditionId,this.buildViewConditionMatcher(t))}push(e,t){return!!this.fired&&(this.decrement(e),!0)}pop(e,t){return this.fired?(this.decrement(e),!0):(0==t&&(this.fired=!0,this.increment(e)),!1)}},Yp=class e extends Wp{constructor(e,t,i){super(e,t,i),h(this,"fired",!1)}fresh(t){return new e(this.condition,this.viewConditionId,this.buildViewConditionMatcher(t))}push(e,t){return this.fired&&(-1==t?this.increment(e):0==t&&this.decrement(e)),!1}pop(e,t){if(this.fired){if(-1==t)return this.decrement(e),!0;0==t&&this.increment(e)}else 0==t&&(this.fired=!0,this.increment(e));return!1}},Kp=class{constructor(e,t,i){h(this,"afterprop",e),h(this,"element",t),h(this,"elementStyle",i)}fresh(e){return this}push(e,t){return!1}pop(e,t){return 0==t&&(e.processPseudoelementProps(this.afterprop,this.element,this.elementStyle),!0)}},Zp=class{constructor(e){h(this,"lang",e)}fresh(e){return this}push(e,t){return!1}pop(e,t){return 0==t&&(e.lang=this.lang,!0)}},Jp=class{constructor(e){h(this,"oldQuotes",e)}fresh(e){return this}push(e,t){return!1}pop(e,t){return 0==t&&(e.quotes=this.oldQuotes,!0)}},Qp=class extends Ht{constructor(e,t,i,n){super(),h(this,"element",e),h(this,"scope",t),h(this,"propName",i),h(this,"validatorSet",n),h(this,"hadAttrFunction",!1)}validatePropertyValue(e){var t;if(yi(e))return e;let i=this.validatorSet.validators[this.propName];return i?null!=(t=e.visit(i))?t:di.unset:!this.propName||CSS.supports(this.propName,e.toString())?e:di.unset}visitFunc(e){var t;if("attr"!==e.name.toLowerCase())return super.visitFunc(e);this.hadAttrFunction=!0;let i=Sc(e);if(!i)return super.visitFunc(e);let n=(null!=(t=i.fallback)?t:function(e){switch(e.kind){case"url":return new ii("about:invalid");case"string":return new Xt("");default:return di.unset}}(i.type)).visit(this);if(!this.element||!this.element.hasAttribute(i.attributeName))return n;let r=function(e,t,i){if(null==t)return null;switch(i.kind){case"string":return new Xt(t);case"url":return new ii(t||"about:invalid");case"unit":{let n=ls(e,new to(`${t.trim()}${xc(i.unit)}`,null),""),r=Pc(i);return n&&r?n.visit(r):null}case"syntax":{if("<string>"===i.syntax)return new Xt(t);if("<url>"===i.syntax)return new ii(t||"about:invalid");let n=ls(e,new to(t,null),""),r=Pc(i);return n&&r?n.visit(r):null}}return null}(this.scope,this.element.getAttribute(i.attributeName),i.type);return r||n}};function ef(e,t){if(Oa(e)){if(e instanceof Xt)return e.stringValue();if(e instanceof li&&t){let i=e.expr.evaluate(t);return"string"==typeof i?i:"number"==typeof i?String(i):""}if(e instanceof oi)return e.values.map(e=>ef(e,t)).join("")}return""}function tf(e){if(e instanceof li){let t=e.expr;return t instanceof It&&/^page-counters?-/.test(t.str)}return(e instanceof oi||e instanceof si)&&e.values.some(e=>tf(e))}function nf(e,t){return tf(e)?e instanceof oi?new oi(e.values.map(e=>nf(e,t))):e instanceof si?new si(e.values.map(e=>nf(e,t))):e:new Xt(ef(e,t))}var rf=class extends Ht{constructor(e,t,i,n,r){super(),h(this,"cascade",e),h(this,"element",t),h(this,"counterResolver",i),h(this,"elementStyle",n),h(this,"pseudoName",r)}getCounterStore(){var e,t;return null!=(t=null==(e=this.cascade.context)?void 0:e.counterStore)?t:null}hasLocalCounterResetOrSet(e){return this.hasLocalCounter(e,"counter-reset",{reset:!0})||this.hasLocalCounter(e,"counter-set",{defaultValue:0})}hasLocalCounterIncrement(e){return this.hasLocalCounter(e,"counter-increment",{})}hasLocalCounter(e,t,i){let n=this.elementStyle[t];if(!n)return!1;let r=n.evaluate(this.cascade.context);if(!r||yi(r))return!1;let o=Rn(r,i);return Object.prototype.hasOwnProperty.call(o,e)}evaluateAndGetString(e){if(!e)return"";let t=this.cascade.quoteDepth,i=ef(e.visit(this),this.cascade.context);return this.cascade.quoteDepth=t,i}visitIdent(e){let t=this.cascade,i=t.quotes,n=Math.floor(i.length/2)-1;switch(e.name){case"open-quote":{let e=i[2*Math.min(n,t.quoteDepth)];return t.quoteDepth++,e}case"close-quote":return t.quoteDepth>0&&t.quoteDepth--,i[2*Math.min(n,t.quoteDepth)+1];case"no-open-quote":return t.quoteDepth++,new Xt("");case"no-close-quote":return t.quoteDepth>0&&t.quoteDepth--,new Xt("")}return e}format(e,t){return this.cascade.counterStyleStore.format(t,e)}formatCounterList(e,t,i){if(!e.length)return this.format(0,i);let n=new Pe;for(let r=0;r<e.length;r++)r>0&&n.append(t),n.append(this.format(e[r],i));return n.toString()}formatLastValue(e,t){let i=e.length?e[e.length-1]:0;return this.format(i,t)}buildCounterText(e,t,i,n,r,o=!1,s=!1){var a,l,h,u,c,d,p,f,g;let m,v="string"==typeof r,y=e=>v?this.formatCounterList(e,r,i):this.formatLastValue(e,i),b=e=>{"footnote-call"===this.pseudoName&&this.element&&Bd(this.element,t,e)};if("footnote-call"===this.pseudoName&&this.element){let e=function(e,t){var i,n;if(!_l(e)||e.hasAttribute(Fl))return null;let r=_d(e)[t];if(r)return r;let o=e.getAttribute("href")||e.getAttributeNS("http://www.w3.org/1999/xlink","href");if(!o)return null;let s=e.baseURI||(null==(i=e.ownerDocument)?void 0:i.baseURI)||"",a=ce(o,s);if("#"===a||a.replace(/#.*$/,"")!==s.replace(/#.*$/,""))return null;let l=a.indexOf("#");if(l<0||l===a.length-1)return null;let h=null==(n=e.ownerDocument)?void 0:n.getElementById(a.substring(l+1));if(!(h instanceof Element))return null;let u=_d(h)[t];return u?(Bd(e,t,u),u):null}(this.element,t);if(e)return y(e)}if("footnote-marker"===this.pseudoName&&this.element){let e=_d(this.element)[t];if(e)return y(e)}if("pages"===t)return y([]);if(!this.element){if(o&&n.length)return m=n,b(m),y(m);if(null!=(a=e.isPageControlledCounter)&&a.call(e,t)&&s&&n.length){let i=(null==(l=e.currentPageCounters)?void 0:l[t])||[];return m=[(i.length?i[i.length-1]:0)+n[n.length-1]],b(m),y(m)}if(null==(h=e.isPageControlledCounter)||!h.call(e,t)){let i=(null==(u=e.currentPageCounters)?void 0:u[t])||[];if(i.length)return m=i,b(m),y(m)}}let w=(null==(c=e.currentPageDocCounters)?void 0:c[t])||[],x=!this.element&&n.length&&(k=w,!((C=n).length===k.length&&C.every((e,t)=>e===k[t]))),S=this.element||x?n:w.length?w:n;var C,k;if(null!=(d=e.isPageControlledCounter)&&d.call(e,t)){let i=(null==(p=e.currentPageDocCounters)?void 0:p[t])||[],n=(null==(f=e.currentPageCounters)?void 0:f[t])||[],r=n.length?n[n.length-1]:0,o=i.length?i[0]:0,s=r+((S.length?S[0]:0)-o);return m=S.length?[s,...S.slice(1)]:n.length?n:[0],b(m),y(m)}return S.length?(m=S,b(m),y(m)):(m=(null==(g=e.currentPageCounters)?void 0:g[t])||[],b(m),y(m))}visitFuncCounter(e){var t;let i=e[0].toString(),n=e.length>1?e[1].stringValue():"decimal",r=(this.cascade.counters[i]||[]).slice(),o=!this.element&&this.hasLocalCounterResetOrSet(i),s=!this.element&&this.hasLocalCounterIncrement(i),a=this.getCounterStore();if(a){let e="pages"===i||(null==(t=null==a?void 0:a.isPageControlledCounter)?void 0:t.call(a,i)),l=this.counterResolver.pageScope,h=new It(l,()=>this.buildCounterText(a,i,n,r,void 0,o,s),e?`page-counter-${i}`:`counter-${i}`);if(e&&null!=a&&a.registerPageCounterExpr){let e=e=>this.formatLastValue(e,n);a.registerPageCounterExpr(i,e,h)}return new li(h)}let l=this.cascade.counters[i];if(l&&l.length){let e=l&&l.length&&l[l.length-1]||0;return new Xt(this.format(e,n))}{let e=new li(this.counterResolver.getPageCounterVal(i,e=>this.format(e||0,n)));return new oi([e])}}visitFuncCounters(e){var t;let i=e[0].toString(),n=e[1].stringValue(),r=e.length>2?e[2].stringValue():"decimal",o=(this.cascade.counters[i]||[]).slice(),s=!this.element&&this.hasLocalCounterResetOrSet(i),a=!this.element&&this.hasLocalCounterIncrement(i),l=this.getCounterStore();if(l){let e="pages"===i||(null==(t=null==l?void 0:l.isPageControlledCounter)?void 0:t.call(l,i)),h=this.counterResolver.pageScope,u=new It(h,()=>this.buildCounterText(l,i,r,o,n,s,a),e?`page-counters-${i}`:`counters-${i}`);return e&&null!=l&&l.registerPageCounterExpr&&l.registerPageCounterExpr(i,e=>this.formatCounterList(e,n,r),u),new li(u)}let h=this.cascade.counters[i],u=new Pe;if(h&&h.length)for(let e=0;e<h.length;e++)e>0&&u.append(n),u.append(this.format(h[e],r));let c=new li(this.counterResolver.getPageCountersVal(i,e=>{let t=[];if(e.length)for(let i=0;i<e.length;i++)t.push(this.format(e[i],r));let i=u.toString();return i.length&&t.push(i),t.length?t.join(n):this.format(0,r)}));return new oi([c])}visitFuncTargetCounter(e){let t,i=e[0];t=i instanceof ii?i.url:i.stringValue();let n=e[1].toString(),r=e.length>2?e[2].stringValue():"decimal",o=new li(this.counterResolver.getTargetCounterVal(t,n,e=>this.format(e||0,r)));return new oi([o])}visitFuncTargetCounters(e){let t,i=e[0];t=i instanceof ii?i.url:i.stringValue();let n=e[1].toString(),r=e[2].stringValue(),o=e.length>3?e[3].stringValue():"decimal",s=new li(this.counterResolver.getTargetCountersVal(t,n,e=>{let t=e.map(e=>this.format(e,o));return t.length?t.join(r):this.format(0,o)}));return new oi([s])}visitFuncTargetText(e){let t,i=e[0];t=i instanceof ii?i.url:i.stringValue();let n=e.length>1?e[1].stringValue():"content",r=new li(this.counterResolver.getTargetTextVal(t,n));return new oi([r])}visitFuncString(e){let t=e.length>0?e[0].stringValue():"",i=e.length>1?e[1].stringValue():"first";return new li(this.counterResolver.getNamedStringVal(t,i))}visitFuncElement(e){let t=e.length>0?e[0].stringValue():"",i=e.length>1?e[1].stringValue():"first";return new li(this.counterResolver.getRunningElementVal(t,i))}visitFuncContent(e){var t,i,n,r,o,s,a,l;let h=e.length>0?e[0].stringValue():"text",u="";switch(h){case"text":u=this.element.textContent;break;case"before":case"after":case"marker":{let e=null==(t=this.element)?void 0:t.querySelectorAll(`[data-adapt-pseudo="${h}"]`),o=null;if(e&&this.element)for(let t=0;t<e.length;t++){let i=e[t];if(i.parentElement===this.element){o=i;break}}if(o)u=o.textContent||"";else{let e=jd(this.elementStyle,"_pseudos"),t=null==(n=null==(i=null==e?void 0:e[h])?void 0:i.content)?void 0:n.value;if(t)u=this.evaluateAndGetString(t);else if("marker"===h){u=ef(null==(r=this.elementStyle["--viv-marker-content"])?void 0:r.value,this.cascade.context)}}}break;case"first-letter":{let e=jd(this.elementStyle,"_pseudos"),t=null==(s=null==(o=null==e?void 0:e.before)?void 0:o.content)?void 0:s.value,i=null==(l=null==(a=null==e?void 0:e.after)?void 0:a.content)?void 0:l.value,n=(this.evaluateAndGetString(t)||this.element.textContent||this.evaluateAndGetString(i)).match(Y);u=n?n[0]:""}}return new Xt(u)}visitFuncLeader(e){let t="";if(e[0]instanceof Kt)switch(e[0].stringValue()){case"dotted":t=".";break;case"solid":t="_";break;case"space":t=" "}else e[0]instanceof Xt&&(t=e[0].stringValue());return 0==t.length?new Xt(""):new li(new It(this.counterResolver.rootScope,()=>t,"viv-leader"))}visitFunc(e){switch(e.name){case"counter":if(e.values.length<=2)return this.visitFuncCounter(e.values);break;case"counters":if(e.values.length<=3)return this.visitFuncCounters(e.values);break;case"target-counter":if(e.values.length<=3)return this.visitFuncTargetCounter(e.values);break;case"target-counters":if(e.values.length<=4)return this.visitFuncTargetCounters(e.values);break;case"target-text":if(e.values.length>=1&&e.values.length<=2)return this.visitFuncTargetText(e.values);break;case"string":if(e.values.length<=2)return this.visitFuncString(e.values);break;case"element":if(e.values.length<=2)return this.visitFuncElement(e.values);break;case"content":if(e.values.length<=1)return this.visitFuncContent(e.values);break;case"leader":if(e.values.length<=1)return this.visitFuncLeader(e.values)}return e}};function of(e,t,i){let n;if(1===e.nodeType)n=Array.from(e.getClientRects());else{let i=e.ownerDocument.createRange();i.selectNodeContents(e),n=t.getRangeClientRects(i)}return n.reduce((e,t)=>e+("vertical-rl"===i||"vertical-lr"===i?t.height:t.width),0)}_("POST_LAYOUT_BLOCK",(e,t,i)=>{let n=t.flatMap(e=>{let t=function(e){let t=Sa(e);return null!==t&&t.after&&t.viewNode.hasAttribute("data-viv-leader")&&null!==t.blockContainer?t:null}(e),i=null==t?void 0:t.viewNode.parentElement,n=null==i?void 0:i.parentElement;return t&&i&&n?[{leaderContext:t,pseudoElem:i,pseudoParent:n}]:[]});for(let{leaderContext:e,pseudoElem:t,pseudoParent:r}of n){let n=function(e){h.textContent="rtl"===p?(e.startsWith("‏")?"":"‏")+e+(e.endsWith("‏")?"":"‏"):e},o=function(){let e=i.clientLayout.getElementClientRect(t);return"vertical-rl"===d||"vertical-lr"===d?"rtl"===p?e.top-=C:e.bottom+=C:"rtl"===p?e.left-=C:e.right+=C,v.left>e.left||v.right<e.right||v.top>e.top||v.bottom<e.bottom},s=function(){let e,t,i=c.repeat(1e4);if(n(i),o()){e=1,t=1e4;for(let i=0;i<16;i++){let i="",r=Math.floor((e+t)/2);for(let e=0;e<r;e++)i+=c;if(n(i),o())t=r;else{if(e==r)return;e=r}}n(c)}},a=function(e){let n=0,r=t.parentElement;for(;r&&r!==l.viewNode;)n+=i.getComputedInsets(r)[e],r=r.parentElement;return n},l=e.blockContainer,h=e.viewNode,u=t.getAttribute("data-adapt-pseudo"),c=h.getAttribute("data-viv-leader-value"),{writingMode:d,direction:p,marginInlineEnd:f}=i.clientLayout.getElementComputedStyle(t);h.style.marginInlineStart="1px",n(c),t.style.display="inline-block",t.style.textIndent="0";let g=ja(l.viewNode),m=(null==g?void 0:g.style.columnFill)||null;g&&(g.style.columnFill="auto");let v=i.clientLayout.getElementClientRect(l.viewNode),y=i.clientLayout.getElementClientRect(t),b=i.parseComputedLength(f),w=[],x=r;for(;x.parentElement&&x.parentElement!==l.viewNode;)x=x.parentElement;let S=x.nextSibling;for(;S;){if(1===S.nodeType){let e=S,{display:t,float:n,position:r}=i.clientLayout.getElementComputedStyle(e);if("none"!==n||"absolute"===r||"fixed"===r){S=S.nextSibling;continue}if(vs(t))w.push(e);else if(bs(t))break}else if(3===S.nodeType){let e=S;e.length>0&&w.push(e)}S=S.nextSibling}let C=w.reduce((e,t)=>e+of(t,i.clientLayout,d),0);if("after"!==u){let e=of(x,i.clientLayout,d),n=of(t,i.clientLayout,d);C+=e-n}"vertical-rl"===d||"vertical-lr"===d?("rtl"===p?v.top+=b:v.bottom-=b,v.top=Math.min(y.top,v.top),v.bottom=Math.max(y.bottom,v.bottom)):("rtl"===p?v.left+=b:v.right-=b,v.left=Math.min(y.left,v.left),v.right=Math.max(y.right,v.right)),s();let k=i.clientLayout.getElementClientRect(t);t.style.float="rtl"==p?"left":"right";let P=i.clientLayout.getElementClientRect(t),E=0;E="rtl"==p?"vertical-rl"==d||"vertical-lr"==d?k.top-P.top-a("top"):k.left-P.left-a("left"):"vertical-rl"==d||"vertical-lr"==d?P.bottom-k.bottom-a("bottom"):P.right-k.right-a("right"),E-=C,E=Math.max(0,E-.1),t.style.float="",h.style.marginInlineStart=`${E}px`,g&&(m?g.style.columnFill=m:g.style.removeProperty("column-fill"))}});var sf=1/1048576;function af(e,t){for(let i in e)t[i]=e[i].clone()}var lf=class e{constructor(){h(this,"nsCount",0),h(this,"nsPrefix",{}),h(this,"tags",{}),h(this,"nstags",{}),h(this,"epubtypes",{}),h(this,"classes",{}),h(this,"ids",{}),h(this,"pagetypes",{}),h(this,"order",0),h(this,"layerTrees",{})}clone(){let t=new e;t.nsCount=this.nsCount;for(let e in this.nsPrefix)t.nsPrefix[e]=this.nsPrefix[e];af(this.tags,t.tags),af(this.nstags,t.nstags),af(this.epubtypes,t.epubtypes),af(this.classes,t.classes),af(this.ids,t.ids),af(this.pagetypes,t.pagetypes),t.order=this.order;for(let e in this.layerTrees)t.layerTrees[e]=this.layerTrees[e];return t}registerLayer(e,t,i){var n,r;return(null!=(r=(n=this.layerTrees)[e])?r:n[e]=new fd).register(t,i)}insertInTable(e,t,i){let n=e[t];n&&(i=n.mergeWith(i)),e[t]=i}createInstance(e,t,i,n,r,o,s,a,l,h,u){return new uf(this,e,t,i,n,r,o,s,a,l,h,u)}nextOrder(){return this.order+=sf}},hf=class e{constructor(e,t,i,n,r,o,s,a,l,u,c,d){h(this,"context",t),h(this,"counterListener",i),h(this,"counterResolver",n),h(this,"counterStyleStore",o),h(this,"cmykStore",s),h(this,"root",a),h(this,"scope",l),h(this,"validatorSet",u),h(this,"styles",c),h(this,"mergeValidatorSet",d),h(this,"code"),h(this,"stack",[[],[]]),h(this,"conditions",Object.create(null)),h(this,"currentElement",null),h(this,"currentElementOffset",null),h(this,"currentLocalName",""),h(this,"currentNamespace",null),h(this,"currentId",null),h(this,"currentXmlId",null),h(this,"currentNSTag",""),h(this,"currentPageType",null),h(this,"previousPageType",null),h(this,"firstPageType",null),h(this,"pageTypePageIndices",Object.create(null)),h(this,"isFirst",!0),h(this,"isRoot",!0),h(this,"counters",Object.create(null)),h(this,"lastCounterChanges",[]),h(this,"lastCounterChangeTypes",Object.create(null)),h(this,"counterScoping",[Object.create(null)]),h(this,"quotes"),h(this,"quoteDepth",0),h(this,"lang",""),h(this,"siblingOrderStack",[0]),h(this,"currentSiblingOrder",0),h(this,"siblingTypeCountsStack",[{byNamespace:{},noNamespace:null}]),h(this,"currentSiblingTypeCounts"),h(this,"currentFollowingSiblingOrder",null),h(this,"followingSiblingOrderStack"),h(this,"followingSiblingTypeCountsStack",[{byNamespace:{},noNamespace:null}]),h(this,"currentFollowingSiblingTypeCounts"),h(this,"viewConditions",Object.create(null)),h(this,"dependentConditions",[]),h(this,"elementStack",[]),this.code=e,this.quotes=[new Xt("“"),new Xt("”"),new Xt("‘"),new Xt("’")],this.currentSiblingTypeCounts=this.siblingTypeCountsStack[0],this.followingSiblingOrderStack=[this.currentFollowingSiblingOrder],this.currentFollowingSiblingTypeCounts=this.siblingTypeCountsStack[0]}pushConditionItem(e){this.stack[this.stack.length-1].push(e)}increment(e,t){this.conditions[e]=(this.conditions[e]||0)+1,t&&(this.viewConditions[e]?this.viewConditions[e].push(t):this.viewConditions[e]=[t])}decrement(e,t){this.conditions[e]--,this.viewConditions[e]&&(this.viewConditions[e]=this.viewConditions[e].filter(e=>e!==t),0===this.viewConditions[e].length&&delete this.viewConditions[e])}buildViewConditionMatcher(e){let t=null;e&&(this.currentElementOffset,t=Qc.buildViewConditionMatcher(this.currentElementOffset,e));let i=this.dependentConditions.map(e=>{let t=this.viewConditions[e];return t&&t.length>0?1===t.length?t[0]:Qc.buildAnyMatcher([].concat(t)):null}).filter(e=>null!==e);return i.length<=0?t:null===t?1===i.length?i[0]:Qc.buildAllMatcher(i):Qc.buildAllMatcher([t].concat(i))}applyAction(e,t,i){let n=t[i];n&&n.apply(e)}pushRule(e,t,i){this.currentElement=null,this.currentElementOffset=null,this.currentNamespace=null,this.currentLocalName="",this.currentId=null,this.currentXmlId=null,this.currentNSTag="",this.currentPageType=t,this.applyActions(new ep(this,i,e,cf))}defineCounter(e,t){let i=this.counterScoping[this.counterScoping.length-1];i||(i=Object.create(null),this.counterScoping[this.counterScoping.length-1]=i),this.counters[e]?(i[e]&&this.counters[e].pop(),this.counters[e].push(t)):this.counters[e]=[t],i[e]=!0}pushCounters(e,t){var i,n,r,o,s,a,l,h,u,c;let d=new Set,p=Object.create(null),f=di.inline,g=e.display;if(g&&(f=g.evaluate(this.context)),f===di.none)return null==(i=this.currentElement)||i.setAttribute("data-viv-display-none","true"),this.lastCounterChanges=[],this.lastCounterChangeTypes=Object.create(null),void this.counterScoping.push(null);if(null!=(n=this.currentElement)&&n.closest("[data-viv-display-none]"))return this.lastCounterChanges=[],this.lastCounterChangeTypes=Object.create(null),void this.counterScoping.push(null);let m=di.inline,v=e.float;v&&(m=v.evaluate(this.context));let y=null,b=null,w=null,x=e["counter-reset"];if(x){let e=x.evaluate(this.context);e&&(y=Rn(e,{reset:!0}))}let S=e["counter-set"];if(S){let e=S.evaluate(this.context);e&&(w=Rn(e,{defaultValue:0}))}let C=e["counter-increment"];if(C){let e=C.evaluate(this.context);e&&(b=Rn(e))}if(("ol"==this.currentLocalName||"ul"==this.currentLocalName)&&"http://www.w3.org/1999/xhtml"==this.currentNamespace&&(y||(y=Object.create(null)),y["list-item"]=(null!=(o=null==(r=this.currentElement)?void 0:r.start)?o:1)-1),ys(f)&&(b||(b=Object.create(null)),b["list-item"]=null!=(s=b["list-item"])?s:1,/^\s*[-+]?\d/.test(null!=(l=null==(a=this.currentElement)?void 0:a.getAttribute("value"))?l:"")&&(w||(w=Object.create(null)),w["list-item"]=this.currentElement.value)),(null==(u=null==(h=this.currentElement)?void 0:h.parentNode)?void 0:u.nodeType)===Node.DOCUMENT_NODE&&(y||(y=Object.create(null)),void 0===y.footnote&&(y.footnote=0)),m===di.footnote&&!t["--viv-semantic-footnote-content"]&&(b||(b=Object.create(null)),void 0===b.footnote)){let e=null==(c=t["counter-increment"])?void 0:c.value;(!e||!(e===di.footnote||e instanceof oi&&e.values.includes(di.footnote)))&&(b.footnote=1)}if(y)for(let e in y)d.add(e),p[e]="reset";if(b)for(let e in b)d.add(e),p[e]||(p[e]="increment");if(w)for(let e in w)d.add(e),p[e]="set";if(this.lastCounterChanges=Array.from(d),this.lastCounterChangeTypes=p,y)for(let e in y)this.defineCounter(e,y[e]);if(b)for(let e in b){this.counters[e]||this.defineCounter(e,0);let t=this.counters[e];t[t.length-1]+=b[e]}if(w)for(let e in w)if(this.counters[e]){let t=this.counters[e];t[t.length-1]=w[e]}else this.defineCounter(e,w[e]);if(ys(f)){let t=this.counters["list-item"],i=t[t.length-1];e["ua-list-item-count"]=new Cd(new Qt(i),0);let n=Wd(e,"_pseudos");n.marker||(n.marker={})}this.counterScoping.push(null)}popCounters(){let e=this.counterScoping.pop();if(e)for(let t in e){let e=this.counters[t];e&&(1==e.length?delete this.counters[t]:e.pop())}}setNamedStrings(e,t,i){let n=e["string-set"];if(!n)return;n=n.filterValue(new rf(this,t,this.counterResolver,e));let r=n.value instanceof si?n.value.values:[n.value];for(let e of r)if(e instanceof oi){let t=e.values[0].stringValue(),n=e.values.slice(1);if(n.some(e=>tf(e)))this.counterResolver.setNamedString(t,nf(new oi(n),this.context),i);else{let e=n.map(e=>ef(e,this.context)).join("");this.counterResolver.setNamedString(t,e,i)}}delete e["string-set"]}setRunningElement(e,t){let i=e.position;if((null==i?void 0:i.value)instanceof ai&&"running"===i.value.name){let e=i.value.values[0].stringValue();this.counterResolver.setRunningElement(e,t)}}processPseudoelementProps(e,t,i,n){this.pushCounters(e,i);let r=e.content;r&&(e.content=r.filterValue(new rf(this,t,this.counterResolver,i,n))),this.popCounters()}pushElement(e,t,i){var n,r,o;let s=this.currentPageType;this.currentPageType=null,this.currentElement=e,this.currentElementOffset=i,this.currentNamespace=e.namespaceURI,this.currentLocalName=e.localName;let a=null!==this.currentNamespace?this.code.nsPrefix[this.currentNamespace]:void 0;this.currentNSTag=a?a+this.currentLocalName:"",this.currentId=e.getAttribute("id"),this.currentXmlId=e.getAttributeNS("http://www.w3.org/XML/1998/namespace","id");let l=e.getAttribute("class"),h=l?l.split(/\s+/):cf,u=e.getAttributeNS("http://www.idpf.org/2007/ops","type"),c=u?u.split(/\s+/):cf,d=ke(e);d&&(this.stack[this.stack.length-1].push(new Zp(this.lang)),this.lang=d.toLowerCase());let p=this.isRoot,f=this.siblingOrderStack;this.currentSiblingOrder=++f[f.length-1],f.push(0);let g=this.siblingTypeCountsStack,m=Ip(this.currentSiblingTypeCounts=g[g.length-1],this.currentNamespace);m[this.currentLocalName]=(m[this.currentLocalName]||0)+1,g.push({byNamespace:{},noNamespace:null});let v=this.followingSiblingOrderStack,y=v[v.length-1];this.currentFollowingSiblingOrder=null!==y?v[v.length-1]=y-1:null,v.push(null);let b=this.followingSiblingTypeCountsStack,w=this.currentFollowingSiblingTypeCounts=b[b.length-1],x=w&&(null!==this.currentNamespace?w.byNamespace[this.currentNamespace]:w.noNamespace);x&&x[this.currentLocalName]--,b.push({byNamespace:{},noNamespace:null});let S=new tp(this,t,h,c,e);this.applyActions(S),this.currentPageType=s,this.applyVarFilter([t],e),Rd(t,!0)&&this.applyVarFilter([t],e),this.applyCalcFilter(t,this.context),this.applyCmykFilter(t,e),this.applyAttrFilter(e,t);let C=t.quotes,k=null;if(C){let e=C.evaluate(this.context);e&&(k=new Jp(this.quotes),e===di.none?this.quotes=[new Xt(""),new Xt("")]:e===di.auto||e===di.initial?this.quotes=[new Xt("“"),new Xt("”"),new Xt("‘"),new Xt("’")]:e instanceof oi&&(this.quotes=e.values))}this.pushCounters(t,t);let P=this.currentId||this.currentXmlId||e.getAttribute("name")||"";if(p||P){let e=Object.create(null);Object.keys(this.counters).forEach(t=>{e[t]=Array.from(this.counters[t])}),this.counterListener.countersOfId(P,e)}let E=jd(t,"_pseudos");if(E){let i=!0;for(let s of df){s||(i=!1);let a=E[s];if(a){let l=null==(n=Hd(t,"float"))?void 0:n.value,h=e instanceof Element&&_l(e),u=e instanceof Element&&Ll(e),c=!!Hd(t,"--viv-semantic-footnote-content"),d=("before"===s||"after"===s)&&(l===di.footnote||u||c)&&!!a.content,p=Md(a),f="footnote-call"===s&&h&&p,g="footnote-marker"===s&&(u||c)&&p;if(("before"!==s&&"after"!==s||(d||Oa(null==(r=a.content)?void 0:r.value)||this.hasNonTrivialViewConditionalPseudoContent(a)))&&("marker"!==s||ys(null==(o=Hd(t,"display"))?void 0:o.value))&&("footnote-call"!==s&&"footnote-marker"!==s||l===di.footnote||f||g)&&("footnote-call"!==s&&"footnote-marker"!==s||!c||p))if(i){if(this.processPseudoelementProps(a,e,t,s),"marker"===s)this.processMarkerPseudoelementProps(a,e,t),delete E[s];else if("footnote-marker"===s){if(this.resolvePseudoelementInheritedPropertyValue(a,"list-style-position",e,t)===di.outside){this.processMarkerPseudoelementProps(a,e,t);let i=a.content;i&&(t["_footnote-marker-content"]=i),t.display=new Cd(Zt("list-item"),0),t["list-style-position"]=new Cd(di.outside,0),t["list-style-type"]=new Cd(di.none,0),t["list-style-image"]=new Cd(di.none,0),delete E[s]}}else if("first-letter"===s&&a["initial-letter"]){let e=a["initial-letter"].evaluate(this.context);e!==di.normal&&!yi(e)&&(t["--viv-initialLetter"]=new Cd(e,0)),delete a["initial-letter"]}}else this.stack[this.stack.length-2].push(new Kp(a,e,t));else delete E[s]}}}return this.setNamedStrings(t,e,i),this.setRunningElement(t,i),k&&this.stack[this.stack.length-2].push(k),S}hasNonTrivialViewConditionalPseudoContent(e){let t=e._viewConditionalStyles;return!(!t||t.length<=0)&&t.some(e=>{var t;return Oa(null==(t=e.styles.content)?void 0:t.value)})}processMarkerPseudoelementProps(t,i,n){var r,o,s,a,l;let h=ys(null==(r=n.display)?void 0:r.value);if(!Oa(null==(o=t.content)?void 0:o.value)&&h){let e=this.getInheritedPropertyValue("list-style-type",i,n),r=this.getInheritedPropertyValue("list-style-image",i,n);if(r instanceof ii)t.content=new Cd(new oi([r,new Xt(" ")]),0);else if(e instanceof Xt)t.content=new Cd(e,0);else if(e instanceof Kt&&e!==di.none){let i=null==(a=null==(s=n["ua-list-item-count"])?void 0:s.value)?void 0:a.num;if(null!=i){let n=e.name.toLowerCase();"disc"===n||"circle"===n||"square"===n||"disclosure-open"===n||"disclosure-closed"===n||(t.content=new Cd(new Xt(this.counterStyleStore.formatMarker(e.name,i)),0))}}}let u=t.content;if(u){let e=u.value;if(Oa(e)){let t=this.resolveMarkerContentVal(e);n["--viv-marker-content"]=new Cd(t,0)}}for(let i of e.markerAllowedProps){let e=t[i];if(e){let t=e.evaluate(this.context,i);t&&!yi(t)&&(n[`--viv-marker-${i}`]=new Cd(t,0))}}if(!vs(null==(l=Hd(n,"display"))?void 0:l.value)){let e=this.getInheritedPropertyValue("list-style-position",i,n);e&&e!==di.outside&&!yi(e)&&(n["list-style-position"]=new Cd(e,0))}}resolveMarkerContentVal(e){if(e instanceof li){let t=e.expr.evaluate(this.context);return"string"==typeof t?new Xt(t):"number"==typeof t?new Xt(String(t)):e}if(e instanceof oi){let t=e.values.map(e=>this.resolveMarkerContentVal(e));return new oi(t)}return e}getInheritedPropertyValue(e,t,i){var n;for(let n=t;n;n=n.parentElement){let r=(n===t?i:this.styles.styleOf(n))[e];if(r){let t=r.evaluate(this.context,e);if(t===di.inherit||t===di.unset||bi(t))continue;if(t===di.initial)break;return t}}return null!=(n=this.validatorSet.defaultValues[e])?n:null}resolvePseudoelementInheritedPropertyValue(e,t,i,n){var r;let o=e[t];if(o){let e=o.evaluate(this.context,t);if(e!==di.inherit&&e!==di.unset&&!bi(e))return e===di.initial?null!=(r=this.validatorSet.defaultValues[t])?r:null:e}return this.getInheritedPropertyValue(t,i,n)}applyAttrFilterInner(e,t){for(let i in t)if(Vd(i)&&!Si(i)){let n=t[i],r=new Qp(e,this.scope,i,this.validatorSet),o=n.filterValue(r);if(!r.hadAttrFunction){t[i]=o;continue}let s=r.validatePropertyValue(o.value);t[i]=o.withValue(s)}}applyAttrFilter(e,t){let i=jd(t,"_pseudos");for(let t in i)this.applyAttrFilterInner(e,i[t]);this.applyAttrFilterInner(e,t)}applyVarFilter(e,t){let i=e[0],n=e.map(e=>({...e})),r={},o=jd(i,"_pseudos"),s=Object.keys(i).filter(Vd),a=o=>{var s,a,l;let h=Hd(i,o),u=h.value,c=Si(o)?n:e,d=new Mf(c,this.styles,this.root,t,Si(o)?o:null);Si(o)&&d.getFallbackCycleMembers(u,c,t)&&(u=di.initial);for(let e=0;;e++){if(e>=32){u=Si(o)?di.initial:di.unset;break}let t=u.visit(d);if(d.error){u=Si(o)?di.initial:di.unset,d.error=!1;break}if(t===u)break;u=t}if(u!==h.value){let e=null==(s=this.validatorSet.getShorthand(o,u))?void 0:s.clone(this.scope);if(e)if(yi(u)){for(let t of e.propList){let e=h.withValue(u),n=Hd(i,t);$d(r,t,Pd(this.context,n,e))}delete i[o]}else{let t=ls(this.scope,new to(u.toString(),null),"");if(t&&(t.visit(e),!e.error)){for(let t of e.propList){let n=h.withValue(null!=(l=null!=(a=e.values[t])?a:this.validatorSet.defaultValues[t])?l:di.initial),o=Hd(i,t);$d(r,t,Pd(this.context,o,n))}delete i[o]}}else i[o]=h.withValue(u)}if(r[o]){let e=Hd(i,o);e&&e.value!==Wt&&Ed(r,o,e,this.context)}};for(let n in i)if(zd(n)){if("_pseudos"===n)continue;let r=jd(i,n);for(let i in r)this.applyVarFilter([r[i],...e],t)}for(let e of s)Si(e)&&a(e);for(let e of s)Si(e)||a(e);if(o)for(let i in o)this.applyVarFilter([o[i],...e],t);for(let e in r)i[e]=r[e]}applyCalcFilter(e,t){let i=new Df(t);for(let n in e)if(zd(n)){let i=jd(e,n);for(let e in i)this.applyCalcFilter(i[e],t)}else if(Vd(n)&&!Si(n)){let t=Hd(e,n);e[n]=t.withValue(t.value.visit(i))}}applyCmykFilter(e,t){let i=new Wi(this.cmykStore);if(this.applyCmykFilterInternal(e,i,""),t){let e=i.getConversions();e&&t.setAttribute("data-viv-device-cmyk",JSON.stringify(e))}}applyCmykFilterInternal(e,t,i){for(let n in e)if(zd(n)){let i=jd(e,n);for(let e in i)this.applyCmykFilterInternal(i[e],t,`::${e}:`)}else if(Vd(n)&&!Si(n)){let r=Hd(e,n),o=r.value.toString();t.reset();let s=r.value.visit(t);s!==r.value&&(t.hadDeviceCmyk()&&t.recordConversion(i+n,o),e[n]=r.withValue(s))}}applyActions(e){let t,i=e.currentClassNames;for(t=0;t<i.length;t++)this.applyAction(e,this.code.classes,i[t]);let n=e.currentEpubTypes;for(t=0;t<n.length;t++)this.applyAction(e,this.code.epubtypes,n[t]);null!==this.currentId&&this.applyAction(e,this.code.ids,this.currentId),this.applyAction(e,this.code.tags,this.currentLocalName),""!=this.currentLocalName&&this.applyAction(e,this.code.tags,"*"),this.applyAction(e,this.code.nstags,this.currentNSTag),null!==this.currentPageType&&(this.applyAction(e,this.code.pagetypes,this.currentPageType),this.applyAction(e,this.code.pagetypes,"*")),this.stack.push([]);for(let e=1;e>=-1;--e){let i=this.stack[this.stack.length-e-2];for(t=0;t<i.length;)i[t].push(this,e)?i.splice(t,1):t++}this.isFirst=!0,this.isRoot=!1,Rd(e.currentStyle)}pop(){for(let e=1;e>=-1;--e){let t=this.stack[this.stack.length-e-2],i=0;for(;i<t.length;)t[i].pop(this,e)?t.splice(i,1):i++}this.stack.pop(),this.isFirst=!1}popRule(){this.pop()}popElement(e){this.siblingOrderStack.pop(),this.siblingTypeCountsStack.pop(),this.followingSiblingOrderStack.pop(),this.followingSiblingTypeCountsStack.pop(),this.pop(),this.popCounters()}};h(hf,"markerAllowedProps",["color","font-family","font-size","font-style","font-weight","font-variant","hyphens","line-height","tab-size","text-combine-upright","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-orientation","text-shadow","text-transform","unicode-bidi","direction","white-space"]);var uf=hf,cf=[],df=["before","footnote-call","footnote-marker","marker","inner","first-letter","first-line","","after"],pf=class e{constructor(){h(this,"actions",[])}push(e){this.actions.push(e)}restartWith(t){let i=new e;return i.push(t),i}emit(e,t){t.insertChained(Kd(this.actions,e))}contributeTo(e){e.takeAlternative(this.actions)}recordTextIn(e,t){e.push(t)}finishIn(e){e.applyRuleForSelector()}},ff=class{push(){}restartWith(){return this}emit(){}contributeTo(){}recordTextIn(){}finishIn(){}},gf=class extends Uo{constructor(e,t,i,n,r,o,s){super(e,t,s),h(this,"condition",i),h(this,"regionId",r),h(this,"validatorSet",o),h(this,"chain",new ff),h(this,"selectorListVoided",!1),h(this,"pendingChained",[]),h(this,"specificity",0),h(this,"elementStyle",null),h(this,"ruleId",0),h(this,"conditionCount",0),h(this,"pseudoelement",null),h(this,"footnoteContent",!1),h(this,"cascade"),h(this,"layer"),h(this,"state"),h(this,"viewConditionId",null),h(this,"insideSelectorRule"),h(this,"invalid",!1),this.cascade=n?n.cascade:new lf,this.layer=n?n.layer:null,this.state=0}layerStatementRule(e){for(let t of e)this.cascade.registerLayer(this.flavor,this.layer,t)}insertNonPrimary(e){this.cascade.insertInTable(this.cascade.tags,"*",e)}processChain(e){this.chain.emit(e,this)}insertChained(e){this.pendingChained.push(e)}takePendingChained(){for(let e of this.pendingChained)e instanceof ap&&e.makePrimary(this.cascade)||this.insertNonPrimary(e);this.pendingChained.splice(0)}invalidContinuationAfterPseudoelement(e){return!!this.pseudoelement&&(this.invalidSelector(`::${this.pseudoelement} followed by ${e}`),!0)}isInsideSelectorRule(e){return 0!=this.state&&(this.reportAndSkip(e),!0)}tagSelector(e,t){!t&&!e||this.invalidContinuationAfterPseudoelement(t||"*")||(t&&(this.specificity+=1),t&&e?this.chain.push(new pp(e,t.toLowerCase())):t?this.chain.push(new dp(t.toLowerCase())):this.chain.push(new gp(e)))}invalidSelector(e){R.warn(e),this.setInvalid(),this.voidSelectorList()}setInvalid(){this.invalid=!0;for(let e=this;e instanceof bf;e=e.parent)e.parent.invalid=!0}classSelector(e){this.invalidContinuationAfterPseudoelement(`.${e}`)||(this.specificity+=256,this.chain.push(new up(e)))}pseudoclassSelector(e,t){if(!this.invalidContinuationAfterPseudoelement(`:${e}`)){if(t?!vf.has(e.toLowerCase()):vf.has(e.toLowerCase()))return void this.invalidSelector(`Unsupported pseudo-class :${e}`);switch(e.toLowerCase()){case"enabled":this.chain.push(new Lp);break;case"disabled":this.chain.push(new _p);break;case"checked":this.chain.push(new Bp);break;case"root":case"scope":this.chain.push(new Np);break;case"link":case"any-link":this.chain.push(new dp("a")),this.chain.push(new xp("","href"));break;case"href-epub-type":case"href-role-type":if(t&&t.length>=1&&"string"==typeof t[0]){let i=t[0],n=new RegExp(`(^|\\s)${Re(i)}($|\\s)`),r=t[1];this.chain.push(new fp(n,r,"href-role-type"===e))}else this.chain.push(new Dp(""));break;case"footnote-content":this.footnoteContent=!0;break;case"visited":case"active":case"hover":case"focus":this.chain.push(new Dp(""));break;case"lang":if(t&&1==t.length&&"string"==typeof t[0]){let e=t[0];this.chain.push(new Pp(new RegExp(`^${Re(e.toLowerCase())}($|-)`)))}else this.chain.push(new Dp(""));break;case"dir":if(t&&1==t.length&&"string"==typeof t[0]){/^(ltr|rtl)$/i.test(t[0])?this.chain.push(new Mp(`:dir(${t[0].toLowerCase()})`)):this.chain.push(new Dp(""));break}return void this.invalidSelector(`Invalid pseudo-class :${e}`);case"nth-child":case"nth-last-child":case"nth-of-type":case"nth-last-of-type":{let i=mf[e.toLowerCase()];t&&2==t.length?this.chain.push(new i(t[0],t[1])):this.chain.push(new Dp(""));break}case"first-child":this.chain.push(new Ep);break;case"last-child":this.chain.push(new Fp(0,1));break;case"first-of-type":this.chain.push(new Ap(0,1));break;case"last-of-type":this.chain.push(new Rp(0,1));break;case"only-child":this.chain.push(new Ep),this.chain.push(new Fp(0,1));break;case"only-of-type":this.chain.push(new Ap(0,1)),this.chain.push(new Rp(0,1));break;case"empty":this.chain.push(new Op);break;case"before":case"after":case"first-line":case"first-letter":return void this.pseudoelementSelector(e,t);default:return void this.invalidSelector(`Unknown pseudo-class :${e}`)}this.specificity+=256}}pseudoelementSelector(e,t){if(e=e.toLowerCase(),!this.invalidContinuationAfterPseudoelement(`::${e}`)){switch(e){case"before":case"after":case"first-line":case"first-letter":case"footnote-call":case"footnote-marker":case"marker":case"inner":case"after-if-continues":if(this.pseudoelement)return void this.invalidSelector(`Double pseudo-element ::${this.pseudoelement}::${e}`);this.pseudoelement=e;break;case"first-n-lines":if(t&&1==t.length&&"number"==typeof t[0]){let i=Math.round(t[0]);if(i>0&&i==t[0]){if(this.pseudoelement)return void this.invalidSelector(`Double pseudo-element ::${this.pseudoelement}::${e}`);this.pseudoelement=`first-${i}-lines`;break}}this.chain.push(new Dp(""));break;case"nth-fragment":t&&2==t.length?this.viewConditionId=`NFS_${t[0]}_${t[1]}`:this.chain.push(new Dp(""));break;default:return void this.invalidSelector(`Unknown pseudo-element ::${e}`)}this.specificity+=1}}idSelector(e){this.invalidContinuationAfterPseudoelement(`#${e}`)||(this.specificity+=65536,this.chain.push(new cp(e)))}attributeSelector(e,t,i,n,r){if(this.invalidContinuationAfterPseudoelement(`[${t}]`))return;let o;switch(this.specificity+=256,n=n||"",i){case 0:o=new xp(e,t);break;case 39:o=new Sp(e,t,n,null!=r?r:null);break;case 45:o=!n||n.match(/\s/)?new Dp(""):new kp(e,t,wp(`(^|\\s)${bp(n,null!=r?r:null)}($|\\s)`),null!=r?r:null);break;case 44:o=new kp(e,t,wp(`^${bp(n,null!=r?r:null)}($|-)`),null!=r?r:null);break;case 43:o=n?new kp(e,t,wp(`^${bp(n,null!=r?r:null)}`),null!=r?r:null):new Dp("");break;case 42:o=n?new kp(e,t,wp(`${bp(n,null!=r?r:null)}$`),null!=r?r:null):new Dp("");break;case 46:o=n?new kp(e,t,wp(bp(n,null!=r?r:null)),null!=r?r:null):new Dp("");break;case 50:if("supported"!=n)return void this.invalidSelector(`Unsupported :: attr selector op: ${n}`);o=new Cp(e,t);break;default:return void this.invalidSelector(`Unsupported attr selector: ${i}`)}this.chain.push(o)}descendantSelector(){if(this.invalidContinuationAfterPseudoelement("descendant selector"))return;let e="d"+yf++;this.processChain(new np(new Gp(e,this.viewConditionId,null))),this.chain=this.chain.restartWith(new Dp(e)),this.viewConditionId=null}childSelector(){if(this.invalidContinuationAfterPseudoelement("child selector"))return;let e="c"+yf++;this.processChain(new np(new qp(e,this.viewConditionId,null))),this.chain=this.chain.restartWith(new Dp(e)),this.viewConditionId=null}adjacentSiblingSelector(){if(this.invalidContinuationAfterPseudoelement("adjacent sibling selector"))return;let e="a"+yf++;this.processChain(new np(new Xp(e,this.viewConditionId,null))),this.chain=this.chain.restartWith(new Dp(e)),this.viewConditionId=null}followingSiblingSelector(){if(this.invalidContinuationAfterPseudoelement("following sibling selector"))return;let e="f"+yf++;this.processChain(new np(new Yp(e,this.viewConditionId,null))),this.chain=this.chain.restartWith(new Dp(e)),this.viewConditionId=null}nextSelector(){this.finishChain(),this.pseudoelement=null,this.footnoteContent=!1,this.specificity=0,this.selectorListVoided||(this.chain=new pf)}startSelectorRule(){this.isInsideSelectorRule("E_CSS_UNEXPECTED_SELECTOR")||(this.state=1,this.elementStyle={},this.ruleId=yd(),this.pseudoelement=null,this.viewConditionId=null,this.specificity=0,this.footnoteContent=!1,this.selectorListVoided=!1,this.pendingChained.splice(0),this.chain=new pf,this.invalid=!1)}error(e,t){super.error(e,t),1==this.state&&(this.state=0),this.setInvalid()}startStylesheet(e){super.startStylesheet(e),this.state=0}startRuleBody(){this.finishChain(),this.selectorListVoided?this.pendingChained.splice(0):this.takePendingChained(),super.startRuleBody(),1==this.state&&(this.state=0)}endRule(){super.endRule(),this.insideSelectorRule=0}finishChain(){this.chain.finishIn(this)}voidSelector(){this.chain=new ff,this.pseudoelement=null,this.viewConditionId=null,this.footnoteContent=!1,this.specificity=0}voidSelectorList(){this.voidSelector(),this.selectorListVoided=!0}applyRuleForSelector(){this.processChain(this.makeApplyRuleAction(this.specificity)),this.voidSelector()}makeApplyRuleAction(e){let t=this.regionId;return this.footnoteContent&&(t=t?"xxx-bogus-xxx":"footnote"),new op(this.elementStyle,e,this.pseudoelement,t,this.viewConditionId)}special(e,t){let i;i=this.condition?new kd(t,0,this.condition):new Cd(t,0),Xd(this.elementStyle,e).push(i)}property(e,t,i){this.validatorSet.validatePropertyAndHandleShorthand(e,t,i,this.scope,this)}invalidPropertyValue(e,t){this.report(`E_INVALID_PROPERTY_VALUE ${e}: ${t.toString()}`)}unknownProperty(e,t){this.report(`E_INVALID_PROPERTY ${e}: ${t.toString()}`)}simpleProperty(e,t,i){"display"==e&&(t===di.oeb_page_head||t===di.oeb_page_foot)&&(this.simpleProperty("flow-options",new oi([di.exclusive,di._static]),i),this.simpleProperty("flow-into",t,i),t=di.block),M("SIMPLE_PROPERTY").forEach(n=>{let r=n({name:e,value:t,important:i});e=r.name,t=r.value,i=r.important});let n=(i?this.getImportantSpecificity():this.getBaseSpecificity())+this.cascade.nextOrder();Td(e,t,this.validatorSet);let r=this.condition?new kd(t,n,this.condition,this.layer,this.ruleId):new Cd(t,n,this.layer,this.ruleId);Ed(this.elementStyle,e,r)}finish(){return this.cascade}startFuncWithSelector(e,t){let i;switch(e){case"is":i=e=>new bf(this,e);break;case"not":i=e=>new wf(this,e);break;case"where":i=e=>new xf(this,e);break;case"has":i=e=>new Sf(this,e);break;case"nth-child":t&&t.length>=2&&(i=e=>new Cf(this,e,t[0],t[1]));break;case"nth-last-child":t&&t.length>=2&&(i=e=>new kf(this,e,t[0],t[1]))}i&&this.owner.delegateTo(e=>{let t=i(e);return t.startSelectorRule(),t})}},mf={"nth-child":class extends Tp{constructor(e,t){super(e,t)}matches(e){return this.matchANPlusB(e.instance.currentSiblingOrder)}getPriority(){return 5}},"nth-of-type":Ap,"nth-last-child":Fp,"nth-last-of-type":Rp},vf=new Set(["dir","href-epub-type","href-role-type","lang","nth-child","nth-last-child","nth-last-of-type","nth-of-type"]),yf=0,bf=class e extends gf{constructor(e,t){super(e.scope,e.owner,e.condition,e,e.regionId,e.validatorSet,t),h(this,"parent",e),h(this,"parentChain"),h(this,"chains",[]),h(this,"maxSpecificity",0),h(this,"selectorTexts",[]),this.parentChain=e.chain}insertChained(e){this.parent.insertChained(e)}takeAlternative(e){this.chains.push(e),this.maxSpecificity=Math.max(this.maxSpecificity,this.specificity)}nextSelector(){this.chain.contributeTo(this),this.chain=new pf,this.pseudoelement=null,this.viewConditionId=null,this.footnoteContent=!1,this.specificity=0}endFuncWithSelector(){this.chain.contributeTo(this),this.chains.length>0?(this.parentChain.push(this.relational()?new Hp(this.selectorTexts):this.positive()?new Vp(this.chains):new Up(this.chains)),this.increasingSpecificity()&&(this.parent.specificity+=this.maxSpecificity)):this.parentChain.push(new Dp("")),this.endDelegation()}startRuleBody(){this.reportAndSkip("E_CSS_UNEXPECTED_RULE_BODY")}error(e,t){super.error(e,t),this.voidAlternative()}pseudoelementSelector(e,t){this.invalidSelector(`Pseudo-element ::${e} in a selector list`)}invalidSelector(e){R.warn(e),this.setInvalid(),this.voidAlternative()}voidAlternative(){this.voidSelector();let t=this;for(;t instanceof e&&!t.forgiving();)t=t.parent,t.voidSelector();t instanceof e||(t.voidSelectorList(),this.endDelegation())}pushSelectorText(e){this.relational()&&this.chain.recordTextIn(this.selectorTexts,e)}positive(){return!0}increasingSpecificity(){return!0}forgiving(){return!0}relational(){return!1}},wf=class extends bf{positive(){return!1}forgiving(){return!1}},xf=class extends bf{increasingSpecificity(){return!1}},Sf=class extends bf{relational(){return!0}forgiving(){return!1}},Cf=class extends bf{constructor(e,t,i,n){super(e,t),h(this,"a",i),h(this,"b",n)}endFuncWithSelector(){this.chain.contributeTo(this),this.chains.length>0?(this.parentChain.push(new $p(this.a,this.b,this.chains)),this.parent.specificity+=256+this.maxSpecificity):this.parentChain.push(new Dp("")),this.endDelegation()}forgiving(){return!1}},kf=class extends Cf{endFuncWithSelector(){this.chain.contributeTo(this),this.chains.length>0?(this.parentChain.push(new jp(this.a,this.b,this.chains)),this.parent.specificity+=256+this.maxSpecificity):this.parentChain.push(new Dp("")),this.endDelegation()}},Pf=class extends Uo{constructor(e,t,i){super(e,t,i)}property(e,t,i){if(this.scope.values[e])this.error(`E_CSS_NAME_REDEFINED ${e}`,this.getCurrentToken());else{let i=e.match(/height|^(top|bottom)$/)?"vh":"vw",n=new Et(this.scope,100,i);this.scope.defineName(e,t.toExpr(this.scope,n))}}},Ef=class extends Uo{constructor(e,t,i,n,r,o,s,a=null){super(e,t,o),h(this,"condition",i),h(this,"elementStyle",n),h(this,"validatorSet",r),h(this,"ruleType",s),h(this,"layer",a),h(this,"order"),h(this,"ruleId",yd()),this.order=0}property(e,t,i){i?R.warn("E_IMPORTANT_NOT_ALLOWED"):this.validatorSet.validatePropertyAndHandleShorthand(e,t,i,this.scope,this)}invalidPropertyValue(e,t){R.warn("E_INVALID_PROPERTY_VALUE",`${e}:`,t.toString())}unknownProperty(e,t){R.warn("E_INVALID_PROPERTY",`${e}:`,t.toString())}simpleProperty(e,t,i){let n=i?this.getImportantSpecificity():this.getBaseSpecificity();n+=this.order,this.order+=sf,Td(e,t,this.validatorSet);let r=this.condition?new kd(t,n,this.condition,this.layer,this.ruleId):new Cd(t,n,this.layer,this.ruleId);Ed(this.elementStyle,e,r)}},Nf=class extends rs{constructor(e,t){super(e),h(this,"validatorSet",t),h(this,"elementStyle",{}),h(this,"order",0),h(this,"ruleId",yd())}property(e,t,i){this.validatorSet.validatePropertyAndHandleShorthand(e,t,i,this.scope,this)}invalidPropertyValue(e,t){R.warn("E_INVALID_PROPERTY_VALUE",`${e}:`,t.toString())}unknownProperty(e,t){R.warn("E_INVALID_PROPERTY",`${e}:`,t.toString())}simpleProperty(e,t,i){let n=i?Bo:_o;n+=this.order,this.order+=sf,Td(e,t,this.validatorSet);let r=new Cd(t,n,null,this.ruleId);Ed(this.elementStyle,e,r)}};function Tf(e,t){let i=Gd(e);i&&i.forEach(e=>{e.matcher.matches()&&t(e.styles)})}function If(e,t,i){Tf(i,i=>{_f(e,i,t)})}function Af(e,t,i,n){let r=new Nf(e,t),o=new to(n,r);try{!function(e,t,i){new ns($o,e,t,i).runParser(Number.POSITIVE_INFINITY,!1,!0,!1,!1)}(o,r,i)}catch(e){R.warn(e,"Style attribute parse error:")}return r.elementStyle}function Ff(e,t,i){let n=e["writing-mode"];if(n){let e=n.evaluate(t,"writing-mode");if(e&&e!==di.inherit&&e!==di.unset&&!bi(e))return e===di.vertical_rl}return i}function Rf(e,t,i){let n=e.direction;if(n){let e=n.evaluate(t,"direction");if(e&&e!==di.inherit&&e!==di.unset&&!bi(e))return e===di.rtl}return i}function Of(e,t,i,n){let r={};for(let t in e)Vd(t)&&(r[t]=Hd(e,t));return If(r,t,e),Lf(e,i,n,(e,i)=>{_f(r,i,t),If(r,t,i)}),r}function Lf(e,t,i,n){let r=jd(e,"_regions");if((t||i)&&r){if(i){let e=["footnote"];t=t?t.concat(e):e}for(let e of t){let t=r[e];t&&n(e,t)}}}function _f(e,t,i){for(let n in t)if(Vd(n)){let r=Hd(t,n),o=e[n];e[n]=Pd(i,o,r)}}var Bf=(e,t,i,n,r,o)=>{var s,a;let l=i?n?hd:ad:n?ud:ld,h=r?cd:dd;for(let i in e){let n=e[i];if(!n)continue;let u,c=null!=(s=l[i])?s:l[h[i]],d=null!=(a=h[i])?a:h[l[i]],p=null!=c?c:d;if(p){let t=e[p];if(t&&Sd(t,n)>0||c&&d&&c!==d&&(p=d,t=e[p],t&&Sd(t,n)>0))continue;u=od[c]?c:od[d]?d:i}else u=i,i.startsWith("text-align")&&(n.value===di.inside||n.value===di.outside)&&(n=n.withValue(r===(n.value===di.inside)?di.right:di.left));t[u]=o(i,n)}},Mf=class e extends Ht{constructor(e,t,i,n,r=null){super(),h(this,"elementStyles",e),h(this,"styles",t),h(this,"root",i),h(this,"element",n),h(this,"currentCustomPropertyName",r),h(this,"resolvingCustomProperties",[]),h(this,"varResolutionState",{cycleMembers:new Set}),r&&this.resolvingCustomProperties.push(r)}getRawCustomPropertyLookup(e,t,i){var n,r;let o=null!=i?i:this.root;if(null!=t&&t.length){for(let r=0;r<t.length;r++){let o=null==(n=t[r][e])?void 0:n.value;if(o){if(o===di.initial)return{found:!0,value:null,elementStyles:t.slice(r),element:i};if(o!==di.inherit&&o!==di.unset&&!bi(o))return{found:!0,value:o,elementStyles:t.slice(r),element:i}}}i&&(o=i.parentElement)}for(;o;o=o.parentElement){let t=this.styles.styleOf(o),i=null==(r=null==t?void 0:t[e])?void 0:r.value;if(i){if(i===di.initial)return{found:!0,value:null,elementStyles:t?[t]:[],element:o};if(i!==di.inherit&&i!==di.unset&&!bi(i))return{found:!0,value:i,elementStyles:t?[t]:[],element:o}}}return{found:!1,value:null,elementStyles:[],element:null}}collectReferencedCustomProperties(e){let t=new Set;return e.visit(new class extends Ut{visitFunc(e){let i=e.values[0]instanceof Kt&&e.values[0].name;return"var"===e.name&&i&&Si(i)&&t.add(i),super.visitFunc(e)}}),Array.from(t)}findReferencedCycleStart(e,t,i,n=new Set){for(let r of this.collectReferencedCustomProperties(e)){if(this.resolvingCustomProperties.includes(r))return r;if(n.has(r))continue;n.add(r);let e=this.getRawCustomPropertyLookup(r,t,i),o=e.value&&this.findReferencedCycleStart(e.value,e.elementStyles,e.element,n);if(o)return o}return null}getFallbackCycleMembers(e,t,i){let n=null,r=this;if(e.visit(new class extends Ut{visitFunc(e){if("var"===e.name)for(let o of e.values.slice(1)){let s=r.findReferencedCycleStart(o,t,i);if(s)return n=s,e}return super.visitFunc(e)}}),!n)return null;let o=this.resolvingCustomProperties.indexOf(n);return new Set(this.resolvingCustomProperties.slice(o))}resolveCustomProperty(e,t,i,n){if(!t)return{found:!1,value:null,continueLookup:!1};if(t===di.initial)return{found:!0,value:null,continueLookup:!1};if(t===di.inherit||t===di.unset||bi(t))return{found:!0,value:null,continueLookup:!0};let r=this.getFallbackCycleMembers(t,i,n);return r?(r.forEach(e=>this.varResolutionState.cycleMembers.add(e)),{found:!0,value:null,continueLookup:!1}):{found:!0,value:this.resolveReferencedCustomProperty(e,t,i,n),continueLookup:!1}}resolveReferencedCustomProperty(t,i,n,r){let o=this.resolvingCustomProperties.indexOf(t);if(o>=0)return this.resolvingCustomProperties.slice(o).forEach(e=>this.varResolutionState.cycleMembers.add(e)),null;let s=new Set(this.varResolutionState.cycleMembers);this.varResolutionState.cycleMembers=new Set;let a=new e(n,this.styles,this.root,r,t);a.resolvingCustomProperties=this.resolvingCustomProperties,a.resolvingCustomProperties.push(t),a.varResolutionState=this.varResolutionState;let l=i;for(let e=0;;e++){if(e>=32){l=null;break}let t=l.visit(a);if(a.error){l=null;break}if(t===l)break;l=t}let h=this.varResolutionState.cycleMembers;return this.varResolutionState.cycleMembers=new Set([...s,...h]),this.resolvingCustomProperties.pop(),h.has(t)?null:l}getVarValue(e){var t,i,n,r;let o=null!=(t=this.element)?t:this.root;if(null!=(i=this.elementStyles)&&i.length){for(let t=0;t<this.elementStyles.length;t++){let i=this.elementStyles[t],r=this.resolveCustomProperty(e,null==(n=i[e])?void 0:n.value,this.elementStyles.slice(t),this.element);if(r.found){if(r.value)return r.value;if(!r.continueLookup)return null}}this.element&&(o=this.element.parentElement)}for(;o;o=o.parentElement){let t=this.styles.styleOf(o),i=this.resolveCustomProperty(e,null==(r=null==t?void 0:t[e])?void 0:r.value,t?[t]:[],o);if(i.found){if(i.value)return i.value;if(!i.continueLookup)return null}}return null}visitFunc(e){if("var"!==e.name)return super.visitFunc(e);let t=e.values[0]instanceof Kt&&e.values[0].name;return t&&Si(t)?this.getVarValue(t)||(this.currentCustomPropertyName&&this.varResolutionState.cycleMembers.has(this.currentCustomPropertyName)||e.values.length<2?(this.error=!0,Wt):2===e.values.length?e.values[1]:new si(e.values.slice(1))):(this.error=!0,Wt)}visitSpaceList(e){let t=this.visitValues(e.values);if(this.error)return Wt;if(t===e.values)return e;let i=[];for(let e of t)e instanceof oi?i.push(...e.values):i.push(e);return new oi(i)}visitCommaList(e){let t=this.visitValues(e.values);if(this.error)return Wt;if(t===e.values)return e;let i=[];for(let e of t)e instanceof si?i.push(...e.values):i.push(e);return new si(i)}},Df=class extends Ht{constructor(e,t,i,n){super(),h(this,"context",e),h(this,"resolveViewportUnit",t),h(this,"percentRef",i),h(this,"vertical",n)}visitFunc(e){let t=super.visitFunc(e);if("calc"!==e.name)return t;let i=t.toString().replace(/^calc\b/,"-epubx-expr");if(this.hasUnresolvableUnit(i))return t;let n=ls(this.context.rootScope,new to(i,null),"");if(n instanceof li)try{let e=n.expr.evaluate(this.context);"number"==typeof e&&!isNaN(e)&&(this.isLengthExpr(i)?t=new Jt(e,"px"):/\d[a-z]/i.test(i)||(t=new Qt(e)))}catch(e){R.warn(e)}return t}hasUnresolvableUnit(e){return/\d(%|em|ex|cap|ch|ic|lh|p?v[whbi]|p?vmin|p?vmax)\W|\Wvar\(\s*--/i.test(e)}isLengthExpr(e){return/\d(px|in|pt|pc|cm|mm|q|rem|rlh)\W/i.test(e)}visitNumeric(e){return this.resolveViewportUnit&&Ye(e.unit)||null!=this.context.rootFontSize&&function(e){switch(null==e?void 0:e.toLowerCase()){case"rem":case"rlh":return!0;default:return!1}}(e.unit)?new Jt(e.num*this.context.queryUnitSize(e.unit,!1,this.vertical),"px"):"number"==typeof this.percentRef&&"%"===e.unit?new Jt(e.num*this.percentRef/100,"px"):e}},zf=class extends Df{hasUnresolvableUnit(e){return/\d(%|em|ex|cap|ch|ic|p?v[whbi]|p?vmin|p?vmax)\W|\Wvar\(\s*--/i.test(e)}isLengthExpr(e){return/\d(px|in|pt|pc|cm|mm|q|rem|r?lh)\W/i.test(e)}};function Vf(e,t,i,n,r){try{if(t instanceof li)return t.expr instanceof It&&(t.expr.str.startsWith("named-string-")||t.expr.str.startsWith("running-element-"))?t:cs(e,t.expr,i);if(t instanceof Jt||t instanceof ai||t instanceof oi||t instanceof si)return t.visit(new Df(e,!0,n,r))}catch(e){return R.warn(e),Wt}return t}var Uf={first:!1,forceEnd:!1,allowEnd:!1,last:!1};function Hf(e){let t=e instanceof $t?e:"string"==typeof e?Zt(e):di.none;if(t===di.none)return Uf;let i=t instanceof oi?t.values:[t],n=Object.create(Uf);for(let e of i)if(e instanceof Kt)switch(e.name){case"first":n.first=!0;break;case"force-end":n.forceEnd=!0,n.allowEnd=!1;break;case"allow-end":n.forceEnd=!1,n.allowEnd=!0;break;case"last":n.last=!0}return n}function $f(e){return!(e.first||e.last||e.forceEnd||e.allowEnd)}var jf={trimStart:!1,spaceFirst:!1,trimEnd:!1,allowEnd:!1,trimAdjacent:!1},Wf={trimStart:!1,spaceFirst:!1,trimEnd:!1,allowEnd:!0,trimAdjacent:!0},Gf={trimStart:!0,spaceFirst:!1,trimEnd:!0,allowEnd:!1,trimAdjacent:!0};function qf(e){let t=e instanceof $t?e:"string"==typeof e?Zt(e):di.normal;if(t===di.normal)return Wf;if(t===di.auto)return Gf;let i=t instanceof oi?t.values:[t],n=Object.create(Wf);for(let e of i)if(e instanceof Kt)switch(e.name){case"trim-both":case"trim-auto":return Gf;case"space-all":return jf;case"trim-start":n.trimStart=!0,n.spaceFirst=!1;break;case"space-start":n.trimStart=!1,n.spaceFirst=!1;break;case"space-first":n.trimStart=!1,n.spaceFirst=!0;break;case"trim-end":n.trimEnd=!0,n.allowEnd=!1;break;case"space-end":n.trimEnd=!1,n.allowEnd=!1;break;case"allow-end":n.trimEnd=!1,n.allowEnd=!0;break;case"trim-adjacent":n.trimAdjacent=!0;break;case"space-adjacent":n.trimAdjacent=!1}return n}var Xf={ideographAlpha:!1,ideographNumeric:!1},Yf={ideographAlpha:!0,ideographNumeric:!0};function Kf(e){let t=e instanceof $t?e:"string"==typeof e?Zt(e):di.normal;if(t===di.normal||t===di.auto)return Yf;if(t===di.none)return Xf;let i=t instanceof oi?t.values:[t],n=Object.create(Xf);for(let e of i)if(e instanceof Kt)switch(e.name){case"no-autospace":return Xf;case"ideograph-alpha":n.ideographAlpha=!0;break;case"ideograph-numeric":n.ideographNumeric=!0}return n}function Zf(e,t){return!(e.ideographAlpha||e.ideographNumeric||t.trimStart||t.spaceFirst||t.trimEnd||t.allowEnd||t.trimAdjacent)}function Jf(e){return e?(e=e.toLowerCase(),/^zh\b.*-(hant|tw|hk)\b/.test(e)?"zh-hant":/^zh\b/.test(e)?"zh-hans":/^ja\b/.test(e)?"ja":/^ko\b/.test(e)?"ko":e):null}var Qf=/^[‘’“”〰﹙﹚﹛﹜﹝﹞〚〛]\p{M}*$/u,eg=/^[‘“﹙﹛﹝〚]\p{M}*$/u,tg=new class{getPolyfilledInheritedProps(){return["hanging-punctuation","text-autospace","text-spacing-trim"]}preprocessSingleDocument(e){e.body&&this.preprocessForTextSpacing(e.body)}preprocessForTextSpacing(e){var t;let i=e.ownerDocument.createNodeIterator(e,NodeFilter.SHOW_TEXT);for(let e=i.nextNode();e;e=i.nextNode()){let i=e.parentElement;if(!i||"http://www.w3.org/1999/xhtml"!==i.namespaceURI||"true"===(null==(t=i.dataset)?void 0:t.mathTypeset))continue;let n=e.textContent.replace(/(?![()\[\]{}])[\p{Ps}\p{Pe}\p{Pf}\p{Pi}、。,.:;、。\u3000\u3030]\p{M}*(?=\P{M})|.(?=(?![()\[\]{}])[\p{Ps}\p{Pe}\p{Pf}\p{Pi}、。,.:;、。\u3000\u3030])|(?!\p{P})[\p{sc=Han}\u3041-\u30FF\u31C0-\u31FF]\p{M}*(?=(?![\p{sc=Han}\u3041-\u30FF\u31C0-\u31FF\uFF01-\uFF60])[\p{L}\p{Nd}])|(?![\p{sc=Han}\u3041-\u30FF\u31C0-\u31FF\uFF01-\uFF60])[\p{L}\p{Nd}]\p{M}*(?=(?!\p{P})[\p{sc=Han}\u3041-\u30FF\u31C0-\u31FF])/gsu,"$&\0").split("\0");if(n.length>1){let t=n.length-1;for(let i=0;i<t;i++)e.before(document.createTextNode(n[i]));e.textContent=n[t]}}}processGeneratedContent(e,t,i,n,r,o){r=Jf(r);let s=Kf(t),a=qf(i),l=Hf(n);if($f(l)&&Zf(s,a))return;this.preprocessForTextSpacing(e);let h=e.style.whiteSpace;0===(o?e.offsetHeight:e.offsetWidth)&&(e.style.whiteSpace="pre");let u=e.ownerDocument.createNodeIterator(e,NodeFilter.SHOW_TEXT),c=null,d=null;for(let e=u.nextNode();e;e=d){d=u.nextNode();let t=!c,i=!c||/\n$/.test(c.textContent),n=!d||/^\n/.test(d.textContent),h=!d;this.processTextSpacing(e,t||i,t,i,n,h,c,d,s,a,l,r,o),c=e}e.style.whiteSpace=h}postLayoutBlock(e,t){var i,n,r,o,s,a,l,h;let u=!e||1===e.fragmentIndex&&function(){let e=t[0];for(let t=e;;t=t.parent)if(!t||!t.inline){if(1!==(null==t?void 0:t.fragmentIndex))return!1;break}if(!e.inline)return!0;for(let t=e.viewNode.previousSibling;t;t=t.previousSibling)if(!Qs(t,e.whitespace)&&!d(t))return!1;return!0}(),c=u||function(){var e;let i=function(){var e;for(let i=t[0];i&&i.inline;i=i.parent){let t=null==(e=i.viewNode)?void 0:e.previousSibling,n=t&&t.nodeType===Node.TEXT_NODE&&/^[ \t\r\n\f]*$/.test(t.textContent)&&i.whitespace!==Zs.PRESERVE?t.previousSibling:t;if(n)return{nodeContext:i,prevNode:n}}return null}();if(!i)return!1;let n=i.nodeContext;for(let t=i.prevNode;t;t=t.lastChild)if(t.nodeType===Node.ELEMENT_NODE){if("br"===t.localName)return!0;let i=null==(e=t.style)?void 0:e.display;if(i&&"inline"!==i)return!/^(inline|ruby)\b/.test(i)}else if(t.nodeType===Node.TEXT_NODE)if(n.whitespace===Zs.PRESERVE){if(/\n$/.test(t.textContent))return!0}else if(n.whitespace===Zs.NEWLINE&&/\n[ \t\r\n\f]*$/.test(t.textContent))return!0;return!1}();function d(e){var t;if(1!==(null==e?void 0:e.nodeType))return!1;let i=e;if(i.hasAttribute(Za))return!0;let{position:n,float:r}=null!=(t=i.style)?t:{};return"absolute"===n||"fixed"===n||!(!r||"none"===r)}let p=-1;for(let f=0;f<t.length;f++){let g=t[f],m=g.after||!g.inline||g.display?null:xa(g);if(m&&m.viewNode.parentNode&&!Qs(m.viewNode,m.whitespace)){let g=function(e){var t,i,n;if((null==(t=e.viewNode)?void 0:t.nodeType)===Node.ELEMENT_NODE)return"br"===e.viewNode.localName;if((null==(i=e.viewNode)?void 0:i.nodeType)===Node.TEXT_NODE){let t=e.viewNode;if(e.whitespace===Zs.PRESERVE){if(/\n$/.test(t.textContent))return!0}else if(e.whitespace===Zs.NEWLINE&&/\n[ \t\r\n\f]*$/.test(t.textContent))return!0;if("br"===(null==(n=t.previousElementSibling)?void 0:n.localName))return Qs(t,e.whitespace)}return!1},v=function(e){var t,i,n;if((null==(t=e.viewNode)?void 0:t.nodeType)===Node.ELEMENT_NODE)return"br"===e.viewNode.localName;if((null==(i=e.viewNode)?void 0:i.nodeType)===Node.TEXT_NODE){let t=e.viewNode;if(e.whitespace===Zs.PRESERVE){if(/^\n/.test(t.textContent))return!0}else if(e.whitespace===Zs.NEWLINE&&/^[ \t\r\n\f]*\n/.test(t.textContent))return!0;if("br"===(null==(n=t.nextElementSibling)?void 0:n.localName))return Qs(t,e.whitespace)}return!1};p<0&&(p=f);let y=Jf(null!=(o=null!=(n=null!=(i=m.lang)?i:m.parent.lang)?n:null==e?void 0:e.lang)?o:null==(r=null==e?void 0:e.parent)?void 0:r.lang),b=Kf(m.inheritedProps["text-autospace"]),w=qf(m.inheritedProps["text-spacing-trim"]),x=Hf(m.inheritedProps["hanging-punctuation"]);if($f(x)&&Zf(b,w)||/\b(flex|grid)\b/.test(null!=(s=m.parent.display)?s:""))continue;let S=null,C=null,k=f===p,P=f===p&&u,E=f===p&&c,N=!1,T=!1;for(let e=f-1;e>=0;e--){let i=t[e];if(g(i)){E=!0;break}if(!i.display&&i.viewNode.nodeType===Node.TEXT_NODE&&i.viewNode.textContent.length>0){S=i.viewNode;break}if((null==(a=i.viewNode)?void 0:a.nodeType)===Node.ELEMENT_NODE&&"footnote-call"===og(i.viewNode)){if(i.viewNode.contains(m.viewNode))continue;let e=sl(i.viewNode);if(e){S=e;break}}if(i.display&&!/^(inline|ruby)\b/.test(i.display)||(null==(l=i.viewNode)?void 0:l.nodeType)===Node.ELEMENT_NODE&&("br"===i.viewNode.localName||ze[i.viewNode.localName]))break;0===e&&(k=!0,u&&(P=!0,E=!0))}for(let e=f+1;e<t.length;e++){let i=t[e];if(v(i)){N=!0;break}if(i.viewNode!==m.viewNode&&!i.display&&i.viewNode.nodeType===Node.TEXT_NODE&&i.viewNode.textContent.length>0){C=i.viewNode;break}if(i.display&&!/^(inline|ruby)\b/.test(i.display)||(null==(h=i.viewNode)?void 0:h.nodeType)===Node.ELEMENT_NODE&&("br"===i.viewNode.localName||ze[i.viewNode.localName])){e===t.length-1&&d(i.viewNode)&&(T=!0);break}if(e===t.length-1){N=!0,T=!0;for(let e=i.viewNode.nextSibling;e;e=e.nextSibling)if(!d(e)){T=!1;break}}}if("inline-block"===m.parent.display){let e=Sa(m.parent);if(!P){let t=e.viewNode.firstChild;for(;Qs(t,m.whitespace);)t=t.nextSibling;m.viewNode===t&&(P=!0)}if(!T){let t=e.viewNode.lastChild;for(;Qs(t,m.whitespace);)t=t.previousSibling;m.viewNode===t&&(T=!0)}}if(this.processTextSpacing(m.viewNode,k,P,E,N,T,S,C,b,w,x,y,m.vertical)>0)break}}}processTextSpacing(e,t,i,n,r,o,s,a,l,h,u,c,d){var p,f;let g,m,v,y=e.textContent,b=e.ownerDocument,w=0;function x(){if(t)return!0;if(!s)return!1;g||(g=b.createRange(),g.selectNode(e));let i=g.getClientRects()[0];if(!i)return!1;m||(m=b.createRange(),m.selectNode(s));let n=m.getClientRects(),r=n[n.length-1];return!!r&&(w||(w=Da(r,d)),d?i.top<r.top+r.height-i.width||i.left+i.width<r.left+i.width/10||i.left>r.left+r.width-i.width/10:i.left<r.left+r.width-i.height||i.top>r.top+r.height-i.height/10||i.top+i.height<r.top+i.height/10)}function S(){if(!a)return!1;g||(g=b.createRange(),g.selectNode(e));let t=g.getClientRects()[0];if(!t)return!1;w||(w=Da(t,d)),v||(v=b.createRange(),v.selectNode(a));let i=v.getClientRects()[0];return!!i&&(d?t.top+t.height>i.top+t.width||t.left>i.left+i.width-t.width/10||t.left+t.width<i.left+t.width/10:t.left+t.width>i.left+t.height||t.top+t.height<i.top+t.height/10||t.top>i.top+i.height-t.height/10)}let C,k=!1,P=!1,E=!1,N=!1,T=function(e,t){return"chromium"===X&&t&&Qf.test(e)}(y,d);if(i&&u.first&&/^[\p{Ps}\p{Pf}\p{Pi}'"\u3000]\p{M}*$/u.test(y)?(C="viv-ts-open",P=!0):o&&u.last&&/^[\p{Pe}\p{Pf}\p{Pi}'"]\p{M}*$/u.test(y)?(C="viv-ts-close",E=!0):(u.forceEnd||u.allowEnd)&&/^[、。,.、。]\p{M}*$/u.test(y)?(C="viv-ts-close",N=!0):(h.trimStart||h.spaceFirst||h.trimAdjacent)&&/^[‘“〝([{⦅〈〈《「『【〔〖〘〚]\p{M}*$/u.test(y)?C="viv-ts-open":(h.trimEnd||h.allowEnd||h.trimAdjacent)&&(/^[’”〞〟)]}⦆〉〉》」』】〕〗〙〛]\p{M}*$/u.test(y)||"zh-hans"===c&&/^[:;]\p{M}*$/u.test(y)||"zh-hant"!==c&&/^[、。,.]\p{M}*$/u.test(y))?C="viv-ts-close":T&&(C=function(e){return eg.test(e)?"viv-ts-open":"viv-ts-close"}(y),k=!0),void 0!==C){let t=function(e){let t=.7*parseFloat(b.defaultView.getComputedStyle(e).fontSize);return(d?e.offsetHeight:e.offsetWidth)>t},l=function(){return d?c.offsetLeft:c.offsetTop};if("viv-ts-inner"===(null==(p=e.parentElement)?void 0:p.localName))return 0;let c=b.createElement(C),g=b.createElement("viv-ts-inner");if(c.appendChild(g),e.before(c),g.appendChild(e),T&&"mixed"===b.defaultView.getComputedStyle(c).textOrientation&&(g.style.textOrientation="sideways"),k)return 0;let m=t(g);if(m||P||E||N)if("viv-ts-open"===C)if(P)c.className="viv-hang-first";else if(i||n)h.trimStart?c.className="viv-ts-trim":c.className="viv-ts-space";else if(h.trimStart||h.spaceFirst||!x()){if(h.trimAdjacent&&s&&/[\p{Ps}\p{Pi}\p{Pe}\p{Pf}\u00B7\u2027\u30FB\u3000:;、。,.]\p{M}*$/u.test(s.textContent)&&(!/[\p{Pe}\p{Pf}]\p{M}*$/u.test(s.textContent)||"viv-ts-inner"===(null==(f=s.parentElement)?void 0:f.localName)&&t(s.parentElement)))c.className="viv-ts-trim";else if((h.trimStart||h.spaceFirst)&&x()){let e=l();c.className="viv-ts-auto",e===l()&&!x()&&(c.className="viv-ts-trim")}}else c.className="viv-ts-space";else if("viv-ts-close"===C)if(E)c.className=m?"viv-hang-last":"viv-hang-last viv-hang-hw";else if(o||r){let e=l();N?(c.className=m?u.allowEnd&&h.allowEnd?"viv-ts-auto":"viv-hang-end":"viv-hang-end viv-hang-hw",u.allowEnd&&e===l()&&(h.trimEnd?c.className="viv-ts-trim":h.allowEnd?(c.className="viv-hang-end",e===l()&&(c.className="")):c.className="viv-ts-space")):h.trimEnd?c.className="viv-ts-trim":h.allowEnd?(c.className="viv-ts-auto",e===l()&&(c.className="")):c.className="viv-ts-space"}else if(a&&/^[\p{Pe}\p{Pf}\u00B7\u2027\u30FB\u3000:;、。,.]/u.test(a.textContent))m&&h.trimAdjacent&&(c.className="viv-ts-trim");else if(N){let e=S(),t=e&&u.allowEnd;t||(c.className=m?"viv-hang-end":"viv-hang-end viv-hang-hw"),m?t&&h.trimEnd?c.className="viv-ts-auto":t||S()?!e&&u.allowEnd&&(h.trimEnd?(c.className="viv-ts-auto",S()||(c.className="viv-hang-end")):(c.className="viv-ts-space",S()||(h.allowEnd?(c.className="viv-ts-auto",S()||(c.className="viv-hang-end")):c.className="viv-hang-end"))):c.className="":!e&&!S()&&(c.className="")}else if(h.trimEnd||h.allowEnd)if(S())h.allowEnd?c.className="viv-ts-space":c.className="viv-ts-auto";else{let e=l();c.className="viv-ts-auto",e===l()&&(c.className="")}}function I(e){var t;let i=null==(t=null==e?void 0:e.ownerDocument.defaultView)?void 0:t.getComputedStyle(e);return!!i&&("upright"===i.textOrientation||"all"===i.textCombineUpright||"horizontal"===i["-webkit-text-combine"])}function A(e,t){if(e.nodeType===Node.ELEMENT_NODE){let t=b.defaultView.getComputedStyle(e);if(parseFloat(t.marginInlineEnd)||parseFloat(t.borderInlineEndWidth)||parseFloat(t.paddingInlineEnd))return!0}let i=e.parentElement;if(i&&!i.contains(t))return A(i,t);if(t.nodeType===Node.ELEMENT_NODE){let e=b.defaultView.getComputedStyle(t);if(parseFloat(e.marginInlineStart)||parseFloat(e.borderInlineStartWidth)||parseFloat(e.paddingInlineStart))return!0}let n=t.parentElement;return!(!n||n.contains(e))&&A(e,n)}return(l.ideographAlpha||l.ideographNumeric)&&(s&&/^(?!\p{P})[\p{sc=Han}\u3041-\u30FF\u31C0-\u31FF]/u.test(y)&&(l.ideographAlpha&&/(?![\p{sc=Han}\u3041-\u30FF\u31C0-\u31FF\uFF01-\uFF60])\p{L}\p{M}*$/u.test(s.textContent)||l.ideographNumeric&&/(?![\uFF01-\uFF60])\p{Nd}\p{M}*$/u.test(s.textContent))&&!(d&&null!==s.parentElement&&I(s.parentElement))&&!A(s,e)&&e.before(b.createElement("viv-ts-thin-sp")),a&&/(?!\p{P})[\p{sc=Han}\u3041-\u30FF\u31C0-\u31FF]\p{M}*$/u.test(y)&&(l.ideographAlpha&&/^(?![\p{sc=Han}\u3041-\u30FF\u31C0-\u31FF\uFF01-\uFF60])\p{L}/u.test(a.textContent)||l.ideographNumeric&&/^(?![\uFF01-\uFF60])\p{Nd}/u.test(a.textContent))&&!(d&&null!==a.parentElement&&I(a.parentElement))&&!A(e,a)&&e.after(b.createElement("viv-ts-thin-sp"))),w}registerHooks(){_("POLYFILLED_INHERITED_PROPS",this.getPolyfilledInheritedProps.bind(this)),_("PREPROCESS_SINGLE_DOCUMENT",this.preprocessSingleDocument.bind(this)),_("POST_LAYOUT_BLOCK",this.postLayoutBlock.bind(this),!0)}};tg.registerHooks();var ig=(new DOMParser).parseFromString('<root xmlns="http://www.pyroxy.com/ns/shadow"/>',"text/xml"),ng=["footnote-marker","marker","first-5-lines","first-4-lines","first-3-lines","first-2-lines","first-line","first-letter","before","footnote-call","","after"],rg="data-adapt-pseudo";function og(e){return e.getAttribute(rg)||""}function sg(e,t){e.setAttribute(rg,t)}var ag=class{constructor(e,t,i,n,r){h(this,"element",e),h(this,"style",t),h(this,"styler",i),h(this,"context",n),h(this,"exprContentListener",r),h(this,"contentProcessed",{}),h(this,"afterStyleTaken",!1)}getStyle(e,t){let i=og(e);!this.afterStyleTaken&&i&&i.match(/after$/)&&(this.style=this.styler.getStyle(this.element,!0),this.afterStyleTaken=!0);let n=jd(this.style,"_pseudos"),r=(null==n?void 0:n[i])||{};if(i.match(/^first-/)&&!r["x-first-pseudo"]){let e,t=1;"first-letter"==i?t=0:null!=(e=i.match(/^first-([0-9]+)-lines$/))&&(t=e[1]-0),r["x-first-pseudo"]=new Cd(new ei(t),0)}return r}processContent(e,t,i){let n=og(e);if(!this.contentProcessed[n]){this.contentProcessed[n]=!0;let i=t.content;Oa(i)&&(i.visit(new Ra(e,this.context,i,this.exprContentListener)),function(e){tg.preprocessForTextSpacing(e)}(e))}}};Ms.isInstanceOfAfterIfContinuesLayoutConstraint;var lg=Jc.registerFragmentIndex;Jc.clearFragmentIndices;var hg=class{constructor(e,t){h(this,"sourceNode",e),h(this,"styler",t)}createElement(e,t){let i=t.viewNode.ownerDocument.createElement("div"),n=new vg(e,i,t),r=n.getColumn().pageBreakType;return n.getColumn().pageBreakType=null,n.layout(this.createNodePositionForPseudoElement(),!0).thenAsync(()=>{this.styler.contentProcessed["after-if-continues"]=!1,n.getColumn().pageBreakType=r;let e=i.firstChild;return be(e,"display","block"),so(e)})}createNodePositionForPseudoElement(){let e=ig.createElementNS("http://www.w3.org/1999/xhtml","div");sg(e,"after-if-continues");let t=this.createShadowContext(e),i={steps:[{node:e,shadowType:t.type,shadowContext:t,nodeShadow:null,shadowSibling:null}],offsetInNode:0,after:!1,preprocessedTextContent:null};return new Ea(i)}createShadowContext(e){return new pa(this.sourceNode,e,null,null,null,Vs.ShadowType.ROOTED,this.styler)}},ug=class e{constructor(e,t,i){h(this,"nodeContext",e),h(this,"afterIfContinues",t),h(this,"pseudoElementHeight",i),h(this,"flagmentLayoutConstraintType","AfterIfContinue")}allowLayout(e,t,i){return!(t&&!e||e&&e.overflow)}nextCandidate(e){return!1}postLayout(e,t,i,n){}finishBreak(e,t){return this.getRepetitiveElements().affectTo(e)?this.afterIfContinues.createElement(t,this.nodeContext).thenAsync(e=>(this.nodeContext.viewNode.appendChild(e),so(!0))):so(!0)}getRepetitiveElements(){return new cg(this.nodeContext,this.pseudoElementHeight)}equalsTo(t){return t instanceof e&&this.afterIfContinues==t.afterIfContinues}getPriorityOfFinishBreak(){return 9}},cg=class{constructor(e,t){h(this,"nodeContext",e),h(this,"pseudoElementHeight",t)}calculateOffset(e){return this.affectTo(e)?this.pseudoElementHeight:0}calculateMinimumOffset(e){return this.calculateOffset(e)}affectTo(e){if(!e)return!1;let t=e.shadowContext?e.shadowContext.owner:e.sourceNode;if(t===this.nodeContext.sourceNode)return!!e.after;for(let e=t.parentNode;e;e=e.parentNode)if(e===this.nodeContext.sourceNode)return!0;return!1}};function dg(e,t){let i=e&&function(e){var t;return null!==e.afterIfContinues&&1===(null==(t=e.viewNode)?void 0:t.nodeType)?e:null}(e);if(!i||i.after||t.asFloatNodeContext(i))return so(e);let n=i.afterIfContinues,r=i;return n.createElement(t,r).thenAsync(i=>{let o=function(e,t,i){let n=e.viewNode;n.appendChild(i);let r=Xa(i,t,e.vertical);return n.removeChild(i),r}(r,t,i);return t.fragmentLayoutConstraints.push(new ug(r,n,o)),so(e)})}function pg(e,t){return e.thenAsync(e=>dg(e,t))}var fg=class{constructor(e){h(this,"constraints",e)}allowLayout(e){return this.constraints.every(t=>t.allowLayout(e))}},gg=class extends eh{constructor(e,t){super(),h(this,"checkPoints",e),h(this,"penalty",t),h(this,"alreadyEvaluated",!1),h(this,"breakNodeContext",null)}findAcceptableBreak(e,t){return t<this.getMinBreakPenalty()?null:(this.alreadyEvaluated||(this.breakNodeContext=e.findBoxBreakPosition(this,t>0),this.alreadyEvaluated=!!this.breakNodeContext||t>0||!!e.pseudoParent),this.breakNodeContext)}getMinBreakPenalty(){return this.penalty}getNodeContext(){return this.alreadyEvaluated?this.breakNodeContext:this.checkPoints[this.checkPoints.length-1]}},mg=class extends Fa{constructor(e,t,i,n,r,o,s,a,l){super(e),h(this,"layoutContext",t),h(this,"clientLayout",i),h(this,"layoutConstraint",n),h(this,"flowRootFormattingContext",l),h(this,"last"),h(this,"viewDocument"),h(this,"isNonFirstColumn",!1),h(this,"isFloat",!1),h(this,"isFootnote",!1),h(this,"startEdge",0),h(this,"endEdge",0),h(this,"beforeEdge",0),h(this,"afterEdge",0),h(this,"footnoteEdge",0),h(this,"chunkPositions",[]),h(this,"bands"),h(this,"overflown",!1),h(this,"breakPositions",[]),h(this,"pageBreakType",null),h(this,"forceNonfitting",!0),h(this,"leftFloatEdge",0),h(this,"rightFloatEdge",0),h(this,"bottommostFloatTop",0),h(this,"stopAtOverflow",!0),h(this,"lastAfterPosition",null),h(this,"fragmentLayoutConstraints",[]),h(this,"pseudoParent",null),h(this,"nodeContextOverflowingDueToRepetitiveElements",null),h(this,"blockDistanceToBlockEndFloats",NaN),h(this,"lastLineStride",0),h(this,"breakAtTheEdgeBeforeFloat",null),h(this,"lineFootnoteOverflowEdge",null),h(this,"pageFloatLayoutContext"),function(e){e.element.setAttribute("data-vivliostyle-column","true")}(this),this.last=e.lastChild,this.viewDocument=e.ownerDocument,this.pageFloatLayoutContext=r.withContainer(this),Aa(o,this),this.innerShape=s,this.exclusions=a,this.bands=this.measure(),this.createFloats()}getTopEdge(){return this.vertical?this.rtl?this.endEdge:this.startEdge:this.beforeEdge}getBottomEdge(){return this.vertical?this.rtl?this.startEdge:this.endEdge:this.afterEdge}getLeftEdge(){return this.vertical?this.afterEdge:this.rtl?this.endEdge:this.startEdge}getRightEdge(){return this.vertical?this.beforeEdge:this.rtl?this.startEdge:this.endEdge}asFloatNodeContext(e){let t=Sa(e);return t&&t.floatSide&&(!this.isFloat||t.parent)?t:null}stopByOverflow(e){return this.stopAtOverflow&&!!e&&e.overflow}almostEquals(e,t,i=(0===this.clientLayout.pixelRatio?.5:1.5/(this.clientLayout.pixelRatio||1))){return Math.abs(e-t)<i}getFloatLayoutUnit(){return 0===this.clientLayout.pixelRatio?0:1/(this.clientLayout.pixelRatio||1)}getFloatLayoutTolerance(e){return e||1}isOverflown(e){let t=1.5/(this.clientLayout.pixelRatio||1);return!this.almostEquals(e,this.footnoteEdge,t)&&(this.vertical?e<this.footnoteEdge:e>this.footnoteEdge)}getExclusions(){let e=this.pageFloatLayoutContext.getFloatFragmentExclusions();return this.exclusions.concat(e)}openAllViews(e){let t=oo("openAllViews"),i=e.steps;this.layoutContext.setViewRoot(this.element,this.isFootnote);let n=i.length-1,r=null;return t.loop(()=>{for(;n>=0;){let t=r;if(r=t?la(i[n],t):ha(ca(e),this.flowRootFormattingContext),0==n&&(r.offsetInNode=this.calculateOffsetInNodeForNodeContext(e),r.after=e.after,r.preprocessedTextContent=e.preprocessedTextContent,r.after))break;let o=this.layoutContext.setCurrent(r,0==n&&0==r.offsetInNode);if(n--,o.isPending())return o}return so(!1)}).then(()=>{t.finish(r)}),t.result()}calculateOffsetInNodeForNodeContext(e){return e.preprocessedTextContent?function(e,t){return $s(e,t,1)}(e.preprocessedTextContent,e.offsetInNode):e.offsetInNode}maybePeelOff(e,t){var i,n,r;if(e.firstPseudo&&e.inline&&!e.after&&0==e.firstPseudo.count){let t=xa(e);if(t){let o=t.viewNode,s=o.textContent,a=s.match(Y),l=a?a[0].length:0;if(!a&&3===(null==(i=e.sourceNode)?void 0:i.nodeType)&&3===(null==(n=e.sourceNode.nextSibling)?void 0:n.nodeType)&&s===e.sourceNode.textContent){let t=s+e.sourceNode.nextSibling.textContent,i=t.match(Y);if(i){let n=i[0];l=n.length,e.sourceNode.textContent=n,o.textContent=n,e.sourceNode.nextSibling.textContent=t.substr(l)}}if(l>0){let e=null!=(r=o.textContent)?r:"";o.textContent=e.substr(0,l)}return this.layoutContext.peelOff(t,l)}}return so(e)}buildViewToNextBlockEdge(e,t){let i=!1,n=oo("buildViewToNextBlockEdge");return n.loopWithFrame(n=>{var r;let o=ka(e);if(o&&!il(o)&&"http://www.w3.org/1999/xhtml"===(null==(r=o.viewNode.parentElement)?void 0:r.namespaceURI)&&(t.push(o.copy()),t.length>1e3)){let e=1===o.viewNode.nodeType?o.viewNode:o.viewNode.parentElement;if(Da(this.clientLayout.getElementClientRect(e),this.vertical)>=2)return void n.breakLoop()}this.maybePeelOff(e,0).then(r=>{if(r!==e){e=r;let i=ka(r);i&&!il(i)&&t.push(i.copy())}this.nextInTree(e).then(t=>{if(!(e=t))return void n.breakLoop();(i||!this.layoutConstraint.allowLayout(e))&&(i=!0,(e=e.modify()).overflow=!0);let r=this.asFloatNodeContext(e);r&&(vl(r.floatReference)||"footnote"===r.floatSide)?this.layoutFloatOrFootnote(r).then(t=>{e=t,this.pageFloatLayoutContext.isInvalidated()&&(e=null),e?e.pluginProps.lineFootnoteOverflow?n.breakLoop():n.continueLoop():n.breakLoop()}):e.inline?n.continueLoop():n.breakLoop()})})}).then(()=>{n.finish(e)}),n.result()}nextInTree(e,t){return pg(this.layoutContext.nextInTree(e,t),this)}buildDeepElementView(e){if(!e.viewNode)return so(e);let t=[],i=e.sourceNode,n=oo("buildDeepElementView");return n.loopWithFrame(n=>{let r=ka(e);r&&r.inline&&!il(r)?t.push(r.copy()):(t.length>0&&this.postLayoutBlock(e,t),t=[]),this.maybePeelOff(e,0).then(r=>{let o=r;if(o!==e){let r=o;for(;r&&r.sourceNode!=i;)r=r.parent;if(null==r)return e=o,void n.breakLoop();let s=ka(o);s&&!il(s)&&t.push(s.copy())}this.nextInTree(o).then(t=>{if(!(e=t)||e.sourceNode==i)return void n.breakLoop();if(!this.layoutConstraint.allowLayout(e)&&((e=e.modify()).overflow=!0,this.stopAtOverflow))return void n.breakLoop();let r=this.asFloatNodeContext(e);!r||!vl(r.floatReference)&&"footnote"!==r.floatSide?n.continueLoop():this.layoutFloatOrFootnote(r).then(t=>{e=t,this.pageFloatLayoutContext.isInvalidated()&&(e=null),e?n.continueLoop():n.breakLoop()})})})}).then(()=>{t.length>0&&this.postLayoutBlock(e,t),n.finish(e)}),n.result()}createFloat(e,t,i,n){let r=this.viewDocument.createElement("div");return this.vertical?(n>=this.height&&(n-=.1),n<1&&(n=0),be(r,"height",`${i}px`),be(r,"width",`${n}px`)):(i>=this.width&&(i-=.1),i<1&&(i=0),be(r,"width",`${i}px`),be(r,"height",`${n}px`)),be(r,"float",t),be(r,"clear",t),this.element.insertBefore(r,e),r}killFloats(){let e=this.element.firstChild;for(;e;){let t=e.nextSibling;if(1==e.nodeType){let t=e,i=t.style.cssFloat;if("left"!=i&&"right"!=i&&"none"!==i)break;this.element.removeChild(t)}e=t}}createFloats(){let e=this.element.firstChild,t=this.bands,i=this.vertical?this.getTopEdge():this.getLeftEdge(),n=this.vertical?this.getBottomEdge():this.getRightEdge(),r=this.vertical?-this.getRightEdge():this.getTopEdge(),o=this.vertical?-this.getLeftEdge():this.getBottomEdge(),s=null,a=1.5/(this.clientLayout.pixelRatio||1);for(let e of t){let t=Math.abs(e.x1-i)<a&&Math.abs(e.x2-n)<a?a:void 0;this.almostEquals(e.x1,i,t)?e.x1=i:this.almostEquals(e.x1,n,t)&&(e.x1=n),this.almostEquals(e.x2,n,t)?e.x2=n:this.almostEquals(e.x2,i,t)&&(e.x2=i),this.almostEquals(e.y1,r,t)?e.y1=r:this.almostEquals(e.y1,o,t)&&(e.y1=o),this.almostEquals(e.y2,o,t)?e.y2=o:this.almostEquals(e.y2,r,t)&&(e.y2=r)}let l=this.getFloatLayoutUnit(),h="webkit"===X?Math.floor:Math.round,u=t.map(e=>l>0?(h(e.y2/l)-h(e.y1/l))*l:e.y2-e.y1),c=.01;for(let e=0;e<t.length;e++){let r=e<t.length-1?t[e+1].x1:i,o=e<t.length-1?t[e+1].x2:n,s=r-t[e].x1,a=t[e].x2-o,h=0,d=0;s>c?h=1:s<-c&&(h=-1),a>c?d=1:a<-c&&(d=-1);let p=0!==h&&0!==d?h===d?h:0:h||d;if(l>0&&0!==p){let i=p*l;u[e]+i>=0&&(e>=t.length-1||u[e+1]-i>=0)&&(u[e]+=i,e<t.length-1&&(u[e+1]-=i))}}for(let r=0;r<t.length;r++){let o=t[r];o.left=this.createFloat(e,"left",o.x1-i,u[r]),o.right=this.createFloat(e,"right",n-o.x2,u[r]),o.x1<n&&o.x2>i?s=o:s||be(o.right,"float","none")}if(s){let e=t[t.length-1],r=1.5/(this.clientLayout.pixelRatio||1);if(s!==e&&(e.y2>=o||this.almostEquals(e.y2,o,r))&&(this.footnoteEdge=this.vertical?-s.y2:s.y2,s.x1===i&&s.x2===n))for(let e=t.indexOf(s);e<t.length;e++){let i=t[e];this.element.removeChild(i.left),this.element.removeChild(i.right),i.left=null,i.right=null}}this.adjustColumnBlockSizeForBlockEndFloats()}adjustColumnBlockSizeForBlockEndFloats(){var e;if(this.element.hasAttribute("data-vivliostyle-in-column-balancing")||null!=(e=this.element.parentElement)&&e.hasAttribute("data-vivliostyle-in-column-balancing"))return;let t=this.vertical?this.width:this.height,i=this.getBoxDir()*(this.footnoteEdge-this.beforeEdge),n=1.5/(this.clientLayout.pixelRatio||1);if(i>0&&i<t&&!this.almostEquals(i,t,n)){let e=this.vertical?"width":"height";if(be(this.element,e,`${i}px`),this.vertical){let e=this.left+(t-i);be(this.element,"left",`${e}px`)}this.element.setAttribute("data-vivliostyle-column-block-size-adjusted","true")}}calculateEdge(e,t,i,n){let r;if(e&&Ya(e.viewNode))return NaN;if(e&&e.after&&!e.inline&&(r=qa(e,this.clientLayout,0,this.vertical),!isNaN(r)))return r;let o=n-(e=t[i]).boxOffset;for(;;){if(r=qa(e,this.clientLayout,o,this.vertical),!isNaN(r))return r;if(o>0){o--;continue}if(--i<0)return this.beforeEdge;let n=t[i];e=n,1!=n.viewNode.nodeType&&(o=n.viewNode.textContent.length)}}parseComputedLength(e){let t=e.match(/^(-?[0-9]*(\.[0-9]*)?)px$/);return t?this.clientLayout.adjustLengthValue(parseFloat(t[0])):0}getComputedMargin(e){let t=this.clientLayout.getElementComputedStyle(e),i=new sn(0,0,0,0);return t&&(i.left=this.parseComputedLength(t.marginLeft),i.top=this.parseComputedLength(t.marginTop),i.right=this.parseComputedLength(t.marginRight),i.bottom=this.parseComputedLength(t.marginBottom)),i}getComputedPaddingBorder(e){let t=this.clientLayout.getElementComputedStyle(e),i=new sn(0,0,0,0);return t&&(i.left=this.parseComputedLength(t.borderLeftWidth)+this.parseComputedLength(t.paddingLeft),i.top=this.parseComputedLength(t.borderTopWidth)+this.parseComputedLength(t.paddingTop),i.right=this.parseComputedLength(t.borderRightWidth)+this.parseComputedLength(t.paddingRight),i.bottom=this.parseComputedLength(t.borderBottomWidth)+this.parseComputedLength(t.paddingBottom)),i}getComputedInsets(e){let t=this.clientLayout.getElementComputedStyle(e),i=new sn(0,0,0,0);if(t){if("border-box"==t.boxSizing)return this.getComputedMargin(e);i.left=this.parseComputedLength(t.marginLeft)+this.parseComputedLength(t.borderLeftWidth)+this.parseComputedLength(t.paddingLeft),i.top=this.parseComputedLength(t.marginTop)+this.parseComputedLength(t.borderTopWidth)+this.parseComputedLength(t.paddingTop),i.right=this.parseComputedLength(t.marginRight)+this.parseComputedLength(t.borderRightWidth)+this.parseComputedLength(t.paddingRight),i.bottom=this.parseComputedLength(t.marginBottom)+this.parseComputedLength(t.borderBottomWidth)+this.parseComputedLength(t.paddingBottom)}return i}setComputedInsets(e,t){let i=this.clientLayout.getElementComputedStyle(e);i&&(t.marginLeft=this.parseComputedLength(i.marginLeft),t.borderLeft=this.parseComputedLength(i.borderLeftWidth),t.paddingLeft=this.parseComputedLength(i.paddingLeft),t.marginTop=this.parseComputedLength(i.marginTop),t.borderTop=this.parseComputedLength(i.borderTopWidth),t.paddingTop=this.parseComputedLength(i.paddingTop),t.marginRight=this.parseComputedLength(i.marginRight),t.borderRight=this.parseComputedLength(i.borderRightWidth),t.paddingRight=this.parseComputedLength(i.paddingRight),t.marginBottom=this.parseComputedLength(i.marginBottom),t.borderBottom=this.parseComputedLength(i.borderBottomWidth),t.paddingBottom=this.parseComputedLength(i.paddingBottom))}setComputedWidthAndHeight(e,t){let i=this.clientLayout.getElementComputedStyle(e);i&&(t.width=this.parseComputedLength(i.width),t.height=this.parseComputedLength(i.height))}layoutUnbreakable(e){return this.buildDeepElementView(e)}layoutFloat(e){let t=oo("layoutFloat"),i=e.viewNode,n=yl(e.floatSide,e.vertical,e.direction,this.layoutContext.page.side);return be(i,"float","none"),be(i,"display","inline-block"),be(i,"vertical-align","top"),this.buildDeepElementView(e).then(r=>{let o=Ua(this.clientLayout,i,this.vertical),s=this.getComputedMargin(i),a=new rn(o.left-s.left,o.top-s.top,o.right+s.right,o.bottom+s.bottom),l=this.rtl?this.endEdge:this.startEdge,h=this.rtl?this.startEdge:this.endEdge,u=e.parent;for(;u&&u.inline;)u=u.parent;let c=u&&ka(u);if(c){let t=c.viewNode,r=t.ownerDocument.createElement("div");r.style.left="0px",r.style.top="0px",this.vertical?(r.style.bottom="0px",r.style.width="1px"):(r.style.right="0px",r.style.height="1px"),t.appendChild(r);let o=Ua(this.clientLayout,r,this.vertical);l=Math.max(this.rtl?this.getEndEdge(o):this.getStartEdge(o),l),h=Math.min(this.rtl?this.getStartEdge(o):this.getEndEdge(o),h),t.removeChild(r);let s=this.vertical?a.y2-a.y1:a.x2-a.x1;"left"==n?h=Math.max(h,l+s):l=Math.min(l,h-s),u!==e.parent&&!e.firstPseudo&&(t.appendChild(i),i.setAttribute("data-vivliostyle-float-box-moved","true"))}let d=new rn(l,this.getBoxDir()*this.beforeEdge,h,this.getBoxDir()*this.afterEdge),p=a;this.vertical&&(p=bn(a));let f=this.getBoxDir();if(p.y1<this.bottommostFloatTop*f){let e=p.y2-p.y1;p.y1=this.bottommostFloatTop*f,p.y2=p.y1+e}if(e.clearSide){let t=/^(top|bottom|inside|outside|(block|inline)-(start|end))$/.test(e.clearSide)?yl(e.clearSide,e.vertical,e.direction,this.layoutContext.page.side):"same"===e.clearSide?n:e.clearSide,i=this.beforeEdge;"right"!==t&&(i=f*Math.max(i*f,this.leftFloatEdge*f)),"left"!==t&&(i=f*Math.max(i*f,this.rightFloatEdge*f));let r=i*f;if(p.y1<r){let e=p.y2-p.y1;p.y1=r,p.y2=p.y1+e}}d.y2+=this.getFloatLayoutUnit(),function(e,t,i,n){let r=i.y1,o=i.x2-i.x1,s=i.y2-i.y1,a=Cn(t,r);for(;;){let l=r+s;if(l>e.y2)return!1;let h=e.x1,u=e.x2;for(let e=a;e<t.length&&t[e].y1<l;e++){let i=t[e];i.x1>h&&(h=i.x1),i.x2<u&&(u=i.x2)}if(h+o<=u||a>=t.length)return"left"==n?(i.x1=h,i.x2=h+o):(i.x1=u-o,i.x2=u),i.y2+=r-i.y1,i.y1=r,!0;r=t[a].y2,a++}}(d,this.bands,p,n),this.vertical&&(a=wn(p));let g=this.getComputedInsets(i);be(i,"width",a.x2-a.x1-g.left-g.right+"px"),be(i,"height",a.y2-a.y1-g.top-g.bottom+"px"),be(i,"position","absolute"),e.display,be(i,"display",e.display);let m,v=u?u.containingBlockForAbsolute?Sa(u):u.getContainingBlockForAbsolute():null;if(v){let e=v.viewNode,t=e.ownerDocument.createElement("div");t.style.position="absolute",v.vertical?t.style.right="0":t.style.left="0",t.style.top="0",e.appendChild(t),m=Ua(this.clientLayout,t,this.vertical),e.removeChild(t)}else m={left:this.getLeftEdge()-this.paddingLeft,right:this.getRightEdge()+this.paddingRight,top:this.getTopEdge()-this.paddingTop};if(v?v.vertical:this.vertical){let e=Math.max(0,m.right-a.x2);be(i,"right",`${e}px`)}else{let e=Math.max(0,a.x1-m.left);be(i,"left",`${e}px`)}let y=Math.max(0,a.y1-m.top);be(i,"top",`${y}px`),e.clearSpacer&&(e.clearSpacer.remove(),e.clearSpacer=null);let b=this.vertical?a.x1:a.y2,w=this.vertical?a.x2:a.y1;this.isOverflown(b)&&0!=this.breakPositions.length?((e=e.modify()).overflow=!0,t.finish(e)):(this.killFloats(),d=new rn(this.getLeftEdge(),this.getTopEdge(),this.getRightEdge(),this.getBottomEdge()),this.vertical&&(d=bn(d)),function(e,t,i,n,r){for(n||(n=[new ln(i.y1,i.y2,i.x1,i.x2)]);n.length>0&&n[0].y2<=e.y1;)n.shift();if(0==n.length)return;n[0].y1<e.y1&&(n[0].y1=e.y1);let o,s=0==t.length?e.y1:t[t.length-1].y2;s<e.y2&&t.push(new ln(s,e.y2,e.x1,e.x2));let a=Cn(t,n[0].y1);for(let i of n){if(a==t.length)break;for(t[a].y1<i.y1&&(o=t[a],a++,t.splice(a,0,new ln(i.y1,o.y2,o.x1,o.x2)),o.y2=i.y1);a<t.length&&(o=t[a++],o.y2>i.y2&&(t.splice(a,0,new ln(i.y2,o.y2,o.x1,o.x2)),o.y2=i.y2),i.x1!=i.x2&&("left"==r?o.x1=Math.min(i.x2,e.x2):o.x2=Math.max(i.x1,e.x1)),o.y2!=i.y2););}Sn(e,t)}(d,this.bands,p,null,n),this.createFloats(),"left"==n?this.leftFloatEdge=b:this.rightFloatEdge=b,this.bottommostFloatTop=w,this.updateMaxReachedAfterEdge(b),t.finish(r))}),t.result()}setupFloatArea(e,t,i,n,r,o){let s=this.pageFloatLayoutContext,a=s.getPageFloatLayoutContext(t).container,l=e.element;return r.adjustPageFloatArea(e,a,this).thenAsync(()=>{e.killFloats(),e.remeasure();let r=!!s.setFloatAreaDimensions(e,t,i,n,!0,e.isFootnote||!s.hasFloatFragments(),o);if(r){if(e.isFootnote){let t=getComputedStyle(e.element);if(e.vertical){let i=parseFloat(t.maxWidth);!isNaN(i)&&e.width>i&&(e.width=i,be(e.element,"width",`${i}px`))}else{let i=parseFloat(t.maxHeight);!isNaN(i)&&e.height>i&&(e.height=i,be(e.element,"height",`${i}px`))}}e.killFloats(),e.remeasure()}else l.remove();return so(r)})}createPageFloatArea(e,t,i,n,r){let o=this.element.ownerDocument.createElement("div");be(o,"position","absolute");let s=this.pageFloatLayoutContext.getPageFloatLayoutContext(e.floatReference),a=kl.createDetached(this.pageFloatLayoutContext,ml.COLUMN,this.pageFloatLayoutContext.flowName,e.nodePosition),l=s.container,h=this.pageFloatLayoutContext.getPageFloatLayoutContext(e.floatReference).container;h.element.parentNode.appendChild(o);let u=h.getPaddingRect(),c=u.x1-h.originX,d=u.y1-h.originY;be(o,"left",`${c}px`),be(o,"top",`${d}px`);let p=new Sg(t,o,this.layoutContext.clone(),this.clientLayout,this.layoutConstraint,a,l,{vertical:h.vertical,rtl:h.rtl,snapWidth:0,snapHeight:0,originX:h.originX,originY:h.originY,left:c,top:d,width:u.x2-u.x1,height:u.y2-u.y1,marginLeft:0,marginRight:0,marginTop:0,marginBottom:0,borderLeft:0,borderRight:0,borderTop:0,borderBottom:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,borderBoxSizing:!1},null,(h.exclusions||[]).concat(),this.flowRootFormattingContext);return p.isFloat=!0,p.forceNonfitting=!this.pageFloatLayoutContext.hasFloatFragments(),this.setupFloatArea(p,e.floatReference,t,i,n,r).thenAsync(e=>so(e?p:null))}layoutSinglePageFloatFragment(e,t,i,n,r,o,s){let a=this.pageFloatLayoutContext,l=(e=(s?s.continuations:[]).concat(e))[0].float,h=a.getPageFloatPlacementCondition(l,t,i),u={floatArea:null,pageFloatFragment:null,newPosition:null},c=oo("layoutSinglePageFloatFragment");return this.createPageFloatArea(l,t,o,r,h).then(d=>{if(u.floatArea=d,!d)return void c.finish(u);let p=!1,f=0;c.loopWithFrame(t=>{if(f>=e.length)return void t.breakLoop();let i=e[f],r=new Ea(i.nodePosition),o=d.getRootViewNodeCount();d.layout(r,!0).then(e=>{if(u.newPosition=e,!e||n){if(e&&d.isFootnote&&d.breakPositions&&(!d.breakPositions.some(e=>e instanceof gg)||!d.hasNonPseudoTextContentAfter(o)))return p=!0,void t.breakLoop();f++,t.continueLoop()}else p=!0,t.breakLoop()})}).then(()=>{if(!p&&d.isFootnote&&d.computedBlockSize<=0&&u.newPosition){let h=a.getPageFloatLayoutContext(l.floatReference);if(null==h.footnoteMaxBlockSize){if(h.initFootnoteRetryFromEmptyFragment(l,d))return d.element.parentNode&&d.element.parentNode.removeChild(d.element),void this.layoutSinglePageFloatFragment(e,t,i,n,r,o,s).then(e=>{c.finish(e)});p=!0}}if(!p){d.isFootnote&&d.applyCompactFootnoteDisplay();let s=a.setFloatAreaDimensions(d,l.floatReference,t,o,!1,n,h);if(s){let t=r.createPageFloatFragment(e,s,i,d,!!u.newPosition);a.addPageFloatFragment(t,!0),u.pageFloatFragment=t}else p=!0}c.finish(u)})}),c.result()}layoutPageFloatInner(e,t,i,n){let r=this.pageFloatLayoutContext,o=e.float,s=o instanceof $l,a=s&&o.footnotePolicy===di.line&&!!n&&!n.hasFloat(o),l=new Set;for(let e=r;e;e=e.effectiveParent)for(let t of e.floatFragments)t.continuations.some(e=>e.float.insidePageFloatArea)&&l.add(t);function h(t,i){i?r.removePageFloatFragment(i,!0):t&&t.element.parentNode.removeChild(t.element);let n=[];for(let e=r;e;e=e.effectiveParent)for(let t of e.floatFragments)!l.has(t)&&t.continuations.some(e=>e.float.insidePageFloatArea)&&n.push(t);for(let e of n)r.removePageFloatFragment(e,!0);r.restoreStashedFragments(o.floatReference),r.deferPageFloat(e)}a||r.stashEndFloatFragments(o);let u=oo("layoutPageFloatInner");return this.layoutSinglePageFloatFragment([e],o.floatSide,o.clearSide,s||!r.hasFloatFragments(),t,i,a?null:n).then(e=>{let t=e.floatArea,s=e.pageFloatFragment,l=e.newPosition;s?this.layoutStashedPageFloats(o.floatReference,[n]).then(e=>{if(e){let e=s;if(a&&n){let a=n.area,l=a.getRootViewNodeCount();if(a.appendContentFrom(s.area),r.removePageFloatFragment(s,!0),!r.setFloatAreaDimensions(a,o.floatReference,n.floatSide,i,!1,!0,r.getPageFloatPlacementCondition(o,o.floatSide,o.clearSide)))return a.removeContentAfter(l),h(t,s),void u.finish(!1);n.addContinuations(s.continuations),e=n}let c=!!r.generatingNodePosition,d=!c&&o instanceof $l&&o.footnotePolicy===di.line,p=d&&r.hasInvalidatedForLineFootnote(o);if(r.addPageFloatFragment(e,c||p),d&&!p&&r.markInvalidatedForLineFootnote(o),r.discardStashedFragments(o.floatReference),l){let e=new Sl(o,l.primary);r.deferPageFloat(e)}u.finish(!0)}else h(t,s),u.finish(!1)}):(h(t,s),u.finish(!1))}),u.result()}layoutStashedPageFloats(e,t){let i=this.pageFloatLayoutContext,n=i.getStashedFloatFragments(e),r=[],o=[],s=!1,a=oo("layoutStashedPageFloats"),l=0;return a.loopWithFrame(e=>{if(l>=n.length)return void e.breakLoop();let i=n[l];if(t.includes(i))return l++,void e.continueLoop();let a=(new Al).findByFloat(i.continuations[0].float);this.layoutSinglePageFloatFragment(i.continuations,i.floatSide,i.clearSide,!1,a,null).then(t=>{let i=t.floatArea;i&&r.push(i);let n=t.pageFloatFragment;n?(o.push(n),l++,e.continueLoop()):(s=!0,e.breakLoop())})}).then(()=>{s?(o.forEach(e=>{i.removePageFloatFragment(e,!0)}),r.forEach(e=>{let t=e.element;t&&t.parentNode&&t.parentNode.removeChild(t)})):n.forEach(e=>{let t=e.area.element;t&&t.parentNode&&t.parentNode.removeChild(t)}),a.finish(!s)}),a.result()}findFootnoteCallElement(e){let t=e.previousSibling;for(;t;){if(t.nodeType===Node.ELEMENT_NODE&&"footnote-call"===og(t))return t;t=t.previousSibling}return null}setFloatAnchorViewNode(e){let t=e.viewNode.ownerDocument.createElement("span");if(t.setAttribute(Za,"1"),"footnote"===e.floatSide){let i=this.findFootnoteCallElement(e.viewNode);i?t=i:e.viewNode.before(t)}else e.viewNode.parentNode.appendChild(t);e.viewNode.remove();let i=e.modify();return i.after=!0,i.viewNode=t,"footnote"===e.floatSide&&(i.display="inline"),i}resolveFloatReferenceFromColumnSpan(e,t,i){let n=oo("resolveFloatReferenceFromColumnSpan"),r=this.pageFloatLayoutContext,o=r.getPageFloatLayoutContext(ml.REGION);return r.container.width<o.container.width&&e===ml.COLUMN?t===di.auto?this.buildDeepElementView(i.copy()).then(t=>{let i=t.viewNode,r=gl(this.clientLayout,i,["min-content inline size"])["min-content inline size"],o=this.getComputedMargin(i);this.vertical?r+=o.top+o.bottom:r+=o.left+o.right,r>this.width?n.finish(ml.REGION):n.finish(e)}):t===di.all?n.finish(ml.REGION):n.finish(e):n.finish(e),n.result()}layoutPageFloat(e){let t,i=this.pageFloatLayoutContext,n=(new Al).findByNodeContext(e),r=i.findPageFloatByNodePosition(e.toNodePosition());return t=r?so(r):n.createPageFloat(e,i,this),t.thenAsync(t=>{let r=aa(e,0),o=this.setFloatAnchorViewNode(e);i.markPageFloatAnchorSeen(t);let s=n.findPageFloatFragment(t,i),a=new Sl(t,r);if(s&&s.hasFloat(t))return i.registerPageFloatAnchor(t,o.viewNode),so(o);if(i.isForbidden(t)||i.hasPrecedingFloatsDeferredToNext(t))return i.deferPageFloat(a),i.registerPageFloatAnchor(t,o.viewNode),so(o);if(this.nodeContextOverflowingDueToRepetitiveElements)return so(null);{let r=e=>{if(!e||1!==e.nodeType)return NaN;let t=Ua(this.clientLayout,e,this.vertical);return t.right>=t.left&&t.bottom>=t.top?this.vertical?t.left:t.bottom:NaN},l=qa(o,this.clientLayout,0,this.vertical);if("footnote"===e.floatSide){let e=t;if(e.footnotePolicy===di.line||isNaN(l)){let t=o;for(;t;){if((t.shadowContext?t.shadowContext.owner:t.sourceNode)===e.policyAnchorNode){let e=r(t.viewNode);isNaN(e)||(l=e);break}t=t.parent}}}return isNaN(l)&&"footnote"===e.floatSide&&(l=r(o.viewNode)),"footnote"===e.floatSide&&t.footnotePolicy===di.line||!this.isOverflown(l)?("footnote"===e.floatSide&&i.registerPageFloatAnchor(t,o.viewNode),this.layoutPageFloatInner(a,n,l,s).thenAsync(r=>{if(!r)return i.registerPageFloatAnchor(t,o.viewNode),so(o);if("footnote"===e.floatSide){if(t.footnotePolicy===di.line&&i.hasInvalidatedForLineFootnote(t)){if(i.isInvalidated())return so(null);let e=n.findPageFloatFragment(t,i);if(null!=e&&e.hasFloat(t)&&e.continues)return this.registerLineFootnoteOverflowEdge(l),so(o)}return so(o)}return i.generatingNodePosition?so(o):so(null)})):so(o)}})}processLineStyling(e,t,i){let n=oo("processLineStyling"),r=i.concat([]);i.splice(0,i.length);let o=0,s=e.firstPseudo;return 0===(null==s?void 0:s.count)&&(s=s.outer),n.loopWithFrame(i=>{if(!s)return void i.breakLoop();let n=this.findLinePositions(r),a=s.count-o;if(n.length<=a)return void i.breakLoop();let l=this.findAcceptableBreakInside(r,n[a-1],!0),h=l&&va(l);h?this.finishBreak(h,!1,!1).then(()=>{o+=a,this.layoutContext.peelOff(h,0).then(n=>{s=(e=n).firstPseudo,r=[],this.buildViewToNextBlockEdge(e,r).then(e=>{t=e,i.continueLoop()})})}):i.breakLoop()}).then(()=>{Array.prototype.push.apply(i,r),n.finish(t)}),n.result()}registerLineFootnoteOverflowEdge(e){if(!isFinite(e))return;let t=this.getBoxDir();(null==this.lineFootnoteOverflowEdge||t*e<t*this.lineFootnoteOverflowEdge)&&(this.lineFootnoteOverflowEdge=e)}findLineFootnoteOverflowBreak(e){if(null==this.lineFootnoteOverflowEdge||0===e.length)return null;let t=this.findLinePositions(e),i=this.getBoxDir(),n=1.5/(this.clientLayout.pixelRatio||1),r=t.find(e=>i*(e-this.lineFootnoteOverflowEdge)>=-n);return null==r?null:this.findAcceptableBreakInside(e,r,!0)}isLoneImage(e){return!(2!=e.length&&this.breakPositions.length>0)&&(e[0].sourceNode==e[1].sourceNode&&ze[e[0].sourceNode.localName])}getTrailingMarginEdgeAdjustment(e){let t=0,i=0;for(let n=e.length-1;n>=0;n--){let r=e[n];if(!r||!r.after||!r.viewNode||1!=r.viewNode.nodeType)break;let o=this.getComputedMargin(r.viewNode),s=this.vertical?-o.left:o.bottom;s>0?t=Math.max(t,s):i=Math.min(i,s)}return t+i}layoutBreakableBlock(e){let t=oo("layoutBreakableBlock"),i=[];return this.lineFootnoteOverflowEdge=null,this.buildViewToNextBlockEdge(e,i).then(n=>{let r=i.length-1;if(r<0)return void t.finish(n);this.postLayoutBlock(n,i);let o=this.suppressOpenAncestorBlockEndInset(null!=n?n:e),s=this.calculateEdge(n,i,r,i[r].boxOffset);o();let a,l=!1;if(!n||!Ya(n.viewNode)){let e=th(n,this.collectElementsOffset());l=this.isOverflown(s+(this.vertical?-1:1)*e.minimum),this.isOverflown(s+(this.vertical?-1:1)*e.current)&&!this.nodeContextOverflowingDueToRepetitiveElements&&(this.nodeContextOverflowingDueToRepetitiveElements=n)}null==n&&(s+=this.getTrailingMarginEdgeAdjustment(i)),this.updateMaxReachedAfterEdge(s),a=e.firstPseudo?this.processLineStyling(e,n,i):so(n),a.then(e=>{let n=this.findLineFootnoteOverflowBreak(i);if(n){let e=n.modify();return e.overflow=!0,e.pluginProps.lineFootnoteOverflow=1,this.breakPositions=[],this.saveEdgeBreakPosition(e,null,!0),this.lineFootnoteOverflowEdge=null,void t.finish(e)}this.lineFootnoteOverflowEdge=null,i.length>0&&(this.saveBoxBreakPosition(i),l&&!this.isLoneImage(i)&&e&&((e=e.modify()).overflow=!0)),t.finish(e)})}),t.result()}postLayoutBlock(e,t){M("POST_LAYOUT_BLOCK").forEach(i=>{i(e,t,this)})}findEndOfLine(e,t,i){let n,r=this.vertical?e-1:e+1,o=0,s=t[0].boxOffset,a=o,l=t.length-1,h=t[l].boxOffset;for(;s<h;){n=s+Math.ceil((h-s)/2),a=o;let e=l;for(;a<e;){let i=a+Math.ceil((e-a)/2);t[i].boxOffset>n?e=i-1:a=i}let u=this.calculateEdge(null,t,a,n);if(this.vertical?u<=r:u>=r){for(h=n-1;t[a].boxOffset==n;)a--;l=a}else i&&this.updateMaxReachedAfterEdge(u),s=n,o=a}return{nodeContext:t[a],index:s,checkPointIndex:a}}findAcceptableBreakInside(e,t,i){var n,r,o;let s=this.findEndOfLine(t,e,!0),a=s.nodeContext,l=a;if(0===s.checkPointIndex&&s.index===l.boxOffset)return null;let h=a.viewNode;if(1!=h.nodeType&&"viv-ts-inner"!==(null==(n=h.parentElement)?void 0:n.localName)){let t=h;l=this.resolveTextNodeBreaker(l).breakTextNode(t,a,s.index,e,s.checkPointIndex,i)}else{let e=rl(l);if(e){if((null==(r=this.breakPositions)?void 0:r[0])instanceof gg&&e.viewNode.contains(this.breakPositions[0].checkPoints[0].viewNode))return null;for(l=e;!l.after&&l.inline&&l.parent;){let e=null==(o=l.viewNode)?void 0:o.previousSibling;for(;e&&(Qs(e,l.parent.whitespace)||Qa(e));)e=e.previousSibling;if(e)break;l=l.parent}}}return this.clearOverflownViewNodes(l,!1),l}resolveTextNodeBreaker(e){return M("RESOLVE_TEXT_NODE_BREAKER").reduce((t,i)=>i(e)||t,yg.instance)}getRangeBoxes(e,t){let i=[],n=e.ownerDocument.createRange(),r=!1,o=e,s=null,a=!1,l=!0;for(;l;){let e=!0;do{let i=null;o==t&&(l=1===t.nodeType&&!(!t.firstChild||r));let h=1===o.nodeType?o:null;h?r?r=!1:Ja(h)?e=!a:!h.firstChild||ze[h.localName]||/^r(uby|[bt]c?)$/.test(h.localName)||nl(this.clientLayout.getElementComputedStyle(h).display)?(e=!a,e?("ruby"===h.localName&&o.firstChild&&(o=o.firstChild),n.setStartBefore(o),a=!0,s=o):/^r(uby|tc?)$/.test(h.localName)||(s=o),o.contains(t)&&(l=!1)):i=o.firstChild:(a||(null==o.parentNode?l=!1:(n.setStartBefore(o),a=!0)),s=o),i||(i=o.nextSibling,i||(r=!0,i=o.parentNode)),o=i}while(e&&l);if(a){n.setEndAfter(s);let e=this.clientLayout.getRangeClientRects(n);Va(e,this.vertical);for(let t=0;t<e.length;t++)i.push(e[t]);a=!1}}return i}findLinePositions(e){let t=[],i=this.getRangeBoxes(e[0].viewNode,e[e.length-1].viewNode);i.sort(this.vertical?ra:na);let n=0,r=0,o=0,s=0,a=0,l=this.getBoxDir();for(;;){if(a<i.length){let e=i[a],t=1;if(s>0){let i=Math.max(this.getBoxSize(e),1);t=l*this.getBeforeEdge(e)<l*n?l*(this.getAfterEdge(e)-n)/i:l*this.getAfterEdge(e)>l*r?l*(r-this.getBeforeEdge(e))/i:1}if(0==s||t>=.6||t>=.2&&this.getStartEdge(e)>=o-1){o=this.getEndEdge(e),this.vertical?(n=0==s?e.right:Math.max(n,e.right),r=0==s?e.left:Math.min(r,e.left)):(n=0==s?e.top:Math.min(n,e.top),r=0==s?e.bottom:Math.max(r,e.bottom)),s++,a++;continue}}if(s>0&&(t.push(r),s=0),a>=i.length)break}return t.sort(_e),this.vertical&&t.reverse(),t}calculateClonedPaddingBorder(e){let t=0;for(let i=e;i;i=i.parent)if(!i.inline&&xs(i.viewNode)){let e=this.getComputedPaddingBorder(i.viewNode);t+=i.vertical?-e.left:e.bottom,"table"===i.display&&(t+=(i.vertical?-1:1)*i.blockBorderSpacing)}return t}getOffsetByRepetitiveElements(e){let t;return t=e?e.calculateOffset(this):th(null,this.collectElementsOffset()),t.current}findBoxBreakPosition(e,t){var i,n;let r=this.element.parentNode,o=this.element.nextSibling;r.removeChild(this.element),r.insertBefore(this.element,o);let s,a,l=e.checkPoints,h=l[0];for(;h.parent&&h.inline;)h=h.parent;t&&!this.isFootnote?(s=1,a=1):(s=Math.max((h.inheritedProps.widows||2)-0,1),a=Math.max((h.inheritedProps.orphans||2)-0,1));let u=this.calculateClonedPaddingBorder(h),c=this.findLinePositions(l),d=this.footnoteEdge-u,p=this.getBoxDir(),f=this.getOffsetByRepetitiveElements(e);d-=p*f;let g=this.findFirstOverflowingEdgeAndCheckPoint(l);isNaN(g.edge)&&(g.edge=p*(1/0));let m=Le(c.length,e=>{let t=c[e];return this.vertical?t<d||t<=g.edge:t>d||t>=g.edge}),v=m<=0;v&&(m=Le(c.length,e=>this.vertical?c[e]<d:c[e]>d));let y,b=l[l.length-1].viewNode;if(b=null!=(i=ol(b))?i:b,(m===c.length&&b.nextSibling||m>=c.length-1&&null!=(n=b.parentElement)&&n.querySelector(".MJXc-display"))&&(s=0,a=1),m=Math.min(c.length-s,m),m<a)return null;if(d=c[m-1],y=v?g.checkPoint:this.findAcceptableBreakInside(e.checkPoints,d,t),y){let e=this.getAfterEdgeOfBlockContainer(y);if(!isNaN(e)&&p*(d-e)>0&&(d=e),this.computedBlockSize=p*(d-this.beforeEdge)+f,c.length>=2){let e=Math.max(1,Math.min(m-1,c.length-1));this.lastLineStride=Math.abs(c[e]-c[e-1])}}return y}getAfterEdgeOfBlockContainer(e){let t=e;do{t=t.parent}while(t&&t.inline);return t?(t=t.copy().modify(),t.after=!0,qa(t,this.clientLayout,0,this.vertical)):NaN}findFirstOverflowingEdgeAndCheckPoint(e){let t=e.findIndex(e=>e.overflow);if(t<0)return{edge:NaN,checkPoint:null};let i=e[t];return{edge:this.calculateEdge(null,e,t,i.boxOffset),checkPoint:i}}findEdgeBreakPosition(e){return this.computedBlockSize=e.computedBlockSize+this.getOffsetByRepetitiveElements(e),e.position}finishBreak(e,t,i){let n=(new nh).find(e.formattingContext).finishBreak(this,e,t,i);return n||(n=sh.finishBreak(this,e,t,i)),n}findAcceptableBreakPosition(){let e=null,t=0,i=0;do{t=i,i=Number.MAX_VALUE;for(let n=this.breakPositions.length-1;n>=0&&!e;--n){let r=this.breakPositions[n],o=r.findAcceptableBreak(this,t);o&&(e={breakPosition:r,nodeContext:o});let s=r.getMinBreakPenalty();s>t&&(i=Math.min(i,s))}}while(i>t&&!e&&this.forceNonfitting);return e}doFinishBreak(e,t,i,n){if(this.pageFloatLayoutContext.isInvalidated()||this.pageBreakType||!t)return so(e);let r=oo("doFinishBreak"),o=!1;if(!e){if(this.forceNonfitting&&!this.isFootnote)return R.warn("Could not find any page breaks?!!"),this.skipTailEdges(t).then(e=>{e?((e=e.modify()).overflow=!1,this.finishBreak(e,o,!0).then(()=>{r.finish(e)})):r.finish(e)}),r.result();e=i,o=!0,this.computedBlockSize=n}return this.finishBreak(e,o,!0).then(()=>{r.finish(e)}),r.result()}isBreakable(e){for(let t=e;t;t=t.parent)if(Qa(t.viewNode))return!1;return!!e.after||"http://www.w3.org/2000/svg"!==e.sourceNode.namespaceURI&&!e.flexContainer}isZeroLength(e){let t=e.trim();return""===t||/^0+(?:\.0+)?(?:[a-z%]*)$/i.test(t)}hasNonZeroBlockStartInset(e){return this.vertical?!(this.isZeroLength(e.paddingRight)&&this.isZeroLength(e.borderRightWidth)):!(this.isZeroLength(e.paddingTop)&&this.isZeroLength(e.borderTopWidth))}hasNonZeroBlockEndInset(e){return this.vertical?!(this.isZeroLength(e.paddingLeft)&&this.isZeroLength(e.borderLeftWidth)):!(this.isZeroLength(e.paddingBottom)&&this.isZeroLength(e.borderBottomWidth))}suppressOpenAncestorBlockEndInset(e){if(!Ma(this))return()=>{};let t=[];for(let i=null==e?void 0:e.parent;i;i=i.parent){if(i.after||i.inline)continue;let e=i.viewNode;if(!e||1!==e.nodeType||xs(e))continue;let n=this.clientLayout.getElementComputedStyle(e);if(n&&!this.hasNonZeroBlockEndInset(n))continue;let r=e.getAttribute("data-viv-box-break");ks(e,"block-end"),t.push({element:e,original:r})}return()=>{for(let{element:e,original:i}of t)null===i?e.removeAttribute("data-viv-box-break"):e.setAttribute("data-viv-box-break",i)}}checkOverflowAndSaveEdge(e,t){if(!e)return!1;for(let t=e;t;t=t.parent)if(Qa(t.viewNode))return!1;if(Ya(e.viewNode))return!1;let i=this.suppressOpenAncestorBlockEndInset(e),n=qa(e,this.clientLayout,0,this.vertical);i();let r=th(e,this.collectElementsOffset()),o=this.isOverflown(n+(this.vertical?-1:1)*r.minimum);if(this.isOverflown(n+(this.vertical?-1:1)*r.current)&&!this.nodeContextOverflowingDueToRepetitiveElements)this.nodeContextOverflowingDueToRepetitiveElements=e;else if(t){let e=n+this.getTrailingMarginEdgeAdjustment(t),i=this.footnoteEdge-this.getBoxDir()*r.current;n=this.vertical?Math.min(n,Math.max(e,i)):Math.max(n,Math.min(e,i))}return this.updateMaxReachedAfterEdge(n),o}checkOverflowAndSaveEdgeAndBreakPosition(e,t,i,n){if(!e||Ya(e.viewNode))return!1;let r=this.checkOverflowAndSaveEdge(e,t);return(i||!r)&&this.saveEdgeBreakPosition(e,n,r),r}applyClearance(e){var t;if(!e.viewNode.parentNode||e.floatReference!==ml.INLINE||e.floatSide)return!1;let i=null!=(t="same"===e.clearSide?e.floatSide:e.clearSide)?t:"",n=/^(page|column|region)$/.test(i),r=this.getComputedMargin(e.viewNode),o=e.viewNode.ownerDocument.createElement("div");this.vertical?(o.style.bottom="0px",o.style.width="1px",o.style.marginRight=`${r.right}px`):(o.style.right="0px",o.style.height="1px",o.style.marginTop=`${r.top}px`);let s=()=>n?this.clientLayout.getElementClientRect(o):Ua(this.clientLayout,o,this.vertical);e.viewNode.parentNode.insertBefore(o,e.viewNode);let a=s(),l=this.getBeforeEdge(a),h=this.getBoxDir(),u=/^(top|bottom|inside|outside|(block|inline)-(start|end))$/.test(i)?yl(i,e.vertical,e.direction,this.layoutContext.page.side):i,c="left"===u||"right"===u?"rtl"===e.direction==("left"===u)?"inline-end":"inline-start":u,d=this.pageFloatLayoutContext.getPageFloatClearEdge(c,this),p=d;switch(u){case"left":d=h*Math.max(d*h,this.leftFloatEdge*h);break;case"right":d=h*Math.max(d*h,this.rightFloatEdge*h);break;default:d=h*Math.max(d*h,Math.max(this.rightFloatEdge*h,this.leftFloatEdge*h))}let f=this.getFloatLayoutUnit(),g=this.leftFloatEdge*h>this.beforeEdge*h||this.rightFloatEdge*h>this.beforeEdge*h;if(f>0&&g){let e=d*h>p*h;d=h*(Math.ceil(d*h/f)+(e?1:0))*f}if(l*h+this.getFloatLayoutTolerance(f)>d*h)return e.viewNode.parentNode.removeChild(o),!1;{let t=Math.max(1,(d-l)*h);this.vertical?o.style.width=`${t}px`:o.style.height=`${t}px`,a=s();let i=this.getAfterEdge(a);if(!e.floatSide)if(this.vertical){let e=i-r.right-d;e>0==r.right>=0&&(e+=r.right),o.style.marginLeft=`${e}px`}else{let e=d-(i+r.top);e>0==r.top>=0&&(e+=r.top),o.style.marginBottom=`${e}px`}return e.clearSpacer=o,!0}}isBFC(e){return!(!ah(e)&&!Ds.isInstanceOfRepetitiveElementsOwnerFormattingContext(e))}hasFixedPositionAncestor(e){for(let t=e;t;t=t.parent)if(tl(t.viewNode))return!0;return!1}skipEdges(e,t,i){var n;let r=e,o=r.after?null==(n=r.parent)?void 0:n.formattingContext:r.formattingContext;if(o&&!this.isBFC(o))return so(r);let s=oo("skipEdges"),a=this,l=!i&&t&&r&&r.after,h=i,u=null,c=[],d=[],p=!1;function f(e){var n,r;if(t&&!a.isNonFirstColumn&&!i&&As(h))for(let t=e;t;t=t.parent)if("column"===t.breakBefore&&(t.breakBefore=null),1===(null==(n=t.viewNode)?void 0:n.nodeType)){let e=t.viewNode;"column"===(null==(r=e.style)?void 0:r.breakBefore)&&(e.style.breakBefore="")}}function g(e){var n,r;if(t&&a.isNonFirstColumn&&!i&&"column"===h){for(let t=e;t;t=t.parent)if("column"===t.breakBefore&&(t.breakBefore=null),1===(null==(n=t.viewNode)?void 0:n.nodeType)){let e=t.viewNode;"column"===(null==(r=e.style)?void 0:r.breakBefore)&&(e.style.breakBefore="")}h=null}}function m(e){var t,n;if(!i&&As(h))for(let i=e;i;i=i.parent)if("column"===i.breakAfter&&(i.breakAfter=null),1===(null==(t=i.viewNode)?void 0:t.nodeType)){let e=i.viewNode;"column"===(null==(n=e.style)?void 0:n.breakAfter)&&(e.style.breakAfter="")}}function v(e){h=Os(h,e)}function y(){return!!i||!!Ns(h)&&(t?a.isNonFirstColumn&&"column"!==h&&"region"!==h:!function(){var e;if(!u||!r||r.floatSide)return!1;for(let t=u;null!=t&&t.parent;t=t.parent){if(t.parent.viewNode&&Qa(t.parent.viewNode))continue;let i=t.after?t.viewNode:null==(e=t.viewNode)?void 0:e.previousSibling;for(;i&&(Qs(i,t.parent.whitespace)||Qa(i));)i=i.previousSibling;if(i)return!1}return!0}()&&!function(){var e,t;if(u||null==r||!r.viewNode||r.shadowContext||r.after||r.floatSide||null==(e=r.parent)||!e.viewNode||Qa(r.parent.viewNode))return!1;let i=!1;for(let e=r;null!=e&&e.parent&&!e.after;e=e.parent){if(e!==r&&Qa(e.viewNode))return!1;let n=null==(t=e.viewNode)?void 0:t.previousSibling;for(;n&&(Qs(n,e.parent.whitespace)||Qa(n));)Qa(n)&&(i=!0),n=n.previousSibling;if(n)return!1}return i}())}let b=e=>{let t=c[0]||e;r=t,t.viewNode.remove(),this.pageBreakType=h};return s.loopWithFrame(e=>{for(var i;r;){let n=(new nh).find(r.formattingContext);do{let o=ka(r);if(!o)break;if(r.inline&&1!=o.viewNode.nodeType){if(Qs(o.viewNode,r.whitespace)||this.hasFixedPositionAncestor(r))break;if(!r.after)return v(r.breakBefore),f(r),g(r),y()?b(o):this.checkOverflowAndSaveEdgeAndBreakPosition(u,null,!0,h)?(r=(this.stopAtOverflow&&u||r).modify(),r.overflow=!0):(!u&&!t&&0===c.length&&this.saveEdgeBreakPosition(r,h,!1),r=r.modify(),r.breakBefore=h),void e.breakLoop()}if(!r.after){if(r.floatSide&&(this.breakAtTheEdgeBeforeFloat=Rs(h)?h:null),n&&n.startNonInlineElementNode(r))break;let i=Ca(r);if(i&&this.applyClearance(i)&&t&&0===this.breakPositions.length&&this.saveEdgeBreakPosition(r.copy(),h,!1),!r.inline&&!r.repeatOnBreak&&(u?rl(u):this.breakPositions[this.breakPositions.length-1]instanceof gg||!t&&0===c.length)&&this.saveEdgeBreakPosition(r.copy(),h,!1),!this.isBFC(r.formattingContext)||Ds.isInstanceOfRepetitiveElementsOwnerFormattingContext(r.formattingContext)||null!==this.asFloatNodeContext(r)||r.flexContainer||!r.nodeShadow&&!r.sourceNode.firstElementChild&&Qs(r.sourceNode.firstChild,r.whitespace))return c.push(o.copy()),v(r.breakBefore),f(r),g(r),y()?b(o):(this.checkOverflowAndSaveEdgeAndBreakPosition(u,null,!0,h)||!this.layoutConstraint.allowLayout(r))&&(r=(this.stopAtOverflow&&u||r).modify(),r.overflow=!0),void e.breakLoop()}let s=Sa(o);if(!s)break;let a=s.viewNode,w=a.style;if(r.after){Ga(a,this),r.floatSide&&(h=null!=h?h:this.breakAtTheEdgeBeforeFloat,this.breakAtTheEdgeBeforeFloat=null);let i=r.sourceNode;if("svg"===i.localName||"math"===i.localName||"true"===i.getAttribute("data-math-typeset")){p=!1,u=s.copy(),d.push(u),h=null,v(r.breakAfter),m(r),this.checkOverflowAndSaveEdgeAndBreakPosition(u,null,!this.stopAtOverflow,h);break}if(r.inline||n&&n.afterNonInlineElementNode(r,this.stopAtOverflow))break;if(p){if(tl(r.viewNode))break;if(y())return b(s),void e.breakLoop();c=[],t=!1,l=!1,h=null}p=!1,el(s.viewNode)||(u=s.copy(),d.push(u)),v(r.breakAfter),m(r),w&&!Qa(r.viewNode)&&this.hasNonZeroBlockEndInset(w)&&(d=u?[u]:[])}else{if(c.push(s.copy()),v(r.breakBefore),f(r),g(r),u&&Ns(h)&&Ha(u.viewNode,s.viewNode),(r.pageType!=(null==(i=r.parent)?void 0:i.pageType)||!Ns(h))&&!this.layoutConstraint.allowLayout(r)&&(this.checkOverflowAndSaveEdgeAndBreakPosition(u,null,!this.stopAtOverflow,h),r=r.modify(),r.overflow=!0,this.stopAtOverflow))return void e.breakLoop();let t=a.localName;if(ze[t])return y()?b(s):this.checkOverflowAndSaveEdgeAndBreakPosition(u,null,!0,h)&&(r=(this.stopAtOverflow&&u||r).modify(),r.overflow=!0),void e.breakLoop();w&&this.hasNonZeroBlockStartInset(w)&&(l=!1,d=[]),p=!0}}while(0);let o=this.nextInTree(r,l);if(o.isPending())return void o.then(t=>{r=t,e.continueLoop()});r=o.get()}this.checkOverflowAndSaveEdgeAndBreakPosition(u,d,!this.stopAtOverflow,h)?u&&this.stopAtOverflow&&(r=u.modify(),r.overflow=!0):Ns(h)&&(this.pageBreakType=h),e.breakLoop()}).then(()=>{u&&(this.lastAfterPosition=u.toNodePosition()),s.finish(r)}),s.result()}skipTailEdges(e){let t=e,i=t.copy(),n=oo("skipEdges"),r=null,o=!1;return n.loopWithFrame(e=>{for(;t;){do{if(!t.viewNode)break;if(t.inline&&1!=t.viewNode.nodeType){if(Qs(t.viewNode,t.whitespace))break;if(!t.after)return Ns(r)&&(this.pageBreakType=r),void e.breakLoop()}if(!t.after&&(null!==this.asFloatNodeContext(t)||t.flexContainer))return r=Os(r,t.breakBefore),Ns(r)&&(this.pageBreakType=r),void e.breakLoop();if(1!=t.viewNode.nodeType)break;let i=t.viewNode,n=i.style;if(t.after){if(o){if(Ns(r))return this.pageBreakType=r,void e.breakLoop();r=null}o=!1,r=Os(r,t.breakAfter)}else{r=Os(r,t.breakBefore);let o=i.localName;if(ze[o])return Ns(r)&&(this.pageBreakType=r),void e.breakLoop();if(n&&this.hasNonZeroBlockStartInset(n))return void e.breakLoop()}o=!0}while(0);let i=this.layoutContext.nextInTree(t);if(i.isPending())return void i.then(i=>{t=i,e.continueLoop()});t=i.get()}i=null,e.breakLoop()}).then(()=>{n.finish(i)}),n.result()}layoutFloatOrFootnote(e){if(vl(e.floatReference)||"footnote"===e.floatSide){let t=this.pageFloatLayoutContext.generatingNodePosition;if(t&&e.sourceNode===t.steps[0].node){let t=e.modify();return t.floatSide=null,t.floatReference=ml.INLINE,t.clearSide=null,this.isBreakable(t)?this.layoutBreakableBlock(t):this.layoutUnbreakable(t)}return this.layoutPageFloat(e)}return this.layoutFloat(e)}layoutNext(e,t,i){let n=oo("layoutNext");return this.skipEdges(e,t,i||null).then(i=>{if(!(e=i)||this.pageBreakType||this.stopByOverflow(e))n.finish(e);else{let i=e.formattingContext;(new nh).find(i).layout(e,this,t).thenFinish(n)}}),n.result()}clearOverflownViewNodes(e,t){if(e)for(let i=e.parent;e;e=i,i=i?i.parent:null){let n=(i||e).formattingContext;(new nh).find(n).clearOverflownViewNodes(this,i,e,t),t=!1}}measure(){be(this.element,"width",`${this.width}px`),be(this.element,"height",`${this.height}px`);let e=this.element.ownerDocument.createElement("div");e.style.position="absolute",e.style.top=`${this.paddingTop}px`,e.style.right=`${this.paddingRight}px`,e.style.bottom=`${this.paddingBottom}px`,e.style.left=`${this.paddingLeft}px`,this.element.appendChild(e);let t=this.clientLayout.getElementClientRect(e);this.element.removeChild(e);let i=this.originX+this.left+this.getInsetLeft(),n=this.originY+this.top+this.getInsetTop(),r=new rn(i,n,i+this.width,n+this.height);return this.startEdge=t?this.vertical?this.rtl?t.bottom:t.top:this.rtl?t.right:t.left:0,this.endEdge=t?this.vertical?this.rtl?t.top:t.bottom:this.rtl?t.left:t.right:0,this.beforeEdge=t?this.vertical?t.right:t.top:0,this.afterEdge=t?this.vertical?t.left:t.bottom:0,this.leftFloatEdge=this.beforeEdge,this.rightFloatEdge=this.beforeEdge,this.bottommostFloatTop=this.beforeEdge,this.footnoteEdge=this.afterEdge,function(e,t,i,n,r,o){o&&(e=bn(e),t=t.map(e=>xn(e)),i=i.map(e=>xn(e)));let s,a,l,h=t.length,u=i?i.length:0,c=[],d=[];for(s=0;s<h;s++)t[s].addSegments(d,s);for(s=0;s<u;s++)i[s].addSegments(d,s+h);let p=d.length;d.sort(hn);let f=0;for(;d[f].shapeId>=h;)f++;let g=d[f].low.y;g>e.y1&&c.push(new ln(e.y1,g,e.x2,e.x2));let m=0,v=[];for(;m<p&&(l=d[m]).low.y<g;)l.high.y>g&&v.push(l),m++;for(;m<p||v.length>0;){let t=e.y2,i=Math.min(vn(Math.ceil(g+n),r),e.y2);for(a=0;a<v.length&&t>i;a++)l=v[a],l.low.x==l.high.x?l.high.y<t&&(t=Math.max(yn(l.high.y,r),i)):l.low.x!=l.high.x&&(t=i);for(t>e.y2&&(t=e.y2);m<p&&(l=d[m]).low.y<t;)if(l.high.y<g)m++;else{if(!(l.low.y<i)){let e=yn(l.low.y,r);e<t&&(t=e);break}l.low.y==l.high.y&&l.low.y==g||(v.push(l),t=i),m++}let o=[];for(a=0;a<v.length;a++)gn(o,v[a],g,t);o.sort((e,t)=>e.x-t.x||e.lowOrHigh-t.lowOrHigh);let s=mn(o,h,u);if(0==s.length)c.push(new ln(g,t,e.x2,e.x2));else{let i=0,n=e.x1;for(a=0;a<s.length;a+=2){let t=Math.max(e.x1,s[a]),r=Math.min(e.x2,s[a+1])-t;r>i&&(i=r,n=t)}0==i?c.push(new ln(g,t,e.x2,e.x2)):c.push(new ln(g,t,Math.max(n,e.x1),Math.min(n+i,e.x2)))}if(t==e.y2)break;for(g=t,a=v.length-1;a>=0;a--)v[a].high.y<=t&&v.splice(a,1)}return Sn(e,c),c}(r,[this.getInnerShape()],this.getExclusions(),8,this.snapHeight,this.vertical)}remeasure(){this.chunkPositions=[],this.bands=this.measure(),this.createFloats(),this.computedBlockSize=0,this.overflown=!1,this.pageBreakType=null,this.lastAfterPosition=null,this.lastLineStride=0}saveEdgeBreakPosition(e,t,i){let n=e.copy(),r=(new nh).find(e.formattingContext),o=this.calculateClonedPaddingBorder(n),s=r.createEdgeBreakPosition(n,t,i,this.computedBlockSize+o);this.breakPositions.push(s)}saveBoxBreakPosition(e){let t=e[0].breakPenalty;if(t){let i=e[0];for(;i.parent&&i.inline;)i=i.parent;t=i.breakPenalty}let i=new gg(e,t);this.breakPositions.push(i)}updateMaxReachedAfterEdge(e){if(!isNaN(e)){let t=this.getBoxDir()*(e-this.beforeEdge);this.computedBlockSize=Math.max(t,this.computedBlockSize)}}layout(e,t,i){if(this.chunkPositions.push(e),e.primary.after&&(this.lastAfterPosition=e.primary),this.stopAtOverflow&&this.overflown)return so(e);if(this.isFullWithPageFloats())return e.primary.after&&1===e.primary.steps.length?so(null):so(e);_a(this);let n=oo("layout");return this.openAllViews(e.primary).then(e=>{let r=null;if(e.viewNode)r=e.copy();else{let e=t=>{t.nodeContext.viewNode&&(r=t.nodeContext,this.layoutContext.removeEventListener("nextInTree",e))};this.layoutContext.addEventListener("nextInTree",e)}let o=new wg(t,i);o.layout(e,this).then(e=>{this.doFinishBreak(e,o.context.overflownNodeContext,r,o.initialComputedBlockSize).then(e=>{let t;t=this.pseudoParent?so(!0):this.doFinishBreakOfFragmentLayoutConstraints(e),t.then(()=>{if(Ma(this)&&(function(e){let t=e.element.querySelectorAll('[data-viv-saved-column-fill="auto"]');for(let i of t)Ga(i,e)}(this),Ba(this)),this.element.hasAttribute("data-vivliostyle-column-block-size-adjusted")&&(this.vertical?(be(this.element,"width",`${this.width}px`),be(this.element,"left",`${this.left}px`)):be(this.element,"height",`${this.height}px`),this.element.removeAttribute("data-vivliostyle-column-block-size-adjusted")),this.pageFloatLayoutContext.isInvalidated())n.finish(null);else if(e){this.overflown=!0;let t=new Ea(e.toNodePosition());n.finish(t)}else n.finish(null)})})})}),n.result()}isFullWithPageFloats(){return this.pageFloatLayoutContext.isColumnFullWithPageFloats(this)}getMaxBlockSizeOfPageFloats(){return this.pageFloatLayoutContext.getMaxBlockSizeOfPageFloats()}doFinishBreakOfFragmentLayoutConstraints(e){let t=oo("doFinishBreakOfFragmentLayoutConstraints"),i=this.fragmentLayoutConstraints.slice();i.sort((e,t)=>e.getPriorityOfFinishBreak()-t.getPriorityOfFinishBreak());let n=0;return t.loop(()=>n<i.length?i[n++].finishBreak(e,this).thenReturn(!0):so(!1)).then(()=>{t.finish(!0)}),t.result()}doLayout(e,t,i){let n=oo("doLayout"),r=null;return this.breakPositions=[],this.nodeContextOverflowingDueToRepetitiveElements=null,n.loopWithFrame(n=>{for(;e;){let o=!0;if(this.layoutNext(e,t,i||null).then(s=>{if(t=!1,i=null,this.nodeContextOverflowingDueToRepetitiveElements&&this.stopAtOverflow?(this.pageBreakType=null,(e=this.nodeContextOverflowingDueToRepetitiveElements).overflow=!0):e=s,this.pageFloatLayoutContext.isInvalidated())n.breakLoop();else if(this.pageBreakType)n.breakLoop();else if(e&&this.stopByOverflow(e)){r=e;let t=this.findAcceptableBreakPosition();e=t&&t.nodeContext,t&&t.breakPosition.breakPositionChosen(this),n.breakLoop()}else o?o=!1:n.continueLoop()}),o)return void(o=!1)}this.computedBlockSize+=this.getOffsetByRepetitiveElements(),n.breakLoop()}).then(()=>{n.finish({nodeContext:e,overflownNodeContext:r})}),n.result()}saveDistanceToBlockEndFloats(){let e=this.pageFloatLayoutContext.getBlockStartEdgeOfBlockEndFloats();e>0&&isFinite(e)&&(this.blockDistanceToBlockEndFloats=this.getBoxDir()*(e-this.beforeEdge-this.computedBlockSize))}collectElementsOffset(){let e=[];for(let t=this;t;t=t.pseudoParent)t.fragmentLayoutConstraints.forEach(t=>{if(Ds.isInstanceOfRepetitiveElementsOwnerLayoutConstraint(t)){let i=t.getRepetitiveElements();e.push(i)}if(Ms.isInstanceOfAfterIfContinuesLayoutConstraint(t)){let i=t.getRepetitiveElements();e.push(i)}zs.isInstanceOfTableRowLayoutConstraint(t)&&t.getElementsOffsetsForTableCell(this).forEach(t=>{e.push(t)})});return e}},vg=class{constructor(e,t,i){h(this,"startNodeContexts",[]),h(this,"column"),h(this,"flowRootSourceNode"),this.flowRootSourceNode=i.sourceNode,this.column=Object.create(e),this.column.element=t,this.column.layoutContext=e.layoutContext.clone(),this.column.stopAtOverflow=!1,this.column.flowRootFormattingContext=i.formattingContext,this.column.pseudoParent=e;let n=this.column.calculateClonedPaddingBorder(i);this.column.footnoteEdge=this.column.footnoteEdge-n;let r=this;this.column.openAllViews=function(e){return mg.prototype.openAllViews.call(this,e).thenAsync(e=>(r.startNodeContexts.push(e.copy()),so(e)))}}layout(e,t){return this.column.layout(e,t)}findAcceptableBreakPosition(){let e=this.column.findAcceptableBreakPosition(),t=this.startNodeContexts[0].copy(),i=new ih(t,null,t.overflow,0);return i.findAcceptableBreak(this.column,0),null!=e?e:{breakPosition:i,nodeContext:t}}finishBreak(e,t,i){return this.column.finishBreak(e,t,i)}doFinishBreakOfFragmentLayoutConstraints(e){this.column.doFinishBreakOfFragmentLayoutConstraints(e)}isStartNodeContext(e){let t=this.startNodeContexts[0];return t.viewNode===e.viewNode&&t.after===e.after&&t.offsetInNode===e.offsetInNode}isLastAfterNodeContext(e){return sa(e.toNodePosition(),this.column.lastAfterPosition)||this.isEffectivelyLastAfterNodeContext(e)}isEffectivelyLastAfterNodeContext(e){var t;let i=this.flowRootSourceNode,n=e.sourceNode;if(!(i&&n&&e.after&&(i===n||null!=(t=i.contains)&&t.call(i,n))))return!1;if(n.nodeType===Node.TEXT_NODE){let t=n;if(e.offsetInNode<t.length){if(!ea(t.data.slice(e.offsetInNode),e.whitespace))return!1}}for(let t=n;t&&t!==i;t=t.parentNode)for(let i=t.nextSibling;i;i=i.nextSibling)if(!Qs(i,e.whitespace))return!1;return!0}getColumnElement(){return this.column.element}getColumn(){return this.column}},yg=class{breakTextNode(e,t,i,n,r,o){if(t.after)t.offsetInNode=e.length;else{let n=i-t.boxOffset,r=e.data;n=173==r.charCodeAt(n)?this.breakAfterSoftHyphen(e,r,n,t):this.breakAfterOtherCharacter(e,r,n,t),n>0&&(t=this.updateNodeContext(t,n,e))}return t}breakAfterSoftHyphen(e,t,i,n){let r=/[\u0620\u0626\u0628\u062A-\u062E\u0633-\u0647\u0649\u064A\u066E\u066F\u0678-\u0687\u069A-\u06BF\u06C1\u06C2\u06CC\u06CE\u06D0\u06D1\u06FA-\u06FC\u06FF\u0712-\u0714\u071A-\u071D\u071F-\u0727\u0729\u072B\u072D\u072E\u074E-\u0758\u075C-\u076A\u076D-\u0770\u0772\u0775-\u0777\u077A-\u077F\u07CA-\u07EA\u07FA\u0841-\u0845\u0848\u084A-\u0853\u0855\u0860\u0862-\u0865\u0868\u0883-\u0886\u0889-\u088D\u08A0-\u08A9\u08AF\u08B0\u08B3-\u08B8\u08BA-\u08C8\u1807\u180A\u1820-\u1878\u1887-\u18A8\u18AA\u200D\uA840-\uA871\u{10AC0}-\u{10AC4}\u{10AD3}-\u{10AD6}\u{10AD8}-\u{10ADC}\u{10ADE}-\u{10AE0}\u{10AEB}-\u{10AEE}\u{10B80}\u{10B82}\u{10B86}-\u{10B88}\u{10B8A}\u{10B8B}\u{10B8D}\u{10B90}\u{10BAD}\u{10BAE}\u{10D01}-\u{10D21}\u{10D23}\u{10EC3}\u{10EC4}\u{10F30}-\u{10F32}\u{10F34}-\u{10F44}\u{10F51}-\u{10F53}\u{10F70}-\u{10F73}\u{10F76}-\u{10F81}\u{10FB0}\u{10FB2}\u{10FB3}\u{10FB8}\u{10FBB}\u{10FBC}\u{10FBE}\u{10FBF}\u{10FC1}\u{10FC4}\u{10FCA}\u{1E900}-\u{1E943}]\p{Mn}*$/u.test(t.slice(0,i))?"‍":"";if(e.replaceData(i,t.length-i,n.breakWord?"":r+bg(n)),r){let e=n.preprocessedTextContent[0][1];n.preprocessedTextContent[0][1]=e.slice(0,i+1)+r+e.slice(i+1)}return i+1}breakAfterOtherCharacter(e,t,i,n){let r=t.charAt(i);i++;let o=t.charAt(i);return e.replaceData(i,t.length-i,!n.breakWord&&Ae(r)&&Ae(o)?bg(n):""),i}updateNodeContext(e,t,i){return(e=e.modify()).offsetInNode+=t,e.breakBefore=null,e}};function bg(e){return e.hyphenateCharacter||e.parent&&e.parent.hyphenateCharacter||"-"}h(yg,"instance"),yg.instance=new yg;var wg=class extends lh{constructor(e,t){super(),h(this,"leadingEdge",e),h(this,"breakAfter"),h(this,"initialPageBreakType",null),h(this,"initialComputedBlockSize",0),h(this,"initialOverflown",!1),h(this,"initialLastLineStride",0),h(this,"context",{overflownNodeContext:null}),this.breakAfter=t||null}resolveLayoutMode(e){return new xg(this.leadingEdge,this.breakAfter,this.context)}prepareLayout(e,t){t.fragmentLayoutConstraints=[],t.pseudoParent||(fh=[])}clearNodes(e){super.clearNodes(e);let t=e;for(;t;){let e=t.viewNode;e&&Ka(e.parentNode,e),t=t.parent}}saveState(e,t){super.saveState(e,t),this.initialPageBreakType=t.pageBreakType,this.initialComputedBlockSize=t.computedBlockSize,this.initialOverflown=t.overflown,this.initialLastLineStride=t.lastLineStride}restoreState(e,t){super.restoreState(e,t),t.pageBreakType=this.initialPageBreakType,t.computedBlockSize=this.initialComputedBlockSize,t.overflown=this.initialOverflown,t.lastLineStride=this.initialLastLineStride}},xg=class{constructor(e,t,i){h(this,"leadingEdge",e),h(this,"breakAfter",t),h(this,"context",i)}doLayout(e,t){let i=oo("DefaultLayoutMode.doLayout");return function(e,t){let i=oo("processAfterIfContinuesOfAncestors"),n=e;return i.loop(()=>{if(null!==n){let e=dg(n,t);return n=n.parent,e.thenReturn(!0)}return so(!1)}).then(()=>{i.finish(!0)}),i.result()}(e,t).then(()=>{t.doLayout(e,this.leadingEdge,this.breakAfter).then(e=>{this.context.overflownNodeContext=e.overflownNodeContext,i.finish(e.nodeContext)})}),i.result()}accept(e,t){return!!(t.pageFloatLayoutContext.isInvalidated()||t.pageBreakType||t.fragmentLayoutConstraints.length<=0)||t.fragmentLayoutConstraints.every(i=>i.allowLayout(e,this.context.overflownNodeContext,t))}postLayout(e,t,i,n){return n||(n=!i.fragmentLayoutConstraints.some(t=>t.nextCandidate(e))),i.fragmentLayoutConstraints.forEach(r=>{r.postLayout(n,e,t,i)}),n}},Sg=class extends mg{constructor(e,t,i,n,r,o,s,a,l,u,c){super(t,i,n,r,o,a,l,u,c),h(this,"floatSide",e),h(this,"parentContainer",s),h(this,"rootViewNodes",[]),h(this,"floatMargins",[]),h(this,"adjustContentRelativeSize",!0),h(this,"parentElement"),this.parentElement=s.element}openAllViews(e){return super.openAllViews(e).thenAsync(e=>(e&&this.fixFloatSizeAndPosition(e),so(e)))}convertPercentageSizesToPx(e){let t=this.parentContainer.getPaddingRect(),i=t.x2-t.x1,n=t.y2-t.y1;function r(t,i){t.forEach(t=>{let n=we(e,t);if(n&&"%"===n.charAt(n.length-1)){let r=parseFloat(n);be(e,t,`${i*r/100}px`)}})}r(["width","max-width","min-width"],i),r(["height","max-height","min-height"],n),r(["margin-top","margin-right","margin-bottom","margin-left","padding-top","padding-right","padding-bottom","padding-left"],this.vertical?n:i),["margin-top","margin-right","margin-bottom","margin-left"].forEach(t=>{"auto"===we(e,t)&&be(e,t,"0")})}fixFloatSizeAndPosition(e){for(;e.parent;)e=e.parent;e.viewNode.nodeType;let t=e.viewNode;if(this.rootViewNodes.push(t),this.adjustContentRelativeSize&&this.convertPercentageSizesToPx(t),this.floatMargins.push(this.getComputedMargin(t)),this.adjustContentRelativeSize){let e=this.floatSide;if(this.parentContainer.vertical){if("block-end"===e||"left"===e){let e=we(t,"height");""!==e&&"auto"!==e&&be(t,"margin-top","auto")}}else if("block-end"===e||"bottom"===e){let e=we(t,"width");""!==e&&"auto"!==e&&be(t,"margin-left","auto")}}}getRootViewNodeCount(){return this.rootViewNodes.length}hasNonPseudoTextContentAfter(e){let t=e=>{var i;return e.nodeType===Node.TEXT_NODE?!(null==(i=e.textContent)||!i.trim()):e.nodeType===Node.ELEMENT_NODE&&!og(e)&&Array.from(e.childNodes).some(t)};return this.rootViewNodes.slice(e).some(t)}appendContentFrom(e){e.rootViewNodes.forEach(e=>{this.element.appendChild(e)}),this.rootViewNodes.push(...e.rootViewNodes),this.floatMargins.push(...e.floatMargins),e.rootViewNodes.splice(0),e.floatMargins.splice(0),e.element.parentNode&&e.element.parentNode.removeChild(e.element),this.applyCompactFootnoteDisplay(),this.updateComputedBlockSizeForFootnoteArea(!0)}removeContentAfter(e){let t=this.rootViewNodes.splice(e);this.floatMargins.splice(e),t.forEach(e=>{e.parentNode&&e.parentNode.removeChild(e)}),this.applyCompactFootnoteDisplay(),this.updateComputedBlockSizeForFootnoteArea(!0)}getContentInlineSize(){return Math.max.apply(null,this.rootViewNodes.map((e,t)=>{let i=Ua(this.clientLayout,e,this.vertical),n=this.floatMargins[t];return this.vertical?n.top+i.height+n.bottom:n.left+i.width+n.right}))}getContentBlockMarginAfter(){return 0===this.rootViewNodes.length?0:Math.max.apply(null,this.rootViewNodes.map((e,t)=>{let i=this.floatMargins[t];return this.vertical?i.left:i.bottom}))}applyCompactFootnoteDisplay(){let e=this.layoutContext,t=null==e?void 0:e.styler,i=null==e?void 0:e.xmldoc,n=this.rootViewNodes.filter(e=>{var n,r,o,s;let a=null==(n=e.ownerDocument.defaultView)?void 0:n.getComputedStyle(e);if("compact"===((null==a?void 0:a.getPropertyValue("--viv-footnote-display").trim())||""))return!("list-item"===(null==a?void 0:a.display)&&"outside"===a.getPropertyValue("list-style-position").trim());let l=e.getAttribute(K);if(!l||!t||!i)return!1;let h=i.getNodeByOffset(parseInt(l,10));if(!h||h.nodeType!==Node.ELEMENT_NODE)return!1;let u=t.getStyle(h,!1),c=null==(o=null==(r=Hd(u,"footnote-display"))?void 0:r.value)?void 0:o.toString(),d=!(null==(s=Hd(u,"--viv-marker-content"))||!s.value);return"compact"===c&&!d});if(0===n.length)return this.updateInlineFootnoteSeparators(),void this.updateComputedBlockSizeForFootnoteArea(!0);let r=this.element.getBoundingClientRect(),o=this.vertical?r.height:r.width;n.forEach(e=>{be(e,"display","inline"),e.style.setProperty("--viv-footnote-white-space","nowrap")});let s=1.5/(this.clientLayout.pixelRatio||1),a=e=>{let t=e.cloneNode(!0);be(t,"display","inline-block"),be(t,"position","absolute"),be(t,"visibility","hidden"),be(t,"white-space","nowrap"),be(t,"max-width","none"),be(t,"left","0"),be(t,"top","0"),this.element.appendChild(t);let i=t.getBoundingClientRect();return this.element.removeChild(t),this.vertical?i.height:i.width};n.forEach(e=>{a(e)>o+s&&(be(e,"display","block"),e.style.removeProperty("--viv-footnote-white-space"))}),this.updateInlineFootnoteSeparators(),this.updateComputedBlockSizeForFootnoteArea(!0)}updateComputedBlockSizeForFootnoteArea(e=!1){if(0===this.rootViewNodes.length)return void(this.computedBlockSize=0);let t=this.getBoxDir(),i=this.beforeEdge;if(e){let e=Ua(this.clientLayout,this.element,this.vertical),n=this.vertical?this.borderRight+this.paddingRight:this.borderTop+this.paddingTop;i=this.getBeforeEdge(e)+t*n}this.computedBlockSize=Math.max(0,...this.rootViewNodes.map(e=>{let n=Ua(this.clientLayout,e,this.vertical),r=this.getComputedMargin(e),o=this.vertical?r.left:r.bottom;return t*(this.getAfterEdge(n)-i)+Math.max(0,o)}))}getFootnoteAfterPseudo(e){return Array.from(e.children).find(e=>"after"===og(e))}hasAuthorFootnoteAfterPseudo(e){let t=this.getFootnoteAfterPseudo(e);if(t&&!t.hasAttribute("data-vivliostyle-default-footnote-separator"))return!0;let i=Array.from(e.children).find(e=>e instanceof Element&&Ll(e)),n=i?this.getFootnoteAfterPseudo(i):null;return!!n&&!n.hasAttribute("data-vivliostyle-default-footnote-separator")}createDefaultFootnoteAfterPseudo(e){let t=e.ownerDocument.createElement("span");sg(t,"after"),t.setAttribute("data-vivliostyle-default-footnote-separator","1"),t.style.whiteSpace="normal",t.textContent=" ",e.appendChild(t)}getFootnoteBreakOpportunity(e){let t=e.nextElementSibling;return null!=t&&t.hasAttribute("data-vivliostyle-footnote-break")?t:null}createFootnoteBreakOpportunity(e){let t=e.ownerDocument.createElement("wbr");t.setAttribute("data-vivliostyle-footnote-break","1"),e.insertAdjacentElement("afterend",t)}updateInlineFootnoteSeparators(){this.rootViewNodes.forEach((e,t)=>{var i,n;let r=e,o=null==(i=r.ownerDocument.defaultView)?void 0:i.getComputedStyle(r).display,s=this.rootViewNodes[t+1],a=null==(n=null==s?void 0:s.ownerDocument.defaultView)?void 0:n.getComputedStyle(s).display,l=this.getFootnoteAfterPseudo(r),h=this.hasAuthorFootnoteAfterPseudo(r),u=!(null==l||!l.hasAttribute("data-vivliostyle-default-footnote-separator")),c=this.getFootnoteBreakOpportunity(r);if("inline"===o&&"inline"===a){let e=!l&&!h;e&&this.createDefaultFootnoteAfterPseudo(r),e||c?e&&(null==c||c.remove()):this.createFootnoteBreakOpportunity(r)}else u&&l.remove(),null==c||c.remove()})}},Cg=class{constructor(e,t){h(this,"parent",e),h(this,"rootSourceNode",t),h(this,"formattingContextType","RepetitiveElementsOwner"),h(this,"isRoot",!1),h(this,"repetitiveElements",null)}getName(){return"Repetitive elements owner formatting context (RepetitiveElementsOwnerFormattingContext)"}isFirstTime(e,t){return t}getParent(){return this.parent}getRepetitiveElements(){return this.repetitiveElements}getRootViewNode(e){let t=this.getRootNodeContext(e);return t?t.viewNode:null}getRootNodeContext(e){let t=e;do{if(!t.belongsTo(this)&&t.sourceNode===this.rootSourceNode)return t}while(t=t.parent);return null}initializeRepetitiveElements(e){this.repetitiveElements||fh.some(e=>e.root===this.rootSourceNode&&(this.repetitiveElements=e.elements,!0))||(this.repetitiveElements=new kg(e,this.rootSourceNode),fh.push({root:this.rootSourceNode,elements:this.repetitiveElements}))}saveState(){}restoreState(e){}},kg=class{constructor(e,t){h(this,"vertical",e),h(this,"ownerSourceNode",t),h(this,"headerSourceNode",null),h(this,"footerSourceNode",null),h(this,"headerViewNode",null),h(this,"footerViewNode",null),h(this,"headerNodePosition",null),h(this,"footerNodePosition",null),h(this,"headerHeight",0),h(this,"footerHeight",0),h(this,"isSkipHeader",!1),h(this,"isSkipFooter",!1),h(this,"enableSkippingFooter",!0),h(this,"enableSkippingHeader",!0),h(this,"doneInitialLayout",!1),h(this,"firstContentSourceNode",null),h(this,"lastContentSourceNode",null),h(this,"affectedNodeCache",[]),h(this,"afterLastContentNodeCache",[]),h(this,"allowInsert",!1),h(this,"allowInsertRepeatitiveElements",!1)}setHeaderNodeContext(e){this.headerNodePosition||(this.headerNodePosition=aa(e,0),this.headerSourceNode=e.sourceNode,this.headerViewNode=e.viewNode)}setFooterNodeContext(e){this.footerNodePosition||(this.footerNodePosition=aa(e,0),this.footerSourceNode=e.sourceNode,this.footerViewNode=e.viewNode)}updateHeight(e){this.headerViewNode&&(this.headerHeight=Xa(this.headerViewNode,e,this.vertical),this.headerViewNode=null),this.footerViewNode&&(this.footerHeight=Xa(this.footerViewNode,e,this.vertical),this.footerViewNode=null)}prepareLayoutFragment(){this.isSkipHeader=this.isSkipFooter=!1,this.enableSkippingFooter=!0,this.enableSkippingHeader=!0}appendHeaderToFragment(e,t,i){return!this.headerNodePosition||this.isSkipHeader?so(!0):this.appendElementToFragment(this.headerNodePosition,e,t,i)}appendFooterToFragment(e,t,i){return!this.footerNodePosition||this.isSkipFooter?so(!0):this.appendElementToFragment(this.footerNodePosition,e,t,i)}appendElementToFragment(e,t,i,n){let r=t.viewNode,o=r.ownerDocument.createElement("div");r.appendChild(o);let s=new vg(n,o,t),a=s.getColumn().pageBreakType;return s.getColumn().pageBreakType=null,this.allowInsertRepeatitiveElements=!0,s.layout(new Ea(e),!0).thenAsync(()=>(this.allowInsertRepeatitiveElements=!1,r.removeChild(o),this.moveChildren(o,r,i),s.getColumn().pageBreakType=a,so(!0)))}moveChildren(e,t,i){if(t)for(;e.firstChild;){let n=e.firstChild;e.removeChild(n),n.setAttribute(Za,"1"),i?t.insertBefore(n,i):t.appendChild(n)}}calculateOffset(e){let t=0;return e&&!this.affectTo(e)||((!this.isSkipFooter||e&&this.isAfterLastContent(e))&&(t+=this.footerHeight),this.isSkipHeader||(t+=this.headerHeight)),t}calculateMinimumOffset(e){let t=0;return e&&!this.affectTo(e)||(!this.enableSkippingFooter&&e&&this.isAfterLastContent(e)&&(t+=this.footerHeight),this.enableSkippingHeader||(t+=this.headerHeight)),t}isAfterLastContent(e){return this.findResultFromCache(e,this.afterLastContentNodeCache,t=>this.isAfterNodeContextOf(this.lastContentSourceNode,e,!1))}affectTo(e){return this.findResultFromCache(e,this.affectedNodeCache,t=>this.isAfterNodeContextOf(this.ownerSourceNode,e,!0))}findResultFromCache(e,t,i){let n=t.filter(t=>t.nodeContext.sourceNode===e.sourceNode&&t.nodeContext.after===e.after);if(n.length>0)return n[0].result;{let n=i(e);return t.push({nodeContext:e,result:n}),n}}isAfterNodeContextOf(e,t,i){let n=[];for(let i=e;i;i=i.parentNode){if(t.sourceNode===i)return t.after;n.push(i)}for(let e=t.sourceNode;e;e=e.parentNode){let t=n.indexOf(e);if(t>=0)return!!i&&0===t;for(let t=e;t;t=t.previousElementSibling)if(n.includes(t))return!0}return t.after}isFirstContentNode(e){return e&&this.firstContentSourceNode===e.sourceNode}isEnableToUpdateState(){return!!(!this.isSkipFooter&&this.enableSkippingFooter&&this.footerNodePosition||!this.isSkipHeader&&this.enableSkippingHeader&&this.headerNodePosition)}updateState(){!this.isSkipFooter&&this.enableSkippingFooter&&this.footerNodePosition?this.isSkipFooter=!0:!this.isSkipHeader&&this.enableSkippingHeader&&this.headerNodePosition&&(this.isSkipHeader=!0)}preventSkippingHeader(){this.isSkipHeader=!1,this.enableSkippingHeader=!1}preventSkippingFooter(){this.isSkipFooter=!1,this.enableSkippingFooter=!1}isHeaderRegistered(){return!!this.headerNodePosition}isFooterRegistered(){return!!this.footerNodePosition}isHeaderSourceNode(e){return this.headerSourceNode===e}isFooterSourceNode(e){return this.footerSourceNode===e}},Pg=class{constructor(e){h(this,"formattingContext",e)}accept(e,t){return!!e}postLayout(e,t,i,n){let r=this.formattingContext.getRepetitiveElements();return r&&(r.doneInitialLayout||(r.updateHeight(i),r.doneInitialLayout=!0)),n}},Eg=class{constructor(e){h(this,"formattingContext",e)}accept(e,t){return!0}postLayout(e,t,i,n){return n}},Ng=class extends Pg{constructor(e,t){super(e),h(this,"processor",t)}doLayout(e,t){return this.processor.doInitialLayout(e,t)}accept(e,t){return!1}},Tg=class extends Eg{constructor(e,t){super(e),h(this,"processor",t)}doLayout(e,t){return!e.belongsTo(this.formattingContext)&&!e.after&&t.fragmentLayoutConstraints.unshift(new Ig(e)),this.processor.doLayout(e,t)}},Ig=class e{constructor(e){h(this,"flagmentLayoutConstraintType","RepetitiveElementsOwner"),h(this,"nodeContext");let t=e.formattingContext;this.nodeContext=t.getRootNodeContext(e)}allowLayout(e,t,i){let n=this.getRepetitiveElements();return!(n&&!Ya(this.nodeContext.viewNode)&&n.isEnableToUpdateState())||(!(t&&!e||e&&e.overflow)||!Og(e,t,n))}nextCandidate(e){let t=this.getRepetitiveElements();return!(!t||!t.isEnableToUpdateState())&&(t.updateState(),!0)}postLayout(e,t,i,n){let r=this.getRepetitiveElements();r&&e&&n.stopAtOverflow&&(null==t||r.isAfterLastContent(t))&&r.preventSkippingFooter()}finishBreak(e,t){let i=this.nodeContext.formattingContext,n=this.getRepetitiveElements();if(!n)return so(!0);let r=this.nodeContext;return function(e,t,i){let n=e.getRepetitiveElements();if(n){let r=e.getRootNodeContext(t),o=r&&Sa(r);if(o){let e=o.viewNode.firstChild;return n.appendHeaderToFragment(o,e,i)}}return so(!0)}(i,r,t).thenAsync(()=>function(e,t,i){let n=e.getRepetitiveElements();if(n&&!n.isSkipFooter){let r=e.getRootNodeContext(t),o=r&&Sa(r);if(o)return n.appendFooterToFragment(o,null,i)}return so(!0)}(i,r,t).thenAsync(()=>(n.prepareLayoutFragment(),so(!0))))}getRepetitiveElements(){return this.nodeContext.formattingContext.getRepetitiveElements()}equalsTo(t){return t instanceof e&&this.nodeContext.formattingContext===t.nodeContext.formattingContext}getPriorityOfFinishBreak(){return 10}},Ag=class extends lh{constructor(e,t){super(),h(this,"formattingContext",e),h(this,"processor",t)}resolveLayoutMode(e){let t=this.formattingContext.getRepetitiveElements();return e.belongsTo(this.formattingContext)||t.doneInitialLayout?(!e.belongsTo(this.formattingContext)&&!e.after&&t&&t.preventSkippingHeader(),new Tg(this.formattingContext,this.processor)):new Ng(this.formattingContext,this.processor)}},Fg=class extends ph{constructor(e,t){super(),h(this,"formattingContext",e),h(this,"column",t)}startNonInlineElementNode(e){let t=this.formattingContext,i=e.nodeContext,n=t.getRepetitiveElements();if(i.parent&&t.rootSourceNode===i.parent.sourceNode){switch(i.repeatOnBreak){case"header":if(!n.isHeaderRegistered())return n.setHeaderNodeContext(i),so(!0);i.repeatOnBreak="none";break;case"footer":if(!n.isFooterRegistered())return n.setFooterNodeContext(i),so(!0);i.repeatOnBreak="none"}n.firstContentSourceNode||(n.firstContentSourceNode=i.sourceNode)}return ph.prototype.startNonInlineElementNode.call(this,e)}afterNonInlineElementNode(e){let t=this.formattingContext,i=e.nodeContext;return i.sourceNode===t.rootSourceNode&&(t.getRepetitiveElements().lastContentSourceNode=e.lastAfterNodeContext&&e.lastAfterNodeContext.sourceNode,e.break=!0),"header"===i.repeatOnBreak||"footer"===i.repeatOnBreak?so(!0):ph.prototype.afterNonInlineElementNode.call(this,e)}};function Rg(e,t){e&&function(e,t){for(let i=e;i;i=i.parent){let e=i.formattingContext;e instanceof Cg&&!i.belongsTo(e)&&t(e,i)}}(e.after?e.parent:e,(e,i)=>{zs.isInstanceOfTableFormattingContext(e)||t.fragmentLayoutConstraints.push(new Ig(i))})}function Og(e,t,i){let n=i.ownerSourceNode,r=e||t;return!r||n.contains(r.sourceNode)}var Lg=new class extends rh{layout(e,t,i){let n=t.asFloatNodeContext(e);if(n)return t.layoutFloatOrFootnote(n);let r=e.formattingContext;return r.getRootViewNode(e)?(i&&Rg(e.parent,t),e.belongsTo(r)?rh.prototype.layout.call(this,e,t,i):new Ag(r,this).layout(e,t)):t.buildDeepElementView(e)}startNonInlineElementNode(e){let t=function(e){let t=e.formattingContext;return t instanceof Cg?t:null}(e).getRepetitiveElements();if(!t)return!1;if(!t.allowInsertRepeatitiveElements&&(t.isHeaderSourceNode(e.sourceNode)||t.isFooterSourceNode(e.sourceNode))){Sa(e).viewNode.remove()}return!1}doInitialLayout(e,t){e.formattingContext;let i=oo("BlockLayoutProcessor.doInitialLayout");return this.layoutEntireBlock(e,t).thenFinish(i),i.result()}layoutEntireBlock(e,t){let i=e.formattingContext,n=new Fg(i,t);return new dh(n,t.layoutContext).iterate(e)}doLayout(e,t){let i=e.formattingContext,n=oo("doLayout");return pg(t.layoutContext.nextInTree(e,!1),t).then(e=>{let r=e;n.loopWithFrame(e=>{for(;r;){let n=!0;if(t.layoutNext(r,!1).then(o=>{r=o,t.pageFloatLayoutContext.isInvalidated()||t.pageBreakType||r&&t.stopByOverflow(r)||r&&r.after&&r.sourceNode==i.rootSourceNode?e.breakLoop():n?n=!1:e.continueLoop()}),n)return void(n=!1)}e.breakLoop()}).then(()=>{n.finish(r)})}),n.result()}finishBreak(e,t,i,n){return rh.prototype.finishBreak.call(this,e,t,i,n)}clearOverflownViewNodes(e,t,i,n){rh.prototype.clearOverflownViewNodes(e,t,i,n)}};_("RESOLVE_LAYOUT_PROCESSOR",e=>e instanceof Cg&&!zs.isInstanceOfTableFormattingContext(e)?Lg:null);var _g=class{constructor(e,t){h(this,"rowIndex",e),h(this,"sourceNode",t),h(this,"cells",[]),h(this,"breakBefore",null),h(this,"breakAfter",null)}addCell(e){this.cells.push(e)}getMinimumHeight(){return Math.min.apply(null,this.cells.map(e=>e.height))}},Bg=class{constructor(e,t,i,n){h(this,"rowIndex",e),h(this,"columnIndex",t),h(this,"anchorColumnIndex",i),h(this,"viewElement"),h(this,"colSpan"),h(this,"rowSpan"),h(this,"height",0),this.viewElement=n,this.colSpan=n.colSpan||1,this.rowSpan=n.rowSpan||1}setHeight(e){this.height=e}},Mg=class{constructor(e,t,i){h(this,"rowIndex",e),h(this,"columnIndex",t),h(this,"cell",i)}},Dg=class{constructor(e,t,i){h(this,"column",e),h(this,"cellNodeContext",i),h(this,"pseudoColumn"),h(this,"empty",!1),this.pseudoColumn=new vg(e,t,i)}findAcceptableBreakPosition(){let e=this.cellNodeContext.viewNode,{verticalAlign:t,alignContent:i}=e.style;"top"!==t&&"baseline"!==t&&be(e,"vertical-align","top"),i&&"normal"!==i&&be(e,"align-content","normal");let n=this.pseudoColumn.findAcceptableBreakPosition();return be(e,"vertical-align",t),i&&"normal"!==i&&be(e,"align-content",i),n}},zg=class{constructor(e,t){h(this,"viewNode",e),h(this,"side",t)}},Vg=class extends ih{constructor(e,t,i,n){super(e,t,i,n),h(this,"formattingContext"),h(this,"acceptableCellBreakPositions",null),h(this,"rowIndex",null),this.formattingContext=e.formattingContext}findAcceptableBreak(e,t){let i=super.findAcceptableBreak(e,t);return t<this.getMinBreakPenalty()||this.hasUnfinishedCells()?null:i}hasUnfinishedCells(){let e=this.getRowIndex(),t=this.formattingContext.getCellsFallingOnRow(e);for(let i of t){if(i.rowIndex+i.rowSpan-1>e)continue;let t=this.formattingContext.getCellFragmentOfCell(i);if(t){let e=t.findAcceptableBreakPosition();if(!t.pseudoColumn.isLastAfterNodeContext(e.nodeContext))return!0}}return!1}getMinBreakPenalty(){let e=super.getMinBreakPenalty();this.getAcceptableCellBreakPositions().forEach(t=>{e+=t.breakPosition.getMinBreakPenalty()});let t=this.getCellFragments();return e+=Math.max(0,...t.map(e=>e.cellNodeContext.breakPenalty)),e}getAcceptableCellBreakPositions(){if(!this.acceptableCellBreakPositions){this.formattingContext;let e=this.getCellFragments();this.acceptableCellBreakPositions=e.map(e=>e.findAcceptableBreakPosition())}return this.acceptableCellBreakPositions}getRowIndex(){return null!=this.rowIndex?this.rowIndex:this.rowIndex=this.formattingContext.findRowIndexBySourceNode(this.position.sourceNode)}getCellFragments(){return this.formattingContext.getRowSpanningCellsOverflowingTheRow(this.getRowIndex()).map(this.formattingContext.getCellFragmentOfCell,this.formattingContext)}},Ug=class extends eh{constructor(e,t,i){super(),h(this,"rowIndex",e),h(this,"beforeNodeContext",t),h(this,"formattingContext",i),h(this,"acceptableCellBreakPositions",null)}findAcceptableBreak(e,t){if(this!==e.breakPositions[0]&&t<this.getMinBreakPenalty())return null;let i=this.getCellFragments(),n=this.getAcceptableCellBreakPositions(),r=n.some((e,t)=>{let n=i[t].pseudoColumn,r=e.nodeContext;return!n.isStartNodeContext(r)&&!n.isLastAfterNodeContext(r)});return this.beforeNodeContext.overflow=n.some(e=>e.nodeContext.overflow),r?this.beforeNodeContext:null}getMinBreakPenalty(){this.formattingContext.getRowByIndex(this.rowIndex);let e=this.beforeNodeContext.breakPenalty,t=this.getAcceptableCellBreakPositions(),i=this.getCellFragments();e+=Math.max(0,...i.map(e=>e.cellNodeContext.breakPenalty));let n=t.some((e,t)=>e.breakPosition instanceof gg&&i[t].cellNodeContext.sourceNode.rowSpan>1);return t.forEach((t,r)=>{let o=t.breakPosition.getMinBreakPenalty();n&&t.breakPosition instanceof ih&&t.breakPosition.overflows&&o>=3&&(i[r].column.checkOverflowAndSaveEdge(t.nodeContext,null)||(o-=3)),e+=o}),e}getAcceptableCellBreakPositions(){if(!this.acceptableCellBreakPositions){let e=this.getCellFragments();this.acceptableCellBreakPositions=e.map(e=>e.findAcceptableBreakPosition())}return this.acceptableCellBreakPositions}getCellFragments(){return this.formattingContext.getCellsFallingOnRow(this.rowIndex).map(this.formattingContext.getCellFragmentOfCell,this.formattingContext)}},Hg=class extends Cg{constructor(e,t){super(e,t),h(this,"tableSourceNode",t),h(this,"formattingContextType","Table"),h(this,"vertical",!1),h(this,"columnCount",-1),h(this,"tableWidth",0),h(this,"captions",[]),h(this,"colGroups",null),h(this,"colWidths",null),h(this,"inlineBorderSpacing",0),h(this,"rows",[]),h(this,"slots",[]),h(this,"cellFragments",[]),h(this,"lastRowViewNode",null),h(this,"cellBreakPositions",[]),h(this,"repetitiveElements",null)}getName(){return"Table formatting context (Table.TableFormattingContext)"}isFirstTime(e,t){var i;if(!t)return t;switch(e.display){case"table-row":{let t=this.findRowIndexBySourceNode(e.sourceNode);return this.cellBreakPositions.every(e=>this.isPreviousFragmentRowSpanningCellBreakPosition(e,t))&&e.fragmentIndex<=1}case"table-cell":return!(e.fragmentIndex>1||"table-row"===(null==(i=e.parent)?void 0:i.display)&&e.parent.fragmentIndex>1)&&!this.cellBreakPositions.some(t=>t.cellNodePosition.steps[0].node===e.sourceNode);default:return t}}getParent(){return this.parent}finishFragment(){this.cellFragments=[]}addRow(e,t){this.rows[e]=t}getRowSlots(e){let t=this.slots[e];return t||(t=this.slots[e]=[]),t}addCell(e,t,i){let n=this.rows[e];n||(this.addRow(e,new _g(e,null)),n=this.rows[e]);let r=this.getRowSlots(e),o=0;for(;r[o];)o++;let s=new Bg(e,t,o,i);n.addCell(s);let a=e+s.rowSpan,l=o+s.colSpan;for(let t=e;t<a;t++){let e=this.getRowSlots(t);for(let i=o;i<l;i++)e[i]=new Mg(t,i,s)}}getRowByIndex(e){return this.rows[e]}findRowIndexBySourceNode(e){return this.rows.findIndex(t=>e===t.sourceNode)}isPreviousFragmentRowSpanningCellBreakPosition(e,t){let i=e.cell;return t>=0&&i.rowIndex<t&&i.rowIndex+i.rowSpan>t}addCellFragment(e,t,i){let n=this.cellFragments[e];n||(n=this.cellFragments[e]=[]),n[t]=i}getCellsFallingOnRow(e){return this.getRowSlots(e).reduce((e,t)=>t.cell!==e[e.length-1]?e.concat(t.cell):e,[])}getRowSpanningCellsOverflowingTheRow(e){return this.getCellsFallingOnRow(e).filter(t=>t.rowIndex+t.rowSpan-1>e)}getCellFragmentOfCell(e){return this.cellFragments[e.rowIndex]&&this.cellFragments[e.rowIndex][e.columnIndex]}getColumnCount(){return this.columnCount<0&&(this.columnCount=Math.max.apply(null,this.rows.map(e=>e.cells.reduce((e,t)=>e+t.colSpan,0)))),this.columnCount}updateCellSizes(e){this.rows.forEach(t=>{t.cells.forEach(t=>{let i=Ua(e,t.viewElement,this.vertical);t.viewElement=null,t.setHeight(this.vertical?i.width:i.height)})})}findCellFromColumn(e){if(!e)return null;let t=null,i=0,n=0;e:for(i=0;i<this.cellFragments.length;i++)if(this.cellFragments[i])for(n=0;n<this.cellFragments[i].length;n++)if(this.cellFragments[i][n]&&e===this.cellFragments[i][n].pseudoColumn.getColumn()){t=this.rows[i].cells[n];break e}if(!t)return null;for(;i<this.slots.length;i++)for(;n<this.slots[i].length;n++){let e=this.slots[i][n];if(e.cell===t)return{rowIndex:e.rowIndex,columnIndex:e.columnIndex}}return null}collectElementsOffsetOfUpperCells(e){let t=[];return this.slots.reduce((i,n,r)=>{if(r>=e.rowIndex)return i;let o=n[e.columnIndex]&&this.getCellFragmentOfCell(n[e.columnIndex].cell);return!o||t.includes(o)||(this.collectElementsOffsetFromColumn(o.pseudoColumn.getColumn(),i),t.push(o)),i},[])}collectElementsOffsetOfHighestColumn(){let e=[];return this.rows.forEach(t=>{t.cells.forEach((t,i)=>{e[i]||(e[i]={collected:[],elements:[]});let n=e[i],r=this.getCellFragmentOfCell(t);!r||n.collected.includes(r)||(this.collectElementsOffsetFromColumn(r.pseudoColumn.getColumn(),n.elements),n.collected.push(r))})}),[new $g(e.map(e=>e.elements))]}collectElementsOffsetFromColumn(e,t){e.fragmentLayoutConstraints.forEach(e=>{if(Ds.isInstanceOfRepetitiveElementsOwnerLayoutConstraint(e)){let i=e.getRepetitiveElements();t.push(i)}zs.isInstanceOfTableRowLayoutConstraint(e)&&e.getElementsOffsetsForTableCell(null).forEach(e=>{t.push(e)})})}saveState(){return[].concat(this.cellBreakPositions)}restoreState(e){this.cellBreakPositions=[].concat(e)}},$g=class{constructor(e){h(this,"repeatitiveElementsInColumns",e)}calculateOffset(e){return this.calculateMaxOffsetOfColumn(e,e=>e.current)}calculateMinimumOffset(e){return this.calculateMaxOffsetOfColumn(e,e=>e.minimum)}calculateMaxOffsetOfColumn(e,t){let i=0;return this.repeatitiveElementsInColumns.forEach(n=>{let r=th(e,n);i=Math.max(i,t(r))}),i}};function jg(e){return function(e){return"table-row-group"===e||"table-header-group"===e||"table-footer-group"===e}(e)||function(e){return"table"===e||"inline-table"===e}(e)}function Wg(e,t,i){let n=e.nodeContext,r=n.display,o=n.parent?n.parent.display:null,s=!1;if("inline-table"===o&&!(n.formattingContext instanceof Hg))for(let e=n.parent;e;e=e.parent)if(e.formattingContext instanceof Hg){s=e.formattingContext===t;break}return s||"table-row"===r&&!jg(o)||"table-cell"===r&&"table-row"!==o&&!jg(o)||n.formattingContext instanceof Hg&&n.formattingContext!==t?i.buildDeepElementView(n).thenAsync(t=>(e.nodeContext=t,so(!0))):null}function Gg(e,t){let i=function(e){var t;return null!==e.floatSide&&1===(null==(t=e.viewNode)?void 0:t.nodeType)?e:null}(t.nodeContext);return!i||!vl(i.floatReference)&&"footnote"!==i.floatSide?null:e.layoutFloatOrFootnote(i).thenAsync(e=>(e&&(t.nodeContext=e),so(!0)))}var qg=class extends ph{constructor(e,t){super(),h(this,"formattingContext",e),h(this,"column",t),h(this,"rowIndex",-1),h(this,"columnIndex",0),h(this,"inRow",!1),h(this,"checkPoints",[]),h(this,"inHeaderOrFooter",!1)}startNonInlineElementNode(e){let t=this.formattingContext,i=Wg(e,t,this.column);if(i)return i;this.postLayoutBlockContents(e);let n=Gg(this.column,e);if(n)return n;let r=e.nodeContext,o=r.display,s=t.getRepetitiveElements();switch(o){case"table":t.inlineBorderSpacing=r.inlineBorderSpacing;break;case"table-caption":{let e=new zg(r.viewNode,r.captionSide);t.captions.push(e);break}case"table-header-group":return s.isHeaderRegistered()||(this.inHeaderOrFooter=!0,s.setHeaderNodeContext(r)),so(!0);case"table-footer-group":return s.isFooterRegistered()||(this.inHeaderOrFooter=!0,s.setFooterNodeContext(r)),so(!0);case"table-row":this.inHeaderOrFooter||(this.inRow=!0,this.rowIndex++,this.columnIndex=0,t.addRow(this.rowIndex,new _g(this.rowIndex,r.sourceNode)),r.breakBefore&&(t.rows[this.rowIndex].breakBefore=r.breakBefore),s.firstContentSourceNode||(s.firstContentSourceNode=r.sourceNode))}return super.startNonInlineElementNode(e)}afterNonInlineElementNode(e){let t=this.formattingContext,i=e.nodeContext,n=i.display,r=this.column.clientLayout;if(this.postLayoutBlockContents(e),i.sourceNode===t.tableSourceNode){let n=r.getElementComputedStyle(t.getRootViewNode(i));t.tableWidth=parseFloat(n[t.vertical?"height":"width"]),t.getRepetitiveElements().lastContentSourceNode=e.lastAfterNodeContext&&e.lastAfterNodeContext.sourceNode,e.break=!0}else switch(n){case"table-header-group":case"table-footer-group":if(this.inHeaderOrFooter)return this.inHeaderOrFooter=!1,so(!0);break;case"table-row":if(!this.inHeaderOrFooter){t.lastRowViewNode=i.viewNode,this.inRow=!1;let e=t.rows[this.rowIndex];e&&i.breakAfter&&(e.breakAfter=Os(e.breakAfter,i.breakAfter))}break;case"table-cell":if(!this.inHeaderOrFooter){this.inRow||(this.rowIndex++,this.columnIndex=0,this.inRow=!0);let e=i.viewNode;t.addCell(this.rowIndex,this.columnIndex,e),this.columnIndex++,Jg(e);let n=t.rows[this.rowIndex];n&&(i.breakBefore&&(n.breakBefore=Os(n.breakBefore,i.breakBefore)),i.breakAfter&&(n.breakAfter=Os(n.breakAfter,i.breakAfter)))}}return super.afterNonInlineElementNode(e)}startNonElementNode(e){this.registerCheckPoint(e)}afterNonElementNode(e){this.registerCheckPoint(e)}startInlineElementNode(e){this.registerCheckPoint(e)}afterInlineElementNode(e){this.registerCheckPoint(e)}registerCheckPoint(e){let t=e.nodeContext;il(t)||this.checkPoints.push(t.clone())}postLayoutBlockContents(e){this.checkPoints.length>0&&this.column.postLayoutBlock(e.nodeContext,this.checkPoints),this.checkPoints=[]}},Xg=class e extends ph{constructor(e,t){super(!0),h(this,"formattingContext",e),h(this,"column",t),h(this,"inRow",!1),h(this,"currentRowIndex",-1),h(this,"currentColumnIndex",0),h(this,"originalStopAtOverflow"),h(this,"inHeader",!1),h(this,"inFooter",!1),h(this,"didExtractRowSpanningCellBreakPositions",!1),this.originalStopAtOverflow=t.stopAtOverflow,t.stopAtOverflow=!1}startNonInlineElementNode(e){return Gg(this.column,e)||super.startNonInlineElementNode(e)}resetColumn(){this.column.stopAtOverflow=this.originalStopAtOverflow}getColSpanningCellWidth(e){let t=this.formattingContext.colWidths,i=0;for(let n=0;n<e.colSpan;n++)i+=t[e.anchorColumnIndex+n];return i+=this.formattingContext.inlineBorderSpacing*(e.colSpan-1),i}layoutCell(e,t,i){let n=e.rowIndex,r=e.columnIndex,o=e.colSpan,s=t.viewNode;o>1&&(be(s,"box-sizing","border-box"),be(s,this.formattingContext.vertical?"height":"width",`${this.getColSpanningCellWidth(e)}px`));let a=s.ownerDocument.createElement("div");s.appendChild(a);let l=new Dg(this.column,a,t);return this.formattingContext.addCellFragment(n,r,l),1===i.primary.steps.length&&i.primary.after&&(l.empty=!0),l.pseudoColumn.layout(i,!0).thenAsync(()=>(Jg(s),so(!0)))}findBrokenCellAtSlot(e,t){let i=this.formattingContext.cellBreakPositions;for(let n=0;n<i.length;n++){let r=i[n];if(r.cell.anchorColumnIndex===e&&r.cellNodePosition.steps[0].node===t)return{position:r,index:n}}return null}extractRowSpanningCellBreakPositions(){if(this.didExtractRowSpanningCellBreakPositions)return[];let e=this.formattingContext.cellBreakPositions;if(0===e.length)return[];let t=[];return e.forEach(e=>{let i=e.cell,n=i.rowIndex;if(n<this.currentRowIndex&&n+i.rowSpan>this.currentRowIndex){let i=t[n];i||(i=t[n]=[]),i.push(e)}}),this.didExtractRowSpanningCellBreakPositions=t.length>0,t}layoutRowSpanningCellsFromPreviousFragment(e){let t=this.formattingContext,i=this.extractRowSpanningCellBreakPositions(),n=i.reduce(e=>e+1,0);if(0===n)return so(!0);let r=this.column.layoutContext,o=e.nodeContext;o.viewNode.remove();let s=oo("layoutRowSpanningCellsFromPreviousFragment"),a=so(!0),l=0,h=[];return i.forEach(e=>{a=a.thenAsync(()=>{let i=la(e[0].cellNodePosition.steps[1],o.parent);return r.setCurrent(i,!1).thenAsync(()=>{let o=Sa(i).viewNode,s=so(!0),a=0;function u(e){for(;a<e;){if(!h.includes(a)){let e=o.ownerDocument.createElement("td");be(e,"padding","0"),o.appendChild(e)}a++}}return e.forEach(e=>{s=s.thenAsync(()=>{let t=e.cell;u(t.anchorColumnIndex);let o=e.cellNodePosition,s=la(o.steps[0],i);return s.offsetInNode=o.offsetInNode,s.after=o.after,s.fragmentIndex=o.steps[0].fragmentIndex+1,r.setCurrent(s,!1).thenAsync(()=>{let i=e.breakChunkPosition;for(let e=0;e<t.colSpan;e++)h.push(a+e);return a+=t.colSpan,this.layoutCell(t,s,i).thenAsync(()=>(s.viewNode.rowSpan=t.rowIndex+t.rowSpan-this.currentRowIndex+n-l,so(!0)))})})}),s.thenAsync(()=>(u(t.getColumnCount()),l++,so(!0)))})})}),a.then(()=>{r.setCurrent(o,!0,e.atUnforcedBreak).then(()=>{s.finish(!0)})}),s.result()}startTableRow(e){if(this.inHeader||this.inFooter)return so(!0);let t=e.nodeContext,i=this.formattingContext;return this.currentRowIndex<0?this.currentRowIndex=i.findRowIndexBySourceNode(t.sourceNode):this.currentRowIndex++,this.currentColumnIndex=0,this.inRow=!0,this.layoutRowSpanningCellsFromPreviousFragment(e).thenAsync(()=>{var n;this.registerCellFragmentIndex();let r=e.breakAtTheEdge;if(this.currentRowIndex>0){let e=i.rows[this.currentRowIndex-1];null!=e&&e.breakAfter&&(r=Os(r,e.breakAfter))}let o=i.rows[this.currentRowIndex];return null!=o&&o.breakBefore&&(r=Os(r,o.breakBefore)),!e.leadingEdge&&Ns(r)?(this.column.checkOverflowAndSaveEdgeAndBreakPosition(e.lastAfterNodeContext,null,!0,r),null==(n=t.viewNode)||n.remove(),e.lastAfterNodeContext&&this.column.layoutContext.processFragmentedBlockEdge(e.lastAfterNodeContext),this.column.pageBreakType=r,this.resetColumn(),e.break=!0,so(!0)):(this.column.checkOverflowAndSaveEdgeAndBreakPosition(e.lastAfterNodeContext,null,!0,r)&&0===i.getRowSpanningCellsOverflowingTheRow(this.currentRowIndex-1).length&&(this.resetColumn(),t.overflow=!0,e.break=!0),so(!0))})}registerCellFragmentIndex(){this.formattingContext.getRowByIndex(this.currentRowIndex).cells.forEach(e=>{let t=this.formattingContext.cellBreakPositions.find(t=>t.cell===e);if(t){let e=t.cellNodePosition.steps[0],i=this.column.layoutContext.xmldoc.getElementOffset(e.node);lg(i,e.fragmentIndex+1,1)}})}startTableCell(e){if(this.inHeader||this.inFooter)return so(!0);let t=e.nodeContext;this.inRow||(this.currentRowIndex<0?this.currentRowIndex=0:this.currentRowIndex++,this.currentColumnIndex=0,this.inRow=!0);let i=this.formattingContext.getRowByIndex(this.currentRowIndex).cells[this.currentColumnIndex];if(!i)return e.break=!0,so(!0);let n=t.copy().modify();n.after=!0,e.nodeContext=n;let r,o=oo("startTableCell"),s=this.findBrokenCellAtSlot(i.anchorColumnIndex,t.sourceNode);if(s){let e=s.position;this.formattingContext.cellBreakPositions.splice(s.index,1),t.fragmentIndex=e.cellNodePosition.steps[0].fragmentIndex+1,r=so(e.breakChunkPosition)}else r=this.column.nextInTree(t,e.atUnforcedBreak).thenAsync(e=>{let i=e.viewNode;i&&t.viewNode.removeChild(i);let n=aa(e,0);return so(new Ea(n))});return r.then(n=>{this.layoutCell(i,t,n).then(()=>{this.afterNonInlineElementNode(e),this.currentColumnIndex++,o.finish(!0)})}),o.result()}startNonInlineBox(e){let t=Wg(e,this.formattingContext,this.column);if(t)return t;let i=e.nodeContext,n=this.formattingContext.getRepetitiveElements(),r=i.display;return"table-header-group"===r&&n&&n.isHeaderSourceNode(i.sourceNode)?(this.inHeader=!0,so(!0)):"table-footer-group"===r&&n&&n.isFooterSourceNode(i.sourceNode)?(this.inFooter=!0,so(!0)):"table-row"===r?this.startTableRow(e):"table-cell"===r?this.startTableCell(e):so(!0)}endNonInlineBox(e){let t=e.nodeContext;if("table-row"===t.display&&(this.inRow=!1,!this.inHeader&&!this.inFooter)){let e=t.copy().modify();e.after=!1;let i=new Ug(this.currentRowIndex,e,this.formattingContext);this.column.breakPositions.push(i)}return so(!0)}afterNonInlineElementNode(t){let i=t.nodeContext,n=this.formattingContext.getRepetitiveElements(),r=i.display;if("table-header-group"===r?n&&!n.allowInsertRepeatitiveElements&&n.isHeaderSourceNode(i.sourceNode)?(this.inHeader=!1,i.viewNode.remove()):be(i.viewNode,"display","table-row-group"):"table-footer-group"===r&&(n&&!n.allowInsertRepeatitiveElements&&n.isFooterSourceNode(i.sourceNode)?(this.inFooter=!1,i.viewNode.remove()):be(i.viewNode,"display","table-row-group")),r&&e.ignoreList[r])i.viewNode.remove();else{if(i.sourceNode!==this.formattingContext.tableSourceNode){if("table-row"!==r||this.inHeader||this.inFooter)return super.afterNonInlineElementNode(t);{let e=super.afterNonInlineElementNode(t);return(e&&e.isPending()?e:so(!0)).thenAsync(()=>{if(!t.break){let e=this.column.checkOverflowAndSaveEdge(i,null),n=this.formattingContext.getRepetitiveElements(),r=this.column.nodeContextOverflowingDueToRepetitiveElements===i,o=!e&&r&&!(null==n||!n.isFooterRegistered());(e||r)&&!o&&0===this.formattingContext.getRowSpanningCellsOverflowingTheRow(this.currentRowIndex).length&&(this.resetColumn(),i.overflow=!0,t.break=!0)}return so(!0)})}}i.overflow=this.column.checkOverflowAndSaveEdge(i,null),this.resetColumn(),t.break=!0}return so(!0)}};h(Xg,"ignoreList",{"table-caption":!0,"table-column-group":!0,"table-column":!0});var Yg=Xg,Kg=[],Zg=class{layoutEntireTable(e,t){let i=e.formattingContext,n=new qg(i,t);return new dh(n,t.layoutContext).iterate(e)}getColumnWidths(e,t,i,n){let r=e.ownerDocument,o=r.createElement("tr"),s=[];for(let e=0;e<t;e++){let e=r.createElement("td");o.appendChild(e),s.push(e)}e.after(o);let a=s.map(e=>{let t=Ua(n,e,i),r=i?t.height:t.width;return Math.ceil(r)});return o.remove(),a}getColGroupElements(e){let t=[],i=e.firstElementChild;for(;i;)"colgroup"===i.localName&&t.push(i),i=i.nextElementSibling;return t}normalizeAndGetColElements(e){let t=[];return e.forEach(e=>{let i=e.span;e.removeAttribute("span");let n=e.firstElementChild;for(;n;){if("col"===n.localName){let r=n.span;for(n.removeAttribute("span"),i-=r;r-- >1;){let i=n.cloneNode(!0);e.insertBefore(i,n),t.push(i)}t.push(n)}n=n.nextElementSibling}for(;i-- >0;)n=e.ownerDocument.createElement("col"),e.appendChild(n),t.push(n)}),t}addMissingColElements(e,t,i,n){if(e.length<i){let r=n.ownerDocument.createElement("colgroup");t.push(r);for(let t=e.length;t<i;t++){let t=n.ownerDocument.createElement("col");r.appendChild(t),e.push(t)}}}normalizeColGroups(e,t,i){let n=e.vertical,r=e.lastRowViewNode;if(!r)return;e.lastRowViewNode=null;let o=r.ownerDocument.createDocumentFragment(),s=e.getColumnCount();if(!(s>0))return void(e.colGroups=o);let a=e.colWidths=this.getColumnWidths(r,s,n,i.clientLayout),l=this.getColGroupElements(t),h=this.normalizeAndGetColElements(l);this.addMissingColElements(h,l,s,t),h.forEach((e,t)=>{be(e,n?"height":"width",`${a[t]}px`)}),l.forEach(e=>{o.appendChild(e.cloneNode(!0))}),e.colGroups=o}doInitialLayout(e,t){let i=e.formattingContext;i.vertical=e.vertical,i.initializeRepetitiveElements(e.vertical);let n=function(e){let t=Kg.findIndex(t=>t.root===e),i=Kg[t];return i?i.tableLayoutOption:null}(e.sourceNode);!function(e){let t=Kg.findIndex(t=>t.root===e);t>=0&&Kg.splice(t,1)}(e.sourceNode);let r=oo("TableLayoutProcessor.doInitialLayout"),o=e.copy();return this.layoutEntireTable(e,t).then(s=>{var a;let l=s.viewNode,h=i.rows[0];if(h&&Ns(h.breakBefore)&&this.hasInFlowContentBefore(l,t))return null==(a=l.parentNode)||a.removeChild(l),t.pageBreakType=h.breakBefore,void r.finish(o);let u=Ua(t.clientLayout,l,t.vertical),c=t.vertical?u.left:u.bottom;if(c+=(t.vertical?-1:1)*th(e,t.collectElementsOffset()).current,!(t.isOverflown(c)||n&&n.calculateBreakPositionsInside||this.hasForcedBreakInRows(i)))return t.breakPositions.push(new im(o)),void r.finish(s);this.normalizeColGroups(i,l,t),i.updateCellSizes(t.clientLayout),r.finish(null)}),r.result()}hasForcedBreakInRows(e){for(let t=0;t<e.rows.length;t++){let i=e.rows[t];if(i&&(t>0&&Ns(i.breakBefore)||t<e.rows.length-1&&Ns(i.breakAfter)))return!0}return!1}hasInFlowContentBefore(e,t){let i=e;for(;i&&i!==t.element;){let e=i.previousSibling;for(;e;){if(1===e.nodeType&&!Qa(e)||3===e.nodeType&&!Qs(e))return!0;e=e.previousSibling}i=i.parentNode}return!1}addCaptions(e,t,i){let n=e.captions;n.forEach((e,r)=>{e&&(t.insertBefore(e.viewNode,i),"top"===e.side&&(n[r]=null))})}addColGroups(e,t,i){e.colGroups&&0===this.getColGroupElements(t).length&&(t.insertBefore(e.colGroups.cloneNode(!0),i),be(t,"table-layout","fixed"),be(t,e.vertical?"height":"width",`${e.tableWidth}px`))}removeColGroups(e,t){if(e.colGroups&&t){let e=this.getColGroupElements(t);e&&e.forEach(e=>{t.removeChild(e)})}}doLayout(e,t){let i=e.formattingContext,n=i.getRootViewNode(e),r=n.firstChild;this.addCaptions(i,n,r),this.addColGroups(i,n,r);let o=new Yg(i,t),s=new dh(o,t.layoutContext),a=oo("TableFormattingContext.doLayout");return s.iterate(e).thenFinish(a),a.result()}layout(e,t,i){let n=e.formattingContext;if(n.getRootViewNode(e)){if(i){let i=n.getRepetitiveElements();i&&e.sourceNode!==n.tableSourceNode&&!e.after&&!i.isFooterRegistered()&&i.preventSkippingHeader(),Rg(e.parent,t)}return new em(n,this).layout(e,t)}return t.buildDeepElementView(e)}createEdgeBreakPosition(e,t,i,n){return new Vg(e,t,i,n)}startNonInlineElementNode(e){return!1}afterNonInlineElementNode(e,t){return Qg(e),!1}finishBreak(e,t,i,n){let r=t.formattingContext;if("table-row"===t.display){let i,n=r.findRowIndexBySourceNode(t.sourceNode);if(i=t.after?r.getRowSpanningCellsOverflowingTheRow(n):r.getCellsFallingOnRow(n),r.cellBreakPositions=r.cellBreakPositions.filter(e=>!i.includes(e.cell)),i.length){let o=oo("TableLayoutProcessor.finishBreak"),s=0;return o.loopWithFrame(e=>{if(s===i.length)return void e.breakLoop();let t=i[s++],o=r.getCellFragmentOfCell(t),a=o.findAcceptableBreakPosition().nodeContext,l=o.cellNodeContext,h=l.toNodePosition(),u=new Ea(a.toNodePosition());r.cellBreakPositions.push({cellNodePosition:h,breakChunkPosition:u,cell:t});let c=l.viewNode;o.column.layoutContext.processFragmentedBlockEdge(o.cellNodeContext),n<t.rowIndex+t.rowSpan-1&&(c.rowSpan=n-t.rowIndex+1),o.empty?e.continueLoop():o.pseudoColumn.finishBreak(a,!1,!0).then(()=>{(function(e,t,i){let n=t.getRepetitiveElements();if(!n||!n.isHeaderRegistered()&&!n.isFooterRegistered())return;let r=t.vertical,o=e.column,s=e.pseudoColumn.getColumnElement(),a=e.cellNodeContext.viewNode,l=Ua(o.clientLayout,a,r),h=o.getComputedPaddingBorder(a);if(r){be(s,"max-width",`${l.right-o.footnoteEdge-n.calculateOffset(i)-h.right}px`)}else{be(s,"max-height",`${o.footnoteEdge-n.calculateOffset(i)-l.top-h.top}px`)}})(o,r,a),e.continueLoop()})}).then(()=>{e.clearOverflownViewNodes(t,!1),e.layoutContext.processFragmentedBlockEdge(t),Qg(t),r.finishFragment(),o.finish(!0)}),o.result()}}return Qg(t),r.finishFragment(),sh.finishBreak(e,t,i,n)}clearOverflownViewNodes(e,t,i,n){rh.prototype.clearOverflownViewNodes(e,t,i,n)}};function Jg(e){let t=e.matches("td, th")?e:e.closest("td, th");if(!t||"baseline"!==t.style.verticalAlign)return;let i=t.querySelector(".-vivliostyle-table-cell-container");if(!i)return;let n=i.children;if(0!==n.length){for(let e=0;e<n.length;e++){let t=n[e].style.position;if("absolute"!==t&&"fixed"!==t)return}be(i,"display","contents")}}function Qg(e){let t=e.display;if("table-row"!==t&&"table"!==t)return;let i,n=Sa(e),r="table-row"===t?n.viewNode.parentElement:n.viewNode.querySelector("tbody");if(!r)return;try{i=r.querySelectorAll(":scope>tr:has(>:empty):not(:has(>:not([rowspan]:not([rowspan='1']),:empty)))")}catch{return}if(0===i.length)return;let o=Array.from(i).reduce((t,i)=>{let n=i.getBoundingClientRect();return t+(e.vertical?n.width:n.height)},0),s=i[i.length-1],a=Array.from(r.children).indexOf(s),l=Array.from(s.children).reduce((e,t)=>{let i=t.rowSpan;return i>1&&a+i<r.childElementCount?Math.max(e,i):e},0),h=l?r.children[a+l-1]:r.lastElementChild;if(h!=r.lastElementChild&&h.querySelector(":scope>*>div>div"))for(let e=h;e&&e!==r.lastElementChild;e=e.nextElementSibling)if(e.querySelector(":scope>[rowspan]:not([rowspan='1'])")){h=e;break}let u=h.getBoundingClientRect(),c=o+(e.vertical?u.width:u.height);be(h,e.vertical?"width":"height",`${c}px`)}var em=class extends lh{constructor(e,t){super(),h(this,"tableFormattingContext",e),h(this,"processor",t)}resolveLayoutMode(e){let t=this.tableFormattingContext.getRepetitiveElements();return t&&t.doneInitialLayout?(e.sourceNode===this.tableFormattingContext.tableSourceNode&&!e.after&&t&&t.preventSkippingHeader(),new rm(this.tableFormattingContext,this.processor)):new tm(this.tableFormattingContext,this.processor)}clearNodes(e){super.clearNodes(e);let t=this.tableFormattingContext.getRootViewNode(e);this.processor.removeColGroups(this.tableFormattingContext,t)}restoreState(e,t){super.restoreState(e,t),this.tableFormattingContext.finishFragment()}},tm=class extends Pg{constructor(e,t){super(e),h(this,"processor",t)}doLayout(e,t){return this.processor.doInitialLayout(e,t)}},im=class extends ih{constructor(e){super(e,null,e.overflow,0)}getMinBreakPenalty(){if(!this.isEdgeUpdated)throw new Error("EdgeBreakPosition.prototype.updateEdge not called");return(this.overflows?3:0)+(this.position.parent?this.position.parent.breakPenalty:0)}breakPositionChosen(e){e.fragmentLayoutConstraints.push(new nm(this.position.sourceNode))}},nm=class e{constructor(e){h(this,"tableRootNode",e),h(this,"flagmentLayoutConstraintType","EntireTable")}allowLayout(e,t,i){return e.overflow,!1}nextCandidate(e){return!0}postLayout(e,t,i,n){Kg.push({root:t.sourceNode,tableLayoutOption:{calculateBreakPositionsInside:!0}})}finishBreak(e,t){return so(!0)}equalsTo(t){return t instanceof e&&t.tableRootNode===this.tableRootNode}getPriorityOfFinishBreak(){return 0}},rm=class extends Eg{constructor(e,t){super(e),h(this,"processor",t)}doLayout(e,t){let i=this.formattingContext.getRepetitiveElements();if(i&&!i.isAfterLastContent(e)){let i=new om(e);t.fragmentLayoutConstraints.some(e=>i.equalsTo(e))||t.fragmentLayoutConstraints.unshift(i)}return this.processor.doLayout(e,t)}},om=class e extends Ig{constructor(e){super(e),h(this,"flagmentLayoutConstraintType","TableRow"),h(this,"cellFragmentLayoutConstraints",[])}allowLayout(e,t,i){let n=this.getRepetitiveElements();return!(n&&!i.pseudoParent&&!Ya(this.nodeContext.viewNode)&&n.isEnableToUpdateState())||(!(t&&!e||e&&e.overflow)||!Og(e,t,n))}nextCandidate(e){let t=this.nodeContext.formattingContext;return!!this.collectCellFragmentLayoutConstraints(e,t).some(t=>t.constraints.some(t=>t.nextCandidate(e)))||super.nextCandidate(e)}postLayout(e,t,i,n){let r=this.nodeContext.formattingContext;if(this.cellFragmentLayoutConstraints=this.collectCellFragmentLayoutConstraints(t,r),this.cellFragmentLayoutConstraints.forEach(t=>{t.constraints.forEach(r=>{r.postLayout(e,t.breakPosition,i,n)})}),!e){let e=r.getRootViewNode(this.nodeContext);(new Zg).removeColGroups(r,e),this.removeDummyRowNodes(i)}super.postLayout(e,t,i,n)}finishBreak(e,t){this.nodeContext.formattingContext;let i=oo("finishBreak"),n=this.cellFragmentLayoutConstraints.reduce((e,t)=>e.concat(t.constraints.map(e=>({constraint:e,breakPosition:t.breakPosition}))),[]),r=0;return i.loop(()=>{if(r<n.length){let e=n[r++];return e.constraint.finishBreak(e.breakPosition,t).thenReturn(!0)}return so(!1)}).then(()=>{i.finish(!0)}),i.result().thenAsync(()=>super.finishBreak(e,t))}removeDummyRowNodes(e){if(e&&"table-row"===e.display&&e.viewNode)for(;e.viewNode.previousElementSibling;){let t=e.viewNode.previousElementSibling;t.parentNode&&t.parentNode.removeChild(t)}}collectCellFragmentLayoutConstraints(e,t){return this.getCellFragemnts(e,t).map(e=>({constraints:e.fragment.pseudoColumn.getColumn().fragmentLayoutConstraints,breakPosition:e.breakPosition}))}getCellFragemnts(e,t){let i=Number.MAX_VALUE;e&&"table-row"===e.display&&(i=t.findRowIndexBySourceNode(e.sourceNode)+1),i=Math.min(t.cellFragments.length,i);let n=[];for(let e=0;e<i;e++)t.cellFragments[e]&&t.cellFragments[e].forEach(e=>{e&&n.push({fragment:e,breakPosition:e.findAcceptableBreakPosition().nodeContext})});return n}getElementsOffsetsForTableCell(e){let t=this.nodeContext.formattingContext,i=t.findCellFromColumn(e);return i?t.collectElementsOffsetOfUpperCells(i):t.collectElementsOffsetOfHighestColumn()}equalsTo(t){return t instanceof e&&this.nodeContext.formattingContext===t.nodeContext.formattingContext}},sm=new Zg;function am(e){return e.reduce((e,t)=>e+t,0)/e.length}_("RESOLVE_FORMATTING_CONTEXT",function(e,t,i,n,r,o){if(!t)return null;if(i===di.table){let t=e.parent;return new Hg(t?t.formattingContext:null,e.sourceNode)}return null}),_("RESOLVE_LAYOUT_PROCESSOR",function(e){return e instanceof Hg?sm:null});var lm=class{constructor(e,t){h(this,"layoutResult",e),h(this,"penalty",t)}};function hm(e){return e.vertical?e.width:e.height}function um(e,t){e.vertical?e.width=t:e.height=t}var cm=class{constructor(e,t,i){h(this,"layoutContainer",e),h(this,"columnGenerator",t),h(this,"regionPageFloatLayoutContext",i),h(this,"originalContainerBlockSize"),this.originalContainerBlockSize=hm(e)}balanceColumns(e){let t=oo("ColumnBalancer#balanceColumns");this.layoutContainer.element.setAttribute("data-vivliostyle-in-column-balancing","true"),this.preBalance(e),this.savePageFloatLayoutContexts(e),this.layoutContainer.clear();let i=[this.createTrialResult(e)];return t.loopWithFrame(e=>{this.hasNextCandidate(i)?(this.updateCondition(i),this.columnGenerator().then(t=>{this.savePageFloatLayoutContexts(t),this.layoutContainer.clear(),t?(i.push(this.createTrialResult(t)),e.continueLoop()):e.breakLoop()})):e.breakLoop()}).then(()=>{let e=i.reduce((e,t)=>t.penalty<e.penalty?t:e,i[0]);this.layoutContainer.element.removeAttribute("data-vivliostyle-in-column-balancing"),this.restoreContents(e.layoutResult),this.tightenColumnBlockSizes(e.layoutResult.columns),this.postBalance(),t.finish(e.layoutResult)}),t.result()}createTrialResult(e){let t=this.calculatePenalty(e);return new lm(e,t)}preBalance(e){}postBalance(){um(this.layoutContainer,this.originalContainerBlockSize)}tightenColumnBlockSizes(e){if(e.length<=1)return;let t=Math.max.apply(null,e.map(e=>e.computedBlockSize));if(!(t<=0))for(let i of e)if(i.vertical){let e=parseFloat(i.element.style.width),n=parseFloat(i.element.style.left);if(isFinite(e)&&isFinite(n)&&e>t){let r=n+e-t;be(i.element,"width",`${t}px`),be(i.element,"left",`${r}px`),i.width=t,i.left=r}}else{let e=parseFloat(i.element.style.height);isFinite(e)&&e>t&&(be(i.element,"height",`${t}px`),i.height=t)}}savePageFloatLayoutContexts(e){let t=this.regionPageFloatLayoutContext.detachChildren();e&&(e.columnPageFloatLayoutContexts=t)}restoreContents(e){let t=this.layoutContainer.element;e.columns.forEach(e=>{t.appendChild(e.element)}),e.columnPageFloatLayoutContexts,this.regionPageFloatLayoutContext.attachChildren(e.columnPageFloatLayoutContexts)}};function dm(e){let t=e[e.length-1];if(0===t.penalty)return!1;let i=e[e.length-2];if(i&&t.penalty>=i.penalty)return!1;let n=t.layoutResult.columns;return Math.max.apply(null,n.map(e=>e.computedBlockSize))>Math.max.apply(null,n.map(e=>e.getMaxBlockSizeOfPageFloats()))+1}function pm(e,t){let i=e[e.length-1].layoutResult.columns,n=Math.max.apply(null,i.map(e=>isNaN(e.blockDistanceToBlockEndFloats)?e.computedBlockSize:e.computedBlockSize-e.blockDistanceToBlockEndFloats+1))-1;n<hm(t)?um(t,n):um(t,hm(t)-1)}var fm=class extends cm{constructor(e,t,i,n){super(i,e,t),h(this,"columnCount",n),h(this,"originalPosition",null),h(this,"foundUpperBound",!1)}preBalance(e){let t=e.columns.reduce((e,t)=>e+t.computedBlockSize,0);um(this.layoutContainer,t/this.columnCount),this.originalPosition=e.position}checkPosition(e){return this.originalPosition?this.originalPosition.isSamePosition(e):null===e}calculatePenalty(e){if(!this.checkPosition(e.position))return 1/0;let t=e.columns;return gm(t)?1/0:Math.max.apply(null,t.map(e=>e.computedBlockSize))}hasNextCandidate(e){if(1===e.length)return!0;if(this.foundUpperBound)return dm(e);{let t=e[e.length-1];return this.checkPosition(t.layoutResult.position)&&!gm(t.layoutResult.columns)?(this.foundUpperBound=!0,!0):hm(this.layoutContainer)<this.originalContainerBlockSize}}updateCondition(e){if(this.foundUpperBound)pm(e,this.layoutContainer);else{let e=Math.min(this.originalContainerBlockSize,hm(this.layoutContainer)+.1*this.originalContainerBlockSize);um(this.layoutContainer,e)}}};function gm(e){if(e.length<=1)return!1;let t=e[e.length-1].computedBlockSize,i=e.slice(0,e.length-1),n=Math.max(...e.map(e=>e.lastLineStride||0)),r=n>0?n/2:6;return i.every(e=>t>e.computedBlockSize+r)}var mm=class extends cm{constructor(e,t,i){super(i,e,t)}calculatePenalty(e){if(e.columns.every(e=>0===e.computedBlockSize))return 1/0;let t=e.columns.filter(e=>!e.pageBreakType).map(e=>e.computedBlockSize);return function(e){let t=am(e);return am(e.map(e=>{let i=e-t;return i*i}))}(t)}hasNextCandidate(e){return dm(e)}updateCondition(e){pm(e,this.layoutContainer)}},vm=class{constructor(e,t,i){h(this,"endStuckFixed"),h(this,"endFixed"),h(this,"endSlipped"),this.endStuckFixed=e,this.endFixed=t,this.endSlipped=i}},ym=class{constructor(){h(this,"map",[])}getMaxFixed(){return 0==this.map.length?0:this.map[this.map.length-1].endFixed}getMaxSlipped(){return 0==this.map.length?0:this.map[this.map.length-1].endSlipped}addStuckRange(e){if(0==this.map.length)this.map.push(new vm(e,e,e));else{let t=this.map[this.map.length-1],i=t.endSlipped+e-t.endFixed;t.endFixed==t.endStuckFixed?(t.endFixed=e,t.endStuckFixed=e,t.endSlipped=i):this.map.push(new vm(e,e,i))}}addSlippedRange(e){0==this.map.length?this.map.push(new vm(e,0,0)):this.map[this.map.length-1].endFixed=e}slippedByFixed(e){let t=Le(this.map.length,t=>e<=this.map[t].endFixed),i=this.map[t];return i.endSlipped-Math.max(0,i.endStuckFixed-e)}fixedBySlipped(e){let t=Le(this.map.length,t=>e<=this.map[t].endSlipped),i=this.map[t];return i.endStuckFixed-(i.endSlipped-e)}};function bm(e){let t={};return Object.keys(e).forEach(i=>{t[i]=Array.from(e[i])}),t}var wm=class e{constructor(t,i,n,r,o,s,a,l){if(h(this,"context",t),h(this,"style",i),h(this,"offset",n),h(this,"isRoot",r),h(this,"flowChunk",o),h(this,"atBlockStart",s),h(this,"atFlowStart",a),h(this,"isParentBoxDisplayed",l),h(this,"flowName"),h(this,"isBlockValue",null),h(this,"hasBoxValue",null),h(this,"styleValues",{}),h(this,"beforeBox",null),h(this,"afterBox",null),h(this,"breakBefore",null),this.flowName=o.flowName,this.hasBox()){let r=i._pseudos;if(r&&r.before){let i=new e(t,r.before,n,!1,o,this.isBlock(),a,!0);Oa(i.styleValue("content"))&&(this.beforeBox=i,this.breakBefore=i.breakBefore)}}this.breakBefore=Os(this.getBreakValue("before"),this.breakBefore),this.atFlowStart&&Ns(this.breakBefore)&&(o.breakBefore=Os(o.breakBefore,this.breakBefore))}buildAfterPseudoElementBox(t,i,n){if(this.hasBox()){let r=this.style._pseudos;if(r&&r.after){let o=new e(this.context,r.after,t,!1,this.flowChunk,i,n,!0);Oa(o.styleValue("content"))&&(this.afterBox=o)}}}styleValue(e,t){if(!(e in this.styleValues)){let i=this.style[e];this.styleValues[e]=i?i.evaluate(this.context,e):t||null}return this.styleValues[e]}displayValue(){return this.styleValue("display",di.inline)}isBlock(){if(null===this.isBlockValue){let e=this.displayValue(),t=this.styleValue("position"),i=this.styleValue("float");this.isBlockValue=function(e,t,i,n){return gs(e,t,i,n).display===di.block}(e,t,i,this.isRoot)}return this.isBlockValue}hasBox(){return null===this.hasBoxValue&&(this.hasBoxValue=this.isParentBoxDisplayed&&this.displayValue()!==di.none&&!fs(this.styleValue("position"))),this.hasBoxValue}getBreakValue(e){let t=null;if(this.isBlock()){let i=this.styleValue(`break-${e}`);i&&(t=i.toString())}return t}},xm=class{constructor(e){h(this,"context",e),h(this,"stack",[]),h(this,"atBlockStart",!0),h(this,"atFlowStart",!0),h(this,"atStartStack",[])}empty(){return 0===this.stack.length}lastBox(){return this.stack[this.stack.length-1]}lastFlowName(){let e=this.lastBox();return e?e.flowChunk.flowName:null}isCurrentBoxDisplayed(){return this.stack.every(e=>e.displayValue()!==di.none)}push(e,t,i,n){let r=this.lastBox();n&&r&&n.flowName!==r.flowName&&this.atStartStack.push({atBlockStart:this.atBlockStart,atFlowStart:this.atFlowStart});let o=n||r.flowChunk,s=this.atFlowStart||!!n,a=this.isCurrentBoxDisplayed(),l=new wm(this.context,e,t,i,o,s||this.atBlockStart,s,a);return this.stack.push(l),this.atBlockStart=l.hasBox()?!l.beforeBox&&l.isBlock():this.atBlockStart,this.atFlowStart=l.hasBox()?!l.beforeBox&&s:this.atFlowStart,l}encounteredTextNode(e){let t=this.lastBox();if((e.nodeType===Node.TEXT_NODE||e.nodeType===Node.CDATA_SECTION_NODE)&&(this.atBlockStart||this.atFlowStart)&&t.hasBox()){let i=Js(t.styleValue("white-space",di.normal).toString());i&&!Qs(e,i)&&(this.atBlockStart=!1,this.atFlowStart=!1)}}pop(e){let t=this.stack.pop();if(t.buildAfterPseudoElementBox(e,this.atBlockStart,this.atFlowStart),this.atFlowStart&&t.afterBox){let e=t.afterBox.getBreakValue("before");t.flowChunk.breakBefore=Os(t.flowChunk.breakBefore,e)}let i=this.lastBox();if(i)if(i.flowName===t.flowName)t.hasBox()&&(this.atBlockStart=this.atFlowStart=!1);else{let e=this.atStartStack.pop();this.atBlockStart=e.atBlockStart,this.atFlowStart=e.atFlowStart}return t}nearestBlockStartOffset(e){if(!e.atBlockStart)return e.offset;let t=this.stack.length-1,i=this.stack[t];for(i===e&&(t--,i=this.stack[t]);t>=0;){if(i.flowName!==e.flowName)return e.offset;if(!i.atBlockStart||i.isRoot)return i.offset;e=i,i=this.stack[--t]}throw new Error("No block start offset found!")}},Sm=class{constructor(e){h(this,"xmldoc",e),h(this,"map",{})}setAt(e,t){this.map[`e${e}`]=t}styleOf(e){return this.map[`e${this.xmldoc.getElementOffset(e)}`]}},Cm=class{constructor(e,t,i,n,r,o,s,a,l,u,c){h(this,"xmldoc",e),h(this,"scope",i),h(this,"context",n),h(this,"primaryFlows",r),h(this,"validatorSet",o),h(this,"counterListener",s),h(this,"root"),h(this,"cascadeHolder"),h(this,"last"),h(this,"rootStyle",{}),h(this,"bodyPropagatedStyle",{}),h(this,"styles"),h(this,"counterSnapshots",[]),h(this,"flows",{}),h(this,"flowChunks",[]),h(this,"flowListener",null),h(this,"flowToReach",null),h(this,"idToReach",null),h(this,"cascade"),h(this,"elementWindow"),h(this,"offsetMap"),h(this,"primary",!0),h(this,"primaryStack",[]),h(this,"rootBackgroundAssigned",!1),h(this,"rootLayoutAssigned",!1),h(this,"lastOffset"),h(this,"breakBeforeValues",{}),h(this,"boxStack"),h(this,"bodyReached",!0),this.root=e.root,this.cascadeHolder=t,this.styles=new Sm(e),this.last=Ce.atRoot(this.root),this.cascade=t.createInstance(n,s,a,e.lang,l,u,this.root,i,o,this.styles,c),this.offsetMap=new ym;let d=e.getElementOffset(this.root);this.lastOffset=d,this.boxStack=new xm(n),this.offsetMap.addStuckRange(d);let p=this.getAttrStyle(this.root);this.elementWindow=this.cascade.pushElement(this.root,p,d),this.recordCounterSnapshot(d,this.cascade.counters,this.cascade.lastCounterChanges,this.cascade.lastCounterChangeTypes),this.postprocessTopStyle(p,!1),this.determineRootSizes(p),"http://www.w3.org/1999/xhtml"===this.root.namespaceURI&&(this.bodyReached=!1),this.primaryStack.push(!0),this.styles.setAt(d,p),this.lastOffset++,this.replayFlowElementsFromOffset(-1)}hasProp(e,t,i){let n=e[i];return n&&n.evaluate(this.context)!==t[i]}transferPropsToRoot(e,t){for(let i in t){let n=e[i];if(n)this.rootStyle[i]=n,delete e[i];else{let e=t[i];e&&(this.rootStyle[i]=new Cd(e,Lo))}}}postprocessTopStyle(e,t){if(t)for(let t of["writing-mode","direction"])e[t]&&!this.rootStyle[t]&&(this.rootStyle[t]=e[t],this.bodyPropagatedStyle[t]=e[t]);else for(let t in e)Ud(t)&&(this.rootStyle[t]=e[t]);if(!this.rootBackgroundAssigned){let t=this.hasProp(e,this.validatorSet.backgroundProps,"background-color")?e["background-color"].evaluate(this.context):null,i=this.hasProp(e,this.validatorSet.backgroundProps,"background-image")?e["background-image"].evaluate(this.context):null;if(t&&!yi(t)||i&&!yi(i)){this.transferPropsToRoot(e,this.validatorSet.backgroundProps);for(let t of["background-position-x","background-position-y"]){let i=e[t];i&&(this.rootStyle[t]=i,delete e[t])}this.rootBackgroundAssigned=!0}}if(!this.rootLayoutAssigned)for(let t=0;t<km.length;t++)if(this.hasProp(e,this.validatorSet.layoutProps,km[t])){this.transferPropsToRoot(e,this.validatorSet.layoutProps),this.rootLayoutAssigned=!0;break}}determineRootSizes(e){var t;let i=e["font-size"],n=!0;if(i&&!yi(i.value)){let e=i.evaluate(this.context),t=this.resolveRootSizingCalc(e),r=e instanceof ai&&t instanceof Jt;if(t instanceof Jt){let e=t.num;switch(t.unit){case"em":case"rem":e*=this.context.initialFontSize;break;case"%":e*=this.context.initialFontSize/100;break;case"lh":case"rlh":e*=this.context.rootLineHeight;break;default:{let i=Ke[t.unit];i&&(e*=i),n=r}}this.context.rootFontSize=e,this.context.isRelativeRootFontSize=n}}let r=null!=(t=this.context.rootFontSize)?t:this.context.initialFontSize,o=e["line-height"],s=null,a=!1;if(o&&!yi(o.value)){let e=o.evaluate(this.context),t=this.resolveRootSizingCalc(e);if(a=e instanceof ai&&t instanceof Jt,t instanceof Qt)s=t.num*r;else if(t instanceof Jt){let e=t.num;switch(t.unit){case"em":case"rem":e*=r;break;case"%":e*=r/100;break;case"lh":case"rlh":e*=this.context.rootLineHeight;break;default:{let i=Ke[t.unit];i&&(e*=i)}}s=e}}this.context.rootLineHeight=null!=s?s:this.context.fontSize()*this.context.pref.lineHeight,this.context.isRootLineHeightFromRelativeCalc=a}resolveRootSizingCalc(e){return e instanceof ai?e.visit(new zf(this.context)):e}getTopContainerStyle(){let e=0;for(;!this.bodyReached&&(e+=5e3,this.styleUntil(e,0)!=Number.POSITIVE_INFINITY););return this.rootStyle}getAttrStyle(e){if(e.style instanceof CSSStyleDeclaration){let t=e.getAttribute("style");if(t)return Af(this.scope,this.validatorSet,this.xmldoc.url,t)}return{}}recordCounterSnapshot(e,t,i=[],n){let r={offset:e,counters:bm(t),changes:Array.from(i||[]),changeTypes:n?{...n}:void 0},o=this.counterSnapshots[this.counterSnapshots.length-1];o&&o.offset===e?this.counterSnapshots[this.counterSnapshots.length-1]=r:this.counterSnapshots.push(r)}getCounterSnapshotAtOffset(e){if(!this.counterSnapshots.length)return null;let t=Le(this.counterSnapshots.length,t=>e<this.counterSnapshots[t].offset),i=0===t?0:t-1;return this.counterSnapshots[i]||null}getLastCounterSnapshot(){return this.counterSnapshots.length?this.counterSnapshots[this.counterSnapshots.length-1]:null}getReachedOffset(){return this.lastOffset}replayFlowElementsFromOffset(e){if(e>=this.lastOffset)return;let t=this.context,i=this.xmldoc.getElementOffset(this.root);if(e<i){let e=this.getStyle(this.root,!1);if(!this.cascade.firstPageType){let t=e.page,i=t&&!yi(t.value)&&t.value.toString();i&&"auto"!==i.toLowerCase()&&(this.cascade.firstPageType=i)}let n=Hd(e,"flow-into"),r=n?n.evaluate(t,"flow-into").toString():"body",o=this.encounteredFlowElement(r,e,this.root,i);this.boxStack.empty()&&this.boxStack.push(e,i,!0,o)}let n=this.xmldoc.getNodeByOffset(e),r=this.xmldoc.getNodeOffset(n,0,!1);if(!(r>=this.lastOffset))for(;;){if(1!=n.nodeType)r+=n.textContent.length;else{let e=n,i=this.getStyle(e,!1),o=i["flow-into"];if(o){let n=o.evaluate(t,"flow-into").toString();this.encounteredFlowElement(n,i,e,r)}r++}if(r>=this.lastOffset)break;let e=n.firstChild;if(null==e)for(;e=n.nextSibling,!e;)if(n=n.parentNode,n===this.root)return;n=e}}resetFlowChunkStream(e){this.flowListener=e;for(let e=0;e<this.flowChunks.length;e++)this.flowListener.encounteredFlowChunk(this.flowChunks[e],this.flows[this.flowChunks[e].flowName])}styleUntilFlowIsReached(e){this.flowToReach=e;let t=0;for(;null!=this.flowToReach&&(t+=5e3,this.styleUntil(t,0)!=Number.POSITIVE_INFINITY););}styleUntilIdIsReached(e){if(!e)return;this.idToReach=e;let t=0;for(;this.idToReach&&(t+=5e3,this.styleUntil(t,0)!==Number.POSITIVE_INFINITY););this.idToReach=null}encounteredFlowElement(e,t,i,n){let r=0,o=Number.POSITIVE_INFINITY,s=!1,a=!1,l=!1,h=t["flow-options"];if(h){let e=function(e){if(e){let t=new En;try{return e.visit(t),t.propSet}catch(e){R.warn(e,"toSet:")}}return{}}(h.evaluate(this.context,"flow-options"));s=!!e.exclusive,a=!!e.static,l=!!e.last}let u=t["flow-linger"];u&&(o=Tn(u.evaluate(this.context,"flow-linger"),Number.POSITIVE_INFINITY));let c=t["flow-priority"];c&&(r=Tn(c.evaluate(this.context,"flow-priority"),0));let d=this.breakBeforeValues[n]||null,p=this.flows[e];if(!p){let t=this.boxStack.lastFlowName();p=this.flows[e]=new ta(e,t,new oh(null))}let f=new ia(e,i,n,r,o,s,a,l,d);return this.flowChunks.push(f),this.flowToReach==e&&(this.flowToReach=null),this.flowListener&&this.flowListener.encounteredFlowChunk(f,p),f}registerForcedBreakOffset(e,t,i){if(Ns(e)){let e=this.flows[i].forcedBreakOffsets;(0===e.length||e[e.length-1]<t)&&e.push(t)}let n=this.breakBeforeValues[t];this.breakBeforeValues[t]=Os(n,e)}styleUntil(e,t){let i,n=-1;if(e<=this.lastOffset&&(i=this.offsetMap.slippedByFixed(e),n=i+t,n<this.offsetMap.getMaxSlipped()))return this.offsetMap.fixedBySlipped(n);if(null==this.last)return Number.POSITIVE_INFINITY;let r=this.context;for(;this.last;){let o=this.last.firstChild;if(null==o)for(;this.last;){if(1==this.last.node.nodeType){this.cascade.popElement(this.last.node),this.primary=this.primaryStack.pop();let e=this.boxStack.pop(this.lastOffset),t=null;if(e.afterBox){let i=e.afterBox.getBreakValue("before");this.registerForcedBreakOffset(i,e.afterBox.atBlockStart?this.boxStack.nearestBlockStartOffset(e):e.afterBox.offset,e.flowName),t=e.afterBox.getBreakValue("after")}t=Os(t,e.getBreakValue("after")),this.registerForcedBreakOffset(t,this.lastOffset,e.flowName)}if(o=this.last.nextSibling,o)break;if(this.last=this.last.parent,!this.last)return e<this.lastOffset&&(n<0&&(i=this.offsetMap.slippedByFixed(e),n=i+t),n<=this.offsetMap.getMaxSlipped())?this.offsetMap.fixedBySlipped(n):Number.POSITIVE_INFINITY}let s=o;if(this.last=s,1!=s.node.nodeType)this.lastOffset+=s.node.textContent.length,this.boxStack.encounteredTextNode(s.node),this.primary?this.offsetMap.addStuckRange(this.lastOffset):this.offsetMap.addSlippedRange(this.lastOffset);else{let o=s.node,a=this.getAttrStyle(o);this.primaryStack.push(this.primary),this.elementWindow=this.cascade.pushElement(o,a,this.lastOffset),this.cascade.lastCounterChanges.length>0&&this.recordCounterSnapshot(this.lastOffset,this.cascade.counters,this.cascade.lastCounterChanges,this.cascade.lastCounterChangeTypes);let l=o.getAttribute("id")||o.getAttributeNS("http://www.w3.org/XML/1998/namespace","id");l&&l===this.idToReach&&(this.idToReach=null),!this.bodyReached&&"body"==o.localName&&o.parentNode==this.root&&(this.postprocessTopStyle(a,!0),this.bodyReached=!0);let h,u=a["flow-into"];if(u){let e=u.evaluate(r,"flow-into").toString(),t=this.encounteredFlowElement(e,a,o,this.lastOffset);this.primary=!!this.primaryFlows[e],h=this.boxStack.push(a,this.lastOffset,o===this.root,t)}else h=this.boxStack.push(a,this.lastOffset,o===this.root),o===this.xmldoc.body&&(h.breakBefore=Os(h.flowChunk.breakBefore,h.breakBefore));let c=this.boxStack.nearestBlockStartOffset(h);if(0===c||o===this.xmldoc.body){let e=a.page,t=e&&!yi(e.value)&&e.value.toString();!this.cascade.firstPageType&&t&&"auto"!==t.toLowerCase()&&(this.cascade.firstPageType=t)}if(this.registerForcedBreakOffset(h.breakBefore,c,h.flowName),h.beforeBox){let e=h.beforeBox.getBreakValue("after");this.registerForcedBreakOffset(e,h.beforeBox.atBlockStart?c:h.offset,h.flowName)}if(this.primary&&h.displayValue()===di.none&&(this.primary=!1),this.styles.setAt(this.lastOffset,a),this.lastOffset++,this.primary?this.offsetMap.addStuckRange(this.lastOffset):this.offsetMap.addSlippedRange(this.lastOffset),this.bodyReached&&0===c)continue;if(e<this.lastOffset&&(n<0&&(i=this.offsetMap.slippedByFixed(e),n=i+t),n<=this.offsetMap.getMaxSlipped()))return this.offsetMap.fixedBySlipped(n)}}return Number.POSITIVE_INFINITY}getStyle(e,t){let i=this.xmldoc.getElementOffset(e);return t&&(i=this.xmldoc.getNodeOffset(e,0,!0)),this.lastOffset<=i&&this.styleUntil(i,0),this.styles.styleOf(e)}processContent(e,t,i){}},km=["column-count","column-width","column-fill"];function Pm(e){return Object.keys(e).filter(e=>!["src","font-family","font-display"].includes(e)).sort()}function Em(e,t){let i={};for(let n in e)i[n]=Hd(e,n).evaluate(t,n);return i}(new Date).valueOf();var Nm=class{constructor(e){h(this,"properties",e),h(this,"fontTraitKey"),h(this,"src"),h(this,"blobURLs",[]),h(this,"blobs",[]),h(this,"family"),h(this,"styleElement",null),this.fontTraitKey=function(e){let t=new Pe;for(let i of Pm(e))t.append(`${i}:${e[i].toString()};`);return t.toString()}(this.properties),this.src=this.properties.src?this.properties.src.toString():null;let t=this.properties["font-family"];this.family=t?t.stringValue():null}traitsEqual(e){return this.fontTraitKey==e.fontTraitKey}makeAtRule(e,t){let i=new Pe;i.append("@font-face {\n font-family: "),i.append(this.family),i.append(";\n ");for(let e of Pm(this.properties))i.append(e),i.append(": "),this.properties[e].appendTo(i,!0),i.append(";\n ");if(t){i.append('src: url("');let e=function(e){return URL.createObjectURL(e)}(t);i.append(e),this.blobURLs.push(e),this.blobs.push(t),i.append('")')}else i.append("src: "),i.append(e);return i.append(";\n}\n"),i.toString()}},Tm=class{constructor(e){h(this,"deobfuscator",e),h(this,"familyMap",{})}registerFamily(e,t){let i=e.family,n=this.familyMap[i],r=t.family;if(n){if(n!=r)throw new Error(`E_FONT_FAMILY_INCONSISTENT ${e.family}`)}else this.familyMap[i]=r}filterFontFamily(e){if(e instanceof si){let t=e.values,i=[];for(let e of t){let t=this.familyMap[e.stringValue()];t&&i.push(Zt(t)),i.push(e)}return new si(i)}{let t=this.familyMap[e.stringValue()];return t?new si([Zt(t),e]):e}}},Im=class{constructor(e,t,i){h(this,"head",e),h(this,"body",t),h(this,"srcURLMap",{}),h(this,"familyPrefix"),h(this,"familyCounter",0),this.familyPrefix=i||"Fnt_"}getViewFontFamily(e,t){let i=e.family,n=t.familyMap[i];return n||(n=this.familyPrefix+ ++this.familyCounter,t.familyMap[i]=n,n)}initFont(e,t,i){let n=oo("initFont"),r=e.src,o={};for(let t of Pm(e.properties))o[t]=e.properties[t];let s=this.getViewFontFamily(e,i);o["font-family"]=Zt(s);let a=new Nm(o),l=this.head.ownerDocument.createElement("style");return l.textContent=a.makeAtRule(r,t),this.head.appendChild(l),a.styleElement=l,R.debug("Load font:",r),n.finish(a),n.result()}loadFont(e,t){let i=e.src,n=e.family+";"+i+";"+e.fontTraitKey,r=this.srcURLMap[n];return r?r.piggyback(n=>{t.registerFamily(e,n),R.debug("Found already-loaded font:",i)}):(r=new yo(()=>{let n=oo("loadFont"),r=i.replace(/^url\("([^"]+)"\).*$/,"$1"),o=t.deobfuscator?t.deobfuscator(r):null;return o?Io(r,"blob").then(i=>{i.responseBlob?o(i.responseBlob).then(i=>{this.initFont(e,i,t).thenFinish(n)}):n.finish(null)}):this.initFont(e,null,t).thenFinish(n),n.result()},`loadFont ${i}`),this.srcURLMap[n]=r,r.start()),r}findOrLoadFonts(e,t){let i=[];for(let n of e)n.src&&n.family?i.push(this.loadFont(n,t)):R.warn("E_FONT_FACE_INVALID");return bo(i).thenAsync(()=>(this.reorderFontFaceRules(i),this.waitFontLoading()))}reorderFontFaceRules(e){var t;for(let i of e){let e=null==(t=i.resource)?void 0:t.styleElement;(null==e?void 0:e.parentNode)===this.head&&this.head.appendChild(e)}}waitFontLoading(){let e=this.head.ownerDocument.fonts,t=0;if(e.forEach(e=>{"unloaded"===e.status&&(t++,e.load().catch(e=>{}))}),0===t)return so(!0);let i=oo("waitFontLoading");return i.loop(()=>i.sleep(20).thenAsync(()=>"loading"===e.status?so(!0):so(!1))).thenFinish(i),i.result()}},Am=!0,Fm=[];function Rm(e,t){return e===t||(e.src||t.src?e.src===t.src:e.textContent===t.textContent)}function Om(e){let t=Array.from(e.querySelectorAll("body > :not(script):not(link):not(style) ~ script"));return Array.from(e.querySelectorAll("head > script, body > script")).filter(e=>!t.includes(e))}function Lm(e,t,i){if(!Am)return so(!1);if((null==i||!i.inHead)&&(null==i||!i.atEnd)&&Om(e.ownerDocument).includes(e))return so(!1);let n=e.textContent,r=e.src,o="module"===e.type,s=r&&r.includes("/MathJax.js");if(s){if(t.document.head.querySelector("script[src*='/MathJax.js']"))return so(!0);t.MathJax||(t.MathJax={MathML:{extensions:["content-mathml.js"]},showProcessingMessages:!1,messageStyle:"none",skipStartupTypeset:!0,CommonHTML:{linebreaks:{automatic:!0}},"fast-preview":{disabled:!0},AuthorInit:function(){t.MathJax.Hub.processSectionDelay=0}})}let a=(o||r)&&e.async&&!s,l=(o&&!a||r&&e.defer)&&!s,h=!(null!=i&&i.atEnd)&&((null==i?void 0:i.forceDefer)||l||a);if(Bm(t)||(t.onload=null),h)return Fm.some(t=>Rm(t,e))||Fm.push(e),so(!0);for(let i of t.document.head.getElementsByTagName("script"))i.hasAttribute("data-vivliostyle-scripting")&&Rm(i,e)&&t.document.head.removeChild(i);let u=t.document.createElement("script");u.textContent=n,r&&(u.src=r),u.async=!!a,u.defer=!!l,u.setAttribute("data-vivliostyle-scripting","true");for(let t of e.attributes)["src","async","defer"].includes(t.name)||u.setAttribute(t.name,t.value);if(R.debug("script:",r),r){let e=Oo(u);return t.document.head.appendChild(u),bo([e])}return t.document.head.appendChild(u),so(!0)}function _m(e,t,i){var n;let r=null!=(n=t.document.querySelector("[data-vivliostyle-textcontent]"))?n:t.document.createElement("div");return r.style.position="fixed",r.style.fontSize="0",r.setAttribute("data-vivliostyle-textcontent","true"),r.setAttribute("aria-hidden","true"),r.style.fontFamily=function(e,t){var i;let n={},r=e=>{var t;let i=null==(t=e["font-family"])?void 0:t.value;if(i)if(i.values)for(let e of i.values)n[e.stringValue()]=!0;else n[i.stringValue()]=!0;let o=e._marginBoxes;if(o)for(let e of Object.values(o))r(e)},o=e=>{if(e instanceof op)r(e.style);else if(e instanceof ip||Array.isArray(e))for(let t of Object.values(e))o(t)};for(let e of Object.values(t.cascade.code))for(let t of Object.values(null!=e?e:{}))o(t);for(let t of e.querySelectorAll("[style]"))null!=(i=t.style)&&i.fontFamily&&(n[t.style.fontFamily]=!0);return Object.keys(n).join(",")}(e,i),r.textContent=e.documentElement.textContent,t.document.body.appendChild(r),r}function Bm(e){return!!Am&&(Fm.length>0||!!e.document.head.querySelector("script[data-vivliostyle-scripting]"))}var Mm=e=>`"${(e=>String(e).replace(/[\u0000-\u001F"\\\u2028\u2029]/g,Ee))(e)}"`,Dm=(e,t,i)=>Mm(i.transformURL(kr(String(e)),t)),zm=(e,t,i)=>e.replace(/[uU][rR][lL]\(\s*"((\\([^0-9a-fA-F]+|[0-9a-fA-F]+\s*)|[^"\r\n])+)"/gm,(e,n)=>`url(${Dm(n,t,i)}`).replace(/[uU][rR][lL]\(\s*'((\\([^0-9a-fA-F]+|[0-9a-fA-F]+\s*)|[^'\r\n])+)'/gm,(e,n)=>`url(${Dm(n,t,i)}`).replace(/[uU][rR][lL]\(\s*((\\([^0-9a-fA-F]+|[0-9a-fA-F]+\s*)|[^"'\r\n\)\s])+)/gm,(e,n)=>`url(${Dm(n,t,i)}`),Vm={},Um=new Set(["base","body","head","html","link","meta","script","style","title"]);function Hm(e){if("webkit"!==X)return!1;let t=e["--viv-marker-content"];if(!t)return!1;let i=function(e){return e instanceof ii?e:e instanceof oi&&e.values[0]instanceof ii&&e.values.slice(1).every(e=>e instanceof Xt&&""===e.str.trim())?e.values[0]:null}(t);if(i)return e["list-style-type"]=di.none,e["list-style-image"]=i,delete e["--viv-marker-content"],!0;let n=function(e){if(e instanceof Xt)return e;if(e instanceof oi){let t=[];for(let i of e.values){if(!(i instanceof Xt))return null;t.push(i.str)}if(t.length>0)return new Xt(t.join(""))}return null}(t);return!!n&&(e["list-style-type"]=n,e["list-style-image"]=di.none,!0)}var $m=class e extends De{constructor(e,t,i,n,r,o,s,a,l,u,c,d,p,f,g,m=new Map,v={value:!1}){super(),h(this,"flowName",e),h(this,"context",t),h(this,"viewport",i),h(this,"styler",n),h(this,"regionIds",r),h(this,"xmldoc",o),h(this,"docFaces",s),h(this,"footnoteStyle",a),h(this,"stylerProducer",l),h(this,"page",u),h(this,"customRenderer",c),h(this,"fallbackMap",d),h(this,"documentURLTransformer",p),h(this,"pageProps",f),h(this,"cascadedPageStyle",g),h(this,"semanticFootnoteFirstRefOffsets",m),h(this,"semanticFootnoteFirstRefOffsetsInitialized",v),h(this,"document"),h(this,"exprContentListener"),h(this,"computedStyleParentFontSizeOverride",null),h(this,"computedStyleParentLineHeightOverride",null),h(this,"nodeContext",null),h(this,"viewRoot",null),h(this,"isFootnote",!1),h(this,"sourceNode",null),h(this,"offsetInNode",0),h(this,"viewNode",null),this.document=i.document,this.exprContentListener=n.counterListener.getExprContentListener()}clone(){return new e(this.flowName,this.context,this.viewport,this.styler,this.regionIds,this.xmldoc,this.docFaces,this.footnoteStyle,this.stylerProducer,this.page,this.customRenderer,this.fallbackMap,this.documentURLTransformer,this.pageProps,this.cascadedPageStyle,this.semanticFootnoteFirstRefOffsets,this.semanticFootnoteFirstRefOffsetsInitialized)}getExplicitPageType(e){let t=null==e?void 0:e.page;if(!t||yi(t.value))return null;let i=t.evaluate(this.context,"page").toString();return i&&"auto"!==i.toLowerCase()?i:null}isNormalFlowElement(e){var t,i,n;let r=this.styler.getStyle(e,!1),o=null==(t=null==r?void 0:r.display)?void 0:t.evaluate(this.styler.context,"display");if((o&&!yi(o)?o:di.inline)===di.none)return!1;let s=null==(i=null==r?void 0:r.position)?void 0:i.evaluate(this.styler.context,"position"),a=s&&!yi(s)?s:di.static;if(fs(a)||ps(a))return!1;let l=null==(n=null==r?void 0:r.float)?void 0:n.evaluate(this.styler.context,"float");return(l&&!yi(l)?l:di.none)===di.none}getFirstInFlowChildElement(e){var t;let i=e.firstChild;for(;i;){if(i.nodeType===Node.TEXT_NODE){if(!Qs(i))return null;i=i.nextSibling;continue}if(i.nodeType!==Node.ELEMENT_NODE){i=i.nextSibling;continue}let e=i;if(this.isNormalFlowElement(e)){let i=this.styler.getStyle(e,!1),n=null==(t=null==i?void 0:i.display)?void 0:t.evaluate(this.styler.context,"display");return vs(n&&!yi(n)?n:di.inline)?null:e}i=i.nextSibling}return null}getEffectiveStartPageType(e,t){let i=t,n=e;for(;n;){let e=this.getFirstInFlowChildElement(n);if(!e)return i;let t=this.getExplicitPageType(this.styler.getStyle(e,!1));t&&(i=t),n=e}return i}syncTextNodePageTypeBoundary(e){if(e.sourceNode.nodeType!==Node.TEXT_NODE||Qs(e.sourceNode)||1!==e.fragmentIndex)return;let t=e.pageType;this.styler.cascade.currentPageType!==t&&(Is(e.breakBefore)||(e.breakBefore=Os(e.breakBefore,"page")),t!==this.styler.cascade.previousPageType&&(this.styler.cascade.previousPageType=this.styler.cascade.currentPageType),this.styler.cascade.currentPageType=t)}syncSemanticFootnoteCounterToTarget(e){if("a"!==e.localName||!_l(e)||!Dl(e,this.xmldoc.url,e=>this.xmldoc.getElementOffset(e),this.semanticFootnoteFirstRefOffsets,this.semanticFootnoteFirstRefOffsetsInitialized))return;let t=e.getAttribute(Ld);if(!t)return;let i=Ml(e,this.xmldoc.url,e=>this.xmldoc.getElement(e));i&&i.setAttribute(Ld,t)}createPseudoelementShadow(e,t,i,n,r,o,s,a,l){var h,u;let c=this.getPseudoMap(n,this.regionIds,this.isFootnote,e,s);if(!c)return l;let d=[],p=ig.createElementNS("http://www.pyroxy.com/ns/shadow","root"),f=p,g=_l(t)&&!!c["footnote-call"]&&Oa(null==(h=c["footnote-call"].content)?void 0:h.value);for(let e of ng){let n;if(e){if(!c[e])continue;let s=Ll(t),a="http://www.pyroxy.com/ns/shadow"===t.namespaceURI&&"include"===t.localName&&t.classList.contains("-vivliostyle-footnote-content");if("footnote-call"==e&&!_l(t)||"footnote-marker"==e&&!(s||a||i&&this.isFootnote)&&(null==(u=this.nodeContext)||!u.pluginProps.nestedFootnoteDetached))continue;if(e.match(/^first-/)){let e=r.display;if(!e||e===di.inline)continue;let i=t.firstElementChild;if(i&&Qs(i.previousSibling)){let e=o.getStyle(i,!1);if(e){let t=Hd(e,"display");if(null!=t&&t.value&&t.value!==di.inline)continue}}}if("before"===e||"after"===e||"footnote-call"===e||"footnote-marker"===e){let t=c[e].content,i=("before"===e||"after"===e)&&(r.float===di.footnote||s||a)&&!!t;if(!t||!Oa(t.value)&&!i)continue}d.push(e),n=ig.createElementNS("http://www.w3.org/1999/xhtml","span"),sg(n,e)}else{if(g)continue;n=ig.createElementNS("http://www.pyroxy.com/ns/shadow","content")}f.appendChild(n),e.match(/^first-/)&&(f=n)}if(!d.length)return l;let m=new ag(t,n,o,s,this.exprContentListener),v=new pa(t,p,null,a,l,da.ROOTLESS,m);return l||v}getPseudoMap(e,t,i,n,r){let o=jd(e,"_pseudos");if(!o)return null;let s={};for(let e in o){let n=s[e]={};_f(n,o[e],r),If(n,r,o[e]),Lf(o[e],t,i,(e,t)=>{_f(n,t,r),Tf(t,e=>{_f(n,e,r)})})}return s}createRefShadow(e,t,i,n,r){let o=oo("createRefShadow");return this.xmldoc.store.load(e).then(s=>{let a=s;if(a){let o=a.getElement(e);if(o){let e=this.stylerProducer.getStylerForDoc(a);r=new pa(i,o,a,n,r,t,e)}}o.finish(r)}),o.result()}createShadows(e,t,i,n,r,o,s,a){let l,h=oo("createShadows"),u=null,c=r.template;if(c instanceof ii||c===di.footnote)if(c!==di.footnote||Dl(t,this.xmldoc.url,e=>this.xmldoc.getElementOffset(e),this.semanticFootnoteFirstRefOffsets,this.semanticFootnoteFirstRefOffsetsInitialized)){let e=c instanceof ii?c.url:ue("user-agent.xml#footnote",ae);l=this.createRefShadow(e,da.ROOTLESS,t,a,u)}else l=so(u);else l=so(u);return l.then(l=>{var u,c,d;let p=null;if("http://www.pyroxy.com/ns/shadow"==t.namespaceURI&&"include"==t.localName){let e=t.getAttribute("href"),i=this.xmldoc;e?i=null!=(u=null==a?void 0:a.xmldoc)?u:this.xmldoc:a&&(e="http://www.w3.org/1999/xhtml"==a.owner.namespaceURI?a.owner.getAttribute("href"):a.owner.getAttributeNS("http://www.w3.org/1999/xlink","href"),i=null!=(d=null==(c=a.parentShadow)?void 0:c.xmldoc)?d:this.xmldoc),e&&(e=ce(e,i.url),p=this.createRefShadow(e,da.ROOTED,t,a,l))}null==p&&(p=so(l));let f=null;p.then(l=>{if(r.display===di.table_cell){let e=ue("user-agent.xml#table-cell",ae);f=this.createRefShadow(e,da.ROOTLESS,t,a,l)}else f=so(l);f.then(l=>{l=this.createPseudoelementShadow(e,t,i,n,r,o,s,a,l),h.finish(l)})})}),h.result()}setViewRoot(e,t){this.viewRoot=e,this.isFootnote=t}computeStyle(e,t,i,n){var r;let o=this.context,s=Of(i,o,this.regionIds,this.isFootnote),a=!(null!=(r=this.nodeContext)&&r.parent);if(a){let e=this.styler.rootStyle["writing-mode"];!s["writing-mode"]&&e&&this.styler.bodyPropagatedStyle["writing-mode"]!==e&&(s["writing-mode"]=e);let t=this.styler.rootStyle.direction;!s.direction&&t&&this.styler.bodyPropagatedStyle.direction!==t&&(s.direction=t)}let l=e,h=e=Ff(s,o,e);if(a&&!e){let t=this.styler.rootStyle["writing-mode"];t&&this.styler.bodyPropagatedStyle["writing-mode"]===t&&(h=Ff({"writing-mode":t},o,e))}let u=!a&&e!==l;t=Rf(s,o,t);let c=!!new Nt(o.style.pageScope,"left-page").evaluate(o);if(Bf(s,n,e,t,c,(t,i)=>{var n,r;let s;u&&(e?/^(min-|max-)?(height|inline-size)$/.test(t)&&(s=null!=(n=o.pageAreaHeight)?n:void 0):/^(min-|max-)?(width|inline-size)$/.test(t)&&(s=null!=(r=o.pageAreaWidth)?r:void 0));let a=i.evaluate(o,t,s,e);return("font-family"==t||"--viv-marker-font-family"==t)&&(a=this.docFaces.filterFontFamily(a)),a}),u){let t=n[e?"height":"width"];(!t||t===di.auto)&&(n[e?"height":"width"]=di.max_content)}if(fs(n.position))return n.position=di.fixed,n.visibility=di.hidden,h;let d=n.position,p=n.float,f=gs(n.display||(this.sourceNode&&"http://www.w3.org/1999/xhtml"===this.sourceNode.namespaceURI?di.inline:void 0),d,p,this.sourceNode===this.xmldoc.root);return["display","position","float"].forEach(e=>{f[e]&&(n[e]=f[e])}),h}inheritFromSourceParent(e,t){var i;let n=e.sourceNode,r=[],o=null,s=n instanceof Element&&"http://www.pyroxy.com/ns/shadow"===n.namespaceURI&&"include"===n.localName&&n.classList.contains("-vivliostyle-footnote-content"),a=this.isFootnote&&(!e.parent||s),l=e.shadowContext;if(n instanceof Element&&"http://www.pyroxy.com/ns/shadow"===n.namespaceURI&&"include"===n.localName&&n.classList.contains("-vivliostyle-footnote-content")){let e=null==l?void 0:l.owner;if(e instanceof Element&&_l(e)){let t=e.getAttribute("href")||e.getAttributeNS("http://www.w3.org/1999/xlink","href");if(t){let e=ce(t,this.xmldoc.url),r=this.xmldoc.getElement(e);r&&Ll(r)&&1===(null==(i=r.parentNode)?void 0:i.nodeType)&&(n=r.parentNode,l=null)}}}let h=-1;for(;n&&1==n.nodeType;){let e=l,t=null!==e&&e.root==n,i=t&&e.type==da.ROOTED&&Ll(n);if(!t||e.type==da.ROOTLESS||i){let t=(e?e.styler:this.styler).getStyle(n,!1);r.push(t),o=o||ke(n)}t&&!i?(n=e.owner,l=e.parentShadow):(n=n.parentNode,h++)}let u=new Set;if(r.length>0){let e=Of(r[0],this.context,this.regionIds,this.isFootnote);for(let t in e){if(!Ud(t))continue;let i=e[t].evaluate(this.context,t);i&&i!==di.inherit&&i!==di.unset&&i!==Wt&&!bi(i)&&u.add(t)}}let c=0===h,d=this.context.queryUnitSize("em",c),p={"font-size":new Cd(new Jt(d,"px"),0)};c&&(p["line-height"]=new Cd(new Qt(this.context.pref.lineHeight),0));let f=new Zd(p,this.context);for(let e=r.length-1;e>=0;--e){let t,i,n=r[e],o=[];for(let e in n)Ud(e)&&o.push(e);o.sort(xi);for(let s of o){if(e>0&&a&&s.startsWith("--viv-marker-")||e>0&&u.has(s))continue;f.setPropName(s);let o=Hd(n,s),l=o;if(o.value===di.initial)delete p[s];else if(!yi(o.value)){if("font-size"===s&&e===r.length-1&&this.context.isRelativeRootFontSize&&this.context.rootFontSize)l=new Cd(new Jt(this.context.rootFontSize,"px"),o.priority);else if("line-height"===s&&e===r.length-1&&(o.value instanceof Jt&&("lh"===o.value.unit||"rlh"===o.value.unit)||this.context.isRootLineHeightFromRelativeCalc))l=new Cd(new Jt(this.context.rootLineHeight,"px"),o.priority);else if(0===e&&o.value instanceof Jt&&"lh"===o.value.unit){let e=this.getLineHeightUnitSize(s,t,i);null!=e&&(l=new Cd(new Jt(o.value.num*e,"px"),o.priority))}else Si(s)||(l=o.filterValue(f));"font-size"===s?t=l.value:"line-height"===s&&(i=l.value),p[s]=l}}}for(let e in t)Ud(e)||(p[e]=t[e]);return{lang:o,elementStyle:p}}resolveURL(e){return e=ue(e,this.xmldoc.url),this.fallbackMap[e]||e}inheritLangAttribute(e){e.lang=ke(e.sourceNode)||e.parent&&e.parent.lang||e.lang}transferPolyfilledInheritedProps(e,t){let i=M("POLYFILLED_INHERITED_PROPS").reduce((e,t)=>e.concat(t()),[].concat(td)).filter(e=>t[e]);if(i.length){let n=e.inheritedProps;if(e.parent){n=e.inheritedProps={};for(let t in e.parent.inheritedProps)n[t]=e.parent.inheritedProps[t]}i.forEach(e=>{let i=t[e];if(i){if(yi(i))i===di.initial&&(n[e]=void 0);else if(i instanceof ei)n[e]=i.num;else if(i instanceof Kt)n[e]=i.name;else if(i instanceof Jt){let t=i;switch(t.unit){case"dpi":case"dpcm":case"dppx":n[e]=t.num*Ke[t.unit];break;default:n[e]=i}}else n[e]=i;["widows","orphans"].includes(e)||delete t[e]}})}}resolveFormattingContext(e,t,i,n,r,o){let s=M("RESOLVE_FORMATTING_CONTEXT");for(let a=0;a<s.length;a++){let l=s[a](e,t,i,n,r,o);if(l)return void(e.formattingContext=l)}}createElementView(e,t,i){var n;let r=!0,o=oo("createElementView"),s=this.sourceNode,a=e.shadowContext?e.shadowContext.styler:this.styler,l=a.getStyle(s,!1);if(this.syncSemanticFootnoteCounterToTarget(s),!e.shadowContext){let t=this.xmldoc.getElementOffset(s);Jc.registerFragmentIndex(t,e.fragmentIndex,0)}let h={},u={getStyle:e=>this.styler.getStyle(e,!1),getProp:(e,t)=>e?Hd(e,t):null,getStyleMap:(e,t)=>jd(e,t),getMutableStyleMap:(e,t)=>Wd(e,t),createCascadeValue:(e,t)=>new Cd(e,t),filterFootnoteMarkerContent:(e,t)=>e.filterValue(new rf(this.styler.cascade,t,this.styler.cascade.counterResolver,this.styler.elementWindow.currentStyle,"footnote-marker")).value};if(!e.parent){let t=this.inheritFromSourceParent(e,l);l=t.elementStyle,e.lang=t.lang}let c=l.position,d=l.float,p=l["float-reference"],f=d&&!yi(d.value)&&d.value!==di.none&&p&&!yi(p.value)?function(e){switch(e){case"inline":return ml.INLINE;case"column":return ml.COLUMN;case"region":return ml.REGION;case"page":return ml.PAGE;default:throw new Error(`Unknown float-reference: ${e}`)}}(p.value.toString()):null,g=!!e.shadowContext&&e.shadowContext.type===da.ROOTED&&Ll(s);if(e.parent&&(fs(null==c?void 0:c.value)||f&&vl(f)||g)){let t=this.inheritFromSourceParent(e,l);l=t.elementStyle,e.lang=t.lang}l=function(e,t,i,n,r,o,s){if("http://www.pyroxy.com/ns/shadow"!==e.namespaceURI||"include"!==e.localName||!e.classList.contains("-vivliostyle-footnote-content"))return t;let a=null==i?void 0:i.owner;if(!(a instanceof Element&&_l(a)))return t;let l=Ml(a,n,r);if(!l)return t;let h=a.getAttribute(o);h?(e.setAttribute(o,h),l.setAttribute(o,h)):(e.removeAttribute(o),l.removeAttribute(o));let u=s.getStyle(l);if(!u)return t;let c={...t},d=zl(u,s),p=s.getProp(u,"footnote-policy"),f=s.getStyleMap(u,"_pseudos"),g=null==f?void 0:f.after;d&&(c["footnote-display"]=d),p&&(c["footnote-policy"]=p),g&&(s.getMutableStyleMap(c,"_pseudos").after={...g});return c}(s,l,e.shadowContext,this.xmldoc.url,e=>this.xmldoc.getElement(e),Ld,u),l=function(e,t,i,n,r){if((null==i?void 0:i.type)!==da.ROOTED||!Ll(e))return t;let o=r.getStyle(e);if(!o)return t;let s={...t},a=zl(o,r),l=r.getProp(o,"footnote-policy"),h=r.getStyleMap(o,"_pseudos"),u=null==h?void 0:h["footnote-marker"],c=r.getProp(u,"content"),d=r.getProp(u,"list-style-position");if(a&&(s["footnote-display"]=a),l&&(s["footnote-policy"]=l),c&&(null==d?void 0:d.evaluate(n,"list-style-position"))===di.outside){let t=r.filterFootnoteMarkerContent(c,e);s["--viv-marker-content"]=r.createCascadeValue(t,0),s.display=r.createCascadeValue(Zt("list-item"),0),s["list-style-position"]=r.createCascadeValue(di.outside,0),s["list-style-type"]=r.createCascadeValue(di.none,0),s["list-style-image"]=r.createCascadeValue(di.none,0)}return s}(s,l,e.shadowContext,this.context,u),e.vertical=this.computeStyle(e.vertical,"rtl"===e.direction,l,h),f&&vl(f)&&h.display===di.block&&(h.display=di.flow_root),a.processContent(s,h,e),this.transferPolyfilledInheritedProps(e,h),this.inheritLangAttribute(e),h.direction&&(e.direction=h.direction.toString());let m=h["flow-into"];if(m&&m.toString()!=this.flowName)return o.finish(!1),o.result();if(Am&&"script"===s.localName&&"http://www.w3.org/1999/xhtml"===s.namespaceURI)return Lm(s,this.viewport.window).thenFinish(o),o.result();let v=h.display;if(Ll(s)&&!g&&s.hasAttribute(Rl)&&(v=h.display=di.none),yi(v)&&(v=v===di.initial||v===di.unset?di.inline:v===di.inherit&&null!=(n=e.parent)&&n.display?Zt(e.parent.display):null),v===di.none)return o.finish(!1),o.result();let y=null==e.parent,b=h[e.vertical?"width":"height"],w=!(v!==di.grid&&v!==di.inline_grid||!b||b===di.auto||yi(b));return e.flexContainer=v===di.flex||w,this.createShadows(e,s,y,l,h,a,this.context,e.shadowContext).then(i=>{var n;e.nodeShadow=i;let c=h.position,d=h.float,p=h.clear,m=e.vertical?di.vertical_rl:di.horizontal_tb,b=e.parent?e.parent.vertical?di.vertical_rl:di.horizontal_tb:m,w=function(e){return"true"===e.getAttribute("data-vivliostyle-flow-root")}(s),x=h["column-count"],S=h["column-width"],C=x&&x!==di.auto&&!yi(x)||S&&S!==di.auto&&!yi(S);e.establishesBFC=function(e,t,i,n,r,o,s){return r=r||o||di.horizontal_tb,!!s||!!i&&i!==di.none&&!yi(i)||ps(t)||e===di.inline_block||e===di.table_cell||e===di.table_caption||e==di.flex||e==di.grid||e==di.flow_root||(e===di.block||e===di.list_item)&&!!n&&n!==di.visible&&n!==di.clip&&!yi(n)||!!o&&r!==o}(v,c,d,h.overflow,m,b,C||w),e.containingBlockForAbsolute=function(e){return e===di.relative||e===di.absolute||e===di.fixed}(c),e.isInsideBFC()&&d!==di.footnote&&(!f||!vl(f))&&(d=null,p=null);let k=null,P=!1,E=this.isFootnote&&(!e.parent||e.pluginProps.nestedFootnoteDetached||g),N=function(e,t,i){var n,r;let o=(null==t?void 0:t.type)===da.ROOTED&&Ll(e)?i.getStyle(e):null;return{sourceStyle:o,footnoteDisplay:(null==(n=zl(o,i))?void 0:n.value)||null,footnotePolicy:(null==(r=i.getProp(o,"footnote-policy"))?void 0:r.value)||null}}(s,e.shadowContext,u);Ul(N.sourceStyle,h,this.context),k=N.footnoteDisplay;let T=d instanceof oi||d===di.left||d===di.right||d===di.top||d===di.bottom||d===di.inline_start||d===di.inline_end||d===di.block_start||d===di.block_end||d===di.snap_block||d===di.snap_inline||d===di.inside||d===di.outside||d===di.footnote?d.toString():null,I=null!==T;if(d&&(delete h.float,d===di.footnote))if(k=h["footnote-display"]||k,P=!!h["--viv-marker-content"],E){I=!1;let e=null==k?void 0:k.toString();e&&(h["--viv-footnote-display"]=Zt(e)),v=P?Zt("list-item"):"inline"===e||"compact"===e?di.inline:di.block,h.display=v}else h.display=di.inline;if(E&&Ll(s)){P=P||!!h["--viv-marker-content"];let e=null==k?void 0:k.toString();e&&(h["--viv-footnote-display"]=Zt(e)),P&&(v=h.display=Zt("list-item")),!P&&("inline"===e||"compact"===e)&&(v=h.display=di.inline)}p&&(p===di.inherit&&e.parent&&e.parent.clearSide&&(p=Zt(e.parent.clearSide)),(p===di.left||p===di.right||p===di.top||p===di.bottom||p===di.inline_start||p===di.inline_end||p===di.block_start||p===di.block_end||p===di.inside||p===di.outside||p===di.both||p===di.all||p===di.same||p===di.column||p===di.region||p===di.page)&&(delete h.clear,(I||h.display&&h.display!=di.inline)&&(e.clearSide=p.toString())));let A=ys(v)&&!(!h["ua-list-item-count"]&&!h["--viv-marker-content"]),F=h["break-inside"];(I||F&&!yi(F)&&F!==di.auto)&&e.breakPenalty++,v&&v!==di.inline&&vs(v)&&e.breakPenalty++,e.inline=!I&&!v||vs(v)||ws(v),e.display=v?v.toString():"inline",e.floatSide=I?T:null,e.floatReference=f||ml.INLINE;let O=h["float-min-wrap-block"];e.floatMinWrapBlock=O&&!yi(O)?O:null;let L=this.isInsideNonRootMultiColumn(e),_=h["column-span"];if(e.columnSpan=L||!_||yi(_)?null:_,!e.inline){let t=h["break-after"];t&&!yi(t)&&(!L||t!==di.column)&&(e.breakAfter=t.toString(),Es[e.breakAfter]&&(h["break-after"]=di.column));let i=h["break-before"];i&&!yi(i)&&(!L||i!==di.column)&&(e.breakBefore=i.toString(),Es[e.breakBefore]&&(this.isAtStartOfPage()?delete h["break-before"]:h["break-before"]=di.column),1!==e.fragmentIndex&&(e.breakBefore=null));let r=h.page,o=r&&!yi(r)?r.toString():null,a=o;!a&&!e.parent&&(e.shadowContext||v===di.table_header_group||v===di.table_footer_group)&&(a=this.styler.cascade.currentPageType),a&&"auto"!==a.toLowerCase()?e.pageType=a:a=e.pageType;let l=null!=o&&"auto"!==o.toLowerCase(),u=l?1===e.fragmentIndex?this.getEffectiveStartPageType(s,a):null!=(n=this.styler.cascade.currentPageType)?n:a:a;this.styler.cascade.currentPageType!==u&&(l||h.position!==di.fixed)&&(1===e.fragmentIndex&&!Is(e.breakBefore)&&(e.breakBefore="page"),u!==this.styler.cascade.previousPageType&&(this.styler.cascade.previousPageType=this.styler.cascade.currentPageType),this.styler.cascade.currentPageType=u)}e.captionSide=h["caption-side"]&&h["caption-side"].toString()||"top";let B=h["border-collapse"];if(!B||B===Zt("separate")){let t,i,n=h["border-spacing"];n&&(n instanceof oi?(t=n.values[0],i=n.values[1]):t=i=n,t.isNumeric()&&(e.inlineBorderSpacing=ui(t,this.context)),i.isNumeric()&&(e.blockBorderSpacing=ui(i,this.context)))}let M=h["footnote-policy"]||N.footnotePolicy;M&&!yi(M)&&(h["--viv-footnote-policy"]=M),e.footnotePolicy=M&&!yi(M)?M:null;let D=h["x-first-pseudo"];if(D){let t=e.parent?e.parent.firstPseudo:null;e.firstPseudo=new ga(t,D.num)}e.inline||this.processAfterIfcontinues(e,s,l,a,this.context);let z=h["white-space"];if(z){let t=Js(z.toString());null!==t&&(e.whitespace=t)}let V=h["hyphenate-character"];V&&V instanceof Xt&&(e.hyphenateCharacter=V.str);let U=h["word-break"],H=h["line-break"],$=h["overflow-wrap"];(U===di.break_all||H===di.anywhere||$===di.break_word||$===di.anywhere)&&(e.breakWord=!0),this.resolveFormattingContext(e,t,v,c,d,y),e.parent&&(t=e.parent.formattingContext.isFirstTime(e,t)),e.inline||(e.repeatOnBreak=this.processRepeatOnBreak(h),this.findAndProcessRepeatingElements(e,s,a));let j,W=!1,G=[],q=s.namespaceURI,X=s.localName,Y=X;if("http://www.w3.org/1999/xhtml"==q?(Um.has(X)?X="div":"vide_"==X?X="video":"audi_"==X?X="audio":"object"==X&&(W=!0),s.hasAttribute(rg)&&s.hasAttribute("src")&&h.content instanceof ii&&(X="img")):"http://www.idpf.org/2007/ops"==q?(X="span",q="http://www.w3.org/1999/xhtml"):"http://www.pyroxy.com/ns/shadow"==q?(q="http://www.w3.org/1999/xhtml",X=e.inline?"span":"div"):W=!0,A?t?(X="li",h["--viv-marker-content"]&&(Hm(h)||(h["list-style-type"]=di.none,h["list-style-image"]=di.none))):(v=vs(v)?di.inline:di.block,h.display=v,X="div"):"body"==X||"li"==X?X="div":"q"==X&&(X="span"),h.behavior&&"none"!=h.behavior.toString()&&(W=!0),s.dataset&&"true"===s.getAttribute("data-math-typeset")&&(W=!0),W){let t=e.parent?e.parent.viewNode:null;j=this.customRenderer(s,t,h)}else j=so(null);j.then(i=>{var n,a,l,u;if(i)W&&(r="true"==i.getAttribute("data-adapt-process-children"));else{if(h.display===di.none)return void o.finish(!1);i=this.createElement(q,X)}if(!y&&C&&h["column-fill"]===di.auto){let t=e.vertical?h.width:h.height;(!t||t===di.auto||yi(t))&&(i.setAttribute("data-viv-saved-column-fill","auto"),h["column-fill"]=di.balance)}X!=Y&&(i.setAttribute("data-vivliostyle-original-tag",Y),("html"===Y||"body"===Y)&&(i.role="presentation")),"a"==X&&i.addEventListener("click",this.page.hrefHandler,!1),"iframe"==i.localName&&"http://www.w3.org/1999/xhtml"==i.namespaceURI&&function(e){e.addEventListener("load",()=>{e.contentWindow.navigator.epubReadingSystem={name:"adapt",version:"0.1",layoutStyle:"paginated",hasFeature:function(e,t){return"mouse-events"===e}}},!1)}(i);let c=e.inheritedProps["image-resolution"],d=[],p=h.width,f=h.height,g=s.getAttribute("width"),m=s.getAttribute("height"),b=p===di.auto||!p&&!g,w=f===di.auto||!f&&!m,x=s.attributes,S=x.length,k=null,P=null,E=null==(a=null==(n=e.parent)?void 0:n.viewNode)?void 0:a.lastElementChild;v===di.table_cell&&"a"===(null==E?void 0:E.localName)&&i.appendChild(E);for(let e=0;e<S;e++){let n=x[e],r=n.namespaceURI,o=n.localName,a=n.value;if(r){if("http://www.w3.org/2000/xmlns/"==r)continue;"http://www.w3.org/1999/xlink"==r&&"href"==o&&(a=this.documentURLTransformer.transformURL(this.resolveURL(a),this.xmldoc.url))}else{if(!Am&&o.match(/^on/)||"style"==o)continue;if("media"===o&&"source"===X&&"http://www.w3.org/1999/xhtml"===q&&"picture"===(null==(l=s.parentElement)?void 0:l.localName))try{let e=this.context.rootScope,t=new Mo(e),i=hs(new to(a,t),t,"");if(i){if(i.toExpr().evaluate(this.context))continue;a="not all"}}catch{}if(("id"==o||"name"==o)&&t){let e=this.documentURLTransformer.transformFragment(a,this.xmldoc.url);i.setAttribute(o,a),i.setAttribute("data-vivliostyle-id",e);let t=i.ownerDocument.createElement("a");t.setAttribute(o,e),t.setAttribute(Za,"1"),t.style.position="absolute",i.appendChild(t),this.page.registerElementWithId(i,e);continue}if("src"==o||"href"==o||"poster"==o)a=this.resolveURL(a),a="href"===o?this.documentURLTransformer.transformURL(a,this.xmldoc.url):he(a),"src"===o&&(a=de(a));else if("srcset"==o)a=a.split(",").map(e=>{let t=e.trim().split(/\s+/),i=he(this.resolveURL(t[0]));return t.length>1?`${i} ${t.slice(1).join(" ")}`:i}).join(",");else if("data"===o&&W&&"object"===X&&i.hasAttribute("data"))continue;if("poster"===o&&"video"===X&&"http://www.w3.org/1999/xhtml"===q){let e=new Image,t=Oo(e,a);b&&w?(G.push(t),d.push({image:e,element:i,fetcher:t})):this.page.fetchers.push(t)}}if("http://www.w3.org/2000/svg"==q&&/^[A-Z\-]+$/.test(o)&&(o=o.toLowerCase()),this.isSVGUrlAttribute(o)&&(a=zm(a,this.xmldoc.url,this.documentURLTransformer)),r){let e=Vm[r];e&&(o=`${e}:${o}`)}if("src"!=o||r||"img"!=X&&"input"!=X||"http://www.w3.org/1999/xhtml"!=q)if("alt"!=o||r||"img"!=X||"http://www.w3.org/1999/xhtml"!=q)if("href"!=o||"image"!=X||"http://www.w3.org/2000/svg"!=q||"http://www.w3.org/1999/xlink"!=r&&r)if(r)i.setAttributeNS(r,o,a);else try{i.setAttribute(o,a)}catch(e){R.warn(e)}else r||i.setAttribute(o,a),this.page.fetchers.push(Oo(i,a));else P=a;else k=a}if(k){let t="input"===X?new Image:i,n=Oo(t,k,P);t!==i&&(i.src=k);let r=()=>{var t,i;if(h.position===di.fixed)return!0;for(let n=null==(t=e.parent)?void 0:t.viewNode;n&&n!==this.viewRoot;n=n.parentElement)if("fixed"===(null==(i=n.style)?void 0:i.position))return!0;return!1};b||w||(()=>{let t=e.vertical?p:f;return t instanceof Jt&&"%"===t.unit})()||r()?(b&&w&&c&&1!==c&&d.push({image:t,element:i,fetcher:n}),G.push(n)):this.page.fetchers.push(n)}else!k&&"img"===X&&"http://www.w3.org/1999/xhtml"===q&&(i.srcset||"picture"===(null==(u=s.parentElement)?void 0:u.localName))&&this.page.fetchers.push(Oo(i));delete h.content;let N=h["--viv-marker-content"];if(N){let e=N instanceof oi?N.values:[N];for(let t of e)t instanceof ii&&t.url&&G.push(Oo(new Image,t.url))}if("object"===i.localName&&"http://www.w3.org/1999/xhtml"===i.namespaceURI&&i.hasAttribute("data")&&this.page.fetchers.push(Oo(i)),"embed"===i.localName&&"http://www.w3.org/1999/xhtml"===i.namespaceURI&&i.hasAttribute("src")&&this.page.fetchers.push(Oo(i)),"iframe"===i.localName&&"http://www.w3.org/1999/xhtml"===i.namespaceURI&&i.hasAttribute("src")){let e=i;"lazy"===e.loading&&(e.loading="eager"),this.page.fetchers.push(Oo(i))}if(this.preprocessElementStyle(e,h),this.applyComputedStyles(i,h),e.inline)t||(ks(i,"inline-start"),xs(i)&&ks(i,"clone"));else if(t){if(!ps(h.position)){let t=h["margin-break"],n=this.getBreakTypeAt(e);(t===di.discard&&null!==n||t!==di.keep&&"auto"===n&&!e.floatSide)&&Ps(i,"block-start")}}else{let t=e.vertical?"width":"height";we(i,t)&&be(i,t,"table-row"===e.display?"0.01px":""),ks(i,"block-start"),xs(i)&&ks(i,"clone"),Ps(i,"block-start")}A&&h["ua-list-item-count"]&&i.setAttribute("value",h["ua-list-item-count"].stringValue()),this.viewNode=i,G.length?bo(G).then(()=>{void 0!==c&&c>0&&this.modifyElemDimensionWithImageResolution(d,c,h,e.vertical),o.finish(r)}):o.timeSlice().then(()=>{o.finish(r)})})}),o.result()}isAtStartOfPage(){var e,t;for(let i=this.nodeContext;null!=i&&i.parent&&!i.after;i=i.parent){let n=i!==this.nodeContext||i.viewNode?null==(t=i.viewNode)?void 0:t.previousSibling:null==(e=i.parent.viewNode)?void 0:e.lastChild;for(;n&&(Qs(n,i.parent.whitespace)||Qa(n));)n=n.previousSibling;if(n)return!1}return!0}isInsideNonRootMultiColumn(e){var t;let i=null==(t=e.parent)?void 0:t.viewNode;return!(!i||!ja(i))}getBreakTypeAt(e){var t,i,n,r,o;if(this.isInsideTable(e))return null;for(let i=e;i&&!i.after;i=i.parent){if(Ns(i.breakBefore))return i.breakBefore;let e=i.parent;if(1===i.fragmentIndex&&!e)return i.sourceNode===(null==(t=i.sourceNode.ownerDocument)?void 0:t.documentElement)?"page":null;if(!e)continue;if(e.floatSide)return null;let n=e.viewNode;if(n){let t=this.viewport.window.getComputedStyle(n),r=parseFloat(t.paddingBlockStart),o=parseFloat(t.borderBlockStartWidth);if(r||o)return null;let s=null==n?void 0:n.firstChild;for(;s&&(Qs(s,e.whitespace)||!i.floatSide&&Qa(s));)s=s.nextSibling;if(s&&s!==i.viewNode)return null}}let s=null!=(o=null==(r=null==(n=null==(i=this.context)?void 0:i.currentLayoutPosition)?void 0:n.flowPositions[this.flowName])?void 0:r.startBreakType)?o:null;return Ns(s)?s:"auto"}isInsideTable(e){for(let t=e;t&&!t.after;t=t.parent)if(t.display&&t.display.startsWith("table"))return!0;return!1}processAfterIfcontinues(e,t,i,n,r){let o=this.getPseudoMap(i,this.regionIds,this.isFootnote,e,r);if(o&&o["after-if-continues"]&&o["after-if-continues"].content){let o=new ag(t,i,n,r,this.exprContentListener);e.afterIfContinues=new hg(t,o)}}isSVGUrlAttribute(t){return e.SVG_URL_ATTRIBUTES.includes(t.toLowerCase())}modifyElemDimensionWithImageResolution(e,t,i,n){e.forEach(e=>{if("load"===e.fetcher.get().get()){let r=e.image,o=r.width/t,s=r.height/t,a=e.element;if(o>0&&s>0)if(i["box-sizing"]===di.border_box&&(i["border-left-style"]!==di.none&&(o+=ui(i["border-left-width"],this.context)),i["border-right-style"]!==di.none&&(o+=ui(i["border-right-width"],this.context)),i["border-top-style"]!==di.none&&(s+=ui(i["border-top-width"],this.context)),i["border-bottom-style"]!==di.none&&(s+=ui(i["border-bottom-width"],this.context))),t>1){let e=i["max-width"]||di.none,t=i["max-height"]||di.none;if(e===di.none&&t===di.none)be(a,"max-width",`${o}px`);else if(e!==di.none&&t===di.none)be(a,"width",`${o}px`);else if(e===di.none&&t!==di.none)be(a,"height",`${s}px`);else{e.isNumeric(),t.isNumeric();let i=e,r=t;"%"!==i.unit?be(a,"max-width",`${Math.min(o,ui(i,this.context))}px`):"%"!==r.unit?be(a,"max-height",`${Math.min(s,ui(r,this.context))}px`):n?be(a,"height",`${s}px`):be(a,"width",`${o}px`)}}else if(t<1){let e=i["min-width"]||mi,t=i["min-height"]||mi;e.isNumeric();let r=e,l=t;0===r.num&&0===l.num?be(a,"min-width",`${o}px`):0!==r.num&&0===l.num?be(a,"width",`${o}px`):0===r.num&&0!==l.num?be(a,"height",`${s}px`):"%"!==r.unit?be(a,"min-width",`${Math.max(o,ui(r,this.context))}px`):"%"!==l.unit?be(a,"min-height",`${Math.max(s,ui(l,this.context))}px`):n?be(a,"height",`${s}px`):be(a,"width",`${o}px`)}}})}preprocessElementStyle(e,t){M("PREPROCESS_ELEMENT_STYLE").forEach(i=>{i(e,t)})}findAndProcessRepeatingElements(e,t,i){for(let n=t.firstChild;n;n=n.nextSibling){if(1!==n.nodeType)continue;let t={},r=i.getStyle(n,!1);if(this.computeStyle(e.vertical,"rtl"===e.direction,r,t),!this.processRepeatOnBreak(t))continue;if(e.formattingContext instanceof Cg&&!e.belongsTo(e.formattingContext))return;let o=e.parent,s=o?o.formattingContext:null;return e.formattingContext=new Cg(s,e.sourceNode),void e.formattingContext.initializeRepetitiveElements(e.vertical)}}processRepeatOnBreak(e){let t=e["repeat-on-break"];return t!==di.none&&((t===di.auto||yi(t))&&(t=e.display===di.table_header_group?di.header:e.display===di.table_footer_group?di.footer:di.none),t&&t!==di.none)?t.toString():null}createTextNodeView(e){let t=oo("createTextNodeView");return this.preprocessTextContent(e).then(e=>{let i=this.offsetInNode||0,n=Hs(e).substr(i);this.viewNode=document.createTextNode(n),t.finish(!0)}),t.result()}preprocessTextContent(e){var t;if(null!=e.preprocessedTextContent)return so(e.preprocessedTextContent);let i,n=i=null!=(t=e.sourceNode.textContent)?t:"",r=oo("preprocessTextContent"),o=M("PREPROCESS_TEXT_CONTENT"),s=0;return r.loop(()=>s>=o.length?so(!1):o[s++](e,n).thenAsync(e=>(n=e,so(!0)))).then(()=>{let t=function(e,t){return(0,Us.default)(e,t,0)}(i,n);e.preprocessedTextContent=t,r.finish(t)}),r.result()}createNodeView(e,t,i){let n,r=oo("createNodeView"),o=!0;return 1==e.sourceNode.nodeType?n=this.createElementView(e,t,i):8==e.sourceNode.nodeType?(this.viewNode=null,n=so(!0)):n=this.createTextNodeView(e),n.then(t=>{var i;if(o=t,e.viewNode=this.viewNode,this.viewNode){let t=(e,t)=>1===(null==e?void 0:e.nodeType)&&og(e)===t,n=e.parent,r=n&&t(this.viewNode,"after")&&t(n.viewNode,"first-letter")?n:null,o=n?null!=(i=null==r?void 0:r.viewNode)&&i.hasChildNodes()?r.parent.viewNode:n.viewNode:this.viewRoot;e.pluginProps.nestedFootnoteDetached&&(o=this.viewRoot),o&&(e.inline&&!(3===this.viewNode.nodeType&&Qs(this.viewNode))&&!o.hasChildNodes()&&Ss(o).includes("block-start")&&ks(o,"text-start"),o.appendChild(this.viewNode),function(e){var t;if(1!==e.nodeType)return;let i=e,n=i.style,r="column"===(null==n?void 0:n.breakBefore),o=i.previousElementSibling,s=o&&"column"===(null==(t=o.style)?void 0:t.breakAfter);if(!r&&!s)return;let a=ja(i);if(!a)return;let l=a.ownerDocument.defaultView.getComputedStyle(a),{writingMode:h,direction:u,columnGap:c,fontSize:d}=l,p="vertical-rl"===h||"vertical-lr"===h,f="rtl"===u,g=(parseFloat(c)||parseFloat(d)||16)/2,m=a.getBoundingClientRect(),v=i.getBoundingClientRect();(p?v.top>m.bottom+g:f?v.right<m.left-g:v.left>m.right+g)&&(r&&(n.breakBefore=""),s&&o&&(o.style.breakAfter=""),n.marginBlockStart=`${La}px`)}(this.viewNode))}r.finish(o)}),r.result()}setCurrent(e,t,i){return this.nodeContext=e,this.sourceNode=e.sourceNode,this.offsetInNode=e.offsetInNode,this.viewNode=null,this.createNodeView(e,t,!!i)}processShadowContent(e){if(null==e.shadowContext||"content"!=e.sourceNode.localName||"http://www.pyroxy.com/ns/shadow"!=e.sourceNode.namespaceURI)return e;let t,i,n=e.boxOffset,r=e.shadowContext,o=r.subShadow||r.parentShadow;r.subShadow?(t=r.subShadow.root,i=r.subShadow.type,i==da.ROOTLESS&&(t=t.firstChild)):(t=r.owner.firstChild,i=da.ROOTLESS);let s,a=e.sourceNode.nextSibling;if(a?(e.sourceNode=a,e.resetView(),s=e):s=e.shadowSibling?e.shadowSibling:null,t){let r=ma.childOf(t,e.parent,n);return r.shadowContext=o,r.shadowType=i,r.shadowSibling=s,this.processShadowContent(r)}return null===s&&(s=e.parent.modify(),s.after=!0),s.boxOffset=n,s}nextPositionInTree(e,t){let i=e.boxOffset+1;if(e.after){let t=va(e);if(!t)return null;if(t.shadowType!=da.ROOTED){let e=t.sourceNode.nextSibling;if(e)return t=t.modify(),t.boxOffset=i,t.sourceNode=e,t.resetView(),this.processShadowContent(t)}if(t.shadowSibling){let e=t.shadowSibling.modify();return e.boxOffset=i,e}let n=t.parent.modify();return n.boxOffset=i,n.after=!0,n}{if(e.nodeShadow){let t=e.nodeShadow.root;if(e.nodeShadow.type==da.ROOTLESS&&(t=t.firstChild),t){let n=ma.childOf(t,e,i);return n.shadowContext=e.nodeShadow,n.shadowType=e.nodeShadow.type,this.processShadowContent(n)}}let n=e.sourceNode.firstChild;if(n)return this.processShadowContent(ma.childOf(n,e,i));if(t){i+=Hs(t).length-1-e.offsetInNode}return(e=e.modify()).boxOffset=i,e.after=!0,e}}findImmediateFootnoteCallSibling(t){var i;let n=this.xmldoc.getElementOffset(t.sourceNode),r=t.viewNode;if(!r)return null;let o=r.previousSibling;for(;o;){if(o.nodeType===Node.TEXT_NODE){if(0===(null!=(i=o.textContent)?i:"").trim().length){o=o.previousSibling;continue}return null}if(o.nodeType===Node.ELEMENT_NODE){let t=o;return"footnote-call"===og(t)&&t.getAttribute(e.FOOTNOTE_CALL_OWNER_ATTR)===n.toString()?t:null}return null}return null}isSemanticFootnoteElement(e){let t=e.sourceNode;return t instanceof Element&&Ll(t)}insertFootnoteCall(t){var i,n;let r=oo("insertFootnoteCall"),o=ig.createElementNS("http://www.w3.org/1999/xhtml","span");sg(o,"footnote-call");let s=this.xmldoc.getElementOffset(t.sourceNode);o.setAttribute(e.FOOTNOTE_CALL_OWNER_ATTR,s.toString());let a=ma.siblingOf(o,t,t.boxOffset);a.inline=!0;let l=new ag(t.sourceNode,this.styler.getStyle(t.sourceNode,!1),this.styler,this.context,this.exprContentListener);return a.shadowContext=new pa(t.sourceNode,o,null,(null==(i=t.parent)?void 0:i.shadowContext)||null,null,da.ROOTLESS,l),a.shadowSibling=t,t.boxOffset++,null!=(n=t.viewNode)&&n.parentNode&&t.viewNode.parentNode.removeChild(t.viewNode),this.setCurrent(a,!0,!1).then(e=>{if(e&&o.hasChildNodes())r.finish(a);else{let e=a.modify();e.after=!0,a.viewNode||(e.inline=!0),r.finish(e)}}),r.result()}nextInTree(e,t){return(e.after||1==e.sourceNode.nodeType?so(null):this.preprocessTextContent(e)).thenAsync(i=>this.nextInTreeWithPreprocessedText(e,i,t))}nextInTreeWithPreprocessedText(e,t,i){let n=this.nextPositionInTree(e,t);if(!n||n.after)return so(n);this.syncTextNodePageTypeBoundary(n);let r=n,o=oo("nextInTree");return this.setCurrent(r,!0,i).then(e=>{if((!r.viewNode||!e)&&(r=r.modify(),r.after=!0,r.viewNode||(r.inline=!0)),"footnote"===r.floatSide&&(!this.isFootnote||r.parent)&&!r.after&&!r.pluginProps.footnoteCallProcessed&&!r.shadowContext&&!this.isSemanticFootnoteElement(r)){let e=this.findImmediateFootnoteCallSibling(r);return null!=e&&e.parentNode&&e.parentNode.removeChild(e),this.isFootnote&&r.parent&&(r.pluginProps.nestedFootnoteDetached=1),r.pluginProps.footnoteCallProcessed=1,void this.insertFootnoteCall(r).then(e=>{this.dispatchEvent({type:"nextInTree",nodeContext:e}),o.finish(e)})}this.dispatchEvent({type:"nextInTree",nodeContext:r}),o.finish(r)}),o.result()}addImageFetchers(e){Xm(e,this.page)}applyComputedStyles(e,t){var i,n,r;let o=t["background-image"];o&&this.addImageFetchers(o);let s=t["border-image-source"];s&&this.addImageFetchers(s);let a=t["list-style-image"];a&&this.addImageFetchers(a);let l=t["mask-image"];l&&this.addImageFetchers(l);let h=t["clip-path"];h&&this.addImageFetchers(h);let u=t.filter;u&&this.addImageFetchers(u);let c=t["shape-outside"];c&&this.addImageFetchers(c);let d=t["--viv-marker-content"];d&&this.addImageFetchers(d);let p,f,g=t.position===di.relative,m=null===(null==(i=this.nodeContext)?void 0:i.parent)&&null===(null==(n=this.sourceNode)?void 0:n.parentElement)&&!(null==(r=this.viewRoot)||!r.parentElement),v=Object.keys(t);v.sort(xi);for(let i of v){if(Wm[i])continue;let n=t[i];if(n&&(n!==Wt||Si(i))){if(n=n.visit(new On(this.xmldoc.url,this.documentURLTransformer)),n instanceof Jt)if("em"===n.unit){let e=this.getEmUnitSize(i,p);null!=e&&(n=new Jt(n.num*e,"px"))}else if("lh"===n.unit){let e=this.getLineHeightUnitSize(i,p,f);null!=e&&(n=new Jt(n.num*e,"px"))}else Ze(n.unit)&&(n=ci(n,this.context));if(("font-size"===i||"line-height"===i)&&("font-size"===i?p=n:f=n,this.viewport.layoutUnitAdj&&n instanceof Jt&&"%"!==n.unit&&"em"!==n.unit&&"lh"!==n.unit&&(n=new hi(`calc(${n.toString()} - var(--viv-layoutUnitAdj))`))),js[i]||g&&Ws[i]){this.page.delayedItems.push(new Gs(e,i,n));continue}m&&this.page.pageAreaElement&&Ud(i)?(be(this.page.pageAreaElement.parentElement.parentElement,i,n.toString()),"writing-mode"!==i&&"direction"!==i&&be(this.viewport.layoutBox,i,n.toString())):be(e,i,n.toString())}}}parsePlusLayoutUnitAdj(e){if(e.endsWith("px")){let t=parseFloat(e);if(!isNaN(t))return Math.round((t+this.viewport.layoutUnitAdj)*this.viewport.layoutUnitPerPixel)/this.viewport.layoutUnitPerPixel}return null}getFootnoteAreaInheritedMetrics(){var e,t;let i=null==(t=null==(e=this.page.pageAreaElement)?void 0:e.parentElement)?void 0:t.parentElement,n=i?this.viewport.window.getComputedStyle(i):null,r=n&&this.parsePlusLayoutUnitAdj(n.fontSize)||this.context.rootFontSize||this.context.initialFontSize;return{fontSize:r,lineHeight:n&&this.parsePlusLayoutUnitAdj(n.lineHeight)||this.context.rootLineHeight||r*this.context.pref.lineHeight}}getComputedFontMetrics(e,t){var i,n,r;let o=this.viewport.window.getComputedStyle(e),s=null!=(i=this.parsePlusLayoutUnitAdj(o.fontSize))?i:t.fontSize;return{fontSize:s,lineHeight:null!=(r=null!=(n=this.parsePlusLayoutUnitAdj(o.lineHeight))?n:t.lineHeight)?r:null!=s?s*this.context.pref.lineHeight:null}}getParentViewStyle(){var e,t,i;return 1===(null==(i=null==(t=null==(e=this.nodeContext)?void 0:e.parent)?void 0:t.viewNode)?void 0:i.nodeType)?this.viewport.window.getComputedStyle(this.nodeContext.parent.viewNode):null}getParentComputedMetrics(e){var t,i;return{fontSize:null!=(t=this.computedStyleParentFontSizeOverride)?t:e?this.parsePlusLayoutUnitAdj(e.fontSize):this.context.rootFontSize,lineHeight:null!=(i=this.computedStyleParentLineHeightOverride)?i:e?this.parsePlusLayoutUnitAdj(e.lineHeight):this.context.rootLineHeight}}getLineHeightUnitSize(e,t,i){var n,r,o;let s=this.getParentViewStyle(),a=this.getParentComputedMetrics(s),l=a.lineHeight;if("line-height"===e||"font-size"===e)return l;let h=null;if(i){if(!(i instanceof Qt||i instanceof Jt&&("em"===i.unit||"%"===i.unit))){if(i instanceof Jt&&"lh"!==i.unit){let e=this.context.queryUnitSize(i.unit,!1);if(null!=e)return i.num*e}return null}h=i instanceof Jt&&"%"===i.unit?i.num/100:i.num}if(null==h)for(let e=null==(r=null==(n=this.nodeContext)?void 0:n.parent)?void 0:r.viewNode;e&&1===e.nodeType;e=e.parentNode){let t=null==(o=null==e?void 0:e.style)?void 0:o.lineHeight;if(t){/^[0-9.]+$/.test(t)&&(h=parseFloat(t));break}}if(null!=h){if(t&&!(t instanceof Jt))return null;let e=a.fontSize;if(t instanceof Jt){let i=Qd(t,e,this.context).num;return"number"!=typeof i||isNaN(i)?null:h*i}return null==e?null:h*e}return l}getEmUnitSize(e,t){let i=this.getParentViewStyle(),n=this.getParentComputedMetrics(i).fontSize;if("font-size"===e||null==t)return n;if(t instanceof Jt){let e=Qd(t,n,this.context).num;if("number"==typeof e&&!isNaN(e))return e}return null}applyPseudoelementStyle(e,t,i){if(e.after)return;let n=this.sourceNode,r=(e.shadowContext?e.shadowContext.styler:this.styler).getStyle(n,!1),o=jd(r,"_pseudos");if(!o||(r=o[t],!r))return;let s={};e.vertical=this.computeStyle(e.vertical,"rtl"===e.direction,r,s);let a=s.content;Oa(a)&&(a.visit(new Ra(i,this.context,a,this.exprContentListener)),delete s.content),this.applyComputedStyles(i,s)}peelOff(e,t){let i=oo("peelOff"),n=e.firstPseudo,r=e.offsetInNode,o=e.after;if(t>0)r+=t;else if(!o&&e.viewNode&&0==r){let t=e.viewNode.parentNode;t&&t.removeChild(e.viewNode)}let s=e.boxOffset+t,a=[],l=e;for(let t=e.parent;t&&t.firstPseudo===n;t=l.parent)a.push(l),l=t;let h=l.shadowSibling,u=a.length-1,c=null;return i.loop(()=>{for(;u>=0;){let e=a[u],t=null!=c?c:l.parent,i=new ma(e.sourceNode,t,s,(null!=t?t:l).formattingContext);i.blockContainer=t&&Pa(t),0==u&&(i.offsetInNode=r,i.after=o),i.shadowType=e.shadowType,i.shadowContext=e.shadowContext,i.nodeShadow=e.nodeShadow,i.shadowSibling=e.shadowSibling?e.shadowSibling:h,h=null,c=i,u--;let n=this.setCurrent(i,!1);if(n.isPending())return n}return so(!1)}).then(()=>{i.finish(null!=c?c:e.parent)}),i.result()}createElement(e,t){return"http://www.w3.org/1999/xhtml"==e?this.document.createElement(t):this.document.createElementNS(e,t)}applyFootnoteStyle(e,t,i){var n;let r={},o=[],s=this.footnoteStyle;if(this.cascadedPageStyle){let e=jd(this.cascadedPageStyle,Hv);e&&e.area&&(s=e.area)}let a=jd(s,"_pseudos");e=this.computeStyle(e,t,s,r);let l=this.getFootnoteAreaInheritedMetrics();!r["font-size"]&&null!=l.fontSize&&(r["font-size"]=new Jt(l.fontSize,"px")),delete r.content;let h=this.computedStyleParentFontSizeOverride,u=this.computedStyleParentLineHeightOverride;this.computedStyleParentFontSizeOverride=l.fontSize,this.computedStyleParentLineHeightOverride=l.lineHeight;try{this.applyComputedStyles(i,r);let s=this.getComputedFontMetrics(i,l);if(this.computedStyleParentFontSizeOverride=s.fontSize,this.computedStyleParentLineHeightOverride=s.lineHeight,a&&a.before){let r=a.before,s=!!Hd(r,"display"),l={},h=this.createElement("http://www.w3.org/1999/xhtml","span");sg(h,"before"),i.appendChild(h),this.computeStyle(e,t,r,l),s||(l.display=di.block);let u=Hd(r,"content");if(u){let e=1===(null==(n=this.sourceNode)?void 0:n.nodeType)?this.sourceNode:this.xmldoc.root;l.content=u.filterValue(new rf(this.styler.cascade,e,this.styler.cascade.counterResolver,this.styler.elementWindow.currentStyle,"before")).evaluate(this.context,"content")}let c=l.content;if(Oa(c)){c.visit(new Ra(h,this.context,c,this.exprContentListener));let e=h.querySelectorAll("img[src]");for(let t=0;t<e.length;t++){let i=e[t],n=i.getAttribute("src");if(!n)continue;let r=Oo(i,n);o.push(r),this.page.fetchers.push(r)}let t=h.getAttribute("src");if(t){let e=h.querySelector("img");e||(e=this.document.createElement("img"),e.setAttribute("src",t),h.appendChild(e));let i=Oo(e,t);o.push(i),this.page.fetchers.push(i)}}delete l.content,this.applyComputedStyles(h,l)}}finally{this.computedStyleParentFontSizeOverride=h,this.computedStyleParentLineHeightOverride=u}return o.length?bo(o).thenReturn(e):so(e)}processFragmentedBlockEdge(e){var t,i,n;let r=!e.inline&&e.after?e.parent:e,o=!1;if(e.inline&&e.after&&!e.shadowContext&&1===(null==(t=e.sourceNode.nextSibling)?void 0:t.nodeType)){let t=e.sourceNode.nextSibling,n=null==(i=Hd(this.styler.getStyle(t,!1),"display"))?void 0:i.value.toString();o=n&&!vs(n)||"true"===t.getAttribute("data-math-typeset")&&/^\s*(\$\$|\\\[)/.test(t.textContent)}let s=0;for(let t=r;t;t=t.parent){if(1!==(null==(n=t.viewNode)?void 0:n.nodeType))continue;let i=t.viewNode;if(i.style)if(t.inline){if(ks(i,"inline-end"),xs(i)){let e=t.vertical?i.offsetWidth:i.offsetHeight;ks(i,"clone"),(t.vertical?i.offsetWidth:i.offsetHeight)>e&&this.fixClonedBoxDecorationOverflow(i)}}else{let n=e.vertical?"width":"height";if(we(i,n)&&be(i,n,""),ks(i,"block-end"),!s++&&t!==r){let{textAlign:e}=this.viewport.window.getComputedStyle(i);if("justify"!==e||o)ks(i,"text-end");else{let e=this.createChildAnonymousBlockIfNeeded(i);e?e!==i?Cs(e,["block-start","text-start","block-end","text-end","justify"]):(ks(i,"text-end"),ks(i,"justify")):ks(i,"text-end")}}xs(i)&&ks(i,"clone"),Ps(i,"block-end")}}}fixClonedBoxDecorationOverflow(e){let t=this.viewport.window.getComputedStyle(e),i=-(parseFloat(t.paddingInlineEnd)+parseFloat(t.borderInlineEndWidth));isNaN(i)||(e.style.marginInlineEnd=`${i}px`)}createChildAnonymousBlockIfNeeded(e){let t=e=>{let{display:i,position:n,float:r}=this.viewport.window.getComputedStyle(e);if("ruby"===e.localName||ze[e.localName])return!1;if("br"===e.localName)return!0;if(("inline"===i||"contents"===i)&&e.hasChildNodes()){let i=e.lastElementChild;if(i&&(!i.nextSibling||i.nextSibling===e.lastChild&&Qs(i.nextSibling))){let e=t(i);if(e||null===e)return e}for(let e=null==i?void 0:i.previousElementSibling;e;e=e.previousElementSibling){let i=t(e);if(i||null===i)return null}return!1}if("none"===i||"absolute"===n||"fixed"===n||r&&"none"!==r||e.hasAttribute(Za)){let i=e.previousElementSibling;return!(!i||!(i.nextSibling===e||i.nextSibling===e.previousSibling&&Qs(i.nextSibling)))&&t(i)}return!(!i||vs(i))},i=null;for(let n=e.lastElementChild;n;n=n.previousElementSibling){let e=t(n);if(e){i=n;break}if(null===e)return null}if(!i)return e;if(i===e.lastElementChild&&(!i.nextSibling||i.nextSibling===e.lastChild&&Qs(i.nextSibling)))return null;let n=e.ownerDocument.createElement("span");n.className="viv-anonymous-block";for(let e=i.nextSibling,t=null;e;e=t)t=e.nextSibling,n.appendChild(e);return e.appendChild(n),n}convertLengthToPx(e,t,i){let n=e.num,r=e.unit;if(function(e){switch(null==e?void 0:e.toLowerCase()){case"em":case"rem":case"lh":case"rlh":return!0;default:return!1}}(r)){let n=t;for(;n&&1!==n.nodeType;)n=n.parentNode;return Jd(e,parseFloat(i.getElementComputedStyle(n)["font-size"]),this.context).num}{let t=this.context.queryUnitSize(r,!1);return t?n*t:e}}isSameNodePositionStep(e,t){if(e.shadowContext){if(!t.shadowContext)return!1;let i=1===e.node.nodeType?e.node:e.node.parentElement,n=1===t.node.nodeType?t.node:t.node.parentElement;return e.shadowContext.owner===t.shadowContext.owner&&og(i)===og(n)}return e.node===t.node}isSameNodePosition(e,t){return e.offsetInNode===t.offsetInNode&&e.after==t.after&&e.steps.length===t.steps.length&&e.steps.every((e,i)=>{let n=t.steps[i];return this.isSameNodePositionStep(e,n)})}isPseudoelement(e){return!!og(e)}};h($m,"SVG_URL_ATTRIBUTES",["color-profile","clip-path","cursor","filter","marker","marker-start","marker-end","marker-mid","fill","stroke","mask"]),h($m,"FOOTNOTE_CALL_OWNER_ATTR","data-viv-footnote-call-owner");var jm=$m,Wm={"float-min-wrap-block":!0,"float-reference":!0,"flow-into":!0,"flow-linger":!0,"flow-options":!0,"flow-priority":!0,"footnote-display":!0,"footnote-policy":!0,"margin-break":!0,page:!0},Gm=class{constructor(e){h(this,"layoutBox"),h(this,"window"),h(this,"pixelRatio"),h(this,"scaleRatio"),h(this,"layoutUnitPerPixel"),this.layoutBox=e.layoutBox,this.window=e.window,this.pixelRatio=e.pixelRatio,this.scaleRatio=e.scaleRatio,this.layoutUnitPerPixel=e.layoutUnitPerPixel}subtractOffsets(e,t){let i=t.left,n=t.top;return{left:e.left-i,top:e.top-n,right:e.right-i,bottom:e.bottom-n,width:e.width,height:e.height}}getRangeClientRects(e){let t=e.getClientRects(),i=this.layoutBox.getBoundingClientRect();return Array.from(t).map(e=>this.subtractOffsets(e,i))}getElementClientRect(e){let t=e.getBoundingClientRect();if(0===t.left&&0===t.top&&0===t.right&&0===t.bottom)return t;let i=this.layoutBox.getBoundingClientRect();return this.subtractOffsets(t,i)}getElementComputedStyle(e){return this.window.getComputedStyle(e,null)}adjustLengthValue(e){return this.layoutUnitPerPixel?Math.floor(e*this.layoutUnitPerPixel)/this.layoutUnitPerPixel:e}},qm=class{constructor(e,t,i,n,r,o){if(h(this,"window",e),h(this,"fontSize",t),h(this,"pixelRatio",i),h(this,"document"),h(this,"root"),h(this,"outerZoomBox"),h(this,"contentContainer"),h(this,"layoutBox"),h(this,"width"),h(this,"height"),h(this,"scaleRatio",1),h(this,"layoutUnitPerPixel",64),h(this,"layoutUnitAdj",0),this.document=e.document,this.root=n||this.document.body,this.root.hasAttribute("data-vivliostyle-toc-box"))return this.outerZoomBox=this.contentContainer=this.layoutBox=this.root,this.width=r||this.root.clientWidth,void(this.height=o||this.root.clientHeight);let s=this.root.firstElementChild;s||(s=this.document.createElement("div"),s.setAttribute("data-vivliostyle-outer-zoom-box","true"),s.role="presentation",this.root.appendChild(s));let a=s.firstElementChild;switch(a||(a=this.document.createElement("div"),a.setAttribute("data-vivliostyle-spread-container","true"),a.role="presentation",s.appendChild(a)),i>0&&CSS.supports("zoom","8")&&(be(this.root,"--viv-outputPixelRatio",`${i}`),be(this.root,"--viv-devicePixelRatio",`${e.devicePixelRatio}`),this.scaleRatio=i/e.devicePixelRatio),X){case"chromium":this.layoutUnitPerPixel=64*(this.pixelRatio||e.devicePixelRatio),this.layoutUnitAdj=1/this.layoutUnitPerPixel;break;case"firefox":this.layoutUnitPerPixel=60,this.layoutUnitAdj=1/this.layoutUnitPerPixel;break;default:this.layoutUnitPerPixel=64,this.layoutUnitAdj=0}this.layoutUnitAdj&&be(this.root,"--viv-layoutUnitAdj",`${this.layoutUnitAdj}px`);let l=s.nextElementSibling;l||(l=this.document.createElement("div"),l.setAttribute("data-vivliostyle-layout-box","true"),l.role="presentation",this.root.appendChild(l)),this.outerZoomBox=s,this.contentContainer=a,this.layoutBox=l,this.width=r||parseFloat(e.getComputedStyle(this.root).width)||this.root.offsetWidth||e.innerWidth,this.height=o||parseFloat(e.getComputedStyle(this.root).height)||this.root.offsetHeight||e.innerHeight;let u=794,c=1056,d=!e.outerWidth&&!e.outerHeight||/Headless/.test(navigator.userAgent)||navigator.webdriver&&800===e.innerWidth&&600===e.innerHeight;(!this.width||!r&&d)&&(this.width=u),(!this.height||!o&&d)&&(this.height=c)}resetZoom(){be(this.outerZoomBox,"width",""),be(this.outerZoomBox,"height",""),be(this.contentContainer,"width",""),be(this.contentContainer,"height",""),be(this.contentContainer,"transform","")}zoom(e,t,i){be(this.root,"--viv-outputScale",`${i}`),be(this.outerZoomBox,"width",e*i+"px"),be(this.outerZoomBox,"height",t*i+"px"),be(this.contentContainer,"width",`${e}px`),be(this.contentContainer,"height",`${t}px`)}clear(){let e=this.root;for(;e.lastChild;)e.removeChild(e.lastChild)}};function Xm(e,t){if(e instanceof si)for(let i of e.values)Xm(i,t);else if(e instanceof ii){let i=he(e.url);t.fetchers.push(Oo(new Image,i))}else if(e instanceof ai)for(let i of e.values)Xm(i,t);else if(e instanceof oi)for(let i of e.values)Xm(i,t)}var Ym=1,Km=class{constructor(e,t,i,n,r){h(this,"name",t),h(this,"pseudoName",i),h(this,"classes",n),h(this,"parent",r),h(this,"specified",{}),h(this,"children",[]),h(this,"pageMaster",null),h(this,"index",0),h(this,"key"),h(this,"_scope"),this._scope=e,this.key="p"+Ym++,r&&(this.index=r.children.length,r.children.push(this))}get scope(){return this._scope}createInstance(e,t,i){throw new Error("E_UNEXPECTED_CALL")}clone(e){throw new Error("E_UNEXPECTED_CALL")}copySpecified(e){let t=this.specified,i=e.specified;for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(i[e]=t[e])}cloneChildren(e){for(let t=0;t<this.children.length;t++)this.children[t].clone({parent:e})}},Zm=class extends Km{constructor(e){super(e,null,null,[],null),this.specified.width=new Cd(fi,0),this.specified.height=new Cd(gi,0)}},Jm=class extends Xe{constructor(e,t){super(e,function(e,t){let n=e.match(/^([^.]+)\.([^.]+)$/);if(n){let e=i.pageMaster.keyMap[n[1]];if(e){let i=this.lookupInstance(e);if(i)return t?i.resolveFunc(n[2]):i.resolveName(n[2])}}return null}),h(this,"pageMaster",t);let i=this}},Qm=class e extends Km{constructor(e,t,i,n,r,o,s,a=null){super(e,t,i,n,r),h(this,"condition",o),h(this,"specificity",s),h(this,"layer",a),h(this,"keyMap",{}),e instanceof Jm||(this._scope=new Jm(e,this)),this.pageMaster=this,this.specified.width=new Cd(fi,0),this.specified.height=new Cd(gi,0),this.specified["wrap-flow"]=new Cd(di.auto,0),this.specified.position=new Cd(di.relative,0),this.specified.overflow=new Cd(di.visible,0)}createInstance(e,t,i){return new vv(e,this)}clone(t){let i=new e(this.scope,this.name,t.pseudoName||this.pseudoName,this.classes,this.parent,this.condition,this.specificity,this.layer);return this.copySpecified(i),this.cloneChildren(i),i}resetScope(){this.scope.pageMaster=this}},ev=class e extends Km{constructor(e,t,i,n,r){super(e,t,i,n,r),this.pageMaster=r.pageMaster,t&&(this.pageMaster.keyMap[t]=this.key),this.specified["wrap-flow"]=new Cd(di.auto,0)}createInstance(e,t,i){return new yv(e,this)}clone(t){let i=new e(t.parent.scope,this.name,this.pseudoName,this.classes,t.parent);return this.copySpecified(i),this.cloneChildren(i),i}},tv=class e extends Km{constructor(e,t,i,n,r){super(e,t,i,n,r),this.pageMaster=r.pageMaster,t&&(this.pageMaster.keyMap[t]=this.key)}createInstance(e,t,i){return new bv(e,this)}clone(t){let i=new e(t.parent.scope,this.name,this.pseudoName,this.classes,t.parent);return this.copySpecified(i),this.cloneChildren(i),i}};function iv(e,t,i){return!t||t===di.auto||yi(t)?null:t.toExpr(e,i)}function nv(e,t,i){return!t||t===di.auto||yi(t)?e.zero:t.toExpr(e,i)}function rv(e,t,i){return!t||yi(t)?e.zero:t===di.auto?null:t.toExpr(e,i)}function ov(e,t,i,n){return!t||i===di.none||yi(t)?e.zero:t.toExpr(e,n)}function sv(e,t,i){return!t||yi(t)?i:t===di._true?e._true:t===di._false?e._false:t.toExpr(e,e.zero)}var av=class{constructor(e,t){h(this,"parentInstance",e),h(this,"pageBox",t),h(this,"cascaded",{}),h(this,"style",{}),h(this,"autoWidth"),h(this,"autoHeight"),h(this,"children",[]),h(this,"isAutoWidth",!1),h(this,"isAutoHeight",!1),h(this,"isTopDependentOnAutoHeight",!1),h(this,"isRightDependentOnAutoWidth",!1),h(this,"calculatedWidth",0),h(this,"calculatedHeight",0),h(this,"pageMasterInstance",null),h(this,"namedValues",{}),h(this,"namedFuncs",{}),h(this,"vertical",!1),h(this,"rtl",!1),h(this,"suppressEmptyBoxGeneration",!1),h(this,"borderBoxSizing",!1),e&&e.children.push(this);let i=this.pageBox.scope;this.autoWidth=new It(i,()=>this.calculatedWidth,"autoWidth"),this.autoHeight=new It(i,()=>this.calculatedHeight,"autoHeight")}reset(){this.calculatedWidth=0,this.calculatedHeight=0}addNamedValues(e,t){let i=this.resolveName(e),n=this.resolveName(t);if(!i||!n)throw new Error("E_INTERNAL");return Mt(this.pageBox.scope,i,n)}resolveName(e){let t=this.namedValues[e];if(t)return t;let i=this.style[e];switch(i&&(t=i.toExpr(this.pageBox.scope,this.pageBox.scope.zero)),e){case"margin-left-edge":t=this.resolveName("left");break;case"margin-top-edge":t=this.resolveName("top");break;case"margin-right-edge":t=this.addNamedValues("border-right-edge","margin-right");break;case"margin-bottom-edge":t=this.addNamedValues("border-bottom-edge","margin-bottom");break;case"border-left-edge":t=this.addNamedValues("margin-left-edge","margin-left");break;case"border-top-edge":t=this.addNamedValues("margin-top-edge","margin-top");break;case"border-right-edge":t=this.addNamedValues("padding-right-edge","border-right-width");break;case"border-bottom-edge":t=this.addNamedValues("padding-bottom-edge","border-bottom-width");break;case"padding-left-edge":t=this.addNamedValues("border-left-edge","border-left-width");break;case"padding-top-edge":t=this.addNamedValues("border-top-edge","border-top-width");break;case"padding-right-edge":t=this.addNamedValues("right-edge","padding-right");break;case"padding-bottom-edge":t=this.addNamedValues("bottom-edge","padding-bottom");break;case"left-edge":t=this.addNamedValues("padding-left-edge","padding-left");break;case"top-edge":t=this.addNamedValues("padding-top-edge","padding-top");break;case"right-edge":t=this.addNamedValues("left-edge","width");break;case"bottom-edge":t=this.addNamedValues("top-edge","height")}if(!t){let i;if("extent"==e)i=this.vertical?"width":"height";else if("measure"==e)i=this.vertical?"height":"width";else{let t=this.vertical?ad:ld;i=e;for(let e in t)i=i.replace(e,t[e])}i!=e&&(t=this.resolveName(i))}return t&&(this.namedValues[e]=t),t}resolveFunc(e){let t=this.namedFuncs[e];if(t)return t;if("columns"===e){let e=this.pageBox.scope,i=new _t(e,0),n=this.resolveName("column-count"),r=this.resolveName("column-width"),o=this.resolveName("column-gap");t=Dt(e,zt(e,new At(e,"min",[i,n]),Mt(e,r,o)),o)}return t&&(this.namedFuncs[e]=t),t}initEnabled(){let e=this.pageBox.scope,t=this.style,i=sv(e,t.enabled,e._true),n=iv(e,t.page,e.zero);if(n){let t=new Nt(e,"page-number");i=Bt(e,i,new bt(e,n,t))}let r=iv(e,t["min-page-width"],e.zero);r&&(i=Bt(e,i,new yt(e,new Nt(e,"page-width"),r)));let o=iv(e,t["min-page-height"],e.zero);o&&(i=Bt(e,i,new yt(e,new Nt(e,"page-height"),o))),i=this.boxSpecificEnabled(i),t.enabled=new li(i)}boxSpecificEnabled(e){return e}initHorizontal(){let e=this.pageBox.scope,t=this.style,i=this.parentInstance?this.parentInstance.style.width.toExpr(e,null):null,n=iv(e,t.left,i),r=iv(e,t["margin-left"],i),o=ov(e,t["border-left-width"],t["border-left-style"],i),s=nv(e,t["padding-left"],i),a=iv(e,t.width,i),l=iv(e,t["max-width"],i),h=nv(e,t["padding-right"],i),u=ov(e,t["border-right-width"],t["border-right-style"],i),c=iv(e,t["margin-right"],i),d=iv(e,t.right,i),p=Mt(e,o,s),f=Mt(e,o,h);if(n&&d&&a){let t=Dt(e,i,Mt(e,a,Mt(e,Mt(e,n,p),f)));r?c?d=Dt(e,t,c):c=Dt(e,t,Mt(e,d,r)):(t=Dt(e,t,d),c?r=Dt(e,t,c):(r=zt(e,t,new Rt(e,.5)),c=r))}else{r||(r=e.zero),c||(c=e.zero),!n&&!d&&!a&&(n=e.zero),n||a?n||d?!a&&!d&&(a=this.autoWidth,this.isAutoWidth=!0):n=e.zero:(a=this.autoWidth,this.isAutoWidth=!0);let o=Dt(e,i,Mt(e,Mt(e,r,p),Mt(e,c,f)));this.isAutoWidth&&(l||(l=Dt(e,o,n||d)),!this.vertical&&(iv(e,t["column-width"],null)||iv(e,t["column-count"],null))&&(a=l,this.isAutoWidth=!1)),n?a?d||(d=Dt(e,o,Mt(e,n,a))):a=Dt(e,o,Mt(e,n,d)):n=Dt(e,o,Mt(e,d,a))}let g=nv(e,t["snap-width"]||(this.parentInstance?this.parentInstance.style["snap-width"]:null),i);t.left=new li(n),t["margin-left"]=new li(r),t["border-left-width"]=new li(o),t["padding-left"]=new li(s),t.width=new li(a),t["max-width"]=new li(l||a),t["padding-right"]=new li(h),t["border-right-width"]=new li(u),t["margin-right"]=new li(c),t.right=new li(d),t["snap-width"]=new li(g)}initVertical(){let e=this.pageBox.scope,t=this.style,i=this.parentInstance?this.parentInstance.style.width.toExpr(e,null):null,n=this.parentInstance?this.parentInstance.style.height.toExpr(e,null):null,r=iv(e,t.top,n),o=iv(e,t["margin-top"],i),s=ov(e,t["border-top-width"],t["border-top-style"],i),a=nv(e,t["padding-top"],i),l=iv(e,t.height,n),h=iv(e,t["max-height"],n),u=nv(e,t["padding-bottom"],i),c=ov(e,t["border-bottom-width"],t["border-bottom-style"],i),d=iv(e,t["margin-bottom"],i),p=iv(e,t.bottom,n),f=Mt(e,s,a),g=Mt(e,c,u);if(r&&p&&l){let t=Dt(e,n,Mt(e,l,Mt(e,Mt(e,r,f),g)));o?d?p=Dt(e,t,o):d=Dt(e,t,Mt(e,p,o)):(t=Dt(e,t,p),d?o=Dt(e,t,d):(o=zt(e,t,new Rt(e,.5)),d=o))}else{o||(o=e.zero),d||(d=e.zero),!r&&!p&&!l&&(r=e.zero),r||l?r||p?!l&&!p&&(l=this.autoHeight,this.isAutoHeight=!0):r=e.zero:(l=this.autoHeight,this.isAutoHeight=!0);let i=Dt(e,n,Mt(e,Mt(e,o,f),Mt(e,d,g)));this.isAutoHeight&&(h||(h=Dt(e,i,r||p)),this.vertical&&(iv(e,t["column-width"],null)||iv(e,t["column-count"],null))&&(l=h,this.isAutoHeight=!1)),r?l?p||(p=Dt(e,i,Mt(e,r,l))):l=Dt(e,i,Mt(e,p,r)):r=Dt(e,i,Mt(e,p,l))}let m=nv(e,t["snap-height"]||(this.parentInstance?this.parentInstance.style["snap-height"]:null),i);t.top=new li(r),t["margin-top"]=new li(o),t["border-top-width"]=new li(s),t["padding-top"]=new li(a),t.height=new li(l),t["max-height"]=new li(h||l),t["padding-bottom"]=new li(u),t["border-bottom-width"]=new li(c),t["margin-bottom"]=new li(d),t.bottom=new li(p),t["snap-height"]=new li(m)}initColumns(){let e=this.pageBox.scope,t=this.style,i=iv(e,t[this.vertical?"height":"width"],null),n=iv(e,t["column-width"],i),r=iv(e,t["column-count"],null),o=function(e,t,i){return!t||t===di.normal||yi(t)?null:t.toExpr(e,i)}(e,t["column-gap"],null);o||(o=new Et(e,1,"em")),n&&!r&&(r=new At(e,"floor",[Vt(e,Mt(e,i,o),Mt(e,n,o))]),r=new At(e,"max",[e.one,r])),r||(r=e.one),n=Dt(e,Vt(e,Mt(e,i,o),r),o),t["column-width"]=new li(n),t["column-count"]=new li(r),t["column-gap"]=new li(o)}depends(e,t,i){return this.style[e].toExpr(this.pageBox.scope,null).depend(t,i)}resolveStyle(e){var t;let i=this.pageBox.scope,n=this.style,r=this.parentInstance?this.parentInstance.getActiveRegions(e):null,o=Of(this.cascaded,e,r,!1);this.vertical=Ff(o,e,!!this.parentInstance&&this.parentInstance.vertical),this.rtl=Rf(o,e,!!this.parentInstance&&this.parentInstance.rtl),this.borderBoxSizing=(null==(t=o["box-sizing"])?void 0:t.value)===di.border_box;let s=!!(e instanceof ky&&e.currentLayoutPosition&&new Nt(i,"left-page").evaluate(e));Bf(o,n,this.vertical,this.rtl,s,(e,t)=>t.value)}init(e){this.resolveStyle(e),this.initHorizontal(),this.initVertical(),this.initColumns(),this.initEnabled()}register(e){e.registerInstance(this.pageBox.key,this)}getProp(e,t){var i,n;let r=this.style[t];return!r&&Ud(t)&&this.pageMasterInstance instanceof qv&&(r="font-size"===t&&e.isRelativeRootFontSize&&e.rootFontSize?new Jt(e.rootFontSize,"px"):null==(n=(null==(i=e.styler)?void 0:i.rootStyle)[t])?void 0:n.value),r&&(r=Vf(e,r,t)),r}getPropAsNumber(e,t){var i,n;let r=this.style[t];if(r){let o=/\b(height|top|bottom)\b/.test(t)?null!=(i=e.pageAreaHeight)?i:e.pageHeight():null!=(n=e.pageAreaWidth)?n:e.pageWidth();r=Vf(e,r,t,o)}return ui(r,e)}getSpecial(e,t){let i=qd(this.cascaded,t);if(i){let t=[];for(let n=0;n<i.length;n++){let r=i[n].evaluate(e,"");r&&r!==Wt&&t.push(r)}if(t.length)return t}return null}getActiveRegions(e){let t=this.getSpecial(e,"region-id");if(t){let e=[];for(let i=0;i<t.length;i++)e[i]=t[i].toString();return e}return null}propagateProperty(e,t,i,n){this.propagatePropertyToElement(e,t.element,i,n)}propagatePropertyToElement(e,t,i,n){let r=this.getProp(e,i);if(r){r.isNumeric()&&Ze(r.unit)&&(r=ci(r,e)),"font-family"===i&&(r=n.filterFontFamily(r));let o=t.parentElement;(i.startsWith("background")||"z-index"===i)&&null!=o&&o.hasAttribute("data-vivliostyle-bleed-box")&&(t=o),be(t,i,r.toString())}}propagateDelayedProperty(e,t,i,n){let r=this.getProp(e,i);r&&n.push(new Gs(t.element,i,r))}assignLeftPosition(e,t){let i=this.getPropAsNumber(e,"left"),n=this.getPropAsNumber(e,"margin-left"),r=this.getPropAsNumber(e,"padding-left"),o=this.getPropAsNumber(e,"border-left-width"),s=this.getPropAsNumber(e,"width");t.setHorizontalPosition(i,s),be(t.element,"margin-left",`${n}px`),be(t.element,"padding-left",`${r}px`),be(t.element,"border-left-width",`${o}px`),t.marginLeft=n,t.borderLeft=o,t.paddingLeft=r}assignRightPosition(e,t){let i=this.getPropAsNumber(e,"right"),n=this.getPropAsNumber(e,"snap-height"),r=this.getPropAsNumber(e,"margin-right"),o=this.getPropAsNumber(e,"padding-right"),s=this.getPropAsNumber(e,"border-right-width");if(be(t.element,"margin-right",`${r}px`),be(t.element,"padding-right",`${o}px`),be(t.element,"border-right-width",`${s}px`),t.marginRight=r,t.borderRight=s,this.vertical&&n>0){let e=i+t.getInsetRight(),r=e-Math.floor(e/n)*n;r>0&&(t.snapOffsetX=n-r,o+=t.snapOffsetX)}t.paddingRight=o,t.snapWidth=n}assignTopPosition(e,t){let i=this.getPropAsNumber(e,"snap-height"),n=this.getPropAsNumber(e,"top"),r=this.getPropAsNumber(e,"margin-top"),o=this.getPropAsNumber(e,"padding-top"),s=this.getPropAsNumber(e,"border-top-width");if(t.top=n,t.marginTop=r,t.borderTop=s,t.snapHeight=i,!this.vertical&&i>0){let e=n+t.getInsetTop(),r=e-Math.floor(e/i)*i;r>0&&(t.snapOffsetY=i-r,o+=t.snapOffsetY)}t.paddingTop=o,be(t.element,"top",`${n}px`),be(t.element,"margin-top",`${r}px`),be(t.element,"padding-top",`${o}px`),be(t.element,"border-top-width",`${s}px`)}assignBottomPosition(e,t){let i=this.getPropAsNumber(e,"margin-bottom"),n=this.getPropAsNumber(e,"padding-bottom"),r=this.getPropAsNumber(e,"border-bottom-width"),o=this.getPropAsNumber(e,"height")-t.snapOffsetY;be(t.element,"height",`${o}px`),be(t.element,"margin-bottom",`${i}px`),be(t.element,"padding-bottom",`${n}px`),be(t.element,"border-bottom-width",`${r}px`),t.height=o-t.snapOffsetY,t.marginBottom=i,t.borderBottom=r,t.paddingBottom=n}assignBeforePosition(e,t){this.vertical?this.assignRightPosition(e,t):this.assignTopPosition(e,t)}assignAfterPosition(e,t){this.vertical?this.assignLeftPosition(e,t):this.assignBottomPosition(e,t)}assignStartEndPosition(e,t){this.vertical?(this.assignTopPosition(e,t),this.assignBottomPosition(e,t)):(this.assignRightPosition(e,t),this.assignLeftPosition(e,t))}sizeWithMaxHeight(e,t){be(t.element,"border-top-width","0px");let i=this.getPropAsNumber(e,"max-height");this.isTopDependentOnAutoHeight?t.setVerticalPosition(0,i):(this.assignTopPosition(e,t),i-=t.snapOffsetY,t.height=i,be(t.element,"height",`${i}px`))}sizeWithMaxWidth(e,t){be(t.element,"border-left-width","0px");let i=this.getPropAsNumber(e,"max-width");if(this.isRightDependentOnAutoWidth)t.setHorizontalPosition(0,i);else{this.assignRightPosition(e,t),i-=t.snapOffsetX,t.width=i;let n=this.getPropAsNumber(e,"right");be(t.element,"right",`${n}px`),be(t.element,"width",`${i}px`)}}prepareContainer(e,t,i,n,r){(!this.parentInstance||this.vertical!=this.parentInstance.vertical)&&be(t.element,"writing-mode",this.vertical?"vertical-rl":"horizontal-tb"),(!this.parentInstance||this.rtl!=this.parentInstance.rtl)&&be(t.element,"direction",this.rtl?"rtl":"ltr"),(this.vertical?this.isAutoWidth:this.isAutoHeight)?this.vertical?this.sizeWithMaxWidth(e,t):this.sizeWithMaxHeight(e,t):(this.assignBeforePosition(e,t),this.assignAfterPosition(e,t)),(this.vertical?this.isAutoHeight:this.isAutoWidth)?this.vertical?this.sizeWithMaxHeight(e,t):this.sizeWithMaxWidth(e,t):this.assignStartEndPosition(e,t);for(let i=0;i<lv.length;i++)this.propagateProperty(e,t,lv[i],n)}transferContentProps(e,t,i,n){for(let i=0;i<cv.length;i++)this.propagateProperty(e,t,cv[i],n);if(this.style["text-overflow"]){let e=t.element.firstElementChild;be(e,"text-overflow","inherit"),be(e,"overflow","inherit")}}transferSingleUriContentProps(e,t,i){let n=()=>{var e,t;let i=null==(t=null!=(e=this.cascaded.width)?e:this.cascaded[this.vertical?"block-size":"inline-size"])?void 0:t.value;return!!i&&i!==di.auto&&!yi(i)},r=()=>{var e,t;let i=null==(t=null!=(e=this.cascaded.height)?e:this.cascaded[this.vertical?"inline-size":"block-size"])?void 0:t.value;return!!i&&i!==di.auto&&!yi(i)};for(let o=0;o<dv.length;o++){let s=dv[o];if("width"!==s&&"height"!==s)this.propagatePropertyToElement(e,t,s,i);else{if("width"===s&&!n()||"height"===s&&!r())continue;be(t,s,"100%")}}}finishContainer(e,t,i,n,r,o,s){var a,l,h,u,c,d,p,f,g,m,v,y;this.vertical?this.calculatedWidth=t.computedBlockSize+t.snapOffsetX:this.calculatedHeight=t.computedBlockSize+t.snapOffsetY;let b=(this.vertical||!n)&&this.isAutoHeight,w=(!this.vertical||!n)&&this.isAutoWidth,x=null;if(w||b){w&&be(t.element,"width","auto"),b&&be(t.element,"height","auto");let e=n&&Ma(n);e&&Ba(n),x=o.getElementClientRect(n?n.element:t.element),e&&_a(n),w&&(this.calculatedWidth=Math.ceil(x.right-x.left-t.paddingLeft-t.borderLeft-t.paddingRight-t.borderRight),this.vertical&&(this.calculatedWidth+=t.snapOffsetX)),b&&(this.calculatedHeight=x.bottom-x.top-t.paddingTop-t.borderTop-t.paddingBottom-t.borderBottom,this.vertical||(this.calculatedHeight+=t.snapOffsetY))}if((this.vertical?this.isAutoHeight:this.isAutoWidth)&&this.assignStartEndPosition(e,t),(this.vertical?this.isAutoWidth:this.isAutoHeight)&&((this.vertical?this.isRightDependentOnAutoWidth:this.isTopDependentOnAutoHeight)&&this.assignBeforePosition(e,t),this.assignAfterPosition(e,t)),r>1){let i=this.getPropAsNumber(e,"column-rule-width"),o=this.getProp(e,"column-rule-style"),s=this.getProp(e,"column-rule-color");if(i>0&&o&&o!=di.none&&s!=di.transparent){let b=this.getPropAsNumber(e,"column-gap"),w=this.vertical?t.height:t.width,x=parseFloat(this.vertical?null!=(a=null==n?void 0:n.element.style.left)?a:"":null!=(l=null==n?void 0:n.element.style.top)?l:""),S=t.getPaddingRect(),C=n,k=this.vertical?"border-top":"border-left";for(let e=1;e<r;e++){let a=this.vertical?(w+b)*e/r-b/2+t.paddingTop-i/2:(w+b)*e/r-b/2+t.paddingLeft-i/2,l=this.vertical?S.y1+a+i/2:S.x1+a+i/2,P=null!=(d=null==(c=null==(u=null==(h=C.pageFloatLayoutContext)?void 0:h.parent)?void 0:u.getBlockEndEdgeOfBlockStartFloats)?void 0:c.call(u,l))?d:NaN,E=null!=(m=null==(g=null==(f=null==(p=C.pageFloatLayoutContext)?void 0:p.parent)?void 0:f.getBlockStartEdgeOfBlockEndFloats)?void 0:g.call(f,l))?m:NaN,N=isFinite(P)?this.vertical?P-S.x1:P-S.y1:NaN,T=isFinite(E)?this.vertical?E-S.x1:E-S.y1:NaN,I=parseFloat(this.vertical?null!=(v=null==n?void 0:n.element.style.width)?v:"":null!=(y=null==n?void 0:n.element.style.height)?y:""),A=I>0?I:this.vertical?n.width:n.height,F=Math.max(x>0?x:0,0),R=F+A,O=Math.max(F,isFinite(this.vertical?T:N)?Math.max(0,this.vertical?T:N):0),L=Math.min(R,isFinite(this.vertical?N:T)?Math.max(0,this.vertical?N:T):R),_=Math.max(0,L-O),B=t.element.ownerDocument.createElement("div");be(B,"position","absolute"),be(B,this.vertical?"left":"top",`${O}px`),be(B,this.vertical?"top":"left",`${a}px`),be(B,this.vertical?"height":"width","0px"),be(B,this.vertical?"width":"height",`${_}px`),be(B,k,`${i}px ${o.toString()}${s?` ${s.toString()}`:""}`),t.element.insertBefore(B,t.element.firstChild)}}}for(let i=0;i<hv.length;i++)this.propagateProperty(e,t,hv[i],s);for(let t of uv){let n=this.getProp(e,t);n&&Xm(n,i)}for(let n=0;n<pv.length;n++)this.propagateDelayedProperty(e,t,pv[n],i.delayedItems)}buildCascadedStyle(e){let t=this.cascaded,i=this.pageBox.specified;for(let e in i)this instanceof qv&&"vivliostyle-page-rule-master"==this.pageBox.pseudoName&&("writing-mode"===e||"direction"===e)||Vd(e)&&$d(t,e,Hd(i,e));if(this.pageBox.pseudoName==fv)for(let i in e)(i.match(/^background-/)||"writing-mode"==i)&&(t[i]=e[i]);if("layout-host"==this.pageBox.pseudoName)for(let i in e)!i.match(/^background-/)&&"writing-mode"!=i&&(t[i]=e[i])}resolveContent(e){let t=this.cascaded,i=t.content;if(i){let n=Array.from(e.lastCounterChanges),r={...e.lastCounterChangeTypes};e.counterScoping.push(null),e.pushCounters(t,t),t.content=i.filterValue(new rf(e,null,e.counterResolver,t)),e.popCounters(),e.popCounters(),e.lastCounterChanges=n,e.lastCounterChangeTypes=r}}applyCascadeAndInit(e,t){this.buildCascadedStyle(t),e.pushRule(this.pageBox.classes,null,this.cascaded),this.resolveContent(e),this.init(e.context),this.register(e.context);for(let i of this.pageBox.children)i.createInstance(this,e.context,t).applyCascadeAndInit(e,t);e.popRule()}resolveAutoSizing(e){this.isAutoWidth&&(this.isRightDependentOnAutoWidth=this.depends("right",this.autoWidth,e)||this.depends("margin-right",this.autoWidth,e)||this.depends("border-right-width",this.autoWidth,e)||this.depends("padding-right",this.autoWidth,e)),this.isAutoHeight&&(this.isTopDependentOnAutoHeight=this.depends("top",this.autoHeight,e)||this.depends("margin-top",this.autoHeight,e)||this.depends("border-top-width",this.autoHeight,e)||this.depends("padding-top",this.autoHeight,e));for(let t of this.children)t.resolveAutoSizing(e)}},lv=["border-left-style","border-right-style","border-top-style","border-bottom-style","border-left-color","border-right-color","border-top-color","border-bottom-color","box-sizing","outline-style","outline-color","outline-width","outline-offset","overflow","visibility"],hv=["border-top-left-radius","border-top-right-radius","border-bottom-right-radius","border-bottom-left-radius","border-start-start-radius","border-start-end-radius","border-end-start-radius","border-end-end-radius","border-image-source","border-image-slice","border-image-width","border-image-outset","border-image-repeat","background-attachment","background-color","background-image","background-repeat","background-position","background-position-x","background-position-y","background-clip","background-origin","background-size","box-shadow","opacity","z-index","background-blend-mode","isolation","mix-blend-mode","filter"],uv=["background-image","border-image-source","filter"],cv=["color","font-family","font-size","font-style","font-weight","line-height","letter-spacing","text-align","text-align-last","text-decoration","text-indent","text-transform","white-space","text-wrap-mode","text-wrap-style","word-spacing","font-feature-settings","font-kerning","font-size-adjust","font-variant-ligatures","font-variant-caps","font-variant-numeric","font-variant-east-asian","font-stretch","text-combine-upright","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-fill-color","text-orientation","text-shadow","text-stroke-color","text-stroke-width","text-underline-offset","text-underline-position","text-overflow","text-box-trim","text-box-edge","text-justify"],dv=["width","height","image-resolution","object-fit","object-position"],pv=["transform","transform-origin"],fv="background-host";function gv(e){var t;let i=e;return{priority:i.specificity,layer:null!=(t=i.layer)?t:null}}var mv=class extends av{constructor(e){super(null,e)}applyCascadeAndInit(e,t){super.applyCascadeAndInit(e,t),this.children.sort((e,t)=>Sd(gv(t.pageBox),gv(e.pageBox))||e.pageBox.index-t.pageBox.index)}},vv=class extends av{constructor(e,t){super(e,t),this.pageMasterInstance=this}get pageAreaEstablishingChild(){return null}boxSpecificEnabled(e){let t=this.pageBox.pageMaster;return t.condition&&(e=Bt(t.scope,e,t.condition)),e}adjustPageLayout(e,t,i){}},yv=class extends av{constructor(e,t){super(e,t),this.pageMasterInstance=e.pageMasterInstance}},bv=class extends av{constructor(e,t){super(e,t),this.pageMasterInstance=e.pageMasterInstance}processPartitionList(e,t,i){let n=null;if(t instanceof Kt&&(n=[t]),t instanceof si&&(n=t.values),n){let t=this.pageBox.scope;for(let r=0;r<n.length;r++)if(n[r]instanceof Kt){let o=Ge(n[r].name,"enabled"),s=new Nt(t,o);i&&(s=new at(t,s)),e=Bt(t,e,s)}}return e}boxSpecificEnabled(e){let t=this.pageBox.scope,i=this.style,n=sv(t,i.required,t._false)!==t._false;if(n||this.isAutoHeight){let n=function(e,t,i){return!t||yi(t)?new Rt(e,i):t.toExpr(e,e.zero)}(t,i["flow-from"],"body");e=Bt(t,e,new At(t,"has-content",[n]))}if(e=this.processPartitionList(e,i["required-partitions"],!1),e=this.processPartitionList(e,i["conflicting-partitions"],!0),n){let i=this.pageMasterInstance.style.enabled,n=i?i.toExpr(t,null):t._true;n=Bt(t,n,e),this.pageMasterInstance.style.enabled=new li(n)}return e}prepareContainer(e,t,i,n,r){var o;this.pageBox.pageMaster instanceof $v||(be(t.element,"overflow","hidden"),t.element.setAttribute("data-vivliostyle-page-partition",null!=(o=this.pageBox.name)?o:"")),super.prepareContainer(e,t,i,n,r)}},wv=class extends Uo{constructor(e,t,i,n,r){super(e,t,r),h(this,"target",i),h(this,"validatorSet",n)}property(e,t,i){this.validatorSet.validatePropertyAndHandleShorthand(e,t,i,this.scope,this)}unknownProperty(e,t){this.report(`E_INVALID_PROPERTY ${e}: ${t.toString()}`)}invalidPropertyValue(e,t){this.report(`E_INVALID_PROPERTY_VALUE ${e}: ${t.toString()}`)}simpleProperty(e,t,i){this.target.specified[e]=new Cd(t,i?_o:Bo)}},xv=class extends wv{constructor(e,t,i,n,r){super(e,t,i,n,r)}},Sv=class e extends wv{constructor(e,t,i,n,r){super(e,t,i,n,r),i.specified.width=new Cd(pi,0),i.specified.height=new Cd(pi,0)}startPartitionRule(e,t,i){let n=new tv(this.scope,e,t,i,this.target);this.owner.delegateTo(e=>new xv(this.scope,this.owner,n,this.validatorSet,e))}startPartitionGroupRule(t,i,n){let r=new ev(this.scope,t,i,n,this.target);this.owner.delegateTo(t=>new e(this.scope,this.owner,r,this.validatorSet,t))}},Cv=class extends wv{constructor(e,t,i,n,r){super(e,t,i,n,r)}startPartitionRule(e,t,i){let n=new tv(this.scope,e,t,i,this.target);this.owner.delegateTo(e=>new xv(this.scope,this.owner,n,this.validatorSet,e))}startPartitionGroupRule(e,t,i){let n=new ev(this.scope,e,t,i,this.target);this.owner.delegateTo(e=>new Sv(this.scope,this.owner,n,this.validatorSet,e))}};function kv(e){var t,i;let n=null==(t=e["writing-mode"])?void 0:t.value,r=null==(i=e.direction)?void 0:i.value;return n===di.vertical_lr||n!==di.vertical_rl&&r!==di.rtl?"ltr":"rtl"}var Pv={a10:{width:new Jt(26,"mm"),height:new Jt(37,"mm")},a9:{width:new Jt(37,"mm"),height:new Jt(52,"mm")},a8:{width:new Jt(52,"mm"),height:new Jt(74,"mm")},a7:{width:new Jt(74,"mm"),height:new Jt(105,"mm")},a6:{width:new Jt(105,"mm"),height:new Jt(148,"mm")},a5:{width:new Jt(148,"mm"),height:new Jt(210,"mm")},a4:{width:new Jt(210,"mm"),height:new Jt(297,"mm")},a3:{width:new Jt(297,"mm"),height:new Jt(420,"mm")},a2:{width:new Jt(420,"mm"),height:new Jt(594,"mm")},a1:{width:new Jt(594,"mm"),height:new Jt(841,"mm")},a0:{width:new Jt(841,"mm"),height:new Jt(1189,"mm")},b10:{width:new Jt(31,"mm"),height:new Jt(44,"mm")},b9:{width:new Jt(44,"mm"),height:new Jt(62,"mm")},b8:{width:new Jt(62,"mm"),height:new Jt(88,"mm")},b7:{width:new Jt(88,"mm"),height:new Jt(125,"mm")},b6:{width:new Jt(125,"mm"),height:new Jt(176,"mm")},b5:{width:new Jt(176,"mm"),height:new Jt(250,"mm")},b4:{width:new Jt(250,"mm"),height:new Jt(353,"mm")},b3:{width:new Jt(353,"mm"),height:new Jt(500,"mm")},b2:{width:new Jt(500,"mm"),height:new Jt(707,"mm")},b1:{width:new Jt(707,"mm"),height:new Jt(1e3,"mm")},b0:{width:new Jt(1e3,"mm"),height:new Jt(1414,"mm")},c10:{width:new Jt(28,"mm"),height:new Jt(40,"mm")},c9:{width:new Jt(40,"mm"),height:new Jt(57,"mm")},c8:{width:new Jt(57,"mm"),height:new Jt(81,"mm")},c7:{width:new Jt(81,"mm"),height:new Jt(114,"mm")},c6:{width:new Jt(114,"mm"),height:new Jt(162,"mm")},c5:{width:new Jt(162,"mm"),height:new Jt(229,"mm")},c4:{width:new Jt(229,"mm"),height:new Jt(324,"mm")},c3:{width:new Jt(324,"mm"),height:new Jt(458,"mm")},c2:{width:new Jt(458,"mm"),height:new Jt(648,"mm")},c1:{width:new Jt(648,"mm"),height:new Jt(917,"mm")},c0:{width:new Jt(917,"mm"),height:new Jt(1297,"mm")},"jis-b10":{width:new Jt(32,"mm"),height:new Jt(45,"mm")},"jis-b9":{width:new Jt(45,"mm"),height:new Jt(64,"mm")},"jis-b8":{width:new Jt(64,"mm"),height:new Jt(91,"mm")},"jis-b7":{width:new Jt(91,"mm"),height:new Jt(128,"mm")},"jis-b6":{width:new Jt(128,"mm"),height:new Jt(182,"mm")},"jis-b5":{width:new Jt(182,"mm"),height:new Jt(257,"mm")},"jis-b4":{width:new Jt(257,"mm"),height:new Jt(364,"mm")},"jis-b3":{width:new Jt(364,"mm"),height:new Jt(515,"mm")},"jis-b2":{width:new Jt(515,"mm"),height:new Jt(728,"mm")},"jis-b1":{width:new Jt(728,"mm"),height:new Jt(1030,"mm")},"jis-b0":{width:new Jt(1030,"mm"),height:new Jt(1456,"mm")},letter:{width:new Jt(8.5,"in"),height:new Jt(11,"in")},legal:{width:new Jt(8.5,"in"),height:new Jt(14,"in")},ledger:{width:new Jt(11,"in"),height:new Jt(17,"in")}},Ev=new Jt(.24,"pt");new Jt(3,"mm");var Nv=new Jt(10,"mm"),Tv=new Jt(13,"mm");function Iv(e){let t={width:fi,height:gi,bleed:mi,bleedOffset:mi,cropOffset:mi},i=e.size;if(i&&i.value!==di.auto){let e,n,r=i.value;if(r.isSpaceList()?(e=r.values[0],n=r.values[1]):(e=r,n=null),e.isNumeric())t.width=e,t.height=n||e;else{let i=e.name&&Pv[e.name.toLowerCase()];i&&(n&&n===di.landscape?(t.width=i.height,t.height=i.width):(t.width=i.width,t.height=i.height))}}let n=e.marks,r=e.bleed,o=n&&!yi(n.value)?n.value:di.none,s=r&&!yi(r.value)?r.value:di.auto;if(s===di.auto){if(o!==di.none){let e=!1;e=o.isSpaceList()?o.values.some(e=>e===di.crop):o===di.crop,e&&(t.bleed=new Jt(6,"pt"))}}else s.isNumeric()&&(t.bleed=s);let a=e["crop-offset"],l=a&&!yi(a.value)?a.value:di.auto;return l===di.auto?o!==di.none&&(t.bleedOffset=Tv):l.isNumeric()&&(t.cropOffset=l),t}function Av(e,t){let i={},n=Math.max(0,e.bleed.num)*t.queryUnitSize(e.bleed.unit,!1),r=!e.cropOffset.num&&e.bleedOffset.num?e.bleedOffset.num*t.queryUnitSize(e.bleedOffset.unit,!1):Math.max(0,e.cropOffset.num*t.queryUnitSize(e.cropOffset.unit,!1)-n),o=n+r,s=e.width;s===fi?t.pref.defaultPaperSize?i.pageWidth=t.pref.defaultPaperSize.width*t.queryUnitSize("px",!1):i.pageWidth=(t.pref.spreadView?Math.floor(t.viewportWidth/2)-t.pref.pageBorder:t.viewportWidth)-2*o:i.pageWidth=s.num*t.queryUnitSize(s.unit,!1);let a=e.height;return a===gi?t.pref.defaultPaperSize?i.pageHeight=t.pref.defaultPaperSize.height*t.queryUnitSize("px",!1):i.pageHeight=t.viewportHeight-2*o:i.pageHeight=a.num*t.queryUnitSize(a.unit,!1),i.bleed=n,i.bleedOffset=r,i.cropOffset=o,i}function Fv(e,t,i){let n=e.createElementNS("http://www.w3.org/2000/svg","svg");return n.setAttribute("width",t),n.setAttribute("height",i),n.style.position="absolute",n}function Rv(e,t,i,n){n=n||"polyline";let r=e.createElementNS("http://www.w3.org/2000/svg",n);return r.setAttribute("stroke",i===di.auto?"#010101":i.toString()),r.setAttribute("stroke-width",t),r.setAttribute("fill","none"),r}var Ov=(e=>(e.TOP_LEFT="top left",e.TOP_RIGHT="top right",e.BOTTOM_LEFT="bottom left",e.BOTTOM_RIGHT="bottom right",e))(Ov||{}),Lv=(e=>(e.TOP="top",e.BOTTOM="bottom",e.LEFT="left",e.RIGHT="right",e))(Lv||{});function _v(e,t,i,n){let r=!1,o=!1,s=e.marks;if(s){let e=s.value;e instanceof oi?e.values.forEach(e=>{e===di.crop?r=!0:e===di.cross&&(o=!0)}):e===di.crop?r=!0:e===di.cross&&(o=!0)}let a=t.bleed;if(!r&&!o)return;let l=i.container,h=l.ownerDocument,u=ui(Ev,n),c=Math.max(0,t.bleedOffset-ui(Nv,n)),d=t.bleedOffset-c,p=e["crop-marks-line-color"],f=p&&!yi(p.value)?p.value:di.auto;r&&Object.keys(Ov).forEach(e=>{let t=Ov[e],i=function(e,t,i,n,r,o,s){let a=r;a<=o+2*Ke.mm&&(a=o+r/2);let l=Math.max(r,a),h=o+l+i/2,u=Fv(e,h,h),c=[[0,o+r],[r,o+r],[r,o+r-a]],d=c.map(e=>[e[1],e[0]]);("top right"===t||"bottom right"===t)&&(c=c.map(e=>[o+l-e[0],e[1]]),d=d.map(e=>[o+l-e[0],e[1]])),("bottom left"===t||"bottom right"===t)&&(c=c.map(e=>[e[0],o+l-e[1]]),d=d.map(e=>[e[0],o+l-e[1]]));let p=Rv(e,i,n);p.setAttribute("points",c.map(e=>e.join(",")).join(" ")),u.appendChild(p);let f=Rv(e,i,n);return f.setAttribute("points",d.map(e=>e.join(",")).join(" ")),u.appendChild(f),t.split(" ").forEach(e=>{u.style[e]=`${s}px`}),u}(h,t,u,f,d,a,c);l.appendChild(i)}),o&&Object.keys(Lv).forEach(e=>{let t=Lv[e],i=function(e,t,i,n,r,o){let s,a,l=2*r;"top"===t||"bottom"===t?(s=l,a=r):(s=r,a=l);let h=Fv(e,s,a),u=Rv(e,i,n);u.setAttribute("points",`0,${a/2} ${s},${a/2}`),h.appendChild(u);let c=Rv(e,i,n);c.setAttribute("points",`${s/2},0 ${s/2},${a}`),h.appendChild(c);let d,p=Rv(e,i,n,"circle");switch(p.setAttribute("cx",s/2),p.setAttribute("cy",a/2),p.setAttribute("r",r/4),h.appendChild(p),t){case"top":d="bottom";break;case"bottom":d="top";break;case"left":d="right";break;case"right":d="left"}return Object.keys(Lv).forEach(e=>{let i=Lv[e];i===t?h.style[i]=`${o}px`:i!==d&&(h.style[i]="0",h.style[`margin-${i}`]="auto")}),h}(h,t,u,f,d,c);l.appendChild(i)})}var Bv,Mv=(()=>{let e={width:!0,height:!0,"block-size":!0,"inline-size":!0,"writing-mode":!0,direction:!0,margin:!0,padding:!0,border:!0,outline:!0,"outline-width":!0,"outline-style":!0,"outline-color":!0,"outline-offset":!0,"border-radius":!0,"border-top-left-radius":!0,"border-top-right-radius":!0,"border-bottom-right-radius":!0,"border-bottom-left-radius":!0,"border-start-start-radius":!0,"border-start-end-radius":!0,"border-end-start-radius":!0,"border-end-end-radius":!0,"box-shadow":!0,"box-sizing":!0};return["left","right","top","bottom","before","after","start","end","block-start","block-end","inline-start","inline-end","inside","outside"].forEach(t=>{e[`margin-${t}`]=!0,e[`padding-${t}`]=!0,e[`border-${t}-width`]=!0,e[`border-${t}-style`]=!0,e[`border-${t}-color`]=!0}),e})(),Dv={"top-left-corner":{order:1,isInTopRow:!0,isInBottomRow:!1,isInLeftColumn:!0,isInRightColumn:!1,positionAlongVariableDimension:null},"top-left":{order:2,isInTopRow:!0,isInBottomRow:!1,isInLeftColumn:!1,isInRightColumn:!1,positionAlongVariableDimension:"start"},"top-center":{order:3,isInTopRow:!0,isInBottomRow:!1,isInLeftColumn:!1,isInRightColumn:!1,positionAlongVariableDimension:"center"},"top-right":{order:4,isInTopRow:!0,isInBottomRow:!1,isInLeftColumn:!1,isInRightColumn:!1,positionAlongVariableDimension:"end"},"top-right-corner":{order:5,isInTopRow:!0,isInBottomRow:!1,isInLeftColumn:!1,isInRightColumn:!0,positionAlongVariableDimension:null},"right-top":{order:6,isInTopRow:!1,isInBottomRow:!1,isInLeftColumn:!1,isInRightColumn:!0,positionAlongVariableDimension:"start"},"right-middle":{order:7,isInTopRow:!1,isInBottomRow:!1,isInLeftColumn:!1,isInRightColumn:!0,positionAlongVariableDimension:"center"},"right-bottom":{order:8,isInTopRow:!1,isInBottomRow:!1,isInLeftColumn:!1,isInRightColumn:!0,positionAlongVariableDimension:"end"},"bottom-right-corner":{order:9,isInTopRow:!1,isInBottomRow:!0,isInLeftColumn:!1,isInRightColumn:!0,positionAlongVariableDimension:null},"bottom-right":{order:10,isInTopRow:!1,isInBottomRow:!0,isInLeftColumn:!1,isInRightColumn:!1,positionAlongVariableDimension:"end"},"bottom-center":{order:11,isInTopRow:!1,isInBottomRow:!0,isInLeftColumn:!1,isInRightColumn:!1,positionAlongVariableDimension:"center"},"bottom-left":{order:12,isInTopRow:!1,isInBottomRow:!0,isInLeftColumn:!1,isInRightColumn:!1,positionAlongVariableDimension:"start"},"bottom-left-corner":{order:13,isInTopRow:!1,isInBottomRow:!0,isInLeftColumn:!0,isInRightColumn:!1,positionAlongVariableDimension:null},"left-bottom":{order:14,isInTopRow:!1,isInBottomRow:!1,isInLeftColumn:!0,isInRightColumn:!1,positionAlongVariableDimension:"end"},"left-middle":{order:15,isInTopRow:!1,isInBottomRow:!1,isInLeftColumn:!0,isInRightColumn:!1,positionAlongVariableDimension:"center"},"left-top":{order:16,isInTopRow:!1,isInBottomRow:!1,isInLeftColumn:!0,isInRightColumn:!1,positionAlongVariableDimension:"start"}},zv=(()=>{let e=Dv;return Object.keys(e).sort((t,i)=>e[t].order-e[i].order)})(),Vv="vivliostyle-page-rule-master",Uv="_marginBoxes",Hv="_footnoteArea",$v=class extends Qm{constructor(e,t,i){super(e,null,Vv,[],t,null,0),h(this,"pageMarginBoxes",{}),h(this,"pageRulePartition");let n=Iv(i);this.pageRulePartition=new jv(this.scope,this,i,n),this.createPageMarginBoxes(i),this.applySpecified(i,n)}createPageMarginBoxes(e){let t=e[Uv];t&&zv.forEach(i=>{t[i]&&(this.pageMarginBoxes[i]=new Gv(this.scope,this,i,e))})}applySpecified(e,t){this.specified.position=new Cd(di.relative,0),this.specified.width=new Cd(t.width,0),this.specified.height=new Cd(t.height,0);for(let t in e)!Mv[t]&&"background-clip"!==t&&(this.specified[t]=e[t])}createInstance(e,t,i){return new qv(e,this,t,i)}},jv=class extends tv{constructor(e,t,i,n){super(e,null,null,[],t),h(this,"pageSize",n),h(this,"pageAreaPartition"),this.pageAreaPartition=new Wv(this.scope,this),this.applySpecified(i)}applySpecified(e){this.specified["wrap-flow"]=new Cd(di.auto,0),this.specified["z-index"]=new Cd(new ei(0),0),this.specified.position=new Cd(di.absolute,0),this.specified.overflow=new Cd(di.visible,0);for(let t in Mv)Mv.hasOwnProperty(t)&&(this.specified[t]=e[t])}createInstance(e,t,i){return new Zv(e,this,t,i)}},Wv=class extends tv{constructor(e,t){super(e,null,null,[],t),this.specified["flow-from"]=new Cd(Zt("body"),0)}},Gv=class extends tv{constructor(e,t,i,n){super(e,null,null,[],t),h(this,"marginBoxName",i),this.applySpecified(n)}applySpecified(e){let t=e[Uv][this.marginBoxName];for(let i in e){let n=e[i],r=t[i];(ed[i]||r&&r.value===di.inherit)&&(this.specified[i]=n)}for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e)){let i=t[e];i&&i.value!==Wt&&i.value!==di.inherit&&i.value!==di.unset&&i.value!==di.revert&&(this.specified[e]=i)}}createInstance(e,t,i){return new Qv(e,this)}},qv=class extends vv{constructor(e,t,i,n){var r;super(e,t),h(this,"pageAreaDimension"),h(this,"pageAreaPartitionInstance"),h(this,"pageMarginBoxInstances",{});let o=null==(r=i.styler)?void 0:r.bodyPropagatedStyle;for(let e in n)if(Object.prototype.hasOwnProperty.call(n,e))switch(e){case"writing-mode":case"direction":if((null==o?void 0:o[e])===n[e])break;this.cascaded[e]=n[e]}this.buildCascadedStyle(n),this.init(i),this.pageAreaPartitionInstance=this.pageBox.pageRulePartition.createInstance(this,i,n);let s=this.pageAreaPartitionInstance.pageAreaDimension;this.pageAreaDimension=s;let a=this.style;a.width=new li(s.borderBoxWidth),a.height=new li(s.borderBoxHeight),a["padding-left"]=new li(s.marginLeft),a["padding-right"]=new li(s.marginRight),a["padding-top"]=new li(s.marginTop),a["padding-bottom"]=new li(s.marginBottom),this.register(i)}get pageAreaEstablishingChild(){return this.pageAreaPartitionInstance}applyCascadeAndInit(e,t){e.pushRule(this.pageBox.classes,null,this.cascaded),this.resolveContent(e);let i=this.cascaded.content;i&&(this.style.content=i.value);for(let i of this.pageBox.children)(i===this.pageBox.pageRulePartition?this.pageAreaPartitionInstance:i.createInstance(this,e.context,t)).applyCascadeAndInit(e,t);e.popRule()}initHorizontal(){let e=this.style;e.left=mi,e["margin-left"]=mi,e["border-left-width"]=mi,e["padding-left"]=mi,e["padding-right"]=mi,e["border-right-width"]=mi,e["margin-right"]=mi,e.right=mi}initVertical(){let e=this.style;e.top=mi,e["margin-top"]=mi,e["border-top-width"]=mi,e["padding-top"]=mi,e["padding-bottom"]=mi,e["border-bottom-width"]=mi,e["margin-bottom"]=mi,e.bottom=mi}adjustPageLayout(e,t,i){let n=t.marginBoxes,r={start:this.pageAreaDimension.marginLeft,end:this.pageAreaDimension.marginRight,extent:this.pageAreaDimension.borderBoxWidth},o={start:this.pageAreaDimension.marginTop,end:this.pageAreaDimension.marginBottom,extent:this.pageAreaDimension.borderBoxHeight};this.sizeMarginBoxesAlongVariableDimension(n.top,!0,r,e,i),this.sizeMarginBoxesAlongVariableDimension(n.bottom,!0,r,e,i),this.sizeMarginBoxesAlongVariableDimension(n.left,!1,o,e,i),this.sizeMarginBoxesAlongVariableDimension(n.right,!1,o,e,i)}sizeMarginBoxesAlongVariableDimension(e,t,i,n,r){let o="start",s="center",a="end",l=this.pageBox.scope,h={},u={},c={};for(let i in e){let n=Dv[i];if(n){let o=e[i],s=this.pageMarginBoxInstances[i],a=new Xv(o,s.style,t,l,r);h[n.positionAlongVariableDimension]=o,u[n.positionAlongVariableDimension]=s,c[n.positionAlongVariableDimension]=a}}let d={start:i.start.evaluate(n),end:i.end.evaluate(n),extent:i.extent.evaluate(n)},p=this.getSizesOfMarginBoxesAlongVariableDimension(c,d.extent),f=!1,g={};Object.keys(h).forEach(e=>{let o=e,s=iv(l,u[o].style[t?"max-width":"max-height"],i.extent);if(s){let e=s.evaluate(n),i=p[o];if(null!=i&&i>e){let i=c[o]=new Kv(h[o],u[o].style,t,l,r,e);g[o]=i.getOuterSize(),f=!0}}}),f&&(p=this.getSizesOfMarginBoxesAlongVariableDimension(c,d.extent),f=!1,[o,s,a].forEach(e=>{var t;p[e]=null!=(t=g[e])?t:p[e]}));let m={};Object.keys(h).forEach(e=>{let o=e,s=iv(l,u[o].style[t?"min-width":"min-height"],i.extent);if(s){let e=s.evaluate(n),i=p[o];if(null!=i&&i<e){let i=c[o]=new Kv(h[o],u[o].style,t,l,r,e);m[o]=i.getOuterSize(),f=!0}}}),f&&(p=this.getSizesOfMarginBoxesAlongVariableDimension(c,d.extent),[o,s,a].forEach(e=>{p[e]=m[e]||p[e]}));let v=d.start+d.extent,y=d.start+(d.start+d.extent);[o,s,a].forEach(e=>{let i=p[e];if(null!=i){let n=h[e],r=0;switch(e){case o:r=t?n.left:n.top;break;case s:r=(y-i)/2;break;case a:r=v-i}t?n.setHorizontalPosition(r,i-n.getInsetLeft()-n.getInsetRight()):n.setVerticalPosition(r,i-n.getInsetTop()-n.getInsetBottom())}})}getSizesOfMarginBoxesAlongVariableDimension(e,t){var i;let n=e.start,r=e.center,o=e.end,s={};if(r){let e=new Yv([n,o]),a=this.distributeAutoMarginBoxSizes(r,e,t);null!=a.xSize&&(s.center=a.xSize);let l=null!=(i=a.xSize)?i:r.getOuterSize(),h=Math.max((t-l)/2,0);n&&(s.start=n.hasAutoSize()?h:n.getOuterSize()),o&&(s.end=o.hasAutoSize()?h:o.getOuterSize())}else{let e=this.distributeAutoMarginBoxSizes(null!=n?n:null,null!=o?o:null,t);null!=e.xSize&&(s.start=e.xSize),null!=e.ySize&&(s.end=e.ySize)}return s}distributeAutoMarginBoxSizes(e,t,i){let n={xSize:null,ySize:null};if(e instanceof Xv&&e.minMaxFitContent&&(n.xSize=e.getOuterSize()),t instanceof Xv&&t.minMaxFitContent&&(n.ySize=t.getOuterSize()),e&&t)if(e.hasAutoSize()&&t.hasAutoSize()){let r=e.getOuterMaxContentSize(),o=t.getOuterMaxContentSize();if(r>0&&o>0){let s=r+o;if(s<i)n.xSize=i*r/s;else{let o=e.getOuterMinContentSize(),a=o+t.getOuterMinContentSize();a<i?n.xSize=o+(i-a)*(r-o)/(s-a):a>0&&(n.xSize=i*o/a)}null!=n.xSize&&n.xSize>0&&(n.ySize=i-n.xSize)}else r>0?n.xSize=i:o>0&&(n.ySize=i)}else e.hasAutoSize()?n.xSize=Math.max(i-t.getOuterSize(),0):t.hasAutoSize()&&(n.ySize=Math.max(i-e.getOuterSize(),0));else e?e.hasAutoSize()&&(n.xSize=i):t&&t.hasAutoSize()&&(n.ySize=i);return n}prepareContainer(e,t,i,n,r){t.element.setAttribute("data-vivliostyle-page-box",!0),super.prepareContainer(e,t,i,n,r)}},Xv=class{constructor(e,t,i,n,r){h(this,"container",e),h(this,"isHorizontal",i),h(this,"clientLayout",r),h(this,"hasAutoSize_"),h(this,"size",null),h(this,"minMaxFitContent",null);let o=t[i?"width":"height"];if(this.hasAutoSize_=!o||o===di.auto||yi(o),this.minMaxFitContent=o instanceof Kt&&("min-content"===o.name||"max-content"===o.name||"fit-content"===o.name)?o.name:null,this.minMaxFitContent){let e=this.getSize();if(this.isHorizontal){let t=e["min-content"===this.minMaxFitContent?"min-content width":"max-content"===this.minMaxFitContent?"max-content width":"fit-content width"];this.container.setHorizontalPosition(this.container.left,t)}else{let t=e["min-content"===this.minMaxFitContent?"min-content height":"max-content"===this.minMaxFitContent?"max-content height":"fit-content height"];this.container.setVerticalPosition(this.container.top,t)}}}hasAutoSize(){return this.hasAutoSize_}getSize(){if(!this.size){let e=this.isHorizontal?["max-content width","min-content width","fit-content width"]:["max-content height","min-content height","fit-content height"];this.size=gl(this.clientLayout,this.container.element,e)}return this.size}getOuterMaxContentSize(){let e=this.getSize();return this.isHorizontal?this.container.getInsetLeft()+e["max-content width"]+this.container.getInsetRight():this.container.getInsetTop()+e["max-content height"]+this.container.getInsetBottom()}getOuterMinContentSize(){let e=this.getSize();return this.isHorizontal?this.container.getInsetLeft()+e["min-content width"]+this.container.getInsetRight():this.container.getInsetTop()+e["min-content height"]+this.container.getInsetBottom()}getOuterSize(){return this.isHorizontal?this.container.getInsetLeft()+this.container.width+this.container.getInsetRight():this.container.getInsetTop()+this.container.height+this.container.getInsetBottom()}},Yv=class{constructor(e){h(this,"params",e)}hasAutoSize(){return this.params.some(e=>{var t;return null!=(t=null==e?void 0:e.hasAutoSize())&&t})}getOuterMaxContentSize(){let e=this.params.map(e=>{var t;return null!=(t=null==e?void 0:e.getOuterMaxContentSize())?t:0});return Math.max.apply(null,e)*e.length}getOuterMinContentSize(){let e=this.params.map(e=>{var t;return null!=(t=null==e?void 0:e.getOuterMinContentSize())?t:0});return Math.max.apply(null,e)*e.length}getOuterSize(){let e=this.params.map(e=>{var t;return null!=(t=null==e?void 0:e.getOuterSize())?t:0});return Math.max.apply(null,e)*e.length}},Kv=class extends Xv{constructor(e,t,i,n,r,o){super(e,t,i,n,r),h(this,"fixedSize"),this.fixedSize=o}hasAutoSize(){return!1}getOuterMaxContentSize(){return this.getOuterSize()}getOuterMinContentSize(){return this.getOuterSize()}getOuterSize(){return this.isHorizontal?this.container.getInsetLeft()+this.fixedSize+this.container.getInsetRight():this.container.getInsetTop()+this.fixedSize+this.container.getInsetBottom()}},Zv=class extends bv{constructor(e,t,i,n){super(e,t),h(this,"contentBoxWidth"),h(this,"contentBoxHeight"),h(this,"pageAreaDimension"),h(this,"pageAreaEstablishingChild");for(let e in n)e.match(/^background-/)&&(this.cascaded[e]=n[e]);this.buildCascadedStyle(n),this.resolveStyle(i);let r=this.resolvePageBoxDimensions({start:"left",end:"right",extent:"width"}),o=this.resolvePageBoxDimensions({start:"top",end:"bottom",extent:"height"});this.contentBoxWidth=new li(r.contentBoxExtent),this.contentBoxHeight=new li(o.contentBoxExtent),this.pageAreaDimension={borderBoxWidth:r.borderBoxExtent,borderBoxHeight:o.borderBoxExtent,marginLeft:r.marginStart,marginRight:r.marginEnd,marginTop:o.marginStart,marginBottom:o.marginEnd},this.initColumns(),this.initEnabled(),this.register(i),this.pageAreaEstablishingChild=new Jv(this,t.pageAreaPartition)}applyCascadeAndInit(e,t){e.pushRule(this.pageBox.classes,null,this.cascaded),this.pageAreaEstablishingChild.applyCascadeAndInit(e,t),e.popRule()}resolvePageBoxDimensions(e){let t,i,n,r=this.style,o=this.pageBox.pageSize,s=this.pageBox.scope,a=e.start,l=e.end,h=e.extent,u=o[h].toExpr(s,null),c=iv(s,r[h],u),d=iv(s,r[`margin-${a}`],u),p=iv(s,r[`margin-${l}`],u),f=nv(s,r[`padding-${a}`],u),g=nv(s,r[`padding-${l}`],u),m=ov(s,r[`border-${a}-width`],r[`border-${a}-style`],u),v=ov(s,r[`border-${l}-width`],r[`border-${l}-style`],u),y=Mt(s,Mt(s,m,f),Mt(s,v,g));return c?(this.borderBoxSizing?(i=c,n=Dt(s,i,y)):(n=c,i=Mt(s,n,y)),t=Dt(s,u,i),d||p?d?p=Dt(s,t,d):d=Dt(s,t,p):(d=zt(s,t,new Rt(s,.5)),p=d)):(d||(d=s.zero),p||(p=s.zero),t=Mt(s,d,p),i=Dt(s,u,t),n=Dt(s,i,y),c=this.borderBoxSizing?i:n),r[a]=new li(d),r[l]=new li(p),r[`margin-${a}`]=mi,r[`margin-${l}`]=mi,r[`border-${a}-width`]=new li(m),r[`border-${l}-width`]=new li(v),r[`padding-${a}`]=new li(f),r[`padding-${l}`]=new li(g),r[h]=new li(c),r[`max-${h}`]=new li(c),{borderBoxExtent:i,contentBoxExtent:n,marginStart:d,marginEnd:p}}prepareContainer(e,t,i,n,r){t.element.setAttribute("data-vivliostyle-page-area-container",!0),super.prepareContainer(e,t,i,n,r)}},Jv=class extends bv{constructor(e,t){super(e,t),h(this,"pageAreaEstablishingChild",null),h(this,"pageRulePartitionInstance"),this.pageRulePartitionInstance=e}applyCascadeAndInit(e,t){var i,n;for(let e in t)e.match(/^column.*$/)&&(this.cascaded[e]=t[e]);this.cascaded["writing-mode"]=null!=(i=t["writing-mode"])?i:new Cd(di.horizontal_tb,0),this.cascaded.direction=null!=(n=t.direction)?n:new Cd(di.ltr,0),super.applyCascadeAndInit(e,{})}initHorizontal(){let e=this.style,t=this.pageRulePartitionInstance,i=t.style,n=this.pageBox.scope;e.left=i["padding-left"],e.width=t.contentBoxWidth,e["margin-left"]=new li(new ht(n,i.left.toExpr(n,null))),e["margin-right"]=new li(new ht(n,i.right.toExpr(n,null))),e["border-left-width"]=i.left,e["border-right-width"]=i.right,e["border-left-style"]=di.solid,e["border-right-style"]=di.solid,e["border-left-color"]=di.transparent,e["border-right-color"]=di.transparent}initVertical(){let e=this.style,t=this.pageRulePartitionInstance,i=t.style,n=this.pageBox.scope;e.top=i["padding-top"],e.height=t.contentBoxHeight,e["margin-top"]=new li(new ht(n,i.top.toExpr(n,null))),e["margin-bottom"]=new li(new ht(n,i.bottom.toExpr(n,null))),e["border-top-width"]=i.top,e["border-bottom-width"]=i.bottom,e["border-top-style"]=di.solid,e["border-bottom-style"]=di.solid,e["border-top-color"]=di.transparent,e["border-bottom-color"]=di.transparent}prepareContainer(e,t,i,n,r){t.element.setAttribute("data-vivliostyle-page-area",!0),i.pageAreaElement=t.element,super.prepareContainer(e,t,i,n,r),e.pageAreaWidth=t.width,e.pageAreaHeight=t.height}},Qv=class extends bv{constructor(e,t){super(e,t),h(this,"boxInfo"),h(this,"suppressEmptyBoxGeneration",!0);let i=t.marginBoxName;this.boxInfo=Dv[i],e.pageMarginBoxInstances[i]=this}prepareContainer(e,t,i,n,r){t.element.setAttribute("data-vivliostyle-page-margin-box",this.pageBox.marginBoxName),this.applyVerticalAlign(e,t.element),super.prepareContainer(e,t,i,n,r)}applyVerticalAlign(e,t){be(t,"display","flex"),be(t,"flex-flow",this.vertical?this.rtl?"row-reverse":"row":"column");let i=this.getProp(e,"vertical-align"),n=null;i===Zt("middle")?n="center":i===Zt("top")?n="flex-start":i===Zt("bottom")&&(n="flex-end"),n&&be(t,"justify-content",n);let r=this.getProp(e,"content");if(this.vertical||r instanceof ii||r instanceof li&&r.expr instanceof It&&r.expr.str.startsWith("running-element-")){let e="center";(this.boxInfo.isInTopRow||this.boxInfo.isInBottomRow)&&(this.boxInfo.isInLeftColumn||"end"===this.boxInfo.positionAlongVariableDimension?e=this.vertical||this.rtl?"start":"end":(this.boxInfo.isInRightColumn||"start"===this.boxInfo.positionAlongVariableDimension)&&(e=this.vertical||this.rtl?"end":"start")),be(t,"align-items",e)}}positionAlongVariableDimension(e,t){let i=this.style,n=this.pageBox.scope,r=e.start,o=e.end,s=e.extent,a="left"===r,l=a?t.borderBoxWidth:t.borderBoxHeight,h=iv(n,i[s],l),u=a?t.marginLeft:t.marginTop;if("start"===this.boxInfo.positionAlongVariableDimension)i[r]=new li(u);else if(h){let e=nv(n,i[`margin-${r}`],l),t=nv(n,i[`margin-${o}`],l),s=nv(n,i[`padding-${r}`],l),a=nv(n,i[`padding-${o}`],l),c=ov(n,i[`border-${r}-width`],i[`border-${r}-style`],l),d=ov(n,i[`border-${o}-width`],i[`border-${o}-style`],l),p=Mt(n,h,Mt(n,this.borderBoxSizing?n.zero:Mt(n,Mt(n,s,a),Mt(n,c,d)),Mt(n,e,t)));switch(this.boxInfo.positionAlongVariableDimension){case"center":i[r]=new li(Mt(n,u,Vt(n,Dt(n,l,p),new Rt(n,2))));break;case"end":i[r]=new li(Dt(n,Mt(n,u,l),p))}}}positionAndSizeAlongFixedDimension(e,t){let i=this.style,n=this.pageBox.scope,r=this.borderBoxSizing,o=e.inside,s=e.outside,a=e.extent,l=t[`margin${s.charAt(0).toUpperCase()}${s.substring(1)}`],h=rv(n,i[`margin-${o}`],l),u=rv(n,i[`margin-${s}`],l),c=nv(n,i[`padding-${o}`],l),d=nv(n,i[`padding-${s}`],l),p=ov(n,i[`border-${o}-width`],i[`border-${o}-style`],l),f=ov(n,i[`border-${s}-width`],i[`border-${s}-style`],l),g=iv(n,i[a],l),m=null;function v(e){if(m)return m;m={extent:g?g.evaluate(e):null,marginInside:h?h.evaluate(e):null,marginOutside:u?u.evaluate(e):null};let t=l.evaluate(e),i=0;return r||[p,c,d,f].forEach(t=>{t&&(i+=t.evaluate(e))}),(null===m.marginInside||null===m.marginOutside)&&i+m.extent+m.marginInside+m.marginOutside>t&&(null===m.marginInside&&(m.marginInside=0),null===m.marginOutside&&(m.marginOutside=0)),null!==m.extent&&null!==m.marginInside&&null!==m.marginOutside&&(m.marginOutside=null),null===m.extent?(m.extent=t-i-m.marginInside-m.marginOutside,null===m.marginInside&&(m.marginInside=0),null===m.marginOutside&&(m.marginOutside=0)):"number"==typeof m.extent&&(null===m.marginInside&&"number"==typeof m.marginOutside?m.marginInside=t-i-m.extent-m.marginOutside:"number"==typeof m.marginInside&&null===m.marginOutside?m.marginOutside=t-i-m.extent-m.marginInside:m.marginInside=m.marginOutside=(t-i-m.extent)/2),m}i[a]=new li(new It(n,function(){let e=v(this).extent;return null===e?"auto":e},a)),i[`margin-${o}`]=new li(new It(n,function(){let e=v(this).marginInside;return null===e?"auto":e},`margin-${o}`)),i[`margin-${s}`]=new li(new It(n,function(){let e=v(this).marginOutside;return null===e?"auto":e},`margin-${s}`)),"left"===o?i.left=new li(Mt(n,t.marginLeft,t.borderBoxWidth)):"top"===o&&(i.top=new li(Mt(n,t.marginTop,t.borderBoxHeight)))}initHorizontal(){let e=this.parentInstance.pageAreaDimension;this.boxInfo.isInLeftColumn?this.positionAndSizeAlongFixedDimension({inside:"right",outside:"left",extent:"width"},e):this.boxInfo.isInRightColumn?this.positionAndSizeAlongFixedDimension({inside:"left",outside:"right",extent:"width"},e):this.positionAlongVariableDimension({start:"left",end:"right",extent:"width"},e)}initVertical(){let e=this.parentInstance.pageAreaDimension;this.boxInfo.isInTopRow?this.positionAndSizeAlongFixedDimension({inside:"bottom",outside:"top",extent:"height"},e):this.boxInfo.isInBottomRow?this.positionAndSizeAlongFixedDimension({inside:"top",outside:"bottom",extent:"height"},e):this.positionAlongVariableDimension({start:"top",end:"bottom",extent:"height"},e)}finishContainer(e,t,i,n,r,o,s){super.finishContainer(e,t,i,n,r,o,s);let a=i.marginBoxes,l=this.pageBox.marginBoxName,h=this.boxInfo;h.isInLeftColumn||h.isInRightColumn?!h.isInTopRow&&!h.isInBottomRow&&(h.isInLeftColumn?a.left[l]=t:h.isInRightColumn&&(a.right[l]=t)):h.isInTopRow?a.top[l]=t:h.isInBottomRow&&(a.bottom[l]=t);let u=this.parentInstance.pageAreaDimension,c=this.getProp(e,"width"),d=c instanceof Kt&&("min-content"===c.name||"max-content"===c.name||"fit-content"===c.name)?c.name:null,p=this.getPropAsNumber(e,"min-width"),f=this.getPropAsNumber(e,"max-width");if(d||p||f){d&&be(t.element,"width",d),p&&be(t.element,"min-width",`${p}px`),f&&be(t.element,"max-width",`${f}px`);let i=this.getProp(e,"margin-left"),n=this.getProp(e,"margin-right");if(h.isInLeftColumn){let r=u.borderBoxWidth.evaluate(e)+u.marginRight.evaluate(e);be(t.element,"right",`${r}px`),(i===di.auto||n!==di.auto)&&be(t.element,"margin-left","auto"),n===di.auto&&be(t.element,"margin-right","auto")}else h.isInRightColumn&&(be(t.element,"right","0"),(n===di.auto||i!==di.auto)&&be(t.element,"margin-right","auto"),i===di.auto&&be(t.element,"margin-left","auto"))}let g=this.getProp(e,"height"),m=g instanceof Kt&&("min-content"===g.name||"max-content"===g.name||"fit-content"===g.name)?g.name:null,v=this.getPropAsNumber(e,"min-height"),y=this.getPropAsNumber(e,"max-height");if(m||v||y){m&&be(t.element,"height",m),v&&be(t.element,"min-height",`${v}px`),y&&be(t.element,"max-height",`${y}px`);let i=this.getProp(e,"margin-top"),n=this.getProp(e,"margin-bottom");if(h.isInTopRow){let r=u.borderBoxHeight.evaluate(e)+u.marginBottom.evaluate(e);be(t.element,"bottom",`${r}px`),(i===di.auto||n!==di.auto)&&be(t.element,"margin-top","auto"),n===di.auto&&be(t.element,"margin-bottom","auto")}else h.isInBottomRow&&(be(t.element,"bottom","0"),(n===di.auto||i!==di.auto)&&be(t.element,"margin-bottom","auto"),i===di.auto&&be(t.element,"margin-top","auto"))}}},ey=class{constructor(e,t,i,n,r){h(this,"pageScope",t),h(this,"rootPageBoxInstance",i),h(this,"context",n),h(this,"docElementStyle",r),h(this,"pageMasterCache",{}),h(this,"pageCascadeInstance"),this.pageCascadeInstance=e,this.definePageProgression()}definePageProgression(){let e=this.pageScope,t=this.context,i=t.isVersoFirstPage,n=new Nt(e,"page-number"),r=new bt(e,new Pt(e,n,new Rt(e,2)),i?e.one:e.zero);e.defineName("recto-page",new at(e,r)),e.defineName("verso-page",r),"ltr"===(t.pageProgression||kv(this.docElementStyle))?(e.defineName("left-page",r),e.defineName("right-page",new at(e,r))):(e.defineName("left-page",new at(e,r)),e.defineName("right-page",r))}getCascadedPageStyle(e){let t={};return this.pageCascadeInstance.pushRule([],e,t),this.pageCascadeInstance.popRule(),t}getPageRulePageMaster(e,t){let i=e.pageBox;if(0===Object.keys(t).length)return i.resetScope(),e;let n=this.makeCacheKey(t,i),r=this.pageMasterCache[n];return r||(r=i.pseudoName===fv?this.generatePageRuleMaster(t):this.generateCascadedPageMaster(t,i),this.pageMasterCache[n]=r),r.pageBox.resetScope(),r}makeCacheKey(e,t){var i;let n=this.makeCascadeValueObjectKey(e),r=(null==(i=this.context.currentLayoutPosition)?void 0:i.page)%2;return`${t.key}^${n}^${r}`}makeCascadeValueObjectKey(e){let t=[];for(let i in e)if(Object.prototype.hasOwnProperty.call(e,i)){let n,r=e[i];n=r instanceof Cd?`${r.value}`:this.makeCascadeValueObjectKey(r),t.push(i+n+(r.priority||""))}return t.sort().join("^")}generatePageRuleMaster(e){let t=new $v(this.pageScope,this.rootPageBoxInstance.pageBox,e).createInstance(this.rootPageBoxInstance,this.context,this.docElementStyle);return t.applyCascadeAndInit(this.pageCascadeInstance,this.docElementStyle),t.resolveAutoSizing(this.context),t}generateCascadedPageMaster(e,t){let i=t.clone({pseudoName:Vv}),n=i.specified,r=e.size;if(r&&!yi(r.value)){let t=Iv(e),i=r.priority;Ed(n,"width",new Cd(t.width,i),this.context),Ed(n,"height",new Cd(t.height,i),this.context)}["counter-reset","counter-increment"].forEach(t=>{n[t]&&(e[t]=n[t])});let o=i.createInstance(this.rootPageBoxInstance,this.context,this.docElementStyle);return o.applyCascadeAndInit(this.pageCascadeInstance,this.docElementStyle),o.resolveAutoSizing(this.context),o}},ty=class extends sp{constructor(e){super(),h(this,"pageType",e)}matches(e){return e.instance.currentPageType===this.pageType}getPriority(){return 3}primarySlot(e){return{table:e.pagetypes,key:this.pageType}}},iy=class extends sp{constructor(e){super(),h(this,"scope",e)}matches(e){return 1===new Nt(this.scope,"page-number").evaluate(e.instance.context)}getPriority(){return 2}},ny=class extends sp{constructor(e){super(),h(this,"scope",e)}matches(e){return!!new Nt(this.scope,"blank-page").evaluate(e.instance.context)}getPriority(){return 2}},ry=class extends sp{constructor(e){super(),h(this,"scope",e)}matches(e){return!!new Nt(this.scope,"left-page").evaluate(e.instance.context)}getPriority(){return 1}},oy=class extends sp{constructor(e){super(),h(this,"scope",e)}matches(e){return!!new Nt(this.scope,"right-page").evaluate(e.instance.context)}getPriority(){return 1}},sy=class extends sp{constructor(e){super(),h(this,"scope",e)}matches(e){return!!new Nt(this.scope,"recto-page").evaluate(e.instance.context)}getPriority(){return 1}},ay=class extends sp{constructor(e){super(),h(this,"scope",e)}matches(e){return!!new Nt(this.scope,"verso-page").evaluate(e.instance.context)}getPriority(){return 1}},ly=class extends Tp{constructor(e,t,i){super(t,i),h(this,"scope",e),h(this,"a",t),h(this,"b",i)}matches(e){let t=e.instance.context,i=t.layoutPositionAtPageStart.page;return t.blankPageAtStart&&i--,!!i&&this.matchANPlusB(i)}getPriority(){return 2}},hy=class extends Tp{constructor(e,t,i,n){super(t,i),h(this,"scope",e),h(this,"a",t),h(this,"b",i),h(this,"pageType",n)}matches(e){let t=e.instance.pageTypePageIndices[this.pageType];if(!t)return!1;for(let e of t)if(this.matchANPlusB(e))return!0;return!1}getPriority(){return 3}},uy=class extends op{constructor(e,t){super(e,t,null,null,null)}apply(e){!function(e,t,i,n,r){Yd(e,t,i,n,null,null,null,r.instance.mergeValidatorSet);let o=i[Uv];if(o){let i=Wd(t,Uv);for(let t in o)if(o.hasOwnProperty(t)){let s=i[t];s||(s={},i[t]=s),Yd(e,s,o[t],n,null,null,null,r.instance.mergeValidatorSet)}}let s=i[Hv];if(s){let e=Wd(t,Hv);for(let t in s)if(s.hasOwnProperty(t)){let i=e[t];i||(i={},e[t]=i);let n=s[t];for(let e in n)if(n.hasOwnProperty(e)&&"_pseudos"!==e){let t=n[e];t instanceof Cd&&Ed(i,e,t)}let r=jd(n,"_pseudos");if(r){let e=Wd(i,"_pseudos");for(let t in r)if(r.hasOwnProperty(t)){let i=e[t];i||(i={},e[t]=i);let n=r[t];for(let e in n)if(n.hasOwnProperty(e)){let t=n[e];t instanceof Cd&&Ed(i,e,t)}}}}}}(e.instance.context,e.currentStyle,this.style,this.specificity,e)}},cy=class extends gf{constructor(e,t,i,n,r,o){super(e,t,null==i?void 0:i.condition,i,null,n,o),h(this,"pageProps",r),h(this,"currentPageSelectors",[]),h(this,"currentNamedPageSelector",""),h(this,"currentPseudoPageClassSelectors",[])}startPageRule(){this.startSelectorRule()}tagSelector(e,t){this.currentNamedPageSelector=t,t&&(this.chain.push(new ty(t)),this.specificity+=65536)}pseudoclassSelector(e,t){if(e=e.toLowerCase(),t)if("nth"===e){let i=t[0],n=t[1];if(3===t.length&&"string"==typeof t[2]){let r=t[2];this.currentPseudoPageClassSelectors.push(`:${e}(${i}n${n<0?n:"+"+n} of ${r})`),this.chain.push(new hy(this.scope,i,n,r)),this.specificity+=65792}else this.currentPseudoPageClassSelectors.push(`:${e}(${i}n${n<0?n:"+"+n})`),this.chain.push(new ly(this.scope,i,n)),this.specificity+=256}else this.reportAndSkip(`E_INVALID_PAGE_SELECTOR :${e}(${t.join("")})`);else switch(this.currentPseudoPageClassSelectors.push(`:${e}`),e){case"first":this.chain.push(new iy(this.scope)),this.specificity+=256;break;case"blank":this.chain.push(new ny(this.scope)),this.specificity+=256;break;case"left":this.chain.push(new ry(this.scope)),this.specificity+=1;break;case"right":this.chain.push(new oy(this.scope)),this.specificity+=1;break;case"recto":this.chain.push(new sy(this.scope)),this.specificity+=1;break;case"verso":this.chain.push(new ay(this.scope)),this.specificity+=1;break;default:this.reportAndSkip(`E_INVALID_PAGE_SELECTOR :${e}`)}}finishSelector(){let e;e=this.currentNamedPageSelector||this.currentPseudoPageClassSelectors.length?[this.currentNamedPageSelector].concat(this.currentPseudoPageClassSelectors.sort()):null,this.currentPageSelectors.push({selectors:e,specificity:this.specificity}),this.currentNamedPageSelector="",this.currentPseudoPageClassSelectors=[]}nextSelector(){this.finishSelector(),super.nextSelector()}startRuleBody(){this.finishSelector(),super.startRuleBody()}simpleProperty(e,t,i){if(("bleed"===e||"marks"===e)&&!this.currentPageSelectors.some(e=>null===e.selectors))return;super.simpleProperty(e,t,i);let n=Hd(this.elementStyle,e),r=this.pageProps;if("bleed"===e||"marks"===e)r[""]||(r[""]={}),Object.keys(r).forEach(t=>{$d(r[t],e,n)});else if("size"===e){let t=r[""];this.currentPageSelectors.forEach(i=>{let o=n.increaseSpecificity(i.specificity),s=i.selectors?i.selectors.join(""):"",a=r[s];a?Ed(a,e,o):(a=r[s]={},$d(a,e,o),t&&["bleed","marks"].forEach(e=>{t[e]&&$d(a,e,t[e])}))})}}insertNonPrimary(e){this.cascade.insertInTable(this.cascade.pagetypes,"*",e)}makeApplyRuleAction(e){return new uy(this.elementStyle,e)}startFootnoteRule(e){let t=Wd(this.elementStyle,Hv),i=t.area;if(i||(i={},t.area=i),e){let t=Wd(i,"_pseudos"),n=t[e];n||(n={},t[e]=n),i=n}this.owner.delegateTo(e=>new py(this.scope,this.owner,this.validatorSet,i,e,this.layer))}startPageMarginBoxRule(e){let t=Wd(this.elementStyle,Uv),i=t[e];i||(i={},t[e]=i),this.owner.delegateTo(e=>new dy(this.scope,this.owner,this.validatorSet,i,e,this.layer))}},dy=class extends Uo{constructor(e,t,i,n,r,o=null){super(e,t,r),h(this,"validatorSet",i),h(this,"boxStyle",n),h(this,"layer",o),h(this,"ruleId",yd())}property(e,t,i){this.validatorSet.validatePropertyAndHandleShorthand(e,t,i,this.scope,this)}invalidPropertyValue(e,t){this.report(`E_INVALID_PROPERTY_VALUE ${e}: ${t.toString()}`)}unknownProperty(e,t){this.report(`E_INVALID_PROPERTY ${e}: ${t.toString()}`)}simpleProperty(e,t,i){let n=i?this.getImportantSpecificity():this.getBaseSpecificity();Td(e,t,this.validatorSet);let r=new Cd(t,n,this.layer,this.ruleId);$d(this.boxStyle,e,r)}},py=class extends Uo{constructor(e,t,i,n,r,o=null){super(e,t,r),h(this,"validatorSet",i),h(this,"areaStyle",n),h(this,"layer",o),h(this,"ruleId",yd())}property(e,t,i){this.validatorSet.validatePropertyAndHandleShorthand(e,t,i,this.scope,this)}invalidPropertyValue(e,t){this.report(`E_INVALID_PROPERTY_VALUE ${e}: ${t.toString()}`)}unknownProperty(e,t){this.report(`E_INVALID_PROPERTY ${e}: ${t.toString()}`)}simpleProperty(e,t,i){let n=i?this.getImportantSpecificity():this.getBaseSpecificity();Td(e,t,this.validatorSet);let r=new Cd(t,n,this.layer,this.ruleId);$d(this.areaStyle,e,r)}},fy=class{constructor(e,t,i){h(this,"store",e),h(this,"url",t),h(this,"document",i),h(this,"lang",null),h(this,"totalOffset",-1),h(this,"root"),h(this,"body"),h(this,"head"),h(this,"last"),h(this,"lastOffset",1),h(this,"idMap",null),this.root=function(e){return e.documentElement}(i);let n=null,r=null;if("http://www.w3.org/1999/xhtml"==this.root.namespaceURI){for(let e=this.root.firstChild;e;e=e.nextSibling){if(1!=e.nodeType)continue;let t=e;if("http://www.w3.org/1999/xhtml"==t.namespaceURI)switch(t.localName){case"head":r=t;break;case"body":n=t}}this.lang=this.root.getAttribute("lang")}this.body=n,this.head=r,this.last=this.root,this.last.setAttribute(K,"0")}doc(){return new by([this.document])}getElementOffset(e){let t=e.getAttribute(K);if(t)return parseInt(t,10);let i=this.lastOffset,n=this.last;for(;n!=e;){let e=n.firstChild;if(!e)for(;e=n.nextSibling,!e;)if(n=n.parentNode,null==n)throw new Error("Internal error");n=e,1==e.nodeType?(e.setAttribute(K,i.toString()),++i):i+=e.textContent.length}return this.lastOffset=i,this.last=e,i-1}getNodeOffset(e,t,i){let n=0,r=e,o=null;if(1==r.nodeType){if(!i)return this.getElementOffset(r)}else{if(n=t,o=r.previousSibling,!o)return r=r.parentNode,n+=1,this.getElementOffset(r)+n;r=o}for(;;){for(;r.lastChild;)r=r.lastChild;if(1==r.nodeType)break;if(n+=r.textContent.length,o=r.previousSibling,!o){r=r.parentNode;break}r=o}return n+=1,this.getElementOffset(r)+n}getTotalOffset(){return this.totalOffset<0&&(this.totalOffset=this.getNodeOffset(this.root,0,!0)),this.totalOffset}getNodeByOffset(e){let t,i=this.root;for(;;){if(t=this.getElementOffset(i),t>=e)return i;let n=i.children;if(!n)break;let r=Le(n.length,t=>{let i=n[t];return this.getElementOffset(i)>e});if(0==r)break;i=n[r-1]}let n=t+1,r=i,o=r.firstChild||r.nextSibling,s=null;for(;;){if(o){if(1==o.nodeType||(r=o,s=r,n+=o.textContent.length,n>e&&!/^\s*$/.test(o.textContent)))break}else if(r=r.parentNode,!r)break;o=r.nextSibling}return o&&s&&/^\s*$/.test(s.textContent)&&(s=o),s||i}buildIdMap(e){let t=e.getAttribute("id");t&&!this.idMap[t]&&(this.idMap[t]=e);let i=e.getAttributeNS("http://www.w3.org/XML/1998/namespace","id");i&&!this.idMap[i]&&(this.idMap[i]=e);for(let t=e.firstElementChild;t;t=t.nextElementSibling)this.buildIdMap(t)}getElement(e){var t;let i=e.match(/([^#]*)#(.+)$/);if(!i||i[1]&&i[1]!=this.url&&(null==(t=this.store)?void 0:t.get(i[1]))!==this)return null;let n=i[2],r=this.document.getElementById(n);return!r&&this.document.getElementsByName&&(r=this.document.getElementsByName(n)[0]),r||(this.idMap||(this.idMap={},this.buildIdMap(this.document.documentElement)),r=this.idMap[n]),r}},gy=((Bv=gy||{}).TEXT_HTML="text/html",Bv.TEXT_XML="text/xml",Bv.APPLICATION_XML="application/xml",Bv.APPLICATION_XHTML_XML="application/xhtml+xml",Bv.IMAGE_SVG_XML="image/svg+xml",Bv);function my(e,t,i){let n,r=i||new DOMParser;try{n=r.parseFromString(e,t)}catch{}return!n||"text/html"!==t&&n.querySelector("parsererror")?null:n}function vy(e,t){let i=e.responseXML;if(!i){let t=new DOMParser,n=e.responseText;if(null!=n){let r=function(e){let t=e.contentType;if(t){let e=Object.keys(gy);for(let i=0;i<e.length;i++)if(gy[e[i]]===t)return t;if(t.match(/\+xml$/))return"application/xml"}let i=e.url.match(/\.([^./#?]+)([#?]|$)/);if(i)switch(i[1]){case"html":case"htm":return"text/html";case"xhtml":case"xht":return"application/xhtml+xml";case"svg":case"svgz":return"image/svg+xml";case"opf":case"xml":return"application/xml"}return null}(e);if(i=my(n,r||"application/xml",t),i&&!r){let e=i.documentElement;"html"!==e.localName.toLowerCase()||e.namespaceURI?"svg"===e.localName.toLowerCase()&&"image/svg+xml"!==i.contentType&&(i=my(n,"image/svg+xml",t)):i=my(n,"text/html",t)}i||(i=my(n,"text/html",t))}}return so(i?new fy(t,e.url,i):null)}var yy=new class e{constructor(e){h(this,"fn",e)}check(e){return this.fn(e)}withAttribute(t,i){return new e(e=>this.check(e)&&1==e.nodeType&&e.getAttribute(t)==i)}withChild(t,i){return new e(e=>{if(!this.check(e))return!1;let n=new by([e]);return n=n.child(t),i&&(n=n.predicate(i)),n.size()>0})}}(e=>!0),by=class e{constructor(e){h(this,"nodes",e)}asArray(){return this.nodes}size(){return this.nodes.length}predicate(t){let i=[];for(let e of this.nodes)t.check(e)&&i.push(e);return new e(i)}forEachNode(t){let i=[],n=e=>{i.push(e)};for(let e=0;e<this.nodes.length;e++)t(this.nodes[e],n);return new e(i)}forEach(e){let t=[];for(let i=0;i<this.nodes.length;i++)t.push(e(this.nodes[i]));return t}forEachNonNull(e){let t=[];for(let i=0;i<this.nodes.length;i++){let n=e(this.nodes[i]);null!=n&&t.push(n)}return t}child(e){return this.forEachNode((t,i)=>{for(let n=t.firstChild;n;n=n.nextSibling)1==n.nodeType&&n.localName==e&&i(n)})}childElements(){return this.forEachNode((e,t)=>{for(let i=e.firstChild;i;i=i.nextSibling)1==i.nodeType&&t(i)})}attribute(e){return this.forEachNonNull(t=>1==t.nodeType?t.getAttribute(e):null)}textContent(){return this.forEach(e=>e.textContent)}},wy=class extends Ef{constructor(e,t,i,n,r,o,s,a){super(e,t,null,i,n,s,"counter-style",a),h(this,"counterStyleName",r),h(this,"counterStyles",o)}endRule(){super.endRule(),this.counterStyles.define(this.counterStyleName,this.elementStyle,{priority:this.getBaseSpecificity(),layer:this.layer})||R.warn(`E_CSS_COUNTER_STYLE_INVALID: @counter-style ${this.counterStyleName}`)}},xy=class{constructor(e,t,i,n,r,o,s,a,l,u,c){h(this,"store",e),h(this,"rootScope",t),h(this,"pageScope",i),h(this,"cascade",n),h(this,"rootBox",r),h(this,"fontFaces",o),h(this,"footnoteProps",s),h(this,"flowProps",a),h(this,"viewportProps",l),h(this,"pageProps",u),h(this,"counterStyleStore",c),h(this,"fontDeobfuscator"),h(this,"validatorSet"),this.fontDeobfuscator=e.fontDeobfuscator,this.validatorSet=e.validatorSet,this.pageScope.defineBuiltIn("has-content",function(e){let t=this,i=t.currentLayoutPosition,n=i.firstFlowChunkOfFlow(e);return t.matchPageSide(i.startSideOfFlow(e))&&i.hasContent(e,t.lookupOffset)&&!!n&&!t.flowChunkIsAfterParentFlowForcedBreak(n)}),this.pageScope.defineName("page-number",new It(this.pageScope,function(){return this.pageNumberOffset+this.getCurrentPageNumberForPageScope()},"page-number")),this.pageScope.defineName("blank-page",new It(this.pageScope,function(){let e=this.currentLayoutPosition;return null==e?void 0:e.isBlankPage},"blank-page"))}sizeViewport(e,t,i,n){if(this.viewportProps.length){let r=new Je(this.rootScope,e,t,i,i*Ue.lineHeight),o=function(e,t){let i={};for(let n=0;n<t.length;n++)Yd(e,i,t[n],0,null,null,null,null);return i}(r,this.viewportProps),s=o.width,a=o.height,l=o["text-zoom"],h=1;if(s&&a||l){let o=Ke.em;if((l?l.evaluate(r,"text-zoom"):null)===di.scale&&(h=o/i,i=o,e*=h,t*=h),s&&a){let e=ui(s.evaluate(r,"width"),r),t=ui(a.evaluate(r,"height"),r);if(e>0&&t>0)return{width:n&&n.spreadView?2*(e+n.pageBorder):e,height:t,fontSize:i}}}}return{width:e,height:t,fontSize:i}}};function Sy(e){let t=new Map,i=e=>{e.formattingContext&&!t.has(e.formattingContext)&&t.set(e.formattingContext,e.formattingContext.saveState()),e.shadowSibling&&i(e.shadowSibling)};for(let t in e.flowPositions){let n=e.flowPositions[t];for(let e of n.positions){let t=e.chunkPosition.primary;for(let e of t.steps)i(e);if(e.chunkPosition.floats)for(let t of e.chunkPosition.floats)for(let e of t.steps)i(e)}}return t}function Cy(e){for(let[t,i]of e)void 0!==i&&t.restoreState(i)}var ky=class e extends Je{constructor(e,t,i,n,r,o,s,a,l,u,c,d,p,f,g,m,v){super(e.rootScope,n.width,n.height,n.fontSize,n.fontSize*p.lineHeight),h(this,"style",e),h(this,"xmldoc",t),h(this,"viewport",n),h(this,"clientLayout",r),h(this,"fontMapper",o),h(this,"customRenderer",s),h(this,"fallbackMap",a),h(this,"pageNumberOffset",l),h(this,"documentURLTransformer",u),h(this,"counterStore",c),h(this,"cmykStore",d),h(this,"lang"),h(this,"primaryFlows",{body:!0}),h(this,"rootPageBoxInstance"),h(this,"styler"),h(this,"stylerMap"),h(this,"currentLayoutPosition",null),h(this,"layoutPositionAtPageStart",null),h(this,"currentCascadedPageStyle",null),h(this,"lookupOffset",0),h(this,"faces"),h(this,"pageBoxInstances",{}),h(this,"pageManager"),h(this,"pageNumberContextStack",[]),h(this,"rootPageFloatLayoutContext"),h(this,"pageBreaks",{}),h(this,"pageProgression",null),h(this,"isVersoFirstPage",!1),h(this,"blankPageAtStart",!1),h(this,"pageSheetSize",{}),h(this,"pageSheetHeight",0),h(this,"pageSheetWidth",0),h(this,"invalidPageAreaOnCurrentPage",!1),h(this,"repeatedInvalidPageAreaLayoutPosition",null),h(this,"semanticFootnoteFirstRefOffsets",new Map),h(this,"semanticFootnoteFirstRefOffsetsInitialized",{value:!1}),h(this,"pageGroupPageCounts",Object.create(null)),h(this,"currentPageGroupDocument",null),this.lang=t.lang||i,this.faces=new Tm(this.style.fontDeobfuscator),this.rootPageFloatLayoutContext=Nl.createRoot(),this.pageProgression=m||null,this.isVersoFirstPage=!!v;for(let t in e.flowProps){let i=Hd(e.flowProps[t],"flow-consume");i&&(i.evaluate(this,"flow-consume")==di.all?this.primaryFlows[t]=!0:delete this.primaryFlows[t])}this.pref=p,this.pubTitle=f,this.docTitle=g;let y=this.counterStore.createCounterListener(this.xmldoc.url),b=this.counterStore.createCounterResolver(this.xmldoc.url,this.style.rootScope,this.style.pageScope);this.styler=new Cm(this.xmldoc,this.style.cascade,this.style.rootScope,this,this.primaryFlows,this.style.validatorSet,y,b,this.style.counterStyleStore,this.cmykStore,this.style.validatorSet),b.setStyler(this.styler),this.styler.resetFlowChunkStream(this),this.stylerMap={},this.stylerMap[this.xmldoc.url]=this.styler;let w=this.styler.getTopContainerStyle();this.pageProgression||(this.pageProgression=kv(w)),this.matchStartPageSide(this.styler.breakBeforeValues[0])||(0===this.pageNumberOffset?this.isVersoFirstPage=!0:this.blankPageAtStart=!0);let x=this.style.rootBox;this.rootPageBoxInstance=new mv(x);let S=this.style.cascade.createInstance(this,y,b,this.lang,this.style.counterStyleStore,this.cmykStore,this.xmldoc.root,this.style.rootScope,this.style.validatorSet,this.styler.styles,this.style.validatorSet);this.styler.cascade.currentPageType=this.styler.cascade.firstPageType,this.rootPageBoxInstance.applyCascadeAndInit(S,w),this.rootPageBoxInstance.resolveAutoSizing(this),this.pageManager=new ey(S,this.style.pageScope,this.rootPageBoxInstance,this,w);let C=this.style.pageProps;C[""]||(C[""]={}),Object.keys(C).forEach(e=>{let t=C[e];this.styler.cascade.applyVarFilter([t],null),Rd(t,!0)&&this.styler.cascade.applyVarFilter([t],null),this.styler.cascade.applyCalcFilter(t,this.styler.context),this.styler.cascade.applyCmykFilter(t);let i=Av(Iv(t),this);this.pageSheetSize[e]={width:i.pageWidth+2*i.cropOffset,height:i.pageHeight+2*i.cropOffset}})}static create(t,i,n,r,o,s,a,l,h,u,c,d,p,f,g,m,v){let y=new e(t,i,n,r,o,s,a,l,h,u,c,d,p,f,g,m,v),b=oo("StyleInstance.create");return y.loadFontsAndScripts().then(()=>{b.finish(y)}),b.result()}loadFontsAndScripts(){let e=oo("StyleInstance.loadFontsAndScripts"),t=[];for(let e of this.style.fontFaces){if(e.condition&&!e.condition.evaluate(this))continue;let i=Em(e.properties,this),n=new Nm(i);t.push(n)}return this.fontMapper.findOrLoadFonts(t,this.faces).then(()=>{(function(e,t,i){if(!Am)return so(!1);let n=Om(e);if(0===n.length)return so(!1);let r=n.some(e=>!(e.async||e.defer||"module"===e.type)),o=r?_m(e,t,i):null,s=t.document.fonts,a=t.$,l=!1,h=oo("loadScripts");return h.loop(()=>{if(0===n.length)return r?h.sleep(20).thenAsync(()=>{var e,i;return"loading"===s.status||t.document.documentElement.classList.contains("wf-loading")||null!=(e=t.FontJSON)&&e.Font&&null!=(i=t.ret)&&i.readyState&&t.ret.readyState<4?so(!0):so(!1)}):so(!1);let e=n.shift();return Lm(e,t,{inHead:!0,forceDefer:l}).thenAsync(()=>(!l&&t.$!==a&&(Fm.push(e),l=!0),0===n.length&&r&&(R.debug("dispatchEvent: DOMContentLoaded (document)"),t.document.dispatchEvent(new Event("DOMContentLoaded"))),so(!0)))}).then(()=>{o&&o.remove(),h.finish(!0)}),h.result()})(this.xmldoc.document,this.viewport.window,this.styler).thenFinish(e)}),e.result()}matchStartPageSide(e){let t=this.pageNumberOffset%2==(this.isVersoFirstPage?1:0),i="ltr"==this.pageProgression;switch(e){case"left":return t!==i;case"right":return t===i;case"recto":return t;case"verso":return!t;default:return!0}}getStylerForDoc(e){let t=this.stylerMap[e.url];if(!t){let i=this.style.store.getStyleForDoc(e),n=new Je(i.rootScope,this.pageWidth(),this.pageHeight(),this.initialFontSize,this.initialFontSize*Ue.lineHeight),r=this.counterStore.createCounterListener(e.url),o=this.counterStore.createCounterResolver(e.url,i.rootScope,i.pageScope);t=new Cm(e,i.cascade,i.rootScope,n,this.primaryFlows,i.validatorSet,r,o,i.counterStyleStore,this.cmykStore,null),this.stylerMap[e.url]=t}return t}registerInstance(e,t){this.pageBoxInstances[e]=t}lookupInstance(e){return this.pageBoxInstances[e]}encounteredFlowChunk(e,t){let i=this.currentLayoutPosition;if(i){i.flows[e.flowName]?t=i.flows[e.flowName]:i.flows[e.flowName]=t;let n=i.flowPositions[e.flowName];n||(n=new Ta,i.flowPositions[e.flowName]=n);let r=function(e){return{steps:[{node:e,shadowType:da.NONE,shadowContext:null,nodeShadow:null,shadowSibling:null,formattingContext:null,fragmentIndex:0}],offsetInNode:0,after:!1,preprocessedTextContent:null}}(e.element),o=new Ea(r),s=new Na(o,e);n.positions.push(s)}}evalSupportsTest(e,t,i){if(i)return"selector"===e&&this.evalSupportsSelector(t);if(!e)return!1;if(Si(e))return"undefined"!=typeof CSS&&CSS.supports(`(${e}:${t})`);let n=!0;let r=new class{unknownProperty(e,t){n=!1}invalidPropertyValue(e,t){n=!1}simpleProperty(e,t,i){}},o=ls(this.style.rootScope,new to(t,null),"");return!!o&&(this.xmldoc.store.validatorSet.validatePropertyAndHandleShorthand(e,o,!1,this.style.rootScope,r),n)}getCurrentPageNumberForPageScope(){var e;return this.currentLayoutPosition?this.currentLayoutPosition.page:null!=(e=this.pageNumberContextStack[this.pageNumberContextStack.length-1])?e:0}getPageNumberContextDepth(){return this.pageNumberContextStack.length}pushPageNumberContext(e){this.pageNumberContextStack.push(e)}restorePageNumberContextDepth(e){this.pageNumberContextStack.length=e}evalSupportsSelector(e){let t=new class extends Ey{errorMsg(...e){}}(null),i=rr(e),n=new to(i+"{}",t);return!!new ns(Ho,n,t,"").runParser(Number.POSITIVE_INFINITY,!1,!1,!1,!1)&&!t.cascadeParserHandler.invalid}getConsumedOffset(e){let t=Number.POSITIVE_INFINITY;for(let i=0;i<e.positions.length;i++){let n=e.positions[i].chunkPosition.primary,r=n.steps[0].node,o=n.offsetInNode,s=n.after,a=0;for(;r.ownerDocument!=this.xmldoc.document;)a++,r=n.steps[a].node,s=!1,o=0;let l=this.xmldoc.getNodeOffset(r,o,s);l<t&&(t=l)}return t}getNodePositionOffset(e){let t=e.steps[0].node,i=e.offsetInNode,n=e.after,r=0;for(;t.ownerDocument!=this.xmldoc.document;)r++,t=e.steps[r].node,n=!1,i=0;return this.xmldoc.getNodeOffset(t,i,n)}getPageStartOffset(e,t){if(!e)return 0;let i=Number.POSITIVE_INFINITY;for(let n in this.primaryFlows){let r=e.flowPositions[n];if(!t&&(!r||0==r.positions.length)&&this.currentLayoutPosition&&(this.styler.styleUntilFlowIsReached(n),r=this.currentLayoutPosition.flowPositions[n],e!=this.currentLayoutPosition&&r&&(r=r.clone(),e.flowPositions[n]=r)),r)for(let e=0;e<r.positions.length;e++){let t=r.positions[e].chunkPosition.primary,n=this.getNodePositionOffset(t);n<i&&(i=n)}}return i}getPageStartCounterOffsets(e){var t;let i=this.getPageStartOffset(e);if(!isFinite(i))return{counterOffset:i,changeOffset:i};let n=this.xmldoc.body||this.xmldoc.root,r=n?this.getFirstInFlowElementAtOrAfter(n,i):null,o=n?this.xmldoc.getElementOffset(n):i,s=i<=o,a=r===n&&s&&null!=(t=this.getFirstInFlowChildElement(n))?t:r;if(!a)return s?{counterOffset:o,changeOffset:o}:{counterOffset:i,changeOffset:i};let l=this.xmldoc.getElementOffset(a),h=i;return s&&l!==i&&(h=l),l===i&&(h=this.isInlineLevelElement(a)?Math.max(0,i-1):this.getDeepestFirstInFlowChildOffset(a)),{counterOffset:h,changeOffset:l}}getPageStartElement(e,t=this.getPageStartOffset(e)){var i;if(!isFinite(t))return null;let n=this.xmldoc.body||this.xmldoc.root;if(!n)return null;let r=this.getFirstInFlowElementAtOrAfter(n,t),o=this.xmldoc.getElementOffset(n);if(r===n&&t<=o)return null!=(i=this.getFirstInFlowChildElement(n))?i:r;if((r?this.xmldoc.getElementOffset(r):Number.POSITIVE_INFINITY)>t){let e=this.xmldoc.getNodeByOffset(t);if(!Qs(e)){let i=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;for(;i;){if(this.xmldoc.getElementOffset(i)<=t&&this.isPageBoundaryCandidateElement(i))return i;i=i.parentElement}}}return r}isForcedPageBreakValue(e){return Ns(e)&&"column"!==e&&"region"!==e}hasForcedPageBreakBefore(e){let t=Hd(e,"break-before");if(!t)return!1;let i=t.evaluate(this,"break-before").toString();return this.isForcedPageBreakValue(i)}getExplicitPageType(e){let t=Hd(e,"page");if(!t||yi(t.value))return null;let i=t.evaluate(this,"page").toString();return i&&"auto"!==i.toLowerCase()?i:null}getPageGroupPageType(e){if(this.isInlineLevelElement(e))return null;let t=this.styler.getStyle(e,!1);return t?this.getExplicitPageType(t):null}getPageStartPageType(e){let t=this.getPageStartOffset(e,!0),i=this.getPageStartElement(e,t);for(;i;){let e=this.getPageGroupPageType(i);if(e)return e;if(i===this.xmldoc.root)break;i=i.parentElement}return""}getPageStartPageTypeOverride(e){if(""!==this.getPageStartPageType(e))return;let t=this.getPageStartOffset(e,!0),i=this.getPageStartElement(e,t);if(i&&this.xmldoc.getElementOffset(i)<t)return"";for(;i&&(i=this.getFirstInFlowChildElement(i),i);){let e=this.getPageGroupPageType(i);if(e)return e}return""}getPreviousInFlowSibling(e){let t=e.previousElementSibling;for(;t;){if(this.isPageBoundaryCandidateElement(t))return t;t=t.previousElementSibling}return null}getFirstDocumentFlowElement(){var e;let t=this.xmldoc.body||this.xmldoc.root;if(!t)return null;let i=this.xmldoc.getElementOffset(t),n=this.getFirstInFlowElementAtOrAfter(t,i);return n===t&&null!=(e=this.getFirstInFlowChildElement(t))?e:n}getEffectiveFirstPageType(e){let t=e,i=t?this.getPageGroupPageType(t):null;for(;t;){let e=this.getFirstInFlowChildElement(t);if(!e)return i;let n=this.getPageGroupPageType(e);n&&(i=n),t=e}return i}getEffectivePageGroupStartElement(e){let t=e,i=e;for(;i;){let e=this.getFirstInFlowChildElement(i);if(!e)return t;this.getPageGroupPageType(e)&&(t=e),i=e}return t}resolveFirstPageType(){let e=this.getFirstDocumentFlowElement();return this.getEffectiveFirstPageType(e)}shouldStartPageGroup(e,t,i){let n=this.styler.getStyle(e,!1);if(!n)return!1;if(this.getFirstDocumentFlowElement()===e)return!0;let r=this.xmldoc.getElementOffset(e),o=this.xmldoc.body||this.xmldoc.root;if(i<=this.xmldoc.getElementOffset(o)&&e===o||!this.getPreviousInFlowSibling(e)&&i===r)return!0;if(r!==i)return!1;if(this.hasForcedPageBreakBefore(n))return!0;let s=this.getPreviousInFlowSibling(e);if(!s)return!1;let a=this.styler.getStyle(s,!1);return!!a&&this.getExplicitPageType(a)!==t}updatePageGroupPageIndices(e){let t=this.pageManager.pageCascadeInstance;t.pageTypePageIndices=Object.create(null);let i=(null==e?void 0:e.startSideOfFlow("body"))||null,n=null==e?void 0:e.flowPositions.body,r=!(!n||!n.positions.length),o=!!i&&Is(i)&&!this.matchPageSide(i)&&!r,s=!(this.blankPageAtStart&&(!e||1===e.page)||null!=e&&e.isBlankPage||o),a=this.getPageStartOffset(e),l=this.getPageStartElement(e,a);if(!l)return;let h=this.getEffectivePageGroupStartElement(l),u=h===l?a:this.xmldoc.getElementOffset(h),c=h.ownerDocument,d=this.currentPageGroupDocument!==c&&s;d&&(this.pageGroupPageCounts=Object.create(null),this.currentPageGroupDocument=c);let p=h;for(;p;){let e=this.getPageGroupPageType(p);if(e){let i=this.pageGroupPageCounts[e]||(this.pageGroupPageCounts[e]=new Map),n=i.get(p)||0;(n>0||s&&(d||this.shouldStartPageGroup(p,e,u)))&&(n+=1,i.set(p,n),(t.pageTypePageIndices[e]||(t.pageTypePageIndices[e]=[])).push(n))}if(p===this.xmldoc.root)break;p=p.parentElement}}preparePageGroupPageIndicesForRerender(e,t){this.pageGroupPageCounts=Object.create(null),this.currentPageGroupDocument=null;for(let i=0;i<t;i++){let t=e[i]||null;this.updatePageGroupPageIndices(t)}}getFirstInFlowElementAtOrAfter(e,t){if(this.isPageBoundaryCandidateElement(e)&&this.xmldoc.getElementOffset(e)>=t)return e;let i=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let i=e;return this.isNormalFlowElement(i)?this.isInlineLevelElement(i)||this.xmldoc.getElementOffset(i)<t?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}}).firstChild();return null!=i?i:null}getDeepestFirstInFlowChildOffset(e){let t=e;for(;;){let e=this.getFirstInFlowChildElement(t);if(!e)return this.xmldoc.getElementOffset(t);t=e}}getFirstInFlowChildElement(e){let t=e.firstChild;for(;t;){if(t.nodeType===Node.TEXT_NODE){if(!Qs(t))return null;t=t.nextSibling;continue}if(t.nodeType!==Node.ELEMENT_NODE){t=t.nextSibling;continue}let e=t;if(this.isNormalFlowElement(e))return this.isInlineLevelElement(e)?null:e;t=t.nextSibling}return null}isPageBoundaryCandidateElement(e){return this.isNormalFlowElement(e)&&!this.isInlineLevelElement(e)}isNormalFlowElement(e){var t,i;let n=this.styler.getStyle(e,!1);if(this.getDisplayValue(e)===di.none)return!1;let r=null==(t=null==n?void 0:n.position)?void 0:t.evaluate(this.styler.context,"position"),o=r&&!yi(r)?r:di.static;if(fs(o)||ps(o))return!1;let s=null==(i=null==n?void 0:n.float)?void 0:i.evaluate(this.styler.context,"float");return(s&&!yi(s)?s:di.none)===di.none}isInlineLevelElement(e){return vs(this.getDisplayValue(e))}getDisplayValue(e){var t;let i=this.styler.getStyle(e,!1),n=null==(t=null==i?void 0:i.display)?void 0:t.evaluate(this.styler.context,"display");return n&&!yi(n)?n:di.inline}getPosition(e,t){if(!e)return 0;let i=Number.POSITIVE_INFINITY;for(let n in this.primaryFlows){let r=e.flowPositions[n];if(!t&&(!r||0==r.positions.length)&&this.currentLayoutPosition&&(this.styler.styleUntilFlowIsReached(n),r=this.currentLayoutPosition.flowPositions[n],e!=this.currentLayoutPosition&&r&&(r=r.clone(),e.flowPositions[n]=r)),r){let e=this.getConsumedOffset(r);e<i&&(i=e)}}return i}dumpLocation(e){R.debug("Location - page",this.currentLayoutPosition.page),R.debug(" current:",e),R.debug(" lookup:",this.lookupOffset);for(let e in this.currentLayoutPosition.flowPositions){let t=this.currentLayoutPosition.flowPositions[e];for(let i of t.positions)R.debug(" Chunk",`${e}:`,i.flowChunk.startOffset)}}matchPageSide(e){switch(e){case"left":case"right":case"recto":case"verso":return new Nt(this.style.pageScope,`${e}-page`).evaluate(this);default:return!0}}updateStartSide(e){for(let t in e.flowPositions){let i=e.flowPositions[t];if(i&&i.positions.length>0){let e=i.positions[0].flowChunk;if(this.getConsumedOffset(i)===e.startOffset){let e=i.positions[0].flowChunk.breakBefore,t=i.startBreakType;i.startBreakType=Ls(Os(t,e))}}}}selectPageMaster(e){var t;let i=this.currentLayoutPosition,n=this.getPosition(i);if(n==Number.POSITIVE_INFINITY&&this.hasActiveRootPageFloatLayoutContext()&&(n=null!=(t=i.highestSeenOffset)?t:this.styler.getReachedOffset()),n==Number.POSITIVE_INFINITY)return null;let r,o=this.rootPageBoxInstance.children;for(let t=0;t<o.length;t++){if(r=o[t],r.pageBox.pseudoName===Vv)continue;let s=1;r.pageBox.pseudoName===fv&&(!this.actualPageWidth||!this.actualPageHeight)&&(s=1/0);let a=r.getProp(this,"utilization");a&&a.isNum()&&(s=a.num);let l=this.queryUnitSize("em",!1),h=this.pageWidth()*this.pageHeight(),u=Math.ceil(s*h/(l*l)),c=this.styler.cascade.currentPageType;this.lookupOffset=this.styler.styleUntil(n,u),this.styler.cascade.currentPageType=c,this.updateStartSide(i),this.layoutPositionAtPageStart=i.clone(),this.initLingering(),this.clearScope(this.style.pageScope);let d=r.getProp(this,"enabled");if(!d||d===di._true){if(1===i.page&&this.blankPageAtStart){r.style={};let t=e.size;e={},t&&(e.size=t)}return this.pageManager.getPageRulePageMaster(r,e)}}throw new Error("No enabled page masters")}flowChunkIsAfterParentFlowForcedBreak(e){let t=this.layoutPositionAtPageStart.flows,i=t[e.flowName].parentFlowName;if(i){let n=e.startOffset,r=t[i].forcedBreakOffsets;if(!r.length||n<r[0])return!1;let o=Le(r.length,e=>r[e]>n)-1,s=r[o],a=this.layoutPositionAtPageStart.flowPositions[i],l=this.getConsumedOffset(a);return!(s<l)&&(l<s||!this.matchPageSide(a.startBreakType))}return!1}beginIsolatedRootPageFloatLayoutContext(e){let t=this.rootPageFloatLayoutContext;return this.rootPageFloatLayoutContext=Nl.createRoot(),e&&this.rootPageFloatLayoutContext.addPageFloatLayoutContextAsPreviousSibling(e),t}endIsolatedRootPageFloatLayoutContext(e){this.rootPageFloatLayoutContext=e}hasActiveRootPageFloatLayoutContext(){return this.rootPageFloatLayoutContext.getDeferredPageFloatContinuations().length>0||this.rootPageFloatLayoutContext.getPageFloatContinuationsDeferredToNext().length>0||this.rootPageFloatLayoutContext.getFloatsDeferredToNextInChildContexts().length>0}hasOnlyDeferredPageFloats(e){return this.noMorePrimaryFlows(e)&&this.hasActiveRootPageFloatLayoutContext()}layoutDeferredPageFloats(e){let t=e.pageFloatLayoutContext,i=t.getDeferredPageFloatContinuations(),n=this.counterStore.currentPageCountersStack.length>0,r=e=>{var t,i;if(!n||e.floatReference!==ml.PAGE)return!1;let r=(null==(i=null==(t=this.layoutPositionAtPageStart)?void 0:t.flowPositions)?void 0:i.body)||null,o=r?this.getConsumedOffset(r):Number.NaN,s=isFinite(o)?o:this.getPageStartOffset(this.layoutPositionAtPageStart,!0),a=this.xmldoc.getNodeOffset(e.nodePosition.steps[0].node,0,!1);return null!=a&&isFinite(s)&&a>s},o=oo("layoutDeferredPageFloats"),s=!1,a=0;return o.loopWithFrame(n=>{if(a===i.length)return void n.breakLoop();let o=i[a++],l=o.float;if(r(l))return void n.breakLoop();let h=(new Al).findByFloat(l),u=h.findPageFloatFragment(l,t);if(!u||!u.hasFloat(l))return t.isForbidden(l)||t.hasPrecedingFloatsDeferredToNext(l)?(t.deferPageFloat(o),void n.breakLoop()):void e.layoutPageFloatInner(o,h,null,u).then(e=>{if(!e)return void n.breakLoop();let i=t.parent.isInvalidated();i?n.breakLoop():(t.isInvalidated()&&!i&&(s=!0,t.validate()),n.continueLoop())});n.continueLoop()}).then(()=>{s&&t.invalidate(),o.finish(!0)}),o.result()}getLastAfterPositionIfDeferredFloatsExists(e,t){if(e.pageFloatLayoutContext.getPageFloatContinuationsDeferredToNext().length>0){if(e.lastAfterPosition){let i;return t?(i=t.clone(),i.primary=e.lastAfterPosition):i=new Ea(e.lastAfterPosition),i}return null}return null}flowRootFormattingContextFor(e){var t,i;return null!=(i=null==(t=this.currentLayoutPosition.flows[e])?void 0:t.formattingContext)?i:new oh(null)}layoutColumn(e,t){let i=this.currentLayoutPosition.flowPositions[t];if(!i||!this.matchPageSide(i.startBreakType))return i?this.layoutDeferredPageFloats(e):so(!0);this.primaryFlows[t]&&e.bands.length>0&&(e.forceNonfitting=!1);let n=oo("layoutColumn");return this.layoutDeferredPageFloats(e).then(()=>{if(e.pageFloatLayoutContext.isInvalidated())return void n.finish(!0);let r=[],o=[],s=!0;n.loopWithFrame(n=>{if(e.pageFloatLayoutContext.hasContinuingFloatFragmentsInFlow(t))n.breakLoop();else{for(;i.positions.length-o.length>0;){let t=0;for(;o.includes(t);)t++;let a=i.positions[t];if(a.flowChunk.startOffset>this.lookupOffset||this.flowChunkIsAfterParentFlowForcedBreak(a.flowChunk))break;for(let e=t+1;e<i.positions.length;e++){if(o.includes(e))continue;let n=i.positions[e];if(n.flowChunk.startOffset>this.lookupOffset||this.flowChunkIsAfterParentFlowForcedBreak(n.flowChunk))break;n.flowChunk.isBetter(a.flowChunk)&&(a=n,t=e)}let l=a.flowChunk,h=!0;if(e.layout(a.chunkPosition,s,i.breakAfter).then(u=>{if(e.pageFloatLayoutContext.isInvalidated())n.breakLoop();else{if(s=!1,a.flowChunk.repeated&&(null===u||l.exclusive)&&r.push(t),l.exclusive)return o.push(t),void n.breakLoop();{let s=!!u||!!e.pageBreakType,l=this.getLastAfterPositionIfDeferredFloatsExists(e,u);if(!u&&e.pageBreakType&&i.positions.length-o.length-1<=0&&(e.pageBreakType=null),e.pageBreakType&&l?(a.chunkPosition=l,i.breakAfter=e.pageBreakType,e.pageBreakType=null):(o.push(t),(u||l)&&(a.chunkPosition=u||l,r.push(t)),i.startBreakType=Ls(e.pageBreakType)),s)return void n.breakLoop()}e.forceNonfitting=!1,h?h=!1:n.continueLoop()}}),h)return void(h=!1)}n.breakLoop()}}).then(()=>{var t;if(!e.pageFloatLayoutContext.isInvalidated()){i.positions=i.positions.filter((e,t)=>r.includes(t)||!o.includes(t)),"column"===i.breakAfter&&(i.breakAfter=null),e.saveDistanceToBlockEndFloats();let n=e.pageFloatLayoutContext.getMaxReachedAfterEdge();if(e.updateMaxReachedAfterEdge(n),0===e.computedBlockSize){let i=e.pageFloatLayoutContext,n=i;for(;n;){let e=n.floatFragments.filter(e=>"isFootnote"in e.area&&e.area.isFootnote);if(e.length>0&&!n.ignoreFootnoteAreaMaxHeight&&e.some(e=>{let t=getComputedStyle(e.area.element),i=e=>""!==e&&"none"!==e;return i(t.getPropertyValue("max-block-size"))||i(e.area.vertical?t.maxWidth:t.maxHeight)})){n.ignoreFootnoteAreaMaxHeight=!0;for(let r of e){i.removePageFloatFragment(r,!0);let e=null==(t=r.continuations[0])?void 0:t.float;e&&n.removeFloatDeferredToNext(e)}i.invalidate();break}n=n.parent}}}n.finish(!0)})}),n.result()}createLayoutConstraint(e){let t=this.currentLayoutPosition.page-1,i=this.counterStore.createLayoutConstraint(t);return new fg([i].concat(e.getLayoutConstraints()))}createAndLayoutColumn(e,t,i,n,r,o,s,a,l,h,u,c,d,p){let f,g=e.vertical?e.isAutoWidth&&e.isRightDependentOnAutoWidth||e.isAutoHeight:e.isAutoHeight&&e.isTopDependentOnAutoHeight||e.isAutoWidth,m=r.element,v=kl.create(a,ml.COLUMN,s,null,null,null),y=this.currentLayoutPosition.clone(),b=oo("createAndLayoutColumn");return b.loopWithFrame(e=>{let b=this.createLayoutConstraint(v);if(l>1){let e,a,y,w,x=this.viewport.document.createElement("div");if(be(x,"position","absolute"),m.appendChild(x),r.vertical){let t=(r.rtl?l-o-1:o)*(u+h)+r.paddingTop,i=parseFloat(m.style.width);e=r.paddingLeft+i-r.width,y=r.width,a=t,w=u}else e=(r.rtl?l-o-1:o)*(u+h)+r.paddingLeft,y=u,a=r.paddingTop,w=r.height;be(x,"left",`${e}px`),be(x,"top",`${a}px`),f=new mg(x,d,this.clientLayout,b,v,{vertical:r.vertical,rtl:r.rtl,snapWidth:r.snapWidth,snapHeight:r.snapHeight,originX:t,originY:i,left:e,top:a,width:y,height:w,marginLeft:0,marginRight:0,marginTop:0,marginBottom:0,borderLeft:0,borderRight:0,borderTop:0,borderBottom:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,borderBoxSizing:!1},c,g?[]:n.concat(),this.flowRootFormattingContextFor(s)),f.isNonFirstColumn=o>0,f.forceNonfitting=p}else f=new mg(m,d,this.clientLayout,b,v,r,c,g?[]:n.concat(),this.flowRootFormattingContextFor(s)),f.isNonFirstColumn=!1;if((f.vertical?f.height:f.width)>=0){let t=f.pageFloatLayoutContext;this.layoutColumn(f,s).then(()=>{t.isInvalidated()||t.finish(),f.pageFloatLayoutContext.isInvalidated()&&!a.isInvalidated()?(f.pageFloatLayoutContext.validate(),this.currentLayoutPosition=y.clone(),f.element!==m&&m.removeChild(f.element),e.continueLoop()):e.breakLoop()})}else f.pageFloatLayoutContext.finish(),e.breakLoop()}).then(()=>{b.finish(f)}),b.result()}getRegionPageFloatLayoutContext(e,t,i,n){let r=t.getProp(this,"writing-mode")||null,o=t.getProp(this,"direction")||null;return kl.createWithContainer(i,e,ml.REGION,n,null,r,o)}layoutFlowColumnsWithBalancing(e,t,i,n,r,o,s,a,l){let h=this.currentLayoutPosition.clone(),u=this.getRegionPageFloatLayoutContext(o,t,s,a),c=!0,d=()=>(this.currentLayoutPosition=h.clone(),this.layoutFlowColumns(e,t,i,n,r,o,u,s,a,l,c).thenAsync(e=>so(e?{columns:e,position:this.currentLayoutPosition}:null)));return d().thenAsync(e=>{if(!e)return so(null);if(l<=1)return so(e.columns);let i=t.getProp(this,"column-fill")||di.balance,n=this.currentLayoutPosition.flowPositions[a],r=function(e,t,i,n,r,o,s){if(t===di.auto)return null;{let a=0===s.positions.length,l=o[o.length-1],h=!(!l||!l.pageBreakType);return a||h?new fm(i,n,r,e):t===di.balance_all?new mm(i,n,r):null}}(l,i,d,u,s,e.columns,n);return r?(c=!1,o.lock(),u.lock(),r.balanceColumns(e).thenAsync(e=>(o.unlock(),o.validate(),u.unlock(),this.currentLayoutPosition=e.position,so(e.columns)))):so(e.columns)})}layoutFlowColumns(e,t,i,n,r,o,s,a,l,h,u){let c=oo("layoutFlowColumns"),d=this.currentLayoutPosition.clone(),p=Sy(this.currentLayoutPosition),f=t.getPropAsNumber(this,"column-gap"),g=h>1?t.getPropAsNumber(this,"column-width"):a.vertical?a.height:a.width,m=t.getActiveRegions(this),v=An(t.getProp(this,"shape-inside"),0,0,a.width,a.height,this),y=new jm(l,this,this.viewport,this.styler,m,this.xmldoc,this.faces,this.style.footnoteProps,this,e,this.customRenderer,this.fallbackMap,this.documentURLTransformer,this.style.pageProps,this.currentCascadedPageStyle,this.semanticFootnoteFirstRefOffsets,this.semanticFootnoteFirstRefOffsetsInitialized),b=0,w=null,x=[];return c.loopWithFrame(e=>{this.createAndLayoutColumn(t,i,n,r,a,b++,l,s,h,f,g,v,y,u).then(t=>o.isInvalidated()?(x=null,void e.breakLoop()):((t.pageBreakType&&"column"!==t.pageBreakType||b===h)&&!s.isInvalidated()&&s.finish(),s.isInvalidated()?(b=0,this.currentLayoutPosition=d.clone(),Cy(p),s.validate(),void(s.isLocked()?(x=null,e.breakLoop()):e.continueLoop())):(w=t,x[b-1]=w,w.pageBreakType&&"column"!=w.pageBreakType&&(b=h,"region"!=w.pageBreakType&&(this.pageBreaks[l]=!0)),void(b<h?e.continueLoop():e.breakLoop()))))}).then(()=>{c.finish(x)}),c.result()}openPageBox(e,t,i,n,r,o){let s=t.getProp(this,"wrap-flow")===di.auto,a=t.getProp(this,"flow-from"),l=this.viewport.document.createElement("div");l.role=t instanceof Qv?"complementary":"presentation";let h=t.getProp(this,"position");be(l,"position",h?h.name:"absolute");let u=t instanceof qv;t instanceof bv?i.appendChild(l):i.insertBefore(l,i.firstChild);let c=new Fa(l);return c.vertical=t.vertical,c.rtl=t.rtl,c.borderBoxSizing=t.borderBoxSizing,c.exclusions=o,t.prepareContainer(this,c,e,this.faces,this.clientLayout),(c.width<=0||c.height<=0)&&(t instanceof qv||a&&a.isIdent())&&(this.invalidPageAreaOnCurrentPage=!0,R.warn("Negative or zero page area size")),c.originX=n,c.originY=r,{boxContainer:l,container:c,offsetX:n+c.left+c.marginLeft+c.borderLeft,offsetY:r+c.top+c.marginTop+c.borderTop,flowName:a,dontExclude:s,forwardOrderInLayout:u,removed:!1}}layoutGeneratedContent(e,t,i,n){let r=i.boxContainer,o=[],s=t.getProp(this,"content");if(s instanceof li&&s.expr instanceof It&&s.expr.str.startsWith("running-element-"))s.visit(new Ra(r,this,s,this.counterStore.getExprContentListener()));else if(Oa(s)){let n="span";s instanceof ii&&(n="img");let a=this.viewport.document.createElement(n);s.visit(new Ra(a,this,s,this.counterStore.getExprContentListener())),r.appendChild(a),"img"==n&&t.transferSingleUriContentProps(this,a,this.faces),t.transferContentProps(this,i.container,e,this.faces);let l=a.querySelectorAll("img[src]");for(let t=0;t<l.length;t++){let i=l[t],n=i.getAttribute("src");if(!n)continue;let r=Oo(i,n);o.push(r),e.fetchers.push(r)}let h=a.getAttribute("src");if(h){let t=a.querySelector("img");t||(t=a);let i=Oo(t,h);o.push(i),e.fetchers.push(i)}"span"==n&&function(e,t,i,n,r,o){tg.processGeneratedContent(e,t,i,n,r,o)}(a,t.getProp(this,"text-autospace"),t.getProp(this,"text-spacing-trim"),t.getProp(this,"hanging-punctuation"),this.lang,t.vertical)}else t.suppressEmptyBoxGeneration&&(n.removeChild(r),i.removed=!0);return i.removed||t.finishContainer(this,i.container,e,null,1,this.clientLayout,this.faces),o.length?bo(o).thenReturn(!0):so(!0)}layoutPageBoxContent(e,t,i,n,r,o){let s=i.boxContainer,a=i.flowName;if(!a||!a.isIdent())return this.layoutGeneratedContent(e,t,i,n);if(!this.pageBreaks[a.toString()]){let n=oo("layoutPageBoxContent.inner"),l=a.toString(),h=t.getPropAsNumber(this,"column-count");return this.layoutFlowColumnsWithBalancing(e,t,i.offsetX,i.offsetY,r,o,i.container,l,h).then(r=>{if(!o.isInvalidated()){let n=r[0];n.element===s&&(i.container=n),i.container.computedBlockSize=Math.max.apply(null,r.map(e=>e.computedBlockSize)),t.finishContainer(this,i.container,e,n,h,this.clientLayout,this.faces);let o=this.currentLayoutPosition.flowPositions[l];o&&"region"===o.breakAfter&&(o.breakAfter=null)}n.finish(!0)}),n.result()}return o.isInvalidated()||t.finishContainer(this,i.container,e,null,1,this.clientLayout,this.faces),so(!0)}excludeOrRemovePageBox(e,t,i,n){if(!e.isAutoHeight||Math.floor(t.container.computedBlockSize)>0){if(!t.removed&&!t.dontExclude){let i=e.getProp(this,"shape-outside"),r=t.container.getOuterShape(i,this);n.push(r)}}else if(0==e.children.length)return i.removeChild(t.boxContainer),!1;return!0}layoutPageBoxChildren(e,t,i,n,r,o=null){let s=oo("layoutPageBoxChildren"),a=i.forwardOrderInLayout,l=a?0:t.children.length-1;return s.loop(()=>{for(;l>=0&&l<t.children.length;){let s=t.children[a?l++:l--];if(s===o)continue;let h=this.layoutContainer(e,s,i.boxContainer,i.offsetX,i.offsetY,n,r);if(h.isPending())return h.thenAsync(()=>so(!r.isInvalidated()));if(r.isInvalidated())break}return so(!1)}).then(()=>{s.finish(!0)}),s.result()}layoutPageAreaEstablishingContainer(e,t,i,n,r,o,s){t.reset();let a=oo("layoutPageAreaEstablishingContainer"),l=this.openPageBox(e,t,i,n,r,o),h=t.pageAreaEstablishingChild;if(null===h){let n=s.withContainer(l.container);return this.layoutPageBoxContent(e,t,l,i,o,n).then(()=>{!n.isInvalidated()&&this.excludeOrRemovePageBox(t,l,i,o)?this.layoutPageBoxChildren(e,t,l,o,n).then(()=>{a.finish(n)}):a.finish(n)}),a.result()}return this.layoutGeneratedContent(e,t,l,i).then(()=>{this.excludeOrRemovePageBox(t,l,i,o),this.layoutPageAreaEstablishingContainer(e,h,l.boxContainer,l.offsetX,l.offsetY,o,s).then(i=>{i.isInvalidated()?a.finish(i):this.layoutPageBoxChildren(e,t,l,o,i,h).then(()=>{a.finish(i)})})}),a.result()}layoutContainer(e,t,i,n,r,o,s){t.reset();let a=t.getProp(this,"enabled");if(a&&a!==di._true)return so(!0);let l=oo("layoutContainer"),h=this.openPageBox(e,t,i,n,r,o);return this.layoutPageBoxContent(e,t,h,i,o,s).then(()=>{s.isInvalidated()?l.finish(!0):this.excludeOrRemovePageBox(t,h,i,o)?this.layoutPageBoxChildren(e,t,h,o,s).then(()=>{l.finish(!0)}):l.finish(!0)}),l.result()}processLinger(){let e=this.currentLayoutPosition.page;for(let t in this.currentLayoutPosition.flowPositions){let i=this.currentLayoutPosition.flowPositions[t];for(let t=i.positions.length-1;t>=0;t--){let n=i.positions[t];n.flowChunk.startPage>=0&&n.flowChunk.startPage+n.flowChunk.linger-1<=e&&i.positions.splice(t,1)}}}initLingering(){let e=this.currentLayoutPosition.page;for(let t in this.currentLayoutPosition.flowPositions){let i=this.currentLayoutPosition.flowPositions[t];for(let t=i.positions.length-1;t>=0;t--){let n=i.positions[t];n.flowChunk.startPage<0&&n.flowChunk.startOffset<this.lookupOffset&&(n.flowChunk.startPage=e)}}}noMorePrimaryFlows(e){for(let t in this.primaryFlows){let i=e.flowPositions[t];if(i&&i.positions.length>0)return!1}return!0}hasSameFlowPositions(e,t){if(e===t)return!0;if(!e||!t)return!1;let i=Object.keys(e.flowPositions),n=Object.keys(t.flowPositions);if(i.length!==n.length)return!1;for(let n of i)if(!e.flowPositions[n].isSamePosition(t.flowPositions[n]))return!1;return!0}checkRepeatedInvalidPageArea(e){let t=this.invalidPageAreaOnCurrentPage;if(this.invalidPageAreaOnCurrentPage=!1,!t)return void(this.repeatedInvalidPageAreaLayoutPosition=null);if(e.isBlankPage||this.noMorePrimaryFlows(e))return;if(!this.hasSameFlowPositions(this.layoutPositionAtPageStart,e))return void(this.repeatedInvalidPageAreaLayoutPosition=null);let i=!!this.repeatedInvalidPageAreaLayoutPosition&&this.hasSameFlowPositions(this.repeatedInvalidPageAreaLayoutPosition,this.layoutPositionAtPageStart);if(this.repeatedInvalidPageAreaLayoutPosition=this.layoutPositionAtPageStart.clone(),i)throw new Error("Negative or zero page area size")}layoutNextPage(e,t){var i,n,r,o;let s=e.container===e.bleedBox;this.pageBreaks={},t?(this.currentLayoutPosition=t.clone(),this.styler.replayFlowElementsFromOffset(t.highestSeenOffset)):(this.currentLayoutPosition=new Ia,this.styler.replayFlowElementsFromOffset(-1)),this.lang&&e.bleedBox.setAttribute("lang",this.lang),this.invalidPageAreaOnCurrentPage=!1;let a=(t=this.currentLayoutPosition).startSideOfFlow("body");t.isBlankPage=Is(a)&&this.matchPageSide(a),e.isBlankPage=t.isBlankPage,t.page++;let l=this.hasOnlyDeferredPageFloats(t),h=l?void 0:this.getPageStartPageTypeOverride(t);if(""===h?e.pageType="":h&&(e.pageType=h),null==e.pageType){let r=1===t.page?this.resolveFirstPageType():null,o=null!=(i=this.styler.cascade.currentPageType)?i:this.styler.cascade.previousPageType,s=e.isBlankPage?this.styler.cascade.previousPageType:l?o:null!=r?r:this.styler.cascade.currentPageType;if(e.pageType=s,!e.pageType){let i=this.getPageStartPageType(t);i&&(e.pageType=i)}e.pageType=null!=(n=e.pageType)?n:"",this.styler.cascade.previousPageType=this.styler.cascade.currentPageType}this.updatePageGroupPageIndices(t),this.clearScope(this.style.pageScope),this.layoutPositionAtPageStart=t.clone();let u=Sy(t),c=s?{}:this.pageManager.getCascadedPageStyle(e.pageType);if(this.currentCascadedPageStyle=c,this.styler.cascade.applyVarFilter([c],null),Rd(c,!0)&&this.styler.cascade.applyVarFilter([c],null),this.styler.cascade.applyCalcFilter(c,this.styler.context),this.styler.cascade.applyCmykFilter(c),!s){let t=new Nt(this.style.pageScope,"left-page");e.side=t.evaluate(this)?"left":"right",e.container.setAttribute("data-vivliostyle-page-side",e.side)}let d=this.selectPageMaster(c);if(!d)return so(null);let p=0;if(!s){e.setAutoPageWidth(d.pageBox.specified.width.value===fi),e.setAutoPageHeight(d.pageBox.specified.height.value===gi);let{counterOffset:t,changeOffset:i}=this.getPageStartCounterOffsets(this.layoutPositionAtPageStart);isFinite(t)||(t=this.lookupOffset,i=this.lookupOffset),isFinite(t)&&this.styler.styleUntil(t,0);let n=this.styler.getCounterSnapshotAtOffset(t),s=i===t?n:this.styler.getCounterSnapshotAtOffset(i);n||(n=this.styler.getLastCounterSnapshot()),s||(s=n);let a=s&&s.offset===i?s:null;this.counterStore.setCurrentPageDocCounters(null!=(r=null==n?void 0:n.counters)?r:null,null!=(o=null==a?void 0:a.changes)?o:null,null==a?void 0:a.changeTypes),this.counterStore.setCurrentPage(e),this.counterStore.updatePageCounters(c,this);let l=Av(Iv(c),this);this.setPageSizeAndBleed(l,e),_v(c,l,e,this),p=l.bleedOffset+l.bleed}let f=!s&&d.getProp(this,"writing-mode")||di.horizontal_tb;this.pageVertical=f!=di.horizontal_tb;let g=d.getProp(this,"direction")||di.ltr,m=kl.create(this.rootPageFloatLayoutContext,ml.PAGE,null,null,f,g,null,e.side),v=oo("layoutNextPage"),y=null;return v.loopWithFrame(t=>{this.layoutPageAreaEstablishingContainer(e,d,e.bleedBox,p,p,[],m).then(i=>{if(y=i,m.isInvalidated()||i.finish(),m.isInvalidated()){for(this.currentLayoutPosition=this.layoutPositionAtPageStart.clone(),Cy(u),m.validate();e.bleedBox.lastChild;)e.bleedBox.removeChild(e.bleedBox.lastChild);t.continueLoop()}else t.breakLoop()})}).then(()=>{e.pageFloatLayoutContext=y,d.adjustPageLayout(this,e,this.clientLayout),s||(this.processLinger(),t=this.currentLayoutPosition,this.checkRepeatedInvalidPageArea(t),Object.keys(t.flowPositions).forEach(e=>{let i=t.flowPositions[e],n=i.breakAfter;n&&("page"===n||!this.matchPageSide(n))&&(i.breakAfter=null)})),this.currentLayoutPosition=this.layoutPositionAtPageStart=null,t.highestSeenOffset=this.styler.getReachedOffset();let i=this.style.store.getTriggersForDoc(this.xmldoc);e.finish(i,this.clientLayout),this.noMorePrimaryFlows(t)&&!this.hasActiveRootPageFloatLayoutContext()&&(t=null),v.finish(t)}),v.result()}setPageSizeAndBleed(e,t){this.actualPageWidth=e.pageWidth,this.actualPageHeight=e.pageHeight,this.pageSheetWidth=e.pageWidth+2*e.cropOffset,this.pageSheetHeight=e.pageHeight+2*e.cropOffset,t.container.style.width=`${this.pageSheetWidth}px`,t.container.style.height=`${this.pageSheetHeight}px`,t.bleedBox.style.left=`${e.bleedOffset}px`,t.bleedBox.style.right=`${e.bleedOffset}px`,t.bleedBox.style.top=`${e.bleedOffset}px`,t.bleedBox.style.bottom=`${e.bleedOffset}px`,t.bleedBox.style.padding=`${e.bleed}px`}},Py=class e extends gf{constructor(e,t,i,n,r,o,s,a){super(i,t,r,o,s,n,a),h(this,"masterHandler",e),h(this,"insideRegion",!1)}startPageTemplateRule(){}startPageMasterRule(e,t,i){let n=new Qm(this.masterHandler.pageScope,e,t,i,this.masterHandler.rootBox,this.condition,this.owner.getBaseSpecificity(),this.layer);this.owner.delegateTo(e=>new Cv(n.scope,this.owner,n,this.validatorSet,e))}startWhenRule(t){let i=t.expr;null!=this.condition&&(i=Bt(this.scope,this.condition,i)),this.owner.delegateTo(t=>new e(this.masterHandler,this.owner,this.scope,this.validatorSet,i,this,this.regionId,t))}startLayerRule(t){let i=this.cascade.registerLayer(this.flavor,this.layer,t);this.owner.delegateTo(t=>{let n=new e(this.masterHandler,this.owner,this.scope,this.validatorSet,this.condition,this,this.regionId,t);return n.layer=i,n})}startDefineRule(){this.owner.delegateTo(e=>new Pf(this.scope,this.owner,e))}startFontFaceRule(){let e={};this.masterHandler.fontFaces.push({properties:e,condition:this.condition,priority:this.getBaseSpecificity(),layer:this.layer}),this.owner.delegateTo(t=>new Ef(this.scope,this.owner,null,e,this.masterHandler.validatorSet,t,"font-face",this.layer))}startCounterStyleRule(e){this.owner.delegateTo(t=>new wy(this.scope,this.owner,{},this.masterHandler.validatorSet,e,this.masterHandler.counterStyles,t,this.layer))}startFlowRule(e){let t=this.masterHandler.flowProps[e];t||(t={},this.masterHandler.flowProps[e]=t),this.owner.delegateTo(e=>new Ef(this.scope,this.owner,null,t,this.masterHandler.validatorSet,e,void 0,this.layer))}startViewportRule(){let e={};this.masterHandler.viewportProps.push(e),this.owner.delegateTo(t=>new Ef(this.scope,this.owner,this.condition,e,this.masterHandler.validatorSet,t,void 0,this.layer))}startFootnoteRule(e){let t=this.masterHandler.footnoteProps;if(e){let i=Wd(t,"_pseudos");t=i[e],t||(t={},i[e]=t)}this.owner.delegateTo(e=>new py(this.scope,this.owner,this.masterHandler.validatorSet,t,e,this.layer))}startRegionRule(){this.insideRegion=!0,this.startSelectorRule()}startPageRule(){this.owner.delegateTo(e=>new cy(this.masterHandler.pageScope,this.owner,this,this.validatorSet,this.masterHandler.pageProps,e)).startPageRule()}startRuleBody(){if(gf.prototype.startRuleBody.call(this),this.insideRegion){this.insideRegion=!1;let t="R"+this.masterHandler.regionCount++;this.special("region-id",Zt(t)),this.endRule(),this.owner.delegateTo(i=>new e(this.masterHandler,this.owner,this.scope,this.validatorSet,this.condition,this,t,i)).startRuleBody()}}},Ey=class extends zo{constructor(e){let t=new Xe(null);super(t,i=>new Py(i,i,t,e,null,null,null,null)),h(this,"validatorSet",e),h(this,"rootScope"),h(this,"pageScope"),h(this,"rootBox"),h(this,"cascadeParserHandler"),h(this,"regionCount",0),h(this,"fontFaces",[]),h(this,"counterStyles",new Ju),h(this,"footnoteProps",{}),h(this,"flowProps",{}),h(this,"viewportProps",[]),h(this,"pageProps",{}),this.rootScope=t,this.pageScope=new Xe(this.rootScope),this.rootBox=new Zm(this.rootScope),this.cascadeParserHandler=this.initialSlave}};function Ny(e,t){return null!=e.text?{url:e.url?ue(pe(e.url),oe):e.url,text:e.text,flavor:t,classes:null,media:null}:{url:e.url?ue(pe(e.url),oe):e.url,flavor:t,classes:null,media:null}}function Ty(e,t){return t.parseOPSResource(e)}var Iy=class extends Fo{constructor(e,t=null,i=null){super(Ty,"document"),h(this,"fontDeobfuscator",e),h(this,"styleByKey",{}),h(this,"styleFetcherByKey",{}),h(this,"styleByDocURL",{}),h(this,"triggersByDocURL",{}),h(this,"validatorSet",function(){let e=new Wc;return e.initBuiltInValidators(),e.parse(So),e}()),h(this,"styleSheets",[]),h(this,"triggerSingleDocumentPreprocessing",!1),this.setStyleSheets(t,i)}getStyleForDoc(e){return this.styleByDocURL[e.url]}getTriggersForDoc(e){return this.triggersByDocURL[e.url]}setStyleSheets(e,t){this.clearStyleSheets(),e&&e.forEach(this.addAuthorStyleSheet,this),t&&t.forEach(this.addUserStyleSheet,this)}clearStyleSheets(){this.styleSheets.splice(0)}addAuthorStyleSheet(e){this.styleSheets.push(Ny(e,"Author"))}addUserStyleSheet(e){this.styleSheets.push(Ny(e,"User"))}parseOPSResource(e){let t=oo("OPSDocStore.load"),i=e.url,n=ie(i);return vy(e,this).then(e=>{var r;if(!e)return void t.finish(null);if(this.triggerSingleDocumentPreprocessing){let t=M("PREPROCESS_SINGLE_DOCUMENT");for(let i=0;i<t.length;i++)try{t[i](e.document)}catch(e){R.warn("Error during single document preprocessing:",e)}}let o=[],s=e.document.getElementsByTagNameNS("http://www.idpf.org/2007/ops","trigger");for(let e=0;e<s.length;e++){let t=s[e],i=t.getAttributeNS("http://www.w3.org/2001/xml-events","observer"),n=t.getAttributeNS("http://www.w3.org/2001/xml-events","event"),r=t.getAttribute("action"),a=t.getAttribute("ref");i&&n&&r&&a&&o.push({observer:i,event:n,action:r,ref:a})}this.triggersByDocURL[i]=o;let a=[];if(a.push({url:ue("user-agent-base.css",ae),text:Po,flavor:"UA",classes:null,media:null}),a.push({url:ue("user-agent-page.css",ae),text:ko,flavor:"UA",classes:null,media:null}),a.push({url:ue("user-agent-counter-styles.css",ae),text:To,flavor:"UA",classes:null,media:null}),n)a.push({url:ue("user-agent-toc.css",ae),text:Eo,flavor:"UA",classes:null,media:null});else{let t=e.document.querySelectorAll("style, link, meta");for(let e of t){let t=e.namespaceURI,n=e.localName;if("http://www.w3.org/1999/xhtml"==t)if("style"==n){let t=e.getAttribute("class"),n=e.getAttribute("media"),r=e.getAttribute("title");a.push({url:i,text:e.textContent,flavor:"Author",classes:r?t:null,media:n})}else if("link"==n){let t=e.getAttribute("href"),n=null==(r=e.getAttribute("rel"))?void 0:r.split(/\s+/),o=e.getAttribute("class"),s=e.getAttribute("media");if(t&&null!=n&&n.includes("stylesheet")&&(!n.includes("alternate")||o)){let n=ue(t,i),r=e.getAttribute("title");a.push({url:n,text:null,classes:r?o:null,media:s,flavor:"Author"})}}else"meta"==n&&"viewport"==e.getAttribute("name")&&a.push({url:i,text:this.processViewportMeta(e),flavor:"Author",classes:null,media:null})}for(let e=0;e<this.styleSheets.length;e++)a.push(this.styleSheets[e])}let l="";for(let e=0;e<a.length;e++)l+=a[e].url,l+="^",a[e].text&&(l+=a[e].text),l+="^";let h=this.styleByKey[l];if(h)return this.styleByDocURL[i]=h,void t.finish(e);let u=this.styleFetcherByKey[l];u||(u=new yo(()=>{let e=oo("fetchStylesheet"),t=0,i=new Ey(this.validatorSet);return e.loop(()=>{if(t<a.length){let e=a[t++];return i.startStylesheet(e.flavor),null!=e.text?ss(e.text,i,e.url,e.classes,e.media).thenReturn(!0):as(e.url,i,e.classes,e.media)}return so(!1)}).then(()=>{let t=i.cascadeParserHandler.finish();h=new xy(this,i.rootScope,i.pageScope,t,i.rootBox,function(e){return[...e].sort(Sd)}(i.fontFaces),i.footnoteProps,i.flowProps,i.viewportProps,i.pageProps,i.counterStyles),this.styleByKey[l]=h,delete this.styleFetcherByKey[l],e.finish(h)}),e.result()},`FetchStylesheet ${i}`),this.styleFetcherByKey[l]=u,u.start()),u.get().then(n=>{this.styleByDocURL[i]=n,t.finish(e)})}),t.result()}processViewportMeta(e){return""}},Ay="▸";function Fy(e){let t=Array.from(e.querySelectorAll("nav[*|type],nav[epub\\:type]"));if(t.length>0||(t=Array.from(e.querySelectorAll("[role=doc-toc]")),t.length>0))return t;for(let i of e.querySelectorAll("nav,.toc,#toc,#table-of-contents,#contents,[role=directory]")){if(t.find(e=>e.contains(i)))continue;let e=i;/^h[1-6]$/.test(e.localName)&&(e=e.previousElementSibling?e.nextElementSibling:e.parentElement),e&&e.querySelector("li a[href]")&&t.push(e)}return t}var Ry=class{constructor(e,t,i,n,r,o,s,a,l,u,c){h(this,"store",e),h(this,"url",t),h(this,"lang",i),h(this,"clientLayout",n),h(this,"fontMapper",r),h(this,"rendererFactory",s),h(this,"fallbackMap",a),h(this,"documentURLTransformer",l),h(this,"counterStore",u),h(this,"cmykStore",c),h(this,"pref"),h(this,"page",null),h(this,"instance",null),this.pref=Ve(o),this.pref.spreadView=!1}setAutoHeight(e,t){if(0!=t--)for(let i=e.firstChild;i;i=i.nextSibling)if(1==i.nodeType){let e=i;"auto"!=we(e,"height","auto")&&(be(e,"height","auto"),this.setAutoHeight(e,t)),"absolute"==we(e,"position","static")&&(be(e,"position","relative"),this.setAutoHeight(e,t))}}makeCustomRenderer(e){let t=this.rendererFactory.makeCustomRenderer(e);return(e,i,n)=>{let r=n.behavior;if(r)switch(r.toString()){case"toc-node-anchor":n.color=di.inherit,n["text-decoration"]=di.none;break;case"toc-node":n.display=di.block,n.margin=mi,n.padding=mi,n["padding-inline-start"]=new Jt(1.25,"em");break;case"toc-node-first-child":n.display=di.inline_block,n.margin=new Jt(.2,"em"),n["vertical-align"]=di.top,n.color=di.inherit,n["text-decoration"]=di.none;break;case"toc-container":n.padding=mi}if(!r||"toc-node"!=r.toString()&&"toc-container"!=r.toString())return t(e,i,n);let o=e.firstChild;o&&1!==o.nodeType&&Qs(o)&&e.replaceChild(e.ownerDocument.createComment(o.textContent),o);let s=i.getAttribute("data-adapt-class");if("toc-node"==s){let e=i.firstChild;e.textContent!=Ay&&(e.textContent=Ay,be(e,"cursor","pointer"),e.addEventListener("click",Oy,!1),e.setAttribute("role","button"),e.setAttribute("aria-expanded","false"),i.setAttribute("aria-expanded","false"),"0px"!==i.style.height&&(e.tabIndex=0))}let a=i.ownerDocument.createElement("div");if(a.setAttribute("data-adapt-process-children","true"),"toc-node"==r.toString()){let t=i.ownerDocument.createElement("div");if(t.textContent="▹",be(t,"margin","0.2em 0 0 -1em"),be(t,"margin-inline-start","-1em"),be(t,"margin-inline-end","0"),be(t,"display","inline-block"),be(t,"width","1em"),be(t,"text-align","center"),be(t,"vertical-align","top"),be(t,"cursor","default"),be(t,"font-family","Menlo,sans-serif"),a.appendChild(t),be(a,"overflow","hidden"),a.setAttribute("data-adapt-class","toc-node"),a.setAttribute("role","treeitem"),"toc-node"==s||"toc-container"==s){be(a,"height","0px");let t=e.firstElementChild;t&&"a"===t.localName&&(t.tabIndex=-1)}else i.setAttribute("role","tree")}else"toc-node"==s&&(a.setAttribute("data-adapt-class","toc-container"),a.setAttribute("role","group"),a.setAttribute("aria-hidden","true"));return so(a)}}showTOC(e,t,i,n,r){if(this.page)return so(this.page);let o=oo("showTOC"),s=new Ks(e,e);this.page=s;let a=re(this.url);return this.store.load(a).then(n=>{for(let e of Fy(n.document))e.setAttribute("data-vivliostyle-role","doc-toc");let a=this.store.getStyleForDoc(n),l=a.sizeViewport(i,1e5,r);t=new qm(t.window,l.fontSize,0,e,l.width,l.height);let h=this.makeCustomRenderer(n);ky.create(a,n,this.lang,t,this.clientLayout,this.fontMapper,h,this.fallbackMap,0,this.documentURLTransformer,this.counterStore,this.cmykStore,this.pref,null,null).then(t=>{this.instance=t,t.layoutNextPage(s,null).then(()=>{this.setAutoHeight(e,2),o.finish(s)})})}),o.result()}hideTOC(){this.page&&(this.page.container.style.visibility="hidden",this.page.container.setAttribute("aria-hidden","true"))}isTOCVisible(){return!!this.page&&"visible"===this.page.container.style.visibility}getTOC(){if(!this.page)return[];function e(e){if(!e)return[];let i=e.querySelectorAll(":scope > [role=treeitem] > a[href]");return Array.from(i).map(t)}function t(t){let i=new URL(t.href),[,n]=i.hash.match(/^#?(.*)$/);return{id:n,title:t.innerText,children:e(t.parentElement.querySelector("[role=group]"))}}return e(this.page.container.querySelector("[role=tree]"))}};function Oy(e){let t=e.target,i=t.textContent==Ay;t.textContent=i?"▾":Ay;let n=t.parentNode;t.setAttribute("aria-expanded",i?"true":"false"),n.setAttribute("aria-expanded",i?"true":"false");let r=n.firstChild;for(;r;){if(1===r.nodeType){let e=r,t=e.getAttribute("data-adapt-class");if("toc-container"===t){if(e.setAttribute("aria-hidden",i?"false":"true"),e.firstChild){r=e.firstChild;continue}}else if("toc-node"===t&&(e.style.height=i?"auto":"0px",e.children.length>=2&&(e.children[1].tabIndex=i?0:-1),e.children.length>=3&&(e.children[0].tabIndex=i?0:-1,!i))){let t=e.children[0];if("▾"==t.textContent){t.textContent=Ay,t.setAttribute("aria-expanded","false"),e.setAttribute("aria-expanded","false"),r=e.children[2];continue}}}for(;!r.nextSibling&&r.parentNode!==n;)r=r.parentNode;r=r.nextSibling}e.stopPropagation()}function Ly(e){let t={};return Object.keys(e).forEach(i=>{t[i]=Array.from(e[i])}),t}function _y(e){return e.split("/").map(encodeURIComponent).join("/")}var By=class e extends Iy{constructor(e=null,t=null){super(null,e,t),h(this,"plainXMLStore"),h(this,"jsonStore"),h(this,"opfByURL",{}),h(this,"primaryOPFByEPubURL",{}),h(this,"deobfuscators",{}),h(this,"documents",{}),this.fontDeobfuscator=this.makeDeobfuscatorFactory(),this.plainXMLStore=new Fo(vy,"document"),this.jsonStore=new Fo(Ro,"text")}static create(t,i){let n=new e(t,i);return n.triggerSingleDocumentPreprocessing=!0,so(n)}makeDeobfuscatorFactory(){return e=>this.deobfuscators[e]}loadAsPlainXML(e,t,i){return this.plainXMLStore.load(e,t,i)}startLoadingAsPlainXML(e){this.plainXMLStore.fetch(e)}loadAsJSON(e,t,i){return this.jsonStore.load(e,t,i)}loadWebPubManifest(e,t){this.loadAsJSON(e,!0).then(i=>{if(!i)return this.reportLoadError(e),void t.finish(null);qy.fromWebPubManifest(this,e,i,void 0,e).then(e=>{t.finish(e)})})}loadPubDoc(e){let t=oo("loadPubDoc");if(/\.opf(?:[#?]|$)/i.test(e)){let[,i,n]=e.match(/^((?:.*\/)?)([^/]*)$/);this.loadOPF(i,n).thenFinish(t)}else/\.json(?:ld)?(?:[#?]|$)/i.test(e)?this.loadWebPubManifest(e,t):function(e){return/\.(x?html?|xht|svg)(?:[#?]|$)/i.test(e)||/^(?:about:|data:|blob:)/i.test(Q(e))}(e)?this.loadWebPub(e).then(i=>{i?t.finish(i):(this.reportLoadError(e),t.finish(null))}):Io(e,void 0,"HEAD").then(i=>{if(i.status>=400)this.loadEPUBDoc(e).then(n=>{n?t.finish(n):(R.error(`Failed to fetch a source document from ${e} (${i.status}${i.statusText?" "+i.statusText:""})`),t.finish(null))});else if(!i.status&&!i.responseXML&&!i.responseText&&!i.responseBlob&&!i.contentType&&/\/[^/.]+(?:[#?]|$)/.test(e)&&(e=e.replace(/([#?]|$)/,"/$1")),"application/oebps-package+xml"==i.contentType){let[,i,n]=e.match(/^((?:.*\/)?)([^/]*)$/);this.loadOPF(i,n).thenFinish(t)}else"application/ld+json"==i.contentType||"application/webpub+json"==i.contentType||"application/audiobook+json"==i.contentType||"application/json"==i.contentType?this.loadWebPubManifest(e,t):this.loadWebPub(e).then(i=>{i?t.finish(i):this.loadEPUBDoc(e).then(i=>{i?t.finish(i):(this.reportLoadError(e),t.finish(null))})})});return t.result()}loadEPUBDoc(e){let t=oo("loadEPUBDoc");e.endsWith("/")||(e+="/"),this.startLoadingAsPlainXML(e+"META-INF/encryption.xml");let i=e+"META-INF/container.xml";return this.loadAsPlainXML(i).then(i=>{if(i){let n=i.doc().child("container").child("rootfiles").child("rootfile").attribute("full-path");for(let i of n)if(i)return void this.loadOPF(e,i).thenFinish(t)}t.finish(null)}),t.result()}loadOPF(e,t){let i=e+t,n=this.opfByURL[i];if(n)return so(n);let r=oo("loadOPF");return this.loadAsPlainXML(i,!0,`Failed to fetch EPUB OPF ${i}`).then(t=>{if(t){let n=t=>{this.opfByURL[i]=t,this.primaryOPFByEPubURL[e]=t,r.finish(t)};this.plainXMLStore.resources[e+"META-INF/container.xml"]?this.loadAsPlainXML(e+"META-INF/encryption.xml").then(i=>{n(qy.fromXMLDoc(this,e,t,i))}):n(qy.fromXMLDoc(this,e,t,null))}else this.reportLoadError(i)}),r.result()}loadWebPub(e){let t=oo("loadWebPub");return this.load(e).then(i=>{if(i)if(i.document.querySelector("a[href='META-INF/'],a[href$='/META-INF/']"))t.finish(null);else{let n=i.document,r=n.querySelector("link[rel='publication'],link[rel='manifest'][type='application/webpub+json']");if(r){let i=r.getAttribute("href");if(/^#/.test(i)){let r=J(n.getElementById(i.substr(1)).textContent);qy.fromWebPubManifest(this,e,r,n).then(e=>{t.finish(e)})}else{let i=ue(r.getAttribute("href"),e);this.loadAsJSON(i,!0,`Failed to fetch Publication Manifest ${i}`).then(r=>{qy.fromWebPubManifest(this,e,r,n,i).then(e=>{t.finish(e)})})}}else qy.fromWebPubManifest(this,e,{},n).then(e=>{e.toc&&e.toc.src===i.url&&0===Fy(n).length&&(e.toc=null),t.finish(e)})}else this.reportLoadError(e),t.finish(null)}),t.result()}addDocument(e,t){let i=oo("EPUBDocStore.load"),n=Q(e);return(this.documents[n]=this.parseOPSResource({status:200,statusText:"",url:n,contentType:t.contentType,responseText:null,responseXML:t,responseBlob:null})).thenFinish(i),i.result()}reportLoadError(e){let t=e=>e.replace(/([^:/?#]|^)[/?#].*/,"$1");e.startsWith("data:")?R.error(`Failed to load ${e}. Invalid data.`):e.startsWith("http:")&&oe.startsWith("https:")&&!/^http:\/\/(localhost|127\.0\.0\.1|\[::1\])(:\d+)?(?:[/?#]|$)/.test(e)?R.error(`Failed to load ${e}. Mixed Content ("http:" content on "https:" context) is not allowed.`):(()=>{let i=t(e);return!(i===t(oe)||Object.keys(this.resources).find(e=>this.resources[e]&&t(e)===i)||!/^https?:?\/\/[^/]/.test(e)||/\.(xhtml|xht|xml|opf)$/i.test(e))})()?R.error(`Failed to load ${e}. This may be caused by network error, incorrect URL, or the server not allowing cross-origin resource sharing (CORS).`):R.error(`Failed to load ${e}. The target resource is invalid.`)}load(e){let t=Q(e),i=this.documents[t];if(i)return i.isPending()?i:so(i.get());{let e=oo("EPUBDocStore.load");return i=super.load(t,!0,`Failed to fetch a source document from ${t}`),i.then(i=>{i?e.finish(i):this.reportLoadError(t)}),e.result()}}processViewportMeta(e){let t=e.getAttribute("content");if(!t)return"";let i,n={};for(;null!=(i=t.match(/^,?\s*([-A-Za-z_.][-A-Za-z_0-9.]*)\s*=\s*([-+A-Za-z_0-9.]*)\s*/));)t=t.substr(i[0].length),n[i[1]]=i[2];let r=n.width-0,o=n.height-0;if(r&&o){return`@-epubx-viewport{width:${r}px;height:${o}px;}`+(!!Object.values(this.primaryOPFByEPubURL).find(e=>e.prePaginated)?`@page{size:${r}px ${o}px;margin:0;}`:"@page{margin:0;}")}return""}},My=class{constructor(){h(this,"id",null),h(this,"src",""),h(this,"mediaType",null),h(this,"title",null),h(this,"itemRefElement",null),h(this,"spineIndex",-1),h(this,"compressedSize",0),h(this,"compressed",null),h(this,"epage",0),h(this,"epageCount",0),h(this,"startPage",null),h(this,"skipPagesBefore",null),h(this,"itemProperties"),this.itemProperties=Z}initWithElement(e,t){this.id=e.getAttribute("id"),this.src=ue(e.getAttribute("href"),t),this.mediaType=e.getAttribute("media-type");let i=e.getAttribute("properties");i&&(this.itemProperties=function(e){let t={};for(let i=0;i<e.length;i++)t[e[i]]=!0;return t}(i.split(/\s+/)))}initWithParam(e){this.spineIndex=e.index,this.id=`item${e.index+1}`,this.src=e.url,this.startPage=e.startPage,this.skipPagesBefore=e.skipPagesBefore}};function Dy(e){return e.id}function zy(e){return t=>{let i=oo("deobfuscator");return function(e,t){let i=oo("makeDigest"),n=i.suspend();return window.crypto.subtle.digest(e,(new TextEncoder).encode(t)).then(e=>{n.schedule(new Uint8Array(e))}),i.result()}("SHA-1",e).then(e=>{let n=t.slice(0,1040),r=t.slice(1040,t.size);(function(e){let t=oo("readBlob"),i=new FileReader,n=t.suspend(i);return i.addEventListener("load",()=>{n.schedule(i.result)},!1),i.readAsArrayBuffer(e),t.result()})(n).then(t=>{let n=new DataView(t);for(let t=0;t<n.byteLength;t++){let i=n.getUint8(t);i^=e[t%20],n.setUint8(t,i)}i.finish(Ao([n,r]))})}),i.result()}}var Vy={dcterms:"http://purl.org/dc/terms/",marc:"http://id.loc.gov/vocabulary/",media:"http://www.idpf.org/epub/vocab/overlays/#",rendition:"http://www.idpf.org/vocab/rendition/#",onix:"http://www.editeur.org/ONIX/book/codelists/current.html#",xsd:"http://www.w3.org/2001/XMLSchema#",opf:"http://www.idpf.org/2007/opf"},Uy="http://idpf.org/epub/vocab/package/meta/#",Hy={language:`${Vy.dcterms}language`,title:`${Vy.dcterms}title`,creator:`${Vy.dcterms}creator`,layout:`${Vy.rendition}layout`,titleType:`${Uy}title-type`,displaySeq:`${Uy}display-seq`,alternateScript:`${Uy}alternate-script`,role:`${Uy}role`};function $y(e,t){let i={};return(n,r)=>{var o,s,a,l,h,u;let c,d,p=n.r||i,f=r.r||i;if(e==Hy.title&&(c="main"==(null==(o=p[Hy.titleType])?void 0:o[0].v),d="main"==(null==(s=f[Hy.titleType])?void 0:s[0].v),c!=d))return c?-1:1;let g=parseInt(null==(a=p[Hy.displaySeq])?void 0:a[0].v,10);isNaN(g)&&(g=Number.MAX_VALUE);let m=parseInt(null==(l=f[Hy.displaySeq])?void 0:l[0].v,10);return isNaN(m)&&(m=Number.MAX_VALUE),g!=m?g-m:e!=Hy.language&&t&&(c=(null==(h=p[Hy.language]||p[Hy.alternateScript])?void 0:h[0].v)==t,d=(null==(u=f[Hy.language]||f[Hy.alternateScript])?void 0:u[0].v)==t,c!=d)?c?-1:1:n.o-r.o}}var jy={"application/xhtml+xml":!0,"image/jpeg":!0,"image/png":!0,"image/svg+xml":!0,"image/gif":!0,"audio/mp3":!0},Wy="viv-id-";function Gy(e,t){if(e.startsWith("data:"))return e===t?"":e;if(t){let i=ue("",t);return e===i||e+"/"===i?"":("/"!=i.charAt(i.length-1)&&(i+="/"),e.substr(0,i.length)==i?decodeURIComponent(e.substr(i.length)):null)}return e}var qy=class e{constructor(e,t,i){h(this,"store",e),h(this,"pubURL",t),h(this,"opfXML"),h(this,"encXML",null),h(this,"items"),h(this,"spine"),h(this,"itemMap"),h(this,"itemMapByPath"),h(this,"uid",null),h(this,"bindings",{}),h(this,"lang",null),h(this,"epageCount",0),h(this,"prePaginated",!1),h(this,"epageIsRenderedPage",!0),h(this,"epageCountCallback",null),h(this,"metadata",{}),h(this,"toc",null),h(this,"cover",null),h(this,"fallbackMap",{}),h(this,"pageProgression",null),h(this,"documentURLTransformer"),this.opfXML=i.opfXML,this.items=i.items,this.spine=i.spine,this.itemMap=i.itemMap,this.itemMapByPath=i.itemMapByPath,this.documentURLTransformer=this.createDocumentURLTransformer()}createDocumentURLTransformer(){let e=this;return new class{constructor(){h(this,"canonicalDocumentURLCache",new Map)}getCanonicalDocumentURL(t){var i,n;let r=Q(ne(t)),o=this.canonicalDocumentURLCache.get(r);if(o)return o;for(let t of e.spine){let o=Q(ne(t.src));if(o===r)return this.canonicalDocumentURLCache.set(r,o),o;let s=null==(n=null==(i=e.store)?void 0:i.get(o))?void 0:n.url;if(s&&Q(ne(s))===r)return this.canonicalDocumentURLCache.set(r,o),o}return this.canonicalDocumentURLCache.set(r,r),r}transformFragment(e,t){let i=this.getCanonicalDocumentURL(t)+(e?`#${e}`:"");return Wy+Fe(i,":")}transformURL(t,i){let n=t.match(/^([^#]*)#?(.*)$/);if(n){let t=this.getCanonicalDocumentURL(n[1]||ne(i)),r=decodeURIComponent(n[2]);if(t&&e.spine.some(e=>Q(ne(e.src))===t))return`#${this.transformFragment(r,t)}`}return t}restoreURL(e){"#"===e.charAt(0)&&(e=e.substring(1)),0===e.indexOf(Wy)&&(e=e.substring(7));let t=Oe(e,":").match(/^([^#]*)#?(.*)$/);return t?[t[1],t[2]]:[]}}}getMetadata(){return this.metadata}getPathFromURL(e){return Gy(e,this.pubURL)}static fromXMLDoc(t,i,n,r){let o=n.doc().child("package"),s=null,a=o.attribute("unique-identifier")[0];if(a){let e=n.getElement(`${n.url}#${a}`);e&&(s=e.textContent.replace(/[ \n\r\t]/g,""))}let l={},h=null,u=null,c=o.child("manifest").child("item").asArray().map(e=>{let t=new My,i=e;t.initWithElement(i,n.url);let r=i.getAttribute("fallback");return r&&!jy[t.mediaType]&&(l[t.src]=r),!h&&t.itemProperties.nav&&(h=t),!u&&t.itemProperties["cover-image"]&&(u=t),t}),d=Be(c,Dy),p=Be(c,e=>Gy(e.src,i)),f={};for(let e in l){let t=e;for(;;){let i=d[l[t]];if(!i)break;if(jy[i.mediaType]){f[e]=i.src;break}t=i.src}}let g=o.child("spine").child("itemref").asArray().map((e,t)=>{let i=e,n=i.getAttribute("idref"),r=d[n];return r&&(r.itemRefElement=i,r.spineIndex=t),r}),m=new e(t,i,{opfXML:n,items:c,spine:g,itemMap:d,itemMapByPath:p});m.encXML=r,m.uid=s,m.toc=h,m.cover=u,m.fallbackMap=f;let v=o.child("spine").attribute("page-progression-direction")[0];v&&(m.pageProgression=C(v));let y=r?r.doc().child("encryption").child("EncryptedData").predicate(yy.withChild("EncryptionMethod",yy.withAttribute("Algorithm","http://www.idpf.org/2008/embedding"))).child("CipherData").child("CipherReference").attribute("URI"):[],b=o.child("bindings").child("mediaType").asArray();for(let e=0;e<b.length;e++){let t=b[e].getAttribute("handler"),i=b[e].getAttribute("media-type");i&&t&&d[t]&&(m.bindings[i]=d[t].src)}if(m.metadata=function(e,t){let i;if(t){i={};for(let e in Vy)i[e]=Vy[e];let e;for(;null!=(e=t.match(/^\s*([A-Z_a-z\u007F-\uFFFF][-.A-Z_a-z0-9\u007F-\uFFFF]*):\s*(\S+)/));)t=t.substr(e[0].length),i[e[1]]=e[2]}else i=Vy;let n=e=>{if(e){let t=e.match(/^\s*(([^:]*):)?(\S+)\s*$/);if(t){let e=t[2]?i[t[2]]:Uy;if(e)return e+t[3]}}return null},r=1,o=e.childElements().forEachNonNull(e=>{if("meta"==e.localName){let t=n(e.getAttribute("property"));if(t)return{name:t,value:e.textContent,id:e.getAttribute("id"),order:r++,refines:e.getAttribute("refines"),lang:null,scheme:n(e.getAttribute("scheme")),role:null}}else if("http://purl.org/dc/elements/1.1/"==e.namespaceURI)return{name:Vy.dcterms+e.localName,order:r++,lang:e.getAttribute("xml:lang"),value:e.textContent,id:e.getAttribute("id"),refines:null,scheme:null,role:e.getAttribute("role")||e.getAttribute("opf:role")};return null}),s=Me(o,e=>e.refines),a=e=>function(e,t){let i={};for(let n in e)i[n]=t(e[n],n);return i}(e,(e,t)=>e.map(e=>{let t={v:e.value,o:e.order};e.scheme&&(t.s=e.scheme);let i=s[`#${e.id}`]||[];if(i.length||e.lang||e.role){e.lang&&i.push({name:Hy.language,value:e.lang,lang:null,id:null,refines:e.id,scheme:null,order:e.order,role:null}),e.role&&i.push({name:Hy.role,value:e.role,lang:null,id:null,refines:e.id,scheme:null,order:e.order,role:null});let n=Me(i,e=>e.name);t.r=a(n)}return t})),l=a(Me(o,e=>e.refines?null:e.name)),h=null;l[Hy.language]&&(h=l[Hy.language][0].v);let u=e=>{for(let t in e){let i=e[t];i.sort($y(t,h));for(let e=0;e<i.length;e++){let t=i[e].r;t&&u(t)}}};return u(l),l}(o.child("metadata"),o.attribute("prefix")[0]),m.metadata[Hy.language]&&(m.lang=m.metadata[Hy.language][0].v),m.metadata[Hy.layout]&&(m.prePaginated="pre-paginated"===m.metadata[Hy.layout][0].v),y.length>0&&s){let e=zy(s);for(let n=0;n<y.length;n++)t.deobfuscators[i+y[n]]=e}return m.prePaginated&&m.assignAutoPages(),m}assignAutoPages(){let e=0;for(let t of this.spine){let i=this.prePaginated?1:Math.ceil(t.compressedSize/1024);t.epage=e,t.epageCount=i,e+=i}this.epageCount=e,this.epageCountCallback&&this.epageCountCallback(this.epageCount)}setEPageCountMode(e){this.epageIsRenderedPage=e||this.prePaginated}countEPages(e){if(this.epageCountCallback=e,this.epageIsRenderedPage)return this.prePaginated&&0==this.epageCount&&this.assignAutoPages(),so(!0);let t=0,i=0,n=oo("countEPages");return n.loopWithFrame(e=>{if(i===this.spine.length)return void e.breakLoop();let n=this.spine[i++];n.epage=t,this.store.load(n.src).then(i=>{if(!i)return void e.continueLoop();let r=1800,o=i.lang||this.lang;o&&o.match(/^(ja|ko|zh)/)&&(r/=3),n.epageCount=Math.ceil(i.getTotalOffset()/r),t+=n.epageCount,this.epageCount=t,this.epageCountCallback&&this.epageCountCallback(this.epageCount),e.continueLoop()})}).thenFinish(n),n.result()}static buildChapters(e,t){let i={},n={},r=[],o=r,s=new fy(null,"",(new DOMParser).parseFromString("<spine></spine>","text/xml"));return t.forEach(t=>{let o=new My;o.initWithParam(t),o.id;let a=s.document.createElement("itemref");a.setAttribute("idref",o.id),s.root.appendChild(a),o.itemRefElement=a,i[o.id]=o;let l=Gy(t.url,e);null==l&&(l=t.url),n[l]=o,r.push(o)}),{opfXML:s,items:r,spine:o,itemMap:i,itemMapByPath:n}}static fromChapters(t,i,n,r){let o=new e(t,i,e.buildChapters(i,n));return r?t.addDocument(n[0].url,r).thenReturn(o):so(o)}static fromWebPubManifest(t,i,n,r,o){var s,a,l,h;let u=null;n.readingProgression&&(u=n.readingProgression);let c={},d=n.name||(null==(s=n.metadata)?void 0:s.title)||(null==r?void 0:r.title);d&&(c[Hy.title]=(Array.isArray(d)?d:[d]).map(e=>{var t;return{v:null!=(t=e.value)?t:e}}));let p=n.author||n.creator||(null==(a=n.metadata)?void 0:a.author)||Array.from(null!=(l=null==r?void 0:r.querySelectorAll("meta[name='author'], meta[name='DC.Creator']"))?l:[]).map(e=>e.content);p&&0!==p.length&&(c[Hy.creator]=(Array.isArray(p)?p:[p]).map(e=>{var t;return{v:null!=(t=e.name)?t:e}}));let f=n.inLanguage||(null==(h=n.metadata)?void 0:h.language)||(null==r?void 0:r.documentElement.lang)||(null==r?void 0:r.documentElement.getAttribute("xml:lang"));f&&(c[Hy.language]=(Array.isArray(f)?f:[f]).map(e=>({v:e})));let g=Q(i),m=Gy(g,i),v=null!==m?_y(m):/^(?:about:|blob:)/i.test(g)?g:null;if(!n.readingOrder&&r&&null!==v){n.readingOrder=[v];for(let e of function(e){let t=Fy(e),i=[];for(let e of t)for(let t of e.querySelectorAll("li a[href]"))i.push(t);return i}(r)){let t=e.getAttribute("href");if(/^(https?:)?\/\//.test(t)||/\.(jpe?g|png|gif|pdf|svg|mml)([#?]|$)/.test(t))continue;let r=Q(ue(t,i)),o=Gy(r,i),s=null!==o?_y(o):r;-1==n.readingOrder.indexOf(s)&&n.readingOrder.push(s)}}let y=[],b=0,w=-1;[n.readingOrder,n.resources].forEach(e=>{e instanceof Array&&e.forEach(t=>{let r=e===n.readingOrder,s="string"==typeof t?t:t.url||t.href,a="string"==typeof t?"":t.encodingFormat||t.href&&t.type||"";if(r||"text/html"===a||"application/xhtml+xml"===a||!a&&"stylesheet"!==t.rel&&/(^|\/)([^/]+\.(x?html|htm|xht)|[^/.]*)([#?]|$)/.test(s)){let e=o?o.replace(/\/[^/]+$/,"/"):i,n={url:ue(pe(s),e),index:b++,startPage:null,skipPagesBefore:null};"contents"===t.rel&&-1===w&&(w=n.index),y.push(n)}})});let x=oo("fromWebPubManifest");return e.fromChapters(t,i,y).then(e=>{var t,i;e.pageProgression=u,e.metadata=c,-1!==w&&(e.toc=e.items[w]),e.toc||(e.toc=o?null!=(t=e.items[0])?t:null:e.itemMapByPath[m]);let r=null==(i=n.readingOrder)?void 0:i.length;r&&r<e.items.length&&e.items.splice(r),x.finish(e)}),x.result()}getCFI(e,t){let i=this.spine[e],n=oo("getCFI");return this.store.load(i.src).then(e=>{let r=e.getNodeByOffset(t),o=null;if(r){let n=e.getNodeOffset(r,0,!1),s=t-n,a=new nn;a.prependPathFromNode(r,s,!1,null),i.itemRefElement&&a.prependPathFromNode(i.itemRefElement,0,!1,null),o=a.toString()}n.finish(o)}),n.result()}resolveFragment(e){return ao("resolveFragment",t=>{if(!e)return void t.finish(null);let i,n=new nn;if(n.fromString(e),this.opfXML){let e=n.navigate(this.opfXML.document);if(1!=e.node.nodeType||e.after||!e.ref)return void t.finish(null);let r=e.node,o=r.getAttribute("idref");if("itemref"!=r.localName||!o||!this.itemMap[o])return void t.finish(null);i=this.itemMap[o],n=e.ref}else i=this.spine[0];this.store.load(i.src).then(e=>{let r=n.navigate(e.document),o=e.getNodeOffset(r.node,r.offset,r.after);t.finish({spineIndex:i.spineIndex,offsetInItem:o,pageIndex:-1})})},(t,i)=>{R.warn(i,"Cannot resolve fragment:",e),t.finish(null)})}resolveEPage(e){return ao("resolveEPage",t=>{if(e<=0)return void t.finish({spineIndex:0,offsetInItem:0,pageIndex:-1});if(this.epageIsRenderedPage){let i=this.spine.findIndex(t=>0==t.epage&&0==t.epageCount||t.epage<=e&&t.epage+t.epageCount>e);-1==i&&(i=this.spine.length-1);let n=this.spine[i];(!n||0==n.epageCount)&&(n=this.spine[--i]);let r=Math.floor(e-n.epage);return void t.finish({spineIndex:i,offsetInItem:-1,pageIndex:r})}let i=Le(this.spine.length,t=>{let i=this.spine[t];return i.epage+i.epageCount>e});i==this.spine.length&&i--;let n=this.spine[i];this.store.load(n.src).then(r=>{(e-=n.epage)>n.epageCount&&(e=n.epageCount);let o=0;if(e>0){let t=r.getTotalOffset();o=Math.round(t*e/n.epageCount),o==t&&o--}t.finish({spineIndex:i,offsetInItem:o,pageIndex:-1})})},(t,i)=>{R.warn(i,"Cannot resolve epage:",e),t.finish(null)})}getEPageFromPosition(e){let t=this.spine[e.spineIndex];if(this.epageIsRenderedPage){return so(t.epage+e.pageIndex)}if(e.offsetInItem<=0)return so(t.epage);let i=oo("getEPage");return this.store.load(t.src).then(n=>{let r=n.getTotalOffset(),o=Math.min(r,e.offsetInItem);i.finish(t.epage+o*t.epageCount/r)}),i.result()}},Xy=(e,t)=>({page:e,position:{spineIndex:e.spineIndex,pageIndex:t,offsetInItem:e.offset}}),Yy=class{constructor(e,t,i,n,r,o){h(this,"opf",e),h(this,"viewport",t),h(this,"fontMapper",i),h(this,"pageSheetSizeReporter",r),h(this,"spineItems",[]),h(this,"spineItemLoadingContinuations",[]),h(this,"pref"),h(this,"clientLayout"),h(this,"counterStore"),h(this,"cmykStore"),h(this,"tocAutohide",!1),h(this,"tocVisible",!1),h(this,"tocView"),h(this,"paginationProgress",{totalOffsetsBySpine:[],renderedOffsetsBySpine:[],totalOffsetsReady:!1,lastReportedPages:0,lastReportedFraction:0,lastReportedSpineIndex:-1,lastReportedHref:""}),h(this,"renderingPageTasks",new Map),this.pref=Ve(n),this.clientLayout=new Gm(t),this.counterStore=new zn(e.documentURLTransformer),this.cmykStore=new Ui,null!=o&&o.length&&this.cmykStore.registerCmykReserveMap(o)}getPage(e){let t=this.spineItems[e.spineIndex];return t?t.pages[e.pageIndex]:null}waitForPreviousSpines(e,t){if(t||0===e)return so(!0);let i=oo("waitForPreviousSpines");return i.loopWithFrame(t=>{let n=!0;for(let t=0;t<e;t++){let e=this.spineItems[t];if(!e||!e.complete){n=!1;break}}n?t.breakLoop():i.sleep(100).then(()=>{t.continueLoop()})}).then(()=>{i.finish(!0)}),i.result()}getCurrentPageProgression(e){if(this.opf.pageProgression)return this.opf.pageProgression;{let t=this.spineItems[e?e.spineIndex:0];return t?t.instance.pageProgression:null}}finishPageContainer(e,t,i){t.container.style.display="none",t.container.style.visibility="visible",t.container.style.position="",t.container.style.top="",t.container.style.left="",t.container.setAttribute("data-vivliostyle-page-side",t.side);let n=e.pages[i];if(t.isFirstPage=0==e.item.spineIndex&&0==i,e.pages[i]=t,this.opf.epageIsRenderedPage){if(0==i&&e.item.spineIndex>0){let t=this.opf.spine[e.item.spineIndex-1];e.item.epage=t.epage+t.epageCount}e.item.epageCount=e.pages.length,this.opf.epageCount=this.opf.spine.reduce((e,t)=>e+t.epageCount,0),this.opf.epageCountCallback&&this.opf.epageCountCallback(this.opf.epageCount)}if(n)e.instance.viewport.contentContainer.replaceChild(t.container,n.container),n.dispatchEvent({type:"replaced",target:null,currentTarget:null,preventDefault:null,newPage:t});else{let n=null;if(i>0)n=e.pages[i-1].container.nextElementSibling;else for(let t=e.item.spineIndex+1;t<this.spineItems.length;t++){let e=this.spineItems[t];if(e&&e.pages[0]){n=e.pages[0].container;break}}e.instance.viewport.contentContainer.insertBefore(t.container,n)}this.pageSheetSizeReporter({width:e.instance.pageSheetWidth,height:e.instance.pageSheetHeight},e.instance.pageSheetSize,e.item.spineIndex,e.instance.pageNumberOffset+i)}getRenderedPageCount(){let e=0;for(let t of this.spineItems)t&&(e+=t.pages.length);return e}markSpineItemCompleteIfReady(e){e.complete=e.layoutPositions.length===e.pages.length,e.complete&&e.instance.viewport.layoutBox.removeAttribute("style")}getTotalOffsetForViewItem(e){let t=e.item.spineIndex,i=this.paginationProgress.totalOffsetsBySpine[t];return null==i&&(i=e.xmldoc.getTotalOffset(),this.paginationProgress.totalOffsetsBySpine[t]=i),i}collectTotalOffsets(){if(this.paginationProgress.totalOffsetsReady)return so(!0);let e=this.paginationProgress.totalOffsetsBySpine,t=0,i=oo("collectTotalOffsets");return i.loopWithFrame(i=>{if(t===this.opf.spine.length)return void i.breakLoop();let n=t++;if(null!=e[n])return void i.continueLoop();let r=this.opf.spine[n];this.opf.store.load(r.src).then(t=>{t&&(e[n]=t.getTotalOffset()),i.continueLoop()})}).then(()=>{this.paginationProgress.totalOffsetsReady=!0,i.finish(!0)}),i.result()}getTotalOffsetAll(){let e=0;for(let t of this.paginationProgress.totalOffsetsBySpine)t&&(e+=t);return e}getRenderedOffsetAll(){var e;let t=0,i=this.paginationProgress.totalOffsetsBySpine,n=this.paginationProgress.renderedOffsetsBySpine;for(let r=0;r<i.length;r++){let o=i[r];if(!o)continue;let s=null!=(e=n[r])?e:0;t+=Math.min(o,s)}return t}reportPaginationProgress(e,t){var i,n;let r=M("PAGINATION_PROGRESS");if(!r.length)return;let o=e.item.spineIndex,s=this.getTotalOffsetForViewItem(e),a=s;t&&(a=e.instance.getPosition(t,!0)),a<0&&(a=0),a>s&&(a=s);let l=this.paginationProgress.renderedOffsetsBySpine[o];null!=l&&a<l&&(a=l),this.paginationProgress.renderedOffsetsBySpine[o]=a;let h=this.getRenderedPageCount(),u=this.getTotalOffsetAll(),c=this.getRenderedOffsetAll(),d=u>0?c/u:0;d<this.paginationProgress.lastReportedFraction?d=this.paginationProgress.lastReportedFraction:this.paginationProgress.lastReportedFraction=d,h>this.paginationProgress.lastReportedPages&&(this.paginationProgress.lastReportedPages=h);let p=e.item.src;o>=(null!=(i=this.paginationProgress.lastReportedSpineIndex)?i:-1)?(this.paginationProgress.lastReportedSpineIndex=o,this.paginationProgress.lastReportedHref=p):p=null!=(n=this.paginationProgress.lastReportedHref)?n:p;let f={fraction:d,pages:this.paginationProgress.lastReportedPages,href:p};for(let e of r)try{e(f)}catch(e){R.warn(e)}}isInCounterResolveScope(){return this.counterStore.currentPageCountersStack.length>0}hasNonEmptyPageType(e){return!(null==e||!e.pageType)&&""!==e.pageType}hasPageTypeBoundaryBetween(e,t){return null!=(null==e?void 0:e.pageType)&&null!=(null==t?void 0:t.pageType)&&e.pageType!==t.pageType}resolvePageTypeForRenderSlot(e,t,i,n,r,o,s){let a=!1;if(n){let l=this.hasPageTypeBoundaryBetween(r,n),h=(null==o?void 0:o.pageType)===n.pageType,u=n.offset!==t.offset,c=s&&!u&&i>0;if(a=null!=n.pageType&&(c||0===i||n.pageType===(null==r?void 0:r.pageType)),t.pageType=a?n.pageType:null,s){let i=e.instance.getPageStartPageTypeOverride(t.position);""===i?t.pageType="":i&&(t.pageType=i)}if(!s&&!a){let t=i>1&&l&&h?r.pageType:null;e.instance.styler.cascade.currentPageType=t,e.instance.pageManager.pageCascadeInstance.currentPageType=t}}!s&&this.hasNonEmptyPageType(r)&&this.hasNonEmptyPageType(o)&&r.pageType!==o.pageType&&(!n||null==n.pageType)&&(t.pageType=r.pageType)}evaluateNextPageRelayout(e,t,i,n,r){if(!e||t&&!i)return{needsRelayout:!1,shouldCascade:!1};let o=!(!t||e.pageType!==t.pageType&&t.pageType);return t&&n&&(!r||o)&&(null==t.pageType||null==e.pageType||e.pageType!==t.pageType)&&(t.pageType=null),{needsRelayout:!0,shouldCascade:!!t||!r}}preparePageCountersForRender(e,t){let i=e.pages[t],n=e.pageCounterStarts[t];i&&n&&(this.counterStore.currentPageCounters=Ly(n));let r=Ly(this.counterStore.currentPageCounters);return(!n||!i)&&(e.pageCounterStarts[t]=r),i}maybeRelayoutFollowingPage(e,t,i,n){if(!t)return so(!0);let r=e.layoutPositions[t.page];e.layoutPositions[t.page]=t;let o=e.pages[t.page],s=!!i&&n.offset!==i.offset,a=e.instance.hasActiveRootPageFloatLayoutContext(),l=!r||!t.isSamePosition(r)||t.highestSeenOffset!==r.highestSeenOffset||s||a,h=this.isInCounterResolveScope(),u=this.evaluateNextPageRelayout(i,o,l,s,h);return u.needsRelayout?(e.complete=!1,u.shouldCascade?this.renderSinglePage(e,t):so(!0)):so(!0)}resolveUnresolvedReferencesForPage(e,t,i,n){let r=oo("resolveUnresolvedReferencesForPage"),o=this.isInCounterResolveScope()?[]:this.counterStore.getUnresolvedRefsToPage(t),s=0,a=t;return r.loopWithFrame(t=>{if(s++,s>o.length)return void t.breakLoop();let n=o[s-1];n.refs=n.refs.filter(e=>!e.isResolved()),0!==n.refs.length?this.getPageViewItem(n.spineIndex).then(r=>{var o;if(!r)return void t.continueLoop();let s=r.instance.styler.cascade,l=r.instance.pageManager.pageCascadeInstance,h={currentPageType:s.currentPageType,previousPageType:s.previousPageType},u={currentPageType:l.currentPageType,previousPageType:l.previousPageType},c=function(e){let t=Object.create(null);return Object.keys(e).forEach(i=>{t[i]=new Map(e[i])}),t}(r.instance.pageGroupPageCounts),d=r.instance.currentPageGroupDocument,p=r.instance.scopes;r.instance.scopes={};let f=n.pageIndex<r.pages.length-1,g=!!r.pages[n.pageIndex],m=g&&f,v=m&&n.pageIndex>0?null==(o=r.pages[n.pageIndex-1])?void 0:o.pageFloatLayoutContext:null,y=m?r.instance.beginIsolatedRootPageFloatLayoutContext(v):null;this.counterStore.pushPageCounters(n.pageCounters),this.counterStore.pushReferencesToSolve(n.refs);let b=r.layoutPositions[n.pageIndex];g&&r.instance.preparePageGroupPageIndicesForRerender(r.layoutPositions,n.pageIndex),this.renderSinglePage(r,b).then(n=>{m&&r.instance.endIsolatedRootPageFloatLayoutContext(y);let o=s.currentPageType;s.currentPageType=h.currentPageType,s.previousPageType=h.previousPageType,l.currentPageType=u.currentPageType,l.previousPageType=u.previousPageType,r.instance.pageGroupPageCounts=c,r.instance.currentPageGroupDocument=d,r.instance.scopes=p;let f=Ly(this.counterStore.currentPageCounters);this.counterStore.popPageCounters(),this.counterStore.popReferencesToSolve(),n.pageAndPosition.position.spineIndex===a.spineIndex&&n.pageAndPosition.position.pageIndex===i&&(a=n.pageAndPosition.page),a.pageType&&a.pageType!==h.currentPageType&&o!==n.pageAndPosition.page.pageType&&(s.currentPageType=a.pageType);let g=r!==e,v=r.pages.length,b=r.layoutPositions[v],w=r.instance.hasActiveRootPageFloatLayoutContext();if(b&&!w){let e=g?Ly(this.counterStore.currentPageCounters):null;g&&(this.counterStore.currentPageCounters=f);let i=v;return void this.renderSinglePage(r,b).then(()=>{g&&this.markSpineItemCompleteIfReady(r);let n=r.pages.length-i;if(g&&n>0){this.counterStore.adjustPageCountersOfLaterSpines(r.item.spineIndex,n),this.counterStore.updateTargetCounterNodesInPages(r.pages);for(let e=r.item.spineIndex+1;e<this.spineItems.length;e++){let t=this.spineItems[e];if(t){t.item.epage+=n;for(let e of t.pageCounterStarts)null!=e&&e.page&&(e.page=e.page.map(e=>e+n));this.counterStore.updatePageCounterNodesInPages(t.pages,t.pageCounterStarts)}}if(e){let t=e.page;t&&(e.page=t.map(e=>e+n))}}e&&(this.counterStore.currentPageCounters=e),t.continueLoop()})}g&&this.markSpineItemCompleteIfReady(r),t.continueLoop()})}):t.continueLoop()}).then(()=>{a.container.parentElement||(a=e.pages[i]),a.isLastPage=!n&&e.item.spineIndex===this.opf.spine.length-1,a.isLastPage&&this.counterStore.finishLastPage(this.viewport),a.container.setAttribute("data-vivliostyle-page-index",i),a.container.setAttribute("data-vivliostyle-spine-index",a.spineIndex),r.finish(a)}),r.result()}renderSinglePage(e,t){let i=oo("renderSinglePage"),n=t?Math.max(t.page,0):0,r=e.instance.getPageNumberContextDepth();e.instance.pushPageNumberContext(n+1);let o=()=>{e.instance.restorePageNumberContextDepth(r)};i.handler=(e,t)=>{o(),e.task.raise(t,e.parent)};let s=this.isInCounterResolveScope(),a=this.preparePageCountersForRender(e,n),l=n>0?e.pages[n-1]:null,h=e.pages[n+1],u=this.makePage(e,t);return this.resolvePageTypeForRenderSlot(e,u,n,a,l,h,s),e.instance.layoutNextPage(u,t).then(n=>{let r=(t=n)?t.page-1:e.layoutPositions.length-1;this.finishPageContainer(e,u,r),this.counterStore.finishPage(u.spineIndex,r),(M("PAGINATION_PROGRESS").length?this.collectTotalOffsets():so(!0)).then(()=>{this.reportPaginationProgress(e,t),this.maybeRelayoutFollowingPage(e,t,a,u).thenAsync(()=>this.resolveUnresolvedReferencesForPage(e,u,r,t)).then(e=>{o(),i.finish({pageAndPosition:Xy(e,r),nextLayoutPosition:t})})})}),i.result()}normalizeSeekPosition(e,t){let i=e.pageIndex,n=-1;if(i<0){n=e.offsetInItem;let r=Le(t.layoutPositions.length,e=>t.instance.getPosition(t.layoutPositions[e],!0)>n);i=r===t.layoutPositions.length?t.complete?t.pages.length-1:Number.POSITIVE_INFINITY:r-1}else i===Number.POSITIVE_INFINITY&&-1!==e.offsetInItem&&(n=e.offsetInItem);return{spineIndex:e.spineIndex,pageIndex:i,offsetInItem:n}}findPage(e,t){let i=oo("findPage");return this.waitForPreviousSpines(e.spineIndex,t).then(()=>{this.getPageViewItem(e.spineIndex).then(n=>{if(!n)return void i.finish(null);let r,o=null;i.loopWithFrame(s=>{let a=this.normalizeSeekPosition(e,n);r=a.pageIndex,o=n.pages[r],o?s.breakLoop():n.complete?(r=n.pages.length-1,o=n.pages[r],s.breakLoop()):t?this.renderPage(a).then(e=>{e&&(o=e.page,r=e.position.pageIndex),s.breakLoop()}):this.isRenderingPageInAnotherTask()?i.sleep(100).then(()=>{s.continueLoop()}):r<n.layoutPositions.length&&!n.pages[r]?this.renderPage(a).then(e=>{e&&(o=e.page,r=e.position.pageIndex),s.breakLoop()}):i.sleep(100).then(()=>{s.continueLoop()})}).then(()=>{i.finish(Xy(o,r))})})}),i.result()}renderPage(e){let t=ro();this.beginRenderingPage(t);let i=!1,n=()=>{i||(i=!0,this.endRenderingPage(t))};return ao("renderPage",t=>{this.renderPageTracked(e).then(e=>{n(),t.finish(e)})},(e,t)=>{n(),e.task.raise(t,e.parent)})}beginRenderingPage(e){this.renderingPageTasks.set(e,(this.renderingPageTasks.get(e)||0)+1)}endRenderingPage(e){let t=this.renderingPageTasks.get(e);1===t?this.renderingPageTasks.delete(e):t&&this.renderingPageTasks.set(e,t-1)}isRenderingPageInAnotherTask(){let e=ro();return Array.from(this.renderingPageTasks.keys()).some(t=>t!==e)}renderPageTracked(e){let t=oo("renderPageTracked");return this.getPageViewItem(e.spineIndex).then(i=>{if(!i)return void t.finish(null);let n=this.normalizeSeekPosition(e,i),r=n.pageIndex,o=n.offsetInItem,s=i.pages[r];s?t.finish(Xy(s,r)):t.loopWithFrame(e=>{if(r<i.layoutPositions.length)return void e.breakLoop();if(i.complete)return r=i.pages.length-1,void e.breakLoop();let t=i.layoutPositions[i.layoutPositions.length-1];this.renderSinglePage(i,t).then(n=>{let a=n.pageAndPosition.page;if(t=n.nextLayoutPosition,t){if(o>=0&&i.instance.getPosition(t)>o)return s=a,r=i.layoutPositions.length-2,void e.breakLoop();e.continueLoop()}else s=a,r=n.pageAndPosition.position.pageIndex,this.markSpineItemCompleteIfReady(i),e.breakLoop()})}).then(()=>{s=s||i.pages[r];let e=i.layoutPositions[r];s?t.finish(Xy(s,r)):this.renderSinglePage(i,e).then(e=>{e.nextLayoutPosition||this.markSpineItemCompleteIfReady(i),t.finish(e.pageAndPosition)})})}),t.result()}renderAllPages(){let e=oo("renderAllPages");return this.renderPagesUpto({spineIndex:this.opf.spine.length-1,pageIndex:Number.POSITIVE_INFINITY,offsetInItem:-1},!1).then(t=>{e.loopWithFrame(t=>{this.spineItems.some(e=>null==e?void 0:e.pages.some(e=>null==e?void 0:e.fetchers.some(e=>!e.arrived)))?e.sleep(100).then(()=>{t.continueLoop()}):t.breakLoop()}).then(()=>{e.finish(t)})}),e.result()}renderPagesUpto(e,t){let i=oo("renderPagesUpto");e||(e={spineIndex:0,pageIndex:0,offsetInItem:0});let n=e.spineIndex,r=e.pageIndex,o=0;t&&(o=n);let s=null;return i.loopWithFrame(t=>{let i={spineIndex:o,pageIndex:o===n?r:Number.POSITIVE_INFINITY,offsetInItem:o===n?e.offsetInItem:-1};this.renderPage(i).then(e=>{s=e,++o>n?t.breakLoop():t.continueLoop()})}).then(()=>{i.finish(s)}),i.result()}firstPage(e,t){return this.findPage({spineIndex:0,pageIndex:0,offsetInItem:-1},t)}lastPage(e,t){return this.findPage({spineIndex:this.opf.spine.length-1,pageIndex:Number.POSITIVE_INFINITY,offsetInItem:-1},t)}nextPage(e,t){let i=e.spineIndex,n=e.pageIndex,r=oo("nextPage");return this.getPageViewItem(i).then(e=>{if(e){if(e.complete&&n==e.pages.length-1){if(i>=this.opf.spine.length-1)return void r.finish(null);i++,n=0;let t=this.spineItems[i],o=t&&t.pages[0],s=e.pages[e.pages.length-1];o&&s&&o.side==s.side&&(t.pages.forEach(e=>{e.container&&e.container.remove()}),this.spineItems[i]=null,this.spineItemLoadingContinuations[i]=null)}else n++;this.findPage({spineIndex:i,pageIndex:n,offsetInItem:-1},t).thenFinish(r)}else r.finish(null)}),r.result()}previousPage(e,t){let i=e.spineIndex,n=e.pageIndex;if(0==n){if(0==i)return so(null);i--,n=Number.POSITIVE_INFINITY}else n--;return this.findPage({spineIndex:i,pageIndex:n,offsetInItem:-1},t)}isRectoPage(e,t){let i="left"===e.side,n="ltr"===this.getCurrentPageProgression(t);return!i&&n||i&&!n}getSpread(e,t){let i=this.getPage(e);if(!i)return so({left:null,right:null});let n,r=oo("getSpread"),o="left"===i.side;return n=this.isRectoPage(i,e)?this.previousPage(e,t):this.nextPage(e,t),n.then(t=>{let i=this.getPage(e),n=t&&t.page;n&&n.side===i.side&&(n=null),o?r.finish({left:i,right:n}):r.finish({left:n,right:i})}),r.result()}nextSpread(e,t){let i=this.getPage(e);if(!i)return so(null);let n=this.isRectoPage(i,e),r=this.nextPage(e,t);return n?r:r.thenAsync(e=>{if(e){if(e.page.side===i.side)return r;let n=this.nextPage(e.position,t);return n.thenAsync(e=>e?n:r)}return so(null)})}previousSpread(e,t){let i=this.getPage(e);if(!i)return so(null);let n=this.isRectoPage(i,e),r=this.previousPage(e,t),o=i.container.previousElementSibling;return n?r.thenAsync(e=>e?e.page.side===i.side||e.page.container!==o?r:this.previousPage(e.position,t):so(null)):r}navigateToEPage(e,t,i){let n=oo("navigateToEPage");return this.opf.resolveEPage(e).then(e=>{e?this.findPage(e,i).thenFinish(n):n.finish(null)}),n.result()}navigateToFragment(e,t,i){let n=oo("navigateToCFI");return this.opf.resolveFragment(e).then(e=>{e?this.findPage(e,i).thenFinish(n):n.finish(null)}),n.result()}resolveSemanticFootnoteNavigationOffset(e,t){if(!Ll(t))return null;let i=t.getAttribute("id");if(!i)return null;let n=ue(`#${i}`,e.xmldoc.url),r=e.xmldoc.document.getElementsByTagName("a");for(let t=0;t<r.length;t++){let i=r.item(t);if(!_l(i))continue;let o=i.getAttribute("href")||i.getAttributeNS("http://www.w3.org/1999/xlink","href");if(o&&ue(o,e.xmldoc.url)===n)return e.xmldoc.getElementOffset(i)}return null}navigateTo(e,t,i){R.debug("Navigate to",e);let n=this.opf.getPathFromURL(Q(e));if(!n){if(this.opf.opfXML&&e.match(/^#epubcfi\(/))n=this.opf.getPathFromURL(this.opf.opfXML.url);else if("#"===e.charAt(0)){let t=this.opf.documentURLTransformer.restoreURL(e);this.opf.opfXML?(n=this.opf.getPathFromURL(t[0]),null==n&&(n=t[0])):n=t[0],e=t[0]+(t[1]?`#${t[1]}`:"")}if(null==n)return so(null)}let r=this.opf.itemMapByPath[n];if(!r){if(this.opf.opfXML&&n==this.opf.getPathFromURL(this.opf.opfXML.url)){let n=e.indexOf("#");if(n>=0)return this.navigateToFragment(e.substr(n+1),t,i)}return so(null)}let o=oo("navigateTo");return this.waitForPreviousSpines(r.spineIndex,i).then(()=>{this.getPageViewItem(r.spineIndex).then(t=>{if(!t)return void o.finish(null);let n=t.xmldoc.getElement(e),s=n&&this.resolveSemanticFootnoteNavigationOffset(t,n),a=null!=s?s:n?t.xmldoc.getElementOffset(n):0;this.findPage({spineIndex:r.spineIndex,pageIndex:-1,offsetInItem:a},i).thenFinish(o)})}),o.result()}makePage(e,t){let i=e.instance.viewport,n=i.document.createElement("div");n.setAttribute("data-vivliostyle-page-container","true"),n.role="presentation",b||(n.style.visibility="hidden"),i.layoutBox.appendChild(n);let r=i.document.createElement("div");r.setAttribute("data-vivliostyle-bleed-box","true"),r.role="presentation",n.appendChild(r);let o=new Ks(n,r);if(o.spineIndex=e.item.spineIndex,o.position=t,o.offset=e.instance.getPosition(t),0===o.offset&&(!e.instance.blankPageAtStart||0!==e.pages.length)){let t=this.opf.documentURLTransformer.transformFragment("",e.item.src);r.setAttribute("id",t),o.registerElementWithId(r,t)}if(i!==this.viewport){let t=$e(this.viewport.width,this.viewport.height,i.width,i.height),r=ls(e.instance.style.rootScope,new to(t,null),"");o.delayedItems.push(new Gs(n,"transform",r))}return o}makeObjectView(e,t,i,n){let r=t.getAttribute("data"),o=null;if(r){r=ue(r,e.url);let i=t.getAttribute("media-type");if(!i){let e=this.opf.getPathFromURL(r);if(e){let t=this.opf.itemMapByPath[e];t&&(i=t.mediaType)}}if(i){let e=this.opf.bindings[i];if(e){o=this.viewport.document.createElement("iframe"),o.style.border="none";let n=Ie(r),s=Ie(i),a=new Pe;a.append(e),a.append("?src="),a.append(n),a.append("&type="),a.append(s);for(let e=t.firstChild;e;e=e.nextSibling)if(1==e.nodeType){let t=e;if("param"==t.localName&&"http://www.w3.org/1999/xhtml"==t.namespaceURI){let e=t.getAttribute("name"),i=t.getAttribute("value");e&&i&&(a.append("&"),a.append(encodeURIComponent(e)),a.append("="),a.append(encodeURIComponent(i)))}}o.setAttribute("src",a.toString());let l=t.getAttribute("width");l&&o.setAttribute("width",l);let h=t.getAttribute("height");h&&o.setAttribute("height",h)}}}return o||(o=this.viewport.document.createElement("object"),r&&o.setAttribute("data",he(r)),o.setAttribute("data-adapt-process-children","true")),so(o)}makeMathJaxView(e,t,i,n){let r=function(){let e=window.MathJax;return e?e.Hub:null}();if(r){let n=i.ownerDocument,o=n.createElement("span");i.appendChild(o);let s=n.importNode(t,!0);this.resolveURLsInMathML(s,e),o.appendChild(s);let a=r.queue;a.Push(["Typeset",r,o]);let l=oo("makeMathJaxView"),h=l.suspend();return a.Push(()=>{h.schedule(o)}),l.result()}return so(null)}resolveURLsInMathML(e,t){if(null!=e){if(1===e.nodeType&&"mglyph"===e.tagName){let i=Array.from(e.attributes);for(let n of i){if("src"!==n.name)continue;let i=ue(n.nodeValue,t.url);n.namespaceURI?e.setAttributeNS(n.namespaceURI,n.name,i):e.setAttribute(n.name,i)}}e.firstChild&&this.resolveURLsInMathML(e.firstChild,t),e.nextSibling&&this.resolveURLsInMathML(e.nextSibling,t)}}makeCustomRenderer(e){return(t,i,n)=>"object"==t.localName&&"http://www.w3.org/1999/xhtml"==t.namespaceURI?this.makeObjectView(e,t,i,n):"http://www.w3.org/1998/Math/MathML"==t.namespaceURI||t.dataset&&"true"==t.dataset.mathTypeset?this.makeMathJaxView(e,t,i,n):so(null)}getPageViewItem(e){if(-1===e||e>=this.opf.spine.length)return so(null);let t=this.spineItems[e];if(t)return so(t);let i=oo("getPageViewItem"),n=this.spineItemLoadingContinuations[e];if(n){let e=i.suspend();return n.push(e),i.result()}n=this.spineItemLoadingContinuations[e]=[];let r=this.opf.spine[e],o=this.opf.store;return o.load(r.src).then(s=>{var a;let l=r.itemRefElement.getAttribute("properties");l&&s.root.setAttribute("data-vivliostyle-epub-spine-properties",l),r.title=s.document.title;let h=o.getStyleForDoc(s),u=this.makeCustomRenderer(s),c=this.viewport,d=h.sizeViewport(c.width,c.height,c.fontSize,this.pref);(d.width!=c.width||d.height!=c.height||d.fontSize!=c.fontSize)&&(c=new qm(c.window,d.fontSize,c.pixelRatio,c.root,d.width,d.height));let p,f,g=null==(a=this.spineItems[0])?void 0:a.instance.isVersoFirstPage,m=this.spineItems[e-1];if(null!==r.startPage)p=r.startPage-1,f=p;else{if(!(e>0)||m&&m.complete){p=m?m.instance.pageNumberOffset+m.pages.length:0;let e=m&&m.pageCounterStarts[m.pages.length-1],t=e&&e.page;if(t&&t.length)f=t[t.length-1]+1;else{let e=this.counterStore.currentPageCounters.page;f=e&&e.length?e[e.length-1]:p}}else p=r.epage||e,!this.opf.prePaginated&&p%2==(g?1:0)&&p++,f=p;null!==r.skipPagesBefore&&(p+=r.skipPagesBefore,f+=r.skipPagesBefore)}this.counterStore.forceSetPageCounter(f);let v=this.opf.metadata&&this.opf.metadata[Hy.title],y=v&&v[0]&&v[0].v||"",b=r.title||"";ky.create(h,s,this.opf.lang,c,this.clientLayout,this.fontMapper,u,this.opf.fallbackMap,p,this.opf.documentURLTransformer,this.counterStore,this.cmykStore,this.pref,y,b,this.opf.pageProgression,g).then(o=>{!this.opf.pageProgression&&o.pageProgression&&(this.opf.pageProgression=o.pageProgression),t={item:r,xmldoc:s,instance:o,layoutPositions:[null],pages:[],complete:!1,pageCounterStarts:[]},this.spineItems[e]=t,i.finish(t),n.forEach(e=>{e.schedule(t)})})}),i.result()}removeRenderedPages(){let e=this.spineItems;for(let t of e)t&&t.pages.splice(0);this.viewport.clear()}hasAutoSizedPages(){let e=this.spineItems;for(let t of e)if(t){let e=t.pages;for(let t of e)if(t.isAutoPageWidth&&t.isAutoPageHeight)return!0}return!1}hasPages(){return this.spineItems.some(e=>e&&e.pages.length>0)}showTOC(e){let t=this.opf,i=t.toc;if(this.tocAutohide=e,!i)return so(null);if(this.tocVisible=!0,this.tocView&&this.tocView.page)return this.tocView.page.container.style.visibility="visible",this.tocView.page.container.setAttribute("aria-hidden","false"),so(this.tocView.page);let n=oo("showTOC");this.tocView||(this.tocView=new Ry(t.store,i.src,t.lang,this.clientLayout,this.fontMapper,this.pref,this,t.fallbackMap,t.documentURLTransformer,this.counterStore,this.cmykStore));let r=this.viewport,o=Math.min(344,Math.round(.67*r.width)-16),s=r.height-6,a=r.document.createElement("div");return r.root.appendChild(a),b||(a.style.visibility="hidden"),a.style.width=`${o+16}px`,a.style.maxHeight=`${s}px`,a.setAttribute("data-vivliostyle-toc-box","true"),a.setAttribute("role","navigation"),this.tocView.showTOC(a,r,o,s,this.viewport.fontSize).then(e=>{a.style.visibility="visible",a.setAttribute("aria-hidden","false"),n.finish(e)}),n.result()}hideTOC(){this.tocVisible=!1,this.tocView&&this.tocView.hideTOC()}isTOCVisible(){return this.tocVisible&&!!this.tocView&&this.tocView.isTOCVisible()}},Ky="data-vivliostyle-viewer-status",Zy=(e=>(e.SINGLE_PAGE="singlePage",e.SPREAD="spread",e.AUTO_SPREAD="autoSpread",e))(Zy||{}),Jy=class{constructor(e,t,i,n){h(this,"window",e),h(this,"viewportElement",t),h(this,"instanceId",i),h(this,"callbackFn",n),h(this,"fontMapper"),h(this,"kick"),h(this,"sendCommand"),h(this,"resizeListener"),h(this,"hyperlinkListener"),h(this,"pageRuleStyleElement"),h(this,"pageSheetSizeAlreadySet",!1),h(this,"renderTask",null),h(this,"actions"),h(this,"readyState","loading"),h(this,"packageURL",[]),h(this,"opf",null),h(this,"touchActive",!1),h(this,"touchX",0),h(this,"touchY",0),h(this,"needResize",!1),h(this,"resized",!1),h(this,"needRefresh",!1),h(this,"viewportSize",null),h(this,"currentPage",null),h(this,"currentSpread",null),h(this,"pagePosition",null),h(this,"fontSize",16),h(this,"zoom",1),h(this,"fitToScreen",!1),h(this,"pageViewMode","singlePage"),h(this,"waitForLoading",!1),h(this,"renderAllPages",!0),h(this,"pref",{fontFamily:"serif",lineHeight:1.25,margin:8,hyphenate:!1,columnWidth:25,horizontal:!1,nightMode:!1,spreadView:!1,pageBorder:1,enabledMediaTypes:{vivliostyle:!0,print:!0},defaultPaperSize:void 0}),h(this,"pageSizes",[]),h(this,"pixelRatioLimit","chromium"===X&&"currentCSSZoom"in Element.prototype?16:0),h(this,"pixelRatio",Math.min(8,this.pixelRatioLimit)),h(this,"viewport",null),h(this,"opfView",null),h(this,"cmykReserveMap"),h(this,"cmykReserveMapUrl"),h(this,"paginationProgressHook",null);let r=t.ownerDocument,o=(e,t)=>{let i=r.getElementById(e);return i||(i=r.createElement("style"),i.id=e,t&&(i.textContent=t),r.head.appendChild(i)),i};o("vivliostyle-viewport-screen-css",wo),o("vivliostyle-viewport-css",xo),o("vivliostyle-polyfill-css",No),t.setAttribute("data-vivliostyle-viewer-viewport",!0),b&&t.setAttribute("data-vivliostyle-debug",!0),t.setAttribute(Ky,"loading"),this.fontMapper=new Im(r.head,t),this.kick=()=>{},this.sendCommand=()=>{},this.resizeListener=()=>{this.needResize=!0,this.resized=!0,this.kick()},this.pageReplacedListener=this.pageReplacedListener.bind(this),this.hyperlinkListener=e=>{},this.pageRuleStyleElement=o("vivliostyle-page-rules"),this.actions={loadPublication:this.loadPublication,loadXML:this.loadXML,configure:this.configure,moveTo:this.moveTo,toc:this.showTOC},this.addLogListeners()}addLogListeners(){let e=T;R.addListener(e.DEBUG,e=>{this.callback({t:"debug",content:e})}),R.addListener(e.INFO,e=>{this.callback({t:"info",content:e})}),R.addListener(e.WARN,e=>{this.callback({t:"warn",content:e})}),R.addListener(e.ERROR,e=>{this.callback({t:"error",content:e})})}ensurePaginationProgressListener(){if(this.paginationProgressHook)return;let e=e=>{this.callback({t:"paginationprogress",...e})};this.paginationProgressHook=e,_("PAGINATION_PROGRESS",e)}removePaginationProgressListener(){this.paginationProgressHook&&(B("PAGINATION_PROGRESS",this.paginationProgressHook),this.paginationProgressHook=null)}callback(e){e.i=this.instanceId,this.callbackFn(e)}setReadyState(e){if(this.readyState!==e){this.readyState=e,this.viewportElement.setAttribute(Ky,e);let t=this.getCurrentPageProgression();t&&this.viewportElement.setAttribute("data-vivliostyle-page-progression",t),this.callback({t:"readystatechange"})}}loadPublication(e){G.registerStartTiming("beforeRender"),this.setReadyState("loading");let t=e.url,i=e.fragment,n=e.authorStyleSheet,r=e.userStyleSheet;this.cmykReserveMapUrl=e.cmykReserveMapUrl,this.viewport=null;let o=oo("loadPublication");return this.configure(e).then(()=>{By.create(n,r).then(e=>{let n=ue(pe(t),this.window.location.href);this.packageURL=[n],e.loadPubDoc(n).then(t=>{t?(this.opf=t,this.loadCmykReserveMap(e).then(()=>{this.render(i).then(()=>{o.finish(!0)})})):o.finish(!1)})})}),o.result()}loadXML(e){G.registerStartTiming("beforeRender"),this.setReadyState("loading");let t=e.url,i=e.document,n=e.fragment,r=e.authorStyleSheet,o=e.userStyleSheet;this.cmykReserveMapUrl=e.cmykReserveMapUrl,this.viewport=null;let s=oo("loadXML");return this.configure(e).then(()=>{By.create(r,o).then(e=>{let r=t.map((e,t)=>({url:ue(pe(e.url),this.window.location.href),index:t,startPage:e.startPage,skipPagesBefore:e.skipPagesBefore}));this.packageURL=r.map(e=>e.url),qy.fromChapters(e,"",r,i).then(t=>{this.opf=t,this.loadCmykReserveMap(e).then(()=>{this.render(n).then(()=>{s.finish(!0)})})})})}),s.result()}render(e){let t;return this.cancelRenderingTask(),t=e?this.opf.resolveFragment(e).thenAsync(e=>(this.pagePosition=e,so(!0))):so(!0),t.thenAsync(()=>(G.registerEndTiming("beforeRender"),this.resize()))}resolveLength(e){let t,i=parseFloat(e);if("string"==typeof e&&(t=e.match(/[a-z]+$/))){let e=t[0];if("em"===e||"rem"===e)return i*this.fontSize;let n=Ke[e];if(n)return i*n}return i}configure(e){if("boolean"==typeof e.autoresize&&(e.autoresize?(this.viewportSize=null,this.window.addEventListener("resize",this.resizeListener,!1),this.needResize=!0):this.window.removeEventListener("resize",this.resizeListener,!1)),"number"==typeof e.fontSize){let t=e.fontSize;t>=5&&t<=72&&this.fontSize!=t&&(this.fontSize=t,this.needResize=!0)}if("object"==typeof e.viewport&&e.viewport){let t=e.viewport,i={marginLeft:this.resolveLength(t["margin-left"])||0,marginRight:this.resolveLength(t["margin-right"])||0,marginTop:this.resolveLength(t["margin-top"])||0,marginBottom:this.resolveLength(t["margin-bottom"])||0,width:this.resolveLength(t.width)||0,height:this.resolveLength(t.height)||0};(i.width>=200||i.height>=200)&&(this.window.removeEventListener("resize",this.resizeListener,!1),this.viewportSize=i,this.needResize=!0)}if("boolean"==typeof e.hyphenate&&(this.pref.hyphenate=e.hyphenate,this.needResize=!0),"boolean"==typeof e.horizontal&&(this.pref.horizontal=e.horizontal,this.needResize=!0),"boolean"==typeof e.nightMode&&(this.pref.nightMode=e.nightMode,this.needResize=!0),"number"==typeof e.lineHeight&&(this.pref.lineHeight=e.lineHeight,this.needResize=!0),"number"==typeof e.columnWidth&&(this.pref.columnWidth=e.columnWidth,this.needResize=!0),"string"==typeof e.fontFamily&&(this.pref.fontFamily=e.fontFamily,this.needResize=!0),"boolean"==typeof e.load&&(this.waitForLoading=e.load),"boolean"==typeof e.renderAllPages&&(this.renderAllPages=e.renderAllPages),"string"==typeof e.userAgentRootURL&&(se(e.userAgentRootURL.replace(/resources\/?$/,"")),le(e.userAgentRootURL)),"string"==typeof e.rootURL&&(se(e.rootURL),le(`${oe}resources/`)),"string"==typeof e.pageViewMode&&e.pageViewMode!==this.pageViewMode&&(this.pageViewMode=e.pageViewMode,this.needResize=!0),"number"==typeof e.pageBorder&&e.pageBorder!==this.pref.pageBorder&&(this.viewport=null,this.pref.pageBorder=e.pageBorder,this.needResize=!0),"number"==typeof e.zoom&&e.zoom!==this.zoom&&(this.zoom=e.zoom,this.needRefresh=!0),"boolean"==typeof e.fitToScreen&&e.fitToScreen!==this.fitToScreen&&(this.fitToScreen=e.fitToScreen,this.needRefresh=!0),"object"==typeof e.defaultPaperSize&&"number"==typeof e.defaultPaperSize.width&&"number"==typeof e.defaultPaperSize.height&&(this.viewport=null,this.pref.defaultPaperSize=e.defaultPaperSize,this.needResize=!0),"boolean"==typeof e.allowScripts&&e.allowScripts!==Am&&(function(e){Am=e}(e.allowScripts),this.needResize=!0),"number"==typeof e.pixelRatio){let t=Math.min(e.pixelRatio,this.pixelRatioLimit);t!==this.pixelRatio&&(this.pixelRatio=t,this.needResize=!0)}return this.configurePlugins(e),so(!0)}configurePlugins(e){M("CONFIGURATION").forEach(t=>{let i=t(e);this.needResize=i.needResize||this.needResize,this.needRefresh=i.needRefresh||this.needRefresh})}pageReplacedListener(e){let t=this.currentPage,i=this.currentSpread,n=e.target;i?(i.left===n||i.right===n)&&this.showCurrent(e.newPage):t===e.target&&this.showCurrent(e.newPage)}forCurrentPages(e){let t=[];this.currentPage&&t.push(this.currentPage),this.currentSpread&&(this.currentSpread.left&&t.push(this.currentSpread.left),this.currentSpread.right&&t.push(this.currentSpread.right)),t.forEach(t=>{t&&e(t)})}removePageListeners(){this.forCurrentPages(e=>{e.removeEventListener("hyperlink",this.hyperlinkListener,!1),e.removeEventListener("replaced",this.pageReplacedListener,!1)})}hidePages(){this.removePageListeners(),this.forCurrentPages(e=>{be(e.container,"display","none")}),this.currentPage=null,this.currentSpread=null}showSinglePage(e){e.addEventListener("hyperlink",this.hyperlinkListener,!1),e.addEventListener("replaced",this.pageReplacedListener,!1),be(e.container,"visibility","visible"),be(e.container,"display","block")}showPage(e){this.hidePages(),this.currentPage=e,e.container.style.marginLeft="",e.container.style.marginRight="",this.showSinglePage(e)}showSpread(e){if(this.hidePages(),this.currentSpread=e,e.left&&e.right){let t=parseFloat(e.left.container.style.width),i=parseFloat(e.right.container.style.width);t&&i&&t!==i&&(t<i?e.left.container.style.marginLeft=i-t+"px":e.right.container.style.marginRight=t-i+"px")}e.left&&(this.showSinglePage(e.left),e.right?e.left.container.removeAttribute("data-vivliostyle-unpaired-page"):e.left.container.setAttribute("data-vivliostyle-unpaired-page",!0)),e.right&&(this.showSinglePage(e.right),e.left?e.right.container.removeAttribute("data-vivliostyle-unpaired-page"):e.right.container.setAttribute("data-vivliostyle-unpaired-page",!0))}reportPosition(){let e=oo("reportPosition");return this.pagePosition,this.opf.getCFI(this.pagePosition.spineIndex,this.pagePosition.offsetInItem).then(t=>{let i=this.currentPage;(this.waitForLoading&&i.fetchers.length>0?bo(i.fetchers):so(!0)).then(()=>{this.sendLocationNotification(i,t).thenFinish(e)})}),e.result()}createViewport(){let e=this.viewportElement;if(this.viewportSize){let t=this.viewportSize;return e.style.marginLeft=`${t.marginLeft}px`,e.style.marginRight=`${t.marginRight}px`,e.style.marginTop=`${t.marginTop}px`,e.style.marginBottom=`${t.marginBottom}px`,new qm(this.window,this.fontSize,this.pixelRatio,e,t.width,t.height)}return new qm(this.window,this.fontSize,this.pixelRatio,e)}resolveSpreadView(e,t){switch(this.pageViewMode){case"singlePage":return!1;case"spread":return!0;default:return null!=e&&(e.width-this.pref.pageBorder)/e.height>=(t?2*t.width/t.height:1.45)&&(!!t||e.width>800)}}updateSpreadView(e){this.pref.spreadView=e,this.viewportElement.setAttribute("data-vivliostyle-spread-view",e.toString())}sizeIsGood(){var e;let t=this.createViewport(),i=(null==(e=this.opfView)?void 0:e.hasPages())&&!this.opfView.hasAutoSizedPages(),n=this.resolveSpreadView(t,this.resized&&i?this.pageSizes[0]:null);this.resized=!1;let r=this.pref.spreadView!==n;return this.updateSpreadView(n),!(this.pixelRatio&&this.opfView&&this.pixelRatio/this.window.devicePixelRatio!==this.opfView.clientLayout.scaleRatio||this.viewportSize||!this.viewport||this.viewport.fontSize!=this.fontSize)&&(!!(!r&&t.width==this.viewport.width&&t.height==this.viewport.height||!r&&t.width==this.viewport.width&&t.height!=this.viewport.height&&/Android|iPhone|iPad|iPod/.test(navigator.userAgent))||!!i&&(this.viewport.width=t.width,this.viewport.height=t.height,this.needRefresh=!0,!0))}setPageSize(e,t,i,n){this.pageSizes[n]=e,this.setPageSizePageRules(t,i,n),0===n&&"autoSpread"===this.pageViewMode&&!this.opfView.hasAutoSizedPages()&&this.updateSpreadView(this.resolveSpreadView(this.viewport,e))}setPageSizePageRules(e,t,i){var n,r;if(this.pageRuleStyleElement&&(!this.pageSheetSizeAlreadySet||this.pageSizes[i].width!==(null==(n=this.pageSizes[i-1])?void 0:n.width)||this.pageSizes[i].height!==(null==(r=this.pageSizes[i-1])?void 0:r.height))){let e=function(e){let t=.75*e;return Math.ceil(t)},t=Math.max(...this.pageSizes.map(e=>e.width)),i=Math.max(...this.pageSizes.map(e=>e.height)),n=e(t),r=e(i),o=`@page {size: ${n}pt ${r}pt; margin: 0 ${-(n*((this.pixelRatio||1)-1)+2)}pt ${-(r*((this.pixelRatio||1)-1)+2)}pt 0;}`;this.pageRuleStyleElement.textContent=o,this.pageSheetSizeAlreadySet=!0}}removePageSizePageRules(){this.pageRuleStyleElement&&(this.pageRuleStyleElement.textContent="",this.pageSheetSizeAlreadySet=!1)}loadCmykReserveMap(e){if(!this.cmykReserveMapUrl)return this.cmykReserveMap=void 0,so(!0);let t=ue(pe(this.cmykReserveMapUrl),oe),i=oo("loadCmykReserveMap");return e.loadAsJSON(t).then(e=>{!function(e){return!!Array.isArray(e)&&e.every(e=>{if(!Array.isArray(e)||2!==e.length)return!1;let[t,i]=e;if(!t||"object"!=typeof t||Array.isArray(t)||!i||"object"!=typeof i||Array.isArray(i))return!1;let n=t,r=i;return Number.isFinite(n.r)&&Number.isFinite(n.g)&&Number.isFinite(n.b)&&Number.isFinite(r.c)&&Number.isFinite(r.m)&&Number.isFinite(r.y)&&Number.isFinite(r.k)})}(e)?(R.warn("Invalid cmykReserveMap data, ignoring"),this.cmykReserveMap=void 0):this.cmykReserveMap=e,i.finish(!0)}),i.result()}reset(){let e=!1,t=!1;this.opfView&&(e=this.opfView.tocVisible,t=this.opfView.tocAutohide,this.opfView.removeRenderedPages()),this.pageSizes=[],this.removePageSizePageRules(),this.viewport=this.createViewport(),this.viewport.resetZoom(),this.opfView=new Yy(this.opf,this.viewport,this.fontMapper,this.pref,this.setPageSize.bind(this),this.cmykReserveMap),e&&this.sendCommand({a:"toc",v:"show",autohide:t})}showCurrent(e,t){this.needRefresh=!1,this.removePageListeners();let i=this.resolveSpreadView(this.viewport,e.dimensions);return i!==this.pref.spreadView&&this.updateSpreadView(i),i?this.opfView.getSpread(this.pagePosition,!!t).thenAsync(t=>t.left||t.right?!t.left||!t.right||this.resolveSpreadView(this.viewport,t.left.dimensions)&&this.resolveSpreadView(this.viewport,t.right.dimensions)?(this.showSpread(t),this.setSpreadZoom(t),this.currentPage="left"===e.side?t.left:t.right,so(null)):(this.updateSpreadView(!1),this.showPage(e),this.setPageZoom(e),this.currentPage=e,so(null)):so(null)):(this.showPage(e),this.setPageZoom(e),this.currentPage=e,so(null))}setPageZoom(e){var t;let i=this.getAdjustedZoomFactor(e.dimensions);null==(t=this.viewport)||t.zoom(e.dimensions.width,e.dimensions.height,i)}setSpreadZoom(e){var t;let i=this.getSpreadDimensions(e);null==(t=this.viewport)||t.zoom(i.width,i.height,this.getAdjustedZoomFactor(i))}getAdjustedZoomFactor(e){return this.fitToScreen?this.calculateZoomFactorToFitInsideViewPort(e):this.zoom}getSpreadDimensions(e){let t=0,i=0;return e.left&&(t+=e.left.dimensions.width,i=e.left.dimensions.height),e.right&&(t+=e.right.dimensions.width,i=Math.max(i,e.right.dimensions.height)),e.left&&e.right&&(t+=2*this.pref.pageBorder,t+=Math.abs(e.left.dimensions.width-e.right.dimensions.width)),{width:t,height:i}}queryZoomFactor(e){if(!this.currentPage)throw new Error("no page exists.");if("fit inside viewport"===e){let e;return this.pref.spreadView?(this.currentSpread,e=this.getSpreadDimensions(this.currentSpread)):e=this.currentPage.dimensions,this.calculateZoomFactorToFitInsideViewPort(e)}throw new Error(`unknown zoom type: ${e}`)}calculateZoomFactorToFitInsideViewPort(e){if(!this.viewport)return this.zoom;let t=this.viewport.width/e.width,i=this.viewport.height/e.height;return Math.min(t,i)}cancelRenderingTask(){this.renderTask&&this.renderTask.interrupt(new eb),this.renderTask=null}resize(){if(this.needResize=!1,this.needRefresh=!1,this.sizeIsGood())return so(!0);this.setReadyState("loading"),this.cancelRenderingTask();let e=ro().getScheduler().run(()=>ao("resize",t=>{this.opf?(this.renderTask=e,G.registerStartTiming("render (resize)"),this.reset(),this.pagePosition&&(0==this.pagePosition.pageIndex&&0==this.pagePosition.offsetInItem||(this.pagePosition.pageIndex=-1)),this.opf.setEPageCountMode(this.renderAllPages),this.opfView.renderPagesUpto(this.pagePosition,!this.renderAllPages).then(i=>{i?(this.pagePosition=i.position,this.showCurrent(i.page,!0).then(()=>{this.setReadyState("interactive"),this.opf.countEPages(e=>{let t={t:"nav",epageCount:e,first:this.currentPage.isFirstPage,last:this.isLastPageForNotification(this.currentPage),metadata:this.opf.metadata,docTitle:this.opf.spine[this.pagePosition.spineIndex].title};(this.currentPage.isFirstPage||0==this.pagePosition.pageIndex&&this.opf.spine[this.pagePosition.spineIndex].epage)&&(t.epage=this.opf.spine[this.pagePosition.spineIndex].epage),this.callback(t)}).then(()=>{this.reportPosition().then(i=>{(this.renderAllPages?this.opfView.renderAllPages():so(null)).then(()=>{this.renderTask===e&&(this.renderTask=null),G.registerEndTiming("render (resize)"),Am&&Bm(this.window)?function(e){if(!Am)return so(!1);let t=oo("loadScripts");return t.loop(()=>0===Fm.length?so(!1):Lm(Fm.shift(),e,{atEnd:!0}).thenReturn(Fm.length>0)).then(()=>{R.debug("dispatchEvent: DOMContentLoaded (window)"),e.dispatchEvent(new Event("DOMContentLoaded")),R.debug("dispatchEvent: load (window)"),e.dispatchEvent(new Event("load")),t.finish(!0)}),t.result()}(this.window).then(()=>{this.renderAllPages&&this.setReadyState("complete"),this.callback({t:"loaded"}),t.finish(i)}):(this.renderAllPages&&this.setReadyState("complete"),this.callback({t:"loaded"}),t.finish(i))})})})})):t.finish(!1)})):t.finish(!1)},(e,t)=>{if(!(t instanceof eb))throw t;G.registerEndTiming("render (resize)"),R.debug(t.message)}));return so(!0)}sendLocationNotification(e,t){let i=oo("sendLocationNotification"),n={t:"nav",first:e.isFirstPage,last:this.isLastPageForNotification(e),metadata:this.opf.metadata,docTitle:this.opf.spine[e.spineIndex].title};return this.opf.getEPageFromPosition(this.pagePosition).then(e=>{n.epage=e,n.epageCount=this.opf.epageCount,t&&(n.cfi=t),this.callback(n),i.finish(!0)}),i.result()}isLastPageForNotification(e){if(!this.opfView||!this.pagePosition)return e.isLastPage;let t=this.opfView.spineItems[this.pagePosition.spineIndex];if(!t||!t.complete)return!1;let i=t.item.spineIndex===this.opf.spine.length-1,n=this.pagePosition.pageIndex===t.pages.length-1;return i&&n}getCurrentPageProgression(){return this.opfView?this.opfView.getCurrentPageProgression(this.pagePosition):null}moveTo(e){var t;let i;if("complete"!==this.readyState&&"next"!==e.where&&this.setReadyState("loading"),"string"==typeof e.where){let t;switch(e.where){case"next":t=this.pref.spreadView?this.opfView.nextSpread:this.opfView.nextPage;break;case"previous":t=this.pref.spreadView?this.opfView.previousSpread:this.opfView.previousPage;break;case"last":t=this.opfView.lastPage;break;case"first":t=this.opfView.firstPage;break;default:return so(!0)}i=()=>t.call(this.opfView,this.pagePosition,!this.renderAllPages)}else if("number"==typeof e.epage){let t=e.epage;i=()=>this.opfView.navigateToEPage(t,this.pagePosition,!this.renderAllPages)}else if("string"==typeof e.url){let t=e.url;i=()=>this.opfView.navigateTo(t,this.pagePosition,!this.renderAllPages)}else{if("number"!=typeof(null==(t=e.position)?void 0:t.spineIndex))return so(!0);{let t=e.position;i=()=>this.opfView.findPage(t,!this.renderAllPages)}}if(!this.opfView)return so(!0);let n=oo("moveTo");return i.call(this.opfView).then(e=>{let t;if(e){this.pagePosition=e.position;let i=oo("moveTo.showCurrent");t=i.result(),this.showCurrent(e.page,!this.renderAllPages).then(()=>{this.reportPosition().thenFinish(i)})}else t=so(!0);t.then(e=>{"loading"===this.readyState&&this.setReadyState("interactive"),n.finish(e)})}),n.result()}showTOC(e){let t=!!e.autohide,i=e.v,n=this.opfView.isTOCVisible(),r=t!=this.opfView.tocAutohide&&"hide"!=i;if(n){if("show"==i&&!r)return so(!0)}else if("hide"==i)return so(!0);if(n&&"show"!=i)return this.opfView.hideTOC(),so(!0);{let e=oo("showTOC");return this.opfView.showTOC(t).then(i=>{if(i){if(r&&(i.listeners={}),t){let e=()=>{this.opfView.hideTOC()};i.addEventListener("hyperlink",e,!1)}i.addEventListener("hyperlink",this.hyperlinkListener,!1)}e.finish(!0)}),e.result()}}runCommand(e){let t=e.a||"";return ao("runCommand",i=>{let n=this.actions[t];n?n.call(this,e).then(()=>{this.callback({t:"done",a:t}),i.finish(!0)}):(R.error("No such action:",t),i.finish(!0))},(e,i)=>{R.error(i,"Error during action:",t),e.finish(!0)})}initEmbed(e){let t=tb(e),i=null,n=this;lo(()=>{let e=oo("commandLoop"),r=ro().getScheduler();return n.hyperlinkListener=e=>{let t=e,i="#"===t.href.charAt(0)||n.packageURL.some(e=>t.href.substr(0,e.length)==e);if(i){e.preventDefault();let o={t:"hyperlink",href:t.href,internal:i};r.run(()=>(n.callback(o),so(!0)))}},e.loopWithFrame(e=>{if(n.needResize)n.resize().then(()=>{e.continueLoop()});else if(n.needRefresh)n.currentPage&&n.showCurrent(n.currentPage,!this.renderAllPages).then(()=>{e.continueLoop()});else if(t){let i=t;t=null,n.runCommand(i).then(()=>{e.continueLoop()})}else{let t=oo("waitForCommand");i=t.suspend(this),t.result().then(()=>{e.continueLoop()})}}).thenFinish(e),e.result()}),n.kick=()=>{let e=i;e&&(i=null,e.schedule(!0))},n.sendCommand=e=>!t&&(t=tb(e),n.kick(),!0),this.window.adapt_command=n.sendCommand}},Qy=(e=>(e.FIT_INSIDE_VIEWPORT="fit inside viewport",e))(Qy||{}),eb=class e extends Error{constructor(){var t;super(),h(this,"name","RenderingCanceledError"),h(this,"message","Page rendering has been canceled"),h(this,"stack"),Object.setPrototypeOf(this,e.prototype),this.stack=null!=(t=(new Error).stack)?t:""}};function tb(e){return"string"==typeof e?J(e):e}var ib=S;function nb(e){let t={};return Object.keys(e).forEach(i=>{let n=e[i];switch(i){case"autoResize":t.autoresize=n;break;case"pageBorderWidth":t.pageBorder=n;break;default:t[i]=n}}),t}var rb=class{constructor(e,t){h(this,"settings",e),h(this,"initialized",!1),h(this,"adaptViewer_"),h(this,"options"),h(this,"eventTarget"),w(!!e.debug),this.adaptViewer_=new Jy(e.window||window,e.viewportElement,"main",this.dispatcher.bind(this)),this.options={autoResize:!0,fontSize:16,pageBorderWidth:1,renderAllPages:!0,pageViewMode:"autoSpread",zoom:1,fitToScreen:!1,defaultPaperSize:void 0,allowScripts:!0,pixelRatio:8},t&&this.setOptions(t),this.eventTarget=new De,Object.defineProperty(this,"readyState",{get(){return this.adaptViewer_.readyState}})}setOptions(e){let t=Object.assign({a:"configure"},nb(e));this.adaptViewer_.sendCommand(t),Object.assign(this.options,e)}dispatcher(e){let t={type:e.t},i=e;Object.keys(i).forEach(e=>{"t"!==e&&(t[e]=i[e])}),this.eventTarget.dispatchEvent(t)}addListener(e,t){"paginationprogress"===e&&this.adaptViewer_.ensurePaginationProgressListener(),this.eventTarget.addEventListener(e,t,!1)}removeListener(e,t){var i;this.eventTarget.removeEventListener(e,t,!1),"paginationprogress"===e&&(null==(i=this.eventTarget.listeners[e])||!i.length)&&this.adaptViewer_.removePaginationProgressListener()}loadDocument(e,t,i){e&&(Array.isArray(e)?e[0]&&("string"==typeof e[0]||e[0].url):"string"==typeof e||e.url)?this.loadDocumentOrPublication(e,null,t,i):this.eventTarget.dispatchEvent({type:"error",content:{error:new Error("No URL specified")}})}loadPublication(e,t,i){e?this.loadDocumentOrPublication(null,e,t,i):this.eventTarget.dispatchEvent({type:"error",content:{error:new Error("No URL specified")}})}loadDocumentOrPublication(e,t,i,n){let r=i||{};function o(e){if(e)return e.flatMap(e=>{let t=e.url||null,i=e.text||null;return null!==i?[{url:t,text:i}]:null!==t?[{url:t}]:[]})}let s=o(r.authorStyleSheet),a=o(r.userStyleSheet);n&&Object.assign(this.options,n);let l=Object.assign({a:e?"loadXML":"loadPublication",userAgentRootURL:this.settings.userAgentRootURL,url:ob(e)||t,document:r.documentObject,fragment:r.fragment,authorStyleSheet:s,userStyleSheet:a,cmykReserveMapUrl:r.cmykReserveMapUrl},nb(this.options));this.initialized?this.adaptViewer_.sendCommand(l):(this.initialized=!0,this.adaptViewer_.initEmbed(l))}getCurrentPageProgression(){return this.adaptViewer_.getCurrentPageProgression()}resolveNavigation(e){switch(e){case"left":return this.getCurrentPageProgression()===ib.LTR?"previous":"next";case"right":return this.getCurrentPageProgression()===ib.LTR?"next":"previous";default:return e}}navigateToPage(e,t){"epage"===e?this.adaptViewer_.sendCommand({a:"moveTo",epage:t}):this.adaptViewer_.sendCommand({a:"moveTo",where:this.resolveNavigation(e)})}navigateToInternalUrl(e){this.adaptViewer_.sendCommand({a:"moveTo",url:e})}navigateToPosition(e){var t,i;this.adaptViewer_.sendCommand({a:"moveTo",position:{spineIndex:e.spineIndex,pageIndex:null!=(t=e.pageIndex)?t:-1,offsetInItem:null!=(i=e.offsetInItem)?i:-1}})}isTOCVisible(){return this.adaptViewer_.opfView&&this.adaptViewer_.opfView.opf&&this.adaptViewer_.opfView.opf.toc?!!this.adaptViewer_.opfView.isTOCVisible():null}showTOC(e,t){let i=null==e?"toggle":e?"show":"hide";this.adaptViewer_.sendCommand({a:"toc",v:i,autohide:t})}queryZoomFactor(e){return this.adaptViewer_.queryZoomFactor(e)}getPageSizes(){return this.adaptViewer_.pageSizes}getTOC(){var e,t,i;return null!=(i=null==(t=null==(e=this.adaptViewer_.opfView)?void 0:e.tocView)?void 0:t.getTOC())?i:[]}getMetadata(){return this.adaptViewer_.opf.getMetadata()}getCover(){return this.adaptViewer_.opf.cover}getCmykMap(){var e;let t=null==(e=this.adaptViewer_)?void 0:e.opfView;return null!=t&&t.cmykStore?t.cmykStore.toJSON():{}}};function ob(e){function t(e){return"number"==typeof e?e:null}function i(e){return"string"==typeof e?{url:e,startPage:null,skipPagesBefore:null}:{url:e.url,startPage:t(e.startPage),skipPagesBefore:t(e.skipPagesBefore)}}return Array.isArray(e)?e.map(i):e?[i(e)]:null}var sb,ab=((sb=ab||{}).PREVIOUS="previous",sb.NEXT="next",sb.LEFT="left",sb.RIGHT="right",sb.FIRST="first",sb.LAST="last",sb.EPAGE="epage",sb),lb=Qy,hb=Zy;G.forceRegisterEndTiming("load_vivliostyle");var ub=class{constructor(e,{title:t="",printCallback:i=e=>e.print(),errorCallback:n=null,hideIframe:r=!0,removeIframe:o=!0}){h(this,"htmlDoc"),h(this,"title"),h(this,"printCallback"),h(this,"errorCallback"),h(this,"hideIframe"),h(this,"removeIframe"),h(this,"iframe"),h(this,"iframeWin",null),h(this,"window"),this.htmlDoc=e,this.title=t,this.printCallback=i,this.errorCallback=n,this.hideIframe=r,this.removeIframe=o,this.iframe=document.createElement("iframe"),this.hideIframe&&(this.iframe.style.width="0",this.iframe.style.height="0",this.iframe.style.borderWidth="0"),this.window=window,this.window.printInstance=this,this.iframe.srcdoc=`\n <!DOCTYPE html>\n <html data-vivliostyle-paginated="true">\n <head>\n <meta charset='utf-8'/>\n <meta name='viewport' content='width=device-width, initial-scale=1.0'/>\n <title>${this.title}</title>\n <style>\n html[data-vivliostyle-paginated] {\n width: 100%;\n height: 100%;\n }\n html[data-vivliostyle-paginated] body,\n html[data-vivliostyle-paginated] [data-vivliostyle-viewer-viewport] {\n width: 100% !important;\n height: 100% !important;\n }\n html[data-vivliostyle-paginated],\n html[data-vivliostyle-paginated] body {\n margin: 0;\n padding: 0;\n }\n </style>\n <style id='vivliostyle-page-rules'></style>\n </head>\n <body onload='parent.printInstance.runInIframe(window)'>\n <div id="vivliostyle-viewer-viewport"></div>\n </body>\n </html>`,document.body.appendChild(this.iframe)}runInIframe(e){return this.iframeWin=e,this.preparePrint().then(()=>this.browserPrint()).then(()=>this.cleanUp())}preparePrint(){this.iframeWin.document.title=this.title;let e=new Blob([this.htmlDoc],{type:"text/html"}),t=URL.createObjectURL(e),i=new rb({viewportElement:this.iframeWin.document.body.firstElementChild,window:this.iframeWin,debug:!0});return new Promise(e=>{i.addListener("readystatechange",()=>{"complete"===i.readyState&&e()}),this.errorCallback&&i.addListener("error",e=>{var t,i;let n=null!=(i=null==(t=e.content.error)?void 0:t.toString())?i:e.content.messages.join("\n");this.errorCallback(n)}),i.loadDocument({url:t})})}browserPrint(){this.printCallback(this.iframeWin)}cleanUp(){delete this.window.printInstance,this.removeIframe&&this.iframe.remove()}};function cb(e,t){new ub(e,t)}return c}(),v=e({__proto__:null,default:t(m)},[m]);!function(e){e.Default="",e.Auto="auto",e.Preset="preset",e.Custom="custom",e.Zero="0"}(g||(g={}));const y=[{name:"letter",description:"Letter"},{name:"legal",description:"Legal"},{name:"ledger",description:"Ledger"},{name:"a10",description:"A10"},{name:"a9",description:"A9"},{name:"a8",description:"A8"},{name:"a7",description:"A7"},{name:"a6",description:"A6"},{name:"a5",description:"A5"},{name:"a4",description:"A4"},{name:"a3",description:"A3"},{name:"a2",description:"A2"},{name:"a1",description:"A1"},{name:"a0",description:"A0"},{name:"b10",description:"B10 (ISO)"},{name:"b9",description:"B9 (ISO)"},{name:"b8",description:"B8 (ISO)"},{name:"b7",description:"B7 (ISO)"},{name:"b6",description:"B6 (ISO)"},{name:"b5",description:"B5 (ISO)"},{name:"b4",description:"B4 (ISO)"},{name:"b3",description:"B3 (ISO)"},{name:"b2",description:"B2 (ISO)"},{name:"b1",description:"B1 (ISO)"},{name:"b0",description:"B0 (ISO)"},{name:"jis-b10",description:"JIS-B10"},{name:"jis-b9",description:"JIS-B9"},{name:"jis-b8",description:"JIS-B8"},{name:"jis-b7",description:"JIS-B7"},{name:"jis-b6",description:"JIS-B6"},{name:"jis-b5",description:"JIS-B5"},{name:"jis-b4",description:"JIS-B4"},{name:"jis-b3",description:"JIS-B3"},{name:"jis-b2",description:"JIS-B2"},{name:"jis-b1",description:"JIS-B1"},{name:"jis-b0",description:"JIS-B0"},{name:"c10",description:"C10"},{name:"c9",description:"C9"},{name:"c8",description:"C8"},{name:"c7",description:"C7"},{name:"c6",description:"C6"},{name:"c5",description:"C5"},{name:"c4",description:"C4"},{name:"c3",description:"C3"},{name:"c2",description:"C2"},{name:"c1",description:"C1"},{name:"c0",description:"C0"}],b={customWidth:"210mm",customHeight:"297mm",customMargin:"10%",baseFontSize:"12pt",baseLineHeight:"1.2",baseFontFamily:"serif",viewerFontSize:16,cropMarks:"crop cross",bleed:"3mm",cropOffset:"9mm"};class w{constructor(e){this.PresetSize=w.PresetSize,this.pageSizeMode=a.observable(g.Default),this.presetSize=a.observable(y[9]),this.isLandscape=a.observable(!1),this.customWidth=a.observable(b.customWidth),this.customHeight=a.observable(b.customHeight),this.pageSizeImportant=a.observable(!1),this.pageMarginMode=a.observable(g.Default),this.customMargin=a.observable(b.customMargin),this.pageMarginImportant=a.observable(!1),this.firstPageMarginZero=a.observable(!1),this.firstPageMarginZeroImportant=a.observable(!1),this.forceHtmlBodyMarginZero=a.observable(!1),this.widowsOrphans=a.observable(""),this.widowsOrphansImportant=a.observable(!1),this.imageMaxSizeToFitPage=a.observable(!1),this.imageMaxSizeToFitPageImportant=a.observable(!1),this.imageKeepAspectRatio=a.observable(!1),this.imageKeepAspectRatioImportant=a.observable(!1),this.baseFontSize=a.observable(b.baseFontSize),this.baseFontSizeSpecified=a.observable(!1),this.baseFontSizeImportant=a.observable(!1),this.baseLineHeight=a.observable(b.baseLineHeight),this.baseLineHeightSpecified=a.observable(!1),this.baseLineHeightImportant=a.observable(!1),this.baseFontFamily=a.observable(b.baseFontFamily),this.baseFontFamilySpecified=a.observable(!1),this.baseFontFamilyImportant=a.observable(!1),this.cropMarks=a.observable(b.cropMarks),this.cropMarksSpecified=a.observable(!1),this.cropMarksImportant=a.observable(!1),this.bleed=a.observable(b.bleed),this.bleedSpecified=a.observable(!1),this.bleedImportant=a.observable(!1),this.cropOffset=a.observable(b.cropOffset),this.cropOffsetSpecified=a.observable(!1),this.cropOffsetImportant=a.observable(!1),this.customStyleAsUserStyle=a.observable(!1),this.allImportant=a.observable(!1),this.pageOtherStyle=a.observable(""),this.firstPageOtherStyle=a.observable(""),this.rootOtherStyle=a.observable(""),this.beforeOtherStyle=a.observable(""),this.afterOtherStyle=a.observable(""),this.viewerFontSize=null,this.setViewerFontSizeObservable=e=>{this.viewerFontSize=e;const t=document.getElementsByName("vivliostyle-settings_viewer-font-size")[0];t&&(t.value=this.fontSizePxToPercent(Number(e()),100,5).toString())},this.viewerFontSizePercent=a.pureComputed({read(){if(!this.viewerFontSize)return 100;return this.fontSizePxToPercent(Number(this.viewerFontSize()),100,5)},write(e){if(!this.viewerFontSize)return;const t=parseFloat(String(e));let i=t&&this.fontSizePercentToPx(t);if(!i||Number(i)<5||Number(i)>72){const e=document.getElementsByName("vivliostyle-settings_viewer-font-size")[0];e&&(e.value="100"),i=b.viewerFontSize}this.viewerFontSize(Number(i))},owner:this}),this.cssText=a.pureComputed({read:this.toCSSText,write:this.fromCSSText,owner:this}),this.allImportant.subscribe(e=>{this.pageSizeImportant(e),this.pageMarginImportant(e),this.firstPageMarginZeroImportant(e),this.widowsOrphansImportant(e),this.imageMaxSizeToFitPageImportant(e),this.imageKeepAspectRatioImportant(e),this.baseFontSizeImportant(e),this.baseLineHeightImportant(e),this.baseFontFamilyImportant(e),this.cropMarksImportant(e),this.bleedImportant(e),this.cropOffsetImportant(e)}),this.cropMarksSpecified.subscribe(e=>{e?this.bleedSpecified(!0):(this.bleedSpecified(!1),this.cropOffsetSpecified(!1))}),this.pageStyleRegExp=new RegExp("^((?:\\n|.)*?)\\/\\*<viewer>\\*\\/\\s*(?:@page\\s*\\{\\s*(?:size:\\s*([^\\s!;{}]+)(?:\\s+([^\\s!;{}]+))?\\s*(!important)?(?:;|(?=[\\s{}]))\\s*)?(?:margin:\\s*([^\\s!;{}]+(?:\\s+[^\\s!;{}]+)?(?:\\s+[^\\s!;{}]+)?(?:\\s+[^\\s!;{}]+)?)\\s*(!important)?(?:;|(?=[\\s{}]))\\s*)?(?:marks:\\s*([^\\s!;{}]+(?:\\s+[^\\s!;{}]+)?)\\s*(!important)?(?:;|(?=[\\s{}]))\\s*)?(?:bleed:\\s*([^\\s!;{}]+)\\s*(!important)?(?:;|(?=[\\s{}]))\\s*)?(?:crop-offset:\\s*([^\\s!;{}]+)\\s*(!important)?(?:;|(?=[\\s{}]))\\s*)?((?:[^{}]+|\\{[^{}]*\\})*)\\}\\s*)?(?:@page\\s*:first\\s*\\{\\s*(margin:\\s*0(?:\\w+|%)?\\s*(!important)?(?:;|(?=[\\s{}]))\\s*)?((?:[^{}]+|\\{[^{}]*\\})*)\\}\\s*)?((?:html|:root),\\s*body\\s*\\{\\s*margin:\\s*0(?:\\w+|%)?\\s*!important(?:;|(?=[\\s{}]))\\s*\\}\\s*)?(?:(?:html|:root)\\s*\\{\\s*(?:font-size:\\s*(calc\\([^()]+\\)|[^\\s!;{}]+)\\s*(!important)?(?:;|(?=[\\s{}]))\\s*)?(?:line-height:\\s*([^\\s!;{}]+)\\s*(!important)?(?:;|(?=[\\s{}]))\\s*)?(?:font-family:\\s*([^!;{}]+)\\s*(!important)?(?:;|(?=[\\s{}]))\\s*)?([^{}]*)\\}\\s*)?(?:body\\s*\\{\\s*(?:[-\\w]+:\\s*inherit\\s*!important(?:;|(?=[\\s{}]))\\s*)+\\}\\s*)?(?:\\*\\s*\\{\\s*widows:\\s*(1|999)\\s*(!important)?(?:;|(?=[\\s{}]))\\s*orphans:\\s*\\25\\s*\\26(?:;|(?=[\\s{}]))\\s*\\}\\s*)?(?:img,\\s*svg\\s*\\{\\s*(max-inline-size:\\s*100%\\s*(!important)?(?:;|(?=[\\s{}]))\\s*max-block-size:\\s*100vb\\s*\\28(?:;|(?=[\\s{}]))\\s*)?(object-fit:\\s*contain\\s*(!important)?(?:;|(?=[\\s{}]))\\s*)?\\}\\s*)?((?:\\n|.)*)$"),e&&this.copyFrom(e)}fontSizePxToPercent(e,t,i){let n=e/b.viewerFontSize*(t||100);return i&&(n=n.toPrecision(i).replace(/(?:\.0*|(\.\d*?)0+)$/,"$1")),n}fontSizePercentToPx(e,t,i){let n=e/(t||100)*b.viewerFontSize;return i&&(n=n.toPrecision(i).replace(/(?:\.0*|(\.\d*?)0+)$/,"$1")),n}fromCSSText(e){const t=this.pageStyleRegExp.exec(e);if(t){const[,e,i,n,r,o,s,a,l,h,u,c,d,p,f,m,v,b,w,x,S,C,k,P,E,N,T,I,A,F,R,O]=t;let L=O,_=k,B=w,M=v,D=p,z=E,V=i,U=n,H=0,$=0;if(this.beforeOtherStyle(e),"landscape"==V||"portrait"==V?(this.isLandscape("landscape"==V),V=U,U=null):"landscape"!=U&&"portrait"!=U||(this.isLandscape("landscape"==U),U=null),null!=V){if(null==U)if("auto"==V)this.pageSizeMode(g.Auto);else{const e=y.find(e=>e.name.toLowerCase()==V.toLowerCase());e?(this.pageSizeMode(g.Preset),this.presetSize(e)):(this.pageSizeMode(g.Custom),this.customWidth(V),this.customHeight(V))}else this.pageSizeMode(g.Custom),this.customWidth(V),this.customHeight(U);this.pageSizeImportant(!!r),r?H++:$++}else this.pageSizeMode(g.Default);null!=o?(this.pageMarginMode("0"==o?g.Zero:g.Custom),"0"==o?this.pageMarginMode(g.Zero):(this.pageMarginMode(g.Custom),this.customMargin(o)),this.pageMarginImportant(!!s),s?H++:$++):this.pageMarginMode(g.Default),null!=a?(this.cropMarksSpecified(!0),this.cropMarks(a),this.cropMarksImportant(!!l),l?H++:$++):this.cropMarksSpecified(!1),null!=h?(this.bleedSpecified(!0),this.bleed(h),this.bleedImportant(!!u),u?H++:$++):this.bleedSpecified(!1),null!=c?(this.cropOffsetSpecified(!0),this.cropOffset(c),this.cropOffsetImportant(!!d),d?H++:$++):this.cropOffsetSpecified(!1),D=D||"",this.pageOtherStyle(D),f?(this.firstPageMarginZero(!0),this.firstPageMarginZeroImportant(!!m),m?H++:$++):this.firstPageMarginZero(!1),M=M||"",this.firstPageOtherStyle(M),b?this.forceHtmlBodyMarginZero(!0):this.forceHtmlBodyMarginZero(!1),null!=B?(B=B.replace(/^\s*calc\([.\d]+\s*\*\s*([.\d]+\w+)\)\s*$/,"$1"),this.baseFontSizeSpecified(!0),this.baseFontSize(B),this.baseFontSizeImportant(!!x),x?H++:$++):this.baseFontSizeSpecified(!1),null!=S?(this.baseLineHeightSpecified(!0),this.baseLineHeight(S),this.baseLineHeightImportant(!!C),C?H++:$++):this.baseLineHeightSpecified(!1),null!=_?(_=_.trim(),this.baseFontFamilySpecified(!0),this.baseFontFamily(_),this.baseFontFamilyImportant(!!P),P?H++:$++):this.baseFontFamilySpecified(!1),z=z||"",this.rootOtherStyle(z),null!=N?(this.widowsOrphans(N),this.widowsOrphansImportant(!!T),T?H++:$++):this.widowsOrphans(g.Default),I?(this.imageMaxSizeToFitPage(!0),this.imageMaxSizeToFitPageImportant(!!A),A?H++:$++):this.imageMaxSizeToFitPage(!1),F?(this.imageKeepAspectRatio(!0),this.imageKeepAspectRatioImportant(!!R),R?H++:$++):this.imageKeepAspectRatio(!1),L=L.replace(/\/\*<\/?viewer>\*\/\n?/g,"")||"",this.afterOtherStyle(L),this.allImportant(H>0&&0==$)}else{const t=e.replace(/\/\*<\/?viewer>\*\/\n?/g,"")||"";this.afterOtherStyle(t)}}toCSSText(){function e(e){return e?" !important":""}let t=this.beforeOtherStyle();if(t+="/*<viewer>*/\n",this.pageSizeMode()!=g.Default||this.pageMarginMode()!=g.Default||this.cropMarksSpecified()||this.bleedSpecified()||this.cropOffsetSpecified()||this.pageOtherStyle()){if(t+="@page { ",this.pageSizeMode()!=g.Default){switch(t+="size: ",this.pageSizeMode()){case g.Auto:t+="auto";break;case g.Preset:t+=this.presetSize().name,this.isLandscape()&&(t+=" landscape");break;case g.Custom:t+=`${this.customWidth()} ${this.customHeight()}`;break;default:throw new Error(`Unknown pageSizeMode ${this.pageSizeMode()}`)}t+=`${e(this.pageSizeImportant())}; `}if(this.pageMarginMode()!=g.Default){switch(t+="margin: ",this.pageMarginMode()){case g.Auto:t+="auto";break;case g.Zero:t+="0";break;case g.Custom:t+=`${this.customMargin()}`;break;default:throw new Error(`Unknown pageMarginMode ${this.pageMarginMode()}`)}t+=`${e(this.pageMarginImportant())}; `}this.cropMarksSpecified()&&(t+=`marks: ${this.cropMarks()}${e(this.cropMarksImportant())}; `),this.bleedSpecified()&&(t+=`bleed: ${this.bleed()}${e(this.bleedImportant())}; `),this.cropOffsetSpecified()&&(t+=`crop-offset: ${this.cropOffset()}${e(this.cropOffsetImportant())}; `),t+=this.pageOtherStyle(),t+="}\n"}if((this.firstPageMarginZero()||this.firstPageOtherStyle())&&(t+="@page :first { ",this.firstPageMarginZero()&&(t+=`margin: 0${e(this.firstPageMarginZeroImportant())}; `),t+=this.firstPageOtherStyle(),t+="}\n"),this.forceHtmlBodyMarginZero()&&(t+=":root, body { margin: 0 !important; }\n"),this.baseFontSizeSpecified()||this.baseLineHeightSpecified()||this.baseFontFamilySpecified()||this.rootOtherStyle()){t+=":root { ";const i=this.baseFontSize();if(this.baseFontSizeSpecified())if(this.viewerFontSize&&this.viewerFontSize()!=b.viewerFontSize&&!i.endsWith("%")){t+=`font-size: calc(${this.fontSizePxToPercent(Number(this.viewerFontSize()),1,5)} * ${i})${e(this.baseFontSizeImportant())}; `}else t+=`font-size: ${this.baseFontSize()}${e(this.baseFontSizeImportant())}; `;this.baseLineHeightSpecified()&&(t+=`line-height: ${this.baseLineHeight()}${e(this.baseLineHeightImportant())}; `),this.baseFontFamilySpecified()&&(t+=`font-family: ${this.baseFontFamily()}${e(this.baseFontFamilyImportant())}; `),t+=this.rootOtherStyle(),t+="}\n"}return(this.baseFontSizeSpecified()&&this.baseFontSizeImportant()||this.baseLineHeightSpecified()&&this.baseLineHeightImportant()||this.baseFontFamilySpecified()&&this.baseFontFamilyImportant())&&(t+="body { ",this.baseFontSizeSpecified()&&this.baseFontSizeImportant()&&(t+="font-size: inherit !important; "),this.baseLineHeightSpecified()&&this.baseLineHeightImportant()&&(t+="line-height: inherit !important; "),this.baseFontFamilySpecified()&&this.baseFontFamilyImportant()&&(t+="font-family: inherit !important; "),t+="}\n"),this.widowsOrphans()&&(t+="* { ",t+=`widows: ${this.widowsOrphans()}${e(this.widowsOrphansImportant())}; `,t+=`orphans: ${this.widowsOrphans()}${e(this.widowsOrphansImportant())}; `,t+="}\n"),(this.imageMaxSizeToFitPage()||this.imageKeepAspectRatio())&&(t+="img, svg { ",this.imageMaxSizeToFitPage()&&(t+=`max-inline-size: 100%${e(this.imageMaxSizeToFitPageImportant())}; `,t+=`max-block-size: 100vb${e(this.imageMaxSizeToFitPageImportant())}; `),this.imageKeepAspectRatio()&&(t+=`object-fit: contain${e(this.imageKeepAspectRatioImportant())}; `),t+="}\n"),t+="/*</viewer>*/\n",t+=this.afterOtherStyle(),t}copyFrom(e){this.pageSizeMode(e.pageSizeMode()),this.presetSize(e.presetSize()),this.isLandscape(e.isLandscape()),this.customWidth(e.customWidth()),this.customHeight(e.customHeight()),this.pageSizeImportant(e.pageSizeImportant()),this.pageMarginMode(e.pageMarginMode()),this.customMargin(e.customMargin()),this.pageMarginImportant(e.pageMarginImportant()),this.firstPageMarginZero(e.firstPageMarginZero()),this.firstPageMarginZeroImportant(e.firstPageMarginZeroImportant()),this.forceHtmlBodyMarginZero(e.forceHtmlBodyMarginZero()),this.widowsOrphans(e.widowsOrphans()),this.widowsOrphansImportant(e.widowsOrphansImportant()),this.imageMaxSizeToFitPage(e.imageMaxSizeToFitPage()),this.imageMaxSizeToFitPageImportant(e.imageMaxSizeToFitPageImportant()),this.imageKeepAspectRatio(e.imageKeepAspectRatio()),this.imageKeepAspectRatioImportant(e.imageKeepAspectRatioImportant()),this.baseFontSize(e.baseFontSize()),this.baseFontSizeSpecified(e.baseFontSizeSpecified()),this.baseFontSizeImportant(e.baseFontSizeImportant()),this.baseLineHeight(e.baseLineHeight()),this.baseLineHeightSpecified(e.baseLineHeightSpecified()),this.baseLineHeightImportant(e.baseLineHeightImportant()),this.baseFontFamily(e.baseFontFamily()),this.baseFontFamilySpecified(e.baseFontFamilySpecified()),this.baseFontFamilyImportant(e.baseFontFamilyImportant()),this.cropMarks(e.cropMarks()),this.cropMarksSpecified(e.cropMarksSpecified()),this.cropMarksImportant(e.cropMarksImportant()),this.bleed(e.bleed()),this.bleedSpecified(e.bleedSpecified()),this.bleedImportant(e.bleedImportant()),this.cropOffset(e.cropOffset()),this.cropOffsetSpecified(e.cropOffsetSpecified()),this.cropOffsetImportant(e.cropOffsetImportant()),this.allImportant(e.allImportant()),this.pageOtherStyle(e.pageOtherStyle()),this.firstPageOtherStyle(e.firstPageOtherStyle()),this.rootOtherStyle(e.rootOtherStyle()),this.beforeOtherStyle(e.beforeOtherStyle()),this.afterOtherStyle(e.afterOtherStyle()),this.viewerFontSize&&e.viewerFontSize&&this.viewerFontSize(e.viewerFontSize()),this.customStyleAsUserStyle(e.customStyleAsUserStyle())}equivalentTo(e){return this.pageSizeMode()===e.pageSizeMode()&&((this.pageSizeMode()!==g.Preset||this.presetSize()===e.presetSize())&&((this.pageSizeMode()!==g.Preset||this.isLandscape()===e.isLandscape())&&((this.pageSizeMode()!==g.Custom||this.customWidth()===e.customWidth())&&((this.pageSizeMode()!==g.Custom||this.customHeight()===e.customHeight())&&(this.pageSizeImportant()===e.pageSizeImportant()&&(this.pageMarginMode()===e.pageMarginMode()&&((this.pageMarginMode()!==g.Custom||this.customMargin()===e.customMargin())&&(this.pageMarginImportant()===e.pageMarginImportant()&&(this.firstPageMarginZero()===e.firstPageMarginZero()&&(this.firstPageMarginZeroImportant()===e.firstPageMarginZeroImportant()&&(this.forceHtmlBodyMarginZero()===e.forceHtmlBodyMarginZero()&&(this.widowsOrphans()===e.widowsOrphans()&&(this.widowsOrphansImportant()===e.widowsOrphansImportant()&&(this.imageMaxSizeToFitPage()===e.imageMaxSizeToFitPage()&&(this.imageMaxSizeToFitPageImportant()===e.imageMaxSizeToFitPageImportant()&&(this.imageKeepAspectRatio()===e.imageKeepAspectRatio()&&(this.imageKeepAspectRatioImportant()===e.imageKeepAspectRatioImportant()&&(this.baseFontSizeSpecified()===e.baseFontSizeSpecified()&&((!this.baseFontSizeSpecified()||this.baseFontSize()===e.baseFontSize())&&(this.baseFontSizeImportant()===e.baseFontSizeImportant()&&(this.baseLineHeightSpecified()===e.baseLineHeightSpecified()&&((!this.baseLineHeightSpecified()||this.baseLineHeight()===e.baseLineHeight())&&(this.baseLineHeightImportant()===e.baseLineHeightImportant()&&(this.baseFontFamilySpecified()===e.baseFontFamilySpecified()&&((!this.baseFontFamilySpecified()||this.baseFontFamily()===e.baseFontFamily())&&(this.baseFontFamilyImportant()===e.baseFontFamilyImportant()&&(this.cropMarksSpecified()===e.cropMarksSpecified()&&((!this.cropMarksSpecified()||this.cropMarks()===e.cropMarks())&&(this.cropMarksImportant()===e.cropMarksImportant()&&(this.bleedSpecified()===e.bleedSpecified()&&((!this.bleedSpecified()||this.bleed()===e.bleed())&&(this.bleedImportant()===e.bleedImportant()&&(this.cropOffsetSpecified()===e.cropOffsetSpecified()&&((!this.cropOffsetSpecified()||this.cropOffset()===e.cropOffset())&&(this.cropOffsetImportant()===e.cropOffsetImportant()&&(this.customStyleAsUserStyle()===e.customStyleAsUserStyle()&&(this.allImportant()===e.allImportant()&&(this.pageOtherStyle()===e.pageOtherStyle()&&(this.firstPageOtherStyle()===e.firstPageOtherStyle()&&(this.rootOtherStyle()===e.rootOtherStyle()&&(this.beforeOtherStyle()===e.beforeOtherStyle()&&(this.afterOtherStyle()===e.afterOtherStyle()&&!(!this.viewerFontSize!=!e.viewerFontSize||this.viewerFontSize&&this.viewerFontSize()!==e.viewerFontSize())))))))))))))))))))))))))))))))))))))))))))}}w.Mode=g,w.Constants=b,w.PresetSize=y;var x={escapeUnicodeChar:e=>`\\u${(65536|e.charCodeAt(0)).toString(16).substring(1)}`,escapeUnicodeString(e){return e.replace(/[^-a-zA-Z0-9_]/g,this.escapeUnicodeChar)},percentEncodeAmpersandAndUnencodedPercent:e=>e.replace(/%(?![0-9A-Fa-f]{2})/g,"%25").replace(/&/g,"%26"),percentEncodeAmpersandAndPercent:e=>e.replace(/%/g,"%25").replace(/&/g,"%26"),percentDecodeAmpersandAndPercent:e=>e.replace(/%26/g,"&").replace(/%25/g,"%"),percentEncodeForDataURI:e=>encodeURI(e).replace(/\?/g,"%3F").replace(/#/g,"%23").replace(/&/g,"%26")};function S(e){return new RegExp(`[#&]${x.escapeUnicodeString(e)}=([^&]*)`,"g")}const C=new class{constructor(){this.localStorageKey=null,this.history=window.history,this.location=window.location,this.storedUrl=this.location.href}getBaseURL(){let e=this.location.href;return e=e.replace(/#.*$/,""),e.replace(/\/[^/]*$/,"/")}hasParameter(e){const t=this.location.href;return S(e).test(t)}getParameter(e){const t=this.location.href,i=S(e),n=[];let r;for(;r=i.exec(t);)n.push(r[1]);return n}setParameter(e,t,i){var n;const r=this.location.href;let o=r;const s=S(e);let a=s.exec(r);if(a&&i)for(;i-- >=1;)a=s.exec(r);if(a){const e=a[1].length,i=a.index+a[0].length-e;o=r.substring(0,i)+t+r.substring(i+e)}else o=`${r+(r.match(/[#&]$/)?"":r.match(/#/)?"&":"#")+e}=${t}`,"src"===e&&(o=o.replace(/#(?!src)(.*?)&(src=[^&]*)/,"#$2&$1"));o!==r&&((null===(n=this.history)||void 0===n?void 0:n.replaceState)?this.history.replaceState(null,"",o):this.location.href=o,this.storedUrl=o,this.saveViewSettings())}removeParameter(e,t){var i;const n=this.location.href;let r=n;const o=S(e);let s=o.exec(n);if(s&&t&&(s=o.exec(n)),s){for(;s;s=o.exec(r)){const e=s.index+s[0].length;r="#"==s[0].charAt(0)?r.substring(0,s.index+1)+r.substring(e+1):r.substring(0,s.index)+r.substring(e),o.lastIndex-=s[0].length}r=r.replace(/^(.*?)[#&]$/,"$1")}r!==n&&((null===(i=this.history)||void 0===i?void 0:i.replaceState)?this.history.replaceState(null,"",r):this.location.href=r,this.storedUrl=r,this.saveViewSettings())}enableRestoreView(e){const t=this.generateLocalStorageKey();if(e)this.localStorageKey=t;else{this.localStorageKey=null;try{window.localStorage.removeItem(t)}catch(e){}}}isEnabledRestoreView(){return!!this.localStorageKey}saveViewSettings(){if(this.localStorageKey){this.hasParameter("f")||this.setParameter("f","epubcfi()");try{window.localStorage.setItem(this.localStorageKey,this.location.hash)}catch(e){}}}generateLocalStorageKey(){const e=this.getParameter("src").join();return e?"view@"+e:null}restoreViewSettings(){const e=this.generateLocalStorageKey();if(e)try{const t=window.localStorage.getItem(e);if(t)return this.location.hash=t,!0}catch(e){}return!1}};class k{constructor(e){var t;const i=function(){const e=C.getParameter("src"),t=C.getParameter("b"),i=C.getParameter("x"),n=C.getParameter("bookMode")[0],r=C.getParameter("f")[0],o=C.getParameter("style"),s=C.getParameter("userStyle"),a=C.getParameter("cmykReserveMap")[0];return{srcUrls:e.length?e:t.length?t:i.length?i:null,bookMode:"true"===n||"false"!==n&&(!!t.length||!i.length&&!(e.length>1)&&null),fragment:r||null,authorStyleSheet:o.length?o:[],userStyleSheet:s.length?s:[],cmykReserveMapUrl:a||null}}();this.srcUrls=a.observable(i.srcUrls||null),this.bookMode=a.observable(null!==(t=i.bookMode)&&void 0!==t?t:e),this.fragment=a.observable(i.fragment||""),this.authorStyleSheet=a.observable(i.authorStyleSheet),this.userStyleSheet=a.observable(i.userStyleSheet),this.pageStyle=new w,this.dataCustomStyleIndex=-1,this.cmykReserveMapUrl=i.cmykReserveMapUrl,this.bookMode.subscribe(t=>{t===e?C.removeParameter("bookMode"):C.setParameter("bookMode",t.toString())}),this.fragment.subscribe(e=>{if(/^epubcfi\(\/([246]\/)?2!\)/.test(e)&&!C.isEnabledRestoreView())C.removeParameter("f");else{const t=e.replace(/[\s+&?=#\u007F-\uFFFF]+/g,encodeURIComponent);C.setParameter("f",t)}});const n=(e,t)=>{if(/^data:,.*?\/\*(?:<|%3C)viewer(?:>|%3E)\*\//.test(e)){this.dataCustomStyleIndex=t;const i=e.replace(/^data:,/,"").replace(/%(?![0-9A-Fa-f]{2})/g,"%25"),n=decodeURIComponent(i);return this.pageStyle.cssText(n),!0}return!1};i.authorStyleSheet.find(n)||i.userStyleSheet.find(n)&&this.pageStyle.customStyleAsUserStyle(!0),this.pageStyle.cssText.subscribe(e=>{this.updateCustomStyleSheetFromCSSText(e)})}toObject(){function e(e){return e.map(e=>({url:e}))}return{fragment:this.fragment(),authorStyleSheet:e(this.authorStyleSheet()),userStyleSheet:e(this.userStyleSheet()),cmykReserveMapUrl:this.cmykReserveMapUrl}}updateCustomStyleSheetFromCSSText(e){null==e&&(e=this.pageStyle.toCSSText());const t=this.pageStyle.customStyleAsUserStyle(),i=t?"userStyle":"style",n=t?this.userStyleSheet:this.authorStyleSheet,r=n();if((!e||/^\s*(\/\*([^*]|\*(?!\/))*\*\/\s*)*$/.test(e))&&r.length<=(-1==this.dataCustomStyleIndex?0:1))return r.pop(),this.dataCustomStyleIndex=-1,n(r),void C.removeParameter(i);const o="data:,"+x.percentEncodeForDataURI(e.trim());-1==this.dataCustomStyleIndex?(r.push(o),this.dataCustomStyleIndex=r.length-1):r[this.dataCustomStyleIndex]=o,n(r),C.setParameter(i,o,this.dataCustomStyleIndex)}switchCustomStyleUserOrAuthorStyleSheets(){const e=this.pageStyle.customStyleAsUserStyle();if(-1!==this.dataCustomStyleIndex){const[t,i]=e?["style","userStyle"]:["userStyle","style"],[n,r]=e?[this.authorStyleSheet,this.userStyleSheet]:[this.userStyleSheet,this.authorStyleSheet],o=n(),s=r(),a=o[this.dataCustomStyleIndex];a&&(o.splice(this.dataCustomStyleIndex,1),s.push(a),this.dataCustomStyleIndex=s.length-1,n(o),r(s),C.removeParameter(t),C.removeParameter(i),o.forEach((e,i)=>{C.setParameter(t,e,i)}),s.forEach((e,t)=>{C.setParameter(i,e,t)}))}}}class P{toSpreadViewString(){switch(this){case E.SPREAD:return"true";case E.SINGLE_PAGE:return"false";case E.AUTO_SPREAD:return"auto";default:throw new Error("Invalid PageViewMode")}}toString(){switch(this){case E.SPREAD:return"spread";case E.SINGLE_PAGE:return"singlePage";case E.AUTO_SPREAD:return"autoSpread";default:throw new Error("Invalid PageViewMode")}}}const E={AUTO_SPREAD:new P,SINGLE_PAGE:new P,SPREAD:new P,defaultMode(){return this.AUTO_SPREAD},fromSpreadViewString(e){switch(e){case"true":return this.SPREAD;case"false":return this.SINGLE_PAGE;default:return this.AUTO_SPREAD}},of(e){switch(e){case m.PageViewMode.SPREAD:return this.SPREAD;case m.PageViewMode.SINGLE_PAGE:return this.SINGLE_PAGE;case m.PageViewMode.AUTO_SPREAD:return this.AUTO_SPREAD;default:throw new Error(`Invalid PageViewMode name: ${e}`)}}};class N{constructor(e){this.zoom=e}get fitToScreen(){return null}getCurrentZoomFactor(e){return 1}toggleFitToScreen(){return new N(1)}zoomIn(e){return new I(1.25*this.getCurrentZoomFactor(e))}zoomOut(e){return new I(.8*this.getCurrentZoomFactor(e))}zoomToActualSize(){return new I(1)}static createDefaultOptions(){return new T}static createFromZoomFactor(e){return new I(e)}}class T extends N{constructor(){super(1)}get fitToScreen(){return!0}toggleFitToScreen(){return new I(1)}getCurrentZoomFactor(e){return e.queryZoomFactor(m.ZoomType.FIT_INSIDE_VIEWPORT)}}class I extends N{get fitToScreen(){return!1}toggleFitToScreen(){return new T}getCurrentZoomFactor(){return this.zoom}}function A(){return{allowScripts:!0,renderAllPages:!0,fontSize:16,profile:!1,pageViewMode:E.defaultMode(),zoom:N.createDefaultOptions(),pixelRatio:8,enableMarker:!1}}function F(e){return e.toPrecision(10).replace(/(?:\.0*|(\.\d*?)0+)$/,"$1")}class R{constructor(e){var t,i,n;const r="boolean"==typeof e?e:void 0,o="object"==typeof e?e:void 0;if(this.allowScripts=a.observable(),this.renderAllPages=a.observable(),this.fontSize=a.observable(),this.profile=a.observable(),this.pageViewMode=a.observable(),this.zoom=a.observable(),this.pixelRatio=a.observable(),this.enableMarker=a.observable(),o)this.copyFrom(o);else{const e=A(),o=function(){const e=C.getParameter("allowScripts")[0],t=C.getParameter("renderAllPages")[0],i=C.getParameter("fontSize")[0],n=C.getParameter("enableMarker")[0],r=/^([\d.]+)(?:(%25|%)|\/([\d.]+))?$/.exec(i);let o=null;if(r){const[,e,t,i]=r;o=parseFloat(e),(t||i)&&(o=16*o/(t?100:parseFloat(i))),o<5&&(o=5),o>72&&(o=72)}const s=C.getParameter("zoom")[0],a=parseFloat(s),l=C.getParameter("pixelRatio")[0],h=l&&parseFloat(l);return{allowScripts:"true"===e||"false"!==e&&null,renderAllPages:"true"===t||"false"!==t&&!C.hasParameter("b")&&null,fontSize:o,profile:"true"===C.getParameter("profile")[0],pageViewMode:E.fromSpreadViewString(C.getParameter("spread")[0]),zoom:a>0?N.createFromZoomFactor(a):N.createDefaultOptions(),pixelRatio:h,enableMarker:"true"===n||"false"!==n&&null}}();this.allowScripts(null!==(t=o.allowScripts)&&void 0!==t?t:e.allowScripts),this.renderAllPages(null!==(i=o.renderAllPages)&&void 0!==i?i:r),this.fontSize(o.fontSize||e.fontSize),this.profile(o.profile||e.profile),this.pageViewMode(o.pageViewMode||e.pageViewMode),this.zoom(o.zoom||e.zoom),this.pixelRatio(null!==(n=o.pixelRatio)&&void 0!==n?n:e.pixelRatio),this.enableMarker(o.enableMarker||e.enableMarker),this.pageViewMode.subscribe(t=>{t===e.pageViewMode?C.removeParameter("spread"):C.setParameter("spread",t.toSpreadViewString())}),this.renderAllPages.subscribe(e=>{e===r?C.removeParameter("renderAllPages"):C.setParameter("renderAllPages",e.toString())}),this.fontSize.subscribe(t=>{"number"==typeof t&&(t=F(t)),Number(t)==e.fontSize?C.removeParameter("fontSize"):C.setParameter("fontSize",`${t}/${e.fontSize}`)}),this.zoom.subscribe(e=>{e.fitToScreen?C.removeParameter("zoom"):C.setParameter("zoom",F(e.getCurrentZoomFactor()))}),this.enableMarker.subscribe(e=>{e?C.setParameter("enableMarker","true"):C.removeParameter("enableMarker")})}}copyFrom(e){this.allowScripts(e.allowScripts()),this.renderAllPages(e.renderAllPages()),this.fontSize(e.fontSize()),this.profile(e.profile()),this.pageViewMode(e.pageViewMode()),this.zoom(e.zoom()),this.pixelRatio(e.pixelRatio()),this.enableMarker(e.enableMarker())}toObject(){return{allowScripts:this.allowScripts(),renderAllPages:this.renderAllPages(),fontSize:Number(this.fontSize()),pageViewMode:this.pageViewMode().toString(),fitToScreen:this.zoom().fitToScreen,zoom:this.zoom().zoom,pixelRatio:this.pixelRatio()}}}R.getDefaultValues=A;var O,L=a.observableArray();!function(e){e.Debug="debug",e.Info="info",e.Warn="warn",e.Error="error"}(O||(O={}));class _{static getLogger(){return new _}constructor(){this.logLevel=O.Error}setLogLevel(e){this.logLevel=e}debug(e){this.logLevel===O.Debug&&L.push({type:"debug",content:e})}info(e){this.logLevel!==O.Debug&&this.logLevel!==O.Info||L.push({type:"info",content:e})}warn(e){this.logLevel!==O.Debug&&this.logLevel!==O.Info&&this.logLevel!==O.Warn||L.push({type:"warn",content:e})}error(e){var t;if(this.logLevel===O.Debug||this.logLevel===O.Info||this.logLevel===O.Warn||this.logLevel===O.Error){if(null===(t=null==e?void 0:e.error)||void 0===t?void 0:t.toString().includes("history.replaceState()"))return;L.push({type:"error",content:e})}}}const B={readonlyObservable(e){const t=a.observable(e);return{getter:a.pureComputed(()=>t()),value:t}}};class M{constructor(e,t){this.viewerOptions=t,this.documentOptions=null,this.coreViewer=new m.CoreViewer(e,t.toObject());const i=this.privState={status:B.readonlyObservable(m.ReadyState.LOADING),pageProgression:B.readonlyObservable(m.PageProgression.LTR)};this.state={status:i.status.getter.extend({rateLimit:{timeout:100,method:"notifyWhenChangesStop"},notify:"always"}),navigatable:a.pureComputed(()=>i.status.value()&&i.status.value()!==m.ReadyState.LOADING),fixedLayout:a.observable(),pageProgression:i.pageProgression.getter},this.epage=a.observable(),this.epageCount=a.observable(),this.firstPage=a.observable(),this.lastPage=a.observable(),this.tocVisible=a.observable(),this.tocPinned=a.observable(),this.inputUrl=a.observable(""),this.rerenderTrigger=a.observable(!1),this.setupViewerEventHandler(),this.setupViewerOptionSubscriptions(),window.coreViewer=this.coreViewer}setupViewerEventHandler(){const e=_.getLogger();this.coreViewer.addListener("debug",t=>{e.debug(t.content)}),this.coreViewer.addListener("info",t=>{e.info(t.content)}),this.coreViewer.addListener("warn",t=>{e.warn(t.content)}),this.coreViewer.addListener("error",t=>{e.error(t.content)}),this.coreViewer.addListener("readystatechange",()=>{const e=this.coreViewer.readyState;e!==m.ReadyState.INTERACTIVE&&e!==m.ReadyState.COMPLETE||this.privState.pageProgression.value(this.coreViewer.getCurrentPageProgression()),this.privState.status.value(e)}),this.coreViewer.addListener("loaded",()=>{this.viewerOptions.profile()&&m.profiler.printTimings(),this.rerenderTrigger(!this.rerenderTrigger())});let t=0;this.coreViewer.addListener("nav",e=>{var i,n,r,o;const{cfi:s,first:a,last:l,epage:h,epageCount:u,metadata:c,docTitle:d}=e;if(this.rerenderTrigger(!this.rerenderTrigger()),s&&(t&&window.clearTimeout(t),t=window.setTimeout(()=>{this.documentOptions.fragment(s),t=0},300)),void 0!==h&&this.epage(h),void 0!==u&&this.epageCount(u),void 0!==a&&this.firstPage(a),void 0!==l&&this.lastPage(l),c||d){let e=document.title;const t=null===(n=null===(i=null==c?void 0:c["http://purl.org/dc/terms/title"])||void 0===i?void 0:i[0])||void 0===n?void 0:n.v;e=t?!d||d===t||this.firstPage()||/\.xhtml$/.test(d)?t:`${d} | ${t}`:d||"Vivliostyle Viewer",e!==document.title&&(document.title=e);const s=null===(o=null===(r=null==c?void 0:c["http://www.idpf.org/vocab/rendition/#layout"])||void 0===r?void 0:r[0])||void 0===o?void 0:o.v;s&&this.state.fixedLayout("pre-paginated"===s)}const p=this.tocVisible(),f=this.coreViewer.isTOCVisible();p&&!f||this.tocVisible(f)}),this.coreViewer.addListener("hyperlink",e=>{e.internal?(window.history.pushState(null,null),this.navigateToInternalUrl(e.href),this.tocVisible()&&this.tocVisible(!1),document.getElementById("vivliostyle-viewer-viewport").focus()):window.location.href=e.href})}setupViewerOptionSubscriptions(){a.computed(()=>{const e=this.viewerOptions.toObject();this.coreViewer.setOptions(e)}).extend({rateLimit:0})}loadDocument(e,t){this.privState.status.value(m.ReadyState.LOADING),t&&this.viewerOptions.copyFrom(t),this.documentOptions=e,e.srcUrls()?e.bookMode()?this.coreViewer.loadPublication(e.srcUrls()[0],e.toObject(),this.viewerOptions.toObject()):this.coreViewer.loadDocument(e.srcUrls(),e.toObject(),this.viewerOptions.toObject()):this.privState.status.value(void 0)}navigateToPrevious(){this.coreViewer.navigateToPage(m.Navigation.PREVIOUS)}navigateToNext(){this.coreViewer.navigateToPage(m.Navigation.NEXT)}navigateToLeft(){this.coreViewer.navigateToPage(m.Navigation.LEFT)}navigateToRight(){this.coreViewer.navigateToPage(m.Navigation.RIGHT)}navigateToFirst(){this.coreViewer.navigateToPage(m.Navigation.FIRST)}navigateToLast(){this.coreViewer.navigateToPage(m.Navigation.LAST)}navigateToEPage(e){this.coreViewer.navigateToPage(m.Navigation.EPAGE,e)}navigateToInternalUrl(e){this.coreViewer.navigateToInternalUrl(e)}navigateToPosition(e){this.coreViewer.navigateToPosition(e)}queryZoomFactor(e){return this.coreViewer.queryZoomFactor(e)}epageToPageNumber(e){if(!e&&0!=e)return;return Math.round(e+1)}epageFromPageNumber(e){if(!e&&0!=e)return;return e-1}showTOC(e,t){if(null==this.coreViewer.isTOCVisible())return;const i=null==e?!this.tocVisible():e;this.tocVisible(i),this.tocPinned(!!i&&!t),this.coreViewer.showTOC(i,t)}}const D={Unidentified:"Unidentified",ArrowDown:"ArrowDown",ArrowLeft:"ArrowLeft",ArrowRight:"ArrowRight",ArrowUp:"ArrowUp",Home:"Home",End:"End",PageDown:"PageDown",PageUp:"PageUp",Escape:"Escape",Enter:"Enter",Space:" "};var z={Keys:D,identifyKeyFromEvent:function(e){const t=e.key,i=e.keyIdentifier,n=e.location;return t===D.ArrowDown||"Down"===t||"Down"===i?e.metaKey?D.End:D.ArrowDown:t===D.ArrowLeft||"Left"===t||"Left"===i?D.ArrowLeft:t===D.ArrowRight||"Right"===t||"Right"===i?D.ArrowRight:t===D.ArrowUp||"Up"===t||"Up"===i?e.metaKey?D.Home:D.ArrowUp:t===D.Escape||"Esc"===t||"U+001B"===i?D.Escape:t===D.Enter||"Enter"===i?D.Enter:t===D.Space||"U+0020"===i?D.Space:"0"===t||"U+0030"===i?"0":"+"===t||"Add"===t||"U+002B"===i||"U+00BB"===i||"U+004B"===i&&n===KeyboardEvent.DOM_KEY_LOCATION_NUMPAD?"+":"-"===t||"Subtract"===t||"U+002D"===i||"U+00BD"===i||"U+004D"===i&&n===KeyboardEvent.DOM_KEY_LOCATION_NUMPAD?"-":t||i||D.Unidentified}};const V=(e,t)=>{let i=e.x-t.x,n=e.y-t.y,r=e.width,o=e.height;const s=document.getElementById("vivliostyle-viewer-viewport").style,a=parseFloat(s.getPropertyValue("--viv-outputScale")||"1");return a&&!isNaN(a)&&(i/=a,n/=a,r/=a,o/=a),new DOMRect(i,n,r,o)},U=p.i18n.t.bind(p.i18n),H=e=>{switch(e){case"red":return"rgba(255,0, 0,0.2)";case"green":return"rgba(0,255,0,0.2)";case"yellow":return"rgba(255,217,0,0.3)";default:return""}},$=e=>{if(e.firstChild)return e.firstChild;for(;e;){if(e.nextSibling)return e.nextSibling;e=e.parentNode}},j=e=>{let t;return t=1==e.nodeType?e:e.parentElement,!!t.closest("[data-adapt-eloff]")},W=e=>!!e.parentElement.closest("rt,[data-adapt-spec]"),G=(e,t)=>{const i=[];for(let n=e.node;n;n=$(n)){if(3==n.nodeType&&!W(n)&&j(n)){const r=n;if(r.data.trim().length>0){const o=n==e.node?e.offset:0,s=n==t.node?t.offset:r.data.length;s>o&&i.push({t:r,startOffset:o,endOffset:s})}}if(n==t.node)break}return i},q=e=>{const t=document.createRange();return t.setStart(e.t,e.startOffset),t.setEnd(e.t,e.endOffset),[...t.getClientRects()]},X=(e,t)=>!!t.querySelector(`[${ne.idAttr}="${e}"]`),Y=(e,t)=>{t.background&&(e.style.background=t.background)},K=(e,t,i,n)=>{const r=e.node.parentElement.closest("[data-vivliostyle-page-container='true']"),o=t.node.parentElement.closest("[data-vivliostyle-page-container='true']");if(n&&X(n.uniqueIdentifier,r)&&X(n.uniqueIdentifier,o))return"";const s=G(e,t),a=(null==n?void 0:n.uniqueIdentifier)||ne.notCreatedId,l=e=>{const t=e.clientX,i=e.clientY;pe.openEditMenu(t,i,a)};let h=0;const u=[];return s.forEach(e=>{u.push(e.t.data.slice(e.startOffset,e.endOffset));const t=e.t.parentElement.closest("[data-vivliostyle-page-container='true']"),n=t.getBoundingClientRect(),r=Z(t),o=J(t);for(const s of q(e)){const e=V(s,n),u=`${o}-${r}-${h++}`;if(document.querySelector(`[${ne.idAttr}='${a}'][data-mn='${u}']`))return;const c=document.createElement("div");c.style.position="absolute",c.style.margin="0",c.style.padding="0",c.style.top=`${e.top}px`,c.style.left=`${e.left}px`,c.style.width=`${e.width}px`,c.style.height=`${e.height}px`,Y(c,i),c.setAttribute(ne.idAttr,a),c.setAttribute("data-mn",`${u}`),c.addEventListener("click",l),t.appendChild(c)}}),u.join("")},Z=e=>{const t=parseInt(e.getAttribute("data-vivliostyle-page-index"));return isNaN(t)?-1:t},J=e=>{const t=parseInt(e.getAttribute("data-vivliostyle-spine-index"));return isNaN(t)?-1:t},Q=(e,t)=>{const i=e.parentElement.closest("[data-vivliostyle-page-container]"),n=J(i),r=e.parentElement.closest("[data-adapt-eloff]"),o=[];let s=e;for(;s&&s!==r;)o.unshift(s),s=s.parentElement;const a=parseInt(r.getAttribute("data-adapt-eloff"));let l=a+t;const h=te(n,a);let u=0,c=-1,d=0;for(const e of h.values()){if(e==r)break;const t=[...e.childNodes].filter(e=>!(1==e.nodeType&&e.hasAttribute("data-adapt-spec")));let i=t.length;if(i>0){l+=t.map(e=>e.textContent.length).reduce((e,t)=>e+t),3==t[0].nodeType&&3==c&&(i-=1);const e=t[t.length-1];c=e.nodeType,3==c?d+=e.data.length:d=0}u+=i}const p=[...r.childNodes].filter(e=>!(1==e.nodeType&&e.hasAttribute("data-adapt-spec"))),f=p.indexOf(o[0]);f>0&&(l+=p.map((e,t)=>t<f?e.textContent.length:0).reduce((e,t)=>e+t));const g=[];if(0==f&&3==o[0].nodeType&&3==c)t+=d,o.length>1&&console.warn("should not reach here; nodePath[0] is text and nodePath is deeper"),g.push(u-1);else{u+=f+1,3==c&&3==p[0].nodeType&&u--,g.push(u-1);let e=0;for(;e<o.length-1;){const t=[...o[e].childNodes].indexOf(o[e+1]);g.push(t),e++}}return new ie(n,a,g,t,l)},ee=e=>{const t=te(e.spineIndex,e.eloff);let i,n=0,r=-1,o=0;for(const s of t.values()){const t=[...s.childNodes].filter(e=>!(1==e.nodeType&&e.hasAttribute("data-adapt-spec"))),a=t.length;if(a>0){3==t[0].nodeType&&3==r&&n--;const s=n+a;if(s>e.nodePath[0])if(n==e.nodePath[0]&&3==t[0].nodeType){const n=t[0];if(o<=e.offset&&e.offset<=o+n.data.length){i=n;break}}else{if(s!=e.nodePath[0]+1||3!=t[t.length-1].nodeType){let r=t[e.nodePath[0]-n];for(let t=1;t<e.nodePath.length;t++)r.childNodes&&r.childNodes.length>e.nodePath[t]&&(r=r.childNodes[e.nodePath[t]]);i=r,o=0;break}{const n=t[t.length-1];if(e.offset<=n.data.length){i=n,o=0;break}}}const l=t[t.length-1];r=l.nodeType,3==r?o+=l.data.length:o=0}n+=a}return i?{node:i,offset:e.offset-o}:null},te=(e,t)=>{const i=`[data-vivliostyle-spine-index='${e}'] [data-adapt-eloff='${t}']`;return Array.from(document.querySelectorAll(i)).filter(e=>!e.querySelector(i))};class ie{constructor(e,t,i,n,r){this.spineIndex=e,this.eloff=t,this.nodePath=i,this.offset=n,this.offsetInItem=r}toString(){return`${this.spineIndex}-${this.eloff}-${this.nodePath.join("/")}-${this.offset}-${this.offsetInItem}`}static fromString(e){const[t,i,n,r,o]=e.split("-").map(e=>e.trim()),s=n.split("/").map(e=>parseInt(e));return new ie(parseInt(t),parseInt(i),s,parseInt(r),parseInt(o))}}class ne{constructor(e,t,i,n,r){this.start=e,this.end=t,this.color=i,this.memo=n,this.markedText=r,this.uniqueIdentifier=ne.notCreatedId}markInfoString(){return`${this.start},${this.end},${this.color}`}toMarkJson(){return{mark:this.markInfoString(),id:this.uniqueIdentifier,memo:this.memo,markedText:this.markedText}}isPersisted(){return this.uniqueIdentifier&&this.uniqueIdentifier!=ne.notCreatedId}static fromMarkInfoString(e){const[t,i,n]=e.split(","),r=ie.fromString(t),o=ie.fromString(i);return new ne(r,o,n,"","")}static fromMarkJson(e){const t=ne.fromMarkInfoString(e.mark);return t.uniqueIdentifier=e.id,t.memo=e.memo,t.markedText=e.markedText,t}}ne.idAttr="data-viv-marker-id",ne.notCreatedId="not-created";const re=e=>{pe.openStartButton(e)};class oe{currentId(){return""}deletable(){return!1}cancellable(){return!1}applyEditing(){}colorChanged(){}deleteCurrentEditing(){}close(){}}class se{constructor(){this.start=(e,t)=>{this.currentStart=e,this.currentEnd=t;const i=ee(this.currentStart),n=ee(this.currentEnd);if(i&&n){const e=H(pe.currentEditingColor());return this.currentText=K(i,n,{background:e}),!0}return!1},this.deletable=()=>!1,this.cancellable=()=>!0,this.deleteCurrentEditing=async()=>{},this.currentId=()=>ne.notCreatedId,this.applyEditing=async()=>{if(this.currentStart&&this.currentEnd){const e=new ne(this.currentStart,this.currentEnd,pe.currentEditingColor(),pe.currentEditingMemo(),this.currentText);await de.persistMark(e)}pe.closeMenu()},this.colorChanged=async()=>{0==this.cancellable()&&this.applyEditing()},this.close=async()=>{document.querySelectorAll(`[${ne.idAttr}="${ne.notCreatedId}"]`).forEach(e=>{e.remove()})}}}class ae{constructor(){this.deletable=()=>!0,this.cancellable=()=>!0,this.deleteCurrentEditing=async()=>{this.currentEditing&&await de.removeMark(this.currentEditing)},this.currentId=()=>{var e;return null===(e=this.currentEditing)||void 0===e?void 0:e.uniqueIdentifier},this.applyEditing=async()=>{this.currentEditing&&(pe.currentEditingColor()==this.currentEditing.color&&pe.currentEditingMemo()==this.currentEditing.memo||(this.currentEditing.color=pe.currentEditingColor(),this.currentEditing.memo=pe.currentEditingMemo(),de.updateMark(this.currentEditing))),pe.closeMenu()},this.colorChanged=async()=>{},this.close=async()=>{if(this.currentEditing){const e=H(this.currentEditing.color);e.length>0&&document.querySelectorAll(`[${ne.idAttr}="${this.currentEditing.uniqueIdentifier}"]`).forEach(t=>{t.style.background=e}),this.currentEditing=void 0}}}}class le{constructor(e){this.parent=e,this.editingColorChanged=async e=>{if(!de.enabled())return;const t=this.markAction().currentId(),i=H(e);i.length>0&&document.querySelectorAll(`[${ne.idAttr}="${t}"]`).forEach(e=>{e.style.background=i}),await this.markAction().colorChanged()},this.openMenu=(e,t)=>{if(this.menuOpened())return;const i=document.getElementById("vivliostyle-text-selection-edit-menu");i&&(i.style.top=`${t}px`,i.style.left=`${e}px`);const n=this.menuOpened.subscribe(t=>{if(t){const t=document.getElementById("vivliostyle-text-selection-edit-menu"),i=document.querySelector("[data-vivliostyle-outer-zoom-box]");if(t&&i){const n=t.getBoundingClientRect(),r=i.getBoundingClientRect();let o=e-n.width;o+n.width>r.right&&(o=r.right-n.width-10),o<r.left&&(o=r.left),t.style.left=`${o}px`,n.bottom>r.bottom&&(t.style.top=r.bottom-n.height-10+"px")}}n.dispose()});this.startButtonOpened(!1),this.menuOpened(!0)},this.closeStartButton=()=>{de.enabled()&&this.startButtonOpened(!1)},this.openEditMenu=async(e,t,i)=>{if(!de.enabled())return;const n=await this.parent.getMark(i);this.currentEditingColor(n.color),this.currentEditingMemo(n.memo),this.editAction.currentEditing=n,this.markAction(this.editAction),this.openMenu(e,t)},this.closeMenu=async()=>{de.enabled()&&(await this.markAction().close(),this.markAction(this.emptyAction),this.menuOpened(!1))},this.applyEditing=async()=>{de.enabled()&&await this.markAction().applyEditing()},this.deleteCurrentEditing=async()=>{de.enabled()&&(confirm(U("CONFIRM_DELETE"))&&await this.markAction().deleteCurrentEditing(),await this.closeMenu())},this.openSelectionMenu=(e,t,i,n,r)=>{de.enabled()&&(this.currentEditingColor("yellow"),this.currentEditingMemo(""),this.newMarkAction.start(i,n)&&(r.empty(),this.markAction(this.newMarkAction),this.openMenu(e,t)))},this.openStartButton=async e=>{if(de.enabled()&&"Range"==e.type){const t=e.getRangeAt(0);if(!t.commonAncestorContainer.parentElement.closest("[data-vivliostyle-outer-zoom-box]"))return;const i=document.getElementById("vivliostyle-text-selection-start-button"),n={node:t.startContainer,offset:t.startOffset},r={node:t.endContainer,offset:t.endOffset},o=G(n,r);if(0==o.length)return;const s=o.reduce((e,t)=>e.concat(q(t)),[]);if(0==s.length)return;const a=Q(o[0].t,o[0].startOffset),l=Q(o[o.length-1].t,o[o.length-1].endOffset),h=s[s.length-1].left,u=s[s.length-1].bottom,c=t=>{t.stopPropagation(),i&&i.removeEventListener("click",c),this.openSelectionMenu(h,u,a,l,e)};i&&(i.style.top=`${u}px`,i.style.left=`${h}px`,i.addEventListener("click",c));const d=this.startButtonOpened.subscribe(e=>{if(e){const e=document.querySelector("[data-vivliostyle-outer-zoom-box]");if(i&&e){const t=i.getBoundingClientRect(),n=e.getBoundingClientRect();let r=h-t.width;r+t.width>n.right&&(r=n.right-t.width-10),r<n.left&&(r=n.left),i.style.left=`${r}px`,t.bottom>n.bottom&&(i.style.top=n.bottom-t.height-10+"px")}}else i.removeEventListener("click",c),d.dispose()});this.startButtonOpened(!0)}},this.menuOpened=a.observable(!1),this.startButtonOpened=a.observable(!1),this.currentEditingColor=a.observable(""),this.currentEditingMemo=a.observable(""),this.currentEditingColor.subscribe(this.editingColorChanged),this.editAction=new ae,this.newMarkAction=new se,this.emptyAction=new oe,this.markAction=a.observable(this.emptyAction),this.deletable=a.pureComputed(()=>this.markAction().deletable()).extend({notify:"always"}),this.cancellable=a.pureComputed(()=>this.markAction().cancellable()).extend({notify:"always"})}init(){const e=document.getElementById("vivliostyle-text-selection-edit-menu");let t=0,i=0;const n=n=>{const r=n.clientX-t,o=n.clientY-i;t=n.clientX,i=n.clientY,e.style.top=`${e.offsetTop+o}px`,e.style.left=`${e.offsetLeft+r}px`};e.addEventListener("mousedown",e=>{"vivliostyle-memo-edit-area"!==e.target.id&&(t=e.clientX,i=e.clientY,document.addEventListener("mousemove",n),document.addEventListener("mouseup",()=>{document.removeEventListener("mousemove",n)}))})}}let he=0;class ue{constructor(){this.markArray=[],this.documentId="",this.markKeyToArrayIndex=new Map}async init(e){C.getParameter("mark").forEach(e=>{const t=this.urlStringToMark(e);this.pushMarkInternal(t,"doNotAddToUrl","persist")}),this.documentId=e}async persistMark(e){return this.pushMarkInternal(e,"addToUrl","persist")}async updateMark(e){await this.removeMark(e),this.pushMarkInternal(e,"addToUrl","doNotPersist")}async getMark(e){const t=this.markKeyToArrayIndex.get(e);return this.markArray[t]}async removeMark(e){const t=this.markKeyToArrayIndex.get(e.id);this.markArray.splice(t,1),this.markRemoved()}async allMarks(){return this.markArray}async allMarksIterator(){const e=this.markArray;return async function*(){let t=0;for(;t<e.length;){const i=e[t++];yield i}}()}markToURLString(e){const t=e.memo?encodeURIComponent(e.memo):"",i=e.markedText?encodeURIComponent(e.markedText):"";return`${e.mark}%1F${t}%1F${i}`}urlStringToMark(e){const[t,i,n]=e.split("%1F",3);return{mark:t,id:"",memo:i?decodeURIComponent(i):"",markedText:n?decodeURIComponent(n):""}}pushMarkInternal(e,t,i){if("persist"==i&&(e.id=""+he++),this.markArray.push(e),this.markKeyToArrayIndex.set(e.id,this.markArray.length-1),"addToUrl"==t){const t=C.getParameter("mark").length;C.setParameter("mark",this.markToURLString(e),t)}return e.id}async markRemoved(){this.markKeyToArrayIndex.clear(),C.removeParameter("mark"),this.markArray.forEach((e,t)=>{C.setParameter("mark",this.markToURLString(e),t),this.markKeyToArrayIndex.set(e.id,t)})}}class ce{constructor(e){this.parent=e,this.removeAllMarks=async()=>{if(confirm(U("CONFIRM_REMOVE_ALL"))){const e=this.list.removeAll();for(const t of e)await this.parent.removeMark(t)}},this.removeOneMark=async e=>{confirm(U("CONFIRM_REMOVE"))&&await this.parent.removeMark(e)},this.updateActualMark=async e=>{this.parent.actualStore.updateMark(e.toMarkJson())},this.navigateToMark=e=>{const{spineIndex:t,offsetInItem:i}=e.start;window.history.pushState(null,null),this.parent.viewer.navigateToPosition({spineIndex:t,offsetInItem:i}),this.pinned()||(this.detailsElement.open=!1)},this.hasMarks=()=>this.list().length>0&&this.parent.enabled(),this.pinned=a.observable(!1),this.list=a.observableArray()}init(){this.detailsElement=document.getElementById("vivliostyle-marks-box")}addMarkToList(e){let t=-1;const i=this.list();for(let n=0;n<i.length;n++){const r=i[n];if(r.uniqueIdentifier===e.uniqueIdentifier)return void this.list.replace(r,e);if(r.start.spineIndex===e.start.spineIndex){if(r.start.offsetInItem>e.start.offsetInItem){t=n;break}}else if(r.start.spineIndex>e.start.spineIndex){t=n;break}}-1===t&&(t=i.length),this.list.splice(t,0,e)}removeMarkFromList(e){this.list.remove(t=>t.uniqueIdentifier===e.uniqueIdentifier)}}const de=new class{constructor(){this.menuStatus=new le(this),this.marksBox=new ce(this),this.initialized=!1,this.justClicked=!1}enabled(){return this.initialized&&this.viewerOptions.enableMarker()}async init(e,t){if(e&&(this.viewerOptions=e),t&&(this.viewer=t),!this.viewerOptions||!this.viewerOptions.enableMarker())return;this.menuStatus.init(),this.marksBox.init(),window.marksStorePlugin?this.actualStore=window.marksStorePlugin:this.actualStore=new ue;const i=C.getParameter("src").join();await this.actualStore.init(i),this.initialized=!0}async toggleEnableMarker(){this.enabled()?this.justClicked?(this.justClicked=!1,this.marksBox.pinned(!0),this.marksBox.detailsElement.open=!0):(document.querySelectorAll(`[${ne.idAttr}]`).forEach(e=>{e.remove()}),this.menuStatus.startButtonOpened()&&this.menuStatus.closeStartButton(),this.menuStatus.menuOpened()&&this.menuStatus.closeMenu(),this.viewerOptions.enableMarker(!1),this.justClicked=!0,window.setTimeout(()=>{this.justClicked=!1},300)):(this.viewerOptions.enableMarker(!0),this.justClicked?(this.justClicked=!1,this.marksBox.pinned(!0),this.marksBox.detailsElement.open=!0):(this.marksBox.pinned(!1),this.justClicked=!0,window.setTimeout(()=>{this.marksBox.detailsElement.firstElementChild.focus(),this.justClicked=!1},300)),this.initialized||await this.init(),await this.retryHighlightMarks())}async persistMark(e){if(!this.initialized)return;const t=await this.actualStore.persistMark(e.toMarkJson());e.uniqueIdentifier=t,this.highlightMark(e)}async updateMark(e){this.initialized&&(this.unhighlightMark(e),this.highlightMark(e),this.actualStore.updateMark(e.toMarkJson()))}async getMark(e){if(this.initialized)return ne.fromMarkJson(await this.actualStore.getMark(e))}async removeMark(e){this.initialized&&(this.unhighlightMark(e),await this.actualStore.removeMark(e.toMarkJson()))}async retryHighlightMarks(){if(this.enabled())if(this.actualStore.allMarksIterator){const e=await this.actualStore.allMarksIterator();for await(const t of e)t&&this.highlightMark(ne.fromMarkJson(t))}else for await(const e of await this.actualStore.allMarks())e&&this.highlightMark(ne.fromMarkJson(e))}unhighlightMark(e){document.querySelectorAll(`[${ne.idAttr}="${e.uniqueIdentifier}"]`).forEach(e=>{e.remove()}),this.marksBox.removeMarkFromList(e)}highlightMark(e,t=!1){if(!e.isPersisted&&!t)throw"mark is not persisted.";const i=ee(e.start);let n=ee(e.end);if(!i||n||this.viewerOptions.renderAllPages()||(console.log(),n=((e,t)=>{let i=e.node;for(let n=e.node;n;n=$(n)){if(1==n.nodeType){const e=n;if(e.hasAttribute("data-vivliostyle-outer-zoom-box"))break;if(e.hasAttribute("data-vivliostyle-page-container")&&J(e)>t.spineIndex)break}3==n.nodeType&&j(n)&&(i=n)}return{node:i,offset:i.data.length}})(i,e.end)),i&&n){const t=H(e.color);K(i,n,{background:t},e)}this.marksBox.addMarkToList(e)}},pe=de.menuStatus,{Keys:fe}=z;class ge{constructor(e,t,i,n){this.viewerOptions=e,this.viewer=t,this.settingsPanel=i,this.navigateToPrevious=()=>!this.isNavigateToPreviousDisabled()&&(this.viewer.navigateToPrevious(),!0),this.navigateToNext=()=>!this.isNavigateToNextDisabled()&&(this.viewer.navigateToNext(),!0),this.navigateToLeft=()=>!this.isNavigateToLeftDisabled()&&(this.viewer.navigateToLeft(),!0),this.navigateToRight=()=>!this.isNavigateToRightDisabled()&&(this.viewer.navigateToRight(),!0),this.navigateToFirst=()=>!this.isNavigateToFirstDisabled()&&(window.history.pushState(null,null),this.viewer.navigateToFirst(),!0),this.navigateToLast=()=>!this.isNavigateToLastDisabled()&&(window.history.pushState(null,null),this.viewer.navigateToLast(),!0),this.zoomIn=()=>{if(this.isZoomInDisabled())return!1;{const e=this.viewerOptions.zoom();return this.viewerOptions.zoom(e.zoomIn(this.viewer)),!0}},this.zoomOut=()=>{if(this.isZoomOutDisabled())return!1;{const e=this.viewerOptions.zoom();return this.viewerOptions.zoom(e.zoomOut(this.viewer)),!0}},this.zoomToActualSize=()=>{if(this.isZoomToActualSizeDisabled())return!1;{const e=this.viewerOptions.zoom();return this.viewerOptions.zoom(e.zoomToActualSize()),!0}},this.toggleFitToScreen=()=>{if(this.isToggleFitToScreenDisabled())return!1;{const e=this.viewerOptions.zoom();return this.viewerOptions.zoom(e.toggleFitToScreen()),!0}},this.increaseFontSize=()=>{if(this.isIncreaseFontSizeDisabled())return!1;{let e=Number(this.viewerOptions.fontSize());return e=e<10?Math.floor(e)+1:e<20?2*(Math.floor(e/2)+1):e<40?4*(Math.floor(e/4)+1):e<72?8*(Math.floor(e/8)+1):72,this.viewerOptions.fontSize(e),this.updateFontSizeSettings(),!0}},this.decreaseFontSize=()=>{if(this.isDecreaseFontSizeDisabled())return!1;{let e=Number(this.viewerOptions.fontSize());return e=e>40?8*(Math.ceil(e/8)-1):e>20?4*(Math.ceil(e/4)-1):e>10?2*(Math.ceil(e/2)-1):e>5?Math.ceil(e)-1:5,this.viewerOptions.fontSize(e),this.updateFontSizeSettings(),!0}},this.defaultFontSize=()=>{if(this.isDefaultFontSizeDisabled())return!1;{const e=R.getDefaultValues().fontSize;return this.viewerOptions.fontSize(e),this.updateFontSizeSettings(),!0}},this.onfocusPageNumber=(e,t)=>{const i=t.currentTarget;return window.setTimeout(()=>{i.setSelectionRange(0,i.value.length)},0),!0},this.onmouseupPageSlider=(e,t)=>{if(this.viewerOptions.renderAllPages())return!0;const i=document.getElementById("vivliostyle-page-number"),n=Number(i.value),r=this.viewer.epageFromPageNumber(n);return this.viewer.navigateToEPage(r),!0},this.onwheelPageSlider=(e,t)=>(t.preventDefault(),this.justPageMovedByWheel||0===t.deltaMode&&Math.abs(t.deltaX)<4&&Math.abs(t.deltaY)<4||(Math.abs(t.deltaX)>=Math.abs(t.deltaY)?t.deltaX<0?this.navigateToLeft():this.navigateToRight():t.deltaY<0?this.navigateToPrevious():this.navigateToNext(),"vivliostyle-page-slider"!==t.currentTarget.id&&(this.justPageMovedByWheel=!0,window.setTimeout(()=>{this.justPageMovedByWheel=!1},166))),!0),this.onwheelViewport=(e,t)=>{const i=document.getElementById("vivliostyle-viewer-viewport");return!!(this.viewer.tocVisible()&&i!=document.activeElement||i.scrollWidth>i.clientWidth||i.scrollHeight>i.clientHeight)||this.onwheelPageSlider(e,t)},this.onclickViewport=(e,t)=>{if(this.pageNumber(),this.settingsPanel.justClicked)return!0;if(this.viewer.tocVisible()&&!this.viewer.tocPinned()){const e=document.querySelector("[data-vivliostyle-toc-box]");e&&!e.contains(document.activeElement)&&this.toggleTOC()}return this.settingsPanel.opened()&&!this.settingsPanel.pinned()&&this.settingsPanel.close(),de.enabled()&&de.marksBox.detailsElement.open&&!de.marksBox.pinned()&&(de.marksBox.detailsElement.open=!1),!0},this.toggleTOC=()=>{if(this.isTOCToggleDisabled())return!1;{let e=0;return this.viewer.tocVisible()?this.justClicked?(this.viewer.showTOC(!0,!1),this.justClicked=!1):(e&&(window.clearInterval(e),e=0),this.viewer.showTOC(!1),this.justClicked=!0,window.setTimeout(()=>{this.justClicked&&(document.getElementById("vivliostyle-viewer-viewport").focus(),this.justClicked=!1)},300)):(this.justClicked?(this.viewer.showTOC(!0,!1),this.justClicked=!1):(this.viewer.showTOC(!0,!0),this.justClicked=!0),e=window.setInterval(()=>{const t=document.querySelector("[data-vivliostyle-toc-box]");t&&"visible"===t.style.visibility&&(t.tabIndex=0,t.focus(),window.clearInterval(e),e=0),this.justClicked=!1},300)),!0}},this.navigateTOC=e=>{const t=Array.from(document.querySelectorAll("[data-vivliostyle-toc-box]>*>*>*>*>*:not([hidden]) [tabindex='0'],[data-vivliostyle-toc-box]>*>*>*>*>*:not([hidden]) a[href]:not([tabindex='-1'])"));let i=t.indexOf(document.activeElement);const n=e=>t[e]&&"button"===t[e].getAttribute("role"),r=e=>t[e]&&"true"===t[e].getAttribute("aria-expanded");switch(e){case fe.ArrowLeft:if(-1==i){i=t.length-1;break}if(!n(i)&&n(i-1)&&i--,n(i)&&r(i))t[i].click();else for(let e=i-1;e>=0;e--)if(n(e)&&t[e].parentElement.contains(t[i])){i=e;break}break;case fe.ArrowRight:if(-1==i){i=0;break}!n(i)&&n(i-1)&&i--,n(i)&&(r(i)?i+=2:t[i].click());break;case fe.ArrowDown:i++;break;case fe.ArrowUp:if(-1==i){i=t.length-1;break}i>0&&n(--i)&&i--;break;case fe.Home:i=0;break;case fe.End:i=t.length-1;break;case fe.Space:!n(i)&&n(i-1)&&i--,n(i)&&t[i].click()}return n(i)&&i++,t[i]&&t[i].focus(),!0},this.toggleMarker=()=>!this.isMarkerToggleDisabled()&&(de.toggleEnableMarker(),!0),this.handleKey=e=>{if(this.settingsPanel.opened()&&this.settingsPanel.settingsToggle.contains(document.activeElement))return!0;const t=document.getElementById("vivliostyle-page-number"),i=document.getElementById("vivliostyle-viewer-viewport"),n=i.scrollWidth>i.clientWidth,r=i.scrollHeight>i.clientHeight,o=t===document.activeElement,s=this.viewer.tocVisible()&&!o&&i!=document.activeElement;if(!s&&i!=document.activeElement&&i.contains(document.activeElement))return!0;switch(e){case"+":return o||!this.increaseFontSize();case"-":return o||!this.decreaseFontSize();case"0":return o||!this.defaultFontSize();case"1":return o||!this.zoomToActualSize();case fe.ArrowLeft:return s?!this.navigateTOC(e):o||n||!this.navigateToLeft();case fe.ArrowRight:return s?!this.navigateTOC(e):o||n||!this.navigateToRight();case fe.ArrowDown:return s?!this.navigateTOC(e):(i.focus(),r||!this.navigateToNext());case fe.ArrowUp:return s?!this.navigateTOC(e):(i.focus(),r||!this.navigateToPrevious());case fe.PageDown:return!!s||(i.focus(),!this.navigateToNext());case fe.PageUp:return!!s||(i.focus(),!this.navigateToPrevious());case fe.Home:return s?!this.navigateTOC(e):(i.focus(),!this.navigateToFirst());case fe.End:return s?!this.navigateTOC(e):(i.focus(),!this.navigateToLast());case"o":case"O":return i.focus(),!this.zoomOut();case"i":case"I":return i.focus(),!this.zoomIn();case"p":case"P":return i.focus(),!this.print();case"f":case"F":return i.focus(),!this.toggleFitToScreen();case"g":case"G":return t.focus(),!1;case"t":case"T":return i.focus(),!this.toggleTOC();case"m":case"M":return i.focus(),!this.toggleMarker();case fe.Escape:if(de.enabled()){if(de.menuStatus.startButtonOpened())return de.menuStatus.closeStartButton(),!1;if(de.menuStatus.menuOpened())return"vivliostyle-memo-edit-area"===document.activeElement.id||(de.menuStatus.closeMenu(),!1);if(de.marksBox.detailsElement.open)return de.marksBox.detailsElement.open=!1,!1}return this.viewer.tocVisible()?!this.toggleTOC():(i.focus(),!0);case fe.Space:return s?!this.navigateTOC(e):"button"!==document.activeElement.getAttribute("role")||(document.activeElement.click(),!1);default:return!0}},this.print=()=>!this.isPrintDisabled()&&(window.print(),!0),this.justClicked=!1,this.justPageMovedByWheel=!1,this.isDisabled=a.pureComputed(()=>this.settingsPanel.opened()&&!this.settingsPanel.pinned()||!this.viewer.state.navigatable());const r=a.pureComputed(()=>n.disablePageNavigation||this.isDisabled());r.subscribe(e=>{const t=document.getElementById("vivliostyle-page-number");t&&(t.disabled=e)}),this.isPageNumberDisabled=a.pureComputed(()=>r()),this.isPageSliderDisabled=a.pureComputed(()=>!(!n.disablePageSlider&&!r())||Number(this.totalPages())<=1),this.isNavigateToPreviousDisabled=a.pureComputed(()=>!!r()||void 0!==this.viewer.state.status&&this.viewer.firstPage()),this.isNavigateToNextDisabled=a.pureComputed(()=>!!r()||void 0!==this.viewer.state.status&&((!this.viewerOptions.renderAllPages()||this.viewer.state.status()==m.ReadyState.COMPLETE)&&this.viewer.lastPage())),this.isNavigateToLeftDisabled=a.pureComputed(()=>!!r()||void 0!==this.viewer.state.pageProgression&&(this.viewer.state.pageProgression()===m.PageProgression.LTR?this.isNavigateToPreviousDisabled():this.isNavigateToNextDisabled())),this.isNavigateToRightDisabled=a.pureComputed(()=>!!r()||void 0!==this.viewer.state.pageProgression&&(this.viewer.state.pageProgression()===m.PageProgression.LTR?this.isNavigateToNextDisabled():this.isNavigateToPreviousDisabled())),this.isNavigateToFirstDisabled=this.isNavigateToPreviousDisabled,this.isNavigateToLastDisabled=a.pureComputed(()=>!!r()||void 0!==this.viewer.state.status&&(!(!this.viewerOptions.renderAllPages()||this.viewer.state.status()==m.ReadyState.COMPLETE)||this.viewer.lastPage())),this.hidePageNavigation=!!n.disablePageNavigation;const o=a.pureComputed(()=>n.disableZoom||this.isDisabled());this.isZoomOutDisabled=o,this.isZoomInDisabled=o,this.isZoomToActualSizeDisabled=o,this.isToggleFitToScreenDisabled=o,this.hideZoom=!!n.disableZoom,this.fitToScreen=a.pureComputed(()=>e.zoom().fitToScreen);const s=a.pureComputed(()=>n.disableFontSizeChange||this.isDisabled()||this.viewer.state.fixedLayout());if(this.isIncreaseFontSizeDisabled=a.pureComputed(()=>!!s()||Number(this.viewerOptions.fontSize())>=72),this.isDecreaseFontSizeDisabled=a.pureComputed(()=>!!s()||Number(this.viewerOptions.fontSize())<=5),this.isDefaultFontSizeDisabled=s,this.hideFontSizeChange=!!n.disableFontSizeChange,this.isTOCToggleDisabled=a.pureComputed(()=>n.disableTOCNavigation||this.isDisabled()||null==this.viewer.tocVisible()),this.hideTOCNavigation=!!n.disableTOCNavigation,this.hidePageSlider=!!n.disablePageSlider,this.isFindBoxDisabled=a.pureComputed(()=>n.disableFind||this.isDisabled()||this.viewer.state.fixedLayout()),this.hideFind=!!n.disableFind,this.isMarkerToggleDisabled=a.pureComputed(()=>n.disableMarker||this.isDisabled()),this.hideMarker=!!n.disableMarker,this.isPrintDisabled=a.pureComputed(()=>!(!n.disablePrint&&!this.isDisabled()&&this.viewer.state.status()==m.ReadyState.COMPLETE)),this.hidePrint=!!n.disablePrint,n.disablePrint){const e=document.createElement("style");e.setAttribute("media","print"),e.textContent="*{display:none}",document.head.appendChild(e)}this.pageNumber=a.pureComputed({read(){return this.viewer.epageToPageNumber(this.viewer.epage())},write(e){const t=this.viewer.epage(),i=this.viewer.epageToPageNumber(t);let n=parseFloat(e.toString().replace(/[0-9]/g,e=>String.fromCharCode(e.charCodeAt(0)-65248)))||0;if(/^[-+]/.test(e.toString())&&(n=i+n),n<1)n=1;else{const e=this.viewer.epageCount();this.viewerOptions.renderAllPages()?n>e&&(n=e):n>e+1&&(n=e+1)}const r=this.viewer.epageFromPageNumber(n),o=document.getElementById("vivliostyle-page-number");o.value=n.toString(),window.history.pushState(null,null),this.viewer.navigateToEPage(r),window.setTimeout(()=>{this.viewer.state.status()!=m.ReadyState.LOADING&&this.viewer.epage()===t&&(o.value=i.toString()),document.getElementById("vivliostyle-viewer-viewport").focus()},10)},owner:this}),this.totalPages=a.pureComputed(()=>{let e=this.viewer.epageCount();if(!e)return e;const t=Number(this.pageNumber());return this.viewer.lastPage()||t>e?e=t:t==e&&e++,e}),this.pageSlider=a.pureComputed({read(){const e=Number(this.pageNumber()),t=document.getElementById("vivliostyle-page-slider");return Number(t.max)<e&&(t.max=String(e)),e},write(e){if(this.viewerOptions.renderAllPages()){const t=Number(e),i=this.viewer.epageFromPageNumber(t);this.viewer.navigateToEPage(i)}else{document.getElementById("vivliostyle-page-number").value=String(e)}},owner:this}),this.pageSliderMax=this.totalPages}updateFontSizeSettings(){this.settingsPanel.state.viewerOptions.fontSize(this.viewerOptions.fontSize()),this.viewer.documentOptions.pageStyle.baseFontSizeSpecified()&&(this.viewer.documentOptions.updateCustomStyleSheetFromCSSText(),this.viewer.loadDocument(this.viewer.documentOptions,this.viewerOptions))}}const{Keys:me}=z;class ve{constructor(e,t,i,n,r){this.viewerOptions=e,this.documentOptions=t,this.viewer=i,this.close=()=>{this.opened(!1),this.pinned(!1);const e=document.getElementById("vivliostyle-viewer-viewport");e&&e.focus()},this.toggle=()=>{this.opened()?this.justClicked?(this.justClicked=!1,this.pinned(!0)):(this.close(),this.justClicked=!0,window.setTimeout(()=>{this.justClicked=!1},300)):(this.viewer.tocPinned()||this.viewer.showTOC(!1),this.opened(!0),this.justClicked?(this.justClicked=!1,this.pinned(!0)):(this.pinned(!1),this.justClicked=!0,this.focusToFirstItem(),window.setTimeout(()=>{this.justClicked=!1},300)))},this.apply=()=>{const e=this.documentOptions.pageStyle.customStyleAsUserStyle()!==this.state.pageStyle.customStyleAsUserStyle();this.documentOptions.pageStyle.copyFrom(this.state.pageStyle),e&&this.documentOptions.switchCustomStyleUserOrAuthorStyleSheets(),this.documentOptions.pageStyle.baseFontSizeSpecified()&&this.documentOptions.updateCustomStyleSheetFromCSSText(),this.viewer.loadDocument(this.documentOptions,this.state.viewerOptions),this.pinned()?this.focusToFirstItem():this.close()},this.cancel=()=>{this.state.viewerOptions.copyFrom(this.viewerOptions),this.state.pageStyle.copyFrom(this.documentOptions.pageStyle),this.close()},this.uiLanguage=a.pureComputed({read:()=>f.i18n.language,write:e=>{f.setLanguage(e),C.hasParameter("lng")&&C.setParameter("lng",e);try{window.localStorage.setItem("i18nextLng",e)}catch(e){}}}),this.isPageStyleChangeDisabled=!!r.disablePageStyleChange,this.isPageViewModeChangeDisabled=!!r.disablePageViewModeChange,this.isBookModeChangeDisabled=!!r.disableBookModeChange,this.isRenderAllPagesChangeDisabled=!!r.disableRenderAllPagesChange,this.isRestoreViewChangeDisabled=!!r.disableRestoreViewChange,this.isUILanguageChangeDisabled=!!r.disableUILanguageChange,this.justClicked=!1,this.settingsToggle=document.getElementById("vivliostyle-menu-item_settings-toggle"),this.opened=a.observable(!1),this.pinned=a.observable(!1),this.state={viewerOptions:new R(e),pageStyle:new w(t.pageStyle),pageViewMode:a.pureComputed({read:()=>this.state.viewerOptions.pageViewMode().toString(),write:e=>{this.state.viewerOptions.pageViewMode(E.of(e))}}),bookMode:a.observable(t.bookMode()),renderAllPages:a.pureComputed({read:()=>this.state.viewerOptions.renderAllPages(),write:e=>{this.state.viewerOptions.renderAllPages(e)}}),restoreView:a.observable(C.isEnabledRestoreView())},this.state.pageStyle.setViewerFontSizeObservable(this.state.viewerOptions.fontSize),this.defaultPageStyle=new w,this.defaultPageStyle.setViewerFontSizeObservable(a.observable(16)),n.visible.subscribe(e=>{e&&this.close()}),this.state.bookMode.subscribe(e=>{t.bookMode(e)}),this.state.renderAllPages.subscribe(t=>{e.renderAllPages(t)}),this.state.restoreView.subscribe(e=>{C.enableRestoreView(e),e?C.setParameter("restoreView","true"):C.removeParameter("restoreView")}),this.resetCustomStyle=a.pureComputed({read(){if(!this.state.pageStyle.equivalentTo(this.defaultPageStyle))return!1;return document.getElementsByName("vivliostyle-settings_reset-custom-style")[0].checked},write(e){e&&(this.state.pageStyle.copyFrom(this.defaultPageStyle),this.state.viewerOptions.fontSize(R.getDefaultValues().fontSize))},owner:this})}focusToFirstItem(e){const t=e||this.settingsToggle,i=["input","textarea","summary","select"].includes(t.localName)?t:Array.from(t.getElementsByTagName("input")).find(e=>!e.disabled&&("radio"!=e.type||e.checked));if(i){for(let e=i.parentElement;e&&e!=this.settingsToggle;e=e.parentElement)"details"==e.localName&&(e.open=!0);i.focus()}}handleKey(e){const t=this.opened()&&this.settingsToggle.contains(document.activeElement),i=t&&("text"==document.activeElement.type||"select"==document.activeElement.localName),n=t&&"textarea"==document.activeElement.localName,r=t&&!i&&!n;switch(e){case me.Escape:return this.opened()&&(this.cancel(),this.close()),!0;case"s":case"S":return!(!this.opened()||r||!t)||(this.toggle(),!1);case"l":case"L":return!r||(this.focusToFirstItem(document.getElementsByName("vivliostyle-settings_ui-language")[0]),!1);case"p":case"P":return!r||(this.focusToFirstItem(document.getElementById("vivliostyle-settings_page-view-and-rendering").firstElementChild),!1);case"v":case"V":return!r||(this.focusToFirstItem(document.getElementById("vivliostyle-settings_page-view-mode")),!1);case"b":case"B":return!r||(this.focusToFirstItem(document.getElementsByName("vivliostyle-settings_book-mode")[0]),!1);case"a":case"A":return!r||(this.focusToFirstItem(document.getElementsByName("vivliostyle-settings_render-all-pages")[0]),!1);case"c":case"C":return!r||(this.focusToFirstItem(document.getElementById("vivliostyle-settings_custom-style").firstElementChild),!1);case"m":case"M":return!r||(this.focusToFirstItem(document.getElementById("vivliostyle-settings_custom-style_more").firstElementChild),!1);case"z":case"Z":return!r||(this.focusToFirstItem(document.getElementById("vivliostyle-settings_page-size")),!1);case"o":case"O":return!r||(this.focusToFirstItem(document.getElementById("vivliostyle-settings_crop-marks")),!1);case"g":case"G":return!r||(this.focusToFirstItem(document.getElementById("vivliostyle-settings_page-margin")),!1);case"k":case"K":return!r||(this.focusToFirstItem(document.getElementById("vivliostyle-settings_page-breaks")),!1);case"i":case"I":return!r||(this.focusToFirstItem(document.getElementById("vivliostyle-settings_images")),!1);case"t":case"T":return!r||(this.focusToFirstItem(document.getElementById("vivliostyle-settings_text")),!1);case"y":case"Y":return!r||(this.focusToFirstItem(document.getElementById("vivliostyle-settings_priority")),!1);case"e":case"E":return!r||(this.focusToFirstItem(document.getElementsByName("vivliostyle-settings_edit-css")[0]),!1);case"r":case"R":return!r||(this.focusToFirstItem(document.getElementsByName("vivliostyle-settings_reset-custom-style")[0]),!1);case me.Enter:return!(i||r&&"vivliostyle-menu-button_apply"!==document.activeElement.id&&"vivliostyle-menu-button_cancel"!==document.activeElement.id)||(document.getElementById("vivliostyle-menu-button_apply").focus(),!1);default:return!0}}}const{Keys:ye}=z;var be;!function(e){e.Default="",e.Searching="Searching",e.Found="Found",e.NotFound="Not Found"}(be||(be={}));class we{constructor(e,t){this.viewer=e,this.navigation=t,this.cancel=!1,this.intervalID=0,this.foundRange=null,this.toggle=()=>this.opened()?this.close():this.open(),this.open=()=>!this.navigation.isFindBoxDisabled()&&(this.opened(!0),window.setTimeout(()=>{document.getElementById("vivliostyle-find-box").focus()},0),!0),this.close=()=>!this.navigation.isFindBoxDisabled()&&(this.opened(!1),this.status()===be.Searching&&(this.cancel=!0),this.status(be.Default),this.foundRange=null,this.fixHighlight(),!0),this.findPrevious=()=>this.findSub(!0),this.findNext=()=>this.findSub(!1),this.opened=a.observable(),this.text=a.observable(""),this.status=a.observable(be.Default),this.text.subscribe(e=>{""!=e?C.setParameter("find",x.percentEncodeAmpersandAndUnencodedPercent(e)):C.removeParameter("find")})}findSub(e){if(this.navigation.isFindBoxDisabled()||this.status()===be.Searching)return!1;if(this.intervalID)return window.clearInterval(this.intervalID),this.intervalID=0,!0;const t=this.text();if(!t)return!1;const i=this.viewer.epage();let n=-1,r=!1;return this.status(be.Searching),this.intervalID=window.setInterval(()=>{if(this.cancel)return this.cancel=!1,this.status(be.Default),window.clearInterval(this.intervalID),void(this.intervalID=0);if(n===this.viewer.epage())return;n=this.viewer.epage(),(r||n!==i)&&window.getSelection().empty();if(this.findText(t,e))return this.status(be.Found),window.clearInterval(this.intervalID),void(this.intervalID=0);!r&&(e?this.viewer.firstPage():this.viewer.lastPage())?(r=!0,this.viewer.firstPage()&&this.viewer.lastPage()?n=-1:e?this.viewer.navigateToLast():this.viewer.navigateToFirst()):!r||(e?n>i:n<i)?e?this.viewer.navigateToPrevious():this.viewer.navigateToNext():(this.status(be.NotFound),window.clearInterval(this.intervalID),this.intervalID=0,n!==i&&this.viewer.navigateToEPage(i))},4),!0}findText(e,t){var i,n;const r=window.getSelection();"Range"!==r.type&&r.empty();const o=window,s=document.getElementById("vivliostyle-menu-find-box");s.style.visibility="hidden",this.foundRange&&0===r.rangeCount&&(r.addRange(this.foundRange),this.foundRange=null,this.fixHighlight());const a=o.find(e,!1,t);return s.style.visibility="",!!a&&((null===(n=null===(i=r.anchorNode)||void 0===i?void 0:i.parentElement)||void 0===n?void 0:n.closest("[data-adapt-eloff]"))?(this.foundRange=r.getRangeAt(0),this.fixHighlight(),!0):this.findText(e,t))}fixHighlight(){if(!/iPad|iPhone|iPod/.test(navigator.userAgent))return;const e=document.querySelectorAll("[data-viv-found-highlight='true']");for(const t of e)t.remove();if(!this.foundRange)return;const t=this.foundRange.startContainer.parentElement.closest("[data-vivliostyle-page-container='true']"),i=t.getBoundingClientRect();for(const e of this.foundRange.getClientRects()){const n=V(e,i),r=document.createElement("div");r.setAttribute("data-viv-found-highlight","true"),r.style.position="absolute",r.style.left=`${n.left}px`,r.style.top=`${n.top}px`,r.style.width=`${n.width}px`,r.style.height=`${n.height}px`,r.style.backgroundColor="#0080ff33",t.appendChild(r)}}handleKey(e,t,i){const n=t.ctrlKey||t.metaKey;switch(e){case ye.Escape:if(n||!this.opened())return!0;if(this.status()===be.Searching)return this.cancel=!0,!1;if(i&&""!==this.text())return this.text(""),this.status(be.Default),!1;if(this.close())return!1;break;case"Enter":if(n||!this.opened())return!0;if(i&&document.getElementById("vivliostyle-find-box").blur(),t.shiftKey?this.findPrevious():this.findNext())return!1;break;case"f":case"F":if(!n)return!0;if(this.open())return!1;break;default:this.status(be.Default)}return!0}}class xe{constructor(e){this.list=e,this.visible=a.pureComputed(()=>e().length>0)}getDisplayMessage(e){var t,i;return null!==(i=null===(t=e.error)||void 0===t?void 0:t.toString())&&void 0!==i?i:e.messages.join("\n")}}const{Keys:Se}=z;class Ce{constructor(){var e,t;this.t=f.t,this.i18n=f.i18n;const i=[].concat(null!==(e=document.documentElement.getAttribute("data-vivliostyle-viewer-flags"))&&void 0!==e?e:[],C.getParameter("flags")).join(),n=i.includes("S"),r={disablePageStyleChange:n||i.includes("P"),disablePageViewModeChange:n||i.includes("V"),disableBookModeChange:n||i.includes("B"),disableRenderAllPagesChange:n||i.includes("A"),disableRestoreViewChange:n||i.includes("R"),disableUILanguageChange:n||i.includes("L")},o={disableTOCNavigation:i.includes("T"),disableFind:i.includes("f"),disableMarker:i.includes("m"),disablePageNavigation:i.includes("N"),disableZoom:i.includes("Z"),disableFontSizeChange:i.includes("F"),disablePageSlider:i.includes("s"),disablePrint:i.includes("p")},s=i.includes("c"),a=!i.includes("k"),l=!i.includes("a"),h=i.includes("d");if(n){const e=document.getElementById("vivliostyle-welcome");e&&e.remove();const t=document.querySelector(".vivliostyle-menu-detail"),i=document.querySelector(".vivliostyle-menu-detail-main");t&&i&&(i.style.visibility="hidden",t.style.height="auto")}s&&(document.oncontextmenu=()=>!1),this.documentOptions=new k(a),this.viewerOptions=new R(l),h&&this.viewerOptions.allowScripts(!1),this.documentOptions.pageStyle.setViewerFontSizeObservable(this.viewerOptions.fontSize),this.viewerOptions.profile()&&v.profiler.enable(),this.isDebug="true"===C.getParameter("debug")[0],this.viewerSettings={userAgentRootURL:`${C.getBaseURL()}resources/`,viewportElement:document.getElementById("vivliostyle-viewer-viewport"),debug:this.isDebug};const u=C.getParameter("src"),c=C.getParameter("b"),d=C.getParameter("x");u.length||(c.length?(C.setParameter("src",c[0]),C.hasParameter("bookMode")||C.setParameter("bookMode","true"),C.hasParameter("renderAllPages")||C.setParameter("renderAllPages","false")):d.length&&(d.forEach((e,t)=>{C.setParameter("src",e,t)}),C.hasParameter("bookMode")||C.setParameter("bookMode","false")));let p=C.getParameter("restoreView")[0];"false"!==p&&(C.hasParameter("f")||C.restoreViewSettings()&&(p=C.getParameter("restoreView")[0]),"true"===p&&C.enableRestoreView(!0)),C.removeParameter("b"),C.removeParameter("x"),C.removeParameter("f",!0),C.removeParameter("spread",!0),C.removeParameter("bookMode",!0),C.removeParameter("allowScripts",!0),C.removeParameter("renderAllPages",!0),C.removeParameter("fontSize",!0),C.removeParameter("zoom",!0),C.removeParameter("find",!0),C.removeParameter("profile",!0),C.removeParameter("debug",!0),C.removeParameter("pixelRatio",!0),C.removeParameter("restoreView",!0),C.removeParameter("lng",!0),this.viewer=new M(this.viewerSettings,this.viewerOptions),this.viewer.inputUrl.subscribe(e=>{""!=e?(C.hasParameter("src")||C.history.pushState&&C.history.pushState(null,""),e=e.startsWith("<")?"data:,"+x.percentEncodeForDataURI(e):x.percentEncodeAmpersandAndUnencodedPercent(e),C.setParameter("src",e),this.documentOptions.srcUrls(C.getParameter("src"))):C.removeParameter("src")}),this.messageDialog=new xe(L),this.settingsPanel=new ve(this.viewerOptions,this.documentOptions,this.viewer,this.messageDialog,r),this.navigation=new ge(this.viewerOptions,this.viewer,this.settingsPanel,o),this.findBox=new we(this.viewer,this.navigation);const g=decodeURIComponent(null!==(t=C.getParameter("find")[0])&&void 0!==t?t:"");g&&this.findBox.text(g),this.marksStore=de,this.marksStore.init(this.viewerOptions,this.viewer),this.marksMenuStatus=de.menuStatus,this.marksBox=de.marksBox,this.viewer.rerenderTrigger.subscribe(()=>{this.marksStore.retryHighlightMarks()}),this.viewer.loadDocument(this.documentOptions),window.onhashchange=()=>{window.location.href!=C.storedUrl&&window.location.reload()}}handleKey(e,t){if(t.isComposing||t.keyCode&&("Enter"===t.key&&13!==t.keyCode&&16!==t.keyCode||"Escape"===t.key&&27!==t.keyCode))return!0;const i=z.identifyKeyFromEvent(t);if("vivliostyle-input-url"===document.activeElement.id)return"Enter"!==i||(this.viewer.loadDocument(this.documentOptions),!1);if("vivliostyle-find-box"===document.activeElement.id)return this.findBox.handleKey(i,t,!0);let n=this.findBox.handleKey(i,t,!1);return!!n&&(!(i===Se.Escape||!document.activeElement.closest("#vivliostyle-marks-box, #vivliostyle-text-selection-start-button, #vivliostyle-text-selection-edit-menu, [data-vivliostyle-page-container]"))||(!!("Home"!==i&&"End"!==i&&"p"!==i&&"P"!==i&&(t.ctrlKey||t.metaKey)||t.altKey||t.shiftKey)||(n=this.settingsPanel.handleKey(i),n&&(n=this.navigation.handleKey(i)),n)))}}const ke="ontouchstart"in window;a.bindingHandlers.menuButton={init(e,t){a.unwrap(t())&&(ke?(e.addEventListener("touchstart",()=>{a.utils.toggleDomNodeCssClass(e,"hover active",!0)}),e.addEventListener("touchend",()=>{a.utils.toggleDomNodeCssClass(e,"hover active",!1)})):(e.addEventListener("mouseover",()=>{a.utils.toggleDomNodeCssClass(e,"hover",!0)}),e.addEventListener("mousedown",()=>{a.utils.toggleDomNodeCssClass(e,"active",!0)}),e.addEventListener("mouseup",()=>{a.utils.toggleDomNodeCssClass(e,"active",!1)}),e.addEventListener("mouseout",()=>{a.utils.toggleDomNodeCssClass(e,"hover",!1),a.utils.toggleDomNodeCssClass(e,"active",!1)})))}};const Pe="ontouchstart"in window;let Ee=null,Ne=null,Te=null;a.bindingHandlers.swipePages={init(e,t){Pe&&a.unwrap(t())&&(e.addEventListener("touchstart",e=>{if(e.touches.length>1)return;if(window.visualViewport&&window.visualViewport.scale>1)return;const t=document.getElementById("vivliostyle-viewer-viewport");t&&t.scrollWidth>t.clientWidth||"Range"!==document.getSelection().type&&(Ee=e.touches[0].clientX,Ne=e.touches[0].clientY)}),e.addEventListener("touchmove",e=>{if(!(e.touches.length>1)&&"Range"!==document.getSelection().type&&null!==Ee&&null!==Ne){const t=e.touches[0].clientX-Ee,i=e.touches[0].clientY-Ne;Math.abs(t)>Math.abs(i)&&(Te=t<0?document.getElementById("vivliostyle-page-navigation-right"):document.getElementById("vivliostyle-page-navigation-left")),Math.abs(t)+Math.abs(i)>=16&&(Te&&(Te.click(),a.utils.toggleDomNodeCssClass(Te,"active",!0)),Ee=null,Ne=null)}}),e.addEventListener("touchend",()=>{Te&&a.utils.toggleDomNodeCssClass(Te,"active",!1),Te=null,Ee=null,Ne=null}))}},a.bindingHandlers.textSelection={init(e,t){const i=/iPad|iPhone|iPod/.test(navigator.userAgent);let n=!1;if(a.unwrap(t())){e.addEventListener("mousedown",()=>{n||"Range"===document.getSelection().type||(n=!0)}),document.addEventListener("mouseup",()=>{n&&(de.enabled()&&re(document.getSelection()),n=!1)});const t=document.getElementById("vivliostyle-page-navigation-left"),r=document.getElementById("vivliostyle-page-navigation-right");t&&r&&(t.onpointermove=r.onpointermove=()=>!1,t.ontouchmove=r.ontouchmove=()=>!1);let o=0;document.addEventListener("selectionchange",()=>{const e=document.getSelection();if("Range"!==e.type)return;const s=e.getRangeAt(0);if(!s.commonAncestorContainer.parentElement.closest("[data-vivliostyle-spread-container]"))return;const a=s.commonAncestorContainer.parentElement.closest("[data-vivliostyle-page-box] > div"),l=null==a?void 0:a.style.zIndex;o||(t&&r&&(i?(t.style.display="none",r.style.display="none"):(t.style.height="min-content",r.style.height="min-content")),a&&"0"===l&&(a.style.zIndex="1"),o=window.setTimeout(()=>{t&&r&&(t.style.display="",r.style.display="",t.style.height="",r.style.height=""),a&&(a.style.zIndex=l),o=0},1e3)),!n&&de.enabled()&&(pe.menuOpened()&&pe.applyEditing(),pe.startButtonOpened()&&pe.startButtonOpened(!1),re(e))})}}},a.bindingHandlers.clickOutside={init(e,t){const i=a.utils.unwrapObservable(t());document.addEventListener("mousedown",t=>{"none"!=window.getComputedStyle(e).display&&(e.contains(t.target)||e===t.target||i())})}};const Ie={en:{translation:{UI_LNG:"en",TIP_UI_Language:"Language of UI",CONFIRM_DELETE:"Do you really want to delete it?",CONFIRM_REMOVE:"Do you really want to remove it?",CONFIRM_REMOVE_ALL:"Do you really want to remove all?",Input_:"Input a document URL or HTML code",Book_Mode:"Book Mode",Render_All_Pages:"Render All Pages",Apply:"Apply",Supported_document_types_:"Supported document types:",HTML_documents_:"HTML documents, with CSS for paged media",Book_like_publications_:"Book-like publications, with Table of Contents",Web_publications_:"Web publications (a collection of HTML documents): specify URL of the first HTML or the manifest file.",Unzipped_EPUB_:"Unzipped EPUB: specify URL of OPF file or top directory of the unzipped EPUB files.",Notes_:"Notes:",GitHub_:"GitHub and Gist URLs can be directly specified. Vivliostyle loads raw github/gist content when such URL is specified.",WARN_Mixed_Content_:"⚠️Mixed Content (“http:” URL is specified to “https:” Vivliostyle Viewer) is usually blocked by browser.",WARN_Cross_Origin_:"⚠️Cross-Origin (request to different domain) is usually blocked by browser unless the server is configured to allow Cross-Origin Resource Sharing (CORS).",URL_parameter_options_:"URL parameter options:",document_URL:"document URL",default_:"(default)",for_Book_like_:"for Book-like publications",DESC_Book_Mode_:"When an HTML document URL is specified, a series of HTML documents linked from the publication manifest or Table of Contents (e.g., marked up with '<nav role=\"doc-toc\">') are automatically loaded.",for_single_HTML_:"for single HTML documents",for_Print_:"for Print (all pages printable, page count works as expected)",for_Read_:"for Read (quick loading with rough page count)",Page_Spread_View:"Page Spread View",Spread_view:"Spread view",Single_page_view:"Single page view",Auto_spread_view:"Auto spread view",additional_stylesheet_URL:"additional (custom) stylesheet URL",user_stylesheet_URL:"user stylesheet URL",Settings:"Settings",DESC_Options_also_1:"Options can also be set in the ",DESC_Options_also_2:" panel.",See_documentation_:"For more details, see documentation:",HREF_User_Guide:"../docs/#/user-guide",Vivliostyle_User_Guide:"Vivliostyle User Guide",HREF_Vivlistyle_Home:"https://vivliostyle.org/",navigate_to_left:"navigate to left",navigate_to_right:"navigate to right",Highlight_:"Highlight…",Marker_Yellow:"Marker: Yellow",Marker_Red:"Marker: Red",Marker_Green:"Marker: Green",OK:"OK",Cancel:"Cancel",Delete:"Delete",TIP_Settings:"Settings (S), Double click/type to pin",Page_View_Mode:"Page View Mode",Auto:"Auto",Single_page:"Single page",Spread:"Spread",TIP_Book_Mode:"On: for Book-like publications, with Table of Contents\nOff: for single HTML documents",TIP_Render_All_Pages:"On: for Print (all pages printable, page count works)\nOff: for Read (quick loading with rough page count)",Restore_View:"Restore View",TIP_Restore_View:"Restore view settings when reopening documents",Custom_Style_Settings:"Custom Style Settings",Page_Size:"Page Size",Default:"Default",DESC_page_size_default:"(=Auto unless specified elsewhere)",DESC_page_size_auto:"(use entire window area)",Preset:"Preset",Landscape:"Landscape",Custom_size:"Custom size",Width:"Width",Height:"Height",More_:"More…",Crop_Marks:"Crop Marks",Crop_marks:"Crop marks",Bleed:"Bleed",Crop_offset:"Crop offset",Page_Margins:"Page Margins",DESC_page_margin_default:"(=10% unless specified elsewhere)",Set_page_margin_to_0:"Set page margin to 0",Custom_margin:"Custom margin",Top_Right_Bottom_Left:"Top/Right/Bottom/Left",Set_first_page_margin_to_0:"Set first page margin to 0",Force_html_body_margin_to_0:"Force html/body margin to 0",Page_Breaks:"Page Breaks",Default_widows_orphans_control:"Default widows/orphans control",Allow_widows_and_orphans:"Allow widows and orphans",Avoid_page_break_inside_paragraph:"Avoid page break inside paragraph",Images:"Images",Set_image_max_size_to_fit_page:"Set image max-size to fit page",Keep_aspect_ratio:"Keep aspect ratio",Text:"Text",Font_size:"Font size",Base_font_size:"Base font-size",Base_line_height:"Base line-height",Base_font_family:"Base font-family",Custom_Style_Priority:"Custom Style Priority",Set_as_user_stylesheet:"Set as user stylesheet",DESC_user_stylesheet:"(lower priority unless !important)",Force_override_document_style:"Force override document style",important_:"(!important)",Edit_CSS:"Edit CSS",Dont_edit_:"Don't edit between /*<viewer>*/ and /*</viewer>*/.",Reset_Custom_Style:"Reset Custom Style",Reset_all_to_default:"Reset all to default",TIP_ToC:"Table of Contents (T), Double click/type to pin",TIP_Marker:"Marker (M), Double click/type to pin",Marks_and_Memos:"Marks and Memos",Remove_All:"Remove All",Remove:"Remove",Memo:"Memo",TIP_Find:"Find (Ctrl/Cmd+F)",TIP_Find_Previous:"Find Previous (Shift+Enter)",TIP_Find_Next:"Find Next (Enter)",Find:"Find",TIP_First_Page:"First Page (Home)",TIP_Previous_Page:"Previous Page (↑)",TIP_Next_Page:"Next Page (↓)",TIP_Last_Page:"Last Page (End)",TIP_Go_to_Page:"Go to Page… (G)",Total_pages:"Total pages",TIP_Text_Smaller:"Text: Smaller (-)",TIP_Text_Larger:"Text: Larger (+)",TIP_Text_Default_Size:"Text: Default Size (0)",TIP_Zoom_Out:"Zoom: Out (O)",TIP_Zoom_In:"Zoom: In (I)",TIP_Zoom_Actual_Size:"Zoom: Actual Size (1)",TIP_Zoom_Fit_to_Screen:"Zoom: Fit to Screen (F)",TIP_Print:"Print (P)"}},ja:{translation:{UI_LNG:"ja",TIP_UI_Language:"UI表示言語 (L)",CONFIRM_DELETE:"本当に削除しますか?",CONFIRM_REMOVE:"本当に削除しますか?",CONFIRM_REMOVE_ALL:"本当にすべて削除しますか?",Input_:"ドキュメントURLまたはHTMLコードを入力",Book_Mode:"Bookモード",Render_All_Pages:"全ページ組版",Apply:"適用",Supported_document_types_:"サポートされている文書の種類:",HTML_documents_:"HTML文書+ページメディア用のCSS",Book_like_publications_:"本のような出版物(目次付き)",Web_publications_:"Web出版物(複数のHTML文書からなるコレクション): 最初のHTMLまたはマニフェストファイルのURLを指定します。",Unzipped_EPUB_:"ZIP解凍済みのEPUB: OPFファイルのURLまたは解凍されたEPUBファイルのトップディレクトリを指定します。",Notes_:"メモ:",GitHub_:"GitHubとGistのURLを直接指定することができます。そのようなURLが指定された場合、Vivliostyle は github/gist の raw コンテンツをロードします。",WARN_Mixed_Content_:"⚠️Mixedコンテンツ(“http:” のURLが “https:” の Vivliostyle Viewer に指定された場合)は通常ブラウザによってブロックされます。",WARN_Cross_Origin_:"⚠️Cross-Origin(異なるドメインへのリクエスト)は、サーバーが Cross-Origin Resource Sharing (CORS) を許可するように設定されていない限り、通常はブラウザによってブロックされます。",URL_parameter_options_:"URLパラメータのオプション:",document_URL:"ドキュメントURL",default_:"(デフォルト)",for_Book_like_:"本のような出版物(目次付き)用",DESC_Book_Mode_:"HTML文書のURLが指定された場合、その出版物マニフェストまたは目次('<nav role=\"doc-toc\">' などでマークアップ)からリンクされた一連のHTML文書が自動的に読み込まれます。",for_single_HTML_:"単体のHTML文書用",for_Print_:"印刷用(すべてのページが印刷可能で、ページ番号は期待されるとおりに機能します)",for_Read_:"閲覧用(おおまかなページ番号を使って、クイックロード)",Page_Spread_View:"ページ見開き表示",Spread_view:"見開き表示",Single_page_view:"単ページ表示",Auto_spread_view:"自動見開き表示",additional_stylesheet_URL:"追加(カスタム)スタイルシートURL",user_stylesheet_URL:"ユーザースタイルシートURL",Settings:"設定",DESC_Options_also_1:"オプションは設定パネル(",DESC_Options_also_2:")でも設定できます。",See_documentation_:"詳しくは、Vivliostyleのドキュメントをご覧ください:",HREF_User_Guide:"../docs/#/ja/user-guide",Vivliostyle_User_Guide:"Vivliostyle ユーザーガイド",HREF_Vivlistyle_Home:"https://vivliostyle.org/ja/",navigate_to_left:"左にページ移動",navigate_to_right:"右にページ移動",Highlight_:"ハイライト…",Marker_Yellow:"マーカー: 黄",Marker_Red:"マーカー: 赤",Marker_Green:"マーカー: 緑",OK:"OK",Cancel:"キャンセル",Delete:"削除",TIP_Settings:"設定 (S), ダブルクリックで固定",Page_View_Mode:"ページ表示モード (P)",Auto:"自動",Single_page:"単ページ",Spread:"見開き",TIP_Book_Mode:"ON: 本のような出版物(目次付き)用\nOFF: 単体のHTML文書用",TIP_Render_All_Pages:"ON: 印刷用(すべてのページが印刷可能で、ページ番号は期待されるとおりに機能します)\nOFF: 閲覧用(おおまかなページ番号を使って、クイックロード)",Restore_View:"閲覧状態を復元",TIP_Restore_View:"文書を開き直すとき閲覧状態を復元",Custom_Style_Settings:"カスタムスタイル設定 (C)",Page_Size:"ページサイズ",Default:"デフォルト",DESC_page_size_default:"(=自動、特に指定のない限り)",DESC_page_size_auto:"(ウィンドウの全領域を使用)",Preset:"プリセット",Landscape:"ランドスケープ",Custom_size:"カスタムサイズ",Width:"幅",Height:"高さ",More_:"詳細… (M)",Crop_Marks:"トンボ設定",Crop_marks:"Crop marks",Bleed:"Bleed",Crop_offset:"Crop offset",Page_Margins:"ページマージン",DESC_page_margin_default:"(=10%、特に指定のない限り)",Set_page_margin_to_0:"ページのマージンを0にする",Custom_margin:"カスタムマージン",Top_Right_Bottom_Left:"上/右/下/左",Set_first_page_margin_to_0:"先頭ページのマージンを0にする",Force_html_body_margin_to_0:"html/bodyのマージンを強制的に0にする",Page_Breaks:"ページ分割処理",Default_widows_orphans_control:"デフォルトのwidows/orphansの制御",Allow_widows_and_orphans:"widow/orphanが生じるのを許容",Avoid_page_break_inside_paragraph:"段落内で改ページしないようにする",Images:"画像",Set_image_max_size_to_fit_page:"画像の最大サイズをページに収める",Keep_aspect_ratio:"アスペクト比を維持",Text:"テキスト",Font_size:"文字サイズ",Base_font_size:"基本の font-size",Base_line_height:"基本の line-height",Base_font_family:"基本の font-family",Custom_Style_Priority:"カスタムスタイルの優先度",Set_as_user_stylesheet:"ユーザースタイルシート扱いにする",DESC_user_stylesheet:"(!important の指定がない限り低い優先度)",Force_override_document_style:"ドキュメントのスタイルを強制的に上書き",important_:"(!important)",Edit_CSS:"CSSを編集 (E)",Dont_edit_:"/*<viewer>*/ と /*</viewer>*/ の間は編集しないこと",Reset_Custom_Style:"カスタムスタイルをリセット (R)",Reset_all_to_default:"すべてをデフォルトにリセット",TIP_ToC:"目次 (T), ダブルクリックで固定",TIP_Marker:"マーカー (M), ダブルクリックで固定",Marks_and_Memos:"マーカーとメモ",Remove_All:"すべて削除",Remove:"削除",Memo:"メモ",TIP_Find:"検索 (Ctrl/Cmd+F)",TIP_Find_Previous:"前を検索 (Shift+Enter)",TIP_Find_Next:"次を検索 (Enter)",Find:"検索",TIP_First_Page:"最初のページ (Home)",TIP_Previous_Page:"前のページ (↑)",TIP_Next_Page:"次のページ (↓)",TIP_Last_Page:"最後のページ (End)",TIP_Go_to_Page:"ページ番号… (G)",Total_pages:"総ページ数",TIP_Text_Smaller:"文字を小さく (-)",TIP_Text_Larger:"文字を大きく (+)",TIP_Text_Default_Size:"デフォルトの文字サイズ (0)",TIP_Zoom_Out:"縮小 (O)",TIP_Zoom_In:"拡大 (I)",TIP_Zoom_Actual_Size:"実際のサイズ (1)",TIP_Zoom_Fit_to_Screen:"画面に合わせる (F)",TIP_Print:"印刷 (P)"}},"zh-Hans":{translation:{UI_LNG:"zh-Hans",TIP_UI_Language:"语言",CONFIRM_DELETE:"你确定要删除它吗?",CONFIRM_REMOVE:"你确定要移除它吗?",CONFIRM_REMOVE_ALL:"你确定要全部移除吗?",Input_:"请输入文档URL或HTML代码",Book_Mode:"图书模式",Render_All_Pages:"渲染所有页面",Apply:"应用",Supported_document_types_:"支持的文档类型:",HTML_documents_:"带有分页媒体的css HTML 文档",Book_like_publications_:"类似书籍的出版物,带有目录",Web_publications_:"Web出版物(一组HTML文档集合): 指定第一个HTML或声明文件的URL。",Unzipped_EPUB_:"解压缩EPUB:指定OPF文件的URL或解压缩后EPUB文件的顶级目录。",Notes_:"注意:",GitHub_:"可以直接指定GitHub和Gist网址。当指定了此类网址时,Vivliostyle会加载原始GitHub/Gist的内容。",WARN_Mixed_Content_:"⚠️混合内容(如果“http:”的URL被指定为“https:”的Vivliostyle Viewer)通常会被浏览器屏蔽。",WARN_Cross_Origin_:"⚠️除非服务器设置为允许跨域请求(CORS),否则对不同域的请求通常会被浏览器阻止。",URL_parameter_options_:"URL 参数选项:",document_URL:"文档 URL",default_:"(默认)",for_Book_like_:"用于类似图书出版物",DESC_Book_Mode_:"当指定一个HTML文档URL, 来自出版物清单或者目录(例如, 带有 '<nav role=\"doc-toc\">'标记)一系列的html文档链接会自动被加载。",for_single_HTML_:"用户单个 HTML 文档",for_Print_:"为了打印(所有页面均可被打印,页数计算也是正常的)",for_Read_:"为了阅读(快速加载粗略页数计算)",Page_Spread_View:"页面视图对页",Spread_view:"对页视图",Single_page_view:"单页视图",Auto_spread_view:"自动对页",additional_stylesheet_URL:"附加 (自定义) 样式表 URL",user_stylesheet_URL:"用户样式表 URL",Settings:"设置",DESC_Options_also_1:"选项也可在",DESC_Options_also_2:"面板设置。",See_documentation_:"有关更多详细信息,请参阅文档:",HREF_User_Guide:"../docs/#/user-guide",Vivliostyle_User_Guide:"Vivliostyle 用户指南",HREF_Vivlistyle_Home:"https://vivliostyle.org/",navigate_to_left:"向左导航",navigate_to_right:"向右导航",Highlight_:"高亮…",Marker_Yellow:"标记: 黄",Marker_Red:"标记: 红",Marker_Green:"标记: 绿",OK:"确认",Cancel:"取消",Delete:"删除",TIP_Settings:"设置 (S),双击/双敲击键以固定",Page_View_Mode:"界面视图模式",Auto:"自动",Single_page:"单页",Spread:"对页",TIP_Book_Mode:"On: 为了类似图书出版物带有目录\nOff: 为了单 HTML 文档",TIP_Render_All_Pages:"On: 为了打印(所有页面可打印, 页面计数正常工作)\nOff: 为了阅读 (快速加载粗略计数)",Restore_View:"恢复阅览状态",TIP_Restore_View:"重新打开文档时恢复视图设置",Custom_Style_Settings:"自定义样式设置",Page_Size:"页面大小",Default:"默认",DESC_page_size_default:"(=自动 除非另外设置)",DESC_page_size_auto:"(使用整个窗口面积)",Preset:"预设",Landscape:"横向",Custom_size:"自定义尺寸",Width:"宽度",Height:"高度",More_:"详细...",Crop_Marks:"裁剪标记",Crop_marks:"裁剪标记",Bleed:"出血",Crop_offset:"裁剪偏移",Page_Margins:"页面边距",DESC_page_margin_default:"(=10% 除非另外设置)",Set_page_margin_to_0:"设置页面边距为 0",Custom_margin:"自定义边距",Top_Right_Bottom_Left:"顶部/右侧/底部/左侧",Set_first_page_margin_to_0:"设置第一页的边距为 0",Force_html_body_margin_to_0:"强制 html/body 边距为 0",Page_Breaks:"分页",Default_widows_orphans_control:"默认 widows/orphans 控制",Allow_widows_and_orphans:"允许产生widows 和 orphans",Avoid_page_break_inside_paragraph:"避免段落内出现分页",Images:"图片",Set_image_max_size_to_fit_page:"图像最大尺寸设置为适合页面",Keep_aspect_ratio:"保持长宽比",Text:"文本",Font_size:"字体大小",Base_font_size:"基础 字号",Base_line_height:"基础 行高",Base_font_family:"基础 字体",Custom_Style_Priority:"自定义 Style 属性",Set_as_user_stylesheet:"设置为用户样式表",DESC_user_stylesheet:"(低优先级除非 !important)",Force_override_document_style:"强制覆盖document的样式",important_:"(!important)",Edit_CSS:"编辑 CSS",Dont_edit_:"不要在 /*<viewer>*/ 和 /*</viewer>*/之间进行编辑",Reset_Custom_Style:"重置自定义样式",Reset_all_to_default:"重置所有",TIP_ToC:"目录 (T), 双击/双敲击键以固定",TIP_Marker:"标记 (M), 双击/双敲击键以固定",Marks_and_Memos:"标记和备忘录",Remove_All:"移除所有",Remove:"移除",Memo:"备忘录",TIP_Find:"查找 (Ctrl/Cmd+F)",TIP_Find_Previous:"查找上一个 (Shift+Enter)",TIP_Find_Next:"查找下一个 (Enter)",Find:"查找",TIP_First_Page:"首页 (Home)",TIP_Previous_Page:"上一页 (↑)",TIP_Next_Page:"下一页 (↓)",TIP_Last_Page:"最后一页(End)",TIP_Go_to_Page:"跳转到… (G)",Total_pages:"总页数",TIP_Text_Smaller:"文本: 小 (-)",TIP_Text_Larger:"文本: 大 (+)",TIP_Text_Default_Size:"文本: 默认尺寸 (0)",TIP_Zoom_Out:"缩小 (O)",TIP_Zoom_In:"放大 (I)",TIP_Zoom_Actual_Size:"缩放: 实际大小 (1)",TIP_Zoom_Fit_to_Screen:"缩放: 适应屏幕 (F)",TIP_Print:"打印 (P)"}},"zh-Hant":{translation:{UI_LNG:"zh-Hant",TIP_UI_Language:"介面語言",CONFIRM_DELETE:"確定要刪除嗎?",CONFIRM_REMOVE:"確定要移除嗎?",CONFIRM_REMOVE_ALL:"確定要全部移除嗎?",Input_:"請輸入文件網址或HTML代碼",Book_Mode:"書籍模式",Render_All_Pages:"排版所有頁面",Apply:"套用",Supported_document_types_:"支援的文件類型:",HTML_documents_:"包含供分頁媒體設計CSS的HTML文件",Book_like_publications_:"包含目次,如書的出版品",Web_publications_:"Web出版品(一組HTML文件集合):請指定第一個HTML或宣告文件的網址。",Unzipped_EPUB_:"解壓縮EPUB:請指定OPF檔案的網址或解壓縮後EPUB檔案的頂級目錄。",Notes_:"注意事項:",GitHub_:"可以直接指定GitHub和Gist網址。當指定此類網址時,Vivliostyle會載入原始GitHub/Gist的內容。",WARN_Mixed_Content_:"⚠️混合內容(例如在使用“https:”的Vivliostyle Viewer中輸入“http:”網址)通常會被瀏覽器阻擋。",WARN_Cross_Origin_:"⚠️除非伺服器設定上允許跨來源資源共享(CORS),否則對不同網域的請求通常會被瀏覽器阻擋。",URL_parameter_options_:"網址參數選項:",document_URL:"文件網址",default_:"(預設)",for_Book_like_:"用於如書的出版物",DESC_Book_Mode_:"當指定一個HTML文件網址時,會自動載入來自出版品宣告或者目次(例如標記為 '<nav role=\"doc-toc\">')的HTML文件序列連結。",for_single_HTML_:"供單一HTML文件使用",for_Print_:"供列印使用(所有頁面都能列印,頁數計算也和預估相同)",for_Read_:"供閱讀使用(因快速載入,頁數計算可能有誤)",Page_Spread_View:"頁面跨頁檢視",Spread_view:"跨頁檢視",Single_page_view:"單頁檢視",Auto_spread_view:"自動跨頁",additional_stylesheet_URL:"附加 (客製化) 樣式表網址",user_stylesheet_URL:"使用者樣式表網址",Settings:"設定",DESC_Options_also_1:"選項也可在",DESC_Options_also_2:"設定面板。",See_documentation_:"若需更多詳細資訊,請參閱文件:",HREF_User_Guide:"../docs/#/user-guide",Vivliostyle_User_Guide:"Vivliostyle使用者指引",HREF_Vivlistyle_Home:"https://vivliostyle.org/",navigate_to_left:"向左導覽",navigate_to_right:"向右導覽",Highlight_:"強調…",Marker_Yellow:"標記:黃",Marker_Red:"標記:紅",Marker_Green:"標記:綠",OK:"確認",Cancel:"取消",Delete:"刪除",TIP_Settings:"設定 (S),滑鼠或鍵盤雙擊以固定",Page_View_Mode:"頁面檢視模式",Auto:"自動",Single_page:"單頁",Spread:"跨頁",TIP_Book_Mode:"On: 供帶有目次的如書出版品\nOff: 供單一HTML文件",TIP_Render_All_Pages:"On: 供列印(所有頁面都能列印, 頁數計數正常)\nOff: 供閱讀 (頁數計算可能有誤)",Restore_View:"回復檢視狀態",TIP_Restore_View:"重新打開文件時回復檢視設定",Custom_Style_Settings:"客製化樣式設定",Page_Size:"頁面尺寸",Default:"預設",DESC_page_size_default:"(除非另有指定,不然等同auto)",DESC_page_size_auto:"(使用整個視窗空間)",Preset:"預設集",Landscape:"橫向",Custom_size:"客製化尺寸",Width:"寬度",Height:"高度",More_:"更多…",Crop_Marks:"裁切標記",Crop_marks:"裁切標記",Bleed:"出血",Crop_offset:"裁切位移",Page_Margins:"頁面邊距",DESC_page_margin_default:"(除非另有指定,不然等同10%)",Set_page_margin_to_0:"設定頁面邊距爲0",Custom_margin:"客製化邊距",Top_Right_Bottom_Left:"頂部/右側/底部/左側",Set_first_page_margin_to_0:"設定第一頁的邊距爲0",Force_html_body_margin_to_0:"強制html/body邊距爲0",Page_Breaks:"分頁",Default_widows_orphans_control:"預設widows/orphans控制",Allow_widows_and_orphans:"允許widows和orphans",Avoid_page_break_inside_paragraph:"避免分頁切斷段落",Images:"圖片",Set_image_max_size_to_fit_page:"圖像最大尺寸設定為填滿頁面",Keep_aspect_ratio:"保持長寬比",Text:"文字",Font_size:"字體尺寸",Base_font_size:"基礎 字號",Base_line_height:"基礎 行距",Base_font_family:"基礎 字體",Custom_Style_Priority:"客製化樣式優先順序",Set_as_user_stylesheet:"設定為使用者樣式表",DESC_user_stylesheet:"(除非有!important,不然優先順序低)",Force_override_document_style:"強制覆蓋文件樣式",important_:"(!important)",Edit_CSS:"編輯CSS",Dont_edit_:"不要在 /*<viewer>*/ 和 /*</viewer>*/之間進行編輯",Reset_Custom_Style:"重置客製化樣式",Reset_all_to_default:"重置全部",TIP_ToC:"目錄 (T), 雙擊/雙敲擊鍵以固定",TIP_Marker:"標記 (M), 雙擊/雙敲擊鍵以固定",Marks_and_Memos:"標記和備忘",Remove_All:"移除所有",Remove:"移除",Memo:"備忘",TIP_Find:"搜尋 (Ctrl/Cmd+F)",TIP_Find_Previous:"搜尋上一個 (Shift+Enter)",TIP_Find_Next:"搜尋下一個 (Enter)",Find:"搜尋",TIP_First_Page:"首頁 (Home)",TIP_Previous_Page:"上一頁 (↑)",TIP_Next_Page:"下一頁 (↓)",TIP_Last_Page:"最後一頁(End)",TIP_Go_to_Page:"跳到頁數… (G)",Total_pages:"總頁數",TIP_Text_Smaller:"文字: 小 (-)",TIP_Text_Larger:"文字: 大 (+)",TIP_Text_Default_Size:"文字: 預設尺寸 (0)",TIP_Zoom_Out:"縮小 (O)",TIP_Zoom_In:"放大 (I)",TIP_Zoom_Actual_Size:"縮放: 實際大小 (1)",TIP_Zoom_Fit_to_Screen:"縮放: 符合螢幕 (F)",TIP_Print:"列印 (P)"}}};f.init(Ie,function(){var e;try{let t=null===(e=/[?&#]lng=([^?&#]+)/.exec(window.location.href))||void 0===e?void 0:e[1];if(t||(t=window.localStorage.getItem("i18nextLng"),t||(t=navigator.language)),t&&(t=/^(zh(-cmn)?|cmn)-(TW|HK|Hant)\b/i.test(t)?"zh-Hant":/^(zh|cmn)\b/i.test(t)?"zh-Hans":t.toLowerCase().replace(/-.*/,""),t in Ie))return t}catch(e){}return"en"}(),a),{start(){function e(){a.applyBindings(new Ce)}window.__loaded?e():window.onload=e}}.start()});
651
+ //# sourceMappingURL=vivliostyle-viewer.js.map