generated from dellevin/template
138 lines
47 KiB
Dart
138 lines
47 KiB
Dart
import 'dart:convert';
|
||
|
||
import 'package:flutter/material.dart';
|
||
import 'epub_theme.dart';
|
||
|
||
String colorToHex(Color color) {
|
||
final argb = color.toARGB32();
|
||
return '#${argb.toRadixString(16).padLeft(8, '0').substring(2)}';
|
||
}
|
||
|
||
Map<String, dynamic> colorToMap(Color color) {
|
||
return {
|
||
'r': (color.r * 255.0).round().clamp(0, 255),
|
||
'g': (color.g * 255.0).round().clamp(0, 255),
|
||
'b': (color.b * 255.0).round().clamp(0, 255),
|
||
'a': color.a,
|
||
};
|
||
}
|
||
|
||
/// Skeleton HTML containing 3 iframes for prev/curr/next chapters
|
||
String generateSkeletonHtml(
|
||
double viewWidth,
|
||
double viewHeight,
|
||
EpubTheme theme,
|
||
int direction,
|
||
) {
|
||
final safeWidth = viewWidth.floor();
|
||
final safeHeight = viewHeight.floor();
|
||
|
||
final colorScheme = theme.colorScheme;
|
||
final primaryColor = theme.overridePrimaryColor ?? colorScheme.primary;
|
||
|
||
final initialConfigJson = jsonEncode({
|
||
'safeWidth': safeWidth,
|
||
'safeHeight': safeHeight,
|
||
'padding': {'top': theme.padding.top, 'left': theme.padding.left},
|
||
'direction': direction,
|
||
'theme': {
|
||
'zoom': theme.zoom,
|
||
|
||
'shouldOverrideTextColor': theme.shouldOverrideTextColor,
|
||
'primaryColor': colorToMap(primaryColor),
|
||
'primaryContainerColor': colorToMap(colorScheme.primaryContainer),
|
||
'surfaceColor': colorToMap(colorScheme.surface),
|
||
'onSurfaceColor': colorToMap(colorScheme.onSurface),
|
||
'onSurfaceVariantColor': colorToMap(colorScheme.onSurfaceVariant),
|
||
'outlineVariantColor': colorToMap(colorScheme.outlineVariant),
|
||
'surfaceContainerColor': colorToMap(colorScheme.surfaceContainer),
|
||
'surfaceContainerHighColor': colorToMap(colorScheme.surfaceContainerHigh),
|
||
|
||
'fontFileName': theme.fontFileName,
|
||
'overrideFontFamily': theme.overrideFontFamily,
|
||
},
|
||
'paginationCss': kPaginationCss,
|
||
});
|
||
|
||
return '''
|
||
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||
<style id="skeleton-style">
|
||
$kSkeletonCss
|
||
</style>
|
||
<script id="skeleton-script">
|
||
$kControllerJs
|
||
</script>
|
||
<script id="skeleton-srcdoc-patch">
|
||
// Patch: loadFrameSrcdoc for Windows WebView2
|
||
// Injects HTML content via srcdoc instead of src URL.
|
||
// A <base> tag is prepended so relative URLs resolve to epub:// and
|
||
// can be intercepted by shouldInterceptRequest.
|
||
window.api.loadFrameSrcdoc = function(token, slot, htmlContent, baseUrl, anchors, properties) {
|
||
var frame = this.frameMgr.getFrame(slot);
|
||
if (!frame) { window.flutter_inappwebview.callHandler("onEventFinished", token); return; }
|
||
this.state.anchors[slot] = anchors || [];
|
||
this.state.properties[slot] = properties || [];
|
||
// Store the URL anchor for onFrameLoad to scroll to
|
||
var urlAnchor = '';
|
||
if (baseUrl.indexOf('#') !== -1) {
|
||
urlAnchor = baseUrl.split('#').pop();
|
||
}
|
||
frame.onload = null;
|
||
// Prepend <base> tag for relative URL resolution
|
||
var baseTag = '<base href="' + baseUrl + '">';
|
||
var htmlWithBase = htmlContent;
|
||
if (htmlWithBase.indexOf('<head') !== -1) {
|
||
htmlWithBase = htmlWithBase.replace(/<head([^>]*)>/i, function(m, a) { return '<head' + a + '>' + baseTag; });
|
||
} else if (htmlWithBase.indexOf('<html') !== -1) {
|
||
htmlWithBase = htmlWithBase.replace(/<html([^>]*)>/i, function(m, a) { return '<html' + a + '><head>' + baseTag + '</head>'; });
|
||
} else {
|
||
htmlWithBase = baseTag + htmlWithBase;
|
||
}
|
||
var self = this;
|
||
frame.onload = function() {
|
||
// Set frame.src so onFrameLoad can extract the anchor for scrolling
|
||
if (urlAnchor) frame.setAttribute('data-srcdoc-anchor', urlAnchor);
|
||
self.onFrameLoad(frame, token);
|
||
};
|
||
frame.srcdoc = htmlWithBase;
|
||
};
|
||
</script>
|
||
<script id="skeleton-variable-script">
|
||
const initialConfig = $initialConfigJson;
|
||
window.addEventListener('DOMContentLoaded', () => {
|
||
window.api.init(initialConfig);
|
||
});
|
||
</script>
|
||
</head>
|
||
<body>
|
||
<div id="frame-container">
|
||
<iframe id="frame-prev" scrolling="no" style="z-index: 1; opacity: 0;"></iframe>
|
||
<iframe id="frame-curr" scrolling="no" style="z-index: 2; opacity: 1;"></iframe>
|
||
<iframe id="frame-next" scrolling="no" style="z-index: 1; opacity: 0;"></iframe>
|
||
</div>
|
||
</body>
|
||
</html>
|
||
''';
|
||
}
|
||
|
||
// ==========================================================================
|
||
// Web assets – embedded from lumina's generated web_assets.dart
|
||
// These are the JS controller and CSS used by the reader WebView.
|
||
// ==========================================================================
|
||
|
||
const String kControllerJs = r'''
|
||
"use strict";(()=>{var v=(a,t)=>()=>(a&&(t=a(a=0)),t);var lt=(a,t)=>()=>(t||a((t={exports:{}}).exports,t),t.exports);function C(a){function t(s,n,l){for(;s.length<n;)s=l+s;return s}let e=t(a.r.toString(16),2,"0"),o=t(a.g.toString(16),2,"0"),r=t(a.b.toString(16),2,"0"),i=a.a!==void 0?t(Math.round(a.a*255).toString(16),2,"0"):"";return"#"+e+o+r+i}function Q(a){let t=a.trim().toLowerCase();if(t==="transparent")return{r:0,g:0,b:0,a:0};let e=t.match(/^#?([a-f\d]{3,8})$/);if(e){let r=e[1];if((r.length===3||r.length===4)&&(r=r.split("").map(i=>i+i).join("")),r.length===6||r.length===8){let i=parseInt(r.substring(0,2),16),s=parseInt(r.substring(2,4),16),n=parseInt(r.substring(4,6),16);if(r.length===8){let l=Math.round(parseInt(r.substring(6,8),16)/255*100)/100;return{r:i,g:s,b:n,a:l}}return{r:i,g:s,b:n}}}let o=t.match(/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*([\d.]+))?\s*\)$/);if(o){let r=parseInt(o[1],10),i=parseInt(o[2],10),s=parseInt(o[3],10);if(r>255||i>255||s>255)return null;if(o[4]!==void 0){let n=parseFloat(o[4]);return n>=0&&n<=1?{r:i,g:s,b:n,a:n}:null}return{r:i,g:s,b:n}}return null}var U,T,L=v(()=>{"use strict";U={r:255,g:255,b:255,a:1},T={r:0,g:0,b:0,a:1}});var h,A=v(()=>{"use strict";h=class{static onViewportResize(){window.flutter_inappwebview.callHandler("onViewportResize")}static onPageCountReady(t){window.flutter_inappwebview.callHandler("onPageCountReady",t)}static onPageChanged(t){window.flutter_inappwebview.callHandler("onPageChanged",t)}static onScrollAnchors(t){window.flutter_inappwebview.callHandler("onScrollAnchors",t)}static onTap(t,e){window.flutter_inappwebview.callHandler("onTap",t,e)}static onLinkTap(t,e,o){window.flutter_inappwebview.callHandler("onLinkTap",t,e,o)}static onFootnoteTap(t,e,o,r,i,s){window.flutter_inappwebview.callHandler("onFootnoteTap",t,e,o,r,i,s)}static onImageLongPress(t,e,o,r,i){window.flutter_inappwebview.callHandler("onImageLongPress",t,e,o,r,i)}static onEventFinished(t){window.flutter_inappwebview.callHandler("onEventFinished",t)}}});function _(a){!a||!a.style||(a.style.setProperty("padding","0","important"),a.style.setProperty("padding-top","0","important"),a.style.setProperty("padding-bottom","0","important"),a.style.setProperty("padding-left","0","important"),a.style.setProperty("padding-right","0","important"),a.style.setProperty("height","100vh","important"),a.style.setProperty("width","100vw","important"),a.style.setProperty("max-width","none","important"),a.style.setProperty("max-height","none","important"),a.style.setProperty("margin","0","important"),a.style.setProperty("margin-top","0","important"),a.style.setProperty("margin-bottom","0","important"),a.style.setProperty("margin-left","0","important"),a.style.setProperty("margin-right","0","important"),a.style.setProperty("column-width","auto","important"),a.style.setProperty("column-count","1","important"),a.style.setProperty("column-gap","0","important"),a.style.setProperty("-webkit-column-width","auto","important"),a.style.setProperty("-webkit-column-count","1","important"),a.style.setProperty("-webkit-column-gap","0","important"),a.style.setProperty("overflow","hidden","important"))}function G(a,t){if(!a)return;let e=!1,o=0,r=a;for(;r&&r!==t.documentElement;){let i=window.getComputedStyle(r),s=i.transform||i.webkitTransform;if(!e&&s&&s!=="none"){let n=s.split("(")[1].split(")")[0].split(",");if(n.length>=6){let l=parseFloat(n[0]),m=parseFloat(n[1]);Math.abs(m)>.5&&Math.abs(l)<.5&&(e=!0,o=m>0?90:-90)}}r&&r!==a&&r.style&&(r.style.setProperty("transform","none","important"),r.style.setProperty("-webkit-transform","none","important")),r=r.parentElement}if(a.style)if(a.style.setProperty("position","fixed","important"),a.style.setProperty("z-index","9999","important"),a.style.setProperty("max-width","none","important"),a.style.setProperty("max-height","none","important"),a.style.setProperty("margin","0","important"),a.style.setProperty("padding","0","important"),e){a.style.setProperty("width","100vh","important"),a.style.setProperty("height","100vw","important"),a.style.setProperty("top","50%","important"),a.style.setProperty("left","50%","important");let i="translate(-50%, -50%) rotate(".concat(o,"deg)");a.style.setProperty("transform",i,"important"),a.style.setProperty("-webkit-transform",i,"important"),a.style.setProperty("transform-origin","center center","important")}else a.style.setProperty("width","100vw","important"),a.style.setProperty("height","100vh","important"),a.style.setProperty("top","0","important"),a.style.setProperty("left","0","important"),a.style.setProperty("transform","none","important"),a.style.setProperty("-webkit-transform","none","important")}function k(a){if(!a||!a.contentDocument&&!a.contentWindow)return;let t=a.contentDocument,e=t.documentElement;_(e),_(t.body);let o=t.querySelectorAll("svg");for(let n=0;n<o.length;n++)o[n].setAttribute("preserveAspectRatio","xMidYMid meet"),G(o[n],t);let r=t.querySelectorAll("svg image");for(let n=0;n<r.length;n++)r[n].setAttribute("width","100%"),r[n].setAttribute("height","100%");let i=t.querySelectorAll("img");for(let n=0;n<i.length;n++)i[n].style.setProperty("object-fit","contain","important"),G(i[n],t);let s=t.body.querySelectorAll("*");for(let n=0;n<s.length;n++){let l=s[n];l.style&&l.tagName!=="IMG"&&l.tagName!=="SVG"&&l.tagName!=="image"&&(l.style.setProperty("margin","0","important"),l.style.setProperty("padding","0","important"),l.style.setProperty("max-width","none","important"),l.style.setProperty("max-height","none","important"))}}var q=v(()=>{"use strict"});function z(a){if(!a)return new P(!1,!1);if(!a.contentDocument&&!a.contentWindow)return new P(!1,!1);let t=a.contentDocument;return new P(t.body.classList.contains("lumina-spine-property-duokan-page-fullscreen"),t.body.classList.contains("lumina-spine-property-duokan-page-fitwindow"))}function Y(a){if(!a||!a.contentDocument&&!a.contentWindow)return;let t=z(a);(t.isFullscreen||t.isFitWindow)&&k(a)}var P,K=v(()=>{"use strict";q();P=class{constructor(t,e){this.isFullscreen=t;this.isFitWindow=e}havePadding(){return!this.isFullscreen&&!this.isFitWindow}}});function O(a){if(!a)return new F(!1);if(!a.contentDocument&&!a.contentWindow)return new F(!1);let t=a.contentDocument;return new F(t.body.classList.contains("lumina-spine-property-rendition-COLON-page-spread-center")||t.body.classList.contains("lumina-spine-property-page-spread-center"))}function X(a){if(!a||!a.contentDocument&&!a.contentWindow)return;let t=a.contentDocument;O(a).isPageSpreadCenter&&k(a)}var F,Z=v(()=>{"use strict";q();F=class{constructor(t){this.isPageSpreadCenter=t}havePadding(){return!this.isPageSpreadCenter}}});function J(a){Y(a),X(a)}function I(a){return new N(z(a),O(a))}var N,j=v(()=>{"use strict";K();Z();N=class{constructor(t,e){this.duokanTypConfig=t;this.renditionTypConfig=e}havePadding(){return this.duokanTypConfig.havePadding()&&this.renditionTypConfig.havePadding()}}});var H,tt=v(()=>{"use strict";H=class{constructor(t){this.state=t}getFrame(t){let e=t.startsWith("frame-")?t:"frame-"+t;return document.getElementById(e)}getCurrFrame(){return this.getFrame("curr")}getSlotFromId(t){return t?t.replace("frame-",""):""}getSlotFromElement(t){return this.getSlotFromId(t.id)}isVertical(){return this.state.config.direction===1}getWidth(){return this.state.config.safeWidth}getHeight(){return this.state.config.safeHeight}scrollTo(t,e){if(!t||!t.contentWindow||!t.contentDocument)return;let o=this.isVertical()?{top:e,left:0,behavior:"auto"}:{top:0,left:e,behavior:"auto"};t.contentDocument.body.scrollTo(o)}cycleFramesDOMAndState(t){let e=this.getFrame("prev"),o=this.getFrame("curr"),r=this.getFrame("next");if(!e||!o||!r)return null;if(t==="next"){e.id="frame-temp",r.id="frame-curr",r.style.zIndex="2",r.style.opacity="1",o.id="frame-prev",o.style.zIndex="1",o.style.opacity="0";let i=document.getElementById("frame-temp");i.id="frame-next",i.style.zIndex="1",i.style.opacity="0";let s=this.state.anchors.prev;this.state.anchors.prev=this.state.anchors.curr;this.state.anchors.curr=this.state.anchors.next;this.state.anchors.next=s;let n=this.state.properties.prev;this.state.properties.prev=this.state.properties.curr;this.state.properties.curr=this.state.properties.next;this.state.properties.next=n}else if(t==="prev"){r.id="frame-temp",e.id="frame-curr",e.style.zIndex="2",e.style.opacity="1",o.id="frame-next",o.style.zIndex="1",o.style.opacity="0";let i=document.getElementById("frame-temp");i.id="frame-prev",i.style.zIndex="1",i.style.opacity="0";let s=this.state.anchors.next;this.state.anchors.next=this.state.anchors.curr;this.state.anchors.curr=this.state.anchors.prev;this.state.anchors.prev=s;let n=this.state.properties.next;this.state.properties.next=this.state.properties.curr;this.state.properties.curr=this.state.properties.prev;this.state.properties.prev=n}return{elPrev:this.getFrame("prev"),elCurr:this.getFrame("curr"),elNext:this.getFrame("next")}}}});var E,et=v(()=>{"use strict";A();E=class{constructor(t,e){this.state=t;this.frameMgr=e}calculatePageCount(t){if(!t||!t.contentDocument)return 0;if(this.frameMgr.isVertical()){let e=t.contentDocument.body.scrollHeight;return Math.round((e+128)/(this.frameMgr.getHeight()+128))}else{let e=t.contentDocument.body.scrollWidth;return Math.round((e+128)/(this.frameMgr.getWidth()+128))}}calculateScrollOffset(t){return this.frameMgr.isVertical()?t*this.frameMgr.getHeight()+t*128:t*this.frameMgr.getWidth()+t*128}calculateCurrentPageIndex(){let t=this.frameMgr.getCurrFrame();if(!t||!t.contentWindow||!t.contentDocument)return 0;if(this.frameMgr.isVertical()){let e=t.contentDocument.body.scrollTop||0;return Math.round((e+128)/(this.frameMgr.getHeight()+128))}else{let e=t.contentDocument.body.scrollLeft||0;return Math.round((e+128)/(this.frameMgr.getWidth()+128))}}calculatePageIndexOfAnchor(t,e){if(!t||!t.contentDocument)return 0;let o=t.contentDocument,r=o.getElementById(e);if(!r)return 0;let i=o.body.getBoundingClientRect(),s=r.getClientRects(),n=s.length>0?s[0]:r.getBoundingClientRect();if(this.frameMgr.isVertical()){let l=n.top+o.body.scrollTop-i.top+n.height/5+1;return Math.floor((l+128)/(this.frameMgr.getHeight()+128))}else{let l=n.left+o.body.scrollLeft-i.left+n.width/5+1;return Math.floor((l+128)/(this.frameMgr.getWidth()+128))}}updatePageState(t){let e=this.frameMgr.getFrame(t);if(!e||!e.contentWindow)return;let o=this.calculatePageCount(e);if(t==="frame-curr")h.onPageCountReady(o),h.onPageChanged(this.calculateCurrentPageIndex());else if(t==="frame-prev"){let r=Math.max(0,o-1),i=this.calculateScrollOffset(r);this.frameMgr.scrollTo(e,i)}else if(t==="frame-next"){let r=this.calculateScrollOffset(0);this.frameMgr.scrollTo(e,r)}}detectActiveAnchor(t){if(!t||!t.contentDocument||t.id!=="frame-curr")return;let e=this.state.anchors.curr;if(!e||e.length===0)return;let o=t.contentDocument,r=[],i="top",s=50,n=this.frameMgr.isVertical();for(let l=0;l<e.length;l++){let m=e[l];if(m==="top"){(n?o.body.scrollTop<s:o.body.scrollLeft<s)&&r.push("top");continue}let c=o.getElementById(m);if(c){let u=c.getBoundingClientRect();n?(u.top<s&&u.bottom>s&&r.push(m),u.top<s&&(i=m)):(u.left<s&&u.right>s&&r.push(m),u.left<s&&(i=m))}}r.length===0&&i&&r.push(i);h.onScrollAnchors(r)}}});var w,R,rt=v(()=>{"use strict";w=class{constructor(t=0,e=0,o=0,r=0){this.x=t||0;this.y=e||0;this.width=Math.max(0,o||0);this.height=Math.max(0,r||0)}contains(t){return t?t.x>=this.x&&t.x<=this.x+this.width&&t.y>=this.y&&t.y<=this.y+this.height:!1}intersects(t){return t?!(t.x>this.x+this.width||t.x+t.width<this.x||t.y>this.y+this.height||t.y+t.height<this.y):!1}},R=class a{constructor(t,e=4){this.northwest=null;this.northeast=null;this.southwest=null;this.southeast=null;this.boundary=t;this.capacity=Math.max(1,e||4);this.items=[];this.divided=!1}toRect(t){return t?new w(t.x,t.y,t.width,t.height):null}subdivide(){let t=this.boundary.x,e=this.boundary.y,o=this.boundary.width/2,r=this.boundary.height/2;this.northwest=new a(new w(t,e,o,r),this.capacity);this.northeast=new a(new w(t+o,e,o,r),this.capacity);this.southwest=new a(new w(t,e+r,o,r),this.capacity);this.southeast=new a(new w(t+o,e+r,o,r),this.capacity);this.divided=!0}insert(t){if(!t||!t.rect)return!1;let e=this.toRect(t.rect);if(!e||!this.boundary.intersects(e))return!1;if(!this.divided&&this.items.length<this.capacity)return this.items.push(t),!0;if(!this.divided){this.subdivide();let o=this.items;this.items=[];for(let r=0;r<o.length;r++)this.insertIntoChildren(o[r])}return this.insertIntoChildren(t)}insertIntoChildren(t){let e=!1;return this.northwest.insert(t)&&(e=!0),this.northeast.insert(t)&&(e=!0),this.southwest.insert(t)&&(e=!0),this.southeast.insert(t)&&(e=!0),e}query(t,e=[]){if(!t||!this.boundary.intersects(t))return e;for(let o=0;o<this.items.length;o++){let r=this.items[o],i=this.toRect(r.rect);i&&t.intersects(i)&&e.push(r)}return this.divided&&(this.northwest.query(t,e),this.northeast.query(t,e),this.southwest.query(t,e),this.southeast.query(t,e)),e}}});var D,ot=v(()=>{"use strict";rt();A();j();D=class{constructor(t,e){this.state=t;this.frameMgr=e}buildInteractionMap(){let t=this.frameMgr.getFrame("curr");if(!t||!t.contentDocument)return this.state.quadTree=null,Promise.resolve();let e=t.contentDocument;return new Promise(o=>{let r=e.body;if(!r){this.state.quadTree=null,o();return}let i=new R(new w(0,0,Math.max(1,r.scrollWidth),Math.max(1,r.scrollHeight)),4),s=r.getBoundingClientRect(),n=e.querySelectorAll("img, image");for(let c=0;c<n.length;c++){let u=n[c],d=u.getBoundingClientRect();if(!d||d.width<5||d.height<5)continue;let b=d.left+r.scrollLeft-s.left,p=d.top+r.scrollTop-s.top,g=u.hasAttribute("zy-footnote"),M=!1;if(g||u.classList.contains("duokan-footnote")&&(M=!0),g||M){let y=g?u.getAttribute("zy-footnote")||"":u.getAttribute("alt")||u.getAttribute("title")||"";i.insert({type:"footnote",priority:2,rect:new w(b,p,d.width,d.height),data:"<div>"+y+"</div>"})}}let l=e.querySelectorAll("a");for(let c=0;c<l.length;c++){let u=l[c],d=u.getAttribute("href"),b=u.getAttribute("epub:type"),p="",g=!1;if(!d&&u.classList.contains("duokan-footnote")){if(!g){let y=u.closest("note");if(y){let f=y.querySelectorAll("aside"),S=Array.from(y.querySelectorAll("a")).indexOf(u);if(f.length>0&&S>=0&&S<f.length)p=f[S].outerHTML,g=!0;else{for(let x=0;x<f.length;x++)p+=f[x].outerHTML;g=!0}}}if(!g&&u.childElementCount===1){let y=u.children[0];if(y.tagName.toLowerCase()==="img"||y.tagName.toLowerCase()==="image"){let f=y;p="<div>"+(f.getAttribute("alt")||f.getAttribute("title")||"")+"</div>",g=!0}}}if(g||u.hasAttribute("title")&&(!d||d==="#")&&(p='<div class="footnote-content">'+u.getAttribute("title")+"</div>",g=!0),g||b==="noteref"&&(p=this.extractFootnoteHtml(this.extractTargetIdFromHref(d)),g=!0),!g&&u.classList.contains("duokan-footnote")&&d&&d.includes("#")){let y=u.href,f=u.ownerDocument.location.href;f.includes("#")&&(f=f.split("#")[0]),(y===f||f===y.split("#")[0])&&(p=this.extractFootnoteHtml(this.extractTargetIdFromHref(d)),g=!0)}if(!g||!p||p.trim()==="")continue;let M=u.getClientRects();for(let y=0;y<M.length;y++){let f=M[y];!f||f.width<5||f.height<5||i.insert({type:"footnote",priority:3,rect:new w(f.left+r.scrollLeft-s.left,f.top+r.scrollTop-s.top,f.width,f.height),data:p})}}let m=e.querySelectorAll("span.notes, .notes");for(let c=0;c<m.length;c++){let u=m[c],d='<div class="aozora-footnote-content">'+u.innerHTML+"</div>",b=u.getClientRects();for(let p=0;p<b.length;p++){let g=b[p];!g||g.width<5||g.height<5||i.insert({type:"footnote",priority:1,rect:new w(g.left+r.scrollLeft-s.left,g.top+r.scrollTop-s.top,g.width,g.height),data:d})}}this.state.quadTree=i,o()})}checkLinkAt(t,e){let o=this.frameMgr.getFrame("curr");if(o&&o.contentDocument){let i=o.contentDocument.elementFromPoint(t,e);if(i){let s=i.closest("a");if(s&&s.getAttribute("href"))return h.onLinkTap(s.href,t,e),!0}}return!1}checkTapElementAt(t,e){let o=this.checkElementAtHelper(t,e,r=>r.type==="footnote");if(o){let r=this.frameMgr.getFrame("curr");if(!r||!r.contentDocument)return;let i=r.contentDocument.body;if(!i)return;let s=o.rect,n=s.x-i.scrollLeft,l=s.y-i.scrollTop;I(r).havePadding()&&(n+=this.state.config.padding.left,l+=this.state.config.padding.top);let c=r.contentDocument.baseURI||"";if(o.type==="footnote"){h.onFootnoteTap(o.data,n,l,s.width,s.height,c);return}}this.checkLinkAt(t,e)||h.onTap(t,e)}checkImageAt(t,e){let o=this.frameMgr.getFrame("curr");if(o&&o.contentDocument){let r=o.contentDocument,i=r.body.getBoundingClientRect(),s=r.elementFromPoint(t,e);if(s){let n=s.closest("img, image");if(n){let l=n.currentSrc||n.src||n.getAttribute("xlink:href")||"";if(l){let m=r.createElement("a");m.href=l,l=m.href;let c=n.getBoundingClientRect();if(!c||c.width<5||c.height<5)return!1;let u=I(o),d=c.left-i.left,b=c.top-i.top;return u.havePadding()&&(d+=this.state.config.padding.left,b+=this.state.config.padding.top),h.onImageLongPress(l,d,b,c.width,c.height),!0}}}}return!1}checkLongPressElementAt(t,e){this.checkImageAt(t,e)}extractTargetIdFromHref(t){if(!t||typeof t!="string")return null;let e=t.indexOf("#");if(e<0||e>=t.length-1)return null;try{return decodeURIComponent(t.substring(e+1))}catch(o){return t.substring(e+1)}}extractFootnoteHtml(t){var n;let e=this.frameMgr.getFrame("curr");if(!e||!e.contentDocument)return"";let o=e.contentDocument;if(!t)return"";let r=String(t).replace(/^#/,"");if(!r)return"";let i=o.getElementById(r);if(i||(i=o.querySelector('[name="'+r+'"]')),!i)return"";i.textContent.trim()===""&&i.nextElementSibling&&(i=i.nextElementSibling);let s=i.closest("li, aside, section, div, p")||i;if(s.tagName.toLowerCase()==="li"){let l=document.createElement("ol"),m=s.cloneNode(!0);return l.appendChild(m),l.outerHTML}return(n=s==null?void 0:s.outerHTML)!=null?n:""}checkElementAtHelper(t,e,o){let r=this.frameMgr.getCurrFrame();if(!r||!r.contentDocument||!this.state.quadTree)return;let i=r.contentDocument.body;if(!i)return;let s=I(r),n=t+i.scrollLeft,l=e+i.scrollTop;s.havePadding()&&(n-=this.state.config.padding.left,l-=this.state.config.padding.top);let m=20,c=this.state.quadTree.query(new w(n-m,l-m,m*2,m*2),[]);if(c.sort((b,p)=>p.priority!==b.priority?p.priority-b.priority:0),c.length>0){let b=c[0].priority;c=c.filter(p=>p.priority===b)}let u,d=1/0;for(let b=c.length-1;b>=0;b--){let p=c[b];if(!(p!=null&&p.rect)||o&&!o(p))continue;let g=new w(p.rect.x,p.rect.y,p.rect.width,p.rect.height),M;if(g.contains({x:n,y:l}))M=0;else{let y=n-(g.x+g.width/2),f=l-(g.y+g.height/2);M=Math.sqrt(y*y+f*f)}M<d&&(d=M,u=p)}return u}}});var $,nt=v(()=>{"use strict";L();$=class{constructor(t,e){this.state=t;this.frameMgr=e}updateThemeState(t,e,o){this.state.config.safeWidth=Math.floor(t);this.state.config.safeHeight=Math.floor(e);this.state.config.padding=o.padding;this.state.config.theme=o.theme}haveBackground(t){if(!t||!t.contentDocument||!t.contentWindow)return!1;try{let e=t.contentWindow,o=t.contentDocument.body;if(!o)return console.warn("Iframe body is null, possibly not fully loaded or not an HTML document."),!1;let r=e.getComputedStyle(o).backgroundColor;if(r&&r!=="rgba(0, 0, 0, 0)"&&r!=="transparent")return!0;let i=e.getComputedStyle(o).backgroundImage;if(i&&i!=="none")return o.style.backgroundColor="#ffffff",!0}catch(e){return console.warn("Failed to get original background color from iframe:",e),!1}return!1}generateVariableStyle(){let t=this.state.config,e=t.theme,o=this.frameMgr.isVertical(),r=e.fontFileName?"@font-face { font-family: 'LuminaCustomFont'; src: url('epub://localhost/fonts/".concat(e.fontFileName,"'); }"):"",i=e.fontFileName?"--lumina-font-family: 'LuminaCustomFont';":"";return r+" :root {"+"--lumina-zoom: ".concat(e.zoom,";")+"--lumina-safe-width: ".concat(t.safeWidth,"px;")+"--lumina-safe-height: ".concat(t.safeHeight,"px;")+"--lumina-padding-top: ".concat(t.padding.top,"px;")+"--lumina-padding-left: ".concat(t.padding.left,"px;")+"--lumina-reader-overflow-x: ".concat(o?"hidden":"auto",";")+"--lumina-reader-overflow-y: ".concat(o?"auto":"hidden",";")+"--lumina-surface-color: ".concat(C(e.surfaceColor),";")+"--lumina-surface-color-rgb: ".concat(e.surfaceColor.r,", ").concat(e.surfaceColor.g,", ").concat(e.surfaceColor.b,";")+"--lumina-on-surface-color: ".concat(C(e.onSurfaceColor),";")+"--lumina-on-surface-color-rgb: ".concat(e.onSurfaceColor.r,", ").concat(e.onSurfaceColor.g,", ").concat(e.onSurfaceColor.b,";")+"--lumina-primary-color: ".concat(C(e.primaryColor),";")+"--lumina-primary-color-rgb: ".concat(e.primaryColor.r,", ").concat(e.primaryColor.g,", ").concat(e.primaryColor.b,";")+"--lumina-primary-container-color: ".concat(C(e.primaryContainerColor),";")+"--lumina-primary-container-color-rgb: ".concat(e.primaryContainerColor.r,", ").concat(e.primaryContainerColor.g,", ").concat(e.primaryContainerColor.b,";")+"--lumina-on-surface-variant-color: ".concat(C(e.onSurfaceVariantColor),";")+"--lumina-on-surface-variant-color-rgb: ".concat(e.onSurfaceVariantColor.r,", ").concat(e.onSurfaceVariantColor.g,", ").concat(e.onSurfaceVariantColor.b,";")+"--lumina-outline-variant-color: ".concat(C(e.outlineVariantColor),";")+"--lumina-outline-variant-color-rgb: ".concat(e.outlineVariantColor.r,", ").concat(e.outlineVariantColor.g,", ").concat(e.outlineVariantColor.b,";")+"--lumina-surface-container-color: ".concat(C(e.surfaceContainerColor),";")+"--lumina-surface-container-color-rgb: ".concat(e.surfaceContainerColor.r,", ").concat(e.surfaceContainerColor.g,", ").concat(e.surfaceContainerColor.b,";")+"--lumina-surface-container-high-color: ".concat(C(e.surfaceContainerHighColor),";")+"--lumina-surface-container-high-color-rgb: ".concat(e.surfaceContainerHighColor.r,", ").concat(e.surfaceContainerHighColor.g,", ").concat(e.surfaceContainerHighColor.b,";")+i+"}"}updateCSSVariables(t,e="injected-variable-style",o=null){let r=t.documentElement,i=t.body,s=this.state.config,n=s.theme,l=this.frameMgr.isVertical();r.style.setProperty("--lumina-zoom",String(n.zoom));r.style.setProperty("--lumina-safe-width",s.safeWidth+"px");r.style.setProperty("--lumina-safe-height",s.safeHeight+"px");r.style.setProperty("--lumina-padding-top",s.padding.top+"px");r.style.setProperty("--lumina-padding-left",s.padding.left+"px");r.style.setProperty("--lumina-reader-overflow-x",l?"hidden":"auto");r.style.setProperty("--lumina-reader-overflow-y",l?"auto":"hidden");r.style.setProperty("--lumina-surface-color",C(n.surfaceColor));r.style.setProperty("--lumina-surface-color-rgb","".concat(n.surfaceColor.r,", ").concat(n.surfaceColor.g,", ").concat(n.surfaceColor.b));r.style.setProperty("--lumina-on-surface-color",C(n.onSurfaceColor));r.style.setProperty("--lumina-on-surface-color-rgb","".concat(n.onSurfaceColor.r,", ").concat(n.onSurfaceColor.g,", ").concat(n.onSurfaceColor.b));r.style.setProperty("--lumina-primary-color",C(n.primaryColor));r.style.setProperty("--lumina-primary-color-rgb","".concat(n.primaryColor.r,", ").concat(n.primaryColor.g,", ").concat(n.primaryColor.b));r.style.setProperty("--lumina-primary-container-color",C(n.primaryContainerColor));r.style.setProperty("--lumina-primary-container-color-rgb","".concat(n.primaryContainerColor.r,", ").concat(n.primaryContainerColor.g,", ").concat(n.primaryContainerColor.b));r.style.setProperty("--lumina-on-surface-variant-color",C(n.onSurfaceVariantColor));r.style.setProperty("--lumina-on-surface-variant-color-rgb","".concat(n.onSurfaceVariantColor.r,", ").concat(n.onSurfaceVariantColor.g,", ").concat(n.onSurfaceVariantColor.b));r.style.setProperty("--lumina-outline-variant-color",C(n.outlineVariantColor));r.style.setProperty("--lumina-outline-variant-color-rgb","".concat(n.outlineVariantColor.r,", ").concat(n.outlineVariantColor.g,", ").concat(n.outlineVariantColor.b));r.style.setProperty("--lumina-surface-container-color",C(n.surfaceContainerColor));r.style.setProperty("--lumina-surface-container-color-rgb","".concat(n.surfaceContainerColor.r,", ").concat(n.surfaceContainerColor.g,", ").concat(n.surfaceContainerColor.b));r.style.setProperty("--lumina-surface-container-high-color",C(n.surfaceContainerHighColor));r.style.setProperty("--lumina-surface-container-high-color-rgb","".concat(n.surfaceContainerHighColor.r,", ").concat(n.surfaceContainerHighColor.g,", ").concat(n.surfaceContainerHighColor.b));let m=o!=null?n.shouldOverrideTextColor&&!this.haveBackground(o):n.shouldOverrideTextColor;i.classList.toggle("lumina-override-color",m);i.classList.toggle("lumina-force-override-font",!!(n.overrideFontFamily&&n.fontFileName));i.classList.toggle("lumina-override-font",!!n.fontFileName);let c=t.getElementById(e);c&&(c.innerHTML=this.generateVariableStyle())}injectInitialStyles(t,e){let o=t.getElementById("injected-variable-style");if(o)o.innerHTML=this.generateVariableStyle(),this.updateCSSVariables(t,"injected-variable-style",e);else{let i=t.createElement("style");i.id="injected-variable-style";i.innerHTML=this.generateVariableStyle();t.head.appendChild(i)}let r=t.getElementById("injected-pagination-style");if(r)r.innerHTML=this.state.config.paginationCss;else{let i=t.createElement("style");i.id="injected-pagination-style";i.innerHTML=this.state.config.paginationCss;t.head.appendChild(i)}}}});var V,it=v(()=>{"use strict";L();V=class{constructor(t,e,o){this.state=t;this.themeMgr=e;this.frameMgr=o}convertToColumnBreak(t){switch(t){case"page":case"right":case"left":return"always";case"avoid":return"avoid";default:return"auto"}}applyRuleWithFixedValue(t,e){let o=t.getPropertyValue(e);o&&!o.includes("calc")&&o.trim().toLowerCase().match(/^(\d+(?:\.\d+)?)(px|pt)$/)&&t.setProperty(e,"calc("+o+" * var(--lumina-zoom))",t.getPropertyPriority(e))}applyBackgroundColorPolyfill(t){if(t.backgroundColor&&t.backgroundColor!=="transparent"&&!t.backgroundColor.includes("var(--lumina-")&&!t.backgroundColor.includes("var(rgba(var(--lumina-")){let e=t.getPropertyValue("background-color"),o=Q(e),r="--lumina-surface-container-color";if(o){let i=o.a!==void 0?o.a:1;i<1&&(r="rgba(var(--lumina-surface-container-color-rgb), ".concat(i,")"))}console.log("Applying background-color polyfill. Original:",e,"New:",r,"All styles:","var("+r+", "+e+")");t.setProperty("background-color","var("+r+", "+e+")",t.getPropertyPriority("background-color"))}}extractOriginalValue(t){let e=t.trim();if(!e.startsWith("var(")||!e.endsWith(")"))return null;let o=e.substring(4,e.length-1),r=0,i=-1;for(let n=0;n<o.length;n++){let l=o[n];if(l==="(")r++;else if(l===")")r--;else if(l===","&&r===0){i=n;break}}return i===-1?null:o.substring(i+1).trim()||null}removeBackgroundColorPolyfill(t){let e=t.getPropertyValue("background-color");if(e.includes("var(--lumina-surface-container-color")||e.includes("var(rgba(var(--lumina-surface-container-color-rgb)")){let o=this.extractOriginalValue(e);o&&t.setProperty("background-color",o,t.getPropertyPriority("background-color"))}}applyRules(t,e){this.applyRuleWithFixedValue(t,"font-size");this.applyRuleWithFixedValue(t,"line-height");e?this.applyBackgroundColorPolyfill(t):this.removeBackgroundColorPolyfill(t);let o=t;t.breakBefore&&(o.webkitColumnBreakBefore=this.convertToColumnBreak(t.breakBefore));t.pageBreakBefore&&(o.webkitColumnBreakBefore=this.convertToColumnBreak(t.pageBreakBefore));t.breakAfter&&t.breakAfter!=="auto"&&(o.webkitColumnBreakAfter=this.convertToColumnBreak(t.breakAfter));t.pageBreakAfter&&t.pageBreakAfter!=="auto"&&(o.webkitColumnBreakAfter=this.convertToColumnBreak(t.pageBreakAfter))}polyfillCss(t){if(!t||!t.contentDocument)return;let e=t.contentDocument,o=t?this.state.config.theme.shouldOverrideTextColor&&!this.themeMgr.haveBackground(t):this.state.config.theme.shouldOverrideTextColor;for(let r=0;r<e.styleSheets.length;r++){let i=e.styleSheets[r];try{let s=i.cssRules||i.rules;if(!s)continue;for(let n=0;n<s.length;n++){let l=s[n];l.type===1&&this.applyRules(l.style,o)}}catch(s){console.error("Access to stylesheet blocked: "+s)}}}}});var B,at=v(()=>{"use strict";B=class{constructor(t){this.state=t}waitForAllResources(t){var i,s;let e=Promise.all(Array.from(t.images).map(n=>!n.src||n.complete||n.naturalHeight!==0?Promise.resolve():new Promise(l=>{let m=setTimeout(()=>{n.removeEventListener("load",c);n.removeEventListener("error",c);console.warn("Image load timeout:",n.src);l()},3e3),c=()=>{clearTimeout(m);l()};n.addEventListener("load",c,{once:!0});n.addEventListener("error",c,{once:!0})}))),o=(s=(i=t.fonts)==null?void 0:i.ready)!=null?s:Promise.resolve(),r=new Promise(n=>setTimeout(n,5e3));return Promise.race([Promise.all([e,o]).then(()=>{}),r])}}});var W,st=v(()=>{"use strict";L();A();j();tt();et();ot();nt();it();at();W=class{constructor(){this.currentSize={width:0,height:0};this.state={anchors:{prev:[],curr:[],next:[]},properties:{prev:[],curr:[],next:[]},quadTree:null,config:{safeWidth:0,safeHeight:0,direction:0,padding:{top:0,left:0},theme:{zoom:1,surfaceColor:U,onSurfaceColor:T,shouldOverrideTextColor:!0,primaryColor:T,primaryContainerColor:T,onSurfaceVariantColor:T,outlineVariantColor:T,surfaceContainerColor:T,surfaceContainerHighColor:T,fontFileName:null,overrideFontFamily:!1},paginationCss:""}},this.frameMgr=new H(this.state);this.paginationMgr=new E(this.state,this.frameMgr);this.interactionMgr=new D(this.state,this.frameMgr);this.themeMgr=new $(this.state,this.frameMgr);this.polyfillMgr=new V(this.state,this.themeMgr,this.frameMgr);this.resourceMgr=new B(this.state);this.resizeDebounceTimer=null;this.onResize=t=>{let e=window.innerWidth,o=window.innerHeight;this.currentSize.width===0&&this.currentSize.height===0?this.currentSize={width:e,height:o}:(this.currentSize.width!==e||this.currentSize.height!==o)&&(this.currentSize={width:e,height:o},this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=setTimeout(()=>{h.onViewportResize()},120))}}init(t){this.state.config=t;this.state.config.safeHeight=Math.floor(this.state.config.safeHeight);this.state.config.safeWidth=Math.floor(this.state.config.safeWidth);this.themeMgr.updateCSSVariables(document,"skeleton-variable-style");window.removeEventListener("resize",this.onResize);window.addEventListener("resize",this.onResize,{passive:!0})}loadFrame(t,e,o,r,i){let s=this.frameMgr.getFrame(e);if(s)if(this.state.anchors[e]=r||[],this.state.properties[e]=i||[],s.onload=null,s.src==null||s.src===""||s.src==="about:blank")s.onload=()=>{this.onFrameLoad(s,t)},s.src=o;else{let n=new URL(s.src),l=new URL(o);n.origin===l.origin&&n.pathname===l.pathname?(s.onload=()=>{this.onFrameLoad(s,t)},s.src=o,this.onFrameLoad(s,t)):(s.onload=()=>{this.onFrameLoad(s,t)},s.src=o)}}jumpToPage(t,e){let o=this.frameMgr.getFrame("curr");if(!o||!o.contentWindow)return;let r=this.paginationMgr.calculateScrollOffset(e);this.frameMgr.scrollTo(o,r);requestAnimationFrame(()=>{requestAnimationFrame(()=>{h.onPageChanged(e);this.paginationMgr.detectActiveAnchor(o);h.onEventFinished(t)})})}jumpToPageFor(t,e,o){let r=this.frameMgr.getFrame(e);if(!r||!r.contentWindow)return;let i=this.paginationMgr.calculateScrollOffset(o);this.frameMgr.scrollTo(r,i);requestAnimationFrame(()=>{requestAnimationFrame(()=>{r.id==="frame-curr"&&h.onPageChanged(o);this.paginationMgr.detectActiveAnchor(r);h.onEventFinished(t)})})}jumpToLastPageOfFrame(t,e){let o=this.frameMgr.getFrame(e);if(!o||!o.contentWindow)return;let r=this.paginationMgr.calculatePageCount(o);this.jumpToPageFor(t,e,r-1)}restoreScrollPosition(t,e){let o=this.frameMgr.getFrame("curr");if(!o||!o.contentWindow)return;let r=this.paginationMgr.calculatePageCount(o),i=Math.round(e*r);this.jumpToPage(t,i)}cycleFrames(t,e){let o=this.frameMgr.cycleFramesDOMAndState(e);o||h.onEventFinished(t);requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.paginationMgr.updatePageState("frame-curr");this.paginationMgr.updatePageState("frame-prev");this.paginationMgr.updatePageState("frame-next");this.paginationMgr.detectActiveAnchor(o.elPrev);this.paginationMgr.detectActiveAnchor(o.elCurr);this.paginationMgr.detectActiveAnchor(o.elNext);this.interactionMgr.buildInteractionMap().then(()=>{h.onEventFinished(t)})})})}checkTapElementAt(t,e){this.interactionMgr.checkTapElementAt(t,e)}checkLongPressElementAt(t,e){this.interactionMgr.checkLongPressElementAt(t,e)}updateTheme(t,e,o,r){this.themeMgr.updateThemeState(e,o,r);this.themeMgr.updateCSSVariables(document,"skeleton-variable-style");let i=document.getElementsByTagName("iframe");for(let s=0;s<i.length;s++){let n=i[s];if(n&&n.contentDocument){let l=n.contentDocument,m=this.paginationMgr.calculateCurrentPageIndex(),c=this.paginationMgr.calculatePageCount(n),u=c>0?m/c:0;this.themeMgr.updateCSSVariables(l,"injected-variable-style",n);requestAnimationFrame(()=>{this.reloadFrame(n,u,t)})}}}waitForRender(t){requestAnimationFrame(function(){requestAnimationFrame(function(){h.onEventFinished(t)})})}onFrameLoad(t,e){if(!t||!t.contentDocument)return;let o=t.contentDocument;this.themeMgr.injectInitialStyles(o,t);this.resourceMgr.waitForAllResources(o).then(()=>{t.contentWindow&&requestAnimationFrame(()=>{let r=this.state.config.theme.shouldOverrideTextColor&&!this.themeMgr.haveBackground(t);o.body.classList.toggle("lumina-override-color",r);o.body.classList.toggle("lumina-force-override-font",!!(this.state.config.theme.overrideFontFamily&&this.state.config.theme.fontFileName));o.body.classList.toggle("lumina-override-font",!!this.state.config.theme.fontFileName);o.body.classList.toggle("lumina-is-vertical",this.frameMgr.isVertical());let i=this.state.properties[this.frameMgr.getSlotFromElement(t)]||[];for(let n of i)o.body.classList.toggle("lumina-spine-property-"+n,!0);J(t);let s=o.body.scrollHeight;requestAnimationFrame(()=>{this.polyfillMgr.polyfillCss(t);requestAnimationFrame(()=>{let n=o.body.scrollHeight;requestAnimationFrame(()=>{let l=o.body.scrollHeight,m=this.paginationMgr.calculatePageCount(t),c=0,u=t.src;if(u&&u.includes("#")){let d=u.split("#")[1];c=this.paginationMgr.calculatePageIndexOfAnchor(t,d);this.frameMgr.scrollTo(t,this.paginationMgr.calculateScrollOffset(c))}requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.interactionMgr.buildInteractionMap().then(()=>{t.id==="frame-curr"?(h.onPageCountReady(m),h.onPageChanged(c)):t.id==="frame-prev"?this.jumpToLastPageOfFrame(-1,"prev"):t.id==="frame-next"&&this.jumpToPageFor(-1,"next",0);this.paginationMgr.detectActiveAnchor(t);requestAnimationFrame(()=>{h.onEventFinished(e)})})})})})})})})})}reloadFrame(t,e,o){!t||!t.contentDocument||!t.contentWindow||this.resourceMgr.waitForAllResources(t.contentDocument).then(()=>{let r=t.contentDocument;this.polyfillMgr.polyfillCss(t);let i=r.body.scrollHeight;requestAnimationFrame(()=>{requestAnimationFrame(()=>{let s=this.paginationMgr.calculatePageCount(t),n=Math.round(e*s);this.frameMgr.scrollTo(t,this.paginationMgr.calculateScrollOffset(n));requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.interactionMgr.buildInteractionMap().then(()=>{t.id==="frame-curr"?(h.onPageCountReady(s),h.onPageChanged(n)):t.id==="frame-prev"?this.jumpToLastPageOfFrame(-1,"prev"):t.id==="frame-next"&&this.jumpToPageFor(-1,"next",0);this.paginationMgr.detectActiveAnchor(t);requestAnimationFrame(()=>{h.onEventFinished(o)})})})})})})})}}});var ut=lt(()=>{st();var ct=new W;window.api=ct});ut();})();
|
||
''';
|
||
|
||
const String kPaginationCss = r'''
|
||
body.lumina-force-override-font,body.lumina-force-override-font *{font-family:var(--lumina-font-family, inherit)!important}body.lumina-override-font{font-family:var(--lumina-font-family, inherit)}@font-face{font-family:DK-SONGTI;src:local("Songti SC"),local("Songti TC"),local("STSong"),local("Noto Serif CJK SC"),local("Noto Serif CJK TC"),local("Noto Serif CJK JP"),local("Noto Serif CJK KR"),local("Noto Serif SC"),local("Noto Serif TC"),local("Noto Serif JP"),local("Noto Serif KR"),local("Source Han Serif SC"),local("Source Han Serif TC"),local("Source Han Serif JP"),local("Source Han Serif KR")}@font-face{font-family:DK-FANGSONG;src:local("STFangsong"),local("FangSong"),local("Songti SC"),local("Songti TC"),local("Noto Serif CJK SC"),local("Noto Serif CJK TC"),local("Noto Serif CJK JP"),local("Noto Serif CJK KR"),local("Noto Serif SC"),local("Noto Serif TC"),local("Noto Serif JP"),local("Noto Serif KR")}@font-face{font-family:DK-KAITI;src:local("Kaiti SC"),local("Kaiti TC"),local("STKaiti"),local("KaiTi"),local("Songti SC"),local("Songti TC"),local("Noto Serif CJK SC"),local("Noto Serif CJK TC"),local("Noto Serif CJK JP"),local("Noto Serif CJK KR"),local("Noto Serif SC"),local("Noto Serif TC"),local("Noto Serif JP"),local("Noto Serif KR")}@font-face{font-family:DK-HEITI;src:local("PingFang SC"),local("PingFang TC"),local("PingFang HK"),local("Heiti SC"),local("Heiti TC"),local("MiSans"),local("HarmonyOS Sans SC"),local("HarmonyOS Sans TC"),local("OPPO Sans"),local("HONOR Sans"),local("Noto Sans CJK SC"),local("Noto Sans CJK TC"),local("Noto Sans CJK JP"),local("Noto Sans CJK KR"),local("Noto Sans SC"),local("Noto Sans TC"),local("Noto Sans JP"),local("Noto Sans KR"),local("Source Han Sans SC"),local("Source Han Sans TC"),local("Source Han Sans JP"),local("Source Han Sans KR")}@font-face{font-family:DK-XIAOBIAOSONG;src:local("Songti SC"),local("Songti TC"),local("STSong"),local("Noto Serif CJK SC"),local("Noto Serif CJK TC"),local("Noto Serif CJK JP"),local("Noto Serif CJK KR"),local("Noto Serif SC"),local("Noto Serif TC"),local("Noto Serif JP"),local("Noto Serif KR")}@font-face{font-family:DK-XIHEITI;src:local("PingFang SC"),local("PingFang TC"),local("PingFang HK"),local("Heiti SC"),local("Heiti TC"),local("MiSans"),local("HarmonyOS Sans SC"),local("HarmonyOS Sans TC"),local("OPPO Sans"),local("HONOR Sans"),local("Noto Sans CJK SC"),local("Noto Sans CJK TC"),local("Noto Sans CJK JP"),local("Noto Sans CJK KR"),local("Noto Sans SC"),local("Noto Sans TC"),local("Noto Sans JP"),local("Noto Sans KR")}@font-face{font-family:DK-SERIF;src:local("Times New Roman"),local("Times"),local("Georgia")}@font-face{font-family:DK-CODE;src:local("Menlo"),local("Monaco"),local("Consolas"),local("Courier New")}@font-face{font-family:DK-SYMBOL;src:local("Apple Color Emoji"),local("Noto Color Emoji"),local("Android Emoji")}aside[epub\:type~=footnote],aside[epub\:type~=endnote],div[epub\:type~=footnote]{display:none!important}note aside{display:none!important}[role~=doc-footnote],[role~=doc-endnote],.duokan-footnote-content,.footnotes,.footnote-container,.endnotes,.noteText{display:none!important}a[epub\:type~=noteref],a[role~=doc-noteref]{display:inline!important}span.notes,.notes{opacity:.7;text-decoration:underline dotted!important;cursor:pointer}body.lumina-override-color{color:var(--lumina-on-surface-color)!important}body.lumina-override-color p,body.lumina-override-color h1,body.lumina-override-color h2,body.lumina-override-color h3,body.lumina-override-color h4,body.lumina-override-color h5,body.lumina-override-color h6,body.lumina-override-color li,body.lumina-override-color span,body.lumina-override-color div,body.lumina-override-color section{color:var(--lumina-on-surface-color)}body.lumina-override-color ::selection{background-color:var(--lumina-primary-container-color)!important;color:inherit!important}body.lumina-override-color a,body.lumina-override-color a:link,body.lumina-override-color a:visited,body.lumina-override-color a:active{color:var(--lumina-primary-color);text-decoration:none}body.lumina-override-color a:visited{color:var(--lumina-primary-color)!important}body.lumina-override-color a *{color:inherit!important}body.lumina-override-color blockquote{background-color:var(--lumina-surface-container-color)!important;border-color:var(--lumina-primary-color)!important;color:var(--lumina-on-surface-variant-color)!important}body.lumina-override-color hr{background-color:var(--lumina-outline-variant-color)!important}body.lumina-override-color code{background-color:var(--lumina-surface-container-high-color)!important;color:var(--lumina-primary-color)!important}body.lumina-override-color pre{background-color:var(--lumina-surface-container-color)!important;border:1px solid var(--lumina-outline-variant-color)!important}body.lumina-override-color pre code{color:var(--lumina-on-surface-variant-color)!important}body.lumina-override-color figcaption{color:var(--lumina-on-surface-variant-color)!important}html{box-sizing:border-box!important;margin:0!important;width:100vw!important;height:100vh!important;padding-top:var(--lumina-padding-top)!important;padding-left:var(--lumina-padding-left)!important;padding-right:calc(100vw - var(--lumina-safe-width) - var(--lumina-padding-left))!important;padding-bottom:calc(100vh - var(--lumina-safe-height) - var(--lumina-padding-top))!important;background-color:transparent;touch-action:none!important;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;text-align:justify;font-size:calc(100% * var(--lumina-zoom))!important;-webkit-text-size-adjust:none!important;text-size-adjust:none!important}body{box-sizing:border-box!important;margin:0!important;padding:0!important;width:100%!important;height:100%!important;background-color:transparent}html,body{overflow-x:var(--lumina-reader-overflow-x)!important;overflow-y:var(--lumina-reader-overflow-y)!important}body{column-width:var(--lumina-safe-width)!important;column-gap:128px!important;column-fill:auto!important;height:var(--lumina-safe-height)!important}body *{orphans:1;widows:1;word-break:break-word!important;overflow-wrap:break-word!important}body.lumina-is-vertical *{max-height:var(--lumina-safe-height)!important}body:not(.lumina-is-vertical) *{max-width:var(--lumina-safe-width)!important}::-webkit-scrollbar,::-webkit-scrollbar:horizontal,::-webkit-scrollbar:vertical{-webkit-appearance:none!important;background-color:transparent!important;display:none!important;height:0!important;width:0!important}body::-webkit-scrollbar,body::-webkit-scrollbar:horizontal,body::-webkit-scrollbar:vertical{-webkit-appearance:none!important;background-color:transparent!important;display:none!important;height:0!important;width:0!important}body.lumina-is-vertical img,body.lumina-is-vertical svg,body.lumina-is-vertical video{max-width:var(--lumina-safe-width)!important}body:not(.lumina-is-vertical) img,body:not(.lumina-is-vertical) svg,body:not(.lumina-is-vertical) video{max-height:var(--lumina-safe-height)!important}img,svg,video{object-fit:contain;height:auto!important;break-inside:avoid;page-break-inside:avoid;-webkit-column-break-inside:avoid}figure{margin:0;padding:0;break-inside:avoid}a{cursor:default!important}*{max-height:1000000px;max-width:1000000px}@import "./_duokan_typ.css";
|
||
''';
|
||
|
||
const String kSkeletonCss = r'''
|
||
html,body{margin:0;padding:0;width:100vw;height:100vh;overflow:hidden;background-color:var(--lumina-surface-color, #FFFFFF)!important}#frame-container{position:absolute;top:0;left:0;right:0;bottom:0;background-color:var(--lumina-surface-color, #FFFFFF)!important;overflow:hidden}iframe{position:absolute;top:0;left:0;width:100%;height:100%;border:none;background-color:var(--lumina-surface-color, #FFFFFF)!important;will-change:opacity;transition:none;touch-action:none;}
|
||
''';
|