diff --git a/.gitignore b/.gitignore index ef33ba4..63ac0c1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # HTML2PDF4Doc JS file. # html2pdf4doc/html2pdf4doc_js/ +.DS_Store .venv/ .vscode .idea/ diff --git a/html2pdf4doc/html2pdf4doc_js/html2pdf4doc.min.js b/html2pdf4doc/html2pdf4doc_js/html2pdf4doc.min.js index e8dd3c1..cc4bc5b 100644 --- a/html2pdf4doc/html2pdf4doc_js/html2pdf4doc.min.js +++ b/html2pdf4doc/html2pdf4doc_js/html2pdf4doc.min.js @@ -1,7 +1,11 @@ /*! Version: 0.3.0 */ -var HTML2PDF4DOC;(()=>{"use strict";var e={d:(t,i)=>{for(var n in i)e.o(i,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:i[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{init:()=>Dn});var i={};e.r(i),e.d(i,{log:()=>R,logGroup:()=>D,logGroupEnd:()=>v,strictAssert:()=>x});var n={};e.r(n),e.d(n,{isAfterContentFlowStart:()=>Z,isComplexTextBlock:()=>X,isContentFlowEnd:()=>J,isContentFlowStart:()=>Y,isFlexRow:()=>ge,isForcedPageBreak:()=>ne,isFullySPlitted:()=>de,isGrid:()=>se,isGridAutoFlowRow:()=>ce,isIMG:()=>$,isInline:()=>oe,isInlineBlock:()=>re,isLiNode:()=>j,isNeutral:()=>z,isNoBreak:()=>ee,isNoHanging:()=>te,isOBJECT:()=>W,isPRE:()=>he,isPageStartElement:()=>K,isSTYLE:()=>L,isSVG:()=>G,isSelectorMatching:()=>H,isSignificantTextNode:()=>I,isSlice:()=>ie,isSlough:()=>pe,isSyntheticTextWrapper:()=>Q,isTableLikeNode:()=>le,isTableNode:()=>ae,isWrappedTextGroup:()=>q,isWrappedTextLine:()=>U,isWrappedTextNode:()=>V});var o={};e.r(o),e.d(o,{insertStyle:()=>ue});var r={};e.r(r),e.d(r,{isFirstChildOfFirstChild:()=>fe,isLastChildOfLastChild:()=>me,isLineChanged:()=>be,isLineKept:()=>we,resolveFlowElement:()=>Me,setInitStyle:()=>Se});var s={};e.r(s),e.d(s,{getBottom:()=>Ee,getBottomWithMargin:()=>De,getContentHeightByProbe:()=>Ie,getEmptyNodeHeightByProbe:()=>Fe,getHeightWithMargin:()=>ve,getLineHeight:()=>Be,getMaxWidth:()=>xe,getNormalizedBottomWithMargin:()=>Oe,getNormalizedTop:()=>ye,getTableEmptyRowHeight:()=>Ne,getTableEntries:()=>He,getTableRowHeight:()=>ke,getTableRowShellHeightByTD:()=>Ae,getTop:()=>Te,getTopForPageStartCandidate:()=>Ce,getTopWithMargin:()=>Re});var l={};e.r(l),e.d(l,{create:()=>Le,createComplexTextBlock:()=>qe,createForcedPageBreak:()=>Ze,createNeutral:()=>$e,createNeutralBlock:()=>Ge,createPrintPageBreak:()=>Ue,createSignpost:()=>Je,createSliceWrapper:()=>Qe,createTable:()=>Xe,createTestNodeFrom:()=>Ke,createTextGroup:()=>ze,createTextLine:()=>je,createTextNodeWrapper:()=>We,createWithFlagNoBreak:()=>Ve,createWord:()=>Ye});var a={};e.r(a),e.d(a,{prepareSplittedNode:()=>nt,splitByWordsGreedyWithSpacesFilter:()=>it,splitTextByLinesGreedy:()=>et,splitTextByWordsGreedy:()=>tt});var h={};e.r(h),e.d(h,{markBottomCut:()=>_t,markCleanBottomCut:()=>pt,markCleanTopCut:()=>dt,markPageEndElement:()=>gt,markPageStartElement:()=>ht,markProcessed:()=>rt,markSliceCuts:()=>ft,markSliceCutsInRows:()=>mt,markTopCut:()=>ut,setFlagNoBreak:()=>st,setFlagNoHanging:()=>lt,setFlagSlice:()=>at,unmarkPageStartElement:()=>ct});var c={};e.r(c),e.d(c,{wrapNodeChildrenWithNeutralBlock:()=>bt});var g={};e.r(g),e.d(g,{copyNodeWidth:()=>Ct,estimateInlineImgGapBelow:()=>Tt,fitElementWithinBoundaries:()=>St,fitElementWithinHeight:()=>Mt,lockNodesWidths:()=>Ot,lockTableWidths:()=>yt,scaleCellsToHeight:()=>Pt});var d={};e.r(d),e.d(d,{findAllForcedPageBreakInside:()=>Nt,findBetterForcedPageStarter:()=>Dt,findBetterPageStart:()=>vt,findFirstChildParent:()=>Ft,findFirstChildParentFromPage:()=>Rt,findLastChildParent:()=>Bt,findPreviousNonHangingsFromPage:()=>xt,findSuitableNonHangingPageStart:()=>kt});var p={};e.r(p),e.d(p,{getFirstChildrenChain:()=>jt,getLastChildrenChain:()=>zt,getPreparedChildren:()=>Gt,getSplitChildren:()=>Wt});var u={};e.r(u),e.d(u,{isReplacedElement:()=>Qt,resolveReplacedElement:()=>ei});var _={};e.r(_),e.d(_,{cloneAndCleanOutsideRange:()=>ai,getSplitPoints:()=>ii,getSplitPointsPerCells:()=>ni,isFirstSliceEmpty:()=>li,normalizeContentCuts:()=>ri,sliceNodeBySplitPoints:()=>oi,sliceNodeContentBySplitPoints:()=>si});var f={};e.r(f),e.d(f,{shouldSkipFlowElement:()=>pi});var m={};e.r(m),e.d(m,{buildRowSlices:()=>_i,evaluateRowSplitPlacement:()=>mi,paginationBuildBalancedRowSlices:()=>fi,replaceCurrentRowsAfterRowSplit:()=>bi,sliceCellsBySplitPoints:()=>ui});var b={};e.r(b),e.d(b,{paginationApplyFullPageScaling:()=>Pi,paginationScaleCellsToHeight:()=>Si,paginationShouldScaleFullPage:()=>Mi});var w={};e.r(w),e.d(w,{applyRowSlicesToEntriesAfterRowSplit:()=>Ci,computeRowFlags:()=>yi});var S={};e.r(S),e.d(S,{paginationRefreshRowsAfterSplit:()=>Ti,validateSplitterAdapter:()=>Oi});var M={};e.r(M),e.d(M,{paginationComputeCellShellHeights:()=>Ei});var P={};e.r(P),e.d(P,{handleRowOverflow:()=>Ri,handleRowSplitFailure:()=>xi,scaleRowCellsToHeight:()=>vi});var C={};e.r(C),e.d(C,{absorbShortTrailingSliceIfFits:()=>Bi,calculateFinalPartReclaimedHeight:()=>Fi});var y={};e.r(y),e.d(y,{paginationBuildRowEvaluationContext:()=>Ni,paginationCanAbsorbLastRow:()=>Ai});var O={};e.r(O),e.d(O,{paginationCalculateRowSplitBudget:()=>Gi,paginationHandleRowSlicesPlacement:()=>Ui,paginationProcessRowSplitResult:()=>zi,paginationResolveAlreadySlicedRow:()=>$i,paginationResolveOverflowingRow:()=>Ii,paginationResolveRowWithRowspan:()=>Li,paginationResolveSplittableRow:()=>Vi,paginationSplitRow:()=>Wi});const T={init:"[html2pdf]",root:"html2pdf-root",paperFlow:"html2pdf-paper-flow",contentFlow:"html2pdf-content-flow",overlayFlow:"html2pdf-overlay-flow",pageDivider:"html2pdf-page",pageStartMarker:"[html2pdf-page-start]",pageEndMarker:"[html2pdf-page-end]",contentFlowStart:"html2pdf-content-flow-start",contentFlowEnd:"html2pdf-content-flow-end",style:"[html2pdf-style]",frontpageTemplate:"[html2pdf-frontpage]",headerTemplate:"[html2pdf-header]",footerTemplate:"[html2pdf-footer]",frontpageElement:"html2pdf-frontpage",frontpageContent:"html2pdf-frontpage-content",headerContent:"html2pdf-header",footerContent:"html2pdf-footer",pageNumberRoot:"[html2pdf-page-number]",pageNumberCurrent:"[html2pdf-page-number-current]",pageNumberTotal:"[html2pdf-page-number-total]",pageChrome:"html2pdf-page-chrome",pageBodySpacer:"html2pdf-page-body-spacer",pageHeader:"html2pdf-page-header",pageFooter:"html2pdf-page-footer",printPageBreak:"html2pdf-print-page-break",runningSafety:"html2pdf-print-running",virtualPaper:"html2pdf-virtual-paper",virtualPaperTopMargin:"html2pdf-virtual-paper-margin-top",virtualPaperBottomMargin:"html2pdf-virtual-paper-margin-bottom",virtualPaperGap:"html2pdf-virtual-paper-gap",printIgnore:"[html2pdf-print-ignore]",printHide:"[html2pdf-print-hide]",neutral:"html2pdf-neutral",word:"html2pdf-word",textNode:"html2pdf-text-node",textLine:"html2pdf-text-line",textGroup:"html2pdf-text-group",complexTextBlock:"html2pdf-complex-text-block",printForcedPageBreak:"html2pdf-print-forced-page-break",split:"[html2pdf-split]",processed:"[html2pdf-processed]",flagNoBreak:"[html2pdf-flag-no-break]",flagNoHanging:"[html2pdf-flag-no-hanging]",flagSlice:"[html2pdf-flag-slice]",topCutPart:".html2pdf-top-cut",bottomCutPart:".html2pdf-bottom-cut",cleanTopCut:".html2pdf-clean-top-cut",cleanBottomCut:".html2pdf-clean-bottom-cut",tocPageNumber:"html2pdf-toc-page-number"},E="background:#eee;color:#888;padding: 0 1px 0 0;";function D(e,t="",i=!1){"boolean"==typeof t&&(i=t,t=""),!0===i?this._debug._&&console.groupCollapsed(`%c${e}`,t):this._debug._&&console.group(`%c${e}`,t)}function v(e){this._debug._&&console.log(`%c โ–ฒ ${e} `,E),this._debug._&&console.groupEnd()}function R(e,...t){this._debug._&&console.log(`[${e}]`,...t)}function x(e,...t){this._assert&&console.assert(e,"โ›”",...t)}class F{constructor({DOM:e,config:t}){this.document=e,this.body=e.body,this._debug=t.debugMode?{...t.debugConfig.DOM}:{},this._assert=!!t.consoleAssert,Object.assign(this,i)}createElement(e){return this.document.createElement(e)}createDocumentFragment(){return this.document.createDocumentFragment()}cloneNode(e){return e?.cloneNode(!0)}cloneNodeWrapper(e){return e?.cloneNode(!1)}insertBefore(e,...t){const i=t.filter((e=>null!=e));e.before(...i)}insertAfter(e,...t){const i=t.filter((e=>null!=e));e.after(...i)}insertAtEnd(e,...t){const i=t.filter((e=>null!=e));e.append(...i)}insertAtStart(e,...t){const i=t.filter((e=>null!=e));e.prepend(...i)}insertInsteadOf(e,...t){this.insertBefore(e,...t),e.remove()}wrap(e,t){return e.before(t),t.append(e),t}moveContent(e,t){for(;e.firstChild;)t.append(e.firstChild);this.strictAssert(""===this.getInnerHTML(e))}moveRowContent(e,t){if(!e||!t)return void(this._debug._&&console.warn("moveRowContent(): sourceTR or targetTR is missing"));const i=this.getElementTagName(e),n=this.getElementTagName(t);this.strictAssert("TR"===i,`moveRowContent(): source is not TR, got ${i}`),this.strictAssert("TR"===n,`moveRowContent(): target is not TR, got ${n}`);const o=[...this.getChildren(e)],r=[...this.getChildren(t)];o.length!==r.length&&this._debug._&&console.warn(`moveRowContent(): cells count mismatch: ${o.length} (source) vs ${r.length} (target)`);const s=Math.min(o.length,r.length);for(let e=0;e0,"getAll(selectors), selectors:",e),1===e.length?[...this.getAllElements(e[0],t)]:[...e].flatMap((e=>[...this.getAllElements(e,t)]))}getElement(e,t=this.document){return this.strictAssert(e),t.querySelector(e)}getAllElements(e,t=this.document){return this.strictAssert(e),t.querySelectorAll(e)}getElementById(e,t=this.document){return t.getElementById(e)}getRightNeighbor(e){return e.nextElementSibling}getLeftNeighbor(e){return e.previousElementSibling}getParentNode(e){return e.parentElement}getNodeValue(e){return e.nodeValue}getLastElementChild(e){return e.lastElementChild}getFirstElementChild(e){return e.firstElementChild}getChildNodes(e){return e.childNodes}getChildren(e){return e.children}getElementOffsetParent(e){return e.offsetParent}getComputedStyle(e){return window.getComputedStyle(e)}getElementBCR(e){return e.getBoundingClientRect()}getElementOffsetLeft(e){return e?.offsetLeft}getElementOffsetHeight(e){return e?.offsetHeight}getElementOffsetWidth(e){return e?.offsetWidth}getElementOffsetTop(e){return e?.offsetTop}getElementOffsetBottom(e){return e?.offsetTop+e?.offsetHeight||void 0}getElementTagName(e){return e.tagName}getDataId(e){return e.dataset.id}getAttribute(e,t){if(!e||!t)return void(this._debug._&&console.warn("getAttribute() must have 2 params"));const i=t.charAt(0);if("."!==i&&"#"!==i||this.log("getAttribute",`you're really sure ${t} is attribute selector?`),"["===i){this.strictAssert("]"===t.at(-1),`the ${t} selector is not OK.`);const i=t.substring(1,t.length-1);return e.getAttribute(i)}e.getAttribute(t)}setAttribute(e,t,i){if(!e||!t)return void(this._debug._&&console.warn("setAttribute() must have 2 params"));const n=t.charAt(0);if("."!==n)if("#"!==n)if("["!==n)this.log("setAttribute",`you're really sure ${t} is a selector?`);else{this.strictAssert("]"===t.at(-1),`the ${t} selector is not OK.`);const n=t.substring(1,t.length-1);e.setAttribute(n,i||"")}else{const i=t.substring(1);e.id=i}else{const i=t.substring(1);e.classList.add(i)}}setStyles(e,t){Object.entries(t).forEach((([t,i])=>{Array.isArray(i)?this.setStyle(e,t,i[0],i[1]||""):this.setStyle(e,t,i)}))}setStyle(e,t,i,n=""){const o=this._toKebab(t);null==i||""===i?e.style.removeProperty(o):e.style.setProperty(o,String(i),n)}_toKebab=e=>{if(e.includes("-"))return e;const t=e.match(/^(webkit|moz|ms|o)(?=[A-Z])/);return t&&(e="-"+t[1]+"-"+e.slice(t[1].length)),e.replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))};addClasses(e,...t){e.classList.add(...t)}removeAttribute(e,t){if(!e||!t)return void(this._debug._&&console.warn("removeAttribute() must have 2 params"));const i=t.charAt(0);if(this.strictAssert(i.match(/[a-zA-Z#\[\.]/),`removeAttribute() expects a valid selector, but received ${t}`),"."!==i)if("#"!==i)if("["!==i)e.removeAttribute(attr);else{this.strictAssert("]"===t.at(-1),`the ${t} selector is not OK.`);const i=t.substring(1,t.length-1);e.removeAttribute(i)}else{const i=t.substring(1);e.removeAttribute(i)}else{const i=t.substring(1);e.classList.remove(i)}}removeAllAttributes(e){for(;e.attributes.length>0;)e.removeAttribute(e.attributes[0].name)}removeClasses(e,...t){e.classList.remove(...t)}removeAllClasses(e){e.classList=""}removeAllStyles(e){e.style=""}getInnerHTML(e){if("string"==typeof e){const t=this.document.querySelector(e);return t?t.innerHTML:void 0}return e.innerHTML}setInnerHTML(e,t){if("string"==typeof e){const i=this.document.querySelector(e);i&&(i.innerHTML=t)}e.innerHTML=t}isDocumentBody(e){return"BODY"===e.tagName}isTextNode(e){return e.nodeType===Node.TEXT_NODE}isElementNode(e){return e.nodeType===Node.ELEMENT_NODE}hasClass(e,t){return e.classList.contains(t)}hasID(e,t){return e.id===t}hasAttribute(e,t){return e.hasAttribute(t)}}class B{constructor(e){this.config=e,this._printWidth=parseFloat(this.config.paperWidth),this._printLeft=parseFloat(this.config.printLeftMargin),this._printRight=parseFloat(this.config.printRightMargin),this._printContentWidth=this._printWidth-this._printLeft-this._printRight+"px",this._flowPreviewPaddingBottom="100px",this._chromeBorderSafeSpace="2px",this._ensureBFC="display: flow-root",this.charWidth="10px"}create(){return this._pageRule()+this._layoutStyles().screen+this._layoutStyles().print+this._chromeStyles().screen+this._chromeStyles().print+this._serviceElementsStyle().screen+this._serviceElementsStyle().print+this._cutEdgeStyle()+(this.config.debugMode?this._testScreenOnlyStyle():"")}_pageRule(){return`@page {\n size: A4;\n size: ${`${this.config.paperWidth} ${this.config.paperHeight}`};\n margin-left: ${this.config.printLeftMargin};\n margin-right: ${this.config.printRightMargin};\n margin-top: ${this.config.printTopMargin};\n margin-bottom: 0;\n}`}_layoutStyles(){return{screen:`\n${T.root} {\n --paper-color: ${this.config.paperColor};\n display: flow-root;\n position: relative;\n z-index: 1;\n width: ${this._printContentWidth};\n margin: 0 auto;\n font-size: ${this.config.printFontSize};\n padding-bottom: ${this._flowPreviewPaddingBottom};\n}\n\n${T.contentFlow} {\n display: block;\n}\n\n${T.paperFlow} {\n display: block;\n position: absolute;\n width: 100%;\n z-index: -1;\n padding-bottom: ${this._flowPreviewPaddingBottom};\n pointer-events: none;\n}\n\n${T.overlayFlow} {\n display: block;\n position: absolute;\n width: 100%;\n z-index: 2147483647;\n padding-bottom: ${this._flowPreviewPaddingBottom};\n pointer-events: none;\n}\n\n${T.virtualPaper} {\n display: grid;\n grid-template-columns: 1fr;\n grid-template-rows: minmax(min-content, max-content) minmax(min-content, max-content) 1fr minmax(min-content, max-content) minmax(min-content, max-content);\n place-items: stretch stretch;\n place-content: stretch stretch;\n width: ${this._printContentWidth};\n height: ${this.config.paperHeight};\n font-size: ${this.config.printFontSize};\n}\n\n${T.virtualPaper}::before {\n position: absolute;\n content: '';\n width: ${this.config.paperWidth};\n height: ${this.config.paperHeight};\n left: -${this.config.printLeftMargin};\n background: var(--paper-color, white);\n box-shadow: rgba(0, 0, 0, 0.1) 2px 2px 12px 0px;\n z-index: -1;\n}\n\n${T.pageChrome} {\n display: block;\n pointer-events: none;\n}\n\n${T.pageBodySpacer} {\n display: block;\n pointer-events: none;\n}\n\n${T.pageFooter},\n${T.pageHeader} {\n display: block;\n position: relative;\n pointer-events: auto;\n}\n\n${T.pageFooter}::before,\n${T.pageHeader}::before {\n content: '';\n position: absolute;\n inset: 0;\n z-index: -1;\n background: var(--paper-color, white);\n}\n\n${T.pageFooter}::before {\n top: ${this._chromeBorderSafeSpace};\n}\n\n${T.pageHeader}::before {\n bottom: ${this._chromeBorderSafeSpace};\n}\n\n${T.virtualPaperTopMargin} {\n display: block;\n height: ${this.config.printTopMargin};\n}\n\n${T.virtualPaperBottomMargin} {\n display: block;\n height: ${this.config.printBottomMargin};\n}\n\n${T.virtualPaperGap} {\n display: block;\n padding-top: ${this.config.virtualPagesGap};\n}\n\n${T.contentFlowStart},\n${T.contentFlowEnd},\n${T.pageDivider},\n${T.runningSafety} {\n ${this._ensureBFC};\n}\n `,print:`\n@media print {\n\n ${T.root},\n ${T.overlayFlow},\n ${T.paperFlow} {\n padding: 0;\n }\n\n ${T.paperFlow},\n ${T.printHide} {\n display: none !important;\n }\n\n ${T.printIgnore} {\n display: contents !important;\n }\n\n ${T.virtualPaperTopMargin},\n ${T.virtualPaperBottomMargin},\n ${T.virtualPaperGap} {\n display: none !important;\n }\n\n ${T.pageChrome},\n ${T.frontpageElement},\n ${T.pageBodySpacer} {\n break-inside: avoid;\n }\n}\n `}}_chromeStyles(){return{screen:`\n${T.headerContent},\n${T.footerContent} {\n display: block;\n font-size: small;\n}\n\n${T.headerContent} p,\n${T.footerContent} p {\n margin: 0;\n}\n\n${T.headerContent} {\n padding-bottom: ${this.config.headerMargin};\n padding-top: 10px; /* for page numbers */\n}\n\n${T.footerContent} {\n padding-top: ${this.config.footerMargin};\n min-height: 32px; /* for page numbers */\n}\n\n${T.tocPageNumber} {\n min-width: 3ch;\n display: flex;\n justify-content: flex-end;\n align-items: baseline;\n}\n\n${T.pageNumberRoot} {\n display: flex;\n column-gap: 2px;\n position: absolute;\n right: 0;\n text-align: right;\n line-height: 1;\n}\n\n${T.headerContent} ${T.pageNumberRoot} {\n top: 0;\n}\n\n${T.footerContent} ${T.pageNumberRoot} {\n bottom: 0;\n}\n `,print:""}}_cutEdgeStyle(){return`\n${T.topCutPart} {\n margin-top: 0 !important;\n}\n${T.bottomCutPart} {\n margin-bottom: 0 !important;\n}\n${T.cleanTopCut} {\n margin-top: 0 !important;\n padding-top: 0 !important;\n border-top: none !important;\n}\n${T.cleanBottomCut} {\n margin-bottom: 0 !important;\n padding-bottom: 0 !important;\n border-bottom: none !important;\n}\n `}_serviceElementsStyle(){const e="display: inline";return{screen:`\n.null {\n display: inline;\n padding: 0;\n margin: 0;\n font: 0;\n color: transparent;\n line-height: 0;\n border: none;\n outline: none;\n background: none;\n background-color: transparent;\n}\n\n${T.word},\n${T.textNode},\n${T.textLine},\n${T.textGroup},\n${T.neutral},\n${T.neutral} span {\n display: inline;\n padding: 0;\n margin: 0;\n font: inherit;\n color: inherit;\n line-height: inherit;\n background: none;\n background-color: transparent;\n}\n\n${T.textGroup} {\n display: block;\n}\n\n${T.textLine} {\n display: inline-block;\n}\n\n${T.textGroup} ${T.textLine} {\n ${e};\n}\n\n${T.complexTextBlock} {\n display: block;\n}\n\n${T.complexTextBlock} ${T.complexTextBlock} {\n ${e};\n}\n\n${T.printPageBreak} {\n ${this._ensureBFC};\n}\n\n${T.printForcedPageBreak} {\n display: block;\n visibility: hidden;\n height: 0;\n overflow: hidden;\n}\n `,print:`\n@media print {\n\n ${T.printPageBreak} {\n break-after: page;\n }\n\n ${T.textLine} {\n ${e};\n }\n}\n `}}_testScreenOnlyStyle(){return`\n/* DEBUG PREVIEW */\n@media screen {\n\n ${T.contentFlow} {\n background:repeating-linear-gradient(\n -45deg,\n rgba(222, 222, 222, .1),\n rgba(222, 222, 222, .1) 10px,\n rgba(222, 222, 222, .2) 10px,\n rgba(222, 222, 222, .2) 20px\n );\n }\n\n ${T.overlayFlow} {\n background:repeating-linear-gradient(\n 45deg,\n rgba(222, 222, 222, 0),\n rgba(222, 222, 222, 0) 18px,\n rgba(0, 166, 255, 0.05) 18px,\n rgba(0, 166, 255, 0.05) 20px\n );\n }\n\n ${T.virtualPaperGap} {\n background: #ff000020;\n }\n\n ${T.pageFooter},\n ${T.pageHeader} {\n background: #fff1ff99;\n }\n ${T.pageBodySpacer} {\n background: #ffee0020;\n }\n ${T.runningSafety} {\n background: #f200ff;\n outline: 0.1px dashed #f200ff88;\n }\n ${T.frontpageElement} {\n background: #00fcff20;\n }\n\n ${T.neutral} {\n background: #00ffee10;\n }\n\n ${T.textNode} {\n background: #00ff0010;\n }\n\n ${T.textGroup},\n ${T.textLine} {\n background: #0000ff08;\n }\n}\n `}}class k{constructor({config:e,DOM:t,node:n,selector:o}){this.success=!1,this._assert=!!e.consoleAssert,Object.assign(this,i),this.root,this.paperFlow,this.contentFlow,this.overlayFlow,this.frontpageTemplate,this.headerTemplate,this.footerTemplate,this._initialRoot,this._contentRoot,this._config=e,this._debug=e.debugMode?{...e.debugConfig.layout}:{},this._assert=!!e.consoleAssert,this._DOM=t,this._selector=o,this._node=n,this._customInitialRootSelector=e.initialRoot,this._defaultInitialRootSelector=o.init}create(){if(this._getTemplates(),this._insertStyle(),this._DOM.getElement(`style${this._selector.style}`)){if(this._createLayout(),this._DOM.getParentNode(this.root)!==this._initialRoot||this._DOM.getElementOffsetParent(this.paperFlow)!==this.root||this._DOM.getElementOffsetParent(this.contentFlow)!==this.root||this._DOM.getElementOffsetParent(this.overlayFlow)!==this.root)return this.strictAssert(this._DOM.getParentNode(this.root)===this._initialRoot,"Failed to insert the layout root into the DOM."),this.strictAssert(this._DOM.getElementOffsetParent(this.paperFlow)===this.root,"Failed to insert the paperFlow element into the DOM."),void this.strictAssert(this._DOM.getElementOffsetParent(this.contentFlow)===this.root,"Failed to insert the contentFlow element into the DOM.");this.success=!0}else console.error("Failed to add print styles into the DOM.")}_getTemplates(){this.strictAssert(this._selector.frontpageTemplate,"frontpageTemplate selector is missing"),this.strictAssert(this._selector.headerTemplate,"headerTemplate selector is missing"),this.strictAssert(this._selector.footerTemplate,"footerTemplate selector is missing"),this.frontpageTemplate=this._DOM.getInnerHTML(this._selector.frontpageTemplate),this.headerTemplate=this._DOM.getInnerHTML(this._selector.headerTemplate),this.footerTemplate=this._DOM.getInnerHTML(this._selector.footerTemplate)}_insertStyle(){this._node.insertStyle(new B(this._config).create())}_createLayout(){this._getInitialRoot(),this._initialRoot?(this.log("create Layout","initial root:",this._initialRoot),this._createRoot(),this._createPaperFlow(),this._createContentFlow(),this._createOverlayFlow(),this._DOM.moveContent(this._initialRoot,this.contentFlow),this._DOM.insertAtEnd(this._initialRoot,this.root),this._DOM.insertAtEnd(this.root,this.paperFlow,this.overlayFlow,this.contentFlow),this._insertContentFlowStartAndEnd(this.contentFlow),this._ignoreUnprintableEnvironment(this.root)):console.error("Failed to initialize the root element.")}_insertContentFlowStartAndEnd(e){const t=this._node.create(this._selector.contentFlowStart),i=this._node.create(this._selector.contentFlowEnd);return this._DOM.insertAtStart(e,t),this._DOM.insertAtEnd(e,i),{contentFlowStart:t,contentFlowEnd:i}}_getInitialRoot(){let e=this._customInitialRootSelector?this._DOM.getElement(this._customInitialRootSelector):this._DOM.getElement(this._defaultInitialRootSelector);if(!e){if(!this._DOM.body)return void console.error("We expected to find the BODY tag.");e=this._DOM.body,console.warn(`The printable area is currently unspecified and encompasses the entire contents of the BODY tag. To restrict the printed content to a specific area, include ${this._defaultInitialRootSelector} in the root element of the desired printing area.`)}return this._initialRoot=e,e}_createRoot(){const e=this._node.create(this._selector.root);return this._DOM.setStyles(e,{visibility:"hidden"}),this.root=e,e}_createPaperFlow(){const e=this._node.create(this._selector.paperFlow);return this.paperFlow=e,e}_createOverlayFlow(){const e=this._node.create(this._selector.overlayFlow);return this.overlayFlow=e,e}_createContentFlow(){const e=this._node.create(this._selector.contentFlow);return this.contentFlow=e,e}_ignoreUnprintableEnvironment(e){if(e===this._DOM.body)return void this.strictAssert(!1,"misshapen root");let t=this._DOM.getParentNode(e);this._DOM.setAttribute(t,this._selector.printIgnore),this._DOM.getChildNodes(t).forEach((t=>{if(t!==e&&this._DOM.isElementNode(t))this._DOM.setAttribute(t,this._selector.printHide);else{if(!this._node.isSignificantTextNode(t))return;{const e=this._node.createTextNodeWrapper();this._DOM.wrap(t,e),this._DOM.setAttribute(e,this._selector.printHide)}}})),this._DOM.isDocumentBody(t)||this._ignoreUnprintableEnvironment(t)}}function N(e){return function(t){return t._config.debugMode&&t._debug[e]}}const A=N("selectors");function H(e,t){if(!e||!t)return void(A(this)&&console.warn("isSelectorMatching() must have 2 params","\n element: ",e,"\n selector: ",t));const i=t.charAt(0);if("."===i){const i=t.substring(1);return this._DOM.hasClass(e,i)}if("#"===i){const i=t.substring(1);return this._DOM.hasID(e,i)}if("["===i){this.strictAssert("]"===t.at(-1),`the ${t} selector is not OK.`);const i=t.substring(1,t.length-1);return this._DOM.hasAttribute(e,i)}return this._DOM.getElementTagName(e)===t.toUpperCase()}function I(e){return!!this._DOM.isTextNode(e)&&this._DOM.getNodeValue(e).trim().length>0}function L(e){return"STYLE"===this._DOM.getElementTagName(e)}function $(e){return"IMG"===this._DOM.getElementTagName(e)}function G(e){return"svg"===this._DOM.getElementTagName(e)}function W(e){return"OBJECT"===this._DOM.getElementTagName(e)}function j(e){return"LI"===this._DOM.getElementTagName(e)}function z(e){return this.isSelectorMatching(e,this._selector.neutral)}function V(e){return this.isSelectorMatching(e,this._selector.textNode)}function U(e){return this.isSelectorMatching(e,this._selector.textLine)}function q(e){return this.isSelectorMatching(e,this._selector.textGroup)}function K(e){return this.isSelectorMatching(e,this._selector.pageStartMarker)}function Y(e){return this.isSelectorMatching(e,this._selector.contentFlowStart)}function Z(e){const t=this._DOM.getLeftNeighbor(e);return this.isSelectorMatching(t,this._selector.contentFlowStart)}function J(e){return this.isSelectorMatching(e,this._selector.contentFlowEnd)}function X(e){return this.isSelectorMatching(e,this._selector.complexTextBlock)}function Q(e){return this.isComplexTextBlock(e)||this.isWrappedTextNode(e)||this.isWrappedTextLine(e)||this.isWrappedTextGroup(e)}function ee(e,t){return this.isSelectorMatching(e,this._selector.flagNoBreak)||this.isWrappedTextLine(e)||this.isWrappedTextGroup(e)||this.isInlineBlock(e,t)||this.notSolved(e)}function te(e){return this.isSelectorMatching(e,this._selector.flagNoHanging)}function ie(e){return this.isSelectorMatching(e,this._selector.flagSlice)}function ne(e){return this.isSelectorMatching(e,this._selector.printForcedPageBreak)}function oe(e,t){if(!(e instanceof HTMLElement))return;const i=(t||this._DOM.getComputedStyle(e)).display;return"inline"===i||"inline-block"===i||"inline-table"===i||"inline-flex"===i||"inline-grid"===i}function re(e,t){if(!(e instanceof HTMLElement))return;const i=(t||this._DOM.getComputedStyle(e)).display;return"inline-block"===i||"inline-table"===i||"inline-flex"===i||"inline-grid"===i}function se(e,t){if(!(e instanceof HTMLElement))return;return"grid"===(t||this._DOM.getComputedStyle(e)).display}function le(e,t){if(!(e instanceof HTMLElement))return;const i=t||this._DOM.getComputedStyle(e);return"TABLE"!==this._DOM.getElementTagName(e)&&["table"].includes(i.display)}function ae(e,t){if(!(e instanceof HTMLElement))return;const i=t||this._DOM.getComputedStyle(e);return"TABLE"===this._DOM.getElementTagName(e)||["table"].includes(i.display)}function he(e,t){if(!(e instanceof HTMLElement))return;const i=t||this._DOM.getComputedStyle(e);return["block"].includes(i.display)&&["pre","pre-wrap","pre-line","break-spaces","nowrap"].includes(i.whiteSpace)}function ce(e,t){if(!(e instanceof HTMLElement))return;const i=t||this._DOM.getComputedStyle(e),n=i.display,o=i.gridAutoFlow;return("grid"===n||"inline-grid"===n)&&"row"===o}function ge(e,t){if(!(e instanceof HTMLElement))return;const i=t||this._DOM.getComputedStyle(e),n=i.display;if("flex"!==n&&"inline-flex"!==n)return!1;return(i.flexDirection||"").startsWith("row")}function de(e,t){const i=t||this._DOM.getComputedStyle(e);return this.isPRE(e,i)||this.isTableNode(e,i)||this.isTableLikeNode(e,i)||this.isGridAutoFlowRow(e,i)}function pe(e){return this._DOM.hasAttribute(e,"slough-node")}function ue(e,t=""){const i=this._DOM.getElement("head"),n=this._DOM.body;if(!i&&!n)return void console.error("Check the structure of your document. We didn`t find HEAD and BODY tags. HTML2PDF4DOC expects valid HTML.");const o=this.create("style",e);o?(this._DOM.setAttribute(o,this._selector.style,t),i?this._DOM.insertAtEnd(i,o):n?this._DOM.insertBefore(n,o):this.strictAssert(!1,"We expected to find the HEAD and BODY tags.")):console.error("Failed to create print styles")}const _e=N("positioning");function fe(e,t){if(!e||!this._DOM.getParentNode(e))return!1;let i=e;for(;this._DOM.getParentNode(i)&&i!==t;){if(this._DOM.getFirstElementChild(this._DOM.getParentNode(i))!==i)return!1;i=this._DOM.getParentNode(i)}return i===t}function me(e,t){if(!e||!this._DOM.getParentNode(e))return!1;let i=e;for(;this._DOM.getParentNode(i)&&i!==t;){if(this._DOM.getParentNode(i)===t){let e=this._DOM.getRightNeighbor(i);for(;!this._DOM.getElementOffsetHeight(e)&&!this._DOM.getElementOffsetWidth(e);)if(e=this._DOM.getRightNeighbor(e),this.isContentFlowEnd(e))return!0;return this.isContentFlowEnd(e)}if(this._DOM.getLastElementChild(this._DOM.getParentNode(i))!==i)return!1;i=this._DOM.getParentNode(i)}return i===t}function be(e,t){return this._DOM.getElementOffsetTop(t)-this._DOM.getElementOffsetBottom(e)>-2}function we(e,t){const i=this._DOM.getElementOffsetBottom(e),n=this._DOM.getElementOffsetTop(t),o=i-n,r=o>=2;return _e(this)&&console.group("isLineKept?"),_e(this)&&console.log("\n",r,"\n","\n currentBottom",i,[e],"\n nextTop",n,[t],"\n delta",o),_e(this)&&console.groupEnd("isLineKept?"),r}function Se(e,t,i){const n="[init-position]",o="[init-vertical-align]",r="relative",s=i||this._DOM.getComputedStyle(t),l=s.position,a=s.verticalAlign;if(e)l!=r&&(this._DOM.setStyles(t,{position:r}),this._DOM.setAttribute(t,n,l)),"top"!=a&&(this._DOM.setStyles(t,{"vertical-align":"top"}),this._DOM.setAttribute(t,o,a));else{const e=this._DOM.getAttribute(t,n),i=this._DOM.getAttribute(t,o);e&&(this._DOM.setStyles(t,{position:e}),this._DOM.removeAttribute(t,n)),i&&(this._DOM.setStyles(t,{"vertical-align":i}),this._DOM.removeAttribute(t,o))}}function Me(e,{prefer:t="self"}={}){if(!e)return null;const i=e=>"last"===t?this._DOM.getLastElementChild(e):"first"===t||"self"===t?this._DOM.getFirstElementChild(e):null,n=new Set;let o=e;for(;o&&!n.has(o);){n.add(o);if(this._DOM.getElementOffsetParent(o))return o;const e=this._DOM.getComputedStyle(o);if(!e)return null;const t=e.display,r=e.visibility,s=e.position;if("none"===t||"collapse"===r||"fixed"===s)return null;if("contents"!==t)return null;{const e=i.call(this,o);if(!e)return null;o=e}}return null}const Pe=N("getters");function Ce(e,t){return this.getTop(e,t)}function ye(e,t,i){const n=i||this._DOM.getComputedStyle(t),o=parseFloat(n.paddingTop)||0;return this.getTop(e,t)-o}function Oe(e,t,i){const n=i||this._DOM.getComputedStyle(t),o=parseFloat(n.paddingTop)||0;return this.getBottomWithMargin(e,t)-o}function Te(e,t=null,i=0){if(!e)return void(Pe(this)&&console.warn("element must be provided, but was received:",e,"\nThe function returned:",void 0));if(null===t)return this._DOM.getElementOffsetTop(e);if(!t)return void(Pe(this)&&console.warn("root must be provided, but was received:",t,"\nThe function returned:",void 0));const n=this._DOM.getElementOffsetParent(e);if(!n)return void(Pe(this)&&console.warn("Element has no offset parent.","\n element:",[e],"\n offsetParent:",n,"\n The function returned:",void 0));const o=this._DOM.getElementOffsetTop(e);return n===t?o+i:this.getTop(n,t,i+o)}function Ee(e,t=null){if(e){if(null===t)return this._DOM.getElementOffsetBottom(e);if(t)return this.getTop(e,t)+this._DOM.getElementOffsetHeight(e);Pe(this)&&console.warn("root must be provided, but was received:",t,"\nThe function returned:",void 0)}else Pe(this)&&console.warn("element must be provided, but was received:",e,"\nThe function returned:",void 0)}function De(e,t){if(!e)return;const i=this.getBottom(e,t);let n;const o=this.createNeutralBlock();this._DOM.insertAfter(e,o);const r=this.getTop(o,t);this._DOM.removeNode(o);if(r>=i)n=r;else{n=i+parseInt(this._DOM.getComputedStyle(e).marginBottom)}return n}function ve(e){const t=parseInt(this._DOM.getComputedStyle(e).marginTop),i=parseInt(this._DOM.getComputedStyle(e).marginBottom);return this._DOM.getElementOffsetHeight(e)+t+i}function Re(e,t){const i=parseInt(this._DOM.getComputedStyle(e).marginTop);return this.getTop(e,t)-i}function xe(e){const t=this.create();this._DOM.insertAtEnd(e,t);const i=this._DOM.getElementOffsetWidth(t);return this._DOM.removeNode(t),i}function Fe(e,t="",i=!0){const n=this.create();i&&this._DOM.setStyles(n,{overflow:"auto"});const o=this._DOM.cloneNodeWrapper(e);this._DOM.setInnerHTML(o,t),this._DOM.insertAtEnd(n,o),this._DOM.insertBefore(e,n);const r=this._DOM.getElementOffsetHeight(n);return this._DOM.removeNode(n),r}function Be(e){const t=this.createNeutral();this._DOM.setInnerHTML(t,"!"),this._DOM.setStyles(t,{display:"block"}),this._DOM.insertAtEnd(e,t);const i=this._DOM.getElementOffsetHeight(t);return this._DOM.removeNode(t),i}function ke(e,t=0){const i=this._DOM.getElementOffsetTop(e),n=this._DOM.cloneNode(e),o="!
".repeat(t);[...n.children].forEach((e=>this._DOM.setInnerHTML(e,o))),this._DOM.insertBefore(e,n);const r=this._DOM.getElementOffsetTop(e);return this._DOM.removeNode(n),r-i}function Ne(e){const t=this._DOM.getElementOffsetTop(e),i=this._DOM.cloneNodeWrapper(e);this._DOM.insertBefore(e,i);const n=this._DOM.getElementOffsetTop(e);return this._DOM.removeNode(i),n-t}function Ae(e){const t=this._DOM.getElementOffsetTop(e),i=this._DOM.cloneNodeWrapper(e),n=e.children.length,o=[...e.children];this._DOM.insertBefore(e,i);const r=[];for(let s=0;sthis._DOM.removeNode(e)))}return this._DOM.removeNode(i),r}function He(e){if(!(e instanceof HTMLElement)||"TABLE"!==e.tagName)throw new Error("Expected a element.");const t=[...e.children].reduce(((e,t)=>{const i=t.tagName;return"TBODY"===i?{...e,rows:[...e.rows,...t.children]}:"CAPTION"===i?(this.setFlagNoBreak(t),{...e,caption:t}):"COLGROUP"===i?(this.setFlagNoBreak(t),{...e,colgroup:t}):"THEAD"===i?(this.setFlagNoBreak(t),{...e,thead:t}):"TFOOT"===i?(this.setFlagNoBreak(t),{...e,tfoot:t}):"TR"===i?{...e,rows:[...e.rows,...t]}:(Pe(this)&&t&&console.warn("unexpected:",t),{...e,unexpected:[...e.unexpected,...t]})}),{caption:null,thead:null,tfoot:null,rows:[],unexpected:[]});return t.unexpected.length>0&&Pe(this)&&console.warn(`something unexpected is found in the table ${e}`),t}function Ie(e,t){const i=t||this._DOM.getComputedStyle(e),n=this.createNeutralBlock();this._DOM.setStyles(n,{display:"block",padding:"0",margin:"0",border:"0",height:"0",clear:"both",visibility:"hidden",contain:"layout"}),this._DOM.insertAtEnd(e,n);const o=this.getNormalizedTop(n,e,i);return this._DOM.removeNode(n),o}N("creators");function Le(e,t){let i;if(e){const t=e.charAt(0);if(t.match(/[#\[\.]/))i=this._DOM.createElement("div"),this._DOM.setAttribute(i,e);else{if(!t.match(/[a-zA-Z]/))return void this.strictAssert(!1,"Expected valid html selector ot tag name, but received:",e);i=this._DOM.createElement(e)}}else i=this._DOM.createElement("div");return t&&this._DOM.setInnerHTML(i,t),i}function $e(){return this.create(this._selector.neutral)}function Ge(){const e=this.createNeutral();return e.style.display="block",e.style.clear="both",e}function We(){return this.create(this._selector.textNode)}function je(){return this.create(this._selector.textLine)}function ze(){return this.create(this._selector.textGroup)}function Ve(e){const t=this.create(this._selector.flagNoBreak);return e&&this._DOM.setStyles(t,e),t}function Ue(){return this.create(this._selector.printPageBreak)}function qe(){return this.create(this._selector.complexTextBlock)}function Ke(e){const t=this._DOM.cloneNodeWrapper(e);return this._DOM.setAttribute(t,".test-node"),this._DOM.setStyles(t,{position:"absolute",background:"rgb(255 239 177)",width:this.getMaxWidth(e)+"px"}),t}function Ye(e,t){const i=this.create(this._selector.word);return this._DOM.setInnerHTML(i,e),i.dataset.index=t,i}function Ze(){return this.create(this._selector.printForcedPageBreak)}function Je(e,t){if(!t)return null;const i=this.create();return this._DOM.setStyles(i,{display:"flex",flexWrap:"nowrap",alignItems:"center",justifyContent:"center",textAlign:"center",fontSize:"8px",fontFamily:"sans-serif",letterSpacing:"1px",textTransform:"uppercase",height:t+"px"}),e&&this._DOM.setInnerHTML(i,e),this.setFlagNoBreak(i),i}function Xe({wrapper:e,caption:t,colgroup:i,thead:n,tfoot:o,tbody:r}){const s=e||this.create("table"),l=this.create("TBODY");return t&&this._DOM.insertAtEnd(s,t),i&&this._DOM.insertAtEnd(s,i),n&&this._DOM.insertAtEnd(s,n),r&&this._DOM.insertAtEnd(l,...r),this._DOM.insertAtEnd(s,l),o&&this._DOM.insertAtEnd(s,o),s}function Qe(e){const t=this._DOM.cloneNodeWrapper(e);return this.unmarkPageStartElement(t),this.setFlagNoBreak(t),t}N("splitters");function et(e){return e.split(/(?<=\n)/)}function tt(e){return(this._DOM.getNodeValue(e)||this._DOM.getInnerHTML(e)).split(/(?<=\s|-)/)}function it(e){return(this._DOM.getNodeValue(e)||this._DOM.getInnerHTML(e)).trim().split(/(?<=\s|-)/).filter((e=>" "!=e))}function nt(e){const t=e,i=this.splitTextByWordsGreedy(e),n=i.map((e=>{const t=this._DOM.createElement("span");return this._DOM.setInnerHTML(t,e+" "),t})),o=this.createTestNodeFrom(e);return this._DOM.insertAtEnd(o,...n),this._DOM.insertAtEnd(e,o),{splittedNode:t,nodeWords:i,nodeWordItems:n}}const ot=N("markers");function rt(e,t){this._markupDebugMode&&this._DOM.setAttribute(e,this._selector.processed,"๐Ÿท๏ธ "+t)}function st(e){this._DOM.setAttribute(e,this._selector.flagNoBreak)}function lt(e,t){this._DOM.setAttribute(e,this._selector.flagNoHanging,t)}function at(e){this._DOM.setAttribute(e,this._selector.flagSlice)}function ht(e,t){this._DOM.setAttribute(e,this._selector.pageStartMarker,t)}function ct(e){this._DOM.removeAttribute(e,this._selector.pageStartMarker)}function gt(e,t){this._DOM.setAttribute(e,this._selector.pageEndMarker,t)}function dt(e){ot(this)&&console.log("[mark โŠค cut]",e),e&&this._DOM.setAttribute(e,this._selector.cleanTopCut)}function pt(e){ot(this)&&console.log("[mark โŠฅ cut]",e),e&&this._DOM.setAttribute(e,this._selector.cleanBottomCut)}function ut(e){ot(this)&&console.log("[mark โŠค cut]",e),e&&this._DOM.setAttribute(e,this._selector.topCutPart)}function _t(e){ot(this)&&console.log("[mark โŠฅ cut]",e),e&&this._DOM.setAttribute(e,this._selector.bottomCutPart)}function ft(e){if(e&&e.length)if(1!==e.length)for(let t=0;t0,n=t0,o=t","color:blue",i),r=i,s=[...this._DOM.getChildren(i)]):Array.isArray(i)?(ot(this)&&console.log("%c[markSliceCutsInRows] It is an Array","color:blue",i),r=void 0,s=i):this.strictAssert(0,"we expected TR or an array of elements!"),!r&&!s.length){ot(this)&&console.log("%c[markSliceCutsInRows] There was no split","color:red",{rowWrapper:r,cellWrappers:s});break}n&&(r&&(ot(this)&&console.log("[markSliceCutsInRows] rowWrapper โŠฅ",r),this.markTopCut(r)),s.forEach((e=>{ot(this)&&console.log("[markSliceCutsInRows] cell ๐Ÿ–๏ธ โŠฅ",e),this.markTopCut(e)}))),o&&(r&&(ot(this)&&console.log("[markSliceCutsInRows] rowWrapper โŠค",r),this.markBottomCut(r)),s.forEach((e=>{ot(this)&&console.log("[markSliceCutsInRows] cell ๐Ÿ–๏ธ โŠค",e),this.markBottomCut(e)})))}else ot(this)&&console.log("%c[markSliceCutsInRows] The rows were not passed. Doing nothing.","color:red")}N("wrappers");function bt(e){const t=this._DOM.getChildren(e),i=this.createNeutralBlock();return this._DOM.insertAtStart(i,...t),this._DOM.insertAtStart(e,i),i}const wt=N("fitters");function St({element:e,height:t,width:i,vspace:n,hspace:o}){const r=n/t,s=o/i,l=ra&&(d||(d=this.wrapNodeChildrenWithNeutralBlock(s),g=this._DOM.getElementOffsetHeight(d)||g),this.fitElementWithinHeight(d,a),o=!0,wt(this)&&console.warn("๐Ÿ’ข scaleCellsToHeight: resized cell content",{cell:s,target:a}))}return o}function Ct(e,t){this._DOM.setStyles(e,{"box-sizing":"border-box",width:`${this._DOM.getElementOffsetWidth(t)}px`,"min-width":`${this._DOM.getElementOffsetWidth(t)}px`})}function yt(e){this.copyNodeWidth(e,e),this._DOM.getAll("td",e).forEach((e=>this.copyNodeWidth(e,e)))}function Ot(e){Array.isArray(e)&&e.forEach((e=>{e&&this.copyNodeWidth(e,e)}))}function Tt(e,t={}){const{descentRatio:i=.22,normalLH:n=1.2,safety:o=1}=t,r=getComputedStyle(e),s=parseFloat(r.fontSize)||0;let l;if("normal"!==r.lineHeight&&r.lineHeight){const e=parseFloat(r.lineHeight);l=Number.isFinite(e)?e:n*s}else l=n*s;const a=(Math.max(0,(l-s)/2)+i*s)*o;return Math.ceil(a)}const Et=N("pageBreaks");function Dt(e,t){let i=e;for(;;){const e=this.findFirstChildParent(i,t);if(e&&e!==i){i=e;continue}const n=Lt.call(this,i,"findBetterForcedPageStarter:left");if(!n||!this.isNoHanging(n))break;i=n}return i}function vt(e,t,i){Et(this)&&console.group("โž— findBetterPageStart");let n=!1,o=!1,r=!1;const s=this.getTop(t,i);Et(this)&&console.log("Start calculations:",{pageStart:e,lastPageStart:t,root:i,topLimit:s});const l=this.findFirstChildParentFromPage(e,s,i);let a;if(l)a=l;else{a=this.getTop(e,i)t?n:null}function Nt(e){return this._DOM.getAll(this._selector.printForcedPageBreak,e)}function At(e,t){let i=this._DOM.getParentNode(e);for(;i&&this.shouldSkipFlowElement(i,{context:t});)i=this._DOM.getParentNode(i);return i}function Ht(e,t){let i=this._DOM.getFirstElementChild(e);for(;i&&this.shouldSkipFlowElement(i,{context:t});)i=this._DOM.getRightNeighbor(i);return i}function It(e,t){let i=this._DOM.getLastElementChild(e);for(;i&&this.shouldSkipFlowElement(i,{context:t});)i=this._DOM.getLeftNeighbor(i);return i}function Lt(e,t){let i=this._DOM.getLeftNeighbor(e);for(;i&&this.shouldSkipFlowElement(i,{context:t});)i=this._DOM.getLeftNeighbor(i);return i}const $t=N("children");function Gt(e){$t(this)&&console.group("๐Ÿšธ getPreparedChildren of",e);let t=[];if(this.isComplexTextBlock(e))t=[...this._DOM.getChildren(e)],$t(this)&&console.info("๐Ÿšธ getPreparedChildren: return children for complexTextBlock",t);else{if(!Yt.call(this,e))return $t(this)&&console.info("๐Ÿชฒ getPreparedChildren: empty node, skip & return []",e),[];{$t(this)&&console.groupCollapsed("โš—๏ธ๐Ÿšธ distill children"),t=[...this._DOM.getChildNodes(e)].reduce(((e,t)=>{if(this.isSTYLE(t))return $t(this)&&console.info("๐Ÿšธ (getPreparedChildren) ignore STYLE",[t]),e;if(this.isSignificantTextNode(t)){const i=this.createTextNodeWrapper();return this._DOM.wrap(t,i),e.push(i),$t(this)&&console.info("๐Ÿšธ (getPreparedChildren) wrap and return TEXT NODE",[t]),e}if(this._DOM.isElementNode(t)){if(this.shouldSkipFlowElement(t,{context:"getPreparedChildren"}))return e;if(!this._DOM.getElementOffsetParent(t)){const i=this.getPreparedChildren(t);return i.length>0&&e.push(...i),$t(this)&&console.info("%c๐Ÿšธ (getPreparedChildren) * no offset parent โ€” unwrapped","color:green",i,[t]),e}return e.push(t),$t(this)&&console.info("๐Ÿšธ (getPreparedChildren) * normal node",[t]),e}return $t(this)&&console.info("%c๐Ÿšธ (getPreparedChildren) IGNORE whitespace / comment ...","color:red",[t]),e}),[]),$t(this)&&console.groupEnd("โš—๏ธ๐Ÿšธ distill children"),$t(this)&&console.info("๐Ÿšธ distilled children",t);const i=Kt.call(this,t),n=this.isInline(e);i&&($t(this)&&console.info("๐Ÿšธ isVerticalFlowDisrupted in children of element",[e]),n?($t(this)&&console.info("๐ŸŽ’๐Ÿšธ parent element is inline wrapper",[e]),t=[Ut.call(this,e)]):t=Vt.call(this,t))}}return $t(this)&&console.groupEnd("๐Ÿšธ getPreparedChildren of"),$t(this)&&console.info("๐Ÿšธ getPreparedChildren:",t),t}function Wt(e,t,i,n){let o=[];if(this.isNoBreak(e))return $t(this)&&console.info("๐Ÿงก isNoBreak",e),[];if(this.isComplexTextBlock(e))return $t(this)&&console.info("๐Ÿ’š ComplexTextBlock",e),this._paragraph.split(e)||[];if(this.isWrappedTextNode(e))return $t(this)&&console.info("๐Ÿ’š TextNode",e),this._paragraph.split(e)||[];if(!Yt.call(this,e))return $t(this)&&console.info("๐Ÿชฒ getSplitChildren: empty node, return []",e),[];const r=this._DOM.getComputedStyle(e);if(this.isTableLikeNode(e,r))$t(this)&&console.info("๐Ÿ’š TABLE like",e),o=this._tableLike.split(e,t,i,n,r)||[];else if(this.isTableNode(e,r))$t(this)&&console.info("๐Ÿ’š TABLE",e),o=this._table.split(e,t,i,n)||[];else if(this.isPRE(e,r))$t(this)&&console.info("๐Ÿ’š PRE",e),o=this._pre.split(e,t,i,n,r)||[];else if(this.isFlexRow(e,r)){$t(this)&&console.info("๐Ÿฉท Flex ROW",e);let t=this.getPreparedChildren(e);o=qt.call(this,t)}else this.isGridAutoFlowRow(e,r)?($t(this)&&console.info("๐Ÿ’œ GRID"),o=this._grid.split(e,t,i,n)||[]):($t(this)&&console.info("๐Ÿ’š found some node - use main this.getPreparedChildren() for:",e),o=this.getPreparedChildren(e));return o}function jt(e){const t=[];if(!e||!this||!this._DOM)return t;let i=e;for(;i;){let e=this._DOM.getFirstElementChild(i);for(;e&&this.shouldSkipFlowElement(e,{context:"getFirstChildren:firstChild"});)e=this._DOM.getRightNeighbor(e);if(!e)break;if(this.isSyntheticTextWrapper(e))break;t.push(e),i=e}return t}function zt(e){const t=[];if(!e||!this||!this._DOM)return t;let i=e;for(;i;){let e=this._DOM.getLastElementChild(i);for(;e&&this.shouldSkipFlowElement(e,{context:"getLastChildren:lastChild"});)e=this._DOM.getLeftNeighbor(e);if(!e)break;if(this.isSyntheticTextWrapper(e))break;t.push(e),i=e}return t}function Vt(e){let t=null;const i=[];return e.forEach((e=>{this.isInline(e)?(t||(t=Ut.call(this,e),i.push(t)),this._DOM.insertAtEnd(t,e)):(t=null,i.push(e))})),i}function Ut(e){const t=this.createComplexTextBlock();return this._DOM.wrap(e,t),t}function qt(e){const t=e.filter((e=>this._DOM.getElementOffsetHeight(e)>0));return t.length>0?t:e}function Kt(e){return e.some(((e,t,i)=>{const n=e,o=i[t+1];if(!o)return!1;return this._DOM.getElementOffsetBottom(n)>this._DOM.getElementOffsetTop(o)}))}function Yt(e){let t=e.firstChild;for(;t;){if(this._DOM.isElementNode(t)){if(!this.shouldSkipFlowElement(t,{context:"hasRenderableChild"}))return!0}else if(this.isSignificantTextNode(t))return!0;t=t.nextSibling}return!1}const Zt=N("media"),Jt=new Set(["IMG","SVG","OBJECT","EMBED","IFRAME","VIDEO","AUDIO","CANVAS"]);function Xt(e,t="self"){return"last"===t?this._DOM.getLastElementChild(e):this._DOM.getFirstElementChild(e)}function Qt(e){if(!e)return!1;const t=this._DOM.getElementTagName(e);if(!t)return!1;if("INPUT"===t){return"image"===(this._DOM.getAttribute(e,"type")||"").toLowerCase()}return Jt.has(t)}function ei(e,{prefer:t="self"}={}){if(!e)return null;const i=new Set;let n=e;for(;n&&!i.has(n);){if(i.add(n),this.isReplacedElement(n))return n;if("function"==typeof this.resolveFlowElement){const e=this.resolveFlowElement(n,{prefer:t});if(e&&e!==n){if(this.isReplacedElement(e))return e;n=e;continue}}const e=[...this._DOM.getChildren(n)].filter((e=>{const t=this._DOM.getComputedStyle(e)?.display;return"none"!==t}));if(1!==e.length)return Zt(this)&&console.info("๐Ÿงญ resolveReplacedElement: branching or empty wrapper",n,e),null;n=Xt.call(this,n,t)||e[0]}return null}const ti=N("slicers");function ii({rootNode:e,rootComputedStyle:t,children:i,firstPartHeight:n,fullPageHeight:o,firstChild:r,points:s=[]}){if(!i.length)return ti(this)&&console.log("๐Ÿงถ [getSplitPoints] %c has no children, early returns []","font-weight:bold",{rootNode:e}),[];const l=t=>{const i=this.findBetterPageStart(t,s.at(-1),e,e);return s.length||i!==r?(ti(this)&&console.log("%c ๐Ÿงผ๐Ÿงผ๐Ÿงผ๐Ÿงผ push(point) in registerPoint()","color:violet",{point:i,points:s,firstChild:r},s.length),s.push(i),!1):(ti(this)&&console.log("%c !points.length && point === children[0] && children[1]","color:red"),ti(this)&&console.log("%c ๐Ÿ…พ๏ธ push(null) in registerPoint()","color:red"),s.push(null),!0)};ti(this)&&console.group("๐Ÿงถ getSplitPoints"),ti(this)&&console.log("points.length",s.length);const a=t||this._DOM.getComputedStyle(e),h=new WeakMap,c=e=>{let t=h.get(e);return t||(t=Object.create(null),h.set(e,t)),t},g=t=>{if(!t)return NaN;const i=c(t);return"top"in i||(i.top=this.getNormalizedTop(t,e,a)),i.top},d=t=>{if(!t)return NaN;const i=c(t);return"bottomWithMargin"in i||(i.bottomWithMargin=this.getNormalizedBottomWithMargin(t,e,a)),i.bottomWithMargin},p=e=>{if(!e)return 0;const t=c(e);return"offsetHeight"in t||(t.offsetHeight=this._DOM.getElementOffsetHeight(e)),t.offsetHeight};this.setInitStyle(!0,e,a);let u=!1;const _=()=>(u||(u=!0,ti(this)&&console.groupEnd(`walking through ${i.length} children`),this.setInitStyle(!1,e,t),ti(this)&&console.groupEnd("getSplitPoints")),s);ti(this)&&console.group(`walking through ${i.length} children`,i);for(let t=0;th))if(ti(this)&&console.log("[getSplitPoints]",`next overtook the floater : (nextElementTop) ${b} > ${h}`,{currentElement:u},"does current overflow? let's check.",{isNextElementTopFinite:w}),(this.isSVG(u)||this.isIMG(u))&&ti(this)&&console.log("%cIMAGE","color:red;text-weight:bold"),S=d(u),S<=h){if(w){ti(this)&&console.log("[getSplitPoints]",`current fits: (currentElementBottom) ${S} <= ${h}, ๐ŸŽ register nextElement as Point.`,{currentElement:u,nextElement:m});if(l(m))return ti(this)&&console.log("%cNULL CASE, return","color:red;text-weight:bold"),_();continue}ti(this)&&console.log("[getSplitPoints] nextElementTop not finite and current fits tail window",{currentElementBottom:S,floater:h,nextElement:m})}else ti(this)&&console.log(`๐Ÿ”ช๐Ÿฅ’ try to split overflowing current: (currentElementBottom > ) ${S} > ${h}`,{currentElement:u}),M=!0;if(!m){ti(this)&&console.log("%c[getSplitPoints] !nextElement","color:red"),ti(this)&&console.log("%c[getSplitPoints] * Try to split it. ๐Ÿ”ช๐Ÿฅ’","color:blue"),S=S??d(u);let t=u;if(u.parentElement&&e.contains(u.parentElement)){let i=u.parentElement;for(;i&&e.contains(i)&&i!==e&&!this._DOM.getRightNeighbor(i);)t=i,i=i.parentElement}const i=t===u?S:d(t);if(i<=h){ti(this)&&console.log("%c ๐Ÿ• [getSplitPoints] !nextElement branch fits with container shell","color:violet",{currentElementBottom:S,containerBottom:i,floater:h,containerElement:t});continue}M=!0}if(!M)continue;let P=[];const C=this.getSplitChildren(u,n,o,e);if(C.length){if(P=ii.call(this,{rootNode:e,rootComputedStyle:a,children:C,firstPartHeight:n,fullPageHeight:o,firstChild:r,points:s}),0===P.length){const e=Math.max(n,o),t=p(u),i=t>e&&(!P.length||1===P.length&&null===P[0]);if(ti(this)&&console.log("room (Math.max)",e),i){if(ti(this)&&console.warn("%cโš ๏ธ UNSPLITTABLE OVERSIZED ELEMENT โ€” SCALE IT","color:white; background:red; font-weight:bold;",u,`height: ${t}`),!s.length&&u===r)return ti(this)&&console.warn("๐Ÿ…พ๏ธ (1) points.push(null) in isUnbreakableOversized"),s.push(null),_();if(m){if(l(m))return _()}}else if(l(u))return _()}}else{ti(this)&&console.log("๐ŸŽ currentElementChildren.length == 0");const e=p(u);if(e>c&&(!P.length||1===P.length&&null===P[0])){if(ti(this)&&console.warn("%cโš ๏ธ UNSPLITTABLE OVERSIZED ELEMENT โ€” SCALE IT","color:white; background:red; font-weight:bold;",u,`height: ${e}`),ti(this)&&console.warn("๐Ÿ…พ๏ธ (2) points.push(null) in isUnbreakableOversized"),!s.length&&u===r)return s.push(null),_();if(m){ti(this)&&console.warn("๐Ÿ…พ๏ธ๐Ÿ…พ๏ธ๐Ÿ…พ๏ธ๐Ÿ…พ๏ธ๐Ÿ…พ๏ธ๐Ÿ…พ๏ธ๐Ÿ…พ๏ธ๐Ÿ…พ๏ธ registerPoint(nextElement)");if(l(m))return _()}}else{if(l(u))return _()}}}return _()}function ni(e,t,i,n,o){ti(this)&&console.group("[โœ–๏ธ] getSplitPointsPerCells");const r=e.map(((e,r)=>{ti(this)&&console.group(`(โ€ข) Split CELL.${r} in:`,o);let s=[];const l=i-(t[r]||0),a=n-(t[r]||0);let h=this.getSplitChildren(e,l,a,o);if(h.length){const t=h[0];ti(this)&&console.log("firstChild",t),s=this.getSplitPoints({rootNode:e,children:h,firstPartHeight:l,fullPageHeight:a,firstChild:t})}else ti(this)&&console.log(`(โ€ข) empty cell #${r}`);return ti(this)&&console.log(`(โ€ข) return splitPoints for CELL#${r}`,s),ti(this)&&console.groupEnd(),s})),s=r.some(li);ti(this)&&console.log("๐Ÿงฝ๐Ÿงฝ๐Ÿงฝ๐Ÿงฝ๐Ÿงฝ๐Ÿงฝ๐Ÿงฝ isFirstPartEmptyInAnyCell",s);let l=r,a=!1;if(s){l=e.map(((e,r)=>{ti(this)&&console.group(`(โ€ขโ€ข) Split CELL.${r} in:`,o);const s=i-(t[r]||0),l=n-(t[r]||0),a=this.getSplitChildren(e,s,l,o),h=a[0];ti(this)&&console.log("firstChild",h);let c=[];return a.length&&(c=this.getSplitPoints({rootNode:e,children:a,firstPartHeight:l,fullPageHeight:l,firstChild:h})),ti(this)&&console.log(`(โ€ขโ€ข) return splitPoints for CELL#${r}`,c),ti(this)&&console.groupEnd(),c})),ti(this)&&console.log("[โ€ขโ€ข] splitPointsPerCell",l);for(let e=0;e0&&this.strictAssert(i.every((e=>null!==e)),"sliceNodeBySplitPoints: splitPoints contains null โ€” sanitize upstream before slicing"),this.strictAssert(i.every((e=>!e||e.nodeType===Node.ELEMENT_NODE&&(t===e||t.contains(e)))),"sliceNodeBySplitPoints: split point is not an Element within rootNode");for(let e=0;e<=i.length;e++){const o=i[e-1]??null,r=i[e]??null,s=this.cloneAndCleanOutsideRange(t,o,r);this.normalizeContentCuts({slice:s,top:null!==o,bottom:null!==r}),this._DOM.getChildNodes(s).length>0&&n.push(s)}return ti(this)&&console.log(n),ti(this)&&console.groupEnd(`๐Ÿ”ช (${e}) sliceNodeBySplitPoints`),n}function ri({slice:e,top:t=!1,bottom:i=!1}){if(e){if(t){const t=[...this.getFirstChildrenChain(e)];t.forEach((e=>this.markCleanTopCut(e))),ti(this)&&console.log("[normalizeContentCuts] topChain ๐Ÿ‘—",t)}if(i){const t=[...this.getLastChildrenChain(e)];t.forEach((e=>this.markCleanBottomCut(e))),ti(this)&&console.log("[normalizeContentCuts] bottomChain ๐Ÿ‘—",t)}}else ti(this)&&console.log("[normalizeContentCuts] no slice has been passed; return")}function si({index:e,rootNode:t,splitPoints:i}){ti(this)&&console.group(`๐Ÿ”ช (${e}) sliceNodeContentBySplitPoints`);const n=[];for(let e=0;e<=i.length;e++){const o=i[e-1]??null,r=i[e]??null,s=this.cloneAndCleanOutsideRange(t,o,r);ti(this)&&console.log({slice:s});const l=this.createNeutralBlock();for(;s.firstChild;)l.appendChild(s.firstChild);l.childNodes.length>0&&n.push(l)}return ti(this)&&console.log(n),ti(this)&&console.groupEnd(`๐Ÿ”ช (${e}) sliceNodeContentBySplitPoints`),n}function li(e){return!!Array.isArray(e)&&(e.length>0&&null===e[0])}function ai(e,t,i){t&&t.setAttribute("split","start"),i&&i.setAttribute("split","end");let n=e.cloneNode(!0);if(t){let t=n.querySelector('[split="start"]'),i=t.previousElementSibling;for(;i;){let e=i;i=i.previousElementSibling,e.remove()}let o=t.parentElement;for(;o&&o!==e;){let e=o.previousElementSibling;for(;e;){let t=e;e=e.previousElementSibling,t.remove()}o=o.parentElement}t.removeAttribute("split")}if(i){let t=n.querySelector('[split="end"]'),i=t.nextElementSibling;for(;i;){let e=i;i=i.nextElementSibling,e.remove()}let o=t.parentElement;for(;o&&o!==e;){let e=o.nextElementSibling;for(;e;){let t=e;e=e.nextElementSibling,t.remove()}o=o.parentElement}t.remove()}return t&&t.removeAttribute("split"),i&&i.removeAttribute("split"),n}const hi=N("flowfilters"),ci="__html2pdfFlowFilter",gi=[{test:e=>"none"===e.display,cache:{reason:"display:none",message:"* display:none โ€” skipped"}},{test:e=>"absolute"===e.position,cache:{reason:"position:absolute",message:"* position:absolute โ€” skipped"}},{test:e=>"fixed"===e.position,cache:{reason:"position:fixed",message:"* position:fixed โ€” skipped"}},{test:e=>"collapse"===e.visibility,cache:{reason:"visibility:collapse",message:"* visibility:collapse โ€” skipped"}}];function di(e,t,i,n,{cached:o}={cached:!1}){if(!hi(e))return;const r=t?`(${t}) `:"",s=o?" (cached)":"";console.info(`๐Ÿšธ ${r}${i.message}${s}`,[n])}function pi(e,{context:t="",computedStyle:i}={}){if(!(e&&this&&this._DOM&&this._DOM.isElementNode(e)))return!1;const n=e[ci];if(n)return di(this,t,n,e,{cached:!0}),!0;const o=i??this._DOM.getComputedStyle(e);if(!o)return!1;for(const i of gi)if(i.test(o))return e[ci]=i.cache,di(this,t,i.cache,e),!0;return!1}N("pagination");function ui({cells:e,splitPointsPerCell:t,sliceCell:i}){return t.map(((t,n)=>{const o=e[n];return i({cell:o,index:n,splitPoints:t})}))}function _i({originalRow:e,originalCells:t,slicedCellsPerOriginal:i,beginRow:n,cloneCellFallback:o,handleCell:r,finalizeRow:s}){const l=Math.max(...i.map((e=>e.length))),a=[];for(let h=0;h{const n=i[t][h]||o(e);r({context:l,cellClone:n,originalCell:e,cellIndex:t})})),a.push(s({context:l}))}return a}function fi({originalRow:e,originalCells:t,splitPointsPerCell:i,sliceCell:n,beginRow:o,cloneCellFallback:r,handleCell:s,finalizeRow:l}){if(!Array.isArray(i)||!i.length)return[];const a=this.sliceCellsBySplitPoints({cells:t,splitPointsPerCell:i,sliceCell:n});return this.buildRowSlices({originalRow:e,originalCells:t,slicedCellsPerOriginal:a,beginRow:o,cloneCellFallback:r,handleCell:s,finalizeRow:l})}function mi({usedRemainingWindow:e,isFirstPartEmpty:t,firstSliceTop:i,firstSliceBottom:n,pageBottom:o,epsilon:r=.5}){return{placeOnCurrentPage:e&&!t,remainingWindowSpace:Math.max(0,o-i),exceedsWindow:n>o+r}}function bi({currentRows:e,index:t,rowSlices:i}){return Array.isArray(e)?(e.splice(t,1,...i),e):[]}const wi=N("pagination");function Si({cells:e,targetHeight:t,shells:i}){return!!(Array.isArray(e)&&e.length&&t>0)&&this.scaleCellsToHeight(e,t,i)}function Mi({needsScalingInFullPage:e,cells:t}){return Boolean(e&&Array.isArray(t)&&t.length)}function Pi({needsScalingInFullPage:e,scaleCallback:t,payload:i}){if(!e)return!1;if("function"!=typeof t)return!1;const n=t(i||{});return!n&&this&&this._debug&&this._debug._&&wi(this)&&console.warn("[pagination.scaling] requested full-page scaling but callback reported no change",i),Boolean(n)}N("pagination");function Ci(e,t,i){e&&Array.isArray(e.rows)&&e.rows.splice(t,1,...i)}function yi({rows:e,DOM:t,cellTagFilter:i,guardCallback:n}){if(!Array.isArray(e))return{};let o=!1,r=!1,s=!1,l=null;e.forEach((e=>{const n=Array.isArray(e)?e:Array.from(t.getChildren(e)||[]);null==l&&(l=n.length),n.length!==l&&(s=!0),n.forEach((e=>{const n=t.getElementTagName(e);if(!i||i(n,e)){const t=parseInt(e.getAttribute?.("rowspan"));Number.isFinite(t)&&t>1&&(o=!0);const i=parseInt(e.getAttribute?.("colspan"));Number.isFinite(i)&&i>1&&(r=!0)}}))}));const a={hasRowspan:o,hasColspan:r,inconsistentCells:s};return n?.(a),a}N("pagination");function Oi(e){if(!e||"object"!=typeof e)throw new Error("splitter kernel adapter must be an object.");if(!e.rows||"object"!=typeof e.rows)throw new Error("splitter kernel adapter must expose a rows provider.");if("function"!=typeof e.rows.replaceRow)throw new Error("splitter kernel adapter rows.replaceRow must be a function.")}function Ti(e,{rowIndex:t,rowSlices:i}){Oi(e);const n=Number.isFinite(t)?t:0,o=Array.isArray(i)?i:[],r=e.rows;r.replaceRow({rowIndex:n,rowSlices:o}),r.syncEntries?.({rowIndex:n,rowSlices:o});const s=e.guards?.getConfig?.({rowIndex:n,rowSlices:o})??r.getGuardConfig?.({rowIndex:n,rowSlices:o})??null;let l=null;if(s){const t={rows:s.rows,DOM:s.DOM||this._DOM,cellTagFilter:s.cellTagFilter,guardCallback:s.guardCallback};Array.isArray(t.rows)&&t.DOM&&(l=this.computeRowFlags(t),e.guards?.onFlags?.({flags:l,rowIndex:n,rowSlices:o}))}return e.metrics?.refresh?.({rowIndex:n,rowSlices:o,flags:l}),r.onRowsChanged?.({rowIndex:n,rowSlices:o,flags:l}),{flags:l}}N("pagination");function Ei({cells:e}){return Array.isArray(e)&&e.length?e.map((e=>{if(!e)return 0;const t=this._DOM.getComputedStyle(e),i=(parseFloat(t?.paddingTop)||0)+(parseFloat(t?.paddingBottom)||0)+(parseFloat(t?.borderTopWidth)||0)+(parseFloat(t?.borderBottomWidth)||0);return Number.isFinite(i)?Math.max(0,i):0})):[]}const Di=N("pagination");function vi({ownerLabel:e,DOM:t,row:i,targetHeight:n,cachedShells:o,getRowShellHeightsCallback:r,scaleCellsToHeightCallback:s}){if(e||Di(this)&&console.warn("[scaleRowCellsToHeight] ๐Ÿ‘ค Owner wanted!",{owner:e}),!i)return Di(this)&&console.warn("[pagination.overflow] Missing row for scaling.",{owner:e}),!1;if("function"!=typeof s)return Di(this)&&console.warn("[pagination.overflow] scaleCellsToHeight callback is required.",{owner:e}),!1;const l=t,a=l&&"function"==typeof l.getChildren?l.getChildren(i):null;return s(a?[...a]:[],n,Array.isArray(o)?o:"function"==typeof r?r(i):[])}function Ri({ownerLabel:e,rowIndex:t,row:i,availableRowHeight:n,fullPageHeight:o,splitStartRowIndexes:r,reasonTail:s,reasonFull:l,registerPageStartCallback:a,scaleProblematicCellsCallback:h,debugLogger:c}){return e||Di(this)&&console.warn("[handleRowOverflow] ๐Ÿ‘ค Owner wanted!",{owner:e}),Array.isArray(r)?"function"!=typeof a?(Di(this)&&console.warn("[pagination.overflow] registerPageStart callback is required.",{owner:e}),t):n!1),isSlice:o=(()=>!1)}=t,{handleRowWithRowspan:r=(()=>e.rowIndex),handleSplittableRow:s=(()=>e.rowIndex),handleAlreadySlicedRow:l=(()=>e.rowIndex)}=i,{row:a}=e;return n(a,e)?r({evaluation:e}):o(a,e)?l({evaluation:e}):s({evaluation:e})}function Li({evaluation:e,splitStartRowIndexes:t,fullPageHeight:i,resolveOverflow:n,debug:o,afterResolve:r}){const{rowIndex:s,tailWindowHeight:l}=e;Hi(this)&&console.log("%c โš ๏ธ Row has ROWSPAN; use conservative fallback (no slicing)","color:DarkOrange; font-weight:bold");const a=n({rowIndex:s,evaluation:e,availableRowHeight:l,splitStartRowIndexes:t,fullPageHeight:i});return r?.({evaluation:e,tailWindowHeight:l,fullPageHeight:i,result:a}),a}function $i({evaluation:e,splitStartRowIndexes:t,resolveSplitFailure:i,fullPageHeight:n,debug:o}){const{rowIndex:r,row:s,tailWindowHeight:l,delta:a}=e;return Hi(this)&&console.log(`%c Row # ${r} is slice! but don't fit`,"color:DarkOrange; font-weight:bold",s),Hi(this)&&console.warn("%c SUPER BIG","background:red;color:white",a,{part:n}),i({evaluation:e,splitStartRowIndexes:t,availableRowHeight:l,fullPageHeight:n})}function Gi({tailWindowHeight:e,minMeaningfulRowSpace:t,fullPartHeight:i,debug:n}){return ethis.sliceNodeBySplitPoints({index:t,rootNode:e,splitPoints:i})),f=l.beginRow||(({originalRow:t,sliceIndex:i})=>{const n=this._DOM.cloneNodeWrapper(t);return r?.({rowWrapper:n,rowIndex:e,sliceIndex:i,originalRow:t}),{rowWrapper:n}}),m=l.cloneCellFallback||(e=>this._DOM.cloneNodeWrapper(e)),b=l.handleCell||(({context:e,cellClone:t})=>{this._DOM.insertAtEnd(e.rowWrapper,t)}),w=l.finalizeRow||(({context:e})=>e.rowWrapper),S=[];if(d.some((e=>Array.isArray(e)&&e.length))){const e=this.paginationBuildBalancedRowSlices({originalRow:t,originalCells:h,splitPointsPerCell:d,sliceCell:_,beginRow:f,cloneCellFallback:m,handleCell:b,finalizeRow:w});S.push(...e)}else Hi(this)&&console.log("๐Ÿ”ด There is no Split");return S.length&&this.markSliceCutsInRows(S),o&&o._&&console.log("%c newRows \n","color:magenta; font-weight:bold",S),{newRows:S,isFirstPartEmptyInAnyTD:p,needsScalingInFullPage:u}}function ji({row:e,rowIndex:t,decorateRowSlice:i}){const n=Array.isArray(e),o=this;return{getParentContainer:()=>n?null:e,getOriginalCells:()=>n?[...e]:[...o._DOM.getChildren(e)],getShellHeights:({cells:t})=>n?[]:o.getTableRowShellHeightByTD(e),markOriginalRow:({cells:t})=>{n||o.setFlagSlice(e)},beginRow:({originalRow:e,sliceIndex:r})=>{if(n)return{cells:[]};const s=o._DOM.cloneNodeWrapper(e);return i?.({rowWrapper:s,rowIndex:t,sliceIndex:r,originalRow:e}),{rowWrapper:s}},cloneCellFallback:e=>o._DOM.cloneNodeWrapper(e),handleCell:({context:e,cellClone:t})=>{n?(o.setFlagSlice(t),e.cells.push(t)):o._DOM.insertAtEnd(e.rowWrapper,t)},finalizeRow:({context:e})=>n?e.cells:e.rowWrapper}}function zi({evaluation:e,splitResult:t,splitStartRowIndexes:i,insufficientRemainingWindow:n,extraCapacity:o,fullPageHeight:r,debug:s,handlers:l={}}){const{newRows:a,isFirstPartEmptyInAnyTD:h,needsScalingInFullPage:c}=t||{},{rowIndex:g,row:d,isLastRow:p,tailWindowHeight:u}=e,{onReplaceRow:_,onAbsorbTail:f,onRefreshRows:m,onPlacement:b,onSplitFailure:w}=l;return Array.isArray(a)&&a.length?(_?.({evaluation:e,newRows:a}),p&&f?.({evaluation:e,newRows:a,extraCapacity:o}),m?.({evaluation:e,newRows:a,splitStartRowIndexes:i}),b?.({evaluation:e,newRows:a,insufficientRemainingWindow:n,isFirstPartEmptyInAnyTD:h,needsScalingInFullPage:c,splitStartRowIndexes:i})??e.rowIndex):(Hi(this)&&console.log(`%c The row is not split. (ROW.${g})`,"color:orange",d),w?.({evaluation:e,splitStartRowIndexes:i,availableRowHeight:u,fullPageHeight:r})??e.rowIndex)}function Vi({evaluation:e,splitStartRowIndexes:t,extraCapacity:i,fullPageHeight:n,minPartLines:o,debug:r,decorateRowSlice:s,onBudgetInfo:l,handlers:a={}}){if(!e||!e.row)return e?.rowIndex??0;const{row:h}=e,c=this.getTableRowHeight(h,o),g=this.paginationCalculateRowSplitBudget({tailWindowHeight:e.tailWindowHeight,minMeaningfulRowSpace:c,fullPartHeight:n,debug:r});l?.({evaluation:e,firstPartHeight:g.firstPartHeight,fullPartHeight:n});const d=a.getRowSliceAdapter,p=d?.({evaluation:e,row:h,rowIndex:e.rowIndex,decorateRowSlice:s}),u=this.paginationSplitRow({rowIndex:e.rowIndex,row:h,firstPartHeight:g.firstPartHeight,fullPageHeight:n,debug:r,decorateRowSlice:s,rowAdapter:p});return this.paginationProcessRowSplitResult({evaluation:e,splitResult:u,splitStartRowIndexes:t,insufficientRemainingWindow:g.insufficientRemainingWindow,extraCapacity:i,fullPageHeight:n,debug:r,handlers:a})}function Ui({evaluation:e,table:t,newRows:i,insufficientRemainingWindow:n,isFirstPartEmptyInAnyTD:o,needsScalingInFullPage:r,splitStartRowIndexes:s,pageBottom:l,fullPageHeight:a,debug:h,registerPageStartCallback:c,scaleProblematicSliceCallback:g,applyFullPageScalingCallback:d}){const{rowIndex:p}=e,u=Array.isArray(i)?i[0]:null;if(!u)return c?.({targetIndex:p,reason:"Row split produced empty first slice"}),p-1;const _=this.getTop(u,t),f=this.getBottom(u,t),m=this.evaluateRowSplitPlacement({usedRemainingWindow:!n,isFirstPartEmpty:o,firstSliceTop:_,firstSliceBottom:f,pageBottom:l,epsilon:0});return m.placeOnCurrentPage?(m.remainingWindowSpace>0&&g?.(u,m.remainingWindowSpace),c?.({targetIndex:p+1,reason:"Row split โ€” next slice starts new page"})):(d?.({row:u,needsScalingInFullPage:r,fullPageHeight:a}),c?.({targetIndex:p,reason:"Empty first part โ€” move row to next page"})),p-1}class qi{constructor({config:e,DOM:t,node:n,selector:o}){this._debug=e.debugMode?{...e.debugConfig.paragraph}:{},this._assert=!!e.consoleAssert,this._DOM=t,this._selector=o,this._node=n,this._minParagraphLeftLines=2,this._minParagraphDanglingLines=2,this._minParagraphBreakableLines=this._minParagraphLeftLines+this._minParagraphDanglingLines||2,Object.assign(this,i)}split(e){return this._splitComplexTextBlockIntoLines(e)}_estimateLineCount(e){return Math.ceil(this._DOM.getElementOffsetHeight(e)/this._node.getLineHeight(e))}_splitComplexTextBlockIntoLines(e){if(this._debug._&&console.group("_splitComplexTextBlockIntoLines",[e]),this._estimateLineCount(e){const t=this._node.getLineHeight(e),i=this._DOM.getElementOffsetHeight(e),n=this._DOM.getElementOffsetLeft(e),o=this._DOM.getElementOffsetTop(e);return{element:e,lines:Math.ceil(i/t),left:n,top:o,height:i,lineHeight:t,text:this._DOM.getInnerHTML(e)}}));this._debug._&&console.log("\n๐Ÿšธ nodeChildren",[...t],"\n๐Ÿšธ extendedChildrenArray",[...i]);const n=i.flatMap((e=>e.lines>1&&!this._node.isNoBreak(e.element)?this._breakItIntoLines(e.element):e.element));this._debug._&&console.log("\n๐Ÿšธ๐Ÿšธ๐Ÿšธ\n partiallyLinedChildren",[...n]);const o=n.reduce(((e,t,i,n)=>(e||(e=[]),"BR"===this._DOM.getElementTagName(t)?(e.at(-1).push(t),e.push([]),this._debug._&&console.log("br; push:",t),e):!e.length||this._node.isLineChanged(e.at(-1).at(-1),t)?(e.push([t]),this._debug._&&console.log("โ—ผ๏ธ start new line:",t),e):0===e.at(-1).length||e.length&&this._node.isLineKept(e.at(-1).at(-1),t)?(this._debug._&&console.log("โฌ† add to line:",t),e.at(-1).push(t),e):void this.strictAssert(!0,"groupedPartiallyLinedChildren: An unexpected case of splitting a complex paragraph into lines.","\nOn the element:",t))),[]);if(this._debug._&&console.log("๐ŸŸก๐ŸŸก๐ŸŸก groupedPartiallyLinedChildren \n",o.length,[...o]),o.length{let i;if(0==e.length)i=e[0],i.setAttribute("role","๐Ÿšซ"),this.strictAssert(0==e.length,"The string cannot be empty (_splitComplexTextBlockIntoLines)");else if(1==e.length)i=e[0];else{i=this._node.createTextGroup(),this._DOM.insertBefore(e[0],i),this._DOM.insertAtEnd(i,...e)}return i.dataset.child=t,i}));return this.logGroupEnd("OK _splitComplexTextBlockIntoLines"),this._DOM.setAttribute(e,this._selector.split),l}_breakItIntoLines(e){if(this._debug._&&console.group("_breakItIntoLines",[e]),this._node.isNoBreak(e))return this.logGroupEnd("isNoBreak"),e;if(this._node.isWrappedTextNode(e)){const t=this._breakWrappedTextNodeIntoLines(e);return this.logGroupEnd("TextNode newLines"),t}return this.logGroupEnd("(recursive _breakItIntoLines)"),this._processNestedInlineElements(e)}_processNestedInlineElements(e){this._debug._&&console.group("_processNestedInlineElements",[e]);const t=this._getNestedInlineChildren(e).flatMap((e=>this._estimateLineCount(e)>1?this._breakItIntoLines(e):e)),i=this._findNewLineStarts(t,e),n=i.map(((n,o)=>{const r=t[n],s=t[i[o+1]];return this._node.cloneAndCleanOutsideRange(e,r,s)}));return this._DOM.insertInsteadOf(e,...n),this.logGroupEnd("Nested Inline parts"),n}_getNestedInlineChildren(e){return[...this._DOM.getChildNodes(e)].reduce(((e,t)=>{if(this._node.isSignificantTextNode(t)){const i=this._node.createTextNodeWrapper();return this._DOM.wrap(t,i),e.push(i),e}if(!this._DOM.getElementOffsetParent(t)){const i=this._node.getPreparedChildren(t);return i.length>0&&e.push(...i),e}if(this._DOM.isElementNode(t)){return this._getNestedInlineChildren(t).forEach((t=>e.push(t))),e}}),[])}_makeWordsFromTextNode(e){const t=this._node.splitTextByWordsGreedy(e);this._debug._&&console.log("wordArray",t);const i=t.map(((e,t)=>this._node.createWord(e+"",t)));return this._debug._&&console.log("wrappedWordArray",i),{wordArray:t,wrappedWordArray:i}}_breakWrappedTextNodeIntoLines(e){e.classList.add("๐Ÿ” _breakItIntoLines"),e.classList.add("๐Ÿšซ_must_be_removed");const{wordArray:t,wrappedWordArray:i}=this._makeWordsFromTextNode(e);this._DOM.setInnerHTML(e,""),this._DOM.insertAtEnd(e,...i);const n=this._findNewLineStarts(i,e),o=n.reduce(((i,o,r)=>{const s=this._node.createTextLine(),l=n[r],a=n[r+1],h=t.slice(l,a).join("")+"";return this._DOM.setInnerHTML(s,h),this._DOM.insertBefore(e,s),i.push(s),i}),[]);return e.remove(),o}_findNewLineStarts(e,t){const i=t.style.lineHeight;t.style.lineHeight=2;const n=e.reduce(((t,i,n)=>{const o=n>0?e[n-1].offsetTop:void 0,r=n>0?e[n-1].offsetHeight:void 0,s=i.offsetTop;return n>0&&o+r<=s&&t.push(n),t}),[0]);return t.style.lineHeight=i,n}}function Ki(e){if(e)return"function"==typeof e.getDebug?e.getDebug():e.debug}function Yi(e,t,i="unknown case"){if(!e||"function"!=typeof e.getSplitBottom||"function"!=typeof e.setSplitBottom)throw new Error("updateSplitBottom: adapter must expose getSplitBottom() and setSplitBottom().");const n=e.getSplitBottom();let o;if("number"==typeof t)o=t;else{if(!(t instanceof HTMLElement))throw new Error("updateSplitBottom: unexpected value type: "+typeof t);if("function"!=typeof e.computeSplitBottomForElement)throw new Error("updateSplitBottom: adapter must implement computeSplitBottomForElement(element).");o=e.computeSplitBottomForElement(t)}e.setSplitBottom(o);const r=function(e){return e?"function"==typeof e.getSplitBottomLog?e.getSplitBottomLog():e.splitBottomLog||null:null}(e);Array.isArray(r)&&r.push(o);const s=Ki(e);s&&s._&&console.log(`%cโ™ป๏ธ [${function(e){return e?.label||"๐Ÿ‘ค [paginator.label] element"}(e)}] update splitBottom (with ${t}) \n โ€ข ${i}`,"color: green; font-weight: bold","\n",n||"โ€ขโ€ขโ€ข","->",o,r?`\n log: ${r}`:"")}function Zi(e,t,i,n="register page start"){const o=function(e){return e?"function"==typeof e.getRows?e.getRows()||[]:e.rows||[]:[]}(e),r=o.length,s=function(e){return!!e&&("function"==typeof e.shouldAssert?e.shouldAssert():Boolean(e.assert))}(e),l=Ki(e),a=Number.isInteger(t);if(s&&console.assert(a,`registerPageStartAt: index must be an integer, got: ${t}`),!a)return;if(s&&console.assert(r>0,"registerPageStartAt: no rows to register"),0===r)return;if(0===t)return l&&l._&&console.log("%c ๐Ÿ“ Row #0 forced to next page (no short first fragment)","color:green; font-weight:bold"),void((o[0]instanceof HTMLElement||"number"==typeof o[0])&&Yi(e,o[0],`${n} (index=0)`));let h=Math.max(1,Math.min(t,r-1));const c=i.at(-1);if(null!=c&&h<=c&&(h=c+1),h>=r)return void(l&&l._&&console.warn(`registerPageStartAt return: computed index (${h}) >= rowsLen (${r})`,"Last split index should not equal rows.length, or the original table will be empty."));i.push(h),l&&l._&&console.log(`%c ๐Ÿ“ Row # ${h} registered as page start`,"color:green; font-weight:bold");const g=o[h];(g instanceof HTMLElement||"number"==typeof g)&&Yi(e,g,n)}function Ji(e){return e._node.createSignpost("(table continued)",e._signpostHeight)}function Xi({owner:e=null,currentRows:t=[]}={}){return{owner:e,currentRows:Array.isArray(t)?t:[],parts:[]}}function Qi({entries:e,part:t,startIndex:i=null,endIndex:n=null,type:o="unknown",rows:r=[],meta:s}){if(!e||!t)return null;const l=function(e){if(e)return Array.isArray(e.parts)||(e.parts=[]),e.parts}(e);if(!l)return null;const a={part:t,type:o,startIndex:i,endIndex:n,rows:Array.isArray(r)?[...r]:[]};return s&&"object"==typeof s&&Object.keys(s).length&&(a.meta={...s}),l.push(a),a}class en{constructor({config:e,DOM:t,node:n,selector:o}){this._debug=e.debugMode?{...e.debugConfig.table}:{},this._assert=!!e.consoleAssert,this._DOM=t,this._selector=o,this._node=n,this._splitLabelHeightFromConfig=e.splitLabelHeight,this._initConstants(),Object.assign(this,i),this._resetCurrent()}split(e,t,i,n){this._setCurrent(e,t,i,n);const o=this._splitCurrentTable();return this._resetCurrent(),o}_initConstants(){this._signpostHeight=parseFloat(this._splitLabelHeightFromConfig)||0,this._minPartLines=2}_resetCurrent(){this._currentTable=void 0,this._currentFirstPageBottom=void 0,this._currentFullPageHeight=void 0,this._currentRoot=void 0,this._currentTableEntries=void 0,this._currentTableRecordedParts=void 0,this._currentTableDistributedRows=void 0,this._currentTableFirstPartContentBottom=void 0,this._currentTableFullPartContentHeight=void 0,this._currentTableTfootHeight=void 0,this._currentTableSplitBottom=void 0,this._logSplitBottom_=[],this._currentRowShellCache=void 0,this._currentOverflowHelpers=void 0,this._currentTableHasRowspan=void 0,this._currentTableHasColspan=void 0,this._currentTableInconsistentCells=void 0,this._currentTableHasUnexpectedChildren=void 0}_setCurrent(e,t,i,n){this._currentTable=e,this._currentFirstPageBottom=t,this._currentFullPageHeight=i,this._currentRoot=n,this._currentRowShellCache=new WeakMap,this._currentOverflowHelpers=this._composeOverflowHelpers()}_prepareCurrentTableForSplitting(){this._lockCurrentTableWidths(),this._collectCurrentTableEntries(),this._updateCurrentTableDistributedRows(),this._currentTableRecordedParts=Xi({owner:this._currentTable,currentRows:this._currentTableDistributedRows}),this._currentTableEntries&&(this._currentTableEntries.recordedParts=this._currentTableRecordedParts),this._currentTable.__html2pdfRecordedParts=this._currentTableRecordedParts,this._analyzeCurrentTableStructure(),this._collectCurrentTableMetrics()}_lockCurrentTableWidths(){this._node.lockTableWidths(this._currentTable)}_splitCurrentTable(){this._prepareCurrentTableForSplitting(),this._setCurrentTableFirstSplitBottom(),this._debug._&&console.group("%c๐Ÿ“Š _splitCurrentTable()","color:green; background:#eee; padding:3px","\nโ€ข",this._currentTableFirstPartContentBottom,"(1st bottom)","\nโ€ข",this._currentTableFullPartContentHeight,"(full part height)",{table:this._currentTable,rows:[...this._currentTableDistributedRows],rowCount:this._currentTableDistributedRows.length,entries:this._currentTableEntries,root:this._currentRoot});const e=this._resolveCurrentTableDistributedRowsInPlace();if(this._debug._&&console.log("๐Ÿ“Š updated table rows",{rows_new:[...this._currentTableDistributedRows],rowCount_new:this._currentTableDistributedRows.length,splitStartRowIndexes:e}),!e.length)return this.logGroupEnd("[_splitCurrentTable]: there are no splits (!splitStartRowIndexes.length)"),[];let t=this._createTableSlices({splitPoints:e,table:this._currentTable,tableEntries:this._currentTableEntries});return this._node.markSliceCuts([this._currentTable,...t]),this._signpostHeight&&(t=this._extendTableSlices(t)),this._DOM.insertAfter(this._currentTable,...t),this._debug._&&console.log("tableSlices",t),this._debug._&&console.log("[table.split] recordedParts",this._currentTableRecordedParts?.parts),this.logGroupEnd("[_splitCurrentTable]"),[this._currentTable,...t]}_resolveCurrentTableDistributedRowsInPlace(){let e=[];for(let t=0;tNumber.isInteger(e)&&e>0&&e<=this._currentTableDistributedRows.length)),"splitStartRowIndexes contains invalid indexes"),this.strictAssert(e.every(((e,t,i)=>0===t||e>i[t-1])),"splitStartRowIndexes must be strictly ascending and without duplicates"),this.strictAssert(e.at(-1)!==this._currentTableDistributedRows.length,"Last split index should not equal rows.length, or the original table will be empty."),e}_evaluateAndResolveRow(e,t){const i=e,n=this._currentTableDistributedRows.length;this._debug._&&console.groupCollapsed(`๐Ÿ”ฒ %c Check the Row # ${i} (from ${n})`,"");const o=this._node.paginationBuildRowEvaluationContext({rows:this._currentTableDistributedRows,rowIndex:e,table:this._currentTable,splitBottom:this._currentTableSplitBottom});if(!o?.row)return console.warn("[table.split] Missing row during evaluation.",{rowIndex:e}),this.logGroupEnd(`Row # ${i} (from ${n}) is checked`),e;if(this._debug._){const e=o.fitsCurrentWindow,t=e?"green":"orange",i=e?"<=":">";console.log(`%c๐Ÿ“ does row fit? %c ${e} %c :: ${o.nextMarker} ${i} ${this._currentTableSplitBottom} %c(ฮ”=${o.delta})`,"",`font-weight:bold;color:${t};`,"",`color:${t};`)}if(this._debug._&&console.info({row:o.row,rows:[...this._currentTableDistributedRows]}),o.fitsCurrentWindow)return this._debug._&&console.log(`%c โœ“ Row # ${e}: PASS`,"color:green"),this.logGroupEnd(`Row # ${i} (from ${n}) is checked`),e;const r=this._node.calculateFinalPartReclaimedHeight({signpostHeight:this._signpostHeight,tfootHeight:this._currentTableTfootHeight});if(this._node.paginationCanAbsorbLastRow({evaluation:o,extraCapacity:r,splitBottom:this._currentTableSplitBottom,debug:this._debug}))return this._debug._&&console.log("๐ŸซŸ last-row-fits-without-bottom-signpost: skip split"),this.logGroupEnd(`Row # ${i} (from ${n}) is checked`),e;const s=this._resolveOverflowingRow({evaluation:o,splitStartRowIndexes:t,extraCapacity:r});return this.logGroupEnd(`Row # ${i} (from ${n}) is checked`),s}_resolveOverflowingRow({evaluation:e,splitStartRowIndexes:t,extraCapacity:i}){return this._node.paginationResolveOverflowingRow({evaluation:e,utils:{rowHasSpan:e=>this._rowHasSpan(e),isSlice:e=>this._node.isSlice(e)},handlers:{handleRowWithRowspan:()=>this._node.paginationResolveRowWithRowspan({evaluation:e,splitStartRowIndexes:t,fullPageHeight:this._currentTableFullPartContentHeight,resolveOverflow:({evaluation:e,splitStartRowIndexes:t,availableRowHeight:i,fullPageHeight:n})=>this._forwardOverflowFallback({rowIndex:e.rowIndex,row:e.row,availableRowHeight:i,fullPageHeight:n,splitStartRowIndexes:t,reasonTail:"Row with ROWSPAN โ€” move to next page",reasonFull:"Row with ROWSPAN โ€” scaled TDs to full page",branch:"rowspan"}),debug:this._debug,afterResolve:({tailWindowHeight:e,fullPageHeight:t})=>{this._debug._&&e>=t&&console.warn("[table.fallback] ROWSPAN row required full-page scaling to fit.")}}),handleSplittableRow:()=>this._resolveSplittableRow({evaluation:e,splitStartRowIndexes:t,extraCapacity:i}),handleAlreadySlicedRow:()=>this._node.paginationResolveAlreadySlicedRow({evaluation:e,splitStartRowIndexes:t,fullPageHeight:this._currentTableFullPartContentHeight,debug:this._debug,resolveSplitFailure:({evaluation:e,splitStartRowIndexes:t,availableRowHeight:i,fullPageHeight:n})=>this._forwardOverflowFallback({rowIndex:e.rowIndex,row:e.row,availableRowHeight:i,fullPageHeight:n,splitStartRowIndexes:t,reasonTail:"Slice doesn't fit tail โ€” move to next page",reasonFull:"Scaled TD content to fit full page",branch:"alreadySliced"})})}})}_resolveSplittableRow({evaluation:e,splitStartRowIndexes:t,extraCapacity:i}){const{rowIndex:n}=e;this._debug._&&console.group(`%c ๐Ÿ”ณ Try to split the ROW ${n} %c (from ${this._currentTableDistributedRows.length})`,"color:magenta;","");const o=this._node.paginationResolveSplittableRow({evaluation:e,splitStartRowIndexes:t,extraCapacity:i,fullPageHeight:this._currentTableFullPartContentHeight,minPartLines:this._minPartLines,debug:this._debug,decorateRowSlice:({rowWrapper:e,rowIndex:t,sliceIndex:i})=>{this._DOM.setAttribute(e,`.splitted_row_${t}_part_${i}`)},onBudgetInfo:({evaluation:e,firstPartHeight:t,fullPartHeight:i})=>{this._debug._&&console.info({currRowTop:e.rowTop,"โ€ข splitBottom":this._currentTableSplitBottom,"โ€ข is row sliced?":!1,"remaining page space":e.tailWindowHeight,"first part height":t,"full part height":i})},handlers:{onReplaceRow:({evaluation:e,newRows:t})=>{this._replaceRowInDOM(e.row,t)},onAbsorbTail:({newRows:e,extraCapacity:t})=>{this._node.absorbShortTrailingSliceIfFits({slices:e,extraCapacity:t,ownerLabel:"table",debug:this._debug})},onRefreshRows:({evaluation:e,newRows:t})=>{this._node.paginationRefreshRowsAfterSplit(this._getSplitterAdapter(),{rowIndex:e.rowIndex,rowSlices:t})},onPlacement:({evaluation:e,newRows:i,insufficientRemainingWindow:n,isFirstPartEmptyInAnyTD:o,needsScalingInFullPage:r})=>this._node.paginationHandleRowSlicesPlacement({evaluation:e,table:this._currentTable,newRows:i,insufficientRemainingWindow:n,isFirstPartEmptyInAnyTD:o,needsScalingInFullPage:r,splitStartRowIndexes:t,pageBottom:this._currentTableSplitBottom,fullPageHeight:this._currentTableFullPartContentHeight,debug:this._debug,registerPageStartCallback:({targetIndex:e,reason:i})=>this._registerPageStartAt(e,t,i),scaleProblematicSliceCallback:(e,t)=>{t>0&&(this._debug._&&console.log("โš–๏ธ scaleProblematicCellsToHeight"),this._scaleProblematicCellsToHeight(e,t,this._getRowShellHeights(e)))},applyFullPageScalingCallback:({row:e,needsScalingInFullPage:t,fullPageHeight:i})=>{this._node.paginationApplyFullPageScaling({needsScalingInFullPage:t&&Boolean(e),payload:{row:e,targetHeight:i},scaleCallback:({row:e,targetHeight:t})=>(this._debug._&&console.log("โš–๏ธ scaleProblematicCellsToHeight"),this._scaleProblematicCellsToHeight(e,t,this._getRowShellHeights(e)))})}}),onSplitFailure:({evaluation:e,splitStartRowIndexes:t,availableRowHeight:i,fullPageHeight:n})=>this._forwardOverflowFallback({rowIndex:e.rowIndex,row:e.row,availableRowHeight:i,fullPageHeight:n,splitStartRowIndexes:t,reasonTail:"Split failed โ€” move row to next page",reasonFull:"Scaled TDs to fit full-page",branch:"splitFailure"})}});return this.logGroupEnd(`๐Ÿ”ณ Try to split the ROW ${n} (from ${this._currentTableDistributedRows.length})`),o}_collectCurrentTableEntries(){this._currentTableEntries=this._node.getTableEntries(this._currentTable)}_rowHasSpan(e){const t=[...this._DOM.getChildren(e)];for(const e of t){const t=this._DOM.getElementTagName(e);if("TD"!==t&&"TH"!==t)continue;const i=parseInt(e.getAttribute("rowspan"));if(Number.isFinite(i)&&i>1)return!0}return!1}_collectCurrentTableMetrics(){const e=this._node.getEmptyNodeHeightByProbe(this._currentTable,'',!1),t=this._node.getTopForPageStartCandidate(this._currentTable,this._currentRoot),i=(this._node.getTopWithMargin(this._currentTable,this._currentRoot),this._DOM.getElementOffsetHeight(this._currentTableEntries.caption)||0),n=this._DOM.getElementOffsetTop(this._currentTableDistributedRows[0],this._currentTable)-i||0;this._currentTableTfootHeight=this._DOM.getElementOffsetHeight(this._currentTableEntries.tfoot)||0,this._currentTableFirstPartContentBottom=this._currentFirstPageBottom-t-e-this._signpostHeight,this._currentTableFullPartContentHeight=this._currentFullPageHeight-i-n-this._currentTableTfootHeight-e-2*this._signpostHeight}_getDistributedRows(e){return[...e.rows,...e.tfoot?[e.tfoot]:[]]}_updateCurrentTableDistributedRows(){this._currentTableDistributedRows=this._getDistributedRows(this._currentTableEntries)}_analyzeCurrentTableStructure(){this._currentTableEntries;const e=this._currentTableDistributedRows||[],t=this._node.computeRowFlags({rows:e,DOM:this._DOM,cellTagFilter:(e,t)=>"TFOOT"!==this._DOM.getElementTagName(t.parentNode)&&("TD"===e||"TH"===e)});this._currentTableHasRowspan=t.hasRowspan,this._currentTableHasColspan=t.hasColspan,this._currentTableInconsistentCells=t.inconsistentCells,this._debug._&&(t.hasRowspan&&console.warn("[table.guard] ROWSPAN detected โ€” slicing not implemented; applying conservative fallback.",{table:this._currentTable}),t.hasColspan&&console.warn("[table.guard] COLSPAN present โ€” handled within-row slicing; monitor results.",{table:this._currentTable}),t.inconsistentCells&&console.warn("[table.guard] Inconsistent cell counts across rows โ€” results may vary.",{table:this._currentTable}))}_updateCurrentTableEntriesAfterSplit(e,t){this._currentTableEntries.rows.splice(e,1,...t)}_setCurrentTableFirstSplitBottom(){this._node.getTop(this._currentTableDistributedRows[0],this._currentTable)>this._currentTableSplitBottom?(this._updateCurrentTableSplitBottom(this._currentTableFullPartContentHeight,"SPECIAL CASE: start immediately from the full height of the page"),this._debug._&&console.log("The Row 0 goes to the 2nd page")):this._updateCurrentTableSplitBottom(this._currentTableFirstPartContentBottom,"start with a short first part")}_getPaginatorAdapter(){return{label:"table",getSplitBottom:()=>this._currentTableSplitBottom,setSplitBottom:e=>{this._currentTableSplitBottom=e},computeSplitBottomForElement:e=>this._node.getTop(e,this._currentTable)+this._currentTableFullPartContentHeight,getRows:()=>this._currentTableDistributedRows,shouldAssert:()=>this._assert,getDebug:()=>this._debug,getSplitBottomLog:()=>this._logSplitBottom_}}_getSplitterAdapter(){const e=()=>({rows:this._currentTableDistributedRows||[],DOM:this._DOM,cellTagFilter:(e,t)=>{const i=t?.parentNode;return"TFOOT"!==(i?this._DOM.getElementTagName(i):void 0)&&("TD"===e||"TH"===e)}});return{label:"table",rows:{getCurrentRows:()=>this._currentTableDistributedRows||[],replaceRow:({rowIndex:e,rowSlices:t})=>{this._node.applyRowSlicesToEntriesAfterRowSplit(this._currentTableEntries,e,t)},syncEntries:()=>{this._updateCurrentTableDistributedRows(),this._currentTableRecordedParts&&(this._currentTableRecordedParts.currentRows=this._currentTableDistributedRows)},getGuardConfig:e,onRowsChanged:()=>{this._currentTableRecordedParts&&(this._currentTableRecordedParts.currentRows=this._currentTableDistributedRows)}},guards:{getConfig:e,onFlags:({flags:e})=>{e&&(this._currentTableHasRowspan=Boolean(e.hasRowspan),this._currentTableHasColspan=Boolean(e.hasColspan),this._currentTableInconsistentCells=Boolean(e.inconsistentCells))}}}}_updateCurrentTableSplitBottom(e,t="unknown case"){Yi(this._getPaginatorAdapter(),e,t)}_registerPageStartAt(e,t,i="register page start"){Zi(this._getPaginatorAdapter(),e,t,i)}_composeOverflowHelpers(){const e=this._node.scaleCellsToHeight.bind(this._node),t=this._getRowShellHeights.bind(this),i={ownerLabel:"table",registerPageStartCallback:this._registerPageStartAt.bind(this),debugLogger:this._debug&&this._debug._?(e,t)=>console.log(e,t):void 0,scaleProblematicCellsCallback:(i,n,o)=>this._node.scaleRowCellsToHeight({ownerLabel:"table",DOM:this._DOM,row:i,targetHeight:n,cachedShells:o,getRowShellHeightsCallback:t,scaleCellsToHeightCallback:e})};return this._currentOverflowHelpers=i,i}_scaleProblematicCellsToHeight(e,t,i){return(this._currentOverflowHelpers||this._composeOverflowHelpers()).scaleProblematicCellsCallback(e,t,i)}_forwardOverflowFallback({rowIndex:e,row:t,availableRowHeight:i,fullPageHeight:n,splitStartRowIndexes:o,reasonTail:r,reasonFull:s,branch:l}){const a=this._currentOverflowHelpers||this._composeOverflowHelpers(),h={ownerLabel:`table:${l}`,rowIndex:e,row:t,availableRowHeight:i,fullPageHeight:n,splitStartRowIndexes:o,reasonTail:r,reasonFull:s,registerPageStartCallback:a.registerPageStartCallback,scaleProblematicCellsCallback:a.scaleProblematicCellsCallback,debugLogger:a.debugLogger};return this._debug._&&console.log(`%c[table.overflow] branch=${l} rowIndex=${e} tail=${i} full=${n}`,"color:orange; font-weight:bold",{reasonTail:r,reasonFull:s}),"splitFailure"===l?this._node.handleRowSplitFailure(h):this._node.handleRowOverflow(h)}_getRowShellHeights(e){if(!this._currentRowShellCache)return this._node.getTableRowShellHeightByTD(e);if(this._currentRowShellCache.has(e))return this._currentRowShellCache.get(e);const t=this._node.getTableRowShellHeightByTD(e);return this._currentRowShellCache.set(e,t),t}_createTableSlice({startId:e,endId:t,table:i,tableEntries:n}){this._debug._&&console.group(`[CREATE Table Slice] range: [${e}, ${t})`),this.strictAssert(Number.isInteger(e)&&(Number.isInteger(t)||t===1/0),`[createTableSlice] invalid bounds: startId=${e}, endId=${t}`);const o=n&&n.rows?n.rows.length:0;this.strictAssert(o>=0,`createTableSlice: invalid rows length: ${o}`),this.strictAssert(e>0&&t>0&&ethis._createTableSlice({startId:e,endId:n===o.length-1?1/0:o[n+1],table:t,tableEntries:i})))}_extendTableSlices(e){return e.reduce(((e,t,i,n)=>{const o=0===i,r=i===n.length-1;return o&&e.push(this._createBottomSignpost()),e.push(this._node.createForcedPageBreak()),e.push(this._createTopSignpost()),e.push(t),!r&&e.push(this._createBottomSignpost()),e}),[])}_createTopSignpost(){return this._node.createSignpost("(table continued)",this._signpostHeight)}_createBottomSignpost(){return this._node.createSignpost("(table continues on the next page)",this._signpostHeight)}_replaceRowInDOM(e,t){this._debug._&&this._DOM.setAttribute(e,".๐Ÿšซ_must_be_removed"),this._DOM.insertInsteadOf(e,...t)}_createAndInsertTableSlice({startId:e,endId:t,table:i,tableEntries:n}){const o=this._normalizeSliceAdapterPayload(function(e,{startId:t,endId:i,table:n,tableEntries:o}){e.strictAssert(Number.isInteger(t)&&Number.isInteger(i),`createAndInsertTableSlice: non-integer bounds: startId=${t}, endId=${i}`);const r=o&&o.rows?o.rows.length:0;e.strictAssert(r>=0,`createAndInsertTableSlice: invalid rows length: ${r}`),e.strictAssert(t>=0&&i>=0&&t({rowIndex:e+i,row:t,cells:Array.from(this._DOM.getChildren(t)||[])}))):[];if(r.length){const i={...o.meta||{},signpostTop:o.signposts?.top??null,signpostBottom:o.signposts?.bottom??null};this._recordTablePart(o.mainPart,{startId:e,endId:t,type:"slice",rows:s,meta:i})}return r}_createAndInsertTableFinalSlice({table:e,startId:t=0}){const i=Array.isArray(this._currentTableDistributedRows)?this._currentTableDistributedRows.length:0,n=this._normalizeSliceAdapterPayload(function(e,{table:t}){e._node.markTopCut(t),e._node.setFlagNoBreak(t);const i=[],n=e._node.createForcedPageBreak();i.push(n);const o=Ji(e);return o&&(e._node.setFlagNoBreak(o),i.push(o)),e._DOM.insertBefore(t,...i),i.push(t),{nodes:i,mainPart:t,signposts:{top:o,bottom:null}}}(this,{table:e}),{startId:t,endId:i,type:"final"}),o=n.mainPart,r=Array.isArray(this._currentTableDistributedRows)?this._currentTableDistributedRows.slice(t).map(((e,i)=>({rowIndex:t+i,row:e,cells:Array.from(this._DOM.getChildren(e)||[])}))):[],s={...n.meta||{},signpostTop:n.signposts?.top??null,signpostBottom:n.signposts?.bottom??null};return this._recordTablePart(o,{startId:t,endId:i,type:"final",rows:r,meta:s}),n.nodes}_normalizeSliceAdapterPayload(e,{startId:t=null,endId:i=null,type:n="slice"}={}){const o=`[table.slice:${n}] rows [${t??"null"}:${i??"null"}]`;this.strictAssert(e,`${o} builder returned no result`);const r=e=>e&&"object"==typeof e&&1===e.nodeType;let s=null;Array.isArray(e)?s={nodes:e}:r(e)?s={nodes:[e],mainPart:e}:"object"==typeof e?s=e:this.strictAssert(!1,`${o} unsupported builder payload: ${e}`);let l=Array.isArray(s.nodes)?[...s.nodes]:[];!l.length&&r(s.mainPart)&&(l=[s.mainPart]),this.strictAssert(l.length>0,`${o} builder produced empty nodes array`);const a=[];l.forEach(((e,t)=>{e?a.push(e):console.warn(`${o} dropped empty node at index ${t}`)})),this.strictAssert(a.length>0,`${o} builder produced only empty nodes`);const h=s.mainPart??a[0];return this.strictAssert(r(h),`${o} missing main part element`),{nodes:a,mainPart:h,signposts:{top:s.signposts?.top??null,bottom:s.signposts?.bottom??null},meta:s.meta}}_recordTablePart(e,t={}){const i=this._currentTableRecordedParts;if(!i||!e)return null;const{startId:n=null,endId:o=null,type:r="unknown",rows:s=[],meta:l}=t||{};return Qi({entries:i,part:e,startIndex:n,endIndex:o,type:r,rows:s,meta:l})}}class tn{constructor({config:e,DOM:t,node:i,selector:n}){this._debug=e.debugMode?{...e.debugConfig.tableLike}:{},this._DOM=t,this._selector=n,this._node=i,this._minLeftLines=2,this._minDanglingLines=2,this._minBreakableLines=this._minLeftLines+this._minDanglingLines,this._minLeftRows=1,this._minDanglingRows=1,this._minBreakableRows=1,this._minPreFirstBlockLines=3,this._minPreLastBlockLines=3,this._minPreBreakableLines=this._minPreFirstBlockLines+this._minPreLastBlockLines,this._minBreakableGridRows=4,this._imageReductionRatio=.8,this._signpostHeight=parseFloat(e.splitLabelHeight)||0}split(e,t,i,n,o){const r=o||this._DOM.getComputedStyle(e);this._debug._&&console.log("root",n);const s=this._node.getPreparedChildren(e),l=this._node.getTop(e,n),a=this._node.getEmptyNodeHeightByProbe(e),h=i-a;let c=s,g=0,d=[],p=t-l-a;const u=r.position;"relative"!=u&&this._DOM.setStyles(e,{position:"relative"});for(let t=0;tp&&(t&&d.push(t),t&&(g+=1),p=t?this._node.getTop(i,e)+h:h)}if(this._DOM.setStyles(e,{position:u}),!d.length)return this._debug._&&console.log("splitters.length",d.length),[];d.push(null);const _=d.map(((t,i,n)=>{const o=this._node.createSliceWrapper(e),r=n[i-1]||0,s=t||n[n.length];return this._DOM.insertAtEnd(o,...c.slice(r,s)),o}));return this._node.markSliceCuts(_),this._DOM.replaceNodeContentsWith(e,..._),this._DOM.removeAllClasses(e),this._DOM.removeAllStyles(e),this._DOM.setStyles(e,{display:"contents"}),this._DOM.setAttribute(e,"[slough-node]",""),_}}class nn{constructor({config:e,DOM:t,node:n,selector:o}){this._debug=e.debugMode?{...e.debugConfig.grid}:{},this._assert=!!e.consoleAssert,Object.assign(this,i),this._DOM=t,this._selector=o,this._node=n,this._resetCurrent(),this._minBreakableGridRows=1,this._minGridRowContentLines=2,this._gridCellLineHeightCache=new WeakMap,this._gridComputedStyleCache=new WeakMap,this._signpostHeight=parseFloat(e.splitLabelHeight)||0}split(e,t,i,n,o){this._resetCurrent(),this._debug._&&console.group("%c split Grid Node","background:#00FFFF",e);const r=this._node.getPreparedChildren(e);this._node.lockNodesWidths(r);const s=o||this._getComputedStyleCached(e);if(!r.length)return this._node.setInitStyle(!1,e,s),this._debug._&&console.groupEnd(),[];this._node.setInitStyle(!0,e,s);const l=this._scanGridLayout(e,s);if(!l.safe)return this._debug._&&console.warn("[grid.split] skip unsafe layout",l),this._debug._&&console.warn("[grid.split] Unsupported grid layout detected; keeping original grid intact.",l),this._node.setInitStyle(!1,e,s),this._debug._&&console.groupEnd(),[];const a=[];let h=!1,c=!1;const g=new Set;let d=null,p=null,u=null;r.forEach((t=>{const i=this._getComputedStyleCached(t),n=parseInt(i.gridRowStart,10),o=Number.isFinite(n),r=this._node.getTop(t,e),s=this._node.getBottom(t,e);let l=!1;l=!a.length||(o&&null!=d?n!==d:null!=u?r>=u-.5:null==p||Math.abs(r-p)>.5),l?(a.push([t]),d=o?n:null,p=r,u=s):(a[a.length-1].push(t),o&&null==d&&(d=n),(null==p||ru)&&(u=s));const _=i.gridRowEnd||"",f=i.gridColumnEnd||"";h=h||_.includes("span"),c=c||f.includes("span"),o&&g.add(n)}));const _=g.size>0&&Math.max(...g)>a.length;if(_)return this._debug._&&console.warn("[grid.split]","Unsupported implicit row gap detected; keeping grid unsplit.",{hasImplicitRowGaps:_}),this._node.setInitStyle(!1,e,s),this._debug._&&console.groupEnd(),[];if(h||c)return this._debug._&&console.warn("[grid.split]","Grid contains row/column spans; using fallback (move row to next page).",{hasRowSpan:h,hasColumnSpan:c}),this._debug._&&console.groupEnd(),this._fallbackMoveGridToNextPage({gridNode:e,nodeComputedStyle:s});this.log("grid.split","currentRows:",a);const f=this._node.getTop(e,n),m=this._node.getEmptyNodeHeightByProbe(e),b=t-f-m,w=i-m;if(this.log("grid.split",{firstPartHeight:b,fullPagePartHeight:w}),this._currentGridNode=e,this._currentGridRows=a,this._currentGridFullPartHeight=w,this._currentGridSplitLog=[],this._currentGridEntries=Xi({owner:e,currentRows:a}),this._currentGridRecordedParts=this._currentGridEntries,this._currentGridNode.__html2pdfRecordedParts=this._currentGridRecordedParts,this._currentGridShellCache=new WeakMap,a.length0?Math.floor(t):1;let o=0;return()=>{if(o+=1,o<=n)return;const t={label:e,iterations:o,limit:n};throw i&&console.assert(!1,`\n\n โ›” [${e}] โ™พ๏ธ loop guard triggered`,t),new Error(`\n โ›” [${e}] โ™พ๏ธ loop guard triggered`)}}({label:"grid.split",limit:Math.max(1,6*(a.length||1)),assert:this._assert});this._updateCurrentGridSplitBottom(b,"start with initial window");for(let t=0;tthis._buildGridSplit({startId:n[i-1]||0,endId:t,node:e,entries:M}))).filter(Boolean).map((e=>e.part)),this._createAndInsertGridFinalSlice({node:e,entries:M,startId:C})];return this.log("grid.split",{splitStartRowIndexes:S,splits:y,recordedParts:this._currentGridRecordedParts?.parts}),this._node.setInitStyle(!1,e,s),this._resetCurrent(),this.logGroupEnd("split Grid Node"),y}_fallbackMoveGridToNextPage({gridNode:e,nodeComputedStyle:t}){return this._node.setInitStyle(!1,e,t),this._resetCurrent(),[]}_resetCurrent(){this._currentGridNode=void 0,this._currentGridRows=void 0,this._currentGridEntries=void 0,this._currentGridRecordedParts=void 0,this._currentGridSplitBottom=void 0,this._currentGridFullPartHeight=void 0,this._currentGridSplitLog=void 0,this._currentGridRowFlags=void 0,this._currentGridShellCache=void 0,this._gridCellLineHeightCache=new WeakMap,this._gridComputedStyleCache=new WeakMap}_getGridSplittableHandlers({evaluation:e,splitStartRowIndexes:t}){return{getRowSliceAdapter:({row:t})=>this._createGridRowSliceAdapter({row:t,rowIndex:e.rowIndex}),onReplaceRow:({newRows:t})=>{this._removeOriginalGridRowCells(e.row),this._node.paginationRefreshRowsAfterSplit(this._getSplitterAdapter(),{rowIndex:e.rowIndex,rowSlices:t})},onAbsorbTail:()=>{},onRefreshRows:({newRows:t})=>{this._node.paginationRefreshRowsAfterSplit(this._getSplitterAdapter(),{rowIndex:e.rowIndex,rowSlices:t})},onPlacement:({evaluation:e,newRows:i,insufficientRemainingWindow:n,isFirstPartEmptyInAnyTD:o,needsScalingInFullPage:r})=>this._node.paginationHandleRowSlicesPlacement({evaluation:e,table:this._currentGridNode,newRows:i,insufficientRemainingWindow:n,isFirstPartEmptyInAnyTD:o,needsScalingInFullPage:r,splitStartRowIndexes:t,pageBottom:this._currentGridSplitBottom,fullPageHeight:this._currentGridFullPartHeight,debug:this._debug,registerPageStartCallback:({targetIndex:e,reason:i})=>this._registerPageStartAt(e,t,i),scaleProblematicSliceCallback:(e,t)=>this._scaleGridCellsToHeight(e,t),applyFullPageScalingCallback:({row:e,needsScalingInFullPage:t,fullPageHeight:i})=>{this._node.paginationApplyFullPageScaling({needsScalingInFullPage:t&&Boolean(e),payload:{cells:e,targetHeight:i},scaleCallback:({cells:e,targetHeight:t})=>this._scaleGridCellsToHeight(e,t)})}}),onSplitFailure:({evaluation:e,splitStartRowIndexes:t,availableRowHeight:i,fullPageHeight:n})=>this._forwardGridOverflowFallback({evaluation:e,splitStartRowIndexes:t,availableRowHeight:i,fullPageHeight:n,branch:"splitFailure"})}}_forwardGridOverflowFallback({evaluation:e,splitStartRowIndexes:t,availableRowHeight:i,fullPageHeight:n=this._currentGridFullPartHeight,branch:o,reasonTail:r,reasonFull:s}){const l=this._composeGridOverflowHelpers(),a={ownerLabel:`grid:${o}`,gridNode:this._currentGridNode,evaluation:e,rowIndex:e.rowIndex,row:e.row,availableRowHeight:i,fullPageHeight:n,splitStartRowIndexes:t,reasonTail:r||("splitFailure"===o?"Grid split failed โ€” move row to next page":"Grid slice overflow โ€” move row to next page"),reasonFull:s||("splitFailure"===o?"Grid split failed โ€” scaled cells to full page":"Grid slice overflow โ€” scaled cells to full page"),registerPageStartCallback:l.registerPageStartCallback,scaleProblematicCellsCallback:l.scaleProblematicCellsCallback,debugLogger:l.debugLogger};return this._debug._&&console.log("[grid.overflow]",o,a),"splitFailure"===o?this._node.handleRowSplitFailure(a):this._node.handleRowOverflow(a)}_buildGridRowEvaluation({rows:e,rowIndex:t,gridNode:i,splitBottom:n}){if(!Array.isArray(e))return null;const o=e[t];if(!o)return null;const r=Array.isArray(o)?new Array(o.length):null,s=this._getRowTop(o,i,r),l=this._getRowBottom(o,i,r),a=e[t+1],h=a?this._getRowTop(a,i):l,c=h-n;return{rowIndex:t,row:o,rowTop:s,rowBottom:l,nextMarker:h,delta:c,tailWindowHeight:n-s,isLastRow:!a,fitsCurrentWindow:c<=0,cellStyles:r}}_composeGridOverflowHelpers(){const e=this._registerPageStartAt.bind(this);this._scaleGridCellsToHeight.bind(this);return{registerPageStartCallback:e,scaleProblematicCellsCallback:(e,t)=>!!Array.isArray(e)&&this._scaleGridCellsToHeight(e,t),debugLogger:this._debug&&this._debug._?(e,t)=>console.log(e,t):void 0}}_resolveGridOverflowingRow({evaluation:e,splitStartRowIndexes:t}){return this._node.paginationResolveOverflowingRow({evaluation:e,utils:{rowHasSpan:()=>!1,isSlice:e=>this._isGridRowSlice(e)},handlers:{handleRowWithRowspan:()=>(this._debug._&&console.warn("[grid.split] ROWSPAN guard triggered unexpectedly.",{evaluation:e}),this._registerPageStartAt(e.rowIndex,t,"Grid ROWSPAN fallback โ€” move row to next page"),e.rowIndex-1),handleSplittableRow:()=>this._resolveGridSplittableRow({evaluation:e,splitStartRowIndexes:t}),handleAlreadySlicedRow:()=>this._forwardGridOverflowFallback({evaluation:e,splitStartRowIndexes:t,branch:"alreadySliced"})}})}_resolveGridSplittableRow({evaluation:e,splitStartRowIndexes:t}){const{rowIndex:i}=e;this._debug._&&console.group("%c[grid.split] Stage5 โ€” splittable row","color:#0080ff",{rowIndex:i,row:e.row,tailWindowHeight:e.tailWindowHeight});const n=this._estimateGridRowMeaningfulSpace({row:e.row,cellStyles:e.cellStyles,minContentLines:this._minGridRowContentLines});if(!(n>0))return console.warn("[grid.metrics] Meaningful row space is unavailable; falling back to overflow handler."),this._forwardGridOverflowFallback({evaluation:e,splitStartRowIndexes:t,availableRowHeight:e.tailWindowHeight,fullPageHeight:this._currentGridFullPartHeight,branch:"metricsMissing",reasonTail:"Grid row metrics missing โ€” move row to next page",reasonFull:"Grid row metrics missing โ€” scaled cells to full page"});const o=this._node.paginationCalculateRowSplitBudget({tailWindowHeight:e.tailWindowHeight,minMeaningfulRowSpace:n,fullPartHeight:this._currentGridFullPartHeight,debug:this._debug}),r=this._node.paginationSplitRow({rowIndex:i,row:e.row,firstPartHeight:o.firstPartHeight,fullPageHeight:this._currentGridFullPartHeight,debug:this._debug,decorateRowSlice:({rowWrapper:e,rowIndex:t,sliceIndex:i})=>{e instanceof HTMLElement&&this._DOM.setAttribute(e,`.grid_row_${t}_part_${i}`)},rowAdapter:this._createGridRowSliceAdapter({row:e.row,rowIndex:i,cellStyles:e.cellStyles})}),s=this._node.paginationProcessRowSplitResult({evaluation:e,splitResult:r,splitStartRowIndexes:t,insufficientRemainingWindow:o.insufficientRemainingWindow,extraCapacity:0,fullPageHeight:this._currentGridFullPartHeight,debug:this._debug,handlers:this._getGridSplittableHandlers({evaluation:e,splitStartRowIndexes:t})});return this.logGroupEnd("[grid.split] Stage5 โ€” splittable row"),s}_createGridRowSliceAdapter({row:e,rowIndex:t,cellStyles:i}){if(!Array.isArray(e))return null;const n=this._currentGridNode,o=e[0]||null,r=this;return{getParentContainer:()=>n,getOriginalCells:()=>[...e],getShellHeights:()=>r._getGridShellHeights(e,i),markOriginalRow:({cells:e})=>{e.forEach((e=>r._node.setFlagSlice(e)))},beginRow:()=>({fragment:r._DOM.createDocumentFragment(),cells:[]}),cloneCellFallback:e=>r._DOM.cloneNodeWrapper(e),handleCell:({context:e,cellClone:t})=>{r._node.setFlagSlice(t),e.fragment.append(t),e.cells.push(t)},finalizeRow:({context:e})=>(o&&r._DOM.insertBefore(o,e.fragment),e.cells)}}_removeOriginalGridRowCells(e){Array.isArray(e)&&e.forEach((e=>{e instanceof HTMLElement&&this._DOM.removeNode(e)}))}_isGridRowSlice(e){if(Array.isArray(e)){const t=e.find((e=>e instanceof HTMLElement));return!!t&&this._node.isSlice(t)}return!!e&&this._node.isSlice(e)}_getPaginatorAdapter(){return{label:"grid",getSplitBottom:()=>this._currentGridSplitBottom,setSplitBottom:e=>{this._currentGridSplitBottom=e},computeSplitBottomForElement:e=>e&&this._currentGridNode?this._node.getTop(e,this._currentGridNode)+(this._currentGridFullPartHeight||0):this._currentGridSplitBottom||0,getRows:()=>Array.isArray(this._currentGridRows)?this._currentGridRows.map((e=>{if(!e)return null;if(e instanceof HTMLElement)return e;if(Array.isArray(e)){const t=e.find((e=>e instanceof HTMLElement));if(t)return t;const i=this._getRowTop(e,this._currentGridNode);return Number.isFinite(i)?i:null}const t=this._getRowTop(e,this._currentGridNode);return Number.isFinite(t)?t:null})):[],shouldAssert:()=>this._assert,getDebug:()=>this._debug,getSplitBottomLog:()=>this._currentGridSplitLog}}_getSplitterAdapter(){return{label:"grid",rows:{getCurrentRows:()=>this._currentGridRows||[],replaceRow:({rowIndex:e,rowSlices:t})=>{Array.isArray(this._currentGridRows)&&this._node.replaceCurrentRowsAfterRowSplit({currentRows:this._currentGridRows,index:e,rowSlices:t})},syncEntries:()=>{this._currentGridEntries&&(this._currentGridEntries.currentRows=this._currentGridRows),this._currentGridRecordedParts&&(this._currentGridRecordedParts.currentRows=this._currentGridRows)},getGuardConfig:()=>({rows:this._currentGridRows||[],DOM:this._DOM})},guards:{onFlags:({flags:e})=>{this._currentGridRowFlags=e}}}}_updateCurrentGridSplitBottom(e,t="unknown case"){Yi(this._getPaginatorAdapter(),e,t)}_registerPageStartAt(e,t,i="register page start"){Zi(this._getPaginatorAdapter(),e,t,i)}_scaleGridCellsToHeight(e,t){if(!(Array.isArray(e)&&e.length&&t>0))return!1;const i=this._getGridShellHeights(e),n=this._debug._?e.map((e=>this._DOM.getElementOffsetHeight(e))):null,o=this._node.paginationScaleCellsToHeight({cells:e,targetHeight:t,shells:i});if(this._debug._){const r=e.map((e=>this._DOM.getElementOffsetHeight(e)));console.log("[grid.scaleCells] target:",t,"shells:",i,"before:",n,"after:",r,"scaled:",o)}return o}_buildGridSplit({startId:e,endId:t,node:i,entries:n}){const o=n?.currentRows||this._currentGridRows||[];if(e===t)return this._debug._&&console.warn("[grid.split] _buildGridSplit: skip empty slice request",e,t),this.strictAssert(!1,"[grid.split] _buildGridSplit: empty slice encountered"),null;if(this._debug._){const i=o.slice(e,t);console.log(`=> [grid.split] _buildGridSplit: slice rows [${e}, ${t})`,i)}const r=this._createAndInsertGridSlice({startId:e,endId:t,node:i,entries:n}),s=this._collectGridTelemetryRows(o,e,t);return this._recordGridPart(r,{startId:e,endId:t,type:"slice",rows:s}),{part:r,telemetryRows:s}}_createAndInsertGridSlice({startId:e,endId:t,node:i,entries:n}){return function(e,{startId:t,endId:i,node:n,entries:o,fallbackCurrentRows:r}){const s=e._DOM.cloneNodeWrapper(n);e._node.copyNodeWidth(s,n),e._node.setFlagNoBreak(s),t&&e._node.markTopCut(s),e._node.markBottomCut(s),n.before(s);const l=o?.currentRows||r||[],a=e&&e._DOM&&"function"==typeof e._DOM.isElementNode?e._DOM.isElementNode.bind(e._DOM):null,h=l.slice(t,i).flat().map((e=>{if(!e)return null;if(a&&a(e))return e;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return e;const t=e.element;if(t){if(a&&a(t))return t;if("undefined"!=typeof HTMLElement&&t instanceof HTMLElement)return t}return null})).filter(Boolean);return e._DOM.insertAtEnd(s,...h),s}(this,{startId:e,endId:t,node:i,entries:n})}_createAndInsertGridFinalSlice({node:e,entries:t,startId:i}){const n=function(e,{node:t,entries:i}){return e._node.markTopCut(t),e._node.setFlagNoBreak(t),t}(this,{node:e,entries:t}),o=t?.currentRows||this._currentGridRows||[],r=this._collectGridTelemetryRows(o,i);return this._recordGridPart(n,{startId:i,endId:o.length,type:"final",rows:r}),n}_collectGridTelemetryRows(e,t,i){if(!Array.isArray(e))return[];return e.slice(t,"number"==typeof i?i:void 0).map(((e,i)=>{const n=Array.isArray(e)?[...e]:[e];return{rowIndex:t+i,row:e,cells:n}}))}_recordGridPart(e,t={}){const i=this._currentGridRecordedParts;if(!i||!e)return null;const{startId:n=null,endId:o=null,type:r="unknown",rows:s=[],meta:l}=t||{};return Qi({entries:i,part:e,startIndex:n,endIndex:o,type:r,rows:s,meta:l})}_estimateGridRowMeaningfulSpace({row:e,cellStyles:t=null,minContentLines:i=this._minGridRowContentLines}){if(!Array.isArray(e)||0===e.length)return console.warn("[grid.metrics] Row payload missing while estimating split budget."),null;const n=this._getGridShellHeights(e,t),o=Array.isArray(t)?t:null,r=Math.max(1,i);let s=0;return e.forEach(((e,t)=>{if(!(e instanceof HTMLElement))return void console.warn("[grid.metrics] Unexpected non-element cell in row; ignoring during split budget calculation.",{cell:e,index:t});let i=o?o[t]:null;i||(i=this._getComputedStyleCached(e),o&&(o[t]=i));const l=this._resolveGridCellLineHeight({cell:e,style:i}),a=(n?.[t]||0)+l*r;s=Math.max(s,a)})),s>0?s:(console.warn("[grid.metrics] Failed to measure meaningful row space."),null)}_resolveGridCellLineHeight({cell:e,style:t}){const i=this._gridCellLineHeightCache,n=i?.get(e);if(n>0)return n;t||(console.warn("[grid.metrics] style not passed for _resolveGridCellLineHeight",{cell:e}),t=this._getComputedStyleCached(e));let o=parseFloat(t?.lineHeight);if(o>0)return i?.set(e,o),o;const r=parseFloat(t?.fontSize);if(Number.isFinite(r)&&r>0){const t=1.2*r;return i?.set(e,t),t}if(o=this._node.getLineHeight(e),o>0)return i?.set(e,o),o;return i?.set(e,16),16}_getGridShellHeights(e,t=null){if(this._currentGridShellCache||(this._currentGridShellCache=new WeakMap),this._currentGridShellCache.has(e))return this._currentGridShellCache.get(e);const i=Array.isArray(e)?e:[e].filter(Boolean),n=this._computeGridCellShellHeights(i,t);return this._currentGridShellCache.set(e,n),n}_getComputedStyleCached(e){if(!e)return console.warn("[grid.split] the element was not passed to _getComputedStyleCached"),null;const t=this._gridComputedStyleCache;if(!t)return this._DOM.getComputedStyle(e);const i=t.get(e);if(i)return i;const n=this._DOM.getComputedStyle(e);return t.set(e,n),n}_computeGridCellShellHeights(e,t=null){return Array.isArray(e)&&e.length?e.map(((e,i)=>{if(!e)return 0;let n=null;t?(n=t[i],n||(n=this._getComputedStyleCached(e),t[i]=n)):n=this._getComputedStyleCached(e);const o=parseFloat(n?.paddingTop)||0,r=parseFloat(n?.paddingBottom)||0,s=parseFloat(n?.borderTopWidth)||0,l=parseFloat(n?.borderBottomWidth)||0,a=parseFloat(n?.marginTop)||0,h=parseFloat(n?.marginBottom)||0,c=o+r+s+l,g=Math.max(0,a)+Math.max(0,h),d=this._DOM.getElementOffsetHeight(e)||0;let p=0;if("function"==typeof this._node.getContentHeightByProbe)try{const t=this._node.getContentHeightByProbe(e,n);Number.isFinite(t)&&t>=0&&(p=t)}catch(e){}p>0&&!(p>d)||(p=Math.max(0,d-c));let u=d-p;return Number.isFinite(u)||(u=c),u=Math.max(u,c),Math.max(0,u+g)})):[]}_getRowTop(e,t,i=null){if(Array.isArray(e)){let i=1/0;return e.forEach((e=>{const n=this._node.getTop(e,t);Number.isFinite(n)&&(i=Math.min(i,n))})),i===1/0?0:i}return e&&this._node.getTop(e,t)||0}_getRowBottom(e,t,i=null){if(Array.isArray(e)){let n=-1/0;return e.forEach(((e,o)=>{const r=this._node.getBottom(e,t);let s=null;i?(s=i[o],!s&&e&&(s=this._getComputedStyleCached(e),i[o]=s)):e&&(s=this._getComputedStyleCached(e));const l=r+(s&&parseFloat(s.marginBottom)||0);Number.isFinite(l)&&(n=Math.max(n,l))})),n===-1/0?0:n}if(e){const i=this._node.getBottom(e,t)||0,n=this._getComputedStyleCached(e);return i+(parseFloat(n?.marginBottom)||0)}return 0}_scanGridLayout(e,t){const i=t.gridAutoFlow||"";if(!i.startsWith("row"))return{safe:!1,reason:`grid-auto-flow=${i}`};if(i.includes("dense"))return{safe:!1,reason:"grid-auto-flow dense not supported yet"};if("none"!==(t.gridTemplateAreas||"none"))return{safe:!1,reason:"grid-template-areas present"};const n=t.gridTemplateColumns||"",o=t.gridTemplateRows||"",r=e=>e.includes("subgrid")||e.includes("auto-fit")||e.includes("auto-fill")||e.includes("fit-content");if(r(n)||r(o))return{safe:!1,reason:"complex track sizing (subgrid/auto-fit/fit-content)"};return/\[.*?\]/.test(n)||/\[.*?\]/.test(o)?{safe:!1,reason:"named grid lines detected"}:{safe:!0}}}const on="background:#999;color:#FFF;padding: 0 4px;";class rn{constructor({config:e,DOM:t,node:i,selector:n}){this._debug=e.debugMode?{...e.debugConfig.pre}:{},this._DOM=t,this._selector=n,this._node=i,this._minPreFirstBlockLines=3,this._minPreLastBlockLines=3,this._minPreBreakableLines=this._minPreFirstBlockLines+this._minPreLastBlockLines,this._imageReductionRatio=.8,this._signpostHeight=parseFloat(e.splitLabelHeight)||0}split(e,t,i,n,o){const r=o||this._DOM.getComputedStyle(e),s=["%c_splitPreNode\n","color:white"];this._debug._&&console.group("%c_splitPreNode","background:cyan"),this._debug._&&console.log(...s,"node",e,{pageBottom:t,fullPageHeight:i});const l=e=>isNaN(parseFloat(e))?0:Math.ceil(parseFloat(e)),a=(l(r.marginTop),l(r.marginBottom),l(r.paddingTop)),h=l(r.paddingBottom),c=l(r.borderTopWidth),g=l(r.borderBottomWidth),d=l(r.lineHeight),p=this._node.getTop(e,n),u=a+h+c+g;if(this._DOM.getElementOffsetHeight(e)1)return this._debug._&&console.log("%c END _splitPreNode TODO!",on),[];{if(this._DOM.isElementNode(_[0])){const e=_[0];return this._debug._&&console.warn("is Element Node",e),this._debug._&&console.log("%c END _splitPreNode ???????",on),[]}this._node.isWrappedTextNode(_[0])&&this._debug._&&console.warn(`is TEXT Node: ${_[0]}`);const n=_[0].wholeText,o=this._node.splitTextByLinesGreedy(n);if(o.length{const t=this._node.createWithFlagNoBreak();return this._DOM.setInnerHTML(t,e),t}));this._debug._&&console.log("linesFromNode",h),this._DOM.replaceNodeContentsWith(e,...h);const d=0,f=d+c,m=d+g;let b=t-p-m-u; +var HTML2PDF4DOC;(()=>{"use strict";var e={d:(t,i)=>{for(var o in i)e.o(i,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:i[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{init:()=>Lo});var i={};e.r(i),e.d(i,{log:()=>x,logGroup:()=>D,logGroupEnd:()=>R,strictAssert:()=>N});var o={};e.r(o),e.d(o,{isAfterContentFlowStart:()=>Z,isComplexTextBlock:()=>Q,isContentFlowEnd:()=>J,isContentFlowStart:()=>X,isFlexRow:()=>ge,isForcedPageBreak:()=>ne,isGrid:()=>le,isGridAutoFlowRow:()=>de,isIMG:()=>G,isInline:()=>re,isInlineBlock:()=>se,isLiNode:()=>z,isNeutral:()=>V,isNoBreak:()=>te,isNoHanging:()=>ie,isOBJECT:()=>j,isPRE:()=>ce,isPageStartElement:()=>Y,isSTYLE:()=>$,isSVG:()=>W,isSelectorMatching:()=>I,isSignificantTextNode:()=>L,isSlice:()=>oe,isSliced:()=>pe,isSlough:()=>ue,isSyntheticTextWrapper:()=>ee,isTableLikeNode:()=>ae,isTableNode:()=>he,isWrappedTextGroup:()=>K,isWrappedTextLine:()=>q,isWrappedTextNode:()=>U});var n={};e.r(n),e.d(n,{explainHeuristicSelectorMismatch:()=>Pe,filterHeuristicSelectorMatches:()=>Ce,hasNoSignificantSiblingNodes:()=>be,hasSignificantLeadingText:()=>we,hasSignificantTrailingText:()=>Se,isHeuristicSelector:()=>me,resolveConfigSelectorConstraints:()=>fe,validateHeuristicSelectorMatch:()=>Me});var r={};e.r(r),e.d(r,{insertStyle:()=>Ee});var s={};e.r(s),e.d(s,{isFirstChildOfFirstChild:()=>Oe,isLastChildOfLastChild:()=>ye,isLineChanged:()=>ve,isLineKept:()=>De,resolveFlowElement:()=>xe,setInitStyle:()=>Re});var l={};e.r(l),e.d(l,{getBottom:()=>Ie,getBottomWithMargin:()=>Le,getContentHeightByProbe:()=>Ye,getEmptyNodeHeightByProbe:()=>je,getHeightWithMargin:()=>$e,getLineHeight:()=>ze,getMaxWidth:()=>We,getNormalizedBottomWithMargin:()=>ke,getNormalizedTop:()=>Fe,getTableEmptyRowHeight:()=>Ue,getTableEntries:()=>Ke,getTableRowHeight:()=>Ve,getTableRowShellHeightByTD:()=>qe,getTop:()=>He,getTopForPageStartCandidate:()=>Be,getTopWithMargin:()=>Ge,resolveRowBoundsGeneric:()=>Xe});var a={};e.r(a),e.d(a,{create:()=>Ze,createComplexTextBlock:()=>rt,createForcedPageBreak:()=>at,createNeutral:()=>Je,createNeutralBlock:()=>Qe,createPrintPageBreak:()=>nt,createSignpost:()=>ht,createSliceWrapper:()=>dt,createTable:()=>ct,createTestNodeFrom:()=>st,createTextGroup:()=>it,createTextLine:()=>tt,createTextNodeWrapper:()=>et,createWithFlagNoBreak:()=>ot,createWord:()=>lt});var h={};e.r(h),e.d(h,{prepareSplittedNode:()=>_t,splitByWordsGreedyWithSpacesFilter:()=>ut,splitTextByLinesGreedy:()=>gt,splitTextByWordsGreedy:()=>pt});var c={};e.r(c),e.d(c,{markBottomCut:()=>vt,markCleanBottomCut:()=>Ot,markCleanTopCut:()=>Tt,markPageEndElement:()=>Ct,markPageNumber:()=>Et,markPageStartElement:()=>Mt,markProcessed:()=>mt,markSliceCuts:()=>Dt,markSliceCutsInRows:()=>Rt,markTopCut:()=>yt,setFlagNoBreak:()=>bt,setFlagNoHanging:()=>wt,setFlagSlice:()=>St,unmarkPageStartElement:()=>Pt});var d={};e.r(d),e.d(d,{wrapNodeChildrenWithNeutralBlock:()=>xt});var g={};e.r(g),e.d(g,{copyNodeWidth:()=>Ht,estimateInlineImgGapBelow:()=>Lt,fitElementWithinBoundaries:()=>Bt,fitElementWithinHeight:()=>Ft,lockNodesWidths:()=>It,lockTableWidths:()=>At,scaleCellsToHeight:()=>kt});var p={};e.r(p),e.d(p,{findAllForcedPageBreakInside:()=>qt,findBetterForcedPageStarter:()=>Gt,findBetterPageStart:()=>Wt,findFirstChildParent:()=>Vt,findFirstChildParentFromPage:()=>jt,findLastChildParent:()=>Ut,findPreviousNonHangingsFromPage:()=>zt});var u={};e.r(u),e.d(u,{getFirstChildrenChain:()=>ti,getLastChildrenChain:()=>ii,getPreparedChildren:()=>Qt,getSplitChildren:()=>ei});var _={};e.r(_),e.d(_,{isReplacedElement:()=>di,resolveReplacedElement:()=>gi});var f={};e.r(f),e.d(f,{cloneAndCleanOutsideRange:()=>Si,getSplitPoints:()=>ui,getSplitPointsPerCells:()=>_i,isFirstSliceEmpty:()=>wi,normalizeContentCuts:()=>mi,sliceNodeBySplitPoints:()=>fi,sliceNodeContentBySplitPoints:()=>bi});var m={};e.r(m),e.d(m,{shouldSkipFlowElement:()=>Ti});var b={};e.r(b),e.d(b,{buildRowSlices:()=>yi,evaluateRowSplitPlacement:()=>Di,paginationBuildBalancedRowSlices:()=>vi,replaceCurrentRowsAfterRowSplit:()=>Ri,sliceCellsBySplitPoints:()=>Oi});var w={};e.r(w),e.d(w,{paginationApplyFullPageScaling:()=>Fi,paginationScaleCellsToHeight:()=>Ni,paginationShouldScaleFullPage:()=>Bi});var S={};e.r(S),e.d(S,{applyRowSlicesToEntriesAfterRowSplit:()=>ki,computeRowFlags:()=>Hi});var M={};e.r(M),e.d(M,{paginationRefreshRowsAfterSplit:()=>Ii,validateSplitterAdapter:()=>Ai});var P={};e.r(P),e.d(P,{paginationComputeCellShellHeights:()=>Li});var C={};e.r(C),e.d(C,{handleRowOverflow:()=>Wi,handleRowSplitFailure:()=>ji,scaleRowCellsToHeight:()=>Gi});var E={};e.r(E),e.d(E,{absorbShortTrailingSliceIfFits:()=>Vi,calculateFinalPartReclaimedHeight:()=>zi});var T={};e.r(T),e.d(T,{paginationBuildRowEvaluationContext:()=>qi,paginationCanAbsorbLastRow:()=>Ki});var O={};e.r(O),e.d(O,{paginationCalculateRowSplitBudget:()=>Qi,paginationHandleRowSlicesPlacement:()=>no,paginationProcessRowSplitResult:()=>io,paginationResolveAlreadySlicedRow:()=>Ji,paginationResolveOverflowingRow:()=>Xi,paginationResolveRowWithRowspan:()=>Zi,paginationResolveSplittableRow:()=>oo,paginationSplitRow:()=>eo});const y={init:"[html2pdf4doc]",root:"html2pdf4doc-root",paperFlow:"html2pdf4doc-paper-flow",contentFlow:"html2pdf4doc-content-flow",overlayFlow:"html2pdf4doc-overlay-flow",pageDivider:"html2pdf4doc-page",pageStartMarker:"[html2pdf4doc-page-start]",pageEndMarker:"[html2pdf4doc-page-end]",pageMarker:"[html2pdf4doc-page]",contentFlowStart:"html2pdf4doc-content-flow-start",contentFlowEnd:"html2pdf4doc-content-flow-end",style:"[html2pdf4doc-style]",frontpageTemplate:"[html2pdf4doc-frontpage]",headerTemplate:"[html2pdf4doc-header]",footerTemplate:"[html2pdf4doc-footer]",frontpageElement:"html2pdf4doc-frontpage",frontpageContent:"html2pdf4doc-frontpage-content",headerContent:"html2pdf4doc-header",footerContent:"html2pdf4doc-footer",pageNumberRoot:"[html2pdf4doc-page-number]",pageNumberCurrent:"[html2pdf4doc-page-number-current]",pageNumberTotal:"[html2pdf4doc-page-number-total]",pageChrome:"html2pdf4doc-page-chrome",pageBodySpacer:"html2pdf4doc-page-body-spacer",pageHeader:"html2pdf4doc-page-header",pageFooter:"html2pdf4doc-page-footer",printPageBreak:"html2pdf4doc-print-page-break",runningSafety:"html2pdf4doc-print-running",virtualPaper:"html2pdf4doc-virtual-paper",virtualPaperTopMargin:"html2pdf4doc-virtual-paper-margin-top",virtualPaperBottomMargin:"html2pdf4doc-virtual-paper-margin-bottom",virtualPaperGap:"html2pdf4doc-virtual-paper-gap",printIgnore:"[html2pdf4doc-print-ignore]",printHide:"[html2pdf4doc-print-hide]",neutral:"html2pdf4doc-neutral",word:"html2pdf4doc-word",textNode:"html2pdf4doc-text-node",textLine:"html2pdf4doc-text-line",textGroup:"html2pdf4doc-text-group",complexTextBlock:"html2pdf4doc-complex-text-block",printForcedPageBreak:"html2pdf4doc-print-forced-page-break",split:"[html2pdf4doc-split]",processed:"[html2pdf4doc-processed]",flagNoBreak:"[html2pdf4doc-flag-no-break]",flagNoHanging:"[html2pdf4doc-flag-no-hanging]",flagSlice:"[html2pdf4doc-flag-slice]",topCutPart:".html2pdf4doc-top-cut",bottomCutPart:".html2pdf4doc-bottom-cut",cleanTopCut:".html2pdf4doc-clean-top-cut",cleanBottomCut:".html2pdf4doc-clean-bottom-cut",tocPageNumber:"html2pdf4doc-toc-page-number"},v="background:#eee;color:#888;padding: 0 1px 0 0;";function D(e,t="",i=!1){"boolean"==typeof t&&(i=t,t=""),!0===i?this._debug._&&console.groupCollapsed(`%c${e}`,t):this._debug._&&console.group(`%c${e}`,t)}function R(e){this._debug._&&console.log(`%c โ–ฒ ${e} `,v),this._debug._&&console.groupEnd()}function x(e,...t){this._debug._&&console.log(`[${e}]`,...t)}function N(e,...t){this._assert&&console.assert(e,"โ›”",...t)}class B{constructor({DOM:e,config:t}){this.document=e,this.body=e.body,this._debug=t.debugMode?{...t.debugConfig.DOM}:{},this._assert=!!t.consoleAssert,Object.assign(this,i)}createElement(e){return this.document.createElement(e)}createDocumentFragment(){return this.document.createDocumentFragment()}cloneNode(e){return e?.cloneNode(!0)}cloneNodeWrapper(e){return e?.cloneNode(!1)}insertBefore(e,...t){const i=t.filter(e=>null!=e);e.before(...i)}insertAfter(e,...t){const i=t.filter(e=>null!=e);e.after(...i)}insertAtEnd(e,...t){const i=t.filter(e=>null!=e);e.append(...i)}insertAtStart(e,...t){const i=t.filter(e=>null!=e);e.prepend(...i)}insertInsteadOf(e,...t){this.insertBefore(e,...t),e.remove()}wrap(e,t){return e.before(t),t.append(e),t}moveContent(e,t){for(;e.firstChild;)t.append(e.firstChild);this.strictAssert(""===this.getInnerHTML(e))}moveRowContent(e,t){if(!e||!t)return void(this._debug._&&console.warn("moveRowContent(): sourceTR or targetTR is missing"));const i=this.getElementTagName(e),o=this.getElementTagName(t);this.strictAssert("TR"===i,`moveRowContent(): source is not TR, got ${i}`),this.strictAssert("TR"===o,`moveRowContent(): target is not TR, got ${o}`);const n=[...this.getChildren(e)],r=[...this.getChildren(t)];n.length!==r.length&&this._debug._&&console.warn(`moveRowContent(): cells count mismatch: ${n.length} (source) vs ${r.length} (target)`);const s=Math.min(n.length,r.length);for(let e=0;e0,"getAll(selectors), selectors:",e),1===e.length?[...this.getAllElements(e[0],t)]:[...e].flatMap(e=>[...this.getAllElements(e,t)])}getElement(e,t=this.document){return this.strictAssert(e),t.querySelector(e)}getAllElements(e,t=this.document){return this.strictAssert(e),t.querySelectorAll(e)}getElementById(e,t=this.document){return t.getElementById(e)}getNodeType(e){return e.nodeType}getRightNeighbor(e){return e.nextElementSibling}getLeftNeighbor(e){return e.previousElementSibling}getParentNode(e){return e.parentElement}getNodeValue(e){return e.nodeValue}getNodeWholeText(e){return e.wholeText}getLastElementChild(e){return e.lastElementChild}getFirstElementChild(e){return e.firstElementChild}getChildNodes(e){return e.childNodes}getChildren(e){return e.children}getElementOffsetParent(e){return e.offsetParent}getComputedStyle(e){return window.getComputedStyle(e)}getElementBCR(e){return e.getBoundingClientRect()}getElementOffsetLeft(e){return e?.offsetLeft}getElementOffsetHeight(e){return e?.offsetHeight}getElementOffsetWidth(e){return e?.offsetWidth}getElementOffsetTop(e){return e?.offsetTop}getElementOffsetBottom(e){return e?.offsetTop+e?.offsetHeight||void 0}getElementTagName(e){return e.tagName}getDataId(e){return e.dataset.id}getAttribute(e,t){if(!e||!t)return void(this._debug._&&console.warn("getAttribute() must have 2 params"));const i=t.charAt(0);if("."!==i&&"#"!==i||this.log("getAttribute",`you're really sure ${t} is attribute selector?`),"["===i){this.strictAssert("]"===t.at(-1),`the ${t} selector is not OK.`);const i=t.substring(1,t.length-1);return e.getAttribute(i)}e.getAttribute(t)}setAttribute(e,t,i){if(!e||!t)return void(this._debug._&&console.warn("setAttribute() must have 2 params"));const o=t.charAt(0);if("."===o){const i=t.substring(1);return void e.classList.add(i)}if("#"===o){const i=t.substring(1);return void(e.id=i)}if("["===o){this.strictAssert("]"===t.at(-1),`the ${t} selector is not OK.`);const o=t.substring(1,t.length-1);return void e.setAttribute(o,i||"")}this.log("setAttribute",`you're really sure ${t} is a selector?`)}setStyles(e,t){Object.entries(t).forEach(([t,i])=>{Array.isArray(i)?this.setStyle(e,t,i[0],i[1]||""):this.setStyle(e,t,i)})}setStyle(e,t,i,o=""){const n=this._toKebab(t);null==i||""===i?e.style.removeProperty(n):e.style.setProperty(n,String(i),o)}_toKebab=e=>{if(e.includes("-"))return e;const t=e.match(/^(webkit|moz|ms|o)(?=[A-Z])/);return t&&(e="-"+t[1]+"-"+e.slice(t[1].length)),e.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())};addClasses(e,...t){e.classList.add(...t)}removeAttribute(e,t){if(!e||!t)return void(this._debug._&&console.warn("removeAttribute() must have 2 params"));const i=t.charAt(0);if(this.strictAssert(i.match(/[a-zA-Z#\[\.]/),`removeAttribute() expects a valid selector, but received ${t}`),"."===i){const i=t.substring(1);return void e.classList.remove(i)}if("#"===i){const i=t.substring(1);return void e.removeAttribute(i)}if("["===i){this.strictAssert("]"===t.at(-1),`the ${t} selector is not OK.`);const i=t.substring(1,t.length-1);return void e.removeAttribute(i)}e.removeAttribute(attr)}removeAllAttributes(e){for(;e.attributes.length>0;)e.removeAttribute(e.attributes[0].name)}removeClasses(e,...t){e.classList.remove(...t)}removeAllClasses(e){e.classList=""}removeAllStyles(e){e.style=""}getInnerHTML(e){if("string"==typeof e){const t=this.document.querySelector(e);return t?t.innerHTML:void 0}return e.innerHTML}setInnerHTML(e,t){if("string"==typeof e){const i=this.document.querySelector(e);i&&(i.innerHTML=t)}e.innerHTML=t}isDocumentBody(e){return"BODY"===e.tagName}isTextNode(e){return e.nodeType===Node.TEXT_NODE}isElementNode(e){return e.nodeType===Node.ELEMENT_NODE}hasClass(e,t){return e.classList.contains(t)}hasID(e,t){return e.id===t}hasAttribute(e,t){return e.hasAttribute(t)}}class F{constructor(e){this.config=e,this._printWidth=parseFloat(this.config.paperWidth),this._printLeft=parseFloat(this.config.printLeftMargin),this._printRight=parseFloat(this.config.printRightMargin),this._printContentWidth=this._printWidth-this._printLeft-this._printRight+"px",this._flowPreviewPaddingBottom="100px",this._chromeBorderSafeSpace="2px",this._ensureBFC="display: flow-root",this.charWidth="10px"}create(){return this._pageRule()+this._layoutStyles().screen+this._layoutStyles().print+this._chromeStyles().screen+this._chromeStyles().print+this._serviceElementsStyle().screen+this._serviceElementsStyle().print+this._cutEdgeStyle()+(this.config.debugMode?this._testScreenOnlyStyle():"")}_pageRule(){return`@page {\n size: A4;\n size: ${`${this.config.paperWidth} ${this.config.paperHeight}`};\n margin-left: ${this.config.printLeftMargin};\n margin-right: ${this.config.printRightMargin};\n margin-top: ${this.config.printTopMargin};\n margin-bottom: 0;\n}`}_layoutStyles(){return{screen:`\n${y.root} {\n --paper-color: ${this.config.paperColor};\n display: flow-root;\n position: relative;\n z-index: 1;\n width: ${this._printContentWidth};\n margin: 0 auto;\n font-size: ${this.config.printFontSize};\n padding-bottom: ${this._flowPreviewPaddingBottom};\n}\n\n${y.contentFlow} {\n display: block;\n}\n\n${y.paperFlow} {\n display: block;\n position: absolute;\n width: 100%;\n z-index: -1;\n padding-bottom: ${this._flowPreviewPaddingBottom};\n pointer-events: none;\n}\n\n${y.overlayFlow} {\n display: block;\n position: absolute;\n width: 100%;\n z-index: 2147483647;\n padding-bottom: ${this._flowPreviewPaddingBottom};\n pointer-events: none;\n}\n\n${y.virtualPaper} {\n display: grid;\n grid-template-columns: 1fr;\n grid-template-rows: minmax(min-content, max-content) minmax(min-content, max-content) 1fr minmax(min-content, max-content) minmax(min-content, max-content);\n place-items: stretch stretch;\n place-content: stretch stretch;\n width: ${this._printContentWidth};\n height: ${this.config.paperHeight};\n font-size: ${this.config.printFontSize};\n}\n\n${y.virtualPaper}::before {\n position: absolute;\n content: '';\n width: ${this.config.paperWidth};\n height: ${this.config.paperHeight};\n left: -${this.config.printLeftMargin};\n background: var(--paper-color, white);\n box-shadow: rgba(0, 0, 0, 0.1) 2px 2px 12px 0px;\n z-index: -1;\n}\n\n${y.pageChrome} {\n display: block;\n pointer-events: none;\n}\n\n${y.pageBodySpacer} {\n display: block;\n pointer-events: none;\n}\n\n${y.pageFooter},\n${y.pageHeader} {\n display: block;\n position: relative;\n pointer-events: auto;\n}\n\n${y.pageFooter}::before,\n${y.pageHeader}::before {\n content: '';\n position: absolute;\n inset: 0;\n z-index: -1;\n background: var(--paper-color, white);\n}\n\n${y.pageFooter}::before {\n top: ${this._chromeBorderSafeSpace};\n}\n\n${y.pageHeader}::before {\n bottom: ${this._chromeBorderSafeSpace};\n}\n\n${y.virtualPaperTopMargin} {\n display: block;\n height: ${this.config.printTopMargin};\n}\n\n${y.virtualPaperBottomMargin} {\n display: block;\n height: ${this.config.printBottomMargin};\n}\n\n${y.virtualPaperGap} {\n display: block;\n padding-top: ${this.config.virtualPagesGap};\n}\n\n${y.contentFlowStart},\n${y.contentFlowEnd},\n${y.pageDivider},\n${y.runningSafety} {\n ${this._ensureBFC};\n}\n `,print:`\n@media print {\n\n ${y.root},\n ${y.overlayFlow},\n ${y.paperFlow} {\n padding: 0;\n }\n\n ${y.paperFlow},\n ${y.printHide} {\n display: none !important;\n }\n\n ${y.printIgnore} {\n display: contents !important;\n }\n\n ${y.virtualPaperTopMargin},\n ${y.virtualPaperBottomMargin},\n ${y.virtualPaperGap} {\n display: none !important;\n }\n\n ${y.pageChrome},\n ${y.frontpageElement},\n ${y.pageBodySpacer} {\n break-inside: avoid;\n }\n}\n `}}_chromeStyles(){return{screen:`\n${y.headerContent},\n${y.footerContent} {\n display: block;\n font-size: small;\n}\n\n${y.headerContent} p,\n${y.footerContent} p {\n margin: 0;\n}\n\n${y.headerContent} {\n padding-bottom: ${this.config.headerMargin};\n padding-top: 10px; /* for page numbers */\n}\n\n${y.footerContent} {\n padding-top: ${this.config.footerMargin};\n min-height: 32px; /* for page numbers */\n}\n\n${y.tocPageNumber} {\n min-width: 3ch;\n display: flex;\n justify-content: flex-end;\n align-items: baseline;\n}\n\n${y.pageNumberRoot} {\n display: flex;\n column-gap: 2px;\n position: absolute;\n right: 0;\n text-align: right;\n line-height: 1;\n}\n\n${y.headerContent} ${y.pageNumberRoot} {\n top: 0;\n}\n\n${y.footerContent} ${y.pageNumberRoot} {\n bottom: 0;\n}\n `,print:""}}_cutEdgeStyle(){return`\n${y.topCutPart} {\n margin-top: 0 !important;\n}\n${y.bottomCutPart} {\n margin-bottom: 0 !important;\n}\n${y.cleanTopCut} {\n margin-top: 0 !important;\n padding-top: 0 !important;\n border-top: none !important;\n}\n${y.cleanBottomCut} {\n margin-bottom: 0 !important;\n padding-bottom: 0 !important;\n border-bottom: none !important;\n}\n `}_serviceElementsStyle(){const e="display: inline";return{screen:`\n.null {\n display: inline;\n padding: 0;\n margin: 0;\n font: 0;\n color: transparent;\n line-height: 0;\n border: none;\n outline: none;\n background: none;\n background-color: transparent;\n}\n\n${y.word},\n${y.textNode},\n${y.textLine},\n${y.textGroup},\n${y.neutral},\n${y.neutral} span {\n display: inline;\n padding: 0;\n margin: 0;\n font: inherit;\n color: inherit;\n line-height: inherit;\n background: none;\n background-color: transparent;\n}\n\n${y.textGroup} {\n display: block;\n}\n\n${y.textLine} {\n display: inline-block;\n}\n\n${y.textGroup} ${y.textLine} {\n ${e};\n}\n\n${y.complexTextBlock} {\n display: block;\n}\n\n${y.complexTextBlock} ${y.complexTextBlock} {\n ${e};\n}\n\n${y.printPageBreak} {\n ${this._ensureBFC};\n}\n\n${y.printForcedPageBreak} {\n display: block;\n visibility: hidden;\n height: 0;\n overflow: hidden;\n}\n `,print:`\n@media print {\n\n ${y.printPageBreak} {\n break-after: page;\n }\n\n ${y.textLine} {\n ${e};\n }\n}\n `}}_testScreenOnlyStyle(){return`\n/* DEBUG PREVIEW */\n@media screen {\n\n ${y.contentFlow} {\n background:repeating-linear-gradient(\n -45deg,\n rgba(222, 222, 222, .1),\n rgba(222, 222, 222, .1) 10px,\n rgba(222, 222, 222, .2) 10px,\n rgba(222, 222, 222, .2) 20px\n );\n }\n\n ${y.overlayFlow} {\n background:repeating-linear-gradient(\n 45deg,\n rgba(222, 222, 222, 0),\n rgba(222, 222, 222, 0) 18px,\n rgba(0, 166, 255, 0.05) 18px,\n rgba(0, 166, 255, 0.05) 20px\n );\n }\n\n ${y.virtualPaperGap} {\n background: #ff000020;\n }\n\n ${y.pageFooter},\n ${y.pageHeader} {\n background: #fff1ff99;\n }\n ${y.pageBodySpacer} {\n background: #ffee0020;\n }\n ${y.runningSafety} {\n background: #f200ff;\n outline: 0.1px dashed #f200ff88;\n }\n ${y.frontpageElement} {\n background: #00fcff20;\n }\n\n ${y.neutral} {\n background: #00ffee10;\n }\n\n ${y.textNode} {\n background: #00ff0010;\n }\n\n ${y.textGroup},\n ${y.textLine} {\n background: #0000ff08;\n }\n}\n `}}class k{constructor({config:e,DOM:t,node:o,selector:n}){this.success=!1,Object.assign(this,i),this.root,this.paperFlow,this.contentFlow,this.overlayFlow,this.frontpageTemplate,this.headerTemplate,this.footerTemplate,this._initialRoot,this._contentRoot,this._config=e,this._debug=e.debugMode?{...e.debugConfig.layout}:{},this._assert=!!e.consoleAssert,this._DOM=t,this._selector=n,this._node=o,this._customInitialRootSelector=e.initialRoot,this._defaultInitialRootSelector=n.init}create(){if(this._getTemplates(),this._insertStyle(),this._DOM.getElement(`style${this._selector.style}`)){if(this._createLayout(),this._DOM.getParentNode(this.root)!==this._initialRoot||this._DOM.getElementOffsetParent(this.paperFlow)!==this.root||this._DOM.getElementOffsetParent(this.contentFlow)!==this.root||this._DOM.getElementOffsetParent(this.overlayFlow)!==this.root)return this.strictAssert(this._DOM.getParentNode(this.root)===this._initialRoot,"Failed to insert the layout root into the DOM."),this.strictAssert(this._DOM.getElementOffsetParent(this.paperFlow)===this.root,"Failed to insert the paperFlow element into the DOM."),void this.strictAssert(this._DOM.getElementOffsetParent(this.contentFlow)===this.root,"Failed to insert the contentFlow element into the DOM.");this.success=!0}else console.error("Failed to add print styles into the DOM.")}_getTemplates(){this.strictAssert(this._selector.frontpageTemplate,"frontpageTemplate selector is missing"),this.strictAssert(this._selector.headerTemplate,"headerTemplate selector is missing"),this.strictAssert(this._selector.footerTemplate,"footerTemplate selector is missing"),this.frontpageTemplate=this._DOM.getInnerHTML(this._selector.frontpageTemplate),this.headerTemplate=this._DOM.getInnerHTML(this._selector.headerTemplate),this.footerTemplate=this._DOM.getInnerHTML(this._selector.footerTemplate)}_insertStyle(){this._node.insertStyle(new F(this._config).create())}_createLayout(){this._getInitialRoot(),this._initialRoot?(this.log("create Layout","initial root:",this._initialRoot),this._createRoot(),this._createPaperFlow(),this._createContentFlow(),this._createOverlayFlow(),this._DOM.moveContent(this._initialRoot,this.contentFlow),this._DOM.insertAtEnd(this._initialRoot,this.root),this._DOM.insertAtEnd(this.root,this.paperFlow,this.overlayFlow,this.contentFlow),this._insertContentFlowStartAndEnd(this.contentFlow),this._ignoreUnprintableEnvironment(this.root)):console.error("Failed to initialize the root element.")}_insertContentFlowStartAndEnd(e){const t=this._node.create(this._selector.contentFlowStart),i=this._node.create(this._selector.contentFlowEnd);return this._DOM.insertAtStart(e,t),this._DOM.insertAtEnd(e,i),{contentFlowStart:t,contentFlowEnd:i}}_getInitialRoot(){let e=this._customInitialRootSelector?this._DOM.getElement(this._customInitialRootSelector):this._DOM.getElement(this._defaultInitialRootSelector);if(!e){if(!this._DOM.body)return void console.error("We expected to find the BODY tag.");e=this._DOM.body,console.warn(`The printable area is currently unspecified and encompasses the entire contents of the BODY tag. To restrict the printed content to a specific area, include ${this._defaultInitialRootSelector} in the root element of the desired printing area.`)}return this._initialRoot=e,e}_createRoot(){const e=this._node.create(this._selector.root);return this._DOM.setStyles(e,{visibility:"hidden"}),this.root=e,e}_createPaperFlow(){const e=this._node.create(this._selector.paperFlow);return this.paperFlow=e,e}_createOverlayFlow(){const e=this._node.create(this._selector.overlayFlow);return this.overlayFlow=e,e}_createContentFlow(){const e=this._node.create(this._selector.contentFlow);return this.contentFlow=e,e}_ignoreUnprintableEnvironment(e){if(e===this._DOM.body)return void this.strictAssert(!1,"misshapen root");let t=this._DOM.getParentNode(e);this._DOM.setAttribute(t,this._selector.printIgnore),this._DOM.getChildNodes(t).forEach(t=>{if(t!==e&&this._DOM.isElementNode(t))this._DOM.setAttribute(t,this._selector.printHide);else{if(!this._node.isSignificantTextNode(t))return;{const e=this._node.createTextNodeWrapper();this._DOM.wrap(t,e),this._DOM.setAttribute(e,this._selector.printHide)}}}),this._DOM.isDocumentBody(t)||this._ignoreUnprintableEnvironment(t)}}function H(e){return function(t){return t._config.debugMode&&t._debug[e]}}const A=H("selectors");function I(e,t){if(!e||!t)return void(A(this)&&console.warn("isSelectorMatching() must have 2 params","\n element: ",e,"\n selector: ",t));const i=t.charAt(0);if("."===i){const i=t.substring(1);return this._DOM.hasClass(e,i)}if("#"===i){const i=t.substring(1);return this._DOM.hasID(e,i)}if("["===i){this.strictAssert("]"===t.at(-1),`the ${t} selector is not OK.`);const i=t.substring(1,t.length-1);return this._DOM.hasAttribute(e,i)}return this._DOM.getElementTagName(e)===t.toUpperCase()}function L(e){return!!this._DOM.isTextNode(e)&&this._DOM.getNodeValue(e).trim().length>0}function $(e){return"STYLE"===this._DOM.getElementTagName(e)}function G(e){return"IMG"===this._DOM.getElementTagName(e)}function W(e){return"svg"===this._DOM.getElementTagName(e)}function j(e){return"OBJECT"===this._DOM.getElementTagName(e)}function z(e){return"LI"===this._DOM.getElementTagName(e)}function V(e){return this.isSelectorMatching(e,this._selector.neutral)}function U(e){return this.isSelectorMatching(e,this._selector.textNode)}function q(e){return this.isSelectorMatching(e,this._selector.textLine)}function K(e){return this.isSelectorMatching(e,this._selector.textGroup)}function Y(e){return this.isSelectorMatching(e,this._selector.pageStartMarker)}function X(e){return this.isSelectorMatching(e,this._selector.contentFlowStart)}function Z(e){const t=this._DOM.getLeftNeighbor(e);return this.isSelectorMatching(t,this._selector.contentFlowStart)}function J(e){return this.isSelectorMatching(e,this._selector.contentFlowEnd)}function Q(e){return this.isSelectorMatching(e,this._selector.complexTextBlock)}function ee(e){return this.isComplexTextBlock(e)||this.isWrappedTextNode(e)||this.isWrappedTextLine(e)||this.isWrappedTextGroup(e)}function te(e,t){return this.isSelectorMatching(e,this._selector.flagNoBreak)||this.isWrappedTextLine(e)||this.isWrappedTextGroup(e)||this.isInlineBlock(e,t)||this.notSolved(e)}function ie(e){return this.isSelectorMatching(e,this._selector.flagNoHanging)}function oe(e){return this.isSelectorMatching(e,this._selector.flagSlice)}function ne(e){return this.isSelectorMatching(e,this._selector.printForcedPageBreak)}function re(e,t){if(!(e instanceof HTMLElement))return;const i=(t||this._DOM.getComputedStyle(e)).display;return"inline"===i||"inline-block"===i||"inline-table"===i||"inline-flex"===i||"inline-grid"===i}function se(e,t){if(!(e instanceof HTMLElement))return;const i=(t||this._DOM.getComputedStyle(e)).display;return"inline-block"===i||"inline-table"===i||"inline-flex"===i||"inline-grid"===i}function le(e,t){if(!(e instanceof HTMLElement))return;return"grid"===(t||this._DOM.getComputedStyle(e)).display}function ae(e,t){if(!(e instanceof HTMLElement))return;const i=(t||this._DOM.getComputedStyle(e)).display;if("TABLE"!==this._DOM.getElementTagName(e)&&["table","inline-table"].includes(i))return!0;const o=e=>"table-row"===e,n=e=>"table-cell"===e;if(o(i)){const t=this._DOM.getChildren(e);for(const e of t)if(e instanceof HTMLElement&&n(this._DOM.getComputedStyle(e).display))return!0;return!1}if("table-row-group"===(r=i)||"table-header-group"===r||"table-footer-group"===r){const t=this._DOM.getChildren(e);for(const e of t){if(!(e instanceof HTMLElement))continue;if(!o(this._DOM.getComputedStyle(e).display))continue;const t=this._DOM.getChildren(e);for(const e of t)if(e instanceof HTMLElement&&n(this._DOM.getComputedStyle(e).display))return!0}return!1}var r;return!1}function he(e,t){if(e instanceof HTMLElement) +//! const computedStyle = style || this._DOM.getComputedStyle(element); +return"TABLE"===this._DOM.getElementTagName(e); +//! || ['table', 'inline-table'].includes(computedStyle.display) +}function ce(e,t){if(!(e instanceof HTMLElement))return;const i=t||this._DOM.getComputedStyle(e);return["block"].includes(i.display)&&["pre","pre-wrap","pre-line","break-spaces","nowrap"].includes(i.whiteSpace)}function de(e,t){if(!(e instanceof HTMLElement))return;const i=t||this._DOM.getComputedStyle(e),o=i.display,n=i.gridAutoFlow;return("grid"===o||"inline-grid"===o)&&"row"===n}function ge(e,t){if(!(e instanceof HTMLElement))return;const i=t||this._DOM.getComputedStyle(e),o=i.display;if("flex"!==o&&"inline-flex"!==o)return!1;return(i.flexDirection||"").startsWith("row")}function pe(e,t){const i=t||this._DOM.getComputedStyle(e);return this.isTableNode(e,i)||this.isTableLikeNode(e,i)||this.isGridAutoFlowRow(e,i)}function ue(e){return this._DOM.hasAttribute(e,"slough-node")}const _e=H("selectorHeuristics");function fe(e,t,i){const o=[],n=new Set;return _e(this)&&console.group(i),e.forEach(e=>{const i=this._DOM.getAllElements(e,t),r=this.isHeuristicSelector(e);_e(this)&&r&&console.log("๐Ÿช„ [heuristic selector]",e,`\n${i.length} elements found`);for(const t of i)r&&!this.validateHeuristicSelectorMatch(t,e)||n.has(t)||(n.add(t),o.push(t))}),_e(this)&&console.log(i,o.length?o:"has no elements"),_e(this)&&console.groupEnd(i),o}function me(e){return/:(only-child|first-child|last-child)\b/.test(e)}function be(e,{allowWhitespaceText:t=!0,ignoreComments:i=!0}={}){const o=e&&e.parentNode;if(!o)return!1;for(let n=o.firstChild;n;n=n.nextSibling)if(n!==e){if(n.nodeType===Node.ELEMENT_NODE)return!1;if(n.nodeType!==Node.TEXT_NODE){if(n.nodeType===Node.COMMENT_NODE){if(i)continue;return!1}return!1}if(!t)return!1;if(n.nodeValue&&""!==n.nodeValue.trim())return!1}return!0}function we(e){const t=e&&e.parentNode;if(!t)return!1;for(let i=t.firstChild;i&&i!==e;i=i.nextSibling){if(i.nodeType===Node.TEXT_NODE&&i.nodeValue&&""!==i.nodeValue.trim())return!0;if(i.nodeType!==Node.COMMENT_NODE&&i.nodeType!==Node.ELEMENT_NODE&&i.nodeType!==Node.TEXT_NODE&&i.nodeType!==Node.COMMENT_NODE)return!0}return!1}function Se(e){const t=e&&e.parentNode;if(!t)return!1;let i=!1;for(let o=t.firstChild;o;o=o.nextSibling)if(i){if(o.nodeType===Node.TEXT_NODE&&o.nodeValue&&""!==o.nodeValue.trim())return!0;if(o.nodeType!==Node.COMMENT_NODE&&o.nodeType!==Node.ELEMENT_NODE&&o.nodeType!==Node.TEXT_NODE&&o.nodeType!==Node.COMMENT_NODE)return!0}else o===e&&(i=!0);return!1}function Me(e,t){return/:only-child\b/.test(t)?this.hasNoSignificantSiblingNodes(e,{allowWhitespaceText:!0,ignoreComments:!0}):/:first-child\b/.test(t)?!this.hasSignificantLeadingText(e):!/:last-child\b/.test(t)||!this.hasSignificantTrailingText(e)}function Pe(e,t){return/:only-child\b/.test(t)?"has significant sibling nodes (text/elements)":/:first-child\b/.test(t)?"has significant leading text":/:last-child\b/.test(t)?"has significant trailing text":"failed heuristic validation"}function Ce(e,t){return this.isHeuristicSelector(t)?e.filter(e=>this.validateHeuristicSelectorMatch(e,t)):e}function Ee(e,t=""){const i=this._DOM.getElement("head"),o=this._DOM.body;if(!i&&!o)return void console.error("Check the structure of your document. We didn`t find HEAD and BODY tags. HTML2PDF4DOC expects valid HTML.");const n=this.create("style",e);n?(this._DOM.setAttribute(n,this._selector.style,t),i?this._DOM.insertAtEnd(i,n):o?this._DOM.insertBefore(o,n):this.strictAssert(!1,"We expected to find the HEAD and BODY tags.")):console.error("Failed to create print styles")}const Te=H("positioning");function Oe(e,t){if(!e||!this._DOM.getParentNode(e))return!1;let i=e;for(;this._DOM.getParentNode(i)&&i!==t;){if(this._DOM.getFirstElementChild(this._DOM.getParentNode(i))!==i)return!1;i=this._DOM.getParentNode(i)}return i===t}function ye(e,t){if(!e||!this._DOM.getParentNode(e))return!1;let i=e;for(;this._DOM.getParentNode(i)&&i!==t;){if(this._DOM.getParentNode(i)===t){let e=this._DOM.getRightNeighbor(i);for(;!this._DOM.getElementOffsetHeight(e)&&!this._DOM.getElementOffsetWidth(e);)if(e=this._DOM.getRightNeighbor(e),this.isContentFlowEnd(e))return!0;return this.isContentFlowEnd(e)}if(this._DOM.getLastElementChild(this._DOM.getParentNode(i))!==i)return!1;i=this._DOM.getParentNode(i)}return i===t}function ve(e,t){return this._DOM.getElementOffsetTop(t)-this._DOM.getElementOffsetBottom(e)>-2}function De(e,t){const i=this._DOM.getElementOffsetBottom(e),o=this._DOM.getElementOffsetTop(t),n=i-o,r=n>=2;return Te(this)&&console.group("isLineKept?"),Te(this)&&console.log("\n",r,"\n","\n currentBottom",i,[e],"\n nextTop",o,[t],"\n delta",n),Te(this)&&console.groupEnd("isLineKept?"),r}function Re(e,t,i){const o="[init-position]",n="[init-vertical-align]",r="relative",s=i||this._DOM.getComputedStyle(t),l=s.position,a=s.verticalAlign;if(e)l!=r&&(this._DOM.setStyles(t,{position:r}),this._DOM.setAttribute(t,o,l)),"top"!=a&&(this._DOM.setStyles(t,{"vertical-align":"top"}),this._DOM.setAttribute(t,n,a));else{const e=this._DOM.getAttribute(t,o),i=this._DOM.getAttribute(t,n);e&&(this._DOM.setStyles(t,{position:e}),this._DOM.removeAttribute(t,o)),i&&(this._DOM.setStyles(t,{"vertical-align":i}),this._DOM.removeAttribute(t,n))}}function xe(e,{prefer:t="self"}={}){if(!e)return null;const i=e=>"last"===t?this._DOM.getLastElementChild(e):"first"===t||"self"===t?this._DOM.getFirstElementChild(e):null,o=new Set;let n=e;for(;n&&!o.has(n);){o.add(n);if(this._DOM.getElementOffsetParent(n))return n;const e=this._DOM.getComputedStyle(n);if(!e)return null;const t=e.display,r=e.visibility,s=e.position;if("none"===t||"collapse"===r||"fixed"===s)return null;if("contents"===t){const e=i.call(this,n);if(!e)return null;n=e;continue}return null}return null}const Ne=H("getters");function Be(e,t){return this.getTop(e,t)}function Fe(e,t,i){const o=i||this._DOM.getComputedStyle(t),n=parseFloat(o.paddingTop)||0;return this.getTop(e,t)-n}function ke(e,t,i){const o=i||this._DOM.getComputedStyle(t),n=parseFloat(o.paddingTop)||0;return this.getBottomWithMargin(e,t)-n}function He(e,t=null,i=0,o=null,n=[],r=null){if(!e)return void(Ne(this)&&console.warn("[getTop] element must be provided, but was received:",e,"\nThe function returned:",void 0));if(!(e instanceof HTMLElement))return void this.strictAssert(0,"[getTop] element must be HTMLElement, but was received:",e,"\nThe function returned:",void 0);if(null===t)return this._DOM.getElementOffsetTop(e);if(!(t instanceof HTMLElement))return void this.strictAssert(0,"[getTop] root must be HTMLElement, but was received:",t,"\nThe function returned:",void 0);if(o=o||{element:e,root:t},0===i&&!t.contains(e))return void this.strictAssert(0,"[getTop] the provided root does not contain the element.",{element:e,root:t,paramSnapshot:o},"\nThe function returned:",void 0);if(!(r=r||Ae.call(this,t,o)))return void(Ne(this)&&console.warn("Root has no a usable offset reference; nothing else to measure against. \nThe function returned:",void 0,{element:e,paramSnapshot:o,offsetParent:l,traversal:s}));if(e===t)return i;const s=[...n,e],l=this._DOM.getElementOffsetParent(e);if(!l)return void(Ne(this)&&console.warn("Element has no offset parent; offset chain is broken. \nThe function returned:",void 0,{element:e,paramSnapshot:o,offsetParent:l,traversal:s}));const a=this._DOM.getElementOffsetTop(e);return l===t?a+i:l===r.sharedOffsetParent?(r.sharedOffsetParentIsBody&&!r.warnedAboutBody&&(r.warnedAboutBody=!0,Ne(this)&&console.warn("getTop(): reached document.body while measuring offsets. Layout likely lacks positioned ancestors.",{element:e,root:t,paramSnapshot:o})),a+i-r.rootOffsetFromSharedParent):this.getTop(l,t,i+a,o,s,r)}function Ae(e,t){const i=this._DOM.getElementOffsetParent(e);if(!i)return Ne(this)&&console.warn("[getTop*]: root has no offset parent; cannot build relative offsets.",{root:e,paramSnapshot:t}),null;const o=this._DOM.getElementOffsetTop(e);return"number"!=typeof o?(Ne(this)&&console.warn("[getTop*]: root offsetTop is not a number.",{root:e,sharedOffsetParent:i,paramSnapshot:t}),null):{sharedOffsetParent:i,rootOffsetFromSharedParent:o,sharedOffsetParentIsBody:i===e.ownerDocument?.body,warnedAboutBody:!1}}function Ie(e,t=null){if(e){if(null===t)return this._DOM.getElementOffsetBottom(e);if(t)return this.getTop(e,t)+this._DOM.getElementOffsetHeight(e);Ne(this)&&console.warn("root must be provided, but was received:",t,"\nThe function returned:",void 0)}else Ne(this)&&console.warn("[getBottom] element must be provided, but was received:",e,"\nThe function returned:",void 0)}function Le(e,t){if(!e)return;const i=this.getBottom(e,t);let o;const n=this.createNeutralBlock();this._DOM.insertAfter(e,n);const r=this.getTop(n,t);this._DOM.removeNode(n);if(r>=i)o=r;else{o=i+parseInt(this._DOM.getComputedStyle(e).marginBottom)}return o}function $e(e){const t=parseInt(this._DOM.getComputedStyle(e).marginTop),i=parseInt(this._DOM.getComputedStyle(e).marginBottom);return this._DOM.getElementOffsetHeight(e)+t+i}function Ge(e,t){const i=parseInt(this._DOM.getComputedStyle(e).marginTop);return this.getTop(e,t)-i}function We(e){const t=this.create();this._DOM.insertAtEnd(e,t);const i=this._DOM.getElementOffsetWidth(t);return this._DOM.removeNode(t),i}function je(e,t="",i=!0){const o=this.create();i&&this._DOM.setStyles(o,{overflow:"auto"});const n=this._DOM.cloneNodeWrapper(e);this._DOM.setInnerHTML(n,t),this._DOM.insertAtEnd(o,n),this._DOM.insertBefore(e,o);const r=this._DOM.getElementOffsetHeight(o);return this._DOM.removeNode(o),r}function ze(e){const t=this.createNeutral();this._DOM.setInnerHTML(t,"!"),this._DOM.setStyles(t,{display:"block"}),this._DOM.insertAtEnd(e,t);const i=this._DOM.getElementOffsetHeight(t);return this._DOM.removeNode(t),i}function Ve(e,t=0){const i=this._DOM.getElementOffsetTop(e),o=this._DOM.cloneNode(e),n="!
".repeat(t);[...o.children].forEach(e=>this._DOM.setInnerHTML(e,n)),this._DOM.insertBefore(e,o);const r=this._DOM.getElementOffsetTop(e);return this._DOM.removeNode(o),r-i}function Ue(e){const t=this._DOM.getElementOffsetTop(e),i=this._DOM.cloneNodeWrapper(e);this._DOM.insertBefore(e,i);const o=this._DOM.getElementOffsetTop(e);return this._DOM.removeNode(i),o-t}function qe(e){const t=this._DOM.getElementOffsetTop(e),i=this._DOM.cloneNodeWrapper(e),o=e.children.length,n=[...e.children];this._DOM.insertBefore(e,i);const r=[];for(let s=0;sthis._DOM.removeNode(e))}return this._DOM.removeNode(i),r}function Ke(e){if(!(e instanceof HTMLElement)||"TABLE"!==e.tagName)throw new Error("Expected a
element.");const t=[...e.children].reduce((e,t)=>{const i=t.tagName;return"TBODY"===i?{...e,rows:[...e.rows,...t.children]}:"CAPTION"===i?(this.setFlagNoBreak(t),{...e,caption:t}):"COLGROUP"===i?(this.setFlagNoBreak(t),{...e,colgroup:t}):"THEAD"===i?(this.setFlagNoBreak(t),{...e,thead:t}):"TFOOT"===i?(this.setFlagNoBreak(t),{...e,tfoot:t}):"TR"===i?{...e,rows:[...e.rows,...t]}:(Ne(this)&&t&&console.warn("unexpected:",t),{...e,unexpected:[...e.unexpected,...t]})},{caption:null,thead:null,tfoot:null,rows:[],unexpected:[]});return t.unexpected.length>0&&Ne(this)&&console.warn(`something unexpected is found in the table ${e}`),t}function Ye(e,t){const i=t||this._DOM.getComputedStyle(e),o=this.createNeutralBlock();this._DOM.setStyles(o,{display:"block",padding:"0",margin:"0",border:"0",height:"0",clear:"both",visibility:"hidden",contain:"layout"}),this._DOM.insertAtEnd(e,o);const n=this.getNormalizedTop(o,e,i);return this._DOM.removeNode(o),n}function Xe(e,t,i="both"){const o="bottom"!==i,n="top"!==i;if(e instanceof HTMLElement){const r=o?this.getTop(e,t):void 0,s=n?this.getBottom(e,t):void 0;return o&&!Number.isFinite(r)?(this.strictAssert(!1,"[resolveRowBoundsGeneric] failed to measure top for HTMLElement",{row:e,root:t,want:i}),{top:void 0,bottom:void 0}):n&&!Number.isFinite(s)?(this.strictAssert(!1,"[resolveRowBoundsGeneric] failed to measure bottom for HTMLElement",{row:e,root:t,want:i}),{top:void 0,bottom:void 0}):"top"===i?{top:r,bottom:r}:"bottom"===i?{top:s,bottom:s}:{top:r,bottom:s}}if(Array.isArray(e)){let r=o?1/0:void 0,s=n?-1/0:void 0,l=!1,a=!1;return e.forEach(e=>{if(e instanceof HTMLElement){if(o){const i=this.getTop(e,t);Number.isFinite(i)&&(r=Math.min(r,i),l=!0)}if(n){const i=this.getBottom(e,t);Number.isFinite(i)&&(s=Math.max(s,i),a=!0)}}}),"top"===i?l?{top:r,bottom:r}:(this.strictAssert(!1,"[resolveRowBoundsGeneric] no valid top found in row array",{row:e,root:t,want:i}),{top:void 0,bottom:void 0}):"bottom"===i?a?{top:s,bottom:s}:(this.strictAssert(!1,"[resolveRowBoundsGeneric] no valid bottom found in row array",{row:e,root:t,want:i}),{top:void 0,bottom:void 0}):o&&!l?(this.strictAssert(!1,"[resolveRowBoundsGeneric] no valid top found in row array",{row:e,root:t,want:i}),{top:void 0,bottom:void 0}):n&&!a?(this.strictAssert(!1,"[resolveRowBoundsGeneric] no valid bottom found in row array",{row:e,root:t,want:i}),{top:void 0,bottom:void 0}):{top:r,bottom:s}}return this.strictAssert(!1,"[resolveRowBoundsGeneric] unexpected row payload",{row:e,root:t,want:i}),{top:void 0,bottom:void 0}}H("creators");function Ze(e,t){let i;if(e){const t=e.charAt(0);if(t.match(/[#\[\.]/))i=this._DOM.createElement("div"),this._DOM.setAttribute(i,e);else{if(!t.match(/[a-zA-Z]/))return void this.strictAssert(!1,"Expected valid html selector ot tag name, but received:",e);i=this._DOM.createElement(e)}}else i=this._DOM.createElement("div");return t&&this._DOM.setInnerHTML(i,t),i}function Je(){return this.create(this._selector.neutral)}function Qe(){const e=this.createNeutral();return e.style.display="block",e.style.clear="both",e}function et(){return this.create(this._selector.textNode)}function tt(){return this.create(this._selector.textLine)}function it(){return this.create(this._selector.textGroup)}function ot(e){const t=this.create(this._selector.flagNoBreak);return e&&this._DOM.setStyles(t,e),t}function nt(){return this.create(this._selector.printPageBreak)}function rt(){return this.create(this._selector.complexTextBlock)}function st(e){const t=this._DOM.cloneNodeWrapper(e);return this._DOM.setAttribute(t,".test-node"),this._DOM.setStyles(t,{position:"absolute",background:"rgb(255 239 177)",width:this.getMaxWidth(e)+"px"}),t}function lt(e,t){const i=this.create(this._selector.word);return this._DOM.setInnerHTML(i,e),i.dataset.index=t,i}function at(){return this.create(this._selector.printForcedPageBreak)}function ht(e,t){if(!t)return null;const i=this.create();return this._DOM.setStyles(i,{display:"flex",flexWrap:"nowrap",alignItems:"center",justifyContent:"center",textAlign:"center",fontSize:"8px",fontFamily:"sans-serif",letterSpacing:"1px",textTransform:"uppercase",height:t+"px"}),e&&this._DOM.setInnerHTML(i,e),this.setFlagNoBreak(i),i}function ct({wrapper:e,caption:t,colgroup:i,thead:o,tfoot:n,tbody:r}){const s=e||this.create("table"),l=this.create("TBODY");return t&&this._DOM.insertAtEnd(s,t),i&&this._DOM.insertAtEnd(s,i),o&&this._DOM.insertAtEnd(s,o),r&&this._DOM.insertAtEnd(l,...r),this._DOM.insertAtEnd(s,l),n&&this._DOM.insertAtEnd(s,n),s}function dt(e){const t=this._DOM.cloneNodeWrapper(e);return this.unmarkPageStartElement(t),this.setFlagNoBreak(t),t}H("splitters");function gt(e){return e.split(/(?<=\n)/)}function pt(e){return(this._DOM.getNodeValue(e)||this._DOM.getInnerHTML(e)).split(/(?<=\s|-)/)}function ut(e){return(this._DOM.getNodeValue(e)||this._DOM.getInnerHTML(e)).trim().split(/(?<=\s|-)/).filter(e=>" "!=e)}function _t(e){const t=e,i=this.splitTextByWordsGreedy(e),o=i.map(e=>{const t=this._DOM.createElement("span");return this._DOM.setInnerHTML(t,e+" "),t}),n=this.createTestNodeFrom(e);return this._DOM.insertAtEnd(n,...o),this._DOM.insertAtEnd(e,n),{splittedNode:t,nodeWords:i,nodeWordItems:o}}const ft=H("markers");function mt(e,t){this._markupDebugMode&&this._DOM.setAttribute(e,this._selector.processed,"๐Ÿท๏ธ "+t)}function bt(e){this._DOM.setAttribute(e,this._selector.flagNoBreak)}function wt(e,t){this._DOM.setAttribute(e,this._selector.flagNoHanging,t)}function St(e){this._DOM.setAttribute(e,this._selector.flagSlice)}function Mt(e,t){this._DOM.setAttribute(e,this._selector.pageStartMarker,`${t}`)}function Pt(e){this._DOM.removeAttribute(e,this._selector.pageStartMarker)}function Ct(e,t){this._DOM.setAttribute(e,this._selector.pageEndMarker,`${t}`)}function Et(e,t){this._DOM.setAttribute(e,this._selector.pageMarker,`${t}`)}function Tt(e){ft(this)&&console.log("[mark โŠค cut]",e),e&&this._DOM.setAttribute(e,this._selector.cleanTopCut)}function Ot(e){ft(this)&&console.log("[mark โŠฅ cut]",e),e&&this._DOM.setAttribute(e,this._selector.cleanBottomCut)}function yt(e){ft(this)&&console.log("[mark โŠค cut]",e),e&&this._DOM.setAttribute(e,this._selector.topCutPart)}function vt(e){ft(this)&&console.log("[mark โŠฅ cut]",e),e&&this._DOM.setAttribute(e,this._selector.bottomCutPart)}function Dt(e){if(e&&e.length)if(1!==e.length)for(let t=0;t0,o=t0,n=t","color:blue",i),r=i,s=[...this._DOM.getChildren(i)]):Array.isArray(i)?(ft(this)&&console.log("%c[markSliceCutsInRows] It is an Array","color:blue",i),r=void 0,s=i):this.strictAssert(0,"we expected TR or an array of elements!"),!r&&!s.length){ft(this)&&console.log("%c[markSliceCutsInRows] There was no split","color:red",{rowWrapper:r,cellWrappers:s});break}o&&(r&&(ft(this)&&console.log("[markSliceCutsInRows] rowWrapper โŠฅ",r),this.markTopCut(r)),s.forEach(e=>{ft(this)&&console.log("[markSliceCutsInRows] cell ๐Ÿ–๏ธ โŠฅ",e),this.markTopCut(e)})),n&&(r&&(ft(this)&&console.log("[markSliceCutsInRows] rowWrapper โŠค",r),this.markBottomCut(r)),s.forEach(e=>{ft(this)&&console.log("[markSliceCutsInRows] cell ๐Ÿ–๏ธ โŠค",e),this.markBottomCut(e)}))}else ft(this)&&console.log("%c[markSliceCutsInRows] The rows were not passed. Doing nothing.","color:red")}H("wrappers");function xt(e){const t=this._DOM.getChildren(e),i=this.createNeutralBlock();return this._DOM.insertAtStart(i,...t),this._DOM.insertAtStart(e,i),i}const Nt=H("fitters");function Bt({element:e,height:t,width:i,vspace:o,hspace:n}){const r=o/t,s=n/i,l=ra&&(g||(g=this.wrapNodeChildrenWithNeutralBlock(s),d=this._DOM.getElementOffsetHeight(g)||d),this.fitElementWithinHeight(g,a),n=!0,Nt(this)&&console.warn("๐Ÿ’ข scaleCellsToHeight: resized cell content",{cell:s,target:a}))}return n}function Ht(e,t){this._DOM.setStyles(e,{"box-sizing":"border-box",width:`${this._DOM.getElementOffsetWidth(t)}px`,"min-width":`${this._DOM.getElementOffsetWidth(t)}px`})}function At(e){this.copyNodeWidth(e,e),this._DOM.getAll("td",e).forEach(e=>this.copyNodeWidth(e,e))}function It(e){Array.isArray(e)&&e.forEach(e=>{e&&this.copyNodeWidth(e,e)})}function Lt(e,t={}){const{descentRatio:i=.22,normalLH:o=1.2,safety:n=1}=t,r=getComputedStyle(e),s=parseFloat(r.fontSize)||0;let l;if("normal"!==r.lineHeight&&r.lineHeight){const e=parseFloat(r.lineHeight);l=Number.isFinite(e)?e:o*s}else l=o*s;const a=(Math.max(0,(l-s)/2)+i*s)*n;return Math.ceil(a)}const $t=H("pageBreaks");function Gt(e,t){let i=e;for(;;){const e=this.findFirstChildParent(i,t);if(!e||e===i)break;i=e}return i}function Wt(e,t,i){$t(this)&&console.group("โž— findBetterPageStart");let o=!1,n=!1,r=!1;const s=t?this.getTop(t,i):0;$t(this)&&console.log("Start calculations:",{pageStart:e,lastPageStart:t,root:i,topLimit:s});const l=this.findFirstChildParentFromPage(e,s,i);let a;if(l)a=l;else{a=this.getTop(e,i){if(this.isSTYLE(t))return Jt(this)&&console.info("๐Ÿšธ (getPreparedChildren) ignore STYLE",[t]),e;if(this.isSignificantTextNode(t)){const i=this.createTextNodeWrapper();return this._DOM.wrap(t,i),e.push(i),Jt(this)&&console.info("๐Ÿšธ (getPreparedChildren) wrap and return TEXT NODE",[t]),e}if(this._DOM.isElementNode(t)){if(this.shouldSkipFlowElement(t,{context:"getPreparedChildren"}))return e;if(!this._DOM.getElementOffsetParent(t)){const i=this.getPreparedChildren(t);return i.length>0&&e.push(...i),Jt(this)&&console.info("%c๐Ÿšธ (getPreparedChildren) * no offset parent โ€” unwrapped","color:green",i,[t]),e}return e.push(t),Jt(this)&&console.info("๐Ÿšธ (getPreparedChildren) * normal node",[t]),e}return Jt(this)&&console.info("%c๐Ÿšธ (getPreparedChildren) IGNORE whitespace / comment ...","color:red",[t]),e},[]),Jt(this)&&console.groupEnd("โš—๏ธ๐Ÿšธ distill children"),Jt(this)&&console.info("๐Ÿšธ distilled children",t);const i=si.call(this,t),o=this.isInline(e);i&&(Jt(this)&&console.info("๐Ÿšธ isVerticalFlowDisrupted in children of element",[e]),o?(Jt(this)&&console.info("๐ŸŽ’๐Ÿšธ parent element is inline wrapper",[e]),t=[ni.call(this,e)]):t=oi.call(this,t))}}return Jt(this)&&console.info("๐Ÿšธ getPreparedChildren:",t),Jt(this)&&console.groupEnd("๐Ÿšธ getPreparedChildren of"),t}function ei(e,t,i,o){let n=[];if(this.isNoBreak(e))return Jt(this)&&console.info("๐Ÿงก isNoBreak",e),[];if(this.isComplexTextBlock(e))return Jt(this)&&console.info("๐Ÿ’š ComplexTextBlock",e),this._paragraph.split(e)||[];if(this.isWrappedTextNode(e))return Jt(this)&&console.info("๐Ÿ’š TextNode",e),this._paragraph.split(e)||[];if(!li.call(this,e))return Jt(this)&&console.info("๐Ÿชฒ getSplitChildren: empty node, return []",e),[];const r=this._DOM.getComputedStyle(e);if(this.isTableNode(e,r))Jt(this)&&console.info("๐Ÿ’š TABLE",e),n=this._table.split(e,t,i,o,r)||[];else if(this.isTableLikeNode(e,r))Jt(this)&&console.info("๐Ÿ’š TABLE like",e),n=this._tableLike.split(e,t,i,o,r)||[];else if(this.isPRE(e,r))Jt(this)&&console.info("๐Ÿ’š PRE",e),n=this._pre.split(e,t,i,o,r)||[];else if(this.isFlexRow(e,r)){Jt(this)&&console.info("๐Ÿฉท Flex ROW",e);let t=this.getPreparedChildren(e);n=ri.call(this,t)}else this.isGridAutoFlowRow(e,r)?(Jt(this)&&console.info("๐Ÿ’œ GRID"),n=this._grid.split(e,t,i,o)||[]):(Jt(this)&&console.info("๐Ÿ’š found some node - use main this.getPreparedChildren() for:",e),n=this.getPreparedChildren(e));return n}function ti(e){const t=[];if(!e||!this||!this._DOM)return t;let i=e;for(;i;){let e=this._DOM.getFirstElementChild(i);for(;e&&this.shouldSkipFlowElement(e,{context:"getFirstChildren:firstChild"});)e=this._DOM.getRightNeighbor(e);if(!e)break;if(this.isSyntheticTextWrapper(e))break;t.push(e),i=e}return t}function ii(e){const t=[];if(!e||!this||!this._DOM)return t;let i=e;for(;i;){let e=this._DOM.getLastElementChild(i);for(;e&&this.shouldSkipFlowElement(e,{context:"getLastChildren:lastChild"});)e=this._DOM.getLeftNeighbor(e);if(!e)break;if(this.isSyntheticTextWrapper(e))break;t.push(e),i=e}return t}function oi(e){let t=null;const i=[];return e.forEach(e=>{this.isInline(e)?(t||(t=ni.call(this,e),i.push(t)),this._DOM.insertAtEnd(t,e)):(t=null,i.push(e))}),i}function ni(e){const t=this.createComplexTextBlock();return this._DOM.wrap(e,t),t}function ri(e){const t=e.filter(e=>this._DOM.getElementOffsetHeight(e)>0);return t.length>0?t:e}function si(e){return e.some((e,t,i)=>{const o=e,n=i[t+1];if(!n)return!1;return this._DOM.getElementOffsetBottom(o)>this._DOM.getElementOffsetTop(n)})}function li(e){let t=e.firstChild;for(;t;){if(this._DOM.isElementNode(t)){if(!this.shouldSkipFlowElement(t,{context:"hasRenderableChild"}))return!0}else if(this.isSignificantTextNode(t))return!0;t=t.nextSibling}return!1}const ai=H("media"),hi=new Set(["IMG","SVG","OBJECT","EMBED","IFRAME","VIDEO","AUDIO","CANVAS"]);function ci(e,t="self"){return"last"===t?this._DOM.getLastElementChild(e):this._DOM.getFirstElementChild(e)}function di(e){if(!e)return!1;const t=this._DOM.getElementTagName(e);if(!t)return!1;if("INPUT"===t){return"image"===(this._DOM.getAttribute(e,"type")||"").toLowerCase()}return hi.has(t)}function gi(e,{prefer:t="self"}={}){if(!e)return null;const i=new Set;let o=e;for(;o&&!i.has(o);){if(i.add(o),this.isReplacedElement(o))return o;if("function"==typeof this.resolveFlowElement){const e=this.resolveFlowElement(o,{prefer:t});if(e&&e!==o){if(this.isReplacedElement(e))return e;o=e;continue}}const e=[...this._DOM.getChildren(o)].filter(e=>{const t=this._DOM.getComputedStyle(e)?.display;return"none"!==t});if(1!==e.length)return ai(this)&&console.info("๐Ÿงญ resolveReplacedElement: branching or empty wrapper",o,e),null;o=ci.call(this,o,t)||e[0]}return null}const pi=H("slicers");function ui({rootNode:e,rootComputedStyle:t,children:i,firstPartHeight:o,fullPageHeight:n,firstChild:r,points:s=[]}){if(!i.length)return pi(this)&&console.log("๐Ÿงถ [getSplitPoints] %c has no children, early returns []","font-weight:bold",{rootNode:e}),[];const l=t=>{const i=this.findBetterPageStart(t,s.at(-1),e);return s.length||i!==r?(pi(this)&&console.log("%c ๐Ÿงผ๐Ÿงผ๐Ÿงผ๐Ÿงผ push(point) in registerPoint()","color:violet",{point:i,points:s,firstChild:r},s.length),s.push(i),!1):(pi(this)&&console.log("%c !points.length && point === children[0] && children[1]","color:red"),pi(this)&&console.log("%c ๐Ÿ…พ๏ธ push(null) in registerPoint()","color:red"),s.push(null),!0)};pi(this)&&console.group("๐Ÿงถ getSplitPoints"),pi(this)&&console.log("points.length",s.length);const a=t||this._DOM.getComputedStyle(e),h=new WeakMap,c=e=>{let t=h.get(e);return t||(t=Object.create(null),h.set(e,t)),t},d=t=>{if(!t)return NaN;const i=c(t);return"top"in i||(i.top=this.getNormalizedTop(t,e,a)),i.top},g=t=>{if(!t)return NaN;const i=c(t);return"bottomWithMargin"in i||(i.bottomWithMargin=this.getNormalizedBottomWithMargin(t,e,a)),i.bottomWithMargin},p=e=>{if(!e)return 0;const t=c(e);return"offsetHeight"in t||(t.offsetHeight=this._DOM.getElementOffsetHeight(e)),t.offsetHeight};this.setInitStyle(!0,e,a);let u=!1;const _=()=>(u||(u=!0,pi(this)&&console.groupEnd(`walking through ${i.length} children`),this.setInitStyle(!1,e,t),pi(this)&&console.groupEnd("getSplitPoints")),s);pi(this)&&console.group(`walking through ${i.length} children`,i);for(let t=0;th))if(pi(this)&&console.log("[getSplitPoints]",`next overtook the floater : (nextElementTop) ${b} > ${h}`,{currentElement:u},"does current overflow? let's check.",{isNextElementTopFinite:w}),(this.isSVG(u)||this.isIMG(u))&&pi(this)&&console.log("%cIMAGE","color:red;text-weight:bold"),S=g(u),S<=h){if(w){pi(this)&&console.log("[getSplitPoints]",`current fits: (currentElementBottom) ${S} <= ${h}, ๐ŸŽ register nextElement as Point.`,{currentElement:u,nextElement:m});if(l(m))return pi(this)&&console.log("%cNULL CASE, return","color:red;text-weight:bold"),_();continue}pi(this)&&console.log("[getSplitPoints] nextElementTop not finite and current fits tail window",{currentElementBottom:S,floater:h,nextElement:m})}else pi(this)&&console.log(`๐Ÿ”ช๐Ÿฅ’ try to split overflowing current: (currentElementBottom > ) ${S} > ${h}`,{currentElement:u}),M=!0;if(!m){pi(this)&&console.log("%c[getSplitPoints] !nextElement","color:red"),pi(this)&&console.log("%c[getSplitPoints] * Try to split it. ๐Ÿ”ช๐Ÿฅ’","color:blue"),S=S??g(u);let t=u;if(u.parentElement&&e.contains(u.parentElement)){let i=u.parentElement;for(;i&&e.contains(i)&&i!==e&&!this._DOM.getRightNeighbor(i);)t=i,i=i.parentElement}const i=t===u?S:g(t);if(i<=h){pi(this)&&console.log("%c ๐Ÿ• [getSplitPoints] !nextElement branch fits with container shell","color:violet",{currentElementBottom:S,containerBottom:i,floater:h,containerElement:t});continue}M=!0}if(!M)continue;let P=[];const C=this.getSplitChildren(u,o,n,e);if(C.length){if(P=ui.call(this,{rootNode:e,rootComputedStyle:a,children:C,firstPartHeight:o,fullPageHeight:n,firstChild:r,points:s}),0===P.length){const e=Math.max(o,n),t=p(u),i=t>e&&(!P.length||1===P.length&&null===P[0]);if(pi(this)&&console.log("room (Math.max)",e),i){if(pi(this)&&console.warn("%cโš ๏ธ UNSPLITTABLE OVERSIZED ELEMENT โ€” SCALE IT","color:white; background:red; font-weight:bold;",u,`height: ${t}`),!s.length&&u===r)return pi(this)&&console.warn("๐Ÿ…พ๏ธ (1) points.push(null) in isUnbreakableOversized"),s.push(null),_();if(m){if(l(m))return _()}}else if(l(u))return _()}}else{pi(this)&&console.log("๐ŸŽ currentElementChildren.length == 0");const e=p(u);if(e>c&&(!P.length||1===P.length&&null===P[0])){if(pi(this)&&console.warn("%cโš ๏ธ UNSPLITTABLE OVERSIZED ELEMENT โ€” SCALE IT","color:white; background:red; font-weight:bold;",u,`height: ${e}`),pi(this)&&console.warn("๐Ÿ…พ๏ธ (2) points.push(null) in isUnbreakableOversized"),!s.length&&u===r)return s.push(null),_();if(m){pi(this)&&console.warn("๐Ÿ…พ๏ธ๐Ÿ…พ๏ธ๐Ÿ…พ๏ธ๐Ÿ…พ๏ธ๐Ÿ…พ๏ธ๐Ÿ…พ๏ธ๐Ÿ…พ๏ธ๐Ÿ…พ๏ธ registerPoint(nextElement)");if(l(m))return _()}}else{if(l(u))return _()}}}return _()}function _i(e,t,i,o,n){pi(this)&&console.group("[โœ–๏ธ] getSplitPointsPerCells");const r=e.map((e,r)=>{pi(this)&&console.group(`(โ€ข) Split CELL.${r} in:`,n);let s=[];const l=i-(t[r]||0),a=o-(t[r]||0);let h=this.getSplitChildren(e,l,a,n);if(h.length){const t=h[0];pi(this)&&console.log("firstChild",t),s=this.getSplitPoints({rootNode:e,children:h,firstPartHeight:l,fullPageHeight:a,firstChild:t})}else pi(this)&&console.log(`(โ€ข) empty cell #${r}`);return pi(this)&&console.log(`(โ€ข) return splitPoints for CELL#${r}`,s),pi(this)&&console.groupEnd(),s}),s=r.some(wi);pi(this)&&console.log("๐Ÿงฝ๐Ÿงฝ๐Ÿงฝ๐Ÿงฝ๐Ÿงฝ๐Ÿงฝ๐Ÿงฝ isFirstPartEmptyInAnyCell",s);let l=r,a=!1;if(s){l=e.map((e,r)=>{pi(this)&&console.group(`(โ€ขโ€ข) Split CELL.${r} in:`,n);const s=i-(t[r]||0),l=o-(t[r]||0),a=this.getSplitChildren(e,s,l,n),h=a[0];pi(this)&&console.log("firstChild",h);let c=[];return a.length&&(c=this.getSplitPoints({rootNode:e,children:a,firstPartHeight:l,fullPageHeight:l,firstChild:h})),pi(this)&&console.log(`(โ€ขโ€ข) return splitPoints for CELL#${r}`,c),pi(this)&&console.groupEnd(),c}),pi(this)&&console.log("[โ€ขโ€ข] splitPointsPerCell",l);for(let e=0;e0&&this.strictAssert(i.every(e=>null!==e),"sliceNodeBySplitPoints: splitPoints contains null โ€” sanitize upstream before slicing"),this.strictAssert(i.every(e=>!e||e.nodeType===Node.ELEMENT_NODE&&(t===e||t.contains(e))),"sliceNodeBySplitPoints: split point is not an Element within rootNode");for(let e=0;e<=i.length;e++){const n=i[e-1]??null,r=i[e]??null,s=this.cloneAndCleanOutsideRange(t,n,r);this.normalizeContentCuts({slice:s,top:null!==n,bottom:null!==r}),this._DOM.getChildNodes(s).length>0&&o.push(s)}return pi(this)&&console.log(o),pi(this)&&console.groupEnd(`๐Ÿ”ช (${e}) sliceNodeBySplitPoints`),o}function mi({slice:e,top:t=!1,bottom:i=!1}){if(e){if(t){const t=[...this.getFirstChildrenChain(e)];t.forEach(e=>this.markCleanTopCut(e)),pi(this)&&console.log("[normalizeContentCuts] topChain ๐Ÿ‘—",t)}if(i){const t=[...this.getLastChildrenChain(e)];t.forEach(e=>this.markCleanBottomCut(e)),pi(this)&&console.log("[normalizeContentCuts] bottomChain ๐Ÿ‘—",t)}}else pi(this)&&console.log("[normalizeContentCuts] no slice has been passed; return")}function bi({index:e,rootNode:t,splitPoints:i}){pi(this)&&console.group(`๐Ÿ”ช (${e}) sliceNodeContentBySplitPoints`);const o=[];for(let e=0;e<=i.length;e++){const n=i[e-1]??null,r=i[e]??null,s=this.cloneAndCleanOutsideRange(t,n,r);pi(this)&&console.log({slice:s});const l=this.createNeutralBlock();for(;s.firstChild;)l.appendChild(s.firstChild);l.childNodes.length>0&&o.push(l)}return pi(this)&&console.log(o),pi(this)&&console.groupEnd(`๐Ÿ”ช (${e}) sliceNodeContentBySplitPoints`),o}function wi(e){return!!Array.isArray(e)&&(e.length>0&&null===e[0])}function Si(e,t,i){t&&t.setAttribute("split","start"),i&&i.setAttribute("split","end");let o=e.cloneNode(!0);if(t){let t=o.querySelector('[split="start"]'),i=t.previousElementSibling;for(;i;){let e=i;i=i.previousElementSibling,e.remove()}let n=t.parentElement;for(;n&&n!==e;){let e=n.previousElementSibling;for(;e;){let t=e;e=e.previousElementSibling,t.remove()}n=n.parentElement}t.removeAttribute("split")}if(i){let t=o.querySelector('[split="end"]'),i=t.nextElementSibling;for(;i;){let e=i;i=i.nextElementSibling,e.remove()}let n=t.parentElement;for(;n&&n!==e;){let e=n.nextElementSibling;for(;e;){let t=e;e=e.nextElementSibling,t.remove()}n=n.parentElement}t.remove()}return t&&t.removeAttribute("split"),i&&i.removeAttribute("split"),o}const Mi=H("flowfilters"),Pi="__html2pdf4docFlowFilter",Ci=[{test:e=>"none"===e.display,cache:{reason:"display:none",message:"* display:none โ€” skipped"}},{test:e=>"absolute"===e.position,cache:{reason:"position:absolute",message:"* position:absolute โ€” skipped"}},{test:e=>"fixed"===e.position,cache:{reason:"position:fixed",message:"* position:fixed โ€” skipped"}},{test:e=>"collapse"===e.visibility,cache:{reason:"visibility:collapse",message:"* visibility:collapse โ€” skipped"}}];function Ei(e,t,i,o,{cached:n}={cached:!1}){if(!Mi(e))return;const r=t?`(${t}) `:"",s=n?" (cached)":"";console.info(`๐Ÿšธ ${r}${i.message}${s}`,[o])}function Ti(e,{context:t="",computedStyle:i}={}){if(!(e&&this&&this._DOM&&this._DOM.isElementNode(e)))return!1;const o=e[Pi];if(o)return Ei(this,t,o,e,{cached:!0}),!0;const n=i??this._DOM.getComputedStyle(e);if(!n)return!1;for(const i of Ci)if(i.test(n))return e[Pi]=i.cache,Ei(this,t,i.cache,e),!0;return!1}H("pagination");function Oi({cells:e,splitPointsPerCell:t,sliceCell:i}){return t.map((t,o)=>{const n=e[o];return i({cell:n,index:o,splitPoints:t})})}function yi({originalRow:e,originalCells:t,slicedCellsPerOriginal:i,beginRow:o,cloneCellFallback:n,handleCell:r,finalizeRow:s}){const l=Math.max(...i.map(e=>e.length)),a=[];for(let h=0;h{const o=i[t][h]||n(e);r({context:l,cellClone:o,originalCell:e,cellIndex:t})}),a.push(s({context:l}))}return a}function vi({originalRow:e,originalCells:t,splitPointsPerCell:i,sliceCell:o,beginRow:n,cloneCellFallback:r,handleCell:s,finalizeRow:l}){if(!Array.isArray(i)||!i.length)return[];const a=this.sliceCellsBySplitPoints({cells:t,splitPointsPerCell:i,sliceCell:o});return this.buildRowSlices({originalRow:e,originalCells:t,slicedCellsPerOriginal:a,beginRow:n,cloneCellFallback:r,handleCell:s,finalizeRow:l})}function Di({usedRemainingWindow:e,isFirstPartEmpty:t,firstSliceTop:i,firstSliceBottom:o,pageBottom:n,epsilon:r=.5}){return{placeOnCurrentPage:e&&!t,remainingWindowSpace:Math.max(0,n-i),exceedsWindow:o>n+r}}function Ri({currentRows:e,index:t,rowSlices:i}){return Array.isArray(e)?(e.splice(t,1,...i),e):[]}const xi=H("pagination");function Ni({cells:e,targetHeight:t,shells:i}){return!!(Array.isArray(e)&&e.length&&t>0)&&this.scaleCellsToHeight(e,t,i)}function Bi({needsScalingInFullPage:e,cells:t}){return Boolean(e&&Array.isArray(t)&&t.length)}function Fi({needsScalingInFullPage:e,scaleCallback:t,payload:i}){if(!e)return!1;if("function"!=typeof t)return!1;const o=t(i||{});return!o&&this&&this._debug&&this._debug._&&xi(this)&&console.warn("[pagination.scaling] requested full-page scaling but callback reported no change",i),Boolean(o)}H("pagination");function ki(e,t,i){e&&Array.isArray(e.rows)&&e.rows.splice(t,1,...i)}function Hi({rows:e,DOM:t,cellTagFilter:i,guardCallback:o}){if(!Array.isArray(e))return{};let n=!1,r=!1,s=!1,l=null;e.forEach(e=>{const o=Array.isArray(e)?e:Array.from(t.getChildren(e)||[]);null==l&&(l=o.length),o.length!==l&&(s=!0),o.forEach(e=>{const o=t.getElementTagName(e);if(!i||i(o,e)){const t=parseInt(e.getAttribute?.("rowspan"));Number.isFinite(t)&&t>1&&(n=!0);const i=parseInt(e.getAttribute?.("colspan"));Number.isFinite(i)&&i>1&&(r=!0)}})});const a={hasRowspan:n,hasColspan:r,inconsistentCells:s};return o?.(a),a}H("pagination");function Ai(e){if(!e||"object"!=typeof e)throw new Error("splitter kernel adapter must be an object.");if(!e.rows||"object"!=typeof e.rows)throw new Error("splitter kernel adapter must expose a rows provider.");if("function"!=typeof e.rows.replaceRow)throw new Error("splitter kernel adapter rows.replaceRow must be a function.")}function Ii(e,{rowIndex:t,rowSlices:i}){Ai(e);const o=Number.isFinite(t)?t:0,n=Array.isArray(i)?i:[],r=e.rows;r.replaceRow({rowIndex:o,rowSlices:n}),r.syncEntries?.({rowIndex:o,rowSlices:n});const s=e.guards?.getConfig?.({rowIndex:o,rowSlices:n})??r.getGuardConfig?.({rowIndex:o,rowSlices:n})??null;let l=null;if(s){const t={rows:s.rows,DOM:s.DOM||this._DOM,cellTagFilter:s.cellTagFilter,guardCallback:s.guardCallback};Array.isArray(t.rows)&&t.DOM&&(l=this.computeRowFlags(t),e.guards?.onFlags?.({flags:l,rowIndex:o,rowSlices:n}))}return e.metrics?.refresh?.({rowIndex:o,rowSlices:n,flags:l}),r.onRowsChanged?.({rowIndex:o,rowSlices:n,flags:l}),{flags:l}}H("pagination");function Li({cells:e}){return Array.isArray(e)&&e.length?e.map(e=>{if(!e)return 0;const t=this._DOM.getComputedStyle(e),i=(parseFloat(t?.paddingTop)||0)+(parseFloat(t?.paddingBottom)||0)+(parseFloat(t?.borderTopWidth)||0)+(parseFloat(t?.borderBottomWidth)||0);return Number.isFinite(i)?Math.max(0,i):0}):[]}const $i=H("pagination");function Gi({ownerLabel:e,DOM:t,row:i,targetHeight:o,cachedShells:n,getRowShellHeightsCallback:r,scaleCellsToHeightCallback:s}){if(e||$i(this)&&console.warn("[scaleRowCellsToHeight] ๐Ÿ‘ค Owner wanted!",{owner:e}),!i)return $i(this)&&console.warn("[pagination.overflow] Missing row for scaling.",{owner:e}),!1;if("function"!=typeof s)return $i(this)&&console.warn("[pagination.overflow] scaleCellsToHeight callback is required.",{owner:e}),!1;const l=t,a=l&&"function"==typeof l.getChildren?l.getChildren(i):null;return s(a?[...a]:[],o,Array.isArray(n)?n:"function"==typeof r?r(i):[])}function Wi({ownerLabel:e,rowIndex:t,row:i,availableRowHeight:o,fullPageHeight:n,splitStartRowIndexes:r,reasonTail:s,reasonFull:l,registerPageStartCallback:a,scaleProblematicCellsCallback:h,debugLogger:c}){return e||$i(this)&&console.warn("[handleRowOverflow] ๐Ÿ‘ค Owner wanted!",{owner:e}),Array.isArray(r)?"function"!=typeof a?($i(this)&&console.warn("[pagination.overflow] registerPageStart callback is required.",{owner:e}),t):o!1,isSlice:n=()=>!1}=t,{handleRowWithRowspan:r=()=>e.rowIndex,handleSplittableRow:s=()=>e.rowIndex,handleAlreadySlicedRow:l=()=>e.rowIndex}=i,{row:a}=e;return o(a,e)?r({evaluation:e}):n(a,e)?l({evaluation:e}):s({evaluation:e})}function Zi({evaluation:e,splitStartRowIndexes:t,fullPageHeight:i,resolveOverflow:o,debug:n,afterResolve:r}){const{rowIndex:s,tailWindowHeight:l}=e;Yi(this)&&console.log("%c โš ๏ธ Row has ROWSPAN; use conservative fallback (no slicing)","color:DarkOrange; font-weight:bold");const a=o({rowIndex:s,evaluation:e,availableRowHeight:l,splitStartRowIndexes:t,fullPageHeight:i});return r?.({evaluation:e,tailWindowHeight:l,fullPageHeight:i,result:a}),a}function Ji({evaluation:e,splitStartRowIndexes:t,resolveSplitFailure:i,fullPageHeight:o,debug:n}){const{rowIndex:r,row:s,tailWindowHeight:l,delta:a}=e;return Yi(this)&&console.log(`%c Row # ${r} is slice! but don't fit`,"color:DarkOrange; font-weight:bold",s),Yi(this)&&console.warn("%c SUPER BIG","background:red;color:white",a,{part:o}),i({evaluation:e,splitStartRowIndexes:t,availableRowHeight:l,fullPageHeight:o})}function Qi({tailWindowHeight:e,minMeaningfulRowSpace:t,fullPartHeight:i,debug:o}){return ethis.sliceNodeBySplitPoints({index:t,rootNode:e,splitPoints:i})),f=l.beginRow||(({originalRow:t,sliceIndex:i})=>{const o=this._DOM.cloneNodeWrapper(t);return r?.({rowWrapper:o,rowIndex:e,sliceIndex:i,originalRow:t}),{rowWrapper:o}}),m=l.cloneCellFallback||(e=>this._DOM.cloneNodeWrapper(e)),b=l.handleCell||(({context:e,cellClone:t})=>{this._DOM.insertAtEnd(e.rowWrapper,t)}),w=l.finalizeRow||(({context:e})=>e.rowWrapper),S=[];if(g.some(e=>Array.isArray(e)&&e.length)){const e=this.paginationBuildBalancedRowSlices({originalRow:t,originalCells:h,splitPointsPerCell:g,sliceCell:_,beginRow:f,cloneCellFallback:m,handleCell:b,finalizeRow:w});S.push(...e)}else Yi(this)&&console.log("๐Ÿ”ด There is no Split");return S.length&&this.markSliceCutsInRows(S),n&&n._&&console.log("%c newRows \n","color:magenta; font-weight:bold",S),{newRows:S,isFirstPartEmptyInAnyTD:p,needsScalingInFullPage:u}}function to({row:e,rowIndex:t,decorateRowSlice:i}){const o=Array.isArray(e),n=this;return{getParentContainer:()=>o?null:e,getOriginalCells:()=>o?[...e]:[...n._DOM.getChildren(e)],getShellHeights:({cells:t})=>o?[]:n.getTableRowShellHeightByTD(e),markOriginalRow:({cells:t})=>{o||n.setFlagSlice(e)},beginRow:({originalRow:e,sliceIndex:r})=>{if(o)return{cells:[]};const s=n._DOM.cloneNodeWrapper(e);return i?.({rowWrapper:s,rowIndex:t,sliceIndex:r,originalRow:e}),{rowWrapper:s}},cloneCellFallback:e=>n._DOM.cloneNodeWrapper(e),handleCell:({context:e,cellClone:t})=>{o?(n.setFlagSlice(t),e.cells.push(t)):n._DOM.insertAtEnd(e.rowWrapper,t)},finalizeRow:({context:e})=>o?e.cells:e.rowWrapper}}function io({evaluation:e,splitResult:t,splitStartRowIndexes:i,insufficientRemainingWindow:o,extraCapacity:n,fullPageHeight:r,debug:s,handlers:l={}}){const{newRows:a,isFirstPartEmptyInAnyTD:h,needsScalingInFullPage:c}=t||{},{rowIndex:d,row:g,isLastRow:p,tailWindowHeight:u}=e,{onReplaceRow:_,onAbsorbTail:f,onRefreshRows:m,onPlacement:b,onSplitFailure:w}=l;return Array.isArray(a)&&a.length?(_?.({evaluation:e,newRows:a}),p&&f?.({evaluation:e,newRows:a,extraCapacity:n}),m?.({evaluation:e,newRows:a,splitStartRowIndexes:i}),b?.({evaluation:e,newRows:a,insufficientRemainingWindow:o,isFirstPartEmptyInAnyTD:h,needsScalingInFullPage:c,splitStartRowIndexes:i})??e.rowIndex):(Yi(this)&&console.log(`%c The row is not split. (ROW.${d})`,"color:orange",g),w?.({evaluation:e,splitStartRowIndexes:i,availableRowHeight:u,fullPageHeight:r})??e.rowIndex)}function oo({evaluation:e,splitStartRowIndexes:t,extraCapacity:i,fullPageHeight:o,minPartLines:n,debug:r,decorateRowSlice:s,onBudgetInfo:l,handlers:a={}}){if(!e||!e.row)return e?.rowIndex??0;const{row:h}=e,c=this.getTableRowHeight(h,n),d=this.paginationCalculateRowSplitBudget({tailWindowHeight:e.tailWindowHeight,minMeaningfulRowSpace:c,fullPartHeight:o,debug:r});l?.({evaluation:e,firstPartHeight:d.firstPartHeight,fullPartHeight:o});const g=a.getRowSliceAdapter,p=g?.({evaluation:e,row:h,rowIndex:e.rowIndex,decorateRowSlice:s}),u=this.paginationSplitRow({rowIndex:e.rowIndex,row:h,firstPartHeight:d.firstPartHeight,fullPageHeight:o,debug:r,decorateRowSlice:s,rowAdapter:p});return this.paginationProcessRowSplitResult({evaluation:e,splitResult:u,splitStartRowIndexes:t,insufficientRemainingWindow:d.insufficientRemainingWindow,extraCapacity:i,fullPageHeight:o,debug:r,handlers:a})}function no({evaluation:e,table:t,newRows:i,insufficientRemainingWindow:o,isFirstPartEmptyInAnyTD:n,needsScalingInFullPage:r,splitStartRowIndexes:s,pageBottom:l,fullPageHeight:a,debug:h,resolveRowBounds:c,registerPageStartCallback:d,scaleProblematicSliceCallback:g,applyFullPageScalingCallback:p}){const{rowIndex:u}=e,_=Array.isArray(i)?i[0]:null;if(!_)return d?.({targetIndex:u,reason:"Row split produced empty first slice"}),u-1;const f="function"==typeof c?c:e=>this.resolveRowBoundsGeneric(e,t),{top:m,bottom:b}=f(_),w=this.evaluateRowSplitPlacement({usedRemainingWindow:!o,isFirstPartEmpty:n,firstSliceTop:m,firstSliceBottom:b,pageBottom:l,epsilon:0});return w.placeOnCurrentPage?(w.remainingWindowSpace>0&&g?.(_,w.remainingWindowSpace),d?.({targetIndex:u+1,reason:"Row split โ€” next slice starts new page"})):(p?.({row:_,needsScalingInFullPage:r,fullPageHeight:a}),d?.({targetIndex:u,reason:"Empty first part โ€” move row to next page"})),u-1}class ro{constructor({config:e,DOM:t,node:o,selector:n}){this._debug=e.debugMode?{...e.debugConfig.paragraph}:{},this._assert=!!e.consoleAssert,this._DOM=t,this._selector=n,this._node=o,this._minParagraphLeftLines=2,this._minParagraphDanglingLines=2,this._minParagraphBreakableLines=this._minParagraphLeftLines+this._minParagraphDanglingLines||2,Object.assign(this,i)}split(e){return this._splitComplexTextBlockIntoLines(e)}_estimateLineCount(e){return Math.ceil(this._DOM.getElementOffsetHeight(e)/this._node.getLineHeight(e))}_splitComplexTextBlockIntoLines(e){if(this._debug._&&console.group("_splitComplexTextBlockIntoLines",[e]),this._estimateLineCount(e){const t=this._node.getLineHeight(e),i=this._DOM.getElementOffsetHeight(e),o=this._DOM.getElementOffsetLeft(e),n=this._DOM.getElementOffsetTop(e);return{element:e,lines:Math.ceil(i/t),left:o,top:n,height:i,lineHeight:t,text:this._DOM.getInnerHTML(e)}});this._debug._&&console.log("\n๐Ÿšธ nodeChildren",[...t],"\n๐Ÿšธ extendedChildrenArray",[...i]);const o=i.flatMap(e=>e.lines>1&&!this._node.isNoBreak(e.element)?this._breakItIntoLines(e.element):e.element);this._debug._&&console.log("\n๐Ÿšธ๐Ÿšธ๐Ÿšธ\n partiallyLinedChildren",[...o]);const n=o.reduce((e,t,i,o)=>(e||(e=[]),"BR"===this._DOM.getElementTagName(t)?(e.length||e.push([]),e.at(-1).push(t),e.push([]),this._debug._&&console.log("br; push:",t),e):!e.length||this._node.isLineChanged(e.at(-1).at(-1),t)?(e.push([t]),this._debug._&&console.log("โ—ผ๏ธ start new line:",t),e):0===e.at(-1).length||e.length&&this._node.isLineKept(e.at(-1).at(-1),t)?(this._debug._&&console.log("โฌ† add to line:",t),e.at(-1).push(t),e):void this.strictAssert(!0,"groupedPartiallyLinedChildren: An unexpected case of splitting a complex paragraph into lines.","\nOn the element:",t)),[]);if(this._debug._&&console.log("๐ŸŸก๐ŸŸก๐ŸŸก groupedPartiallyLinedChildren \n",n.length,[...n]),n.length{let i;if(0==e.length)i=e[0],i.setAttribute("role","๐Ÿšซ"),this.strictAssert(0==e.length,"The string cannot be empty (_splitComplexTextBlockIntoLines)");else if(1==e.length)i=e[0];else{i=this._node.createTextGroup(),this._DOM.insertBefore(e[0],i),this._DOM.insertAtEnd(i,...e)}return i.dataset.child=t,i});return this.logGroupEnd("OK _splitComplexTextBlockIntoLines"),this._DOM.setAttribute(e,this._selector.split),l}_breakItIntoLines(e){if(this._debug._&&console.group("_breakItIntoLines",[e]),this._node.isNoBreak(e))return this.logGroupEnd("isNoBreak"),e;if(this._node.isWrappedTextNode(e)){const t=this._breakWrappedTextNodeIntoLines(e);return this.logGroupEnd("TextNode newLines"),t}return this.logGroupEnd("(recursive _breakItIntoLines)"),this._processNestedInlineElements(e)}_processNestedInlineElements(e){this._debug._&&console.group("_processNestedInlineElements",[e]);const t=this._getNestedInlineChildren(e).flatMap(e=>this._estimateLineCount(e)>1?this._breakItIntoLines(e):e),i=this._findNewLineStarts(t,e),o=i.map((o,n)=>{const r=t[o],s=t[i[n+1]];return this._node.cloneAndCleanOutsideRange(e,r,s)});return this._DOM.insertInsteadOf(e,...o),this.logGroupEnd("Nested Inline parts"),o}_getNestedInlineChildren(e){return[...this._DOM.getChildNodes(e)].reduce((e,t)=>{if(this._node.isSignificantTextNode(t)){const i=this._node.createTextNodeWrapper();return this._DOM.wrap(t,i),e.push(i),e}if(!this._DOM.getElementOffsetParent(t)){const i=this._node.getPreparedChildren(t);return i.length>0&&e.push(...i),e}if(this._DOM.isElementNode(t)){return this._getNestedInlineChildren(t).forEach(t=>e.push(t)),e}},[])}_makeWordsFromTextNode(e){const t=this._node.splitTextByWordsGreedy(e);this._debug._&&console.log("wordArray",t);const i=t.map((e,t)=>this._node.createWord(e+"",t));return this._debug._&&console.log("wrappedWordArray",i),{wordArray:t,wrappedWordArray:i}}_breakWrappedTextNodeIntoLines(e){e.classList.add("๐Ÿ” _breakItIntoLines"),e.classList.add("๐Ÿšซ_must_be_removed");const{wordArray:t,wrappedWordArray:i}=this._makeWordsFromTextNode(e);this._DOM.setInnerHTML(e,""),this._DOM.insertAtEnd(e,...i);const o=this._findNewLineStarts(i,e),n=o.reduce((i,n,r)=>{const s=this._node.createTextLine(),l=o[r],a=o[r+1],h=t.slice(l,a).join("")+"";return this._DOM.setInnerHTML(s,h),this._DOM.insertBefore(e,s),i.push(s),i},[]);return e.remove(),n}_findNewLineStarts(e,t){const i=t.style.lineHeight;t.style.lineHeight=2;const o=e.reduce((t,i,o)=>{const n=o>0?e[o-1].offsetTop:void 0,r=o>0?e[o-1].offsetHeight:void 0,s=i.offsetTop;return o>0&&n+r<=s&&t.push(o),t},[0]);return t.style.lineHeight=i,o}}function so(e){if(e)return"function"==typeof e.getDebug?e.getDebug():e.debug}function lo(e,t,i="unknown case"){if(!e||"function"!=typeof e.getSplitBottom||"function"!=typeof e.setSplitBottom)throw new Error("updateSplitBottom: adapter must expose getSplitBottom() and setSplitBottom().");const o=e.getSplitBottom();let n;if("number"==typeof t)n=t;else{if(!(t instanceof HTMLElement))throw new Error("updateSplitBottom: unexpected value type: "+typeof t);if("function"!=typeof e.computeSplitBottomForElement)throw new Error("updateSplitBottom: adapter must implement computeSplitBottomForElement(element).");n=e.computeSplitBottomForElement(t)}e.setSplitBottom(n);const r=function(e){return e?"function"==typeof e.getSplitBottomLog?e.getSplitBottomLog():e.splitBottomLog||null:null}(e);Array.isArray(r)&&r.push(n);const s=so(e);s&&s._&&console.log(`%cโ™ป๏ธ [${function(e){return e?.label||"๐Ÿ‘ค [paginator.label] element"}(e)}] update splitBottom (with ${t}) \n โ€ข ${i}`,"color: green; font-weight: bold","\n",o||"โ€ขโ€ขโ€ข","->",n,r?`\n log: ${r}`:"")}function ao(e,t,i,o="register page start"){const n=function(e){return e?"function"==typeof e.getRows?e.getRows()||[]:e.rows||[]:[]}(e),r=n.length,s=function(e){return!!e&&("function"==typeof e.shouldAssert?e.shouldAssert():Boolean(e.assert))}(e),l=so(e),a=Number.isInteger(t);if(s&&console.assert(a,`registerPageStartAt: index must be an integer, got: ${t}`),!a)return;if(s&&console.assert(r>0,"registerPageStartAt: no rows to register"),0===r)return;if(0===t)return l&&l._&&console.log("%c ๐Ÿ“ Row #0 forced to next page (no short first fragment)","color:green; font-weight:bold"),void((n[0]instanceof HTMLElement||"number"==typeof n[0])&&lo(e,n[0],`${o} (index=0)`));let h=Math.max(1,Math.min(t,r-1));const c=i.at(-1);if(null!=c&&h<=c&&(h=c+1),h>=r)return void(l&&l._&&console.warn(`registerPageStartAt return: computed index (${h}) >= rowsLen (${r})`,"Last split index should not equal rows.length, or the original table will be empty."));i.push(h),l&&l._&&console.log(`%c ๐Ÿ“ Row # ${h} registered as page start`,"color:green; font-weight:bold");const d=n[h];(d instanceof HTMLElement||"number"==typeof d)&&lo(e,d,o)}function ho({owner:e=null,currentRows:t=[]}={}){return{owner:e,currentRows:Array.isArray(t)?t:[],parts:[]}}function co({entries:e,part:t,startIndex:i=null,endIndex:o=null,type:n="unknown",rows:r=[],meta:s}){if(!e||!t)return null;const l=function(e){if(e)return Array.isArray(e.parts)||(e.parts=[]),e.parts}(e);if(!l)return null;const a={part:t,type:n,startIndex:i,endIndex:o,rows:Array.isArray(r)?[...r]:[]};return s&&"object"==typeof s&&Object.keys(s).length&&(a.meta={...s}),l.push(a),a}class go{constructor({config:e,DOM:t,node:o,selector:n}){this._debug=e.debugMode?{...e.debugConfig.table}:{},this._assert=!!e.consoleAssert,this._DOM=t,this._selector=n,this._node=o,this._splitLabelHeightFromConfig=e.splitLabelHeight,this._initConstants(),Object.assign(this,i),this._resetCurrent()}split(e,t,i,o,n){this._setCurrent(e,t,i,o);const r=this._splitCurrentTable();return this._resetCurrent(),r}_initConstants(){this._signpostHeight=parseFloat(this._splitLabelHeightFromConfig)||0,this._minPartLines=2}_resetCurrent(){this._currentTable=void 0,this._currentFirstPageBottom=void 0,this._currentFullPageHeight=void 0,this._currentRoot=void 0,this._currentTableEntries=void 0,this._currentTableRecordedParts=void 0,this._currentTableDistributedRows=void 0,this._currentTableFirstPartContentBottom=void 0,this._currentTableFullPartContentHeight=void 0,this._currentTableTfootHeight=void 0,this._currentTableSplitBottom=void 0,this._logSplitBottom_=[],this._currentRowShellCache=void 0,this._currentOverflowHelpers=void 0,this._currentTableHasRowspan=void 0,this._currentTableHasColspan=void 0,this._currentTableInconsistentCells=void 0,this._currentTableHasUnexpectedChildren=void 0}_setCurrent(e,t,i,o){this._currentTable=e,this._currentFirstPageBottom=t,this._currentFullPageHeight=i,this._currentRoot=o,this._currentRowShellCache=new WeakMap,this._currentOverflowHelpers=this._composeOverflowHelpers()}_prepareCurrentTableForSplitting(){this._lockCurrentTableWidths(),this._collectCurrentTableEntries(),this._updateCurrentTableDistributedRows(),this._currentTableRecordedParts=ho({owner:this._currentTable,currentRows:this._currentTableDistributedRows}),this._currentTableEntries&&(this._currentTableEntries.recordedParts=this._currentTableRecordedParts),this._currentTable.__html2pdf4docRecordedParts=this._currentTableRecordedParts,this._analyzeCurrentTableStructure(),this._collectCurrentTableMetrics()}_lockCurrentTableWidths(){this._node.lockTableWidths(this._currentTable)}_splitCurrentTable(){this._prepareCurrentTableForSplitting(),this._setCurrentTableFirstSplitBottom(),this._debug._&&console.group("%c๐Ÿ“Š _splitCurrentTable()","color:green; background:#eee; padding:3px","\nโ€ข",this._currentTableFirstPartContentBottom,"(1st bottom)","\nโ€ข",this._currentTableFullPartContentHeight,"(full part height)",{table:this._currentTable,rows:[...this._currentTableDistributedRows],rowCount:this._currentTableDistributedRows.length,entries:this._currentTableEntries,root:this._currentRoot});const e=this._resolveCurrentTableDistributedRowsInPlace();if(this._debug._&&console.log("๐Ÿ“Š updated table rows",{rows_new:[...this._currentTableDistributedRows],rowCount_new:this._currentTableDistributedRows.length,splitStartRowIndexes:e}),!e.length)return this.logGroupEnd("[_splitCurrentTable]: there are no splits (!splitStartRowIndexes.length)"),[];let t=this._createTableSlices({splitPoints:e,table:this._currentTable,tableEntries:this._currentTableEntries});return this._node.markSliceCuts([this._currentTable,...t]),this._signpostHeight&&(t=this._extendTableSlices(t)),this._DOM.insertAfter(this._currentTable,...t),this._debug._&&console.log("tableSlices",t),this._debug._&&console.log("[table.split] recordedParts",this._currentTableRecordedParts?.parts),this.logGroupEnd("[_splitCurrentTable]"),[this._currentTable,...t]}_resolveCurrentTableDistributedRowsInPlace(){let e=[];for(let t=0;tNumber.isInteger(e)&&e>0&&e<=this._currentTableDistributedRows.length),"splitStartRowIndexes contains invalid indexes"),this.strictAssert(e.every((e,t,i)=>0===t||e>i[t-1]),"splitStartRowIndexes must be strictly ascending and without duplicates"),this.strictAssert(e.at(-1)!==this._currentTableDistributedRows.length,"Last split index should not equal rows.length, or the original table will be empty."),e}_evaluateAndResolveRow(e,t){const i=e,o=this._currentTableDistributedRows.length;this._debug._&&console.groupCollapsed(`๐Ÿ”ฒ %c Check the Row # ${i} (from ${o})`,"");const n=this._node.paginationBuildRowEvaluationContext({rows:this._currentTableDistributedRows,rowIndex:e,table:this._currentTable,splitBottom:this._currentTableSplitBottom});if(!n?.row)return console.warn("[table.split] Missing row during evaluation.",{rowIndex:e}),this.logGroupEnd(`Row # ${i} (from ${o}) is checked`),e;if(this._debug._){const e=n.fitsCurrentWindow,t=e?"green":"orange",i=e?"<=":">";console.log(`%c๐Ÿ“ does row fit? %c ${e} %c :: ${n.nextMarker} ${i} ${this._currentTableSplitBottom} %c(ฮ”=${n.delta})`,"",`font-weight:bold;color:${t};`,"",`color:${t};`)}if(this._debug._&&console.info({row:n.row,rows:[...this._currentTableDistributedRows]}),n.fitsCurrentWindow)return this._debug._&&console.log(`%c โœ“ Row # ${e}: PASS`,"color:green"),this.logGroupEnd(`Row # ${i} (from ${o}) is checked`),e;const r=this._node.calculateFinalPartReclaimedHeight({signpostHeight:this._signpostHeight,tfootHeight:this._currentTableTfootHeight});if(this._node.paginationCanAbsorbLastRow({evaluation:n,extraCapacity:r,splitBottom:this._currentTableSplitBottom,debug:this._debug}))return this._debug._&&console.log("๐ŸซŸ last-row-fits-without-bottom-signpost: skip split"),this.logGroupEnd(`Row # ${i} (from ${o}) is checked`),e;const s=this._resolveOverflowingRow({evaluation:n,splitStartRowIndexes:t,extraCapacity:r});return this.logGroupEnd(`Row # ${i} (from ${o}) is checked`),s}_resolveOverflowingRow({evaluation:e,splitStartRowIndexes:t,extraCapacity:i}){return this._node.paginationResolveOverflowingRow({evaluation:e,utils:{rowHasSpan:e=>this._rowHasSpan(e),isSlice:e=>this._node.isSlice(e)},handlers:{handleRowWithRowspan:()=>this._node.paginationResolveRowWithRowspan({evaluation:e,splitStartRowIndexes:t,fullPageHeight:this._currentTableFullPartContentHeight,resolveOverflow:({evaluation:e,splitStartRowIndexes:t,availableRowHeight:i,fullPageHeight:o})=>this._forwardOverflowFallback({rowIndex:e.rowIndex,row:e.row,availableRowHeight:i,fullPageHeight:o,splitStartRowIndexes:t,reasonTail:"Row with ROWSPAN โ€” move to next page",reasonFull:"Row with ROWSPAN โ€” scaled TDs to full page",branch:"rowspan"}),debug:this._debug,afterResolve:({tailWindowHeight:e,fullPageHeight:t})=>{this._debug._&&e>=t&&console.warn("[table.fallback] ROWSPAN row required full-page scaling to fit.")}}),handleSplittableRow:()=>this._resolveSplittableRow({evaluation:e,splitStartRowIndexes:t,extraCapacity:i}),handleAlreadySlicedRow:()=>this._node.paginationResolveAlreadySlicedRow({evaluation:e,splitStartRowIndexes:t,fullPageHeight:this._currentTableFullPartContentHeight,debug:this._debug,resolveSplitFailure:({evaluation:e,splitStartRowIndexes:t,availableRowHeight:i,fullPageHeight:o})=>this._forwardOverflowFallback({rowIndex:e.rowIndex,row:e.row,availableRowHeight:i,fullPageHeight:o,splitStartRowIndexes:t,reasonTail:"Slice doesn't fit tail โ€” move to next page",reasonFull:"Scaled TD content to fit full page",branch:"alreadySliced"})})}})}_resolveSplittableRow({evaluation:e,splitStartRowIndexes:t,extraCapacity:i}){const{rowIndex:o}=e;this._debug._&&console.group(`%c ๐Ÿ”ณ Try to split the ROW ${o} %c (from ${this._currentTableDistributedRows.length})`,"color:magenta;","");const n=this._node.paginationResolveSplittableRow({evaluation:e,splitStartRowIndexes:t,extraCapacity:i,fullPageHeight:this._currentTableFullPartContentHeight,minPartLines:this._minPartLines,debug:this._debug,decorateRowSlice:({rowWrapper:e,rowIndex:t,sliceIndex:i})=>{this._DOM.setAttribute(e,`.splitted_row_${t}_part_${i}`)},onBudgetInfo:({evaluation:e,firstPartHeight:t,fullPartHeight:i})=>{this._debug._&&console.info({currRowTop:e.rowTop,"โ€ข splitBottom":this._currentTableSplitBottom,"โ€ข is row sliced?":!1,"remaining page space":e.tailWindowHeight,"first part height":t,"full part height":i})},handlers:{onReplaceRow:({evaluation:e,newRows:t})=>{this._replaceRowInDOM(e.row,t)},onAbsorbTail:({newRows:e,extraCapacity:t})=>{this._node.absorbShortTrailingSliceIfFits({slices:e,extraCapacity:t,ownerLabel:"table",debug:this._debug})},onRefreshRows:({evaluation:e,newRows:t})=>{this._node.paginationRefreshRowsAfterSplit(this._getSplitterAdapter(),{rowIndex:e.rowIndex,rowSlices:t})},onPlacement:({evaluation:e,newRows:i,insufficientRemainingWindow:o,isFirstPartEmptyInAnyTD:n,needsScalingInFullPage:r})=>this._node.paginationHandleRowSlicesPlacement({evaluation:e,table:this._currentTable,newRows:i,insufficientRemainingWindow:o,isFirstPartEmptyInAnyTD:n,needsScalingInFullPage:r,splitStartRowIndexes:t,pageBottom:this._currentTableSplitBottom,fullPageHeight:this._currentTableFullPartContentHeight,debug:this._debug,registerPageStartCallback:({targetIndex:e,reason:i})=>this._registerPageStartAt(e,t,i),scaleProblematicSliceCallback:(e,t)=>{t>0&&(this._debug._&&console.log("โš–๏ธ scaleProblematicCellsToHeight"),this._scaleProblematicCellsToHeight(e,t,this._getRowShellHeights(e)))},applyFullPageScalingCallback:({row:e,needsScalingInFullPage:t,fullPageHeight:i})=>{this._node.paginationApplyFullPageScaling({needsScalingInFullPage:t&&Boolean(e),payload:{row:e,targetHeight:i},scaleCallback:({row:e,targetHeight:t})=>(this._debug._&&console.log("โš–๏ธ scaleProblematicCellsToHeight"),this._scaleProblematicCellsToHeight(e,t,this._getRowShellHeights(e)))})}}),onSplitFailure:({evaluation:e,splitStartRowIndexes:t,availableRowHeight:i,fullPageHeight:o})=>this._forwardOverflowFallback({rowIndex:e.rowIndex,row:e.row,availableRowHeight:i,fullPageHeight:o,splitStartRowIndexes:t,reasonTail:"Split failed โ€” move row to next page",reasonFull:"Scaled TDs to fit full-page",branch:"splitFailure"})}});return this.logGroupEnd(`๐Ÿ”ณ Try to split the ROW ${o} (from ${this._currentTableDistributedRows.length})`),n}_collectCurrentTableEntries(){this._currentTableEntries=this._node.getTableEntries(this._currentTable)}_rowHasSpan(e){const t=[...this._DOM.getChildren(e)];for(const e of t){const t=this._DOM.getElementTagName(e);if("TD"!==t&&"TH"!==t)continue;const i=parseInt(e.getAttribute("rowspan"));if(Number.isFinite(i)&&i>1)return!0}return!1}_collectCurrentTableMetrics(){const e=this._node.getEmptyNodeHeightByProbe(this._currentTable,'',!1),t=this._node.getTopForPageStartCandidate(this._currentTable,this._currentRoot),i=(this._node.getTopWithMargin(this._currentTable,this._currentRoot),this._DOM.getElementOffsetHeight(this._currentTableEntries.caption)||0),o=this._DOM.getElementOffsetTop(this._currentTableDistributedRows[0],this._currentTable)-i||0;this._currentTableTfootHeight=this._DOM.getElementOffsetHeight(this._currentTableEntries.tfoot)||0,this._currentTableFirstPartContentBottom=this._currentFirstPageBottom-t-e-this._signpostHeight,this._currentTableFullPartContentHeight=this._currentFullPageHeight-i-o-this._currentTableTfootHeight-e-2*this._signpostHeight}_getDistributedRows(e){return[...e.rows,...e.tfoot?[e.tfoot]:[]]}_updateCurrentTableDistributedRows(){this._currentTableDistributedRows=this._getDistributedRows(this._currentTableEntries)}_analyzeCurrentTableStructure(){this._currentTableEntries;const e=this._currentTableDistributedRows||[],t=this._node.computeRowFlags({rows:e,DOM:this._DOM,cellTagFilter:(e,t)=>"TFOOT"!==this._DOM.getElementTagName(t.parentNode)&&("TD"===e||"TH"===e)});this._currentTableHasRowspan=t.hasRowspan,this._currentTableHasColspan=t.hasColspan,this._currentTableInconsistentCells=t.inconsistentCells,this._debug._&&(t.hasRowspan&&console.warn("[table.guard] ROWSPAN detected โ€” slicing not implemented; applying conservative fallback.",{table:this._currentTable}),t.hasColspan&&console.warn("[table.guard] COLSPAN present โ€” handled within-row slicing; monitor results.",{table:this._currentTable}),t.inconsistentCells&&console.warn("[table.guard] Inconsistent cell counts across rows โ€” results may vary.",{table:this._currentTable}))}_updateCurrentTableEntriesAfterSplit(e,t){this._currentTableEntries.rows.splice(e,1,...t)}_setCurrentTableFirstSplitBottom(){this._node.getTop(this._currentTableDistributedRows[0],this._currentTable)>this._currentTableSplitBottom?(this._updateCurrentTableSplitBottom(this._currentTableFullPartContentHeight,"SPECIAL CASE: start immediately from the full height of the page"),this._debug._&&console.log("The Row 0 goes to the 2nd page")):this._updateCurrentTableSplitBottom(this._currentTableFirstPartContentBottom,"start with a short first part")}_getPaginatorAdapter(){return{label:"table",getSplitBottom:()=>this._currentTableSplitBottom,setSplitBottom:e=>{this._currentTableSplitBottom=e},computeSplitBottomForElement:e=>this._node.getTop(e,this._currentTable)+this._currentTableFullPartContentHeight,getRows:()=>this._currentTableDistributedRows,shouldAssert:()=>this._assert,getDebug:()=>this._debug,getSplitBottomLog:()=>this._logSplitBottom_}}_getSplitterAdapter(){const e=()=>({rows:this._currentTableDistributedRows||[],DOM:this._DOM,cellTagFilter:(e,t)=>{const i=t?.parentNode;return"TFOOT"!==(i?this._DOM.getElementTagName(i):void 0)&&("TD"===e||"TH"===e)}});return{label:"table",rows:{getCurrentRows:()=>this._currentTableDistributedRows||[],replaceRow:({rowIndex:e,rowSlices:t})=>{this._node.applyRowSlicesToEntriesAfterRowSplit(this._currentTableEntries,e,t)},syncEntries:()=>{this._updateCurrentTableDistributedRows(),this._currentTableRecordedParts&&(this._currentTableRecordedParts.currentRows=this._currentTableDistributedRows)},getGuardConfig:e,onRowsChanged:()=>{this._currentTableRecordedParts&&(this._currentTableRecordedParts.currentRows=this._currentTableDistributedRows)}},guards:{getConfig:e,onFlags:({flags:e})=>{e&&(this._currentTableHasRowspan=Boolean(e.hasRowspan),this._currentTableHasColspan=Boolean(e.hasColspan),this._currentTableInconsistentCells=Boolean(e.inconsistentCells))}}}}_updateCurrentTableSplitBottom(e,t="unknown case"){lo(this._getPaginatorAdapter(),e,t)}_registerPageStartAt(e,t,i="register page start"){ao(this._getPaginatorAdapter(),e,t,i)}_composeOverflowHelpers(){const e=this._node.scaleCellsToHeight.bind(this._node),t=this._getRowShellHeights.bind(this),i={ownerLabel:"table",registerPageStartCallback:this._registerPageStartAt.bind(this),debugLogger:this._debug&&this._debug._?(e,t)=>console.log(e,t):void 0,scaleProblematicCellsCallback:(i,o,n)=>this._node.scaleRowCellsToHeight({ownerLabel:"table",DOM:this._DOM,row:i,targetHeight:o,cachedShells:n,getRowShellHeightsCallback:t,scaleCellsToHeightCallback:e})};return this._currentOverflowHelpers=i,i}_scaleProblematicCellsToHeight(e,t,i){return(this._currentOverflowHelpers||this._composeOverflowHelpers()).scaleProblematicCellsCallback(e,t,i)}_forwardOverflowFallback({rowIndex:e,row:t,availableRowHeight:i,fullPageHeight:o,splitStartRowIndexes:n,reasonTail:r,reasonFull:s,branch:l}){const a=this._currentOverflowHelpers||this._composeOverflowHelpers(),h={ownerLabel:`table:${l}`,rowIndex:e,row:t,availableRowHeight:i,fullPageHeight:o,splitStartRowIndexes:n,reasonTail:r,reasonFull:s,registerPageStartCallback:a.registerPageStartCallback,scaleProblematicCellsCallback:a.scaleProblematicCellsCallback,debugLogger:a.debugLogger};return this._debug._&&console.log(`%c[table.overflow] branch=${l} rowIndex=${e} tail=${i} full=${o}`,"color:orange; font-weight:bold",{reasonTail:r,reasonFull:s}),"splitFailure"===l?this._node.handleRowSplitFailure(h):this._node.handleRowOverflow(h)}_getRowShellHeights(e){if(!this._currentRowShellCache)return this._node.getTableRowShellHeightByTD(e);if(this._currentRowShellCache.has(e))return this._currentRowShellCache.get(e);const t=this._node.getTableRowShellHeightByTD(e);return this._currentRowShellCache.set(e,t),t}_createTableSlice({startId:e,endId:t,table:i,tableEntries:o}){this._debug._&&console.group(`[CREATE Table Slice] range: [${e}, ${t})`),this.strictAssert(Number.isInteger(e)&&(Number.isInteger(t)||t===1/0),`[createTableSlice] invalid bounds: startId=${e}, endId=${t}`);const n=o&&o.rows?o.rows.length:0;this.strictAssert(n>=0,`[createTableSlice]: invalid rows length: ${n}`),this.strictAssert(e>0&&t>0&&ethis._createTableSlice({startId:e,endId:o===n.length-1?1/0:n[o+1],table:t,tableEntries:i}))}_extendTableSlices(e){return e.reduce((e,t,i,o)=>{const n=0===i,r=i===o.length-1;return n&&e.push(this._createBottomSignpost()),e.push(this._node.createForcedPageBreak()),e.push(this._createTopSignpost()),e.push(t),!r&&e.push(this._createBottomSignpost()),e},[])}_createTopSignpost(){return this._node.createSignpost("(table continued)",this._signpostHeight)}_createBottomSignpost(){return this._node.createSignpost("(table continues on the next page)",this._signpostHeight)}_replaceRowInDOM(e,t){this._debug._&&this._DOM.setAttribute(e,".๐Ÿšซ_must_be_removed"),this._DOM.insertInsteadOf(e,...t)}}class po{constructor({config:e,DOM:t,node:i,selector:o}){this._debug=e.debugMode?{...e.debugConfig.tableLike}:{},this._DOM=t,this._selector=o,this._node=i,this._minLeftLines=2,this._minDanglingLines=2,this._minBreakableLines=this._minLeftLines+this._minDanglingLines,this._minLeftRows=1,this._minDanglingRows=1,this._minBreakableRows=1,this._minPreFirstBlockLines=3,this._minPreLastBlockLines=3,this._minPreBreakableLines=this._minPreFirstBlockLines+this._minPreLastBlockLines,this._minBreakableGridRows=4,this._imageReductionRatio=.8,this._signpostHeight=parseFloat(e.splitLabelHeight)||0}split(e,t,i,o,n){const r=n||this._DOM.getComputedStyle(e);this._debug._&&console.log("root",o);const s=this._node.getPreparedChildren(e),l=this._node.getTop(e,o),a=this._node.getEmptyNodeHeightByProbe(e),h=i-a;let c=s,d=0,g=[],p=t-l-a;const u=r.position;"relative"!=u&&this._DOM.setStyles(e,{position:"relative"});for(let t=0;tp&&(t&&g.push(t),t&&(d+=1),p=t?this._node.getTop(i,e)+h:h)}if(this._DOM.setStyles(e,{position:u}),!g.length)return this._debug._&&console.log("splitters.length",g.length),[];g.push(null);const _=g.map((t,i,o)=>{const n=this._node.createSliceWrapper(e),r=o[i-1]||0,s=t||o[o.length];return this._DOM.insertAtEnd(n,...c.slice(r,s)),n});return this._node.markSliceCuts(_),this._DOM.replaceNodeContentsWith(e,..._),this._DOM.removeAllClasses(e),this._DOM.removeAllStyles(e),this._DOM.setStyles(e,{display:"contents"}),this._DOM.setAttribute(e,"[slough-node]",""),_}}class uo{constructor({config:e,DOM:t,node:o,selector:n}){this._debug=e.debugMode?{...e.debugConfig.grid}:{},this._assert=!!e.consoleAssert,Object.assign(this,i),this._DOM=t,this._selector=n,this._node=o,this._resetCurrent(),this._minBreakableGridRows=1,this._minGridRowContentLines=2,this._gridCellLineHeightCache=new WeakMap,this._gridComputedStyleCache=new WeakMap,this._signpostHeight=parseFloat(e.splitLabelHeight)||0}split(e,t,i,o,n){this._resetCurrent(),this._debug._&&console.group("%c split Grid Node","background:#00FFFF",e);const r=this._node.getPreparedChildren(e);this._node.lockNodesWidths(r);const s=n||this._getComputedStyleCached(e);if(!r.length)return this._node.setInitStyle(!1,e,s),this._debug._&&console.groupEnd(),[];this._node.setInitStyle(!0,e,s);const l=this._scanGridLayout(e,s);if(!l.safe)return this._debug._&&console.warn("[grid.split] skip unsafe layout",l),this._debug._&&console.warn("[grid.split] Unsupported grid layout detected; keeping original grid intact.",l),this._node.setInitStyle(!1,e,s),this._debug._&&console.groupEnd(),[];const a=[];let h=!1,c=!1;const d=new Set;let g=null,p=null,u=null;r.forEach(t=>{const i=this._getComputedStyleCached(t),o=parseInt(i.gridRowStart,10),n=Number.isFinite(o),r=this._node.getTop(t,e),s=this._node.getBottom(t,e);let l=!1;l=!a.length||(n&&null!=g?o!==g:null!=u?r>=u-.5:null==p||Math.abs(r-p)>.5),l?(a.push([t]),g=n?o:null,p=r,u=s):(a[a.length-1].push(t),n&&null==g&&(g=o),(null==p||ru)&&(u=s));const _=i.gridRowEnd||"",f=i.gridColumnEnd||"";h=h||_.includes("span"),c=c||f.includes("span"),n&&d.add(o)});const _=d.size>0&&Math.max(...d)>a.length;if(_)return this._debug._&&console.warn("[grid.split]","Unsupported implicit row gap detected; keeping grid unsplit.",{hasImplicitRowGaps:_}),this._node.setInitStyle(!1,e,s),this._debug._&&console.groupEnd(),[];if(h||c)return this._debug._&&console.warn("[grid.split]","Grid contains row/column spans; using fallback (move row to next page).",{hasRowSpan:h,hasColumnSpan:c}),this._debug._&&console.groupEnd(),this._fallbackMoveGridToNextPage({gridNode:e,nodeComputedStyle:s});this.log("grid.split","currentRows:",a);const f=this._node.getTop(e,o),m=this._node.getEmptyNodeHeightByProbe(e),b=t-f-m,w=i-m;if(this.log("grid.split",{firstPartHeight:b,fullPagePartHeight:w}),this._currentGridNode=e,this._currentGridRows=a,this._currentGridFullPartHeight=w,this._currentGridSplitLog=[],this._currentGridEntries=ho({owner:e,currentRows:a}),this._currentGridRecordedParts=this._currentGridEntries,this._currentGridNode.__html2pdf4docRecordedParts=this._currentGridRecordedParts,this._currentGridShellCache=new WeakMap,a.length0?Math.floor(t):1;let n=0;return()=>{if(n+=1,n<=o)return;const t={label:e,iterations:n,limit:o};throw i&&console.assert(!1,`\n\n โ›” [${e}] โ™พ๏ธ loop guard triggered`,t),new Error(`\n โ›” [${e}] โ™พ๏ธ loop guard triggered`)}}({label:"grid.split",limit:Math.max(1,6*(a.length||1)),assert:this._assert});this._updateCurrentGridSplitBottom(b,"start with initial window");for(let t=0;tthis._buildGridSplit({startId:o[i-1]||0,endId:t,node:e,entries:M})).filter(Boolean).map(e=>e.part),this._createAndInsertGridFinalSlice({node:e,entries:M,startId:C})];return this.log("grid.split",{splitStartRowIndexes:S,splits:E,recordedParts:this._currentGridRecordedParts?.parts}),this._node.setInitStyle(!1,e,s),this._resetCurrent(),this.logGroupEnd("split Grid Node"),E}_fallbackMoveGridToNextPage({gridNode:e,nodeComputedStyle:t}){return this._node.setInitStyle(!1,e,t),this._resetCurrent(),[]}_resetCurrent(){this._currentGridNode=void 0,this._currentGridRows=void 0,this._currentGridEntries=void 0,this._currentGridRecordedParts=void 0,this._currentGridSplitBottom=void 0,this._currentGridFullPartHeight=void 0,this._currentGridSplitLog=void 0,this._currentGridRowFlags=void 0,this._currentGridShellCache=void 0,this._gridCellLineHeightCache=new WeakMap,this._gridComputedStyleCache=new WeakMap}_getGridSplittableHandlers({evaluation:e,splitStartRowIndexes:t}){return{getRowSliceAdapter:({row:t})=>this._createGridRowSliceAdapter({row:t,rowIndex:e.rowIndex}),onReplaceRow:({newRows:t})=>{this._removeOriginalGridRowCells(e.row),this._node.paginationRefreshRowsAfterSplit(this._getSplitterAdapter(),{rowIndex:e.rowIndex,rowSlices:t})},onAbsorbTail:()=>{},onRefreshRows:({newRows:t})=>{this._node.paginationRefreshRowsAfterSplit(this._getSplitterAdapter(),{rowIndex:e.rowIndex,rowSlices:t})},onPlacement:({evaluation:e,newRows:i,insufficientRemainingWindow:o,isFirstPartEmptyInAnyTD:n,needsScalingInFullPage:r})=>this._node.paginationHandleRowSlicesPlacement({evaluation:e,table:this._currentGridNode,newRows:i,insufficientRemainingWindow:o,isFirstPartEmptyInAnyTD:n,needsScalingInFullPage:r,splitStartRowIndexes:t,pageBottom:this._currentGridSplitBottom,fullPageHeight:this._currentGridFullPartHeight,debug:this._debug,resolveRowBounds:e=>this._getRowBounds(e,this._currentGridNode),registerPageStartCallback:({targetIndex:e,reason:i})=>this._registerPageStartAt(e,t,i),scaleProblematicSliceCallback:(e,t)=>this._scaleGridCellsToHeight(e,t),applyFullPageScalingCallback:({row:e,needsScalingInFullPage:t,fullPageHeight:i})=>{this._node.paginationApplyFullPageScaling({needsScalingInFullPage:t&&Boolean(e),payload:{cells:e,targetHeight:i},scaleCallback:({cells:e,targetHeight:t})=>this._scaleGridCellsToHeight(e,t)})}}),onSplitFailure:({evaluation:e,splitStartRowIndexes:t,availableRowHeight:i,fullPageHeight:o})=>this._forwardGridOverflowFallback({evaluation:e,splitStartRowIndexes:t,availableRowHeight:i,fullPageHeight:o,branch:"splitFailure"})}}_forwardGridOverflowFallback({evaluation:e,splitStartRowIndexes:t,availableRowHeight:i,fullPageHeight:o=this._currentGridFullPartHeight,branch:n,reasonTail:r,reasonFull:s}){const l=this._composeGridOverflowHelpers(),a={ownerLabel:`grid:${n}`,gridNode:this._currentGridNode,evaluation:e,rowIndex:e.rowIndex,row:e.row,availableRowHeight:i,fullPageHeight:o,splitStartRowIndexes:t,reasonTail:r||("splitFailure"===n?"Grid split failed โ€” move row to next page":"Grid slice overflow โ€” move row to next page"),reasonFull:s||("splitFailure"===n?"Grid split failed โ€” scaled cells to full page":"Grid slice overflow โ€” scaled cells to full page"),registerPageStartCallback:l.registerPageStartCallback,scaleProblematicCellsCallback:l.scaleProblematicCellsCallback,debugLogger:l.debugLogger};return this._debug._&&console.log("[grid.overflow]",n,a),"splitFailure"===n?this._node.handleRowSplitFailure(a):this._node.handleRowOverflow(a)}_buildGridRowEvaluation({rows:e,rowIndex:t,gridNode:i,splitBottom:o}){if(!Array.isArray(e))return null;const n=e[t];if(!n)return null;const r=Array.isArray(n)?new Array(n.length):null,{top:s,bottom:l}=this._getRowBounds(n,i),a=e[t+1],h=a?this._getRowTop(a,i):l,c=h-o;return{rowIndex:t,row:n,rowTop:s,rowBottom:l,nextMarker:h,delta:c,tailWindowHeight:o-s,isLastRow:!a,fitsCurrentWindow:c<=0,cellStyles:r}}_composeGridOverflowHelpers(){return{registerPageStartCallback:this._registerPageStartAt.bind(this),scaleProblematicCellsCallback:(e,t)=>!!Array.isArray(e)&&this._scaleGridCellsToHeight(e,t),debugLogger:this._debug&&this._debug._?(e,t)=>console.log(e,t):void 0}}_resolveGridOverflowingRow({evaluation:e,splitStartRowIndexes:t}){return this._node.paginationResolveOverflowingRow({evaluation:e,utils:{rowHasSpan:()=>!1,isSlice:e=>this._isGridRowSlice(e)},handlers:{handleRowWithRowspan:()=>(this._debug._&&console.warn("[grid.split] ROWSPAN guard triggered unexpectedly.",{evaluation:e}),this._registerPageStartAt(e.rowIndex,t,"Grid ROWSPAN fallback โ€” move row to next page"),e.rowIndex-1),handleSplittableRow:()=>this._resolveGridSplittableRow({evaluation:e,splitStartRowIndexes:t}),handleAlreadySlicedRow:()=>this._forwardGridOverflowFallback({evaluation:e,splitStartRowIndexes:t,branch:"alreadySliced"})}})}_resolveGridSplittableRow({evaluation:e,splitStartRowIndexes:t}){const{rowIndex:i}=e;this._debug._&&console.group("%c[grid.split] Stage5 โ€” splittable row","color:#0080ff",{rowIndex:i,row:e.row,tailWindowHeight:e.tailWindowHeight});const o=this._estimateGridRowMeaningfulSpace({row:e.row,cellStyles:e.cellStyles,minContentLines:this._minGridRowContentLines});if(!(o>0))return console.warn("[grid.metrics] Meaningful row space is unavailable; falling back to overflow handler."),this._forwardGridOverflowFallback({evaluation:e,splitStartRowIndexes:t,availableRowHeight:e.tailWindowHeight,fullPageHeight:this._currentGridFullPartHeight,branch:"metricsMissing",reasonTail:"Grid row metrics missing โ€” move row to next page",reasonFull:"Grid row metrics missing โ€” scaled cells to full page"});const n=this._node.paginationCalculateRowSplitBudget({tailWindowHeight:e.tailWindowHeight,minMeaningfulRowSpace:o,fullPartHeight:this._currentGridFullPartHeight,debug:this._debug}),r=this._node.paginationSplitRow({rowIndex:i,row:e.row,firstPartHeight:n.firstPartHeight,fullPageHeight:this._currentGridFullPartHeight,debug:this._debug,decorateRowSlice:({rowWrapper:e,rowIndex:t,sliceIndex:i})=>{e instanceof HTMLElement&&this._DOM.setAttribute(e,`.grid_row_${t}_part_${i}`)},rowAdapter:this._createGridRowSliceAdapter({row:e.row,rowIndex:i,cellStyles:e.cellStyles})}),s=this._node.paginationProcessRowSplitResult({evaluation:e,splitResult:r,splitStartRowIndexes:t,insufficientRemainingWindow:n.insufficientRemainingWindow,extraCapacity:0,fullPageHeight:this._currentGridFullPartHeight,debug:this._debug,handlers:this._getGridSplittableHandlers({evaluation:e,splitStartRowIndexes:t})});return this.logGroupEnd("[grid.split] Stage5 โ€” splittable row"),s}_createGridRowSliceAdapter({row:e,rowIndex:t,cellStyles:i}){if(!Array.isArray(e))return null;const o=this._currentGridNode,n=e[0]||null,r=this;return{getParentContainer:()=>o,getOriginalCells:()=>[...e],getShellHeights:()=>r._getGridShellHeights(e,i),markOriginalRow:({cells:e})=>{e.forEach(e=>r._node.setFlagSlice(e))},beginRow:()=>({fragment:r._DOM.createDocumentFragment(),cells:[]}),cloneCellFallback:e=>r._DOM.cloneNodeWrapper(e),handleCell:({context:e,cellClone:t})=>{r._node.setFlagSlice(t),e.fragment.append(t),e.cells.push(t)},finalizeRow:({context:e})=>(n&&r._DOM.insertBefore(n,e.fragment),e.cells)}}_removeOriginalGridRowCells(e){Array.isArray(e)&&e.forEach(e=>{e instanceof HTMLElement&&this._DOM.removeNode(e)})}_isGridRowSlice(e){if(Array.isArray(e)){const t=e.find(e=>e instanceof HTMLElement);return!!t&&this._node.isSlice(t)}return!!e&&this._node.isSlice(e)}_getPaginatorAdapter(){return{label:"grid",getSplitBottom:()=>this._currentGridSplitBottom,setSplitBottom:e=>{this._currentGridSplitBottom=e},computeSplitBottomForElement:e=>e&&this._currentGridNode?this._node.getTop(e,this._currentGridNode)+(this._currentGridFullPartHeight||0):this._currentGridSplitBottom||0,getRows:()=>Array.isArray(this._currentGridRows)?this._currentGridRows.map(e=>{if(!e)return null;if(e instanceof HTMLElement)return e;if(Array.isArray(e)){const t=e.find(e=>e instanceof HTMLElement);if(t)return t;const i=this._getRowTop(e,this._currentGridNode);return Number.isFinite(i)?i:null}const t=this._getRowTop(e,this._currentGridNode);return Number.isFinite(t)?t:null}):[],shouldAssert:()=>this._assert,getDebug:()=>this._debug,getSplitBottomLog:()=>this._currentGridSplitLog}}_getSplitterAdapter(){return{label:"grid",rows:{getCurrentRows:()=>this._currentGridRows||[],replaceRow:({rowIndex:e,rowSlices:t})=>{Array.isArray(this._currentGridRows)&&this._node.replaceCurrentRowsAfterRowSplit({currentRows:this._currentGridRows,index:e,rowSlices:t})},syncEntries:()=>{this._currentGridEntries&&(this._currentGridEntries.currentRows=this._currentGridRows),this._currentGridRecordedParts&&(this._currentGridRecordedParts.currentRows=this._currentGridRows)},getGuardConfig:()=>({rows:this._currentGridRows||[],DOM:this._DOM})},guards:{onFlags:({flags:e})=>{this._currentGridRowFlags=e}}}}_updateCurrentGridSplitBottom(e,t="unknown case"){lo(this._getPaginatorAdapter(),e,t)}_registerPageStartAt(e,t,i="register page start"){ao(this._getPaginatorAdapter(),e,t,i)}_scaleGridCellsToHeight(e,t){if(!(Array.isArray(e)&&e.length&&t>0))return!1;const i=this._getGridShellHeights(e),o=this._debug._?e.map(e=>this._DOM.getElementOffsetHeight(e)):null,n=this._node.paginationScaleCellsToHeight({cells:e,targetHeight:t,shells:i});if(this._debug._){const r=e.map(e=>this._DOM.getElementOffsetHeight(e));console.log("[grid.scaleCells] target:",t,"shells:",i,"before:",o,"after:",r,"scaled:",n)}return n}_buildGridSplit({startId:e,endId:t,node:i,entries:o}){const n=o?.currentRows||this._currentGridRows||[];if(e===t)return this._debug._&&console.warn("[grid.split] _buildGridSplit: skip empty slice request",e,t),this.strictAssert(!1,"[grid.split] _buildGridSplit: empty slice encountered"),null;if(this._debug._){const i=n.slice(e,t);console.log(`=> [grid.split] _buildGridSplit: slice rows [${e}, ${t})`,i)}const r=this._createAndInsertGridSlice({startId:e,endId:t,node:i,entries:o}),s=this._collectGridTelemetryRows(n,e,t);return this._recordGridPart(r,{startId:e,endId:t,type:"slice",rows:s}),{part:r,telemetryRows:s}}_createAndInsertGridSlice({startId:e,endId:t,node:i,entries:o}){const n=this._DOM.cloneNodeWrapper(i);this._node.copyNodeWidth(n,i),this._node.setFlagNoBreak(n),e&&this._node.markTopCut(n),this._node.markBottomCut(n),i.before(n);const r=o?.currentRows||fallbackCurrentRows||[],s=this&&this._DOM&&"function"==typeof this._DOM.isElementNode?this._DOM.isElementNode.bind(this._DOM):null,l=r.slice(e,t).flat().map(e=>{if(!e)return null;if(s&&s(e))return e;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return e;const t=e.element;if(t){if(s&&s(t))return t;if("undefined"!=typeof HTMLElement&&t instanceof HTMLElement)return t}return null}).filter(Boolean);return this._DOM.insertAtEnd(n,...l),n}_createAndInsertGridFinalSlice({node:e,entries:t,startId:i}){const o=e;this._node.markTopCut(o),this._node.setFlagNoBreak(o);const n=t?.currentRows||this._currentGridRows||[],r=this._collectGridTelemetryRows(n,i);return this._recordGridPart(o,{startId:i,endId:n.length,type:"final",rows:r}),o}_collectGridTelemetryRows(e,t,i){if(!Array.isArray(e))return[];return e.slice(t,"number"==typeof i?i:void 0).map((e,i)=>{const o=Array.isArray(e)?[...e]:[e];return{rowIndex:t+i,row:e,cells:o}})}_recordGridPart(e,t={}){const i=this._currentGridRecordedParts;if(!i||!e)return null;const{startId:o=null,endId:n=null,type:r="unknown",rows:s=[],meta:l}=t||{};return co({entries:i,part:e,startIndex:o,endIndex:n,type:r,rows:s,meta:l})}_estimateGridRowMeaningfulSpace({row:e,cellStyles:t=null,minContentLines:i=this._minGridRowContentLines}){if(!Array.isArray(e)||0===e.length)return console.warn("[grid.metrics] Row payload missing while estimating split budget."),null;const o=this._getGridShellHeights(e,t),n=Array.isArray(t)?t:null,r=Math.max(1,i);let s=0;return e.forEach((e,t)=>{if(!(e instanceof HTMLElement))return void console.warn("[grid.metrics] Unexpected non-element cell in row; ignoring during split budget calculation.",{cell:e,index:t});let i=n?n[t]:null;i||(i=this._getComputedStyleCached(e),n&&(n[t]=i));const l=this._resolveGridCellLineHeight({cell:e,style:i}),a=(o?.[t]||0)+l*r;s=Math.max(s,a)}),s>0?s:(console.warn("[grid.metrics] Failed to measure meaningful row space."),null)}_resolveGridCellLineHeight({cell:e,style:t}){const i=this._gridCellLineHeightCache,o=i?.get(e);if(o>0)return o;t||(console.warn("[grid.metrics] style not passed for _resolveGridCellLineHeight",{cell:e}),t=this._getComputedStyleCached(e));let n=parseFloat(t?.lineHeight);if(n>0)return i?.set(e,n),n;const r=parseFloat(t?.fontSize);if(Number.isFinite(r)&&r>0){const t=1.2*r;return i?.set(e,t),t}if(n=this._node.getLineHeight(e),n>0)return i?.set(e,n),n;return i?.set(e,16),16}_getGridShellHeights(e,t=null){if(this._currentGridShellCache||(this._currentGridShellCache=new WeakMap),this._currentGridShellCache.has(e))return this._currentGridShellCache.get(e);const i=Array.isArray(e)?e:[e].filter(Boolean),o=this._computeGridCellShellHeights(i,t);return this._currentGridShellCache.set(e,o),o}_getComputedStyleCached(e){if(!e)return console.warn("[grid.split] the element was not passed to _getComputedStyleCached"),null;const t=this._gridComputedStyleCache;if(!t)return this._DOM.getComputedStyle(e);const i=t.get(e);if(i)return i;const o=this._DOM.getComputedStyle(e);return t.set(e,o),o}_computeGridCellShellHeights(e,t=null){return Array.isArray(e)&&e.length?e.map((e,i)=>{if(!e)return 0;let o=null;t?(o=t[i],o||(o=this._getComputedStyleCached(e),t[i]=o)):o=this._getComputedStyleCached(e);const n=parseFloat(o?.paddingTop)||0,r=parseFloat(o?.paddingBottom)||0,s=parseFloat(o?.borderTopWidth)||0,l=parseFloat(o?.borderBottomWidth)||0,a=parseFloat(o?.marginTop)||0,h=parseFloat(o?.marginBottom)||0,c=n+r+s+l,d=Math.max(0,a)+Math.max(0,h),g=Math.max(0,c);return Math.max(0,g+d)}):[]}_getRowBounds(e,t,i="both"){return this._node.resolveRowBoundsGeneric(e,t,i)}_getRowTop(e,t){return this._getRowBounds(e,t,"top").top}_getRowBottom(e,t){return this._getRowBounds(e,t,"bottom").bottom}_scanGridLayout(e,t){const i=t.gridAutoFlow||"";if(!i.startsWith("row"))return{safe:!1,reason:`grid-auto-flow=${i}`};if(i.includes("dense"))return{safe:!1,reason:"grid-auto-flow dense not supported yet"};if("none"!==(t.gridTemplateAreas||"none"))return{safe:!1,reason:"grid-template-areas present"};const o=t.gridTemplateColumns||"",n=t.gridTemplateRows||"",r=e=>e.includes("subgrid")||e.includes("auto-fit")||e.includes("auto-fill")||e.includes("fit-content");if(r(o)||r(n))return{safe:!1,reason:"complex track sizing (subgrid/auto-fit/fit-content)"};return/\[.*?\]/.test(o)||/\[.*?\]/.test(n)?{safe:!1,reason:"named grid lines detected"}:{safe:!0}}}const _o="background:#999;color:#FFF;padding: 0 4px;";class fo{constructor({config:e,DOM:t,node:o,selector:n}){this._debug=e.debugMode?{...e.debugConfig.pre}:{},this._assert=!!e.consoleAssert,Object.assign(this,i),this._DOM=t,this._selector=n,this._node=o,this._minPreFirstBlockLines=3,this._minPreLastBlockLines=3,this._minPreBreakableLines=this._minPreFirstBlockLines+this._minPreLastBlockLines,this._imageReductionRatio=.8,this._signpostHeight=parseFloat(e.splitLabelHeight)||0}_normalizeLinesInPlace(e){const t=e.splice(0,this._minPreFirstBlockLines).join(""),i=e.splice(-this._minPreLastBlockLines).join("");e.unshift(t),e.push(i)}_analyzeChildren(e){const t={},i=[...e].map(e=>{const i=this._DOM.getNodeType(e);return i===Node.TEXT_NODE?(t.text=!0,"text"):i===Node.ELEMENT_NODE?"BR"===this._DOM.getElementTagName(e)?(t.br=!0,"br"):this._node.isWrappedTextNode(e)?(t.wrappedText=!0,"wrappedText"):(t.node=!0,"node"):(t.other=!0,"other")});return{has:t,items:i}}split(e,t){this._debug._&&console.group("%c ๐Ÿ”ฒ PRE [split]","background:orange",{node:e});const i=()=>{this._debug._&&console.log("%c END ๐Ÿ”ฒ PRE [split]",_o),this._debug._&&console.groupEnd()},o=this._DOM.getChildNodes(e);if(this._debug._&&console.log("_children:",o.length,o),0==o.length)return this._debug._&&console.log("%c END _splitPreNode (not breakable)",_o),i(),[];let n=[];const r=this._analyzeChildren(o);if(this._debug._&&console.log("_childrenTypes:",r.items.length,r),this.strictAssert(!r.has.wrappedText,"Expected to be dealing with unprocessed PRE child nodes, but have wrappedText!",r),this.strictAssert(!(r.has.text&&r.has.wrappedText),"PRE children has text and wrappedText simultaneously",r),r.has.br&&this._debug._&&console.warn("PRE children has BR"),r.has.node){const t=this._DOM.getInnerHTML(e),i=this._node.splitTextByLinesGreedy(t);n.push(...i)}else for(const e of o){if(this._DOM.isTextNode(e)){const t=this._DOM.getNodeValue(e),i=this._node.splitTextByLinesGreedy(t);n.push(...i);continue}if(this._node.isWrappedTextNode(e)){const t=this._DOM.getInnerHTML(e),i=this._node.splitTextByLinesGreedy(t);n.push(...i);continue}}if(this._debug._&&console.log("_lines:",n),n.length{const t=this._node.createWithFlagNoBreak();return this._DOM.setInnerHTML(t,e),t});return this._debug._&&console.log("linesFromNode",s),this._DOM.replaceNodeContentsWith(e,...s),i(),s}slice(e,t,i,o,n){const r=n||this._DOM.getComputedStyle(e),s=["%c_SLICE PreNode\n","color:white"];this._debug._&&console.group("%c_โœ‚๏ธ slice PRE","background:cyan",{node:e,pageBottom:t,fullPageHeight:i});const l=()=>{this._debug._&&console.log("%c END โœ‚๏ธ slice PRE",_o),this._debug._&&console.groupEnd()},a=e=>isNaN(parseFloat(e))?0:Math.ceil(parseFloat(e)),h=(a(r.marginTop),a(r.marginBottom),a(r.paddingTop)),c=a(r.paddingBottom),d=a(r.borderTopWidth),g=a(r.borderBottomWidth),p=a(r.lineHeight),u=this._node.getTop(e,o),_=h+c+d+g;if(this._DOM.getElementOffsetHeight(e)<_+p*this._minPreBreakableLines)return this._debug._&&console.log("%c END โœ‚๏ธ slice (small node)",_o),l(),[];const f=this._DOM.getChildNodes(e);if(0==f.length)return this._debug._&&console.log("%c END โœ‚๏ธ slice (not breakable)",_o),l(),[];if(f.length>1)return this._debug._&&console.log("%c END โœ‚๏ธ slice TODO!",_o),l(),[];{if(this._DOM.isElementNode(f[0])){const e=f[0];return this._debug._&&console.warn("is Element Node",e),this._debug._&&console.log("%c END โœ‚๏ธ slice ???????",_o),l(),[]}this._node.isWrappedTextNode(f[0])&&this._debug._&&console.warn(`is TEXT Node: ${f[0]}`);const o=f[0].wholeText,n=this._node.splitTextByLinesGreedy(o);if(n.length{const t=this._node.createWithFlagNoBreak();return this._DOM.setInnerHTML(t,e),t});this._debug._&&console.log("linesFromNode",c),this._DOM.replaceNodeContentsWith(e,...c);const p=0,m=p+d,b=p+g;let w=t-u-b-_; //! For firstPartSpace we need all margins & preWrapperHeight. //! For firstPartSpaceForSPlitting we only need selected amendments. -const w=i-u-f;this._debug._&&console.log({pageBottom:t,nodeTop:p,preWrapperHeight:u,topCutLineAmend:f,bottomCutLineAmend:m,fullPageHeight:i},{firstPartSpace:b,fullPageSpace:w});let S=0,M=[],P=b;const C=r.position;"relative"!=C&&this._DOM.setStyles(e,{position:"relative"});for(let t=0;tP&&(this._debug._&&console.log(`start a new page: currentBottom (${n}) > floater(${P})`,i),t&&M.push(t),t&&(S+=1),P=t?this._node.getTop(i,e)+w:w)}if(this._DOM.setStyles(e,{position:C}),!M.length)return this._debug._&&console.log("%c END _splitPreNode NO SPLIITERS",on),[];this._debug._&&console.log(...s,"splitters",M);const y=M.map(((t,i,n)=>{const o=this._node.createSliceWrapper(e),r=t,s=i===n.length-1?1/0:n[i+1],l=h.slice(r,s);return this._DOM.insertAtEnd(o,...l),o}));return this._node.markSliceCuts([e,...y]),this._debug._&&console.log(...s,"newPreElementsArray",y),this._DOM.insertAfter(e,...y),this._debug._&&console.log("%c END _splitPreNode",on),this._debug._&&console.groupEnd(),[e,...y]}}}class sn{constructor({config:e,DOM:t,selector:T}){this._config=e,this._DOM=t,this._selector=T,this._debug=e.debugMode?{...e.debugConfig.node}:{},this._assert=!!e.consoleAssert,this._markupDebugMode=this._config.markupDebugMode,Object.assign(this,i),Object.assign(this,n),Object.assign(this,o),Object.assign(this,r),Object.assign(this,s),Object.assign(this,l),Object.assign(this,a),Object.assign(this,h),Object.assign(this,c),Object.assign(this,g),Object.assign(this,d),Object.assign(this,p),Object.assign(this,u),Object.assign(this,_),Object.assign(this,f),Object.assign(this,m),Object.assign(this,b),Object.assign(this,w),Object.assign(this,S),Object.assign(this,M),Object.assign(this,P),Object.assign(this,C),Object.assign(this,y),Object.assign(this,O),this._paragraph=new qi({config:this._config,DOM:this._DOM,selector:this._selector,node:this}),this._pre=new rn({config:this._config,DOM:this._DOM,selector:this._selector,node:this}),this._table=new en({config:this._config,DOM:this._DOM,selector:this._selector,node:this}),this._grid=new nn({config:this._config,DOM:this._DOM,selector:this._selector,node:this}),this._tableLike=new tn({config:this._config,DOM:this._DOM,selector:this._selector,node:this})}clearTemplates(e){this._DOM.getAll("template",e).forEach((e=>this._DOM.removeNode(e)))}notSolved(e){this._DOM.getElementTagName(e);return!1}}function ln(e){return e?.length?e?.split(/\s+/).filter(Boolean):[]}const an="#66CC00",hn=`color: ${an};font-weight:bold`,cn=`border:1px solid ${an};background:#EEEEEE;color:${an};`,gn="background:#999;color:#FFF;padding: 0 4px;";class dn{constructor({config:e,DOM:t,node:n,selector:o,layout:r,referenceWidth:s,referenceHeight:l}){Object.assign(this,i),this._debug=e.debugMode?{...e.debugConfig.pages}:{},this._assert=!!e.consoleAssert,this._selector=o,this._node=n,this._noHangingSelectors=ln(e.noHangingSelectors),this._pageBreakBeforeSelectors=ln(e.pageBreakBeforeSelectors),this._pageBreakAfterSelectors=ln(e.pageBreakAfterSelectors),this._forcedPageBreakSelectors=ln(e.forcedPageBreakSelectors),this._noBreakSelectors=ln(e.noBreakSelectors),this._garbageSelectors=ln(e.garbageSelectors),this._DOM=t,this._root=r.root,this._contentFlow=r.contentFlow,this._referenceWidth=s,this._referenceHeight=l,this._minLeftLines=2,this._minDanglingLines=2,this._minBreakableLines=this._minLeftLines+this._minDanglingLines,this._minLeftRows=1,this._minDanglingRows=1,this._minBreakableRows=1,this._minPreFirstBlockLines=3,this._minPreLastBlockLines=3,this._minPreBreakableLines=this._minPreFirstBlockLines+this._minPreLastBlockLines,this._minBreakableGridRows=4,this._imageReductionRatio=.8,this._signpostHeight=parseFloat(e.splitLabelHeight)||0,this._commonLineHeight=this._node.getLineHeight(this._root),this._minimumBreakableHeight=this._commonLineHeight*this._minBreakableLines,this.pages=[]}calculate(){return this._removeGarbageElements(),this._prepareNoHangingElements(),this._prepareForcedPageBreakElements(),this._prepareNoBreakElements(),this._calculate(),this._debug._&&console.log("%c โœ” Pages.calculate()",cn,this.pages),this.pages}_removeGarbageElements(){if(this._garbageSelectors.length){this._DOM.getAll(this._garbageSelectors,this._contentFlow).forEach((e=>{this._DOM.removeNode(e)}))}}_prepareNoHangingElements(){if(this._noHangingSelectors.length){this._DOM.getAll(this._noHangingSelectors,this._contentFlow).forEach((e=>{this._node.setFlagNoHanging(e);const t=this._node.findLastChildParent(e,this._contentFlow);t&&this._node.setFlagNoHanging(t,"parent")}))}}_prepareNoBreakElements(){if(this._noBreakSelectors.length){this._DOM.getAll(this._noBreakSelectors,this._contentFlow).forEach((e=>this._node.setFlagNoBreak(e)))}}_prepareForcedPageBreakElements(){const e=this._pageBreakBeforeSelectors.length?this._DOM.getAll(this._pageBreakBeforeSelectors,this._contentFlow):[],t=this._pageBreakAfterSelectors.length?this._DOM.getAll(this._pageBreakAfterSelectors,this._contentFlow):[],i=this._DOM.getAll(this._forcedPageBreakSelectors,this._contentFlow);if(e.length){const t=e[0],i=this._node.findFirstChildParent(t,this._contentFlow)||t;this._node.isAfterContentFlowStart(i)&&e.shift()}if(t.length){const e=t.at(-1),i=this._node.findLastChildParent(e,this._contentFlow)||e,n=this._DOM.getRightNeighbor(i);this._node.isContentFlowEnd(n)&&t.pop()}e.length&&e.forEach((e=>{const t=this._node.findBetterForcedPageStarter(e,this._contentFlow);t&&this._DOM.insertBefore(t,this._node.createForcedPageBreak())})),i&&i.forEach((e=>{if(!this._node.isForcedPageBreak(e)){const t=this._node.findBetterForcedPageStarter(e,this._contentFlow);t&&this._DOM.insertBefore(t,this._node.createForcedPageBreak())}})),t.length&&t.forEach((e=>{const t=this._node.findLastChildParent(e,this._contentFlow);t&&(e=t),this._node.isForcedPageBreak(e.nextElementSibling)||this._DOM.insertAfter(e,this._node.createForcedPageBreak())}))}_registerFirstPage(){this._registerPageStart({element:this._DOM.getElement(this._selector.contentFlowStart,this._contentFlow),context:"register First Page"})}_isContentFlowShort(){const e=this._DOM.getElement(this._selector.contentFlowEnd,this._contentFlow),t=this._node.getBottom(e,this._root),i=tthis._registerPageStart({element:e,context:"All Forced Page Break Inside _contentFlow"})))}_calculate(){if(this._debug._&&console.groupCollapsed("โ€ขโ€ข init data โ€ขโ€ข"),this._debug._&&console.log("this._referenceHeight",this._referenceHeight,"\n","this._noHangingSelectors",this._noHangingSelectors,"\n","this._pageBreakBeforeSelectors",this._pageBreakBeforeSelectors,"\n","this._pageBreakAfterSelectors",this._pageBreakAfterSelectors,"\n","this._forcedPageBreakSelectors",this._forcedPageBreakSelectors,"\n","this._noBreakSelectors",this._noBreakSelectors),this._debug._&&console.groupEnd("โ€ขโ€ข init data โ€ขโ€ข"),this._registerFirstPage(),this._isContentFlowShort())return void this._resolveForcedPBInsideContentFlow();const e=this._node.getPreparedChildren(this._contentFlow);this._debug._&&console.groupCollapsed("%c๐Ÿšธ children(contentFlow)",cn),this._debug._&&console.log(e),this._debug._&&console.groupEnd("%c๐Ÿšธ children(contentFlow)",cn),this._parseNodes({array:e})}_registerPageStart({element:e,improveResult:t=!1,type:i="current",context:n=""}){if(this._debug._registerPageStart&&console.log("%c๐Ÿ“","background:yellow;font-weight:bold","\n improveResult:",t,"\n passed pageStart:",e,"\n context:",n),"next"===i&&this._node.isContentFlowEnd(e))return void(this._debug._parseNode&&console.log("๐Ÿ [registerAsPageStart] reaches the ContentFlowEnd element}. SKIP registering.",e));if(this._node.isPageStartElement(e))return void(this._debug._registerPageStart&&console.warn("๐Ÿšจ [_registerPageStart] pageStart candidate is already PageStartElement, return",e));let o=e;t&&(this._debug._registerPageStart&&console.log("[_registerPageStart] improve result:"),o=this._node.findBetterPageStart(o,this.pages.at(-1)?.pageStart,this._root)),this._DOM.getElementOffsetParent(o)||this._debug._registerPageStart&&console.warn("๐Ÿšจ pageStart has no offsetParent. Check the caller.",o);const r=this._node.getTopForPageStartCandidate(o,this._root),s=r+this._referenceHeight,l=this._DOM.getLeftNeighbor(o);this.pages.push({pageStart:o,pageBottom:s,pageTop:r,prevPageEnd:l}),this._node.markPageStartElement(o,this.pages.length),this._debug._registerPageStart&&console.log(`%c๐Ÿ“register page ${this.pages.length}`,"background:yellow;font-weight:bold","\n improved result:",t,"\n pageTop:",r,"\n pageBottom:",s,"\n pageStart:",o)}_parseNodes({previous:e,next:t,array:i,arrayTopParent:n,arrayBottomParent:o}){this._debug._parseNodes&&console.log("๐Ÿ”ต _parseNodes",{array:i,arrayTopParent:n,arrayBottomParent:o});for(let r=0;r"),"๐Ÿ“„",this.pages.length,{currentElement:n}),this._debug._parseNode&&console.log({previousElement:i,currentElement:n,nextElement:o,isFirstChild:e,isLastChild:t,arrayTopParent:r,arrayBottomParent:s}),!o)return this._node.markProcessed(n,"content-flow-end"),this._debug._parseNode&&console.log("%c END _parseNode (!nextElement)",gn),void(this._debug._parseNode&&console.groupEnd());const a=this._node.getBottom(n,this._root),h=s?this._node.getBottom(s,this._root):void 0;let c=h;const g=this._node.getTop(n,this._root);if(void 0!==h&&h-a>=this._referenceHeight){if(c=void 0,this._debug._parseNode&&console.log("๐Ÿช Tail: We got a tail from the lower shells of the last child. Giving up our โ€œlast childโ€ rule here and will try to insert a page break at the end of some parent. ",{arrayParentBottomEdge:h,currentParentBottomEdge:c,currentElementBottom:a,pageBottom:this.pages.at(-1).pageBottom},{currentElement:n,arrayBottomParent:s}),a<=this.pages.at(-1).pageBottom){this._debug._parseNode&&console.log("๐Ÿช Tail: currentElementBottom <= this.pages.at(-1).pageBottom");const e=[];let t=n;for(this._debug._parseNode&&console.log("๐Ÿช Tail: currentElement",n);t&&t!==s;)e.push({element:t,bottom:this._node.getBottom(t,this._root)}),t=t.parentElement;if(t!==s)throw new Error('"bottom" parent not found in the ancestor chain');e.push({element:s,bottom:h}),this._debug._parseNode&&console.log("๐Ÿช Tail: _parents",e),this._debug._parseNode&&console.log("๐Ÿช Tail: current PageBottom",this.pages.at(-1).pageBottom);for(let t=0;tthis.pages.at(-1).pageBottom){this._debug._parseNode&&console.log("๐Ÿช Tail: _parents[i].bottom > this.pages.at(-1).pageBottom",e[t].bottom,">",this.pages.at(-1).pageBottom,e[t].element);const i=this._node.createNeutral();if(i.classList.add("service"),this._DOM.insertAtEnd(e[t].element,i),this._registerPageStart({element:i,context:"_isTailLongerThanPage"}),this._debug._parseNode&&console.log("_registerPageStart",i),this._node.markProcessed(i,"node is ForcedPageBreak"),this._debug._parseNode&&console.log(this.pages.at(-1).pageBottom,h),!(h>this.pages.at(-1).pageBottom))return this._debug._parseNode&&console.log("%c END _parseNode (bottom Tail of parents)",gn),void(this._debug._parseNode&&console.groupEnd());this._debug._&&console.log("๐Ÿงง โ€ข arrayParentBottomEdge > this.pages.at(-1).pageBottom")}return this._debug._parseNode&&console.log("%c END _parseNode (bottom Tail of parents)",gn),void(this._debug._parseNode&&console.groupEnd())}this._debug._parseNode&&console.log("๐Ÿช Tail: currentElementBottom > this.pages.at(-1).pageBottom","DOING NOTHING")} +const S=i-_-m;this._debug._&&console.log({pageBottom:t,nodeTop:u,preWrapperHeight:_,topCutLineAmend:m,bottomCutLineAmend:b,fullPageHeight:i},{firstPartSpace:w,fullPageSpace:S});let M=0,P=[],C=w;const E=r.position;"relative"!=E&&this._DOM.setStyles(e,{position:"relative"});for(let t=0;tC&&(this._debug._&&console.log(`start a new page: currentBottom (${o}) > floater(${C})`,i),t&&P.push(t),t&&(M+=1),C=t?this._node.getTop(i,e)+S:S)}if(this._DOM.setStyles(e,{position:E}),!P.length)return this._debug._&&console.log("%c END โœ‚๏ธ slice - NO SPLIITERS",_o),l(),[];this._debug._&&console.log(...s,"splitters",P);const T=P.map((t,i,o)=>{const n=this._node.createSliceWrapper(e),r=t,s=i===o.length-1?1/0:o[i+1],l=c.slice(r,s);return this._DOM.insertAtEnd(n,...l),n});return this._node.markSliceCuts([e,...T]),this._debug._&&console.log(...s,"newPreElementsArray",T),this._DOM.insertAfter(e,...T),this._debug._&&console.log("%c END โœ‚๏ธ slice PRE",_o),l(),[e,...T]}}}class mo{constructor({config:e,DOM:t,selector:y}){this._config=e,this._DOM=t,this._selector=y,this._debug=e.debugMode?{...e.debugConfig.node}:{},this._assert=!!e.consoleAssert,this._markupDebugMode=this._config.markupDebugMode,Object.assign(this,i),Object.assign(this,o),Object.assign(this,n),Object.assign(this,r),Object.assign(this,s),Object.assign(this,l),Object.assign(this,a),Object.assign(this,h),Object.assign(this,c),Object.assign(this,d),Object.assign(this,g),Object.assign(this,p),Object.assign(this,u),Object.assign(this,_),Object.assign(this,f),Object.assign(this,m),Object.assign(this,b),Object.assign(this,w),Object.assign(this,S),Object.assign(this,M),Object.assign(this,P),Object.assign(this,C),Object.assign(this,E),Object.assign(this,T),Object.assign(this,O),this._paragraph=new ro({config:this._config,DOM:this._DOM,selector:this._selector,node:this}),this._pre=new fo({config:this._config,DOM:this._DOM,selector:this._selector,node:this}),this._table=new go({config:this._config,DOM:this._DOM,selector:this._selector,node:this}),this._grid=new uo({config:this._config,DOM:this._DOM,selector:this._selector,node:this}),this._tableLike=new po({config:this._config,DOM:this._DOM,selector:this._selector,node:this})}clearTemplates(e){this._DOM.getAll("template",e).forEach(e=>this._DOM.removeNode(e))}notSolved(e){this._DOM.getElementTagName(e);return!1}}function bo(e){return e?.length?e?.split(/\s+/).filter(Boolean):[]}const wo="#66CC00",So=`color: ${wo};font-weight:bold`,Mo=`border:1px solid ${wo};background:#EEEEEE;color:${wo};`,Po="background:#999;color:#FFF;padding: 0 4px;";class Co{constructor({config:e,DOM:t,node:o,selector:n,layout:r,referenceWidth:s,referenceHeight:l}){Object.assign(this,i),this._debug=e.debugMode?{...e.debugConfig.pages}:{},this._assert=!!e.consoleAssert,this._selector=n,this._node=o,this._configSelectors={noHanging:e.noHangingSelectors,pageBreakBefore:e.pageBreakBeforeSelectors,pageBreakAfter:e.pageBreakAfterSelectors,forcedPageBreak:e.forcedPageBreakSelectors,noBreak:e.noBreakSelectors,garbage:e.garbageSelectors},this._DOM=t,this._root=r.root,this._contentFlow=r.contentFlow,this._referenceWidth=s,this._referenceHeight=l,this._minLeftLines=2,this._minDanglingLines=2,this._minBreakableLines=this._minLeftLines+this._minDanglingLines,this._minLeftRows=1,this._minDanglingRows=1,this._minBreakableRows=1,this._minPreFirstBlockLines=3,this._minPreLastBlockLines=3,this._minPreBreakableLines=this._minPreFirstBlockLines+this._minPreLastBlockLines,this._minBreakableGridRows=4,this._imageReductionRatio=.8,this._signpostHeight=parseFloat(e.splitLabelHeight)||0,this._commonLineHeight=this._node.getLineHeight(this._root),this._minimumBreakableHeight=this._commonLineHeight*this._minBreakableLines,this._contentFlowEnd,this._contentFlowLastChild,this.pages=[]}calculate(){return this._removeGarbageElements(),this._prepareConfigSelectorConstraints(),this._calculatePageStarts(),this._resolvePageEnds(),this._debug._&&console.log("%c โœ” Pages.calculate()",Mo,this.pages),this.pages}_removeGarbageElements(){const e=bo(this._configSelectors.garbage);if(e.length){this._node.resolveConfigSelectorConstraints(e,this._contentFlow).forEach(e=>{this._DOM.removeNode(e)})}}_prepareConfigSelectorConstraints(){this._debug._&&console.groupCollapsed("๐Ÿ—‚๏ธ prepare config selector constraints");const e=bo(this._configSelectors.noHanging),t=bo(this._configSelectors.pageBreakBefore),i=bo(this._configSelectors.pageBreakAfter),o=bo(this._configSelectors.forcedPageBreak),n=bo(this._configSelectors.noBreak);this._prepareNoHangingElements(e),this._prepareForcedPageBreakElements({beforeSelectors:t,afterSelectors:i,forcedSelectors:o}),this._prepareNoBreakElements(n);this._debug._&&console.groupEnd("๐Ÿ—‚๏ธ prepare config selector constraints")}_prepareNoHangingElements(e){if(e.length){const t=this._node.resolveConfigSelectorConstraints(e,this._contentFlow,"noHangings");t.forEach(e=>{this._node.setFlagNoHanging(e);const t=this._node.findLastChildParent(e,this._contentFlow);t&&this._node.setFlagNoHanging(t,"parent")}),this._debug._&&t.length&&console.log("โœ“ noHangings got the flag")}}_prepareNoBreakElements(e){if(e.length){const t=this._node.resolveConfigSelectorConstraints(e,this._contentFlow,"noBreaks");t.forEach(e=>this._node.setFlagNoBreak(e)),this._debug._&&t.length&&console.log("โœ“ noBreaks got the flag")}}_prepareForcedPageBreakElements({beforeSelectors:e,afterSelectors:t,forcedSelectors:i}){const o=e.length?this._node.resolveConfigSelectorConstraints(e,this._contentFlow,"pageStarters"):[],n=t.length?this._node.resolveConfigSelectorConstraints(t,this._contentFlow,"pageEnders"):[],r=this._node.resolveConfigSelectorConstraints(i,this._contentFlow,"forcedPageStarters");if(o.length){const e=o[0],t=this._node.findFirstChildParent(e,this._contentFlow)||e;this._node.isAfterContentFlowStart(t)&&o.shift()}if(n.length){const e=n.at(-1),t=this._node.findLastChildParent(e,this._contentFlow)||e,i=this._DOM.getRightNeighbor(t);this._node.isContentFlowEnd(i)&&n.pop()}o.length&&o.forEach(e=>{const t=this._node.findBetterForcedPageStarter(e,this._contentFlow);this.strictAssert(t,"findBetterForcedPageStarter should return an element. Returns:",t),this._DOM.insertBefore(t,this._node.createForcedPageBreak()),this._debug._&&console.log("๐Ÿ“„โคต๏ธ pageStarters โ€ข inserted before",{candidate:t,element:e})}),r&&r.forEach(e=>{if(!this._node.isForcedPageBreak(e)){const t=this._node.findBetterForcedPageStarter(e,this._contentFlow);this.strictAssert(t,"findBetterForcedPageStarter should return an element. Returns:",t),this._DOM.insertBefore(t,this._node.createForcedPageBreak()),this._debug._&&console.log("๐Ÿ“„โคต๏ธโคต๏ธ forcedPageStarters โ€ข inserted before",{candidate:t,element:e})}}),n.length&&n.forEach(e=>{const t=this._node.findLastChildParent(e,this._contentFlow);t&&(e=t),this._node.isForcedPageBreak(this._DOM.getRightNeighbor(e))||(this._DOM.insertAfter(e,this._node.createForcedPageBreak()),this._debug._&&console.log("๐Ÿ“„โคด๏ธ pageEnders โ€ข inserted after",{element:e}))})}_registerFirstPage(){this._registerPageStart({element:this._DOM.getElement(this._selector.contentFlowStart,this._contentFlow),context:"register First Page"})}_isContentFlowShort(){const e=this._DOM.getElement(this._selector.contentFlowEnd,this._contentFlow),t=this._node.getBottom(e,this._root),i=tthis._registerPageStart({element:e,context:"All Forced Page Break Inside _contentFlow"}))}_calculatePageStarts(){if(this._registerFirstPage(),this._isContentFlowShort())return void this._resolveForcedPBInsideContentFlow();const e=this._node.getPreparedChildren(this._contentFlow);this._contentFlowEnd=e.at(-1),this._contentFlowLastChild=e.at(-2),this._debug._&&console.groupCollapsed("%c๐Ÿšธ children(contentFlow)",Mo),this._debug._&&console.log(e),this._debug._&&console.groupEnd("%c๐Ÿšธ children(contentFlow)",Mo),this._parseNodes({array:e})}_resolvePageEnds(){for(let e=1;e"),"๐Ÿ“„",this.pages.length,{currentElement:o}),this._debug._parseNode&&console.log({previousElement:i,currentElement:o,nextElement:n,isFirstChild:e,isLastChild:t,arrayTopParent:r,arrayBottomParent:s}),!n)return this._node.markProcessed(o,"content-flow-end"),this._debug._parseNode&&console.log("%c END _parseNode (!nextElement)",Po),void(this._debug._parseNode&&console.groupEnd());const a=this._node.getBottom(o,this._root),h=s?this._node.getBottom(s,this._root):void 0;let c=h;const d=this._node.getTop(o,this._root);if(void 0!==h&&h-a>=this._referenceHeight){if(c=void 0,this._debug._parseNode&&console.log("๐Ÿช Tail: We got a tail from the lower shells of the last child. Giving up our โ€œlast childโ€ rule here and will try to insert a page break at the end of some parent. ",{arrayParentBottomEdge:h,currentParentBottomEdge:c,currentElementBottom:a,pageBottom:this.pages.at(-1).pageBottom},{currentElement:o,arrayBottomParent:s}),a<=this.pages.at(-1).pageBottom){this._debug._parseNode&&console.log("๐Ÿช Tail: currentElementBottom <= this.pages.at(-1).pageBottom");const e=[];let t=o;for(this._debug._parseNode&&console.log("๐Ÿช Tail: currentElement",o);t&&t!==s;)e.push({element:t,bottom:this._node.getBottom(t,this._root)}),t=t.parentElement;if(t!==s)throw new Error('"bottom" parent not found in the ancestor chain');e.push({element:s,bottom:h}),this._debug._parseNode&&console.log("๐Ÿช Tail: _parents",e),this._debug._parseNode&&console.log("๐Ÿช Tail: current PageBottom",this.pages.at(-1).pageBottom);for(let t=0;tthis.pages.at(-1).pageBottom){this._debug._parseNode&&console.log("๐Ÿช Tail: _parents[i].bottom > this.pages.at(-1).pageBottom",e[t].bottom,">",this.pages.at(-1).pageBottom,e[t].element);const i=this._node.createNeutral();if(i.classList.add("service"),this._DOM.insertAtEnd(e[t].element,i),this._registerPageStart({element:i,context:"_isTailLongerThanPage"}),this._debug._parseNode&&console.log("_registerPageStart",i),this._node.markProcessed(i,"node is ForcedPageBreak"),this._debug._parseNode&&console.log(this.pages.at(-1).pageBottom,h),!(h>this.pages.at(-1).pageBottom))return this._debug._parseNode&&console.log("%c END _parseNode (bottom Tail of parents)",Po),void(this._debug._parseNode&&console.groupEnd());this._debug._&&console.log("๐Ÿงง โ€ข arrayParentBottomEdge > this.pages.at(-1).pageBottom")}return this._debug._parseNode&&console.log("%c END _parseNode (bottom Tail of parents)",Po),void(this._debug._parseNode&&console.groupEnd())}this._debug._parseNode&&console.log("๐Ÿช Tail: currentElementBottom > this.pages.at(-1).pageBottom","DOING NOTHING")} //! currentParentBottomEdge is refreshed right before, so descendants see live parent boundaries. -const d=c??a;if(this._debug._parseNode&&console.log("[_parseNode]",{currentBlockBottom:d,currentParentBottomEdge:c,currentElementBottom:a}),this.pages.at(-1).pageStart===n&&(this._node.isNoBreak(n)||d<=this.pages.at(-1).pageBottom))return this._node.markProcessed(n,"node is already registered and fits in the page"),this._debug._parseNode&&console.log("%c END _parseNode (node is already registered and fits in the next page)",gn),void(this._debug._parseNode&&console.groupEnd());if(g>=this.pages.at(-1).pageBottom&&a-g){const t=e&&Boolean(r)?this._node.getTopForPageStartCandidate(r,this._root):void 0,i=Boolean(t)&&g-t>=this._referenceHeight;if(i)this._debug._parseNode&&console.log("๐Ÿช beginning Tail",{parentTop:t,currentParentBottomEdge:c,currentElementTop:g,pageBottom:this.pages.at(-1).pageBottom},{currentElement:n,arrayTopParent:r});else{const e=this._DOM.getComputedStyle(n)?.display||"";if(e.includes("inline")||"contents"===e)return this._debug._parseNode&&console.log("๐Ÿง… current in thin wrapper"),this._registerPageStart({element:n,improveResult:!0,context:"๐Ÿง… current in thin wrapper"}),this._debug._parseNode&&console.log("%c END _parseNode (registered new page start)",gn),void(this._debug._parseNode&&console.groupEnd())}this._registerPageStart({element:n,improveResult:!i,context:"currentElementTop >= this.pages.at(-1).pageBottom"})}if(this._node.isForcedPageBreak(n))return this._registerPageStart({element:n,context:"currentElement is ForcedPageBreak"}),this._node.markProcessed(n,"node is ForcedPageBreak"),this._debug._parseNode&&console.log("%c END _parseNode (isForcedPageBreak)",gn),void(this._debug._parseNode&&console.groupEnd());this.strictAssert(this._DOM.getElementOffsetParent(n),"it is expected that the element has an offset parent",n);const p=this._node.getTop(o,this._root);if(this._debug._parseNode&&console.log(...l,"โ€ข pageBottom",this.pages.at(-1).pageBottom,"\n","โ€ข nextElementTop",p),p<=this.pages.at(-1).pageBottom)return this._debug._parseNode&&console.log("nextElementTop <= this.pages.at(-1).pageBottom",p,"<=",this.pages.at(-1).pageBottom),this._node.markProcessed(n,"node fits"),this._node.findAllForcedPageBreakInside(n).forEach((e=>{this._node.markProcessed(e,"node is ForcedPageBreak (inside a node that fits)"),this._registerPageStart({element:e,context:"All Forced Page Break Inside currentElement"})})),this._debug._parseNode&&console.log("%c END _parseNode (node pass)",gn),void(this._debug._parseNode&&console.groupEnd());{if(this._debug._parseNode&&console.log("nextElementTop > this.pages.at(-1).pageBottom",p,">",this.pages.at(-1).pageBottom),d<=this.pages.at(-1).pageBottom)return this._debug._parseNode&&console.log("currentBlockBottom <= this.pages.at(-1).pageBottom",d,"<=",this.pages.at(-1).pageBottom,"\n register nextElement as pageStart"),this._node.isNoHanging(n)?(this._debug._parseNode&&console.log("currentElement fits / last, and _isNoHanging => move it to the next page"),this._node.markProcessed(n,"it fits & last & _isNoHanging => move it to the next page"),this._registerPageStart({element:n,improveResult:!0,context:"currentElement is NoHanging"}),this._debug._parseNode&&console.log("%c END _parseNode (isNoHanging)",gn),void(this._debug._parseNode&&console.groupEnd())):(this._registerPageStart({element:o,type:"next",context:"currentBlockBottom <= PgBtt && nextElementTop > PgBtt"}),this._node.markProcessed(n,"fits, its bottom falls exactly on the cut"),this._node.markProcessed(o,"starts new page, its top is exactly on the cut"),this._debug._parseNode&&console.log("%c END _parseNode (currentElement fits, register the next element)",gn),void(this._debug._parseNode&&console.groupEnd()));const t=this._node.resolveReplacedElement(n,{prefer:"first"});if(t){const i=this._node.isSVG(t),s=i?this._node.createSignpost(t):t,l=this._node.getTop(s,this._root),a=e&&r?this._node.getTop(r,this._root):void 0,g=r||this._DOM.getParentNode(s),d=this._node.estimateInlineImgGapBelow(g);let p=this.pages.at(-1).pageBottom-l-d;p-=h?h-this._node.getBottom(s,this._root):0;let u=this._referenceHeight-d-(void 0!==a?l-a:0);const _=this._DOM.getElementOffsetHeight(s),f=this._DOM.getElementOffsetWidth(s);if(this._debug._parseNode&&console.log("๐Ÿ–ผ๏ธ๐Ÿ–ผ๏ธ๐Ÿ–ผ๏ธ๐Ÿ–ผ๏ธ๐Ÿ–ผ๏ธ๐Ÿ–ผ๏ธ (if mediaElement)",t,{_imageParent:g,arrayTopParent:r,arrayParentBottomEdge:h,availableImageNodeSpace:p,currentParentBottomEdge:c,currentElement:n,currentImage:s,currentImageHeight:_,currentImageWidth:f,isSvgMedia:i,imgGapBelow:d,parentTopForImage:a}),f>this._referenceWidth&&this._debug._parseNode&&console.warn("%c IMAGE is too wide","color: red"),_this._imageReductionRatio)return this._debug._parseNode&&console.log("Register next elements; ๐Ÿ–ผ๏ธ๐Ÿ–ผ๏ธ๐Ÿ–ผ๏ธ IMG RESIZE to availableImageNodeSpace:",p,n),this._node.markProcessed(n,`IMG with ratio ${m}, and next starts on next`),this._node.fitElementWithinBoundaries({element:t,height:_,width:f,vspace:p,hspace:this._referenceWidth}),this._registerPageStart({element:o,type:"next",context:"current IMG was RESIZED to availableImageNodeSpace"}),this._debug._parseNode&&console.log("%c END _parseNode ๐Ÿ–ผ๏ธ IMG scaled",gn),void(this._debug._parseNode&&console.groupEnd());this._node.markProcessed(n,"IMG starts on next");const b=i?s:t;return this._registerPageStart({element:b,improveResult:!0,context:"move IMG it to next page"}),this._debug._parseNode&&console.log("๐Ÿ–ผ๏ธ register Page Start",n),_>u&&(this._node.fitElementWithinBoundaries({element:t,height:_,width:f,vspace:u,hspace:this._referenceWidth}),this._node.markProcessed(n,"IMG starts on next and resized"),this._debug._parseNode&&console.log("๐Ÿ–ผ๏ธ ..and fit it to full page",n)),this._debug._parseNode&&console.log("%c END",gn),void(this._debug._parseNode&&console.groupEnd())}if(n.style.height){this._debug._parseNode&&console.log("๐Ÿฅ currentElement has HEIGHT",n.style.height);const e=this.pages.at(-1).pageBottom-g,t=p-g,i=e/t,r=this._referenceHeight/t;return this._debug._parseNode&&console.log("\n๐Ÿฅ currentElementTop",g,"\n๐Ÿฅ pageBottom",this.pages.at(-1).pageBottom,"\n๐Ÿฅ availableSpace",e,"\n๐Ÿฅ currentElementContextualHeight",t,"\n๐Ÿฅ availableSpaceFactor",i,"\n๐Ÿฅ fullPageFactor",r),this.strictAssert(i<1),i>.8?(this._debug._parseNode&&console.log("๐Ÿฅ availableSpaceFactor > 0.8: ",i),this._DOM.setStyles(n,{transform:`scale(${i})`,"transform-origin":"top center"}),this._registerPageStart({element:o,type:"next",context:"IMMEDIATELY scale currentElement to the remaining space; availableSpaceFactor > 0.8; currentElement.style.height"}),this._node.markProcessed(n,"processed as a image, has been scaled down within 20%, the next one starts a new page"),this._node.markProcessed(o,"the previous one was scaled down within 20%, and this one starts a new page."),this._debug._parseNode&&console.log("%c END _parseNode (has height & scale)",gn),void(this._debug._parseNode&&console.groupEnd())):(r<1&&(this._debug._parseNode&&console.log("๐Ÿฅ fullPageFactor < 1: ",r),this._node.markProcessed(n,"processed as a image, has been scaled down, and starts new page"),this._DOM.setStyles(n,{transform:`scale(${r})`,"transform-origin":"top center"})),this._debug._parseNode&&console.log("๐Ÿฅ _registerPageStart",n),this._registerPageStart({element:n,improveResult:!0,context:'has height & processed "as a image", has been scaled down, and starts new page'}),this._node.markProcessed(n,"processed as a image, starts new page"),this._debug._parseNode&&console.log("%c END _parseNode (has height & put on next page)",gn),void(this._debug._parseNode&&console.groupEnd()))}if(this._debug._parseNode&&console.log("split or not? \n","currentBlockBottom",d),this._debug._parseNode&&console.log("currentParentBottomEdge || currentElementBottom",{currentParentBottomEdge:c,currentElementBottom:a},"currentBlockBottom > this.pages.at(-1).pageBottom",d,">",this.pages.at(-1).pageBottom),this._DOM.getElementOffsetHeight(n) this.pages.at(-1).pageBottom"}),this._node.markProcessed(n,"starts new page, #fewLines"),this._debug._parseNode&&console.log("%c END _parseNode #fewLines",gn),void(this._debug._parseNode&&console.groupEnd());const u=this._node.getSplitChildren(n,this.pages.at(-1).pageBottom,this._referenceHeight,this._root);this._debug._parseNode&&console.log("try to break it and loop the children:",u);if(u.length){const e=r||n,t=s||n,l=this._node.isFullySPlitted(n)||this._node.isSlough(n);this._debug._parseNode&&console.log({isFullySPlittedParent:l,arrayTopParent:r}),this._parseNodes({array:u,previous:i,next:o,arrayTopParent:l?void 0:e,arrayBottomParent:l?void 0:t}),this._node.markProcessed(n,"getSplitChildren and _parseNodes")}else this._debug._parseNode&&console.log(...l,"_registerPageStart (from _parseNode): \n",n),this._registerPageStart({element:n,improveResult:!0,context:"does not fit, has no children, register it (or parents if improved)"}),this._node.markProcessed(n,"doesn't fit, has no children, register it or parents")}this._debug._parseNode&&console.log("%c END _parseNode [โ€ขโ€ขโ€ข]",gn,{currentElement:n}),this._debug._parseNode&&console.groupEnd()}}class pn{constructor({config:e,DOM:t,node:i,selector:n,layout:o}){this._debug=e.debugMode?{...e.debugConfig.paper}:{},this._DOM=t,this._selector=n,this._node=i,this._frontpageTemplate=o.frontpageTemplate,this._headerTemplate=o.headerTemplate,this._footerTemplate=o.footerTemplate,this._pageChromeSelector=n?.pageChrome||".pageChrome",this._pageBodySpacerSelector=n?.pageBodySpacer||".pageBodySpacer",this._pageHeaderSelector=n?.pageHeader||".pageHeader",this._pageFooterSelector=n?.pageFooter||".pageFooter",this._headerContentSelector=n?.headerContent||".headerContent",this._footerContentSelector=n?.footerContent||".footerContent",this._frontpageElementSelector=n?.frontpageElement||".frontpageElement",this._frontpageContentSelector=n?.frontpageContent||".frontpageContent",this._virtualPaperSelector=n?.virtualPaper||".virtualPaper",this._virtualPaperTopMarginSelector=n?.virtualPaperTopMargin||".virtualPaperTopMargin",this._virtualPaperBottomMarginSelector=n?.virtualPaperBottomMargin||".virtualPaperBottomMargin",this._pageNumberRootSelector=n?.pageNumberRoot||void 0,this._pageNumberCurrentSelector=n?.pageNumberCurrent||void 0,this._pageNumberTotalSelector=n?.pageNumberTotal||void 0,this._paperHeight,this._frontpageFactor,this.headerHeight,this.footerHeight,this.bodyHeight,this.bodyWidth,this._calculatePaperParams()}createPageChrome({pageNumber:e,pageCount:t}){const i=this._node.create(this._pageChromeSelector),n=this._composePageElements({pageNumber:e,pageCount:t});return this._DOM.insertAtEnd(i,n),i}_composePageElements({pageNumber:e,pageCount:t}){const i=this._DOM.createDocumentFragment(),n=this._createPageBodySpacer(this.bodyHeight),o=this._createPageHeader(this._headerTemplate),r=this._createPageFooter(this._footerTemplate);return this._DOM.insertAtEnd(i,this.createVirtualTopMargin(),o,n,r,this.createVirtualBottomMargin()),e&&t&&(this._setPageNumber(o,e,t),this._setPageNumber(r,e,t)),i}createFrontpage(){if(!this._frontpageTemplate)return void(this._debug&&console.warn("[paper โ€ข createFrontpage()] called without a template"));const e=this._node.create(this._frontpageElementSelector);this._DOM.setStyles(e,{height:this.bodyHeight+"px",display:"inline-block",width:"100%","vertical-align":"top"});const t=this._createFrontpageContent(this._frontpageTemplate,this._frontpageFactor);return this._DOM.setStyles(t,{display:"flow-root","transform-origin":"top center",height:"100%"}),this._DOM.insertAtStart(e,t),e}createVirtualTopMargin(){return this._node.create(this._virtualPaperTopMarginSelector)}createVirtualBottomMargin(){return this._node.create(this._virtualPaperBottomMarginSelector)}createVirtualPaper(e){const t=this._node.create(this._virtualPaperSelector);return e&&this._DOM.insertAtEnd(t,this.createVirtualTopMargin(),e,this.createVirtualBottomMargin()),t}_createFrontpageContent(e,t){const i=this._node.create(this._frontpageContentSelector);return e&&this._DOM.setInnerHTML(i,e),t&&this._DOM.setStyles(i,{transform:`scale(${t})`}),i}_createPageBodySpacer(e,t){const i=this._node.create(this._pageBodySpacerSelector);return this._DOM.setStyles(i,{height:e+"px"}),t&&this._DOM.insertAtEnd(i,t),i}_createPageHeader(e){const t=this._node.create(this._pageHeaderSelector);if(e){const i=this._node.create(this._headerContentSelector);this._DOM.setInnerHTML(i,e),this._DOM.insertAtEnd(t,i)}return t}_createPageFooter(e){const t=this._node.create(this._pageFooterSelector);if(e){const i=this._node.create(this._footerContentSelector);this._DOM.setInnerHTML(i,e),this._DOM.insertAtEnd(t,i)}return t}_setPageNumber(e,t,i){const n=this._pageNumberRootSelector?this._DOM.getElement(this._pageNumberRootSelector,e):this._pageNumberRootSelector;if(n){const e=this._DOM.getElement(this._pageNumberCurrentSelector,n),o=this._DOM.getElement(this._pageNumberTotalSelector,n);this._DOM.setInnerHTML(e,t),this._DOM.setInnerHTML(o,i)}}_calculatePaperParams(){const e=this._createPageBodySpacer(),t=this._createPageHeader(this._headerTemplate),i=this._createPageFooter(this._footerTemplate),n=this._node.create(this._virtualPaperSelector);this._DOM.insertAtEnd(n,this.createVirtualTopMargin(),t,e,i,this.createVirtualBottomMargin());const o=this._node.create("#workbench");this._DOM.setStyles(o,{position:"absolute",left:"-3000px"}),this._DOM.insertAtEnd(o,n),this._DOM.insertAtStart(this._DOM.body,o);const r=this._DOM.getElementBCR(n).height,s=this._DOM.getElementOffsetHeight(t)||0,l=this._DOM.getElementOffsetHeight(i)||0,a=this._DOM.getElementOffsetHeight(e),h=this._DOM.getElementOffsetWidth(e),c=this._createFrontpageContent(this._frontpageTemplate);this._DOM.insertAtStart(e,c);const g=this._DOM.getElementOffsetHeight(e),d=g>a?a/g:1;this._DOM.removeNode(o),s>.2*r&&console.warn("It seems that your custom header is too high"),l>.15*r&&console.warn("It seems that your custom footer is too high"),d<1&&console.warn("It seems that your frontpage content is too large. We made it smaller to fit on the page. Check out how it looks! It might make sense to fix this with styles or reduce the text amount."),this._paperHeight=r,this.headerHeight=s,this.footerHeight=l,this.bodyHeight=a,this.bodyWidth=h,this._frontpageFactor=d}}class un{constructor({config:e,DOM:t,selector:n,node:o,pages:r,layout:s,paper:l}){this._config=e,this._debug=e.debugMode?{...e.debugConfig.preview}:{},this._assert=!!e.consoleAssert,Object.assign(this,i),this._DOM=t,this._selector=n,this._node=o,this._virtualPaperGapSelector=n.virtualPaperGap,this._runningSafetySelector=n.runningSafety,this._printPageBreakSelector=n.printPageBreak,this._pageDivider=n.pageDivider,this._virtualPaper=n.virtualPaper,this._virtualPaperTopMargin=n.virtualPaperTopMargin,this._pageBodySpacer=n.pageBodySpacer,this._pages=r,this._root=s.root,this._contentFlow=s.contentFlow,this._paperFlow=s.paperFlow,this._overlayFlow=s.overlayFlow,this._paper=l,this._hasFrontPage=!!s.frontpageTemplate}create(){this._processFrontPage(),this._processPages(),(!0===this._config.mask||"true"===this._config.mask)&&this._addMask(),this._makeRootVisible()}_addMask(){const e=parseInt(this._config.virtualPagesGap),t=parseInt(this._config.paperHeight),i=parseInt(this._config.printTopMargin),n=parseInt(this._config.printBottomMargin),o=parseInt(this._config.headerMargin),r=parseInt(this._config.footerMargin),s=this._paper.headerHeight,l=this._paper.footerHeight,a=this._paper.bodyHeight,h=s?Math.ceil(o/2):0,c=l?Math.ceil(r/2):0,g=s-h,d=l-c,p=a+h+c,u=i+g,_=t+e;this.strictAssert(t===p+g+i+d+n,"Paper size calculation params do not match");const f=function({maskStep:e,maskWindow:t,maskFirstShift:i}){return`\n -webkit-mask-image: linear-gradient(\n black 0,\n black ${t}px,\n transparent ${t}px,\n transparent ${e}px\n );\n mask-image: linear-gradient(\n black 0,\n black ${t}px,\n transparent ${t}px,\n transparent ${e}px\n );\n -webkit-mask-repeat: no-repeat;\n mask-repeat: no-repeat;\n -webkit-mask-size: 100% ${e}px;\n mask-size: 100% ${e}px;\n -webkit-mask-position: 100% ${i}px;\n mask-position: 100% ${i}px;\n -webkit-mask-repeat: repeat-y;\n mask-repeat: repeat-y;\n -webkit-mask-origin: border-box;\n mask-origin: border-box;\n `}({maskFirstShift:u,maskStep:_,maskWindow:p}),m=`\n @media screen {\n ${this._selector.contentFlow} {\n ${f}\n }\n }\n @media print {\n ${this._selector.root}::after {\n /* Safety placeholder for the bottom margin of the paper.\n Remove if the margins at the bottom of the page are replaced with padding.\n Placed under the footer.\n */\n --paper-color: ${this._config.paperColor};\n background: var(--paper-color, white);\n content: '';\n position: fixed;\n pointer-events: none;\n z-index: 11;\n inset: 0;\n top: unset;\n height: ${n+l}px;\n }\n }`;this._node.insertStyle(m,"mask")}_makeRootVisible(){this._DOM.setStyles(this._root,{visibility:"visible"})}_processFrontPage(){if(this._hasFrontPage){const e=this._paper.createFrontpage();this._DOM.insertAtStart(this._contentFlow,e),this._pages.unshift({pageStart:e})}}_processPages(){for(let e=0;e0&&this._debug._&&console.warn(`[preview] There is no page end element before ${e}. Perhaps it's a 'beginningTail'.`),t?this._DOM.setStyles(t,{"margin-top":["0","important"]}):this.strictAssert(0,"[preview] [_preventPageOverflow] current page First Element do not pass! page:",e)}_createPageBreaker(e,t){const i=this._node.create(this._pageDivider);return this._DOM.setAttribute(i,"[page]",`${e+1}`),t&&this._paper.footerHeight&&this._DOM.setStyles(i,{marginTop:this._paper.footerHeight+"px"}),this._paper.headerHeight&&this._DOM.setStyles(i,{paddingBottom:this._paper.headerHeight+"px"}),i}_updatePageStartElementAttrValue(e,t){this._hasFrontPage&&this._node.markPageStartElement(e,`${t+1}`)}_insertPaper(e,t,i){i?this._DOM.insertAtEnd(e,i,t):this._DOM.insertAtEnd(e,t)}_createVirtualPaperGap(){return this._node.create(this._virtualPaperGapSelector)}_createVirtualPaperTopMargin(){return this._paper.createVirtualTopMargin()}_createVirtualPaperBottomMargin(){return this._paper.createVirtualBottomMargin()}_insertFrontpageSpacer(e,t){const i=this._node.create();return this._DOM.setStyles(i,{paddingBottom:t+"px"}),this._DOM.setAttribute(i,".printFrontpageSpacer"),this._DOM.insertAtStart(e,i),i}_insertHeaderSpacer(e,t){const i=this._DOM.createDocumentFragment(),n=this._node.create(this._runningSafetySelector);this._DOM.insertAtEnd(i,this._createVirtualPaperTopMargin(),n),this._DOM.insertAtEnd(e,i)}_insertFooterSpacer({target:e,footerHeight:t,pageSeparator:i,paperSeparator:n,pageIndex:o}){const r=this._DOM.createDocumentFragment(),s=this._createVirtualPaperGap(),l=this._node.create(this._runningSafetySelector);this._DOM.insertAtEnd(r,l,this._createVirtualPaperBottomMargin(),this._node.create(this._printPageBreakSelector),s),this._DOM.insertAtStart(e,r),this._balanceFooter({balancingFooter:l,contentSeparator:s,pageSeparator:i,paperSeparator:n,pageIndex:o})}_balanceFooter({balancingFooter:e,contentSeparator:t,pageSeparator:i,paperSeparator:n,pageIndex:o}){const r=this._node.getTop(i,this._root),s=this._node.getTop(n,this._root),l=this._node.getTop(t,this._root);this.strictAssert(s==r,"balancers in paper layers are misaligned",{pageIndex:o,balancingFooter:e,contentSeparator:t,pageSeparator:i,paperSeparator:n});const a=r-l;this._debug._&&console.log({balancingFooter:e,contentSeparatorTop:l,paperSeparatorTop:s,pageSeparatorTop:r}),this._DOM.setStyles(e,{"margin-bottom":a+"px"}),this.strictAssert(a>=0,`[pages: ${o}-${o+1}] balancer is negative: ${a} < 0`,t)}}class _n{constructor({config:e,DOM:t,selector:i,node:n,layout:o}){this._globalDebugMode=e.debugMode,this._debug=e.debugMode?{...e.debugConfig.toc}:{},this._assert=!!e.consoleAssert,this._DOM=t,this._node=n,this._tocPageNumberSelector=e.tocPageNumberSelector,this._root=o.root,this._contentFlow=o.contentFlow,this._pageDividerSelector=i.pageDivider}render(){this._globalDebugMode&&console.time("Processing TOC"),this._debug._&&console.log(`\n๐Ÿ“‘ TOC: I am here!\n\ntocPageNumberSelector:\n โ€ข ${this._tocPageNumberSelector}\n pageDividerSelector:\n โ€ข ${this._pageDividerSelector}\n `);const e=this._DOM.getAll(this._tocPageNumberSelector,this._contentFlow);if(this._debug._&&console.log("๐Ÿ“‘ tocPageNumberBoxes",e.length),!e.length)return void(this._debug._&&console.log("๐Ÿ“‘ no valid toc"));const t=this._DOM.getAll(this._pageDividerSelector,this._contentFlow).reduce(((e,t,i)=>{const n=this._node.getTop(t,this._root)-1,o=this._DOM.getAttribute(t,"[page]");return e[n]=o,e}),{});this._debug._&&console.log("๐Ÿ“‘ dataFromPagesMarkers",t);const i=e.reduce(((e,t)=>{const i=this._DOM.getDataId(t),n=this._DOM.getElementById(i),o=this._node.getTop(n,this._root);return e[o]={box:t,id:i,targetTop:o},e}),{});this._debug._&&console.log("๐Ÿ“‘ dataFromTOC",i);const n={...t,...i};let o=0;this._debug._&&console.groupCollapsed("Processing obj");for(const e in n){const t=n[e];this._debug._&&console.log(`Processing ${e}: ${t}`),"string"==typeof t?o=t:(t.page=o,this._DOM.setInnerHTML(t.box,o))}this._debug._&&console.groupEnd("Processing obj"),this._debug._&&console.log("๐Ÿ“‘ tocObject",n),this._globalDebugMode&&console.timeEnd("Processing TOC")}}class fn{constructor({config:e,DOM:t,selector:n,node:o,layout:r}){this._config=e,this._selector=n,this._DOM=t,this._node=o,this._layout=r,this._root=r.root,this._assert=!!e.consoleAssert,Object.assign(this,i)}init(){this._config.debugMode&&console.log("๐Ÿ™ i am Validator!");const e=`${this._selector.paperFlow} ${this._selector.virtualPaperGap}`,t=`${this._selector.contentFlow} ${this._selector.virtualPaperGap}`,i=[...this._DOM.getAllElements(e)],n=[...this._DOM.getAllElements(t)],o=i.map((e=>this._node.getTop(e))),r=n.map((e=>this._node.getTop(e,this._root))),s=o.reduce(((e,t,i)=>(t!==r[i]&&e.push(i+1),e)),[]);this.strictAssert(!s.length,"Problems with preview generation on the following pages: ",s)}}const mn="border:1px dashed #cccccc;background:#ffffff;color:#cccccc;";class bn{constructor(e){this._debugMode=e.debugMode,this._preloader,this._preloaderTarget=this._resolveTarget(e)||document.body,this._preloaderBackground=e.preloaderBackground||"white"}create(){this._debugMode&&console.groupCollapsed("%c Preloader ",mn),this._insertStyle(),this._preloader=document.createElement("div"),this._preloader.classList.add("lds-dual-ring"),this._preloaderTarget.append(this._preloader),this._debugMode&&console.groupEnd("%c Preloader ",mn)}remove(){if(!this._preloader)return;let e=1;const t=setInterval((()=>{e<=.1&&(clearInterval(t),this._preloader.remove()),this._preloader.style.opacity=e,e-=.1*e}),50);this._debugMode&&console.log("%c Preloader removed ",mn)}_insertStyle(){const e=document.querySelector("head"),t=document.createElement("style");t.append(document.createTextNode(this._css())),t.setAttribute("data-preloader-style",""),e.append(t)}_css(){return`\n /* PRELOADER */\n .lds-dual-ring {\n position: absolute;\n z-index: 99999;\n top: 0; left: 0; bottom: 0; right: 0;\n background: ${this._preloaderBackground};\n display: flex;\n justify-content: center;\n align-items: center;\n }\n /*\n .lds-dual-ring:after {\n content: " ";\n display: block;\n width: 64px;\n height: 64px;\n margin: 8px;\n border-radius: 50%;\n border: 6px solid #eee;\n border-color: #eee transparent #eee transparent;\n animation: lds-dual-ring 1.2s linear infinite;\n }\n @keyframes lds-dual-ring {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n */\n `}_resolveTarget(e){const t=(e.preloaderTarget||"").trim();return t&&document.querySelector(t)}}class wn{constructor(e){this._debugMode=e.debugMode}run(){let e=[...document.querySelectorAll("object")];this._debugMode&&console.log(e);let t=[];return e.forEach((e=>{const i=new Promise((t=>{e.addEventListener("load",(i=>{this._debugMode&&console.log("โฐ EVENT: object load",e.clientHeight,e.clientWidth,e),t()}))}));t.push(i)})),Promise.all(t)}}const Sn=e=>!0===e||"true"===e;function Mn(e){const t=Array.isArray(e)?[]:{};return Object.entries(e).forEach((([e,i])=>{t[e]=!i||"object"!=typeof i||Mn(i)})),t}const Pn={DOM:{_:!1},layout:{_:!1},pages:{_:!1,_parseNode:!1,_parseNodes:!1,_registerPageStart:!1},paper:{_:!1},preview:{_:!1},toc:{_:!1},node:{_:!1,children:!1,creators:!1,flowFilters:!1,fitters:!1,getters:!1,markers:!1,pageBreaks:!1,positioning:!1,selectors:!1,slicers:!1,splitters:!1,wrappers:!1,pagination:!1},paragraph:{_:!1},grid:{_:!1},pre:{_:!1},table:{_:!1},tableLike:{_:!1},testSignals:{forcedModeLog:!1}};function Cn(e){const t=function(e){let t={debugMode:!1,forcedDebugMode:!1,consoleAssert:!1,markupDebugMode:!1,preloader:!1,preloaderTarget:"",preloaderBackground:"",mask:!0,noHangingSelectors:"",forcedPageBreakSelectors:"",pageBreakBeforeSelectors:"",pageBreakAfterSelectors:"",noBreakSelectors:"",tocPageNumberSelector:"html2pdf-toc-page-number",printLeftMargin:"21mm",printRightMargin:"21mm",printTopMargin:"12mm",printBottomMargin:"12mm",printFontSize:"12pt",paperColor:"white",paperWidth:"210mm",paperHeight:"297mm",headerMargin:"16px",footerMargin:"16px",virtualPagesGap:"16px",splitLabelHeight:"24px"};const i={paperWidth:"210mm",paperHeight:"297mm"},n={paperWidth:"148.5mm",paperHeight:"210mm"};switch((e=function(e){const t={...e};for(const e in t){const i=t[e];if("string"==typeof i){const n=i.toLowerCase();"true"===n||"1"===n?t[e]=!0:"false"!==n&&"0"!==n&&""!==n||(t[e]=!1)}}return t}(e)).printPaperSize){case"A5":case"a5":t={...t,...n};break;default:t={...t,...i}}t={...t,initialRoot:T.init,tocPageNumberSelector:T.tocPageNumber,...e},console.info("[HTML2PDF4DOC] Config:",t);const o={printLeftMargin:t.printLeftMargin,printRightMargin:t.printRightMargin,printTopMargin:t.printTopMargin,printBottomMargin:t.printBottomMargin,printFontSize:t.printFontSize,paperWidth:t.paperWidth,paperHeight:t.paperHeight,headerMargin:t.headerMargin,footerMargin:t.footerMargin,virtualPagesGap:t.virtualPagesGap},r=document.createElement("div");return r.style="\n position:absolute;\n z-index:1000;\n left: 200%;\n ",document.body.append(r),Object.entries(o).forEach((([e,t])=>{r.style.width=t,o[e]=`${Math.trunc(r.getBoundingClientRect().width)}px`})),r.remove(),t={...t,...o},t.noHangingSelectors=t.noHangingSelectors+" H1 H2 H3 H4 H5 H6",t.forcedPageBreakSelectors=t.forcedPageBreakSelectors+" "+T.printForcedPageBreak,t.debugMode&&console.info("Config with converted units:",t),t}(e);t.forcedDebugMode&&(t.debugMode=!0,t.consoleAssert=!0,t.markupDebugMode=!0);const i=t.forcedDebugMode?Mn(Pn):Pn;return{...t,debugConfig:i}}const yn="color:Gray;border:1px solid;";console.info("[HTML2PDF4DOC] Version:","0.3.0");const On=document.currentScript.dataset,Tn=new class{constructor(e){this.params=function(e={}){const t={...e};return[["printWidth","paperWidth"],["printHeight","paperHeight"]].forEach((([e,i])=>{Object.prototype.hasOwnProperty.call(t,e)&&(console.warn(`[HTML2PDF4DOC] Config option "${e}" is deprecated. Use "${i}" instead.`),Object.prototype.hasOwnProperty.call(t,i)||(t[i]=t[e]),delete t[e])})),t}(e),this.forcedDebugMode=Sn(e.forcedDebugMode),this.debugMode=Sn(e.debugMode)||this.forcedDebugMode,this.preloader=e.preloader,this.selector=T,this.config}async render(){console.time("[HTML2PDF4DOC] Total time"),this.debugMode&&console.log("๐Ÿ document.readyState",document.readyState),document.addEventListener("readystatechange",(e=>{this.debugMode&&console.log("๐Ÿ readystatechange",document.readyState)})),this.debugMode&&console.time("โฑ๏ธ await DOMContentLoaded time"),await new Promise((e=>{window.addEventListener("DOMContentLoaded",(t=>{this.debugMode&&console.log("โฐ EVENT: DOMContentLoaded"),e()}))})),this.debugMode&&console.timeEnd("โฑ๏ธ await DOMContentLoaded time"),this.debugMode&&console.time("โฑ๏ธ create Preloader time");const e=new bn(this.params);"true"===this.preloader&&e.create(),this.debugMode&&console.timeEnd("โฑ๏ธ create Preloader time"),this.debugMode&&console.time("โฑ๏ธ Config time"),this.debugMode&&console.groupCollapsed("%c config ",yn+"color:LightGray"),this.config=Cn(this.params),this.debugMode&&console.groupEnd(),this.debugMode&&console.info("โš™๏ธ Current config with debugConfig:",this.config),this.debugMode&&console.timeEnd("โฑ๏ธ Config time"),this.config.debugConfig.testSignals.forcedModeLog&&console.info("[HTML2PDF4DOC] ๐Ÿ› ๏ธ Forced debug mode is active."),this.config.consoleAssert&&console.info("[HTML2PDF4DOC] ๐Ÿงง Assertions enabled."),this.debugMode&&console.time("โฑ๏ธ DOM helpers init time");const t=new F({DOM:window.document,config:this.config});this.debugMode&&console.timeEnd("โฑ๏ธ DOM helpers init time"),this.debugMode&&console.time("โฑ๏ธ node helpers init time");const i=new sn({config:this.config,DOM:t,selector:this.selector});this.debugMode&&console.timeEnd("โฑ๏ธ node helpers init time"),this.debugMode&&console.time("โฑ๏ธ await window load time"),await new Promise((e=>{window.addEventListener("load",(t=>{this.debugMode&&console.log("โฐ EVENT: window load"),e()}))})),this.debugMode&&console.timeEnd("โฑ๏ธ await window load time"),this.debugMode&&console.time("โฑ๏ธ Layout time"),this.debugMode&&console.groupCollapsed("%c Layout ",yn);const n=new k({config:this.config,DOM:t,selector:this.selector,node:i});if(n.create(),this.debugMode&&console.groupEnd(),this.debugMode&&console.timeEnd("โฑ๏ธ Layout time"),!n.success)return void(this.debugMode&&console.error("Failed to create layout.\n\nWe have to interrupt the process of creating PDF preview."));this.debugMode&&console.info("%c calculate Paper params ",yn),this.debugMode&&console.time("โฑ๏ธ Paper time");const o=new pn({config:this.config,DOM:t,selector:this.selector,node:i,layout:n});if(this.debugMode&&console.timeEnd("โฑ๏ธ Paper time"),!o||!o.bodyHeight||!o.bodyWidth)return void(this.debugMode&&console.error("Failed to create paper calculations.\n\nWe have to interrupt the process of creating PDF preview."));this.debugMode&&console.time("โฑ๏ธ Preprocess time"),this.debugMode&&console.groupCollapsed("%c Preprocess ",yn),await new wn(this.config).run(),this.debugMode&&console.groupEnd(),this.debugMode&&console.timeEnd("โฑ๏ธ Preprocess time"),this.debugMode&&console.time("โฑ๏ธ Pages time"),this.debugMode&&console.group("%c Pages ",yn);const r=new dn({config:this.config,DOM:t,selector:this.selector,node:i,layout:n,referenceHeight:o.bodyHeight,referenceWidth:o.bodyWidth}).calculate();this.debugMode&&console.groupEnd(),this.debugMode&&console.timeEnd("โฑ๏ธ Pages time"),this.debugMode&&console.time("โฑ๏ธ Preview time"),this.debugMode&&console.groupCollapsed("%c Preview ",yn),new un({config:this.config,DOM:t,selector:this.selector,node:i,layout:n,paper:o,pages:r}).create(),this.debugMode&&console.groupEnd(),this.debugMode&&console.timeEnd("โฑ๏ธ Preview time"),this.debugMode&&console.time("โฑ๏ธ Toc time"),new _n({config:this.config,DOM:t,selector:this.selector,node:i,layout:n}).render(),this.debugMode&&console.timeEnd("โฑ๏ธ Toc time"),this.debugMode&&console.time("โฑ๏ธ Validator time"),new fn({config:this.config,DOM:t,selector:this.selector,node:i,layout:n}).init(),this.debugMode&&console.timeEnd("โฑ๏ธ Validator time"),t.setAttribute(n.root,"[success]"),t.setAttribute(n.root,"[pages]",r.length),e.remove(),console.info("[HTML2PDF4DOC] Page count:",r.length),console.timeEnd("[HTML2PDF4DOC] Total time")}}(On),En="manual"===On.init;function Dn(){En&&Tn.render()}En&&console.info("HTML2PDF4DOC in manual initialization mode"),!En&&Tn.render(),HTML2PDF4DOC=t})(); \ No newline at end of file +const g=c??a;if(this._debug._parseNode&&console.log("[_parseNode]",{currentBlockBottom:g,currentParentBottomEdge:c,currentElementBottom:a}),this.pages.at(-1).pageStart===o&&(this._node.isNoBreak(o)||g<=this.pages.at(-1).pageBottom))return this._node.markProcessed(o,"node is already registered and fits in the page"),this._debug._parseNode&&console.log("%c END _parseNode (node is already registered and fits in the next page)",Po),void(this._debug._parseNode&&console.groupEnd());if(d>=this.pages.at(-1).pageBottom&&a-d){const t=e&&Boolean(r)?this._node.getTopForPageStartCandidate(r,this._root):void 0,i=Boolean(t)&&d-t>=this._referenceHeight;if(i)this._debug._parseNode&&console.log("๐Ÿช beginning Tail",{parentTop:t,currentParentBottomEdge:c,currentElementTop:d,pageBottom:this.pages.at(-1).pageBottom},{currentElement:o,arrayTopParent:r});else{const e=this._DOM.getComputedStyle(o)?.display||"";if(e.includes("inline")||"contents"===e)return this._debug._parseNode&&console.log("๐Ÿง… current in thin wrapper"),this._registerPageStart({element:o,improveResult:!0,context:"๐Ÿง… current in thin wrapper"}),this._debug._parseNode&&console.log("%c END _parseNode (registered new page start)",Po),void(this._debug._parseNode&&console.groupEnd())}this._registerPageStart({element:o,improveResult:!i,context:"currentElementTop >= this.pages.at(-1).pageBottom"})}if(this._node.isForcedPageBreak(o))return this._registerPageStart({element:o,context:"currentElement is ForcedPageBreak"}),this._node.markProcessed(o,"node is ForcedPageBreak"),this._debug._parseNode&&console.log("%c END _parseNode (isForcedPageBreak)",Po),void(this._debug._parseNode&&console.groupEnd());this.strictAssert(this._DOM.getElementOffsetParent(o),"it is expected that the element has an offset parent",o);const p=this._node.getTop(n,this._root);if(this._debug._parseNode&&console.log(...l,"โ€ข pageBottom",this.pages.at(-1).pageBottom,"\n","โ€ข nextElementTop",p),p<=this.pages.at(-1).pageBottom)return this._debug._parseNode&&console.log("nextElementTop <= this.pages.at(-1).pageBottom",p,"<=",this.pages.at(-1).pageBottom),this._node.markProcessed(o,"node fits"),this._node.findAllForcedPageBreakInside(o).forEach(e=>{this._node.markProcessed(e,"node is ForcedPageBreak (inside a node that fits)"),this._registerPageStart({element:e,context:"All Forced Page Break Inside currentElement"})}),this._debug._parseNode&&console.log("%c END _parseNode (node pass)",Po),void(this._debug._parseNode&&console.groupEnd());{if(this._debug._parseNode&&console.log("nextElementTop > this.pages.at(-1).pageBottom",p,">",this.pages.at(-1).pageBottom),g<=this.pages.at(-1).pageBottom)return this._debug._parseNode&&console.log("currentBlockBottom <= this.pages.at(-1).pageBottom",g,"<=",this.pages.at(-1).pageBottom,"\n register nextElement as pageStart"),this._node.isNoHanging(o)?(this._debug._parseNode&&console.log("currentElement fits / last, and _isNoHanging => move it to the next page"),this._node.markProcessed(o,"it fits & last & _isNoHanging => move it to the next page"),this._registerPageStart({element:o,improveResult:!0,context:"currentElement is NoHanging"}),this._debug._parseNode&&console.log("%c END _parseNode (isNoHanging)",Po),void(this._debug._parseNode&&console.groupEnd())):(this._registerPageStart({element:n,type:"next",context:"currentBlockBottom <= PgBtt && nextElementTop > PgBtt"}),this._node.markProcessed(o,"fits, its bottom falls exactly on the cut"),this._node.markProcessed(n,"starts new page, its top is exactly on the cut"),this._debug._parseNode&&console.log("%c END _parseNode (currentElement fits, register the next element)",Po),void(this._debug._parseNode&&console.groupEnd()));const t=this._node.resolveReplacedElement(o,{prefer:"first"});if(t){const i=this._node.isSVG(t),s=i?this._node.createSignpost(t):t,l=this._node.getTop(s,this._root),a=e&&r?this._node.getTop(r,this._root):void 0,d=r||this._DOM.getParentNode(s),g=this._node.estimateInlineImgGapBelow(d);let p=this.pages.at(-1).pageBottom-l-g;p-=h?h-this._node.getBottom(s,this._root):0;let u=this._referenceHeight-g-(void 0!==a?l-a:0);const _=this._DOM.getElementOffsetHeight(s),f=this._DOM.getElementOffsetWidth(s);if(this._debug._parseNode&&console.log("๐Ÿ–ผ๏ธ๐Ÿ–ผ๏ธ๐Ÿ–ผ๏ธ๐Ÿ–ผ๏ธ๐Ÿ–ผ๏ธ๐Ÿ–ผ๏ธ (if mediaElement)",t,{_imageParent:d,arrayTopParent:r,arrayParentBottomEdge:h,availableImageNodeSpace:p,currentParentBottomEdge:c,currentElement:o,currentImage:s,currentImageHeight:_,currentImageWidth:f,isSvgMedia:i,imgGapBelow:g,parentTopForImage:a}),f>this._referenceWidth&&this._debug._parseNode&&console.warn("%c IMAGE is too wide","color: red"),_this._imageReductionRatio)return this._debug._parseNode&&console.log("Register next elements; ๐Ÿ–ผ๏ธ๐Ÿ–ผ๏ธ๐Ÿ–ผ๏ธ IMG RESIZE to availableImageNodeSpace:",p,o),this._node.markProcessed(o,`IMG with ratio ${m}, and next starts on next`),this._node.fitElementWithinBoundaries({element:t,height:_,width:f,vspace:p,hspace:this._referenceWidth}),this._registerPageStart({element:n,type:"next",context:"current IMG was RESIZED to availableImageNodeSpace"}),this._debug._parseNode&&console.log("%c END _parseNode ๐Ÿ–ผ๏ธ IMG scaled",Po),void(this._debug._parseNode&&console.groupEnd());this._node.markProcessed(o,"IMG starts on next");const b=i?s:t;return this._registerPageStart({element:b,improveResult:!0,context:"move IMG it to next page"}),this._debug._parseNode&&console.log("๐Ÿ–ผ๏ธ register Page Start",o),_>u&&(this._node.fitElementWithinBoundaries({element:t,height:_,width:f,vspace:u,hspace:this._referenceWidth}),this._node.markProcessed(o,"IMG starts on next and resized"),this._debug._parseNode&&console.log("๐Ÿ–ผ๏ธ ..and fit it to full page",o)),this._debug._parseNode&&console.log("%c END",Po),void(this._debug._parseNode&&console.groupEnd())}if(o.style.height){this._debug._parseNode&&console.log("๐Ÿฅ currentElement has HEIGHT",o.style.height);const e=this.pages.at(-1).pageBottom-d,t=p-d,i=e/t,r=this._referenceHeight/t;return this._debug._parseNode&&console.log("\n๐Ÿฅ currentElementTop",d,"\n๐Ÿฅ pageBottom",this.pages.at(-1).pageBottom,"\n๐Ÿฅ availableSpace",e,"\n๐Ÿฅ currentElementContextualHeight",t,"\n๐Ÿฅ availableSpaceFactor",i,"\n๐Ÿฅ fullPageFactor",r),this.strictAssert(i<1),i>.8?(this._debug._parseNode&&console.log("๐Ÿฅ availableSpaceFactor > 0.8: ",i),this._DOM.setStyles(o,{transform:`scale(${i})`,"transform-origin":"top center"}),this._registerPageStart({element:n,type:"next",context:"IMMEDIATELY scale currentElement to the remaining space; availableSpaceFactor > 0.8; currentElement.style.height"}),this._node.markProcessed(o,"processed as a image, has been scaled down within 20%, the next one starts a new page"),this._node.markProcessed(n,"the previous one was scaled down within 20%, and this one starts a new page."),this._debug._parseNode&&console.log("%c END _parseNode (has height & scale)",Po),void(this._debug._parseNode&&console.groupEnd())):(r<1&&(this._debug._parseNode&&console.log("๐Ÿฅ fullPageFactor < 1: ",r),this._node.markProcessed(o,"processed as a image, has been scaled down, and starts new page"),this._DOM.setStyles(o,{transform:`scale(${r})`,"transform-origin":"top center"})),this._debug._parseNode&&console.log("๐Ÿฅ _registerPageStart",o),this._registerPageStart({element:o,improveResult:!0,context:'has height & processed "as a image", has been scaled down, and starts new page'}),this._node.markProcessed(o,"processed as a image, starts new page"),this._debug._parseNode&&console.log("%c END _parseNode (has height & put on next page)",Po),void(this._debug._parseNode&&console.groupEnd()))}if(this._debug._parseNode&&console.log("split or not? \n","currentBlockBottom",g),this._debug._parseNode&&console.log("currentParentBottomEdge || currentElementBottom",{currentParentBottomEdge:c,currentElementBottom:a},"currentBlockBottom > this.pages.at(-1).pageBottom",g,">",this.pages.at(-1).pageBottom),this._DOM.getElementOffsetHeight(o) this.pages.at(-1).pageBottom"}),this._node.markProcessed(o,"starts new page, #fewLines"),this._debug._parseNode&&console.log("%c END _parseNode #fewLines",Po),void(this._debug._parseNode&&console.groupEnd());const u=this._node.getSplitChildren(o,this.pages.at(-1).pageBottom,this._referenceHeight,this._root);this._debug._parseNode&&console.log("try to break it and loop the children:",u);if(u.length){const e=r||o,t=s||o,l=this._node.isSliced(o)||this._node.isSlough(o);this._debug._parseNode&&console.log({isSlicedParent:l,arrayTopParent:r}),this._parseNodes({array:u,previous:i,next:n,arrayTopParent:l?void 0:e,arrayBottomParent:l?void 0:t}),this._node.markProcessed(o,"getSplitChildren and _parseNodes")}else this._debug._parseNode&&console.log(...l,"_registerPageStart (from _parseNode): \n",o),this._registerPageStart({element:o,improveResult:!0,context:"does not fit, has no children, register it (or parents if improved)"}),this._node.markProcessed(o,"doesn't fit, has no children, register it or parents")}this._debug._parseNode&&console.log("%c END _parseNode [โ€ขโ€ขโ€ข]",Po,{currentElement:o}),this._debug._parseNode&&console.groupEnd()}}class Eo{constructor({config:e,DOM:t,node:i,selector:o,layout:n}){this._debug=e.debugMode?{...e.debugConfig.paper}:{},this._DOM=t,this._selector=o,this._node=i,this._frontpageTemplate=n.frontpageTemplate,this._headerTemplate=n.headerTemplate,this._footerTemplate=n.footerTemplate,this._pageChromeSelector=o?.pageChrome||".pageChrome",this._pageBodySpacerSelector=o?.pageBodySpacer||".pageBodySpacer",this._pageHeaderSelector=o?.pageHeader||".pageHeader",this._pageFooterSelector=o?.pageFooter||".pageFooter",this._headerContentSelector=o?.headerContent||".headerContent",this._footerContentSelector=o?.footerContent||".footerContent",this._frontpageElementSelector=o?.frontpageElement||".frontpageElement",this._frontpageContentSelector=o?.frontpageContent||".frontpageContent",this._virtualPaperSelector=o?.virtualPaper||".virtualPaper",this._virtualPaperTopMarginSelector=o?.virtualPaperTopMargin||".virtualPaperTopMargin",this._virtualPaperBottomMarginSelector=o?.virtualPaperBottomMargin||".virtualPaperBottomMargin",this._pageNumberRootSelector=o?.pageNumberRoot||void 0,this._pageNumberCurrentSelector=o?.pageNumberCurrent||void 0,this._pageNumberTotalSelector=o?.pageNumberTotal||void 0,this._paperHeight,this._frontpageFactor,this.headerHeight,this.footerHeight,this.bodyHeight,this.bodyWidth,this._calculatePaperParams()}createPageChrome({pageNumber:e,pageCount:t}){const i=this._node.create(this._pageChromeSelector);this._node.markPageNumber(i,e);const o=this._composePageElements({pageNumber:e,pageCount:t});return this._DOM.insertAtEnd(i,o),i}_composePageElements({pageNumber:e,pageCount:t}){const i=this._DOM.createDocumentFragment(),o=this._createPageBodySpacer(this.bodyHeight);this._node.markPageNumber(o,e);const n=this._createPageHeader(this._headerTemplate),r=this._createPageFooter(this._footerTemplate);return this._DOM.insertAtEnd(i,this.createVirtualTopMargin(),n,o,r,this.createVirtualBottomMargin()),e&&t&&(this._setPageNumber(n,e,t),this._setPageNumber(r,e,t)),i}createFrontpage(){if(!this._frontpageTemplate)return void(this._debug&&console.warn("[paper โ€ข createFrontpage()] called without a template"));const e=this._node.create(this._frontpageElementSelector);this._DOM.setStyles(e,{height:this.bodyHeight+"px",display:"inline-block",width:"100%","vertical-align":"top"});const t=this._createFrontpageContent(this._frontpageTemplate,this._frontpageFactor);return this._DOM.setStyles(t,{display:"flow-root","transform-origin":"top center",height:"100%"}),this._DOM.insertAtStart(e,t),e}createVirtualTopMargin(){return this._node.create(this._virtualPaperTopMarginSelector)}createVirtualBottomMargin(){return this._node.create(this._virtualPaperBottomMarginSelector)}createVirtualPaper(e){const t=this._node.create(this._virtualPaperSelector);return e&&this._DOM.insertAtEnd(t,this.createVirtualTopMargin(),e,this.createVirtualBottomMargin()),t}_createFrontpageContent(e,t){const i=this._node.create(this._frontpageContentSelector);return e&&this._DOM.setInnerHTML(i,e),t&&this._DOM.setStyles(i,{transform:`scale(${t})`}),i}_createPageBodySpacer(e,t){const i=this._node.create(this._pageBodySpacerSelector);return this._DOM.setStyles(i,{height:e+"px"}),t&&this._DOM.insertAtEnd(i,t),i}_createPageHeader(e){const t=this._node.create(this._pageHeaderSelector);if(e){const i=this._node.create(this._headerContentSelector);this._DOM.setInnerHTML(i,e),this._DOM.insertAtEnd(t,i)}return t}_createPageFooter(e){const t=this._node.create(this._pageFooterSelector);if(e){const i=this._node.create(this._footerContentSelector);this._DOM.setInnerHTML(i,e),this._DOM.insertAtEnd(t,i)}return t}_setPageNumber(e,t,i){const o=this._pageNumberRootSelector?this._DOM.getElement(this._pageNumberRootSelector,e):this._pageNumberRootSelector;if(o){const e=this._DOM.getElement(this._pageNumberCurrentSelector,o),n=this._DOM.getElement(this._pageNumberTotalSelector,o);this._DOM.setInnerHTML(e,t),this._DOM.setInnerHTML(n,i)}}_calculatePaperParams(){const e=this._createPageBodySpacer(),t=this._createPageHeader(this._headerTemplate),i=this._createPageFooter(this._footerTemplate),o=this._node.create(this._virtualPaperSelector);this._DOM.insertAtEnd(o,this.createVirtualTopMargin(),t,e,i,this.createVirtualBottomMargin());const n=this._node.create("#workbench");this._DOM.setStyles(n,{position:"absolute",left:"-3000px"}),this._DOM.insertAtEnd(n,o),this._DOM.insertAtStart(this._DOM.body,n);const r=this._DOM.getElementBCR(o).height,s=this._DOM.getElementBCR(t).height||0,l=this._DOM.getElementBCR(i).height||0,a=this._DOM.getElementBCR(e).height,h=this._DOM.getElementBCR(e).width,c=this._createFrontpageContent(this._frontpageTemplate);this._DOM.insertAtStart(e,c);const d=this._DOM.getElementBCR(e).height,g=d>a?a/d:1;this._DOM.removeNode(n),s>.2*r&&console.warn("It seems that your custom header is too high"),l>.15*r&&console.warn("It seems that your custom footer is too high"),g<1&&console.warn("It seems that your frontpage content is too large. We made it smaller to fit on the page. Check out how it looks! It might make sense to fix this with styles or reduce the text amount."),this._paperHeight=r,this.headerHeight=s,this.footerHeight=l,this.bodyHeight=a,this.bodyWidth=h,this._frontpageFactor=g}}class To{constructor({config:e,DOM:t,selector:o,node:n,pages:r,layout:s,paper:l}){this._config=e,this._debug=e.debugMode?{...e.debugConfig.preview}:{},this._assert=!!e.consoleAssert,Object.assign(this,i),this._accumulatedAssertions={},this._DOM=t,this._selector=o,this._node=n,this._virtualPaperGapSelector=o.virtualPaperGap,this._runningSafetySelector=o.runningSafety,this._printPageBreakSelector=o.printPageBreak,this._pageDivider=o.pageDivider,this._virtualPaper=o.virtualPaper,this._virtualPaperTopMargin=o.virtualPaperTopMargin,this._pageBodySpacer=o.pageBodySpacer,this._pages=r,this._root=s.root,this._contentFlow=s.contentFlow,this._paperFlow=s.paperFlow,this._overlayFlow=s.overlayFlow,this._paper=l,this._hasFrontPage=!!s.frontpageTemplate}create(){return this._processFrontPage(),this._processPages(),(!0===this._config.mask||"true"===this._config.mask)&&this._addMask(),this._makeRootVisible(),this._accumulatedAssertions}_addMask(){const e=parseInt(this._config.virtualPagesGap),t=parseInt(this._config.paperHeight),i=parseInt(this._config.printTopMargin),o=parseInt(this._config.printBottomMargin),n=parseInt(this._config.headerMargin),r=parseInt(this._config.footerMargin),s=this._paper.headerHeight,l=this._paper.footerHeight,a=this._paper.bodyHeight,h=s?Math.ceil(n/2):0,c=l?Math.ceil(r/2):0,d=s-h,g=l-c,p=a+h+c,u=i+d,_=t+e;this.strictAssert(t===p+d+i+g+o,"Paper size calculation params do not match");const f=function({maskStep:e,maskWindow:t,maskFirstShift:i}){return`\n -webkit-mask-image: linear-gradient(\n black 0,\n black ${t}px,\n transparent ${t}px,\n transparent ${e}px\n );\n mask-image: linear-gradient(\n black 0,\n black ${t}px,\n transparent ${t}px,\n transparent ${e}px\n );\n -webkit-mask-repeat: no-repeat;\n mask-repeat: no-repeat;\n -webkit-mask-size: 100% ${e}px;\n mask-size: 100% ${e}px;\n -webkit-mask-position: 100% ${i}px;\n mask-position: 100% ${i}px;\n -webkit-mask-repeat: repeat-y;\n mask-repeat: repeat-y;\n -webkit-mask-origin: border-box;\n mask-origin: border-box;\n `}({maskFirstShift:u,maskStep:_,maskWindow:p}),m=`\n @media screen {\n ${this._selector.contentFlow} {\n ${f}\n }\n }\n @media print {\n ${this._selector.root}::after {\n /* Safety placeholder for the bottom margin of the paper.\n Remove if the margins at the bottom of the page are replaced with padding.\n Placed under the footer.\n */\n --paper-color: ${this._config.paperColor};\n background: var(--paper-color, white);\n content: '';\n position: fixed;\n pointer-events: none;\n z-index: 11;\n inset: 0;\n top: unset;\n height: ${o+l}px;\n }\n }`;this._node.insertStyle(m,"mask")}_makeRootVisible(){this._DOM.setStyles(this._root,{visibility:"visible"})}_processFrontPage(){if(this._hasFrontPage){const e=this._paper.createFrontpage();this._DOM.insertAtStart(this._contentFlow,e),this._pages.unshift({pageStart:e,pageEnd:e}),this._pages[1].prevPageEnd=e}}_processPages(){for(let e=0;e0&&this._debug._&&console.warn(`[preview] There is no page end element before ${e}. Perhaps it's a 'beginningTail'.`)}_createPageBreaker(e,t){const i=this._node.create(this._pageDivider);return this._DOM.setAttribute(i,"[page]",`${e+1}`),t&&this._paper.footerHeight&&this._DOM.setStyles(i,{marginTop:this._paper.footerHeight+"px"}),this._paper.headerHeight&&this._DOM.setStyles(i,{paddingBottom:this._paper.headerHeight+"px"}),i}_updatePageNumberElementAttrValue(e){this._hasFrontPage&&this._node.markPageStartElement(this._pages[e].pageStart,`${e+1}`),this._node.markPageEndElement(this._pages[e].pageEnd,`${e+1}`)}_insertPaper(e,t,i){i?this._DOM.insertAtEnd(e,i,t):this._DOM.insertAtEnd(e,t)}_createVirtualPaperGap(){return this._node.create(this._virtualPaperGapSelector)}_createVirtualPaperTopMargin(){return this._paper.createVirtualTopMargin()}_createVirtualPaperBottomMargin(){return this._paper.createVirtualBottomMargin()}_insertFrontpageSpacer(e,t){const i=this._node.create();return this._DOM.setStyles(i,{paddingBottom:t+"px"}),this._DOM.setAttribute(i,".printFrontpageSpacer"),this._DOM.insertAtStart(e,i),i}_insertHeaderSpacer(e,t){const i=this._DOM.createDocumentFragment(),o=this._node.create(this._runningSafetySelector);this._DOM.insertAtEnd(i,this._createVirtualPaperTopMargin(),o),this._DOM.insertAtEnd(e,i)}_insertFooterSpacer({target:e,footerHeight:t,pageSeparator:i,paperSeparator:o,pageIndex:n}){const r=this._DOM.createDocumentFragment(),s=this._createVirtualPaperGap(),l=this._node.create(this._runningSafetySelector);this._DOM.insertAtEnd(r,l,this._createVirtualPaperBottomMargin(),this._node.create(this._printPageBreakSelector),s),this._DOM.insertAtStart(e,r),this._balanceFooter({balancingFooter:l,contentSeparator:s,pageSeparator:i,paperSeparator:o,pageIndex:n})}_balanceFooter({balancingFooter:e,contentSeparator:t,pageSeparator:i,paperSeparator:o,pageIndex:n}){const r=this._node.getTop(i,this._root),s=this._node.getTop(o,this._root),l=this._node.getTop(t,this._root);this.strictAssert(s==r,"balancers in paper layers are misaligned",{pageIndex:n,balancingFooter:e,contentSeparator:t,pageSeparator:i,paperSeparator:o,paperSeparatorTop:s,pageSeparatorTop:r});const a=r-l;this._debug._&&console.log({balancingFooter:e,contentSeparatorTop:l,paperSeparatorTop:s,pageSeparatorTop:r}),this._DOM.setStyles(e,{"margin-bottom":a+"px"});a<-1&&(this._debug._&&console.warn(`[pages: ${n}-${n+1}] balancer is negative: ${a} < 0. Submitted to the Validator.`,t),this._accumulatedAssertions[n]={balancer:a,contentSeparator:t,pageNumber:n})}}class Oo{constructor({config:e,DOM:t,selector:i,node:o,layout:n}){this._globalDebugMode=e.debugMode,this._debug=e.debugMode?{...e.debugConfig.toc}:{},this._assert=!!e.consoleAssert,this._DOM=t,this._node=o,this._tocPageNumberSelector=e.tocPageNumberSelector,this._root=n.root,this._contentFlow=n.contentFlow,this._pageDividerSelector=i.pageDivider}render(){this._globalDebugMode&&console.time("Processing TOC"),this._debug._&&console.log(`\n๐Ÿ“‘ TOC: I am here!\n\ntocPageNumberSelector:\n โ€ข ${this._tocPageNumberSelector}\n pageDividerSelector:\n โ€ข ${this._pageDividerSelector}\n `);const e=this._DOM.getAll(this._tocPageNumberSelector,this._contentFlow);if(this._debug._&&console.log("๐Ÿ“‘ tocPageNumberBoxes",e.length),!e.length)return void(this._debug._&&console.log("๐Ÿ“‘ no valid toc"));const t=this._DOM.getAll(this._pageDividerSelector,this._contentFlow).reduce((e,t,i)=>{const o=this._node.getTop(t,this._root)-1,n=this._DOM.getAttribute(t,"[page]");return e[o]=n,e},{});this._debug._&&console.log("๐Ÿ“‘ dataFromPagesMarkers",t);const i=e.reduce((e,t)=>{const i=this._DOM.getDataId(t),o=this._DOM.getElementById(i),n=this._node.getTop(o,this._root);return e[n]={box:t,id:i,targetTop:n},e},{});this._debug._&&console.log("๐Ÿ“‘ dataFromTOC",i);const o={...t,...i};let n=0;this._debug._&&console.groupCollapsed("Processing obj");for(const e in o){const t=o[e];this._debug._&&console.log(`Processing ${e}: ${t}`),"string"==typeof t?n=t:(t.page=n,this._DOM.setInnerHTML(t.box,n))}this._debug._&&console.groupEnd("Processing obj"),this._debug._&&console.log("๐Ÿ“‘ tocObject",o),this._globalDebugMode&&console.timeEnd("Processing TOC")}}class yo{constructor({config:e,DOM:t,selector:o,node:n,layout:r,pages:s,previewValidations:l}){this._config=e,this._selector=o,this._DOM=t,this._node=n,this._layout=r,this._root=r.root,this._pageCount=s.length,this._accumulatedAssertions=l,this._assert=!!e.consoleAssert,Object.assign(this,i)}init(){this._config.debugMode&&console.log("๐Ÿ™ i am Validator!");const e=this._collectPageOverflowAssertions();for(const[t,i]of Object.entries(e))this._accumulatedAssertions[t]={...this._accumulatedAssertions[t]||{},...i};this.strictAssert(0===Object.keys(this._accumulatedAssertions).length,"Page overflow detected:",this._accumulatedAssertions)}_collectPageOverflowAssertions(){const e=`${this._selector.paperFlow} ${this._selector.virtualPaperGap}`,t=`${this._selector.contentFlow} ${this._selector.virtualPaperGap}`,i=(this._selector.contentFlow,this._selector.contentFlowEnd,`${this._selector.contentFlow} ${this._selector.pageEndMarker}`),o=`${this._selector.pageChrome} ${this._selector.pageBodySpacer}`,n={},r=[...this._DOM.getAllElements(e)],s=[...this._DOM.getAllElements(t)];this._assertElementsCount(this._pageCount-1,{paperGapElements:r,pageGapElements:s});const l=r.map(e=>this._node.getTop(e,this._root)),a=s.map(e=>this._node.getTop(e,this._root));for(let e=0;ee?this._node.getBottom(e,this._root):void 0),u=d.map(e=>e?this._node.getBottom(e,this._root):void 0);for(let e=0;e{e<=.1&&(clearInterval(t),this._preloader.remove()),this._preloader.style.opacity=e,e-=.1*e},50);this._debugMode&&console.log("%c Preloader removed ",vo)}_insertStyle(){const e=document.querySelector("head"),t=document.createElement("style");t.append(document.createTextNode(this._css())),t.setAttribute("data-preloader-style",""),e.append(t)}_css(){return`\n /* PRELOADER */\n .lds-dual-ring {\n position: absolute;\n z-index: 99999;\n top: 0; left: 0; bottom: 0; right: 0;\n background: ${this._preloaderBackground};\n display: flex;\n justify-content: center;\n align-items: center;\n }\n /*\n .lds-dual-ring:after {\n content: " ";\n display: block;\n width: 64px;\n height: 64px;\n margin: 8px;\n border-radius: 50%;\n border: 6px solid #eee;\n border-color: #eee transparent #eee transparent;\n animation: lds-dual-ring 1.2s linear infinite;\n }\n @keyframes lds-dual-ring {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n */\n `}_resolveTarget(e){const t=(e.preloaderTarget||"").trim();return t&&document.querySelector(t)}}class Ro{constructor(e){this._debugMode=e.debugMode}run(){let e=[...document.querySelectorAll("object")];this._debugMode&&console.log(e);let t=[];return e.forEach(e=>{const i=new Promise(t=>{e.addEventListener("load",i=>{this._debugMode&&console.log("โฐ EVENT: object load",e.clientHeight,e.clientWidth,e),t()})});t.push(i)}),Promise.all(t)}}const xo=e=>!0===e||"true"===e;function No(e){const t=Array.isArray(e)?[]:{};return Object.entries(e).forEach(([e,i])=>{t[e]=!i||"object"!=typeof i||No(i)}),t}const Bo={DOM:{_:!1},layout:{_:!1},pages:{_:!1,_parseNode:!1,_parseNodes:!1,_registerPageStart:!1},paper:{_:!1},preview:{_:!1},toc:{_:!1},node:{_:!1,children:!1,creators:!1,flowFilters:!1,fitters:!1,getters:!1,markers:!1,pageBreaks:!1,positioning:!1,selectors:!1,selectorHeuristics:!1,slicers:!1,splitters:!1,wrappers:!1,pagination:!1},paragraph:{_:!1},grid:{_:!1},pre:{_:!1},table:{_:!1},tableLike:{_:!1},testSignals:{forcedModeLog:!1}};function Fo(e){const t=function(e){let t={debugMode:!1,forcedDebugMode:!1,consoleAssert:!1,markupDebugMode:!1,preloader:!1,preloaderTarget:"",preloaderBackground:"",mask:!0,noHangingSelectors:"",forcedPageBreakSelectors:"",pageBreakBeforeSelectors:"",pageBreakAfterSelectors:"",noBreakSelectors:"",tocPageNumberSelector:"html2pdf4doc-toc-page-number",printLeftMargin:"21mm",printRightMargin:"21mm",printTopMargin:"12mm",printBottomMargin:"12mm",printFontSize:"12pt",paperColor:"white",paperWidth:"210mm",paperHeight:"297mm",headerMargin:"16px",footerMargin:"16px",virtualPagesGap:"16px",splitLabelHeight:"24px"};const i={paperWidth:"210mm",paperHeight:"297mm"},o={paperWidth:"148.5mm",paperHeight:"210mm"};switch((e=function(e){const t={...e};for(const e in t){const i=t[e];if("string"==typeof i){const o=i.toLowerCase();"true"===o||"1"===o?t[e]=!0:"false"!==o&&"0"!==o&&""!==o||(t[e]=!1)}}return t}(e)).printPaperSize){case"A5":case"a5":t={...t,...o};break;default:t={...t,...i}}t={...t,initialRoot:y.init,tocPageNumberSelector:y.tocPageNumber,...e},console.info("[HTML2PDF4DOC] Config:",t);const n={printLeftMargin:t.printLeftMargin,printRightMargin:t.printRightMargin,printTopMargin:t.printTopMargin,printBottomMargin:t.printBottomMargin,printFontSize:t.printFontSize,paperWidth:t.paperWidth,paperHeight:t.paperHeight,headerMargin:t.headerMargin,footerMargin:t.footerMargin,virtualPagesGap:t.virtualPagesGap},r=document.createElement("div");return r.style="\n position:absolute;\n z-index:1000;\n left: 200%;\n ",document.body.append(r),Object.entries(n).forEach(([e,t])=>{r.style.width=t,n[e]=`${Math.trunc(r.getBoundingClientRect().width)}px`}),r.remove(),t={...t,...n},t.noHangingSelectors=t.noHangingSelectors+" H1 H2 H3 H4 H5 H6",t.forcedPageBreakSelectors=t.forcedPageBreakSelectors+" "+y.printForcedPageBreak,t.debugMode&&console.info("Config with converted units:",t),t}(e);t.forcedDebugMode&&(t.debugMode=!0,t.consoleAssert=!0,t.markupDebugMode=!0);const i=t.forcedDebugMode?No(Bo):Bo;return{...t,debugConfig:i}}const ko="color:Gray;border:1px solid;";console.info("[HTML2PDF4DOC] Version:","0.3.0");const Ho=document.currentScript.dataset,Ao=new class{constructor(e){this.params=function(e={}){const t={...e};return[["printWidth","paperWidth","data-print-width","data-paper-width"],["printHeight","paperHeight","data-print-height","data-paper-height"]].forEach(([e,i,o,n])=>{Object.prototype.hasOwnProperty.call(t,e)&&(console.warn(`[HTML2PDF4DOC] Config option "${o}" is deprecated. Use "${n}" instead.`),Object.prototype.hasOwnProperty.call(t,i)||(t[i]=t[e]),delete t[e])}),t}(e),this.forcedDebugMode=xo(e.forcedDebugMode),this.debugMode=xo(e.debugMode)||this.forcedDebugMode,this.preloader=e.preloader,this.selector=y,this.config}async render(){console.time("[HTML2PDF4DOC] Total time"),this.debugMode&&console.log("๐Ÿ document.readyState",document.readyState),document.addEventListener("readystatechange",e=>{this.debugMode&&console.log("๐Ÿ readystatechange",document.readyState)}),this.debugMode&&console.time("โฑ๏ธ await DOMContentLoaded time"),await new Promise(e=>{window.addEventListener("DOMContentLoaded",t=>{this.debugMode&&console.log("โฐ EVENT: DOMContentLoaded"),e()})}),this.debugMode&&console.timeEnd("โฑ๏ธ await DOMContentLoaded time"),this.debugMode&&console.time("โฑ๏ธ create Preloader time");const e=new Do(this.params);"true"===this.preloader&&e.create(),this.debugMode&&console.timeEnd("โฑ๏ธ create Preloader time"),this.debugMode&&console.time("โฑ๏ธ Config time"),this.debugMode&&console.groupCollapsed("%c config ",ko+"color:LightGray"),this.config=Fo(this.params),this.debugMode&&console.groupEnd(),this.debugMode&&console.info("โš™๏ธ Current config with debugConfig:",this.config),this.debugMode&&console.timeEnd("โฑ๏ธ Config time"),this.config.debugConfig.testSignals.forcedModeLog&&console.info("[HTML2PDF4DOC] ๐Ÿ› ๏ธ Forced debug mode is active."),this.config.consoleAssert&&console.info("[HTML2PDF4DOC] ๐Ÿงง Assertions enabled."),this.debugMode&&console.time("โฑ๏ธ DOM helpers init time");const t=new B({DOM:window.document,config:this.config});this.debugMode&&console.timeEnd("โฑ๏ธ DOM helpers init time"),this.debugMode&&console.time("โฑ๏ธ node helpers init time");const i=new mo({config:this.config,DOM:t,selector:this.selector});this.debugMode&&console.timeEnd("โฑ๏ธ node helpers init time"),this.debugMode&&console.time("โฑ๏ธ await window load time"),await new Promise(e=>{window.addEventListener("load",t=>{this.debugMode&&console.log("โฐ EVENT: window load"),e()})}),this.debugMode&&console.timeEnd("โฑ๏ธ await window load time"),this.debugMode&&console.time("โฑ๏ธ Layout time"),this.debugMode&&console.groupCollapsed("%c Layout ",ko);const o=new k({config:this.config,DOM:t,selector:this.selector,node:i});if(o.create(),this.debugMode&&console.groupEnd(),this.debugMode&&console.timeEnd("โฑ๏ธ Layout time"),!o.success)return void(this.debugMode&&console.error("Failed to create layout.\n\nWe have to interrupt the process of creating PDF preview."));this.debugMode&&console.info("%c calculate Paper params ",ko),this.debugMode&&console.time("โฑ๏ธ Paper time");const n=new Eo({config:this.config,DOM:t,selector:this.selector,node:i,layout:o});if(this.debugMode&&console.timeEnd("โฑ๏ธ Paper time"),!n||!n.bodyHeight||!n.bodyWidth)return void(this.debugMode&&console.error("Failed to create paper calculations.\n\nWe have to interrupt the process of creating PDF preview."));this.debugMode&&console.time("โฑ๏ธ Preprocess time"),this.debugMode&&console.groupCollapsed("%c Preprocess ",ko),await new Ro(this.config).run(),this.debugMode&&console.groupEnd(),this.debugMode&&console.timeEnd("โฑ๏ธ Preprocess time"),this.debugMode&&console.time("โฑ๏ธ Pages time"),this.debugMode&&console.group("%c Pages ",ko);const r=new Co({config:this.config,DOM:t,selector:this.selector,node:i,layout:o,referenceHeight:n.bodyHeight,referenceWidth:n.bodyWidth}).calculate();this.debugMode&&console.groupEnd(),this.debugMode&&console.timeEnd("โฑ๏ธ Pages time"),this.debugMode&&console.time("โฑ๏ธ Preview time"),this.debugMode&&console.groupCollapsed("%c Preview ",ko);const s=new To({config:this.config,DOM:t,selector:this.selector,node:i,layout:o,paper:n,pages:r}).create();this.debugMode&&console.groupEnd(),this.debugMode&&console.timeEnd("โฑ๏ธ Preview time"),this.debugMode&&console.time("โฑ๏ธ Toc time"),new Oo({config:this.config,DOM:t,selector:this.selector,node:i,layout:o}).render(),this.debugMode&&console.timeEnd("โฑ๏ธ Toc time"),this.debugMode&&console.time("โฑ๏ธ Validator time"),new yo({config:this.config,DOM:t,selector:this.selector,node:i,layout:o,pages:r,previewValidations:s}).init(),this.debugMode&&console.timeEnd("โฑ๏ธ Validator time"),t.setAttribute(o.root,"[success]"),t.setAttribute(o.root,"[pages]",r.length),e.remove(),console.info("[HTML2PDF4DOC] Page count:",r.length),console.timeEnd("[HTML2PDF4DOC] Total time")}}(Ho),Io="manual"===Ho.init;function Lo(){Io&&Ao.render()}Io&&console.info("HTML2PDF4DOC in manual initialization mode"),!Io&&Ao.render(),HTML2PDF4DOC=t})(); \ No newline at end of file diff --git a/submodules/html2pdf b/submodules/html2pdf index 51527ae..d02e201 160000 --- a/submodules/html2pdf +++ b/submodules/html2pdf @@ -1 +1 @@ -Subproject commit 51527ae256c789b429e9b90f68da13d5fd184458 +Subproject commit d02e2016918997389ae9c01e75ca3675c52d901b diff --git a/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/autogen.css b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/autogen.css new file mode 100644 index 0000000..ad3f8a2 --- /dev/null +++ b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/autogen.css @@ -0,0 +1,258 @@ +/* A wrapper for styling the markup generated by MarkupRenderer. */ + +sdoc-autogen { + /* + TODO: 'display: contents;' + Turn this back on when the bug is fixed: + Selenium cannot detect text inside a container + with the 'display: contents;' directive + */ + /* display: contents; */ + + /* hyphens: auto; */ + + --autogen-v-rhythm: calc(var(--base-rhythm, 8px) * 2); +} + +sdoc-autogen a, +sdoc-autogen a:link, +sdoc-autogen a:visited { + text-decoration: underline; +} + +/* Table */ + +sdoc-autogen table { + border-collapse: collapse; + margin: var(--base-padding) 0; + font-size: 1rem; + + /*** add scroll for wide tables */ + /* issue#1370 https://css-tricks.com/preventing-a-grid-blowout/ */ + /* border: 1px solid #ccc; */ + border: none; + display: block; + overflow-x: auto; + white-space: nowrap; +} + +sdoc-autogen table caption { + font-weight: bold; + padding-bottom: 1rem; +} + +sdoc-autogen table th { + background-color: var(--color-bg-main); +} + +sdoc-autogen table th, +sdoc-autogen table td { + padding: var(--base-rhythm) calc(var(--base-rhythm) * 1.5); + vertical-align: top; + text-align: left; + border: 1px solid #ccc; + + /* issue#1370 https://css-tricks.com/preventing-a-grid-blowout/ */ + /*** add scroll for wide tables (unset) */ + white-space: initial; +} + +/* Typography */ + +sdoc-autogen p { + margin: var(--autogen-v-rhythm) 0; +} + +/* blockquote */ + +sdoc-autogen blockquote { + color: #666; + padding: .25em 0 0.25em 1rem; + border-left: 4px solid #ccc; + margin: var(--autogen-v-rhythm) 0; +} + +/* pre.code */ + +sdoc-autogen pre.code { + font-family: var(--code-font-family); + + font-size: var(--code-font-size); + line-height: 2; + margin: var(--code-font-size) 0; + padding: calc(var(--code-font-size)*1) + calc(var(--code-font-size)*1) + calc(var(--code-font-size)*1) + calc(var(--code-font-size)*2); + + overflow: auto; + background-color: var(--color-bg-main); + border: 1px solid var(--color-border); +} + +/* We have to override this for the print version because the printer + interprets scroll-bars differently in different environments, + which breaks HTML2PDF. + Also, we need to show the whole code in its entirety. + */ +[html2pdf] sdoc-autogen pre.code { + overflow: unset; + white-space: pre-wrap; + overflow-wrap: break-word; +} + +/* ``some text`` is generated into: by docutils. */ +sdoc-autogen tt.literal { + position: relative; + padding: 0 4px; + font-style: normal; + font-family: var(--code-font-family); + font-size: var(--code-font-size); + background-color: var(--color-bg-main); + border: 1px solid var(--color-border); + border-radius: 4px; + + overflow-wrap: break-word; + word-wrap: break-word; + -webkit-box-decoration-break: clone; + box-decoration-break: clone; +} + +/* ul */ + +sdoc-autogen ul, +sdoc-autogen ol { + padding-left: 1.6em; + margin: var(--autogen-v-rhythm) 0; +} + +/* list in table */ +sdoc-autogen td ul, +sdoc-autogen dt ol { + margin: 0; + padding-left: 1em; +} + +/* object */ + +sdoc-autogen img, +sdoc-autogen svg, +sdoc-autogen object { + max-width: 100%; + height: auto; + padding: 1em 0; + background: var(--color-bg-contrast); +} + +/* + ************************** + automatically added by RST + ************************** +*/ + +div.document { + /* alarm style for detecting unwrapped blocks */ + border: 1px dashed red; +} + +sdoc-autogen div.document { + display: contents; + border: none; +} + +/* block margins */ + +sdoc-autogen .document > *:first-child, /* RST */ +sdoc-autogen > *:first-child { + margin-top: 0 !important; +} + +sdoc-autogen .document > *:last-child, /* RST */ +sdoc-autogen > *:last-child { + margin-bottom: 0 !important; +} + +/* admonition by RST */ +/* "attention", "caution", "danger", "error", "hint", "important", "note", "tip", "warning" */ + +sdoc-autogen .admonition { + display: block; + overflow: hidden; + padding: 0 var(--autogen-v-rhythm); + border: var(--requirement-border-width, 1px) solid; + border-radius: var(--requirement-border-radius); + margin: var(--autogen-v-rhythm) 0; + color: var(--color-fg-main); +} + +sdoc-autogen .admonition .admonition-title { + margin: 0; + padding-top: calc(0.5 * var(--base-rhythm)); + padding-bottom: calc(0.5 * var(--base-rhythm)); + color: currentColor; + font-weight: 600; + position: relative; +} + +sdoc-autogen .admonition .admonition-title::after { + content: ''; + position: absolute; + top: 0; bottom: 0; + left: calc(-1 * var(--autogen-v-rhythm)); + right: calc(-1 * var(--autogen-v-rhythm)); + /* background:repeating-linear-gradient( + -45deg, + rgba(255, 255, 255, .25), + rgba(255, 255, 255, .25) 10px, + rgba(255, 255, 255, .0) 10px, + rgba(255, 255, 255, .0) 20px + ); */ + background-color: currentColor; + opacity: 0.1; +} + +sdoc-autogen .admonition > *:not(.admonition-title) { + color: var(--color-fg-main); +} + +sdoc-autogen .admonition.attention { + color: Crimson; +} + +sdoc-autogen .admonition.caution { + color: Crimson; +} + +sdoc-autogen .admonition.important { + color: OrangeRed; +} + +sdoc-autogen .admonition.danger { + color: red; +} + +sdoc-autogen .admonition.error { + color: Red; +} + +sdoc-autogen .admonition.warning { + color: DarkOrange; +} + +sdoc-autogen .admonition.warning .admonition-title::before { + /* content: 'โš ๏ธ'; */ + margin-right: var(--base-rhythm); +} + +sdoc-autogen .admonition.note { + /* color: CornflowerBlue; */ + color: SteelBlue; +} + +sdoc-autogen .admonition.hint { + color: DarkSlateBlue; +} + +sdoc-autogen .admonition.tip { + color: MediumSlateBlue; +} diff --git a/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/base.css b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/base.css new file mode 100644 index 0000000..6471e25 --- /dev/null +++ b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/base.css @@ -0,0 +1,154 @@ +/* @import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@400;500;600;700&family=Noto+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600;1,700&display=swap'); */ + +/* .test-content {} */ + +:root { + + --color-bg-main: #F2F5F9; + --color-fg-main: #444; + + --color-bg-contrast: #fff; + --color-fg-contrast: #000; + + --color-fg-accent: rgb(242, 100, 42); + --color-bg-accent: rgb(242 100 42 / 10%); + + --color-accent: #274466; + --color-highlight: rgb(255, 255, 200); + --color-highlight-secondary: rgb(230, 236, 242); + + --color-fg-secondary: rgba(0, 0, 0, .5); + --color-bg-secondary: rgba(0, 0, 0, .025); + + --color-fg-secondary-invert: rgb(255 255 255 / 50%); + --color-bg-secondary-invert: rgb(0 0 0 / 10%); + + --color-bg-ui: #282c42; + + --color-red: rgb(200, 0, 0); + --color-blue: rgb(50, 100, 200); + --color-green: rgb(0, 100, 100); + + --color-danger: var(--color-red); + --color-cancel: var(--color-fg-secondary); + --color-submit: var(--color-action); + + --color-link: var(--color-fg-secondary); + --color-action: var(--color-fg-accent); + --color-hover: var(--color-fg-contrast); + + --color-border: rgba(0,0,0,.1); + --color-placeholder: rgba(0,0,0,.25); + + --base-border: 1px solid var(--color-border); + --code-border-color: var(--color-border); + + --scrollbarBG: transparent; + --thumbBG: rgba(0,0,0,.05); + + --base-rhythm: 8px; + + --base-font-size: calc(var(--base-rhythm)*2); + --base-line-height: 1.6; + + --font-size: var(--base-font-size); + + --font-size-l: 1.25rem; + --font-size-sm: 0.8125rem; + --font-size-xsm: 0.75rem; + --font-size-xxsm: 11px; + --code-font-size: .85em; + + --base-font-family: 'Noto Sans', sans-serif; + --code-font-family: 'Noto Sans Mono', consolas, monaco, monospace; + /* + DEV NOTE: To use system fonts, + uncomment the following two variables, replacing the previous two: + */ + /* --base-font-family: ui-sans-serif, system-ui, -apple-system, "system-ui", "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif; */ + /* --code-font-family: monospace; */ + + --base-gap: calc(var(--base-rhythm)*6); + --tree-gap: calc(var(--base-rhythm)*4); + --base-padding: calc(var(--base-rhythm)*2); + + --base-elevation-0: 0 0 0 rgba(0,0,0,0); + --base-elevation-node: 0 0 16px rgba(0,0,0,.1); + --base-elevation-modal: 0 0 32px rgba(0,0,0,.32); + + --main-elevation-shadow: inset 8px 8px 16px rgba(0,0,0,.2); + --base-elevation: 0 0 16px rgba(0,0,0,.2); + + --traceability-arrow: 1.25rem; + + --card-width: 300px; +} + +body { + margin: 0; + padding: 0; + + font-family: var(--base-font-family); + font-size: var(--base-font-size); + line-height: var(--base-line-height); + color: var(--color-fg-main); + background-color: var(--color-bg-main); +} + +@font-face { + font-family: 'Noto Sans'; + font-style: normal; + font-weight: 100 900; + /* font-stretch: 100%; */ + font-display: swap; + src: url('./fonts/NotoSans-VariableFont_wdth,wght.ttf') format('truetype-variations'); +} + +@font-face { + font-family: 'Noto Sans'; + font-style: italic; + font-weight: 100 900; + /* font-stretch: 100%; */ + font-display: swap; + src: url('./fonts/NotoSans-Italic-VariableFont_wdth,wght.ttf') format('truetype-variations'); +} + +@font-face { + font-family: 'Noto Sans Mono'; + font-style: normal; + font-weight: 100 900; + /* font-stretch: 100%; */ + font-display: swap; + src: url('./fonts/NotoSansMono-VariableFont_wdth,wght.ttf') format('truetype-variations'); +} + +* { box-sizing: border-box; } + +sdoc-scope { + display: contents; +} + +/* scrollbar */ + +* { + scrollbar-color: var(--thumbBG) var(--scrollbarBG); +} +::-webkit-scrollbar:horizontal, +::-webkit-scrollbar:vertical, +::-webkit-scrollbar, +::-webkit-scrollbar-track:horizontal, +::-webkit-scrollbar-track:vertical, +::-webkit-scrollbar-track, +::-webkit-scrollbar-corner { + background-color: var(--scrollbarBG); +} +::-webkit-scrollbar-thumb:horizontal, +::-webkit-scrollbar-thumb:vertical, +::-webkit-scrollbar-thumb { + background-color: var(--thumbBG) + /* + background-color: var(--scrollbarBG); + border: 3px solid var(--thumbBG); + border-radius: 6px; + */ +} diff --git a/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/content.css b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/content.css new file mode 100644 index 0000000..596cf49 --- /dev/null +++ b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/content.css @@ -0,0 +1,203 @@ +/* .main */ + +.main { + position: relative; + overflow: auto; + scroll-behavior: smooth; + scrollbar-gutter: stable both-edges; + padding: var(--base-gap) /* == calc(var(--base-rhythm)*6) */ + calc(var(--base-rhythm)*6); /* compensate both-edges scrollbar-gutter */ + + height: 100%; + background-color: var(--color-bg-main); + + display: flex; + flex-direction: column; + justify-content: flex-start; + align-items: stretch; + gap: var(--base-rhythm); +} + +/* redefine main layout grid */ + +[data-viewtype="diff"] .main { + padding-bottom: 0; +} + +[data-viewtype="source-file"] .main { + padding: 0; + scrollbar-gutter: unset; +} + +.main_sticky_header { + position: sticky; + top: 0; + left: 0; + z-index: 11; + + display: flex; + flex-direction: column; + gap: var(--base-rhythm); + + /* margin-bottom: calc(var(--base-rhythm)*4); */ + background-color: var(--color-bg-main); + border: none; +} + +.main_sticky_header > * { + position: relative; +} + +.main_sticky_header::before { + content: ''; + position: absolute; + bottom: 0; + top: -60px; + left: calc(-1 * var(--base-gap)); + right: calc(-1 * var(--base-gap)); + background-color: var(--color-bg-main); + z-index: 0; +} + +/* .content */ + +.content { + width: 100%; + min-width: calc(var(--card-width) + calc(var(--base-padding)*4)); +} + +[data-viewtype="document"] .content { + display: block; + max-width: 900px; + margin-bottom: 300px; + margin-left: auto; + margin-right: auto; +} + +[data-viewtype="traceability"] .content { + display: grid; + place-items: stretch stretch; + grid-template-columns: minmax(min-content, max-content) + minmax(var(--card-width), calc(2*var(--card-width))) + minmax(min-content, max-content); + gap: var(--requirement-tree-margin) 0; + width: -moz-fit-content; + width: fit-content; + /* overflow: hidden; */ +} + +[data-viewtype="requirements-coverage"] .content, +[data-viewtype="deep_traceability"] .content { + display: grid; + place-items: stretch stretch; + grid-template-columns: minmax(min-content, max-content) + max-content + minmax(min-content, max-content); + gap: var(--requirement-tree-margin) 0; + width: -moz-fit-content; + width: fit-content; + + /* fon node-controls: */ + /* overflow: hidden; */ +} + +[data-viewtype="table"] .content { + background-color: var(--color-bg-contrast); + display: block; + /* aligns the width of the white box of the content and the table: */ + width: fit-content; +} + +[data-viewtype="table"] sdoc-node .free_text{ + max-width: 900px; +} + +[data-viewtype="search"] .content { + display: grid; + place-items: stretch stretch; + grid-template-columns: 1fr; + gap: var(--tree-gap) 0; + width: -moz-fit-content; + width: fit-content; +} + +/* TODO */ +/* used in TR, DTR, requirements_coverage: */ +.content_section { + display: contents; +} +/* TODO */ +.content_item { + position: relative; + display: flex; + flex-direction: column; + flex-wrap: nowrap; + align-content: stretch; + align-items: stretch; +} + +/* traceability */ + +.content_item[data-role="parents"] { + grid-column: 1 / 2; +} + +.content_item[data-role="current"] { + grid-column: 2 / 3; +} + +[data-viewtype="deep_traceability"] .content_item[data-role="current"] { + /* central column */ + width: var(--card-width); +} + +[data-viewtype="requirements-coverage"] .content_item[data-role="current"] { + /* central column */ + width: calc(var(--card-width)*0.75); +} + +.content_item[data-role="children"] { + grid-column: 3 / 4; +} + +[data-viewtype="deep_traceability"] .content_item[data-role="current"]::before, +[data-viewtype="traceability"] .content_item[data-role="current"]::before { + /* for vertical line in 'current' column */ + content: ''; + position: absolute; + top: 0; + bottom: calc(var(--requirement-tree-margin)*(-1)); + left: 50%; + border-left: 1px dotted #000; +} + +[data-viewtype="deep_traceability"] section:last-child .content_item[data-role="current"]::before, +[data-viewtype="traceability"] section:last-child .content_item[data-role="current"]::before { + /* the last section doesn't need a vertical connector under the middle node */ + content: none; +} + +/* placeholder */ + +sdoc-main-placeholder { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + color: var(--color-placeholder); + font-weight: 700; + font-family: var(--code-font-family); + width: 100%; + height: 100%; +} + +sdoc-main-legend { + display: block; + color: var(--color-placeholder); + font-weight: 700; + font-family: var(--code-font-family); + max-width: 1024px; + padding: var(--base-gap); + font-weight: 500; + margin-bottom: auto; /* To align the element at the top of the container that uses 'display:flex' */ +} diff --git a/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/diff.css b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/diff.css new file mode 100644 index 0000000..35ab06f --- /dev/null +++ b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/diff.css @@ -0,0 +1,531 @@ +/* diff */ +:root { + --pre-stripe: 20px; + --pre-stripe-color: rgba(0,0,0,0.02); + --pre-block-bg-color: rgba(0,0,0,0.01); + + --diff-block-color-left: rgba(255, 55, 55, .05); + --diff-word-color-left: rgba(255, 55, 55, .2); + --diff-icon-color-left: rgba(255, 55, 55, .75); + --diff-document-color-left: rgba(255, 55, 55, 1); + + --diff-block-color-right: rgba(20, 120, 20, .05); + --diff-word-color-right: rgba(20, 120, 20, .2); + --diff-icon-color-right: rgba(20, 120, 20, .75); + --diff-document-color-right: rgba(20, 120, 20, 1); +} + +/* + *** diff *** + */ + +.diff { + scroll-behavior: smooth; + background-color: var(--color-bg-main); + + display: grid; + place-items: stretch stretch; + place-content: stretch stretch; + grid-template-columns: minmax(0, 1fr) /* issue#1370 https://css-tricks.com/preventing-a-grid-blowout/ */ + minmax(0, 1fr); + grid-template-rows: minmax(0, max-content) + minmax(0, 1fr); + + gap: var(--base-rhythm); + + min-height: 0; /* to prevent from overflowing the parent flex container */ +} + +/* controls */ + +.diff_controls { + display: flex; + justify-content: flex-end; + gap: calc(var(--base-rhythm)/2); +} + +#diff_left_open { + color: var(--diff-document-color-left); +} + +#diff_right_open { + color: var(--diff-document-color-right); +} + +#diff_left_close, +#diff_right_close { + color: var(--color-link); +} + +#diff_left_open:hover, +#diff_right_open:hover { + color: var(--color-hover); +} + +/* columns */ +.diff_column { + overflow: auto; + overflow-y: scroll; + + overflow-wrap: break-word; + + border-radius: 4px; + border: 1px solid var(--color-border); + + position: relative; /* for position:sticky */ +} + +.diff_column[left] { + direction:rtl; +} + +.diff_column[right] { + direction:ltr; +} + +.diff_inner { + direction: initial; + padding-bottom: 100%; /* to balance the scrolling freely */ +} + +.diff_content { + display: flex; + flex-direction: column; + gap: var(--base-rhythm); + padding: var(--base-rhythm); +} + +/* details with summary */ + +.diff details { + width: 100%; +} + +.diff summary { + list-style: none; + display: flex; + gap: var(--base-rhythm); + cursor: pointer; + color: var(--color-link); +} + +.diff details[modified] > summary { + color: var(--color-fg-accent); +} + +.diff details[modified="left"] > summary { + color: var(--diff-document-color-left); +} + +.diff details[modified="right"] > summary { + color: var(--diff-document-color-right); +} + +.diff summary:hover, +.diff details[modified] > summary:hover { + color: var(--color-hover); +} + +.diff summary::-webkit-details-marker { + display: none; +} + +.diff details > summary::before { + content:"+"; +} + +.diff details[open] > summary::before { + content:"โ€“"; +} + +/* document / details */ + +.diff_document { + background-color: var(--color-bg-contrast); + border: 1px solid transparent; + border-radius: 4px; + padding: 0 var(--base-rhythm); +} + +.diff_document[modified] { + border-color: var(--color-fg-accent); +} + +.diff_document[modified="left"] { + border-color: var(--diff-document-color-left, rgba(255, 55, 55, 1)); +} + +.diff_document[modified="right"] { + border-color: var(--diff-document-color-right, rgba(20, 120, 20, 1)); +} + +.diff_document > summary { + line-height: 1.2; + padding: var(--base-rhythm) 0; + font-size: var(--font-size-sm); + font-weight: 700; + justify-content: space-between; /* '+' to right */ +} + +.diff_document[open] > summary { + /* + When the details are closed up, the summary sometimes covers the bottom border. + That's why we only add the background for cases where the card is open + and sticking makes sense. + */ + background: var(--color-bg-contrast); + position: sticky; + top: 0; +} + +.diff_document > summary .document_title { + flex-grow: 1; +} + +.diff_document[open] > summary { + border-bottom: 1px dotted; +} + +.diff_document > summary::before, +.diff_document[open] > summary::before { + content: none !important; +} + +.diff_document > summary::after { + content:"+"; +} + +.diff_document[open] > summary::after { + content:"โ€“"; +} + +/* folder */ + +.diff_folder { + display: flex; + align-items: center; + justify-content: flex-start; + column-gap: calc(var(--base-rhythm)/2); + font-size: var(--font-size-sm); + min-width: 0; + line-height: 1.5; + padding-top: var(--base-rhythm); +} + +/* node content */ + +.diff_node { + margin: var(--base-rhythm) 0; +} + +.diff_node_fields { + display: flex; + flex-direction: column; + margin: var(--base-rhythm) 0; + row-gap: calc(var(--base-rhythm) / 2); +} + +.diff_node > .diff_node_fields { + padding-left: calc(var(--base-rhythm)*2); +} + +.diff_node_field { + display: flex; + flex-wrap: wrap; + align-items: baseline; + column-gap: calc(var(--base-rhythm) / 2); +} + +.diff_node_field > .badge { + line-height: var(--pre-stripe); +} + +/* + *** changelog *** + */ + +.changelog { + display: flex; + flex-direction: column; +} + +.changelog .sdoc-table_key_value { + width: auto; +} + +.changelog .diff_column { + margin-right: -16px; + border-radius: 0; + border: none; + border-right: 1px solid var(--color-border); +} + +.changelog_summary { + padding: calc(2 * var(--base-rhythm)); +} + +.changelog_content { + display: flex; + flex-direction: column; + gap: var(--base-rhythm); + margin-bottom: calc(4 * var(--base-rhythm)); +} + +.changelog_changes { + display: flex; + flex-direction: column; + gap: var(--base-rhythm); +} + +.changelog_change { + background-color: var(--color-bg-contrast); + border: 1px solid var(--color-border); + border-radius: 4px; + display: flex; + flex-direction: row; + flex-wrap: wrap; +} + +.changelog_change_meta { + background-color: var(--color-bg-main); + width: 100%; + font-size: var(--font-size-xsm); + font-weight: 700; + display: flex; + gap: var(--base-rhythm); + padding: var(--base-rhythm); +} + +.changelog_change_type { + font-size: var(--font-size-xsm); +} + +.changelog_change_type.removed { + color: red; +} + +.changelog_change_type.modified { + color: orange; +} + +.changelog_change_type.added { + color: green; +} + +.changelog_change_node { + width: 100%; + padding: var(--base-rhythm); +} + +@media (min-width: 768px) { + .changelog_change_node { + /* width: calc(50% - var(--base-rhythm)); */ + width: 50%; + } +} + +.changelog_node_null { + display: flex; + justify-content: center; + align-items: center; + color: var(--color-placeholder); + + height: 100%; + min-height: 32px; + background:repeating-linear-gradient( + -45deg, + rgba(234, 234, 234, 0.1), + rgba(234, 234, 234, .1) 10px, + rgba(234, 234, 234, .15) 10px, + rgba(234, 234, 234, .15) 20px + ); + +} + +/* + *** MISC *** + */ + +/* badge */ + +.badge { + white-space: nowrap; +} + +.badge::before { + content: attr(text); + padding: 0 calc(var(--base-rhythm)/2); + border: 1px solid; + border-radius: calc(var(--base-rhythm)/2); + font-size: var(--font-size-xxsm); + font-weight: 600; + text-transform: uppercase; +} + +/* in summary: */ +[modified="left"] > summary .badge::before, +/* in field: */ +[modified="left"] > .badge::before { + color: white; + background-color: var(--diff-icon-color-left); + border-color: var(--diff-icon-color-left); +} + +/* in summary: */ +[modified="right"] > summary .badge::before, +/* in field: */ +[modified="right"] > .badge::before { + color: white; + background-color: var(--diff-icon-color-right); + border-color: var(--diff-icon-color-right); +} + +/* pre */ + +.sdoc_pre_content { + flex-grow: 1; + white-space: pre-wrap; + overflow-x: clip; + font-family: monospace; + font-size: 0.85em; + line-height: var(--pre-stripe); + background-image: repeating-linear-gradient( + to bottom, + var(--pre-stripe-color), + var(--pre-stripe-color) var(--pre-stripe), + transparent var(--pre-stripe), + transparent calc(var(--pre-stripe)*2) + ); + background-color: var(--pre-block-bg-color); +} + +[multiline] .sdoc_pre_content { + flex-basis: 100%; +} + +[modified="left"] > .sdoc_pre_content { + background-color: var(--diff-block-color-left); +} +.lambda_red {background-color: var(--diff-word-color-left);} + +[modified="right"] > .sdoc_pre_content { + background-color: var(--diff-block-color-right); +} +.lambda_green {background-color: var(--diff-word-color-right);} + +/* preloaded */ +/* + The element has been pre-loaded + and a smooth appearance effect is added to it. + The element will retain the computed values set by the last keyframe. + */ +.preloaded { + position: relative; + animation: fadeInPreloaded 1s ease-in-out; + animation-fill-mode: forwards; +} + +@keyframes fadeInPreloaded { + from { + opacity: 0; + } + to { + opacity: 1; + } +} + +/* skeleton */ + +.skeleton_spinner_container { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + min-height: 333px; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + grid-column: 1/3; + grid-row: 2/3; + z-index: 11; +} + +@keyframes change-color { + from {background-color: rgba(255,255,255,0.8);} + to {background-color: rgba(255,255,255,0.3);} +} + +@keyframes pulse { + 0%, 100% { + opacity: .5; + } + 50% { + opacity: 1; + } +} + +.skeleton_spinner { + position: relative; + text-indent: -9999em; + animation: mulShdSpin 1.3s infinite linear; + transform: translateZ(0); + /* size */ + font-size: 8px; + margin: 36px; + /* dot */ + color: var(--color-fg-accent); + width: 1em; + height: 1em; + border-radius: 50%; +} + +@keyframes mulShdSpin { + 0%, + 100% { + box-shadow: 0 -3em 0 0.2em, + 2em -2em 0 0em, 3em 0 0 -1em, + 2em 2em 0 -1em, 0 3em 0 -1em, + -2em 2em 0 -1em, -3em 0 0 -1em, + -2em -2em 0 0; + } + 12.5% { + box-shadow: 0 -3em 0 0, 2em -2em 0 0.2em, + 3em 0 0 0, 2em 2em 0 -1em, 0 3em 0 -1em, + -2em 2em 0 -1em, -3em 0 0 -1em, + -2em -2em 0 -1em; + } + 25% { + box-shadow: 0 -3em 0 -0.5em, + 2em -2em 0 0, 3em 0 0 0.2em, + 2em 2em 0 0, 0 3em 0 -1em, + -2em 2em 0 -1em, -3em 0 0 -1em, + -2em -2em 0 -1em; + } + 37.5% { + box-shadow: 0 -3em 0 -1em, 2em -2em 0 -1em, + 3em 0em 0 0, 2em 2em 0 0.2em, 0 3em 0 0em, + -2em 2em 0 -1em, -3em 0em 0 -1em, -2em -2em 0 -1em; + } + 50% { + box-shadow: 0 -3em 0 -1em, 2em -2em 0 -1em, + 3em 0 0 -1em, 2em 2em 0 0em, 0 3em 0 0.2em, + -2em 2em 0 0, -3em 0em 0 -1em, -2em -2em 0 -1em; + } + 62.5% { + box-shadow: 0 -3em 0 -1em, 2em -2em 0 -1em, + 3em 0 0 -1em, 2em 2em 0 -1em, 0 3em 0 0, + -2em 2em 0 0.2em, -3em 0 0 0, -2em -2em 0 -1em; + } + 75% { + box-shadow: 0em -3em 0 -1em, 2em -2em 0 -1em, + 3em 0em 0 -1em, 2em 2em 0 -1em, 0 3em 0 -1em, + -2em 2em 0 0, -3em 0em 0 0.2em, -2em -2em 0 0; + } + 87.5% { + box-shadow: 0em -3em 0 0, 2em -2em 0 -1em, + 3em 0 0 -1em, 2em 2em 0 -1em, 0 3em 0 -1em, + -2em 2em 0 0, -3em 0em 0 0, -2em -2em 0 0.2em; + } +} diff --git a/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/element.css b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/element.css new file mode 100644 index 0000000..ca00643 --- /dev/null +++ b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/element.css @@ -0,0 +1,1823 @@ + + +[data-viewtype="source-file"] .requirement__link:hover { + text-decoration: none; +} + +svg { + /* Disable shrinking of icons in flex strings */ + flex-shrink: 0; +} + +/* typography */ + +h1 { font-size: 2em; } +h2 { font-size: 1.6em; } +h3 { font-size: 1.4em; } +h4 { font-size: 1.2em; } +h5 { font-size: 1em; } +h6 { font-size: 1em; } + +h1:first-child, +h2:first-child, +h3:first-child, +h4:first-child, +h5:first-child, +h6:first-child { + margin-top: 0; +} + +/* a */ + +a { + /* Disabled link styles */ + text-decoration: none; + color: gray; + transition: color .2s ease; +} + +a:link, +a:visited, +a[href] { /* or a[href] */ + /* Enabled link styles */ + text-decoration: none; + color: var(--color-link); +} + +a:hover { + /* color: blueviolet; */ + color: var(--color-hover); +} + +a[aria-disabled="true"] { + /* color: currentColor; */ + cursor: not-allowed; + opacity: 0.5; + text-decoration: none; + pointer-events: none; +} + +/* misc */ + +code { + position: relative; + padding: 0 4px; + font-style: normal; + font-family: var(--code-font-family); + font-size: var(--code-font-size); + background-color: var(--color-bg-main); + border: 1px solid var(--color-border); + border-radius: 4px; + + overflow-wrap: break-word; + word-wrap: break-word; + -webkit-box-decoration-break: clone; + box-decoration-break: clone; +} + +/* action_button */ + +.actions_group { + display: flex; + /* header context: */ + column-gap: calc(var(--base-rhythm)/2); + margin-left: auto; +} + +.action_button, +a.action_button, +a.action_button:link, +a.action_button:visited { + font-size:var(--font-size-xsm); + font-weight: 600; + text-align: left; + text-decoration: none; + white-space: nowrap; + position: relative; + display: inline-flex; + + align-items: center; + justify-content: center; + -webkit-box-align: center; + -webkit-box-pack: center; + border-radius: 6px; + border: 1px solid transparent; + backface-visibility: hidden; + user-select: none; + cursor: pointer; + appearance: none; + + /* 1.5 column-gap is compensated by SVG negative margin */ + column-gap: calc(var(--base-rhythm)*1.5); + padding-left: calc(var(--base-rhythm)*1.5); + padding-right: calc(var(--base-rhythm)*1.5); + min-height: calc(var(--base-rhythm)*4); + max-width: 100%; + + /* box-shadow: rgb(0 0 0 / 10%) 0px 1px 2px 0px; */ + color: var(--color-action); + background-color: rgb(255, 255, 255); + border-color: rgba(0, 0, 0, 0.05); + background-clip: padding-box; + + transition: 0.2s; +} + +.action_button:hover, +a.action_button:hover { + box-shadow: rgb(0 0 0 / 10%) 0px 2px var(--base-rhythm) 0px; + color: var(--color-hover); + z-index: 6; +} + +.action_button:disabled, +.action_button:disabled:hover, +.action_button[aria-disabled="true"], +.action_button[aria-disabled="true"]:hover { + color: var(--color-action); + opacity: .4; + cursor: default; +} + +.action_button svg { + /* + action_button 1.5 column-gap + is compensated by SVG negative margin + */ + margin-left: calc(var(--base-rhythm)*(-.5)); + margin-right: calc(var(--base-rhythm)*(-.5)); +} + +[data-action-type="submit"], +.action_button[type=submit] { + color: var(--color-submit); +} + +[data-action-type="action"], +[data-action-type="confirm_delete"] { + color: var(--color-action) !important; + border-color: var(--color-action) !important; +} + +[data-action-type="delete"], +[data-action-type="confirm_delete"] { + color: var(--color-danger) !important; + border-color: var(--color-danger) !important; +} + +[data-action-type="confirm_delete"]:hover { + color: var(--color-bg-contrast) !important; + background: var(--color-danger) !important; +} + +[data-action-type="cancel"], +.action_button[href*="cancel"] { + color: var(--color-cancel) !important; +} + +.action_icon, +a.action_icon, +a.action_icon:link, +a.action_icon:visited { + position: relative; + display: inline-flex; + align-items: center; + justify-content: center; + -webkit-box-align: center; + -webkit-box-pack: center; + backface-visibility: hidden; + user-select: none; + cursor: pointer; + appearance: none; + border: none; + border-color: transparent; + background-color: rgba(0,0,0,0); + background: rgba(0,0,0,0); + box-shadow: none; + background-clip: padding-box; + + color: var(--color-action); + transition: 0.2s; + padding: calc(var(--base-rhythm)*.5); + z-index: 2; +} + +.action_icon.secondary, +a.action_icon.secondary, +a.action_icon.secondary:link, +a.action_icon.secondary:visited { + color: var(--color-link); +} + +.action_icon.secondary:hover, +a.action_icon.secondary:hover, +.action_icon:hover, +a.action_icon:hover { + color: var(--color-hover); + z-index: 6; +} + +.action_button.compact { + column-gap: 0; + padding-left: calc(var(--base-rhythm)* 0.75); + padding-right: calc(var(--base-rhythm)* 0.75); + min-height: calc(var(--base-rhythm)*3); +} + +.action_button.compact .action_button_compact__arising { + overflow: hidden; + + max-width: 0; + margin-left: 0; + + transition-property: max-width, margin; + transition-duration: .5s; + transition-timing-function: ease-in-out; + transition-delay: 1s; +} + +.action_button.compact:hover > .action_button_compact__arising { + max-width: 200px; + margin-left: var(--base-rhythm); + + transition-property: max-width, margin; + transition-duration: .5s; + transition-timing-function: ease-in-out; + transition-delay: 0; +} + +/* TODO */ +sdoc-node-controls .action_button { + /* depends on sdoc-node-controls: */ + /* + width: calc(var(--base-rhythm)*4); + height: calc(var(--base-rhythm)*4); + */ + padding: 0 !important; + width: unset; + height: unset; + min-height: calc(var(--base-rhythm)*3) !important; + max-width: 100%; + max-height: 100%; + aspect-ratio: 1; + border-radius: 20% !important; + + vertical-align: top; +} + +/* field_action */ +/* TODO: optimize code with .action_icon & .action_button */ + +.field_action { /* button */ + font-size:var(--font-size-xsm); + font-weight: 600; + text-align: left; + text-decoration: none; + white-space: nowrap; + + position: static; + display: inline-flex; + align-items: center; + justify-content: center; + -webkit-box-align: center; + -webkit-box-pack: center; + backface-visibility: hidden; + user-select: none; + cursor: pointer; + appearance: none; + border: none; + border-color: transparent; + background-color: rgba(0,0,0,0); + background: rgba(0,0,0,0); + box-shadow: none; + background-clip: padding-box; + + color: var(--color-action); + transition: 0.2s; + padding: calc(var(--base-rhythm)*.5); + z-index: 2; +} + +.field_action:hover, +a.field_action:hover { + color: var(--color-hover); + z-index: 6; +} + +.field_action::before { + content: ''; + position: absolute; + /* The element is expected to be placed in a context + that defines the top and bottom boundaries. + + The width of the element must be enough + to cover the entire available context, + and will be cut off by the parent element via overflow. + */ + top: calc(var(--base-rhythm)*(-3)); /* -2 */ + bottom: calc(var(--base-rhythm)*(-1)); /* -2 */ + left: -100vw; + right: -100vw; + z-index: 0; + pointer-events: none; + /* Determines the shade of the color through the opacity of the element. + The color is passed from the parent. + */ + transition: background-color 0.3s; + background-color: transparent; + opacity: .1; /* Defines the color shade. */ +} + +.field_action:hover::before { + background: currentcolor; +} + +/* *** + USED BY copy_to_clipboard controller + */ + +sdoc-field { + display: flex; + /* it is assumed that it will automatically stretch, as a block element, + to the entire field space, and the elements in the service area will be + positioned relative to it: + */ + position: relative; + flex-grow: 1; + width: 100%; /* holds within the width of the parent */ +} + +sdoc-field-content { + flex-grow: 1; + width: 100%; /* holds within the width of the parent */ +} + +.copy_to_clipboard-cover { + position: absolute; + z-index: 98; + top: 0; + bottom: 0; + left: 0; + right: 0; + pointer-events: none; + + border-top-right-radius: 6px; /* TODO 4 + in button*/ + background-color: rgba(242, 100, 42, 0); + transition: .5s ease-out; +} + +.copy_to_clipboard-cover:hover { + background-color: rgba(242, 100, 42, 0.05); + transition: .5s ease-out; +} + +/* Fix: Prevent .copy_to_clipboard-button from receiving hover when covered by dropdown menu */ +sdoc-field > sdoc-field-service .copy_to_clipboard-button { + visibility: hidden; +} + +sdoc-field:hover > sdoc-field-service .copy_to_clipboard-button { + visibility: visible; +} + +/* button overrides */ +.copy_to_clipboard-button.action_button { + height: calc(var(--base-rhythm)*3); + width: calc(var(--base-rhythm)*3); + min-height: unset; + padding: var(--base-rhythm); + position: absolute; + right: 0; + pointer-events: auto; + + max-height: 100%; /* for meta row: to keep the copy button from expanding out of the content line */ +} + +/* button behavior */ +sdoc-field .copy_to_clipboard-button { + transition: .5s ease-out; + opacity: 0; +} + +sdoc-field:hover .copy_to_clipboard-button { + opacity: 1; +} + +/* *** + USED BY copy_stable_link controller + inside sdoc-node + */ + +.copy_stable_link-button { + display: inline-flex; + align-items: center; + justify-content: center; + padding: var(--base-rhythm); + + position: absolute; + left: 0; + top: 0; + + cursor: pointer; + transition: .5s ease-out; + opacity: 0; +} + +.copy_stable_link-button:hover { + color: var(--color-action); +} + +sdoc-node:hover .copy_stable_link-button { + opacity: 1; +} + +/* ANCHOR */ + +sdoc-anchor { + /* for Fixed Headers + Section Anchors */ + /* calc(var(--base-gap) + var(--base-padding)); */ + scroll-snap-margin-top: var(--base-gap); + scroll-margin-top: var(--base-gap); +} + +sdoc-node > sdoc-anchor { + scroll-snap-margin-top: unset; /** top: 0; */ + scroll-margin-top: unset; /** top: 0; */ + + display: block; + position: absolute; + top: 0; + bottom: 0; + z-index: 0; +} + +sdoc-anchor.anchor_in_rst { + top:unset; + /* + For anchors generated within the text, + we shift them to the left, beyond the node + (by the sdoc-node padding-inline). + */ + transform: translateX(calc(-4 * var(--base-rhythm))); +} + +sdoc-anchor:target + sdoc-node-content sdoc-node-title, +sdoc-anchor:target + sdoc-section sdoc-section-title, +sdoc-anchor:target + .requirement__title { + background-color: var(--color-highlight); +} + +sdoc-anchor .anchor_block { + display: none; +} + +/* + This styles should only be triggered if + export/html/_static/controllers/anchor_controller.js + processes the parent sdoc-node. +*/ +sdoc-node[data-controller="anchor_controller"] sdoc-anchor { + position: absolute; + z-index: 2; + left: 0; + transition: opacity 0.5s; + opacity: 0; +} + +sdoc-node[data-controller="anchor_controller"]:hover sdoc-anchor { + opacity: 1; +} + +sdoc-node[data-controller="anchor_controller"] sdoc-anchor.anchor_has_back_links { + opacity: 1; +} + +sdoc-node[data-controller="anchor_controller"] sdoc-anchor:hover { + z-index: 10; +} + +sdoc-node[data-controller="anchor_controller"] sdoc-anchor .anchor_block { + display: block; + position: absolute; + top: 0; + left: calc(-4 * var(--base-rhythm) - 3px); + + border-radius: 6px; + transition: opacity 0.2s; + opacity: .6; +} + +sdoc-node[data-controller="anchor_controller"] sdoc-anchor:hover .anchor_block { + background-color: rgb(255, 255, 255); + border-color: rgba(0, 0, 0, 0.05); + box-shadow: rgb(0 0 0 / 10%) 0px 2px var(--base-rhythm) 0px; + opacity: 1; +} + +sdoc-node[data-controller="anchor_controller"] sdoc-anchor .anchor_button { + cursor: pointer; + font-size:var(--font-size-sm); + font-weight: 600; + text-align: left; + white-space: nowrap; + position: relative; + display: inline-flex; + align-items: center; + justify-content: flex-start; + + border-radius: 6px; + border: 1px solid transparent; + background-clip: padding-box; + + /* 1.5 column-gap is compensated by SVG negative margin */ + column-gap: calc(var(--base-rhythm)*1.5); + padding-left: calc(var(--base-rhythm)*1.5); + padding-right: calc(var(--base-rhythm)*1.5); + min-height: calc(var(--base-rhythm)*4); + min-width: calc(var(--base-rhythm)*4); + + /* box-shadow: rgb(0 0 0 / 10%) 0px 1px 2px 0px; */ + /* color: var(--color-action); */ + + overflow: hidden; + + transition: opacity 0.2s; + opacity: .6; +} + +sdoc-node[data-controller="anchor_controller"] sdoc-anchor .anchor_button:hover { + color: var(--color-hover); + z-index: 6; + + opacity: 1; +} + +sdoc-node[data-controller="anchor_controller"] sdoc-anchor .anchor_button svg { + color: var(--color-fg-secondary); + margin-left: calc(var(--base-rhythm)*(-.5)); + margin-right: calc(var(--base-rhythm)*(-.5)); +} + +sdoc-node[data-controller="anchor_controller"] sdoc-anchor.anchor_has_back_links .anchor_button svg { + color: black; + opacity: 1; +} + +sdoc-node[data-controller="anchor_controller"] sdoc-anchor .anchor_button:hover svg { + color: var(--color-action) !important; +} + +sdoc-node[data-controller="anchor_controller"] sdoc-anchor .anchor_button_text { + font-size: var(--font-size-sm); + font-weight: bolder; + + display: none; +} + +sdoc-node[data-controller="anchor_controller"] sdoc-anchor:hover .anchor_button_text { + display: block; +} + +sdoc-node[data-controller="anchor_controller"] sdoc-anchor .anchor_back_links { + min-width: 300px; + padding-left: calc(var(--base-rhythm)*4); + padding-right: var(--base-rhythm); + padding-top: var(--base-rhythm); + padding-bottom: calc(var(--base-rhythm)*1); + + display: none; +} + +sdoc-node[data-controller="anchor_controller"] sdoc-anchor:hover .anchor_back_links { + display: block; +} + +sdoc-node[data-controller="anchor_controller"] sdoc-anchor .anchor_back_links a { + display: list-item; +} +sdoc-node[data-controller="anchor_controller"] sdoc-anchor .anchor_back_links a::marker { + content: 'โ‡  '; + width: calc(var(--base-rhythm)*4); +} + +sdoc-node[data-controller="anchor_controller"] sdoc-anchor .anchor_back_links_number { + color: var(--color-fg-accent); + position: absolute; + width: calc(var(--base-rhythm)*4); + text-align: center; + top: calc(var(--base-rhythm)*3); + left: 0; + font-weight: bold; +} + +sdoc-node[data-controller="anchor_controller"] sdoc-anchor:hover .anchor_back_links_number { + top: calc(var(--base-rhythm)*5); +} + +/* nav */ + +.nav { + list-style: none; + padding: 0; + margin: 0; + + display: flex; + flex-flow: column nowrap; + background-color: var(--color-bg-ui); + width: var(--base-gap); + height: 100%; +} + +.nav_list { + list-style: none; + padding: 0; + margin: 0; +} + +.nav_list li { + margin-bottom: var(--base-rhythm); +} + +.nav_list__link { + display: flex; + column-gap: var(--base-rhythm); +} + +/* nav_button */ + +.nav_button { + display: flex; + justify-content: center; + align-items: center; + cursor: pointer; + + text-decoration: none; + + height: var(--base-gap); + width: var(--base-gap); + transition: 0.3s; + + color: var(--color-fg-secondary); +} + +.nav_button:hover { + color: var(--color-fg-contrast); +} + +.nav .nav_button { + color: var(--color-fg-secondary-invert); + background-color: transparent; + border-left: 2px solid transparent; +} + +.nav .nav_button:hover { + color: var(--color-bg-contrast); + border-color: var(--color-bg-contrast); +} + +/* should be like .nav .nav_button:hover */ +[data-viewtype="document-tree"] [data-link="index"], +[data-viewtype="search"] [data-link="search"], +[data-viewtype="diff"] [data-link="diff"], +[data-viewtype="requirements-coverage"] [data-link="requirements_coverage"], +[data-viewtype="traceability-matrix"] [data-link="traceability-matrix"], +[data-viewtype="coverage-tree"] [data-link="source_coverage"] { + color: var(--color-bg-contrast); + border-color: var(--color-bg-contrast); + cursor: default; +} + +/* sdoc tabs (page nav) */ + +.sdoc-tabs { + border-bottom: 1px solid var(--color-border); +} + +.sdoc-tab-list { + display: flex; + overflow: auto; + margin-bottom: -1px; +} + +.sdoc-tab { + padding: var(--base-rhythm) calc(2 * var(--base-rhythm)); + font-size: var(--font-size-xsm); + font-weight: 600; + line-height: 1; + color: var(--color-link); + text-decoration: none; + background-color: transparent; + border-width: 1px 1px 0px; + border-top-style: solid; + border-right-style: solid; + border-left-style: solid; + border-top-color: transparent; + border-right-color: transparent; + border-left-color: transparent; + border-image: initial; + border-bottom-style: initial; + border-bottom-color: initial; + + color: var(--color-fg-contrast); +} + +.sdoc-tab:hover { + color: var(--color-hover); +} + +.sdoc-tab[active] { + color: var(--color-fg-contrast); + border-color: var(--color-border); + border-top-right-radius: 4px; + border-top-left-radius: 4px; + background-color: var(--color-bg-main); +} + +/* tags */ + +.tags { + padding-bottom: var(--base-gap); +} + +.tag { + display: inline-flex; + align-items: center; + background-color: rgba(0,0,0,0.1); + border: 2px solid rgba(0,0,0,0.05); + font-size: 12px; + line-height: 1; + vertical-align: middle; + margin: 2px 0px; + padding-left: 8px; + border-radius: 2em; +} + +.tag_badge { + display: inline-flex; + justify-content: center; + align-items: center; + font-size: var(--font-size-xxsm); + background-color: rgba(255, 255, 255, 0.75); + border: 4px solid transparent; + min-width: 18px; + height: 18px; + border-radius: 2em; + margin-left: 4px; +} + +/* coverage */ + +.value-bar { + display: flex; + height: 1rem; + align-items: center; + gap: 4px; +} + +.value-bar_bar { + width: 3rem; + border-radius: .5rem; + + /* box-shadow: inset 0px 2px 2px 0px #ccc; */ + border: 1px solid rgba(0,0,0,0.1); + position: relative; + overflow: hidden; + + height: 0.75rem; + + background-color: rgba(255, 255, 255, 0.2); +} + +.value-bar_bar[data-value] { + border: 1px solid rgb(80, 240, 40); + background-color: rgba(255, 255, 255, 1); +} + +.value-bar_filler { + position: absolute; + top: 0; + bottom: 0; + left: 0; + background: rgb(80, 240, 40); +} + +.value-bar_text { + width: 2.5rem; + text-align: right; + font-size: 0.75rem; + line-height: 1; + font-weight: 600; +} + +ol.arabic { + list-style: decimal; +} + +ol.loweralpha { + list-style: lower-alpha; +} + +ol.upperalpha { + list-style: upper-alpha; +} + +ol.lowerroman { + list-style: lower-roman; +} + +ol.upperroman { + list-style: upper-roman; +} + +/* svg icon */ + +svg.svg_icon polyline, +svg.svg_icon line, +svg.svg_icon circle, +svg.svg_icon rect, +svg.svg_icon path { + fill: none; + fill-rule: evenodd; + stroke-width: 1.5; + /* stroke: #000; */ + stroke: currentColor; + stroke-linecap: round; + stroke-linejoin: round; + /* transition: 0.2s; */ +} + +svg.svg_icon { + width: calc(var(--base-rhythm)*2); + height: calc(var(--base-rhythm)*2); + flex: 0 0 auto; + background: transparent; + /* color: rgb(246, 153, 13); */ +} + +.svg_icon_hover_visible { + display: none; +} +.anchor_button:hover .svg_icon_hover_visible, +svg:hover .svg_icon_hover_visible { + display: inline; +} +.svg_icon_not_hover_visible { + display: inline; +} +.anchor_button:hover .svg_icon_not_hover_visible, +svg:hover .svg_icon_not_hover_visible { + display: none; +} + +/* .header */ + +.header { + height: calc(var(--base-rhythm)*6); + display: flex; + align-items: center; + justify-content: flex-start; + column-gap: calc(var(--base-rhythm)/2); + padding-left: calc(var(--base-rhythm)*2); + padding-right: var(--base-rhythm); + border-bottom: var(--base-border); + min-width: 0; +} + +.header__document_title { + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + font-size: var(--font-size-sm); + font-weight: 700; + + flex-shrink: 0.1; +} + +.header__project_name { + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + font-size: var(--font-size-sm); + font-weight: 400; + min-width: calc(var(--base-rhythm)*2.5); + + flex-shrink: 100; +} + +/* .footer */ + +.footer { + display: flex; + align-items: center; + justify-content: flex-end; + height: 100%; + padding: var(--base-rhythm) calc(var(--base-rhythm)*2); + column-gap: calc(var(--base-rhythm)/2); + background-color: var(--color-bg-ui); + color: var(--color-fg-secondary-invert); + font-size: .85rem; +} + +a.strictdoc__link { + color: var(--color-fg-accent); + fill: var(--color-fg-accent); +} + +a.strictdoc__version { + color: var(--color-fg-secondary-invert); + fill: var(--color-fg-secondary-invert); + display: flex; + column-gap: calc(var(--base-rhythm)/2); + align-items: center; +} + +a.strictdoc__link:hover, +a.strictdoc__version:hover { + color: var(--color-bg-main); + fill: var(--color-bg-main); +} + +/* --md-source-version-icon: url(data:image/svg+xml;charset=utf-8,); */ + + +/* pagetype */ + +.pagetype { + font-size: var(--font-size-xxsm); + font-weight: 700; + text-transform: uppercase; + color: var(--color-fg-secondary); + display: flex; + align-items: center; + justify-content: center; + line-height: 1; +} + +/* viewtype */ + +.viewtype { + position: relative; + font-size: var(--font-size-xsm); +} + +.viewtype__handler { + font-weight: 500; + color: var(--color-fg-accent); + cursor: pointer; + display: flex; + align-items: center; + justify-content: center; + column-gap: calc(var(--base-rhythm)/2); + user-select: none; +} + +.viewtype__menu { + position: absolute; + z-index: 99; + left: calc(var(--base-rhythm)*(-2)); + top: calc(var(--base-rhythm)*3); + margin: 0; + list-style: none; + padding: var(--base-rhythm); + background: var(--color-bg-contrast); + box-shadow: 0 2px 8px rgb(0 0 0 / 20%); + border-radius: var(--base-rhythm); + font-weight: 500; + display: flex; + flex-direction: column; + row-gap: calc(var(--base-rhythm)/2); +} + +.viewtype__menu[aria-hidden="true"] { + display: none; +} + +.viewtype__menu[aria-hidden="false"] { + display: flex; +} + +.viewtype__menu_header { + padding: var(--base-rhythm); + text-transform: uppercase; + color: var(--color-fg-secondary); + font-weight: 700; + font-size: var(--font-size-xxsm); +} + +.viewtype__menu_item { + padding: 0; + margin: 0; + list-style: none; + white-space: nowrap; + display: block; + padding: var(--base-rhythm); + border-radius: calc(var(--base-rhythm)/2); +} + +.viewtype__menu_item, +.viewtype__menu_item:link, +.viewtype__menu_item:visited { + text-decoration: none; + color: var(--color-fg-main); +} + +.viewtype__menu_item:hover { + background-color: var(--color-bg-secondary); + color: var(--color-fg-accent); +} + +[data-viewtype="document"] [data-viewtype_link="document"], +[data-viewtype="table"] [data-viewtype_link="table"], +[data-viewtype="traceability"] [data-viewtype_link="traceability"], +[data-viewtype="deep_traceability"] [data-viewtype_link="deep_traceability"], +[data-viewtype="standalone_document"] [data-viewtype_link="standalone_document"], +[data-viewtype="html2pdf"] [data-viewtype_link="html2pdf"], +.viewtype__menu_item.active { + background-color: var(--color-bg-accent); + color: var(--color-fg-accent); + cursor: default; +} + +/* sdoc-menu */ + +sdoc-menu menu { + position: absolute; + z-index: 99; + right: 100%; + top: 0; + margin: 0; + list-style: none; + padding: var(--base-rhythm); + background: var(--color-bg-contrast); + box-shadow: 0 2px 8px rgb(0 0 0 / 20%); + border-radius: var(--base-rhythm); + font-weight: 500; + + display: flex; + flex-direction: column; + row-gap: calc(var(--base-rhythm)/2); + +} + +sdoc-menu.add_node menu { + display: grid; + grid-template-columns: minmax(min-content, max-content) + minmax(min-content, max-content) + minmax(min-content, max-content) + minmax(min-content, max-content); +} + +sdoc-menu menu[aria-hidden="true"] { + display: none; +} + +sdoc-menu menu[aria-hidden="false"] { + display: flex; +} +sdoc-menu.add_node menu[aria-hidden="false"] { + display: grid; +} + +sdoc-menu header:first-child { + /* "Add node" */ + grid-column: 1 / -1; + border-bottom: var(--base-border); +} + +sdoc-menu menu a { + padding: 0; + margin: 0; + list-style: none; + white-space: nowrap; + display: flex; /* affects the 'add node' buttons */ + padding: var(--base-rhythm); + border-radius: calc(var(--base-rhythm)/2); + font-size: var(--font-size-xsm); +} + +sdoc-menu menu a, +sdoc-menu menu a:link, +sdoc-menu menu a:visited { + text-decoration: none; + color: var(--color-fg-main); +} + +sdoc-menu menu a:hover { + background-color: var(--color-bg-secondary); + color: var(--color-fg-accent); +} + +sdoc-menu menu header { + padding: var(--base-rhythm); + text-transform: uppercase; + color: var(--color-fg-secondary); + font-weight: 700; + font-size: var(--font-size-xxsm); +} + +/* plus to close */ +sdoc-menu-handler[aria-expanded="true"] svg { + transform: rotate(45deg); + color: black; +} + +/* affects other menus: */ +[aria-expanded="true"] svg { + color: black; +} + +/* tree */ + +.tree { + display: flex; + flex-direction: column; + justify-content: flex-start; + align-items: flex-start; + gap: var(--base-rhythm); + margin-top: calc(var(--base-rhythm) * 2); + margin-bottom: calc(var(--base-rhythm) * 8); + padding-left: calc(var(--base-rhythm) * 2); + padding-right: calc(var(--base-rhythm) * 2); +} + +.tree_fragments { /* ul */ + margin-top: 0; + margin-bottom: 0; + padding-left: calc(var(--base-rhythm) * 2); + padding-right: 0; + list-style: none; + width: 100%; +} + +.tree_fragments li { + list-style: none; + width: 100%; +} + +.tree_fragments, +.tree_fragments li { + display: flex; + flex-direction: column; + justify-content: flex-start; + align-items: flex-start; + gap: var(--base-rhythm); +} + +.tree_folder { + display: flex; + align-items: flex-start; + justify-content: flex-start; + column-gap: var(--base-rhythm); + min-width: 0; + line-height: 1.5; + width: 99%; + padding-top: 8px; + margin-top: 8px; + opacity: 0.6; + position: relative; + border-top: var(--base-border); +} + +.tree_folder:first-child { + border-top: none; +} + +.tree_folder_path { + font-size: var(--font-size-xsm); + font-weight: 400; +} + +a.tree_item, +.tree_item { + display: flex; + align-items: flex-start; + justify-content: flex-start; + column-gap: var(--base-rhythm); + font-size: var(--font-size-sm); + min-width: 0; + line-height: 1.5; + width: 99%; /* To calculate cite overflow */ +} + +.tree_item[active] { + color: var(--color-fg-contrast); +} + +.document_title { + font-size: var(--font-size-sm); + font-weight: 700; + width: 99%; /* To calculate cite overflow */ +} + +.document_title[data-file_name]::after { + content: attr(data-file_name); + display: block; + text-overflow: ellipsis; + overflow: hidden; + width: 99%; /* To calculate cite overflow */ + font-weight:400; + opacity:0.6; +} + +/** TOC **/ + +.toc, +.toc ul, +.toc li { + list-style: none; + padding: 0; + margin: 0; +} + +.toc { + margin-top: calc(var(--base-rhythm) * 2); + padding-left: calc(var(--base-rhythm) * 2); + font-size: var(--font-size-sm); + line-height: 1.2; + padding-bottom: var(--base-gap); +} + +.toc li { + margin: 0; + padding-left: var(--base-rhythm); + position: relative; +} + +.toc a { + display: block; + position: relative; + padding-top: var(--base-rhythm); + padding-bottom: var(--base-rhythm); + padding-right: var(--base-rhythm); +} + +.toc a, +.toc a:link, +.toc a:visited { + text-decoration: none; + color: var(--color-fg-secondary); +} +.toc a:hover { + color: var(--color-fg-contrast); +} + +.toc a:focus, +.toc a:active { + background: transparent; +} + +.toc-title-no-link { + color: var(--color-fg-secondary); + opacity: .6; + display: block; + padding-top: var(--base-rhythm); + padding-bottom: var(--base-rhythm); + padding-right: var(--base-rhythm); +} + +/* TOC targeted */ +.toc a[targeted]::before { + position: absolute; + z-index: -1; + content: ''; + top: 0; + bottom: 0; + right: 0; + left: -200px; /* parent has overflow */ + background-color: var(--color-highlight); +} + +/* TOC intersected */ +.toc a::after { + position: absolute; + z-index: -1; + content: ''; + top: 0; + right: 0; + bottom: 0; + width: 8px; + background-color: var(--color-bg-main); +} + +.toc a[intersected]::after { + position: absolute; + z-index: -1; + content: ''; + top: 0; + right: 0; + bottom: 0; + width: 8px; + background-color: var(--color-highlight); +} + +/* TOC parented */ +/* behavior depends on collapsible_list.js */ +.toc [data-collapsible_list__branch="closed"] ~ a[parented]::after { + background-color: var(--color-highlight); +} + +/* pdf-toc */ + +.pdf-toc { + display: table; + width: 100%; +} +.pdf-toc-row { + display: table-row; +} +.pdf-toc-cell { + display: table-cell; + padding-top: var(--base-rhythm); + padding-right: var(--base-rhythm); + font-size: 1em; + line-height: 1.5; +} +.pdf-toc-cell[dotted] { + position: relative; + width: 100%; /* to get max */ +} +.pdf-toc-cell[dotted] > * { + background-color: white; + display: inline; + padding-right: 8px; + position: relative; +} +.pdf-toc-cell[dotted]::before { + content: ''; + position: absolute; + border-bottom: dotted 2px rgba(0,0,0,.4); + bottom: .4em; + left: .8em; + right: .8em; +} +.pdf-toc-cell:last-child { /* page number */ + vertical-align: bottom; + padding-right: 0; + text-align: right; +} + +/* table_key_value component */ + +.sdoc-table_key_value { + display: grid; + grid-template-columns: minmax(min-content, max-content) minmax(min-content, 1fr); + place-items: stretch stretch; + place-content: stretch stretch; + position: relative; + border: var(--base-border); + border-radius: calc(var(--base-rhythm)*0.5); + + margin: var(--base-padding) 0; + padding: calc(var(--base-rhythm)*0.5); + gap: 2px; + + width: fit-content; + max-width: 100%; + /* overflow-x: auto; */ +} + +.sdoc-table_key_value-section, +.sdoc-table_key_value-key, +.sdoc-table_key_value-value { + padding: var(--base-rhythm) calc(var(--base-rhythm)*2); + background-color: var(--color-bg-secondary); +} + +.sdoc-table_key_value-key { + grid-column: 1 / 2; + color: var(--color-fg-main); + + display: flex; + flex-direction: row; + justify-content: flex-start; + align-items: flex-start; + + position: relative; + transition: 0.3s all; +} + +a.sdoc-table_key_value-key { + background-color: rgba(255,255,255,0.5); + color: var(--color-fg-contrast); + padding-right: calc(var(--base-rhythm)*5); + align-items: center; +} + +a.sdoc-table_key_value-key:hover { + background-color: rgba(255,255,255,1); + color: var(--color-fg-accent); +} + +a.sdoc-table_key_value-key::after { + content: "โ–ธ"; + position: absolute; + right: calc(var(--base-rhythm)*2); + color: var(--color-fg-accent); + font-size: var(--font-size-sm); +} + +.sdoc-table_key_value-value { + grid-column: 2 / 3; +} + +.sdoc-table_key_value-section { + grid-column: 1 / -1; + + padding: calc(var(--base-rhythm)*2); + padding-top: calc(var(--base-rhythm)*4); + padding-bottom: calc(var(--base-rhythm)*1); + font-family: var(--code-font-family); + + font-size: 0.85em; + font-weight: 500; + text-transform: uppercase; + color: var(--color-fg-secondary); + background-color: var(--color-bg-main); +} + +/* badge */ + +.badge { + white-space: nowrap; +} + +.badge::before { + content: attr(text); + padding: 0 calc(var(--base-rhythm)/2); + border: 1px solid; + border-radius: calc(var(--base-rhythm)/2); + font-size: var(--font-size-xxsm); + font-weight: 600; + text-transform: uppercase; +} + +.error { + color: var(--color-danger); +} + +/* tabs */ + +sdoc-tab-content { + display: none; +} +sdoc-tab-content[active] { + display: contents; +} + +sdoc-tabs { + grid-column: 1 / -1; + + /* compensate top padding for sdoc-form-grid: */ + /* margin-top: calc(var(--base-rhythm)*(-4)); */ + padding: calc(var(--base-rhythm)*(1)) calc(var(--base-rhythm)*(2)) 0; + + background-color: var(--color-bg-main); + border-radius: 4px; + + display: flex; +} + +sdoc-tab { + font-size: var(--font-size-xsm); + font-weight: 600; + text-align: left; + text-decoration: none; + white-space: nowrap; + position: relative; + display: inline-flex; + + align-items: center; + justify-content: center; + -webkit-box-align: center; + -webkit-box-pack: center; + + border: 1px solid transparent; + border-bottom: none; + border-radius: 4px 4px 0 0; + + user-select: none; + cursor: pointer; + appearance: none; + + /* 1.5 column-gap is compensated by SVG negative margin */ + /* column-gap: calc(var(--base-rhythm)*1.5); */ + + min-height: calc(var(--base-rhythm)*4); + padding-left: calc(var(--base-rhythm)*1.5); + padding-right: calc(var(--base-rhythm)*1.5); + + color: rgba(0, 0, 0, 0.5); + background-color: rgba(255, 255, 255, 0); + background-clip: padding-box; + + transition: 0.2s; +} + +sdoc-tab:hover { + background-color: rgba(255, 255, 255, 0.5); +} + +sdoc-tab[active] { + color: var(--color-hover); + background-color: rgba(255, 255, 255, 1); + cursor: default; +} + +sdoc-tab[data-errors] { + color: var(--color-danger); + border-color: var(--color-danger); +} + +sdoc-tab[data-errors]::after { + content: attr(data-errors); + display: flex; + justify-content: center; + align-items: center; + background-color: var(--color-danger); + color: var(--color-bg-contrast); + font-size: var(--font-size-xsm); + height: calc(var(--font-size-xsm)*1.75); + width: calc(var(--font-size-xsm)*1.75); + aspect-ratio: 1; + border-radius: 50%; + + /* parent column-gap == 0 */ + position: relative; + right: calc(var(--base-rhythm)*(-1)); +} + +sdoc-tabs.in_aside_panel { + background-color: var(--color-highlight-secondary); + border-bottom: 4px solid var(--color-bg-main); +} + +sdoc-tabs.in_aside_panel sdoc-tab:hover { + background-color: rgba(255, 255, 255, 0.25); +} + +sdoc-tabs.in_aside_panel sdoc-tab[active] { + background-color: var(--color-bg-main); +} + +/* document_issues */ + +.document_issues-banner { + display: flex; + flex-direction: column; + position: relative; + margin-bottom: var(--base-gap); + font-size: var(--font-size-sm); +} + +.document_issues-toggler { + text-align: right; +} + +.document_issues-banner_details { + display: block; + overflow: hidden; + color: var(--color-danger); + border: 1px solid; + border-radius: var(--requirement-border-radius); +} + +.document_issues-banner_summary { + font-weight: 600; + position: relative; + color: var(--color-danger); + padding-inline: calc(2 * var(--base-rhythm)); + padding-block: var(--base-rhythm); + cursor: pointer; + user-select: none; + display: flex; +} + +.document_issues-banner_summary::before { + content: 'โ–ธ'; + margin-right: var(--base-rhythm); +} + +[open] > .document_issues-banner_summary::before { + content: 'โ–พ'; +} + +.document_issues-banner_summary::after { + content: ''; + position: absolute; + inset: 0; + background-color: currentColor; + opacity: 0.1; +} + +.document_issues-banner_content { + position: relative; + color: var(--color-fg-contrast); + padding-inline: calc(2 * var(--base-rhythm)); + padding-block: calc(1 * var(--base-rhythm)); +} + +.document_issues-banner ul { + margin: 0; + padding-inline-start: 20px; +} + +.field_issue { + grid-column: 1 / -1; + position: relative; + color: var(--color-danger); + padding: var(--base-rhythm) 0; + font-size: var(--font-size-sm); + line-height: 1.5; +} + +.field_issue-ribbon { + position: relative; + padding: calc(.5 * var(--base-rhythm)) var(--base-rhythm); + border-radius: calc(.5 * var(--base-rhythm)); + border: 1px solid; +} + +sdoc-node-content .field_issue-ribbon::before { + position: absolute; + content: ''; + bottom: 100%; + left: var(--base-rhythm); + width: 0; + height: 0; + border-left: 6px solid transparent; + border-right: 6px solid transparent; + border-bottom: 6px solid currentColor; +} + +.field_issue-ribbon::after { + content: ''; + position: absolute; + inset: 0; + pointer-events: none; +} + +/* + ** SEARCH bar and result area + */ + +.search-box { + /* DEV: to push to the right in the header flex box */ + margin-left: auto; +} + +.actions_group + .search-box { + /* DEV: if on the server to the right of the action buttons */ + margin-left: unset; +} + +.search-input { + z-index: 101; + position: relative; + min-height: calc(var(--base-rhythm) * 6); /* = .header height */ + display: flex; + align-items: center; + justify-content: flex-end; +} + +.search-input input { + width: 145px; + transition: all .3s ease-out; +} + +.search-box[active] .search-input { + width: 100%; + border-bottom: var(--base-border); + padding-inline: var(--base-rhythm); +} + +.search-box[active] .search-input input { + width: 100%; +} + +.search-box[active] { + z-index: 100; + position: fixed; + width: 50%; + min-width: 300px; + right: 0; + top: 0; + bottom: 0; + background-color: white; + box-shadow: var(--base-elevation); + + display: flex; + flex-direction: column; + min-height: 0; +} + +.search-results { + display: none; +} + +.search-box[active] .search-results { + display: flex; + flex-direction: column; + flex: 1 1 auto; + min-height: 0; +} + +.search-results-navigation { + display: flex; + align-items: center; + justify-content: space-between; + flex: 0 0 auto; + + padding-inline: var(--base-rhythm); + padding-block: calc(var(--base-rhythm) / 2); + border-bottom: var(--base-border); +} + +.search-results-count { + font-size: var(--font-size-sm); + color: var(--color-fg-secondary); +} + +.search-results-count b { + color: var(--color-action); +} + +.search-results-navigation-buttons { + display: flex; + gap: 2px; +} + +.search-results-navigation-button { + display: inline-flex; + align-items: center; + justify-content: center; + + block-size: 1rem; + font-size: 1rem; + line-height: 0; + font-family: monospace; + + aspect-ratio: 1 / 1; + + border: 1px solid; + border-radius: 4px; + background-color: white; + cursor: pointer; +} + +.search-results-navigation-button:hover { + color: var(--color-action); +} + +.search-results-navigation-button#previous, +.search-results-navigation-button#next { + aspect-ratio: 1.75 / 1; +} + +.search-results-navigation-button#start::after { + content: 'ยซ'; +} +.search-results-navigation-button#previous::after { + content: 'โ€น'; +} +.search-results-navigation-button#next::after { + content: 'โ€บ'; +} +.search-results-navigation-button#end::after { + content: 'ยป'; +} + +.search-results-navigation-button[disabled] { + color: #ccc; + cursor: default; +} + +.search-suggestions { + flex: 1 1 auto; + min-height: 0; + overflow: auto; +} + +.static_search-result-node { + padding: calc(var(--base-rhythm)*2); + border-bottom: var(--base-border); +} + +.static_search-result-node-field { + margin-bottom: var(--base-rhythm); +} + +.static_search-result-node-field-key { + font-size: var(--font-size-sm); + font-family: var(--code-font-family); + font-weight: 500; + color: var(--requirement-label-color); +} + +.static_search-result-node-link, +.static_search-result-node-link a { + color: var(--color-action); +} + +.static_search-result-node-link a:hover { + color: var(--color-hover); +} diff --git a/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/favicon.ico b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/favicon.ico new file mode 100644 index 0000000..a1cd1eb Binary files /dev/null and b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/favicon.ico differ diff --git a/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/fonts/NotoSans-Italic-VariableFont_wdth,wght.ttf b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/fonts/NotoSans-Italic-VariableFont_wdth,wght.ttf new file mode 100644 index 0000000..4e962ee Binary files /dev/null and b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/fonts/NotoSans-Italic-VariableFont_wdth,wght.ttf differ diff --git a/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/fonts/NotoSans-VariableFont_wdth,wght.ttf b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/fonts/NotoSans-VariableFont_wdth,wght.ttf new file mode 100644 index 0000000..f7d0d78 Binary files /dev/null and b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/fonts/NotoSans-VariableFont_wdth,wght.ttf differ diff --git a/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/fonts/NotoSansMono-VariableFont_wdth,wght.ttf b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/fonts/NotoSansMono-VariableFont_wdth,wght.ttf new file mode 100644 index 0000000..122ef75 Binary files /dev/null and b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/fonts/NotoSansMono-VariableFont_wdth,wght.ttf differ diff --git a/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/form.css b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/form.css new file mode 100644 index 0000000..be530b8 --- /dev/null +++ b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/form.css @@ -0,0 +1,595 @@ +/* form */ + +sdoc-backdrop { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + display: flex; + justify-content: center; + align-items: center; + background: rgba(0,0,0,.5); + z-index: 99999; +} + +sdoc-modal { + display: grid; + grid-template-columns: minmax(0, 1fr); /* issue#1370 https://css-tricks.com/preventing-a-grid-blowout/ */ + grid-template-rows: min-content minmax(0, 1fr) min-content; + grid-template-areas: + "modal-header" + "modal-content" + "modal-footer"; + place-items: stretch stretch; + place-content: stretch stretch; + + background-color: var(--color-bg-contrast); + border-radius: 8px; + + width: 600px; + max-width: 90vw; + min-width: 375px; + max-height: 90vh; + + box-shadow: var(--base-elevation-modal); + overflow: hidden; + overflow-y: auto; +} + +sdoc-modal[context="confirm"] { + width: 600px; +} + +sdoc-modal[context="form"] { + width: 90vw; + height: 90vh; + max-width: 600px; + max-height: 90vh; +} + +sdoc-modal-container { + padding: calc(var(--base-rhythm)*4); +} + +sdoc-modal-header { + grid-area: modal-header; + padding-top: calc(var(--base-rhythm)*2); + padding-bottom: calc(var(--base-rhythm)*2); + padding-left: calc(var(--base-rhythm)*4); + padding-right: calc(var(--base-rhythm)*4); + font-size: 1.25rem; + font-weight: 600; +} + +.sdoc-modal-header-back-button { + position: relative; + left: calc(var(--base-rhythm) * (-1)); + display: inline-flex; + padding-right: var(--base-rhythm); +} + +.sdoc-modal-header-back-button:hover { + color: var(--color-action); +} + +sdoc-modal-content { + grid-area: modal-content; + border-top: var(--base-border); + border-bottom: var(--base-border); + /* padding-top: calc(var(--base-rhythm)*2); */ + /* padding-bottom: calc(var(--base-rhythm)*2); */ + overflow: auto; + scroll-behavior: smooth; +} + +sdoc-modal-message { + display: block; + padding-left: calc(var(--base-rhythm)*4); + padding-right: calc(var(--base-rhythm)*4); + margin-top: calc(var(--base-rhythm)*2); + margin-bottom: calc(var(--base-rhythm)*2); +} + +sdoc-modal-footer { + grid-area: modal-footer; + display: flex; + justify-content: flex-end; /* buttons to right */ + padding-top: calc(var(--base-rhythm)*2); + padding-bottom: calc(var(--base-rhythm)*2); + padding-left: calc(var(--base-rhythm)*4); + padding-right: calc(var(--base-rhythm)*3); /* buttons to right */ + column-gap: var(--base-rhythm); +} + +/* sdoc-form */ + +sdoc-form { + display: block; + position: relative; + background-color: var(--color-bg-contrast); + border-radius: 4px; + z-index: 11; + border: 1px solid var(--color-fg-accent); +} + +sdoc-form-header { + display: block; + padding-top: 0; + padding-left: calc(var(--base-rhythm)*4); + padding-right: calc(var(--base-rhythm)*4); + font-size: 1.25rem; + font-weight: 600; +} + +sdoc-form-descr { + display: block; + padding-top: 0; + padding-bottom: 0; + padding-left: calc(var(--base-rhythm)*4); + padding-right: calc(var(--base-rhythm)*4); + margin-top: calc(var(--base-rhythm)*2); + margin-bottom: calc(var(--base-rhythm)*2); +} + +sdoc-form-footer { + display: flex; + justify-content: flex-start; /* buttons to left */ + padding-top: 0; + padding-bottom: 0; + padding-left: calc(var(--base-rhythm)*3); /* buttons to left */ + padding-right: calc(var(--base-rhythm)*4); + margin-top: calc(var(--base-rhythm)*2); + margin-bottom: calc(var(--base-rhythm)*2); + column-gap: var(--base-rhythm); +} + +sdoc-form-field { + /* + Flex can not be used, it is necessary exactly "display: block" because of + the effect on the display of the contenteditable element contained inside. + Extra spaces are formed there and it breaks the Selenium end2end tests. + */ + display: block; + position: relative; + padding-top: 0; + padding-bottom: 0; + padding-left: calc(var(--base-rhythm)*4); + padding-right: calc(var(--base-rhythm)*4); + margin-top: calc(var(--base-rhythm)*4); + margin-bottom: calc(var(--base-rhythm)*4); + min-width: 200px; +} + +sdoc-form-row-main { + display: flex; + flex-direction: column; + position: relative; +} + +sdoc-form-row-aside { + display: flex; + flex-wrap: nowrap; + align-items: flex-start; + justify-content: flex-end; + position: relative; +} + +sdoc-form-row-aside [data-action-type="delete"]:hover, +sdoc-form-row-aside [data-action-type="delete"] { + color: var(--color-danger); +} + +sdoc-form-row-aside [data-action-type="action"]:hover, +sdoc-form-row-aside [data-action-type="action"] { + color: var(--color-action); +} + +sdoc-form-row-aside [data-action-type="move_up"]:hover, +sdoc-form-row-aside [data-action-type="move_up"] { + color: var(--color-green); +} + +sdoc-form-row-aside [data-action-type="move_down"]:hover, +sdoc-form-row-aside [data-action-type="move_down"] { + color: var(--color-blue); +} + +sdoc-form-row [data-action-type="add_field"]:only-child { + /* + It is expected to be a button (.action_button) + to add fields like "comment" or "link" + to the requirement edit form. + */ + justify-content: flex-start; + /* color: rgba(0,0,0,0.5) !important; */ + border: none; + top: -40%; +} + +/* + fields grid: + inside sdoc-form-grid +*/ + +sdoc-form-grid { + display: grid; + place-items: stretch stretch; + place-content: stretch stretch; + grid-template-columns: minmax(0, min-content) + minmax(0, 1fr) /* issue#1370 https://css-tricks.com/preventing-a-grid-blowout/ */ + minmax(0, min-content); + gap: + calc(var(--base-rhythm)*4) + var(--base-rhythm); + + padding: + calc(var(--base-rhythm)*4) + calc(var(--base-rhythm)*3); /* (4-1) related to column gap */ + + overflow-x: clip; /* Prevents overflow issues affecting: + - field_action::before (highlight visibility on delete) and + - autocompletable (dropdown visibility) */ + + /* content container has no padding-block */ + margin-top: calc(var(--base-rhythm)*2); + margin-bottom: calc(var(--base-rhythm)*2); +} + +sdoc-form-grid + sdoc-form-field { + padding: 0; + margin: 0; + } + +sdoc-form-grid + sdoc-form-row { + display: contents; + } + +sdoc-form-grid + sdoc-form-row-aside:first-of-type { + grid-column: 1 / 2; /* left */ + } + +sdoc-form-grid + sdoc-form-row-main { + grid-column: 2 / 3; /* center */ + } + +sdoc-form-grid + sdoc-form-row-aside:last-of-type { + grid-column: 3 / 4; /* right */ + } + +/* sdoc-form-field-group */ + +sdoc-form-field-group { + /* display: grid; + place-items: stretch stretch; + place-content: stretch stretch; */ + + display: flex; + flex-direction: row; + flex-wrap: wrap; + + padding: var(--base-rhythm); + border: var(--base-border); + border-radius: var(--base-rhythm); + + gap: calc(var(--base-rhythm)*3); /* label (2) + 1 */ + padding-top: calc(var(--base-rhythm)*3); /* related to column gap */ + padding-bottom: calc(var(--base-rhythm)*1); + + position: relative; +} + +sdoc-form-field-group::before { + /* TODO move to other label */ + content: attr(data-field-label); + position: absolute; + font-family: var(--code-font-family); + font-size: var(--font-size-xsm); + font-weight: 500; + color: var(--color-placeholder); + text-transform: uppercase; + top: calc(var(--base-rhythm)*(-1.25)); + right: var(--base-rhythm); + padding: 0 var(--base-rhythm); + background: var(--color-bg-contrast); + transition: color .2s ease; +} + +sdoc-form-field-group:focus-within::before { + color: var(--color-fg-accent); +} + +/** + * sdoc-contenteditable + */ + +sdoc-contenteditable, +sdoc-autocompletable { + display: block; + position: relative; +} + +sdoc-contenteditable[contenteditable="false"], +sdoc-autocompletable[contenteditable="false"] { + color: var(--color-fg-secondary); +} + +.autocomplete-items { + position: absolute; + border: 1px solid var(--color-action); + background-color: var(--color-bg-contrast); + top: 100%; + left: 0; + right: 0; + width: 33vw; + max-height: 60vh; + overflow-y: auto; + z-index: 999; +} + +.autocomplete-active { + /*when navigating through the items using the arrow keys:*/ + background-color: var(--color-highlight) !important; +} + +.autocompletable-result-item { + position:relative; + display:block; + padding:.25rem 0.25rem; + margin-bottom:-1px; + border:1px solid rgba(0,0,0,.125) +} + +.monospace { + font-family: var(--code-font-family); +} + +.form__requirement_title { + font-size: 1.125em; + font-weight: 700; +} + +/* field name // before */ + +/* todo: Join sdoc-contenteditable with sdoc-form-field */ + +sdoc-form-field label, +sdoc-contenteditable::before, +sdoc-autocompletable::before { + /* for contenteditable */ + content: attr(data-field-label); + /* for all */ + position: absolute; + font-family: var(--code-font-family); + font-size: var(--font-size-xsm); + font-weight: 500; + color: var(--color-placeholder); + text-transform: uppercase; + top: calc(var(--base-rhythm)*(-2.25)); + transition: color .2s ease; + + white-space: nowrap; +} + +sdoc-form-field:focus-within label, +sdoc-contenteditable:focus::before, +sdoc-autocompletable:focus::before { + color: var(--color-fg-accent); +} + +/* sdoc-form-field select */ +sdoc-form-field select { + /* A reset of styles, including removing the default dropdown arrow */ + /* appearance: none; */ + background-color: transparent; + /* border: none; */ + border: 1px solid var(--color-placeholder); + border-radius: 6px; + + padding: 0 1em 0 .5em; + margin: 0; + width: 100%; + font-family: inherit; + font-size: inherit; + cursor: inherit; + line-height: inherit; + /* Stack above custom arrow */ + z-index: 1; + /* Remove focus outline, will add on alternate element */ + outline: none; +} + +sdoc-form-field select:focus { + border: 1px solid var(--color-fg-accent); +} + +/* Remove dropdown arrow in IE10 & IE11 + @link https://www.filamentgroup.com/lab/select-css.html +*/ +sdoc-form-field select::-ms-expand { + display: none; +} + +/* placeholder // after */ + +[placeholder]:empty::after { + content: attr(placeholder); + pointer-events: none; + color: var(--color-placeholder); + /* For Firefox: */ + display: block; +} + +[placeholder]:empty:focus::after { + color: rgba(242, 100, 42,.2); +} + +sdoc-contenteditable[data-field-suffix]:not(:empty)::after, +sdoc-autocompletable[data-field-suffix]:not(:empty)::after { + content: attr(data-field-suffix); + color: var(--color-fg-accent); + margin-left: 4px; +} + +/* data-field-suffix */ + +[contenteditable=true] { + white-space: pre-wrap; + word-break: break-word; + overflow-wrap: anywhere; + outline: none; + /* Without this hack ( display: inline-block ) + Chrome generates duplicated new lines when Enter pressed. + Add style "display:inline-block;" to contenteditable, + it will not generate div, p, span automatic in chrome */ + /* https://stackoverflow.com/a/24689390/598057 */ + /* Also, the parent element should not be allowed to have a flex display. + In order to isolate the 'contenteditable, + the structure "sdoc-form-row-main > sdoc-form-field > contenteditable" + is implemented. + */ + display: inline-block; + /* This is to prevent the field from shifting when the second line appears while typing: */ + vertical-align: top; + width: 100%; +} + +[contenteditable=true][data-field-type="multiline"] { + font-family: var(--code-font-family); +} + + + +form[data-controller~="scroll_into_view"] { + /* fix on 1px border and smth unruly */ + scroll-snap-margin-top: calc(var(--base-padding) + 1px); + scroll-margin-top: calc(var(--base-padding) + 1px); +} + +/* input */ + +sdoc-form input[type="text"] { + padding: var(--base-rhythm); + font-size: var(--font-size); + border: 1px solid var(--color-border); + border-radius: 3px; + outline: transparent; + width: 100%; + transition: border-color calc(var(--transition, 0.2) * 1s) ease; +} + +sdoc-form input[type="text"]:focus { + border-color: var(--color-action); + color: var(--color-action); +} + +/* diff */ + +sdoc-form[diff] { + grid-column: 1 / -1; + + margin: 0; + background-color: transparent; + border: none; +} + +sdoc-form[diff] form { + display: flex; + gap: var(--base-rhythm); + position: relative; + padding: var(--base-rhythm); + background-color: var(--color-bg-contrast); + border: 1px solid var(--color-border); + border-radius: 4px; +} + +/* search */ + +sdoc-form[search] { + display: block; + background-color: transparent; + border: none; + border-radius: 0; +} + +sdoc-form[search] form { + display: flex; + gap: var(--base-rhythm); + position: relative; + padding: var(--base-rhythm); + background-color: var(--color-bg-contrast); + border: 1px solid var(--color-border); + border-radius: 4px; +} + +sdoc-form[search][success] { + border-bottom: 1px solid var(--color-border); +} + +sdoc-form-error { + display: block; + color: var(--color-danger); + font-size: 12px; + /* + set 'order' to be displayed after any other items, + in the context of using flex: + */ + order: 11; + /* + FOR: + components/grammar_form_element/index.jinja + "Relations_Row" + id="document__editable_grammar_relations" + */ + grid-column: 2 / -1; +} + +sdoc-form-error + sdoc-form-error { + margin-top: var(--base-rhythm); +} + +sdoc-form-error + sdoc-form-field-group { + border-color: var(--color-danger); +} + + +sdoc-form-field-group[errors]::before, /* Grammar -> label for group of fields */ +sdoc-contenteditable[errors]::before, /* inside contenteditable errors block does not affected */ +sdoc-autocompletable[errors]::before, +sdoc-form-error + sdoc-form-field > label, /* Grammar -> relation field ; File filed */ +sdoc-form-error + sdoc-form-field > sdoc-contenteditable::before, +sdoc-form-error + sdoc-form-field > sdoc-autocompletable::before { + color: var(--color-danger); +} + +.sdoc-form-error, +.sdoc-form-success, +.sdoc-form-reset { + display: block; + padding: var(--base-rhythm) calc(var(--base-rhythm)*2); + position: relative; +} + +.sdoc-form-error { + color: var(--color-danger); +} + +.sdoc-form-success { + color: var(--color-action); +} + +.sdoc-form-reset { + position: absolute; + right: 0; + bottom: 0; +} + +.sdoc-form-error, +.sdoc-form-success { + padding-right: 120px; /* == sdoc-form-reset width */ +} diff --git a/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/html2pdf4doc.css b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/html2pdf4doc.css new file mode 100644 index 0000000..f7ead23 --- /dev/null +++ b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/html2pdf4doc.css @@ -0,0 +1,4 @@ +html2pdf-print-forced-page-break + sdoc-node-content[node-view="narrative"], +html2pdf-page + sdoc-node-content[node-view="narrative"] { + border-top: none; +} diff --git a/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/layout.css b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/layout.css new file mode 100644 index 0000000..8ecd6df --- /dev/null +++ b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/layout.css @@ -0,0 +1,116 @@ +.layout { + height: 100vh; + width: 100%; + display: grid; + + grid-template-columns: + fit-content(var(--base-gap)) + fit-content(20%) + fit-content(20%) + minmax( 0, 1fr ) /* issue#1370 https://css-tricks.com/preventing-a-grid-blowout/ */ + fit-content(20%) + auto; + grid-template-rows: + var(--base-gap) + minmax( 0, 1fr ) /* https://github.com/w3c/csswg-drafts/issues/1777 */ + calc(var(--base-rhythm)*4); + grid-template-areas: + "nav header header header header aside" + "nav tree bar_left main bar_right aside" + "nav footer footer footer footer aside"; + + place-items: stretch stretch; + place-content: stretch stretch; + + overflow: hidden; /* Prevents scrolling before children's styles are triggered */ +} + +.layout_nav { + grid-area: nav; + position: relative; + z-index: 10; +} + +.layout_tree { + grid-area: tree; + min-width: 0; +} + +.layout_toc, +.layout_toc[data-position='left'] { + grid-area: bar_left; +} +.layout_toc[data-position='right'] { + grid-area: bar_right; +} + +.layout_footer { + grid-area: footer; +} + +.layout_header { + grid-area: header; + min-width: 0; +} + +.layout_aside { + grid-area: aside; + min-width: 0; +} + +.layout_main { + grid-area: main; + min-width: 0; +} + +/* */ + +.section-number { + margin-right: .5rem; + font-size: 0.85em; + font-weight: bold; +} + +/* messages */ + +.mars { + position: fixed; + z-index: 1111; + top: 0; + bottom: 0; + left: 0; + right: 0; + pointer-events: none; + + display: flex; + justify-content: center; + /* align-items: flex-end */ + align-items: center; + + padding: calc(var(--base-rhythm)*10); +} + +/* */ + +sdoc-toast { + pointer-events: initial; + text-align: center; + border-radius: var(--base-rhythm); + box-shadow: 0 8px 32px rgba(0,0,0,.3); + background: var(--color-bg-ui); + color: var(--color-fg-secondary-invert); +} + +sdoc-toast:not(:empty) { + padding: .75rem 2rem; +} + +sdoc-toast a, +sdoc-toast a:link, +sdoc-toast a:visited { + color: var(--color-bg-contrast); +} + +sdoc-toast a:hover { + color: var(--color-fg-accent); +} diff --git a/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/node.css b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/node.css new file mode 100644 index 0000000..cf45ed3 --- /dev/null +++ b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/node.css @@ -0,0 +1,246 @@ +turbo-frame { + display: contents; +} + +sdoc-node { + display: block; + position: relative; +} + +/* sdoc-node[show-node-type-name] sdoc-node-content { + margin-top: calc(2 * var(--base-rhythm)); +} */ + +sdoc-node[show-node-type-name]::before { + content: attr(show-node-type-name); + position: absolute; + top: calc(1 * var(--base-rhythm)); + right: calc(4 * var(--base-rhythm)); + + font-size: 10px; + font-family: var(--code-font-family); + font-weight: 600; + line-height: 1; + text-transform: uppercase; + + padding-top: calc(0.25 * var(--base-rhythm)); + padding-bottom: calc(0.5 * var(--base-rhythm)); + padding-left: calc(0.75 * var(--base-rhythm)); + padding-right: calc(0.75 * var(--base-rhythm)); + border-radius: 3px; + border: var(--requirement-border-width, 1px) solid var(--requirement-border-color, #bfbfbf); + + color: var(--requirement-label-color); + background-color: var(--color-bg-contrast); +} + +/* sdoc-node */ + +sdoc-node { + background-color: var(--color-bg-contrast); + border-radius: 3px; + + /* padding: calc(3 * var(--base-rhythm)) calc(4 * var(--base-rhythm)); */ + padding-inline: calc(4 * var(--base-rhythm)); + padding-block: calc(3 * var(--base-rhythm)); +} + +sdoc-node[node-role="root"] { + padding-top: calc(3 * var(--base-rhythm)); +} + +sdoc-node[node-style="readonly"][node-role="requirement"] { + background: none; + background-color: transparent; + outline: none; + padding-left: 0; + padding-right: 0; + padding-bottom: 0; + margin: 0; +} + +sdoc-node[show-node-type-name][node-style="readonly"]::before { + right: 0; +} + +sdoc-node[show-node-type-name][node-view="plain"]::before { + content: none; +} + +/* editable_node */ + +sdoc-node[node-style="card"][node-role="requirement"], +[data-editable_node="on"] { + box-shadow: var(--base-elevation-0); + transition: box-shadow .5s; +} + +sdoc-node[node-style="card"][node-role="requirement"]:hover, +[data-editable_node="on"]:hover { + box-shadow: var(--base-elevation-node); + z-index: 10; +} + +/* sdoc-node[node-style="card"] */ + +sdoc-node[node-style="card"] { + background-color: var(--color-bg-contrast); + border-radius: 3px; + padding: 0; +} + +sdoc-node[node-style="card"][node-role="text"], +sdoc-node[node-style="card"][node-role="section"] { + background-color: var(--color-bg-contrast); + padding: calc(var(--base-rhythm)) calc(var(--base-rhythm)*2); +} + +[data-role='current'] sdoc-node[node-style="card"] { + background-color: var(--color-bg-contrast); +} + +[data-role='current'] [node-role="requirement"] { + +} + +[data-role='parents'] sdoc-node[node-style="card"], +[data-role='children'] sdoc-node[node-style="card"] { + background-color: var(--color-bg-secondary); + width: var(--card-width); +} + +sdoc-node[node-style="card"].highlighted { + background-color: var(--color-highlight); +} + +[data-viewtype="traceability"] sdoc-node[node-style="card"] + sdoc-node[node-style="card"] { + margin-top: var(--base-padding); +} + +[data-viewtype="deep_traceability"] sdoc-node[node-style="card"] { + /* width: var(--card-width); */ + /* flex-grow: 1; */ +} + +[data-viewtype="requirements-coverage"] sdoc-node[node-style="card"] { + width: calc(var(--card-width)*0.75); + /* width: auto; */ + font-size: .85em; + line-height: 1.4; +} + +/* nouid */ + +sdoc-node.nouid { + /* background-color: rgb(240, 220, 220); */ +} + +.nouid sdoc-node-title, +.nouid .requirement__title { + color: #502222; +} + +/* sdoc-node-controls */ + +sdoc-node-controls[data-direction~="column"], +sdoc-node-controls { + position: absolute; + + display: flex; + justify-content: flex-start; + + transition: .5s ease-out; + opacity: 0; + + /* HACK: [sdoc-node outline hack] */ + left: calc(100% + 1px); + top: -2px; + + /* default: column to right */ + bottom: 0; + right: unset; + width: calc(var(--base-rhythm)*4); /* determines the size of the buttons */ + height: unset; + + justify-content: flex-start; + flex-direction: column; +} + +sdoc-node-controls[data-direction~="column"] { + flex-direction: column; + justify-content: flex-start; + + left: 100%; + top: 0; + bottom: 0; + right: unset; + width: calc(var(--base-rhythm)*4); /* determines the size of the buttons */ + height: unset; +} + +sdoc-node-controls[data-direction~="row"] { + flex-direction: row; + justify-content: flex-end; + + top: calc(100% - 4px); + left: 0; + right: 0; + bottom: unset; + height: calc(var(--base-rhythm)*4); /* determines the size of the buttons */ + width: unset; +} + +sdoc-main-placeholder + sdoc-node-controls { + opacity: 1; +} + +sdoc-node-controls:hover, +sdoc-node:hover sdoc-node-controls { + opacity: 1; +} + +sdoc-node:hover sdoc-node-controls:hover { + opacity: 1; +} + +sdoc-menu { + display: flex; + align-items: stretch; + /* default: */ + flex-direction: column; +} + +sdoc-menu-handler { + display: flex; + align-items: stretch; + /* default: */ + flex-direction: column; +} + +sdoc-menu, /* default: */ +sdoc-menu-handler, /* default: */ +sdoc-node-controls[data-direction~="column"] sdoc-menu, +sdoc-node-controls[data-direction~="column"] sdoc-menu-handler { + flex-direction: column; +} + +sdoc-node-controls[data-direction~="row"] sdoc-menu, +sdoc-node-controls[data-direction~="row"] sdoc-menu-handler { + flex-direction: row; +} + +/* math equation numbering support */ +div.math { + position: relative; + text-align: center; + padding-right: 3em; /* reserve space for eqno */ + overflow: hidden; /* prevents scrollbars */ +} + +.math .eqno { + position: absolute; + right: 0; + top: 0; + font-size: 90%; + white-space: nowrap; +} \ No newline at end of file diff --git a/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/node_content.css b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/node_content.css new file mode 100644 index 0000000..f1c4845 --- /dev/null +++ b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/node_content.css @@ -0,0 +1,495 @@ +:root { + --requirement-container-limit: 500px; + --requirement-border-color: rgb(230, 230, 230); /* = var(--color-border) on white without opacity */ + --requirement-border-width: 1px; + --requirement-border-radius: 4px; + --requirement-inner-borders-width: 1px; + --requirement-label-color: var(--color-fg-secondary, #808080); + --requirement-bg-dark-color: var(--color-bg-main, #F2F5F9); + --requirement-bg-light-color: var(--color-bg-contrast, #FFFFFF); +} + +/* sdoc-node-content */ + +sdoc-node-content { + display: grid; + grid-template-columns: minmax(0, 1fr); /* issue#1370 https://css-tricks.com/preventing-a-grid-blowout/ */ + place-items: stretch stretch; + place-content: stretch stretch; + gap: var(--requirement-inner-borders-width); + + position: relative; + background-color: var(--color-bg-contrast); /* affects the color of the space between cells */ + border: + var(--requirement-border-width, 1px) + solid + var(--requirement-border-color); + + border-radius: var(--requirement-border-radius); + + + min-width: 300px; + + /* and use overflow-wrap: break-word; in the field */ + max-width: 100%; + + /* + DEV: to show anchors (in the context) to the left of the node, + need to remove this: + overflow-x: auto; + */ +} + +/* Workaround for html2pdf4doc print bug: + (https://github.com/strictdoc-project/strictdoc/issues/2450#issuecomment-3299134769) + Disable background for elements that trigger header/footer overlap. + This hides the background of problematic split (not sliced) sections + to prevent them from covering header/footer areas during printing. + Real fix will be applied in html2pdf4doc in a future release. */ +@media print { + sdoc-node-content { + background: none; + background-color: transparent; + } +} + +sdoc-node-title { + display: block; + + font-size: 1.125em; + font-weight: 700; +} + +sdoc-node-title:last-child { + margin-bottom: 0; +} + +sdoc-node-title * { + /* affect H inside title, if applicable */ + margin: 0; +} + +[node-style="card"] sdoc-node-title { + font-size: 1em; +} + +/* synonym to [node-view="inline"] */ +sdoc-node-content[node-view="simple"] sdoc-node-title { + padding-left: calc(var(--base-rhythm)*2); + padding-right: calc(var(--base-rhythm)*2); + padding-top: calc(var(--base-rhythm)*1); + padding-bottom: calc(var(--base-rhythm)*1); + + word-break: break-word; + overflow-wrap: break-word; +} + +/* sdoc-node-content[node-view="simple"] sdoc-node-title, */ +sdoc-node-content[node-view="table"] sdoc-node-title, +sdoc-node-content[node-view="zebra"] sdoc-node-title { + padding-left: calc(var(--base-rhythm)*2); + padding-right: calc(var(--base-rhythm)*2); + padding-top: calc(var(--base-rhythm)*1); + padding-bottom: calc(var(--base-rhythm)*1); + + border-top-right-radius: var(--requirement-border-radius); + border-top-left-radius: var(--requirement-border-radius); + + background-color: var(--requirement-bg-dark-color); + /* border-bottom: */ + outline: 1px solid var(--requirement-border-color); + + word-break: break-word; + overflow-wrap: break-word; +} + +sdoc-node-uid { + display: block; + padding-left: calc(var(--base-rhythm)*2); + padding-right: calc(var(--base-rhythm)*2); + padding-top: calc(var(--base-rhythm)*1); + padding-bottom: calc(var(--base-rhythm)*1); + font-size: var(--font-size-sm); + font-family: var(--code-font-family); + font-weight: 700; + + text-transform: uppercase; + color: var(--requirement-label-color); + + word-break: break-word; + overflow-wrap: break-word; +} + +sdoc-node-field-label { + display: flex; + align-items:flex-start; + + padding-left: calc(var(--base-rhythm)*2); + padding-right: calc(var(--base-rhythm)*2); + padding-top: calc(var(--base-rhythm)*1.75); + padding-bottom: calc(var(--base-rhythm)*1); + + font-size: var(--font-size-sm); + font-family: var(--code-font-family); + font-weight: 500; + line-height: 1; + color: var(--requirement-label-color); + + /* @mettta and @stanislaw are commenting this out because REQUIREMENT's field names + were split apart, even though there was enough screen width + word-break: break-word; + */ + overflow-wrap: break-word; +} + +sdoc-node-field { + display: block; + position: relative; + + padding-left: calc(var(--base-rhythm)*2); + padding-right: calc(var(--base-rhythm)*2); + padding-top: calc(var(--base-rhythm)*1); + padding-bottom: calc(var(--base-rhythm)*1); + + word-break: break-word; + overflow-wrap: break-word; +} + +[data-viewtype="html2pdf"] sdoc-node-field-label { + word-break: normal; +} + +/* for relations in requirement */ +sdoc-node-field > ol:first-child, +sdoc-node-field > ul:first-child { + margin-top: 0; +} +sdoc-node-field > ol:last-child, +sdoc-node-field > ul:last-child { + margin-bottom: 0; +} + +/* node-view="plain" */ + +sdoc-node-content[node-view="plain"] { + border: 0; + display: flex; + flex-direction: column; + gap: var(--base-padding); +} + +sdoc-node-content[node-view="plain"] sdoc-node-field-label { + display: none; +} + +sdoc-node-content[node-view="plain"] sdoc-node-field { + padding: 0; +} + +/* node-view="table" */ + +sdoc-node-content[node-view="table"] { + /* grid: */ + grid-template-columns: minmax(80px, min-content) minmax(0, 1fr); /* issue#1370 https://css-tricks.com/preventing-a-grid-blowout/ */ + /* border: */ + background-color: var(--requirement-border-color); +} + +sdoc-node-content[node-view="table"] + sdoc-node-title { + grid-column: 1 / 3; + } + +sdoc-node-content[node-view="table"] + sdoc-node-field-label { + grid-column: 1 / 2; + background-color: var(--requirement-bg-dark-color); + } + +sdoc-node-content[node-view="table"] + sdoc-node-field { + grid-column: 2 / 3; + background-color: var(--requirement-bg-light-color); + } + +sdoc-node:not([node-style="card"]) { + /* Making the node a container for the requirement: */ + container: node / inline-size; + /* + HACK: [sdoc-node outline hack] + Buggy behavior for @container CSS feature: + after window resize, the 1px vertically space + appears randomly between nodes. + */ + outline: 1px solid #fff; + margin: 1px 0; +} + +/* calc(var(--card-width) + calc(var(--base-padding)*4)) */ +/* 300 + 16*4 = 364 */ +@container node (width < 400px) { + sdoc-node-content[node-view="table"] { + /* removes columns: */ + grid-template-columns: minmax(0, 1fr); /* issue#1370 https://css-tricks.com/preventing-a-grid-blowout/ */ + /* removes inner border: */ + background-color: var(--requirement-bg-light-color); + } + + sdoc-node-content[node-view="table"] + sdoc-node-title, + sdoc-node-content[node-view="table"] + sdoc-node-field-label, + sdoc-node-content[node-view="table"] + sdoc-node-field { + /* removes columns: */ + grid-column: unset; + } +} + +@supports not (container-type: inline-size) { + /* TODO test 888px */ + @media (max-width: 888px) { + /* Do the same as if there was a container support */ + + sdoc-node-content[node-view="table"] { + /* removes columns: */ + grid-template-columns: minmax(0, 1fr); /* issue#1370 https://css-tricks.com/preventing-a-grid-blowout/ */ + /* removes inner border: */ + background-color: var(--requirement-bg-light-color); + } + + sdoc-node-content[node-view="table"] + sdoc-node-title, + sdoc-node-content[node-view="table"] + sdoc-node-field-label, + sdoc-node-content[node-view="table"] + sdoc-node-field { + /* removes columns: */ + grid-column: unset; + } + } +} + +/* node-view="zebra" */ + +sdoc-node-content[node-view="zebra"] { + grid-template-columns: minmax(0, 1fr); /* issue#1370 https://css-tricks.com/preventing-a-grid-blowout/ */ +} + +sdoc-node-content[node-view="zebra"] + sdoc-node-field-label { + background-color: var(--requirement-bg-dark-color); + } + +sdoc-node-content[node-view="zebra"] + sdoc-node-field { + background-color: var(--requirement-bg-light-color); + } + +/* node-view="simple" */ +/* synonym to "inline" */ + +sdoc-node-content[node-view="simple"] { + grid-template-columns: minmax(0, 1fr); /* issue#1370 https://css-tricks.com/preventing-a-grid-blowout/ */ +} + +sdoc-node-content[node-view="simple"] +sdoc-node-field-label { + background-color: #fff; + padding-bottom: 0; +} + +/* node-view="narrative" */ + +sdoc-node-content[node-view="narrative"] { + display: flex; + flex-direction: column; + padding-top: var(--base-rhythm); + border-radius: 0; + border-left: none; + border-right: none; + border-bottom: none; +} + +sdoc-node-content[node-view="narrative"] sdoc-node-title { + border: none; + outline: none; + background: none; + background-color: transparent; + padding: 0; + margin-bottom: var(--base-padding); + grid-column: 1 / -1; +} + +sdoc-node-content[node-view="narrative"] sdoc-node-field { + padding: 0; +} + +sdoc-node-content[node-view="narrative"] sdoc-node-field-label { + opacity: 0.8; + font-size: var(--font-size-sm); + line-height: calc(var(--font-size-sm) * 1.5); + padding: 0; +} + +sdoc-node-content[node-view="narrative"] .node_fields_group-primary { + display: flex; + flex-direction: column; + padding-top: var(--base-padding); +} + +sdoc-node-content[node-view="narrative"] .node_fields_group-primary sdoc-node-field { + margin-bottom: var(--base-padding); + color: var(--color-fg-contrast); +} + +sdoc-node-content[node-view="narrative"] .node_fields_group-primary sdoc-node-field:last-child { + margin-bottom: 0; +} + +sdoc-node-content[node-view="narrative"] .node_fields_group-secondary { + display: grid; + grid-template-columns: max-content 1fr; + gap: calc(.5 * var(--base-rhythm)); +} + +sdoc-node-content[node-view="narrative"] .node_fields_group-secondary sdoc-node-field { + font-size: var(--font-size-sm); + line-height: calc(var(--font-size-sm) * 1.5); + opacity: 0.6; +} + +sdoc-node-content[node-view="narrative"] .requirement__parent-uid, +sdoc-node-content[node-view="narrative"] .requirement__child-uid { + /* + affects UID in links; + make them lighter: + */ + font-weight: normal; +} + +/* section */ + +sdoc-section, +sdoc-section-title { + display: block; + margin: 0; +} + +sdoc-section-title { + font-weight: 700; +} + +sdoc-section-title { + margin-bottom: var(--base-padding); +} + +sdoc-section-title:last-child { + margin-bottom: 0; +} + +sdoc-section-title * { + margin: 0; + + /* This rule, when the element starts the page when printed, + creates illegal margins, + which breaks the rhythm of HTML2PDF4DOC + and generates blank pages: + */ + /* display: inline; */ +} + +/* TEXT node */ + +sdoc-text, +sdoc-section-text { + display: block; + margin: 0; +} + +[node-style="card"] sdoc-text { + padding: var(--base-padding); +} + +sdoc-section-text { + margin-top: var(--base-padding); +} + +sdoc-section-text:first-child { + margin-top: 0; +} + +/* meta */ + +sdoc-meta { + display: grid; + grid-template-columns: minmax(min-content, max-content) minmax(min-content, 1fr); + place-items: stretch stretch; + place-content: stretch stretch; + position: relative; + border: + var(--requirement-border-width, 1px) + solid + var(--requirement-border-color); + border-radius: var(--requirement-border-radius); + + font-size: var(--font-size-sm); + line-height: 24px; /* to keep the copy button from expanding out of the content line */ + /* margin: var(--base-padding) 0; */ + margin: 0; + padding: calc(var(--base-rhythm)*0.5); + row-gap: 2px; + + width: fit-content; + max-width: 100%; + overflow-x: auto; +} + +sdoc-meta-section, +sdoc-meta-label, +sdoc-meta-field { + display: flex; + align-items: flex-start; + padding: calc(var(--base-rhythm)*0.25) var(--base-rhythm); + background-color: var(--color-bg-contrast); +} + +sdoc-meta-label { + grid-column: 1 / 2; + font-family: var(--code-font-family); + font-weight: 700; + text-transform: uppercase; + color: var(--requirement-label-color); + background-color: var(--color-bg-secondary); +} + +sdoc-meta-field { + grid-column: 2 / 3; +} + +sdoc-meta-section { + grid-column: 1 / -1; +} + +/* PDF */ +/* There is no sdoc-node wrapper, so such neighbours and nesting is possible. */ +sdoc-text + sdoc-text, +sdoc-text + sdoc-section, +sdoc-text + sdoc-section-title, +sdoc-section + sdoc-text, +sdoc-section + sdoc-section, +sdoc-section + sdoc-section sdoc-section-title { + margin-top: calc(var(--base-rhythm)*4); +} + +/* requirement type tag */ + +.requirement__type-tag { + /* font-size: var(--font-size-sm); + font-family: var(--code-font-family); + font-weight: 500; + line-height: 1; + text-transform: uppercase; */ + color: var(--requirement-label-color); + white-space: nowrap; +} diff --git a/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/project_tree.css b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/project_tree.css new file mode 100644 index 0000000..940d06b --- /dev/null +++ b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/project_tree.css @@ -0,0 +1,218 @@ + +/* tree */ +.project_tree { + position: relative; + /* width: -moz-fit-content; + width: fit-content; */ + /* margin: 0 auto; */ +} + +.project_tree details>summary { + list-style: none; +} + +.project_tree summary::-webkit-details-marker { + display: none +} + +/* folder */ + +.project_tree-folder { + border: var(--base-border); + border-radius: calc(0.5 * var(--base-rhythm)); + overflow: hidden; + position: relative; + padding-left: var(--base-rhythm); + padding-right: var(--base-rhythm); + background: var(--color-bg-secondary); +} + +.project_tree-folder[open] { + background: transparent; +} + +.project_tree-folder.source { + padding-right: 0; + border-right: none; + border-bottom: none; +} + +.project_tree-folder summary { + position: relative; + cursor: pointer; + user-select: none; +} + +.project_tree-folder-title { + font-weight: bold; + display: flex; + column-gap: calc(0.5 * var(--base-rhythm)); + font-size: 0.85rem; + line-height: 1.2; + color: #666; + padding: calc(0.5 * var(--base-rhythm)); + position: relative; +} + +.project_tree-folder-title::before, +.project_tree-folder-title::after { + content: ''; + position: absolute; + top: 0; + right: -20px; + left: -20px; + bottom: 0; +} + +.project_tree-folder-title::after { + background: var(--color-bg-secondary); +} + +.project_tree-folder summary:hover > .project_tree-folder-title::before { + background: var(--color-bg-secondary); +} + +.project_tree-folder summary:hover > .project_tree-folder-title, +.project_tree-folder summary:hover::after { + color: var(--color-fg-accent); +} + +/* .icon_collapse_expand is class inside SVG */ +.project_tree-folder-title .icon_collapse_expand { + margin-left: auto; +} +/* .collapsed and .expanded are classes inside SVG .icon_collapse */ +.project_tree-folder > summary .icon_collapse_expand .collapsed { + display: initial; +} +.project_tree-folder > summary .icon_collapse_expand .expanded { + display: none; +} +.project_tree-folder[open] > summary .icon_collapse_expand .expanded { + display: initial; +} +.project_tree-folder[open] > summary .icon_collapse_expand .collapsed { + display: none; +} + +.project_tree-folder-content { + display: flex; + flex-direction: column; + justify-content: space-between; + gap: var(--base-rhythm); + padding-top: var(--base-rhythm); + padding-bottom: var(--base-rhythm); +} + +/* file */ + +.project_tree-file { + display: flex; + column-gap: var(--base-rhythm); + padding: calc(0.5 * var(--base-rhythm)); + border-radius: calc(0.5 * var(--base-rhythm)); + transition: background .3s; + border: 1px solid rgba(255,255,255,0); +} + +.project_tree-file:not([href]):hover { + border: 1px solid rgba(255,255,255,0.75); + background: rgba(0,0,0,0.01); +} + +.project_tree-file[href]:hover { + background: rgba(255,255,255,0.5); +} + +.project_tree-file[href]:hover .project_tree-file-icon, +.project_tree-file[href]:hover .project_tree-file-title { + color: var(--color-fg-accent); +} + +.project_tree-file-details { + display: block; +} + +.project_tree-file-icon { + line-height: 0; +} + +.project_tree-file-title { + font-size: 1em; + font-weight: 500; + line-height: 1.2; + transition: color .2s; +} + +.project_tree-file-icon, +.project_tree-file-title { + color: var(--color-fg-secondary); +} + +.project_tree-file[href] .project_tree-file-icon, +.project_tree-file[href] .project_tree-file-title { + color: var(--color-fg-main); +} + +.project_tree-file-name { + font-size: 0.85rem; + line-height: 1.2; + color: var(--color-fg-secondary); + margin-top: 0.25rem; +} + +.project_tree-file-aside { + margin-left: auto; +} + +/* dashboard */ + +.dashboard { + display: flex; + align-items: flex-start; + gap: var(--base-rhythm); +} + +.dashboard-main { + flex-grow: 1; +} + +.dashboard-aside { + width: 30%; + /* max-width: 300px; */ + font-size: 0.75rem; + display: flex; + gap: var(--base-rhythm); + flex-direction: column; +} + +.dashboard-block:empty { + display: none; +} + +.dashboard-block { + border: var(--base-border); + border-radius: calc(0.5 * var(--base-rhythm)); + overflow: hidden; + position: relative; + padding: var(--base-rhythm); +} + +.dashboard-block-title { + font-weight: 600; + position: relative; + top: calc(-1 * var(--base-rhythm)); + color: var(--color-fg-secondary); + padding: calc(0.5 * var(--base-rhythm)) 0; +} + +.dashboard-block-title::after { + content: ''; + position: absolute; + top: -20px; + left: -20px; + right: -20px; + bottom: 0; + background-color: rgba(0,0,0,0.025); + border-bottom: var(--base-border); +} diff --git a/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/requirement-tree.css b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/requirement-tree.css new file mode 100644 index 0000000..b0aa443 --- /dev/null +++ b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/requirement-tree.css @@ -0,0 +1,283 @@ +:root { + --requirement-tree-line-width: 1px; + --requirement-tree-line-color: var(--color-border); + --requirement-tree-margin: var(--tree-gap); + --requirement-tree-downward-margin: calc(var(--requirement-tree-margin)*.5); + --requirement-tree-downward-string-margin: calc(var(--requirement-tree-downward-margin)*0.25); + --requirement-tree-line: var(--requirement-tree-line-width) solid; + --requirement-tree-downward-line: var(--requirement-tree-line-color) var(--requirement-tree-line-width) solid; + --requirement-tree-arrow-size: calc(var(--requirement-tree-margin)/4); + /* var(--color-fg-contrast) */ + /* var(--color-accent) */ +} + +/* requirement-tree */ + +.requirement-tree { + position: relative; + + list-style: none; + padding: 0; + margin: 0; + box-sizing: border-box; + + display: flex; + justify-content: flex-start; + flex-direction: column; + align-content: flex-start; + + /* default aka right direction */ + align-items: flex-start; + margin-left: var(--requirement-tree-margin); +} + +.requirement-tree_right.requirement-tree { + align-items: flex-start; + margin-right: 0; + margin-left: var(--requirement-tree-margin); +} + +.requirement-tree_left.requirement-tree { + align-items: flex-end; + margin-left: 0; + margin-right: var(--requirement-tree-margin); +} + +.requirement-tree_branch { + position: relative; + + display: flex; + justify-content: center; + align-items: flex-start; + align-content: stretch; + margin-bottom: var(--requirement-tree-margin); +} + +.requirement-tree_left .requirement-tree_branch { + flex-direction: row-reverse; +} + +.requirement-tree_branch:last-child { + margin-bottom: 0; +} + +.requirement-tree_node { + display: flex; + flex-direction: column; + align-items: stretch; + + /* for width restrictions in deep trace */ + max-width: var(--card-width); +} + +[data-viewtype="requirements-coverage"] .requirement-tree_node { + width: calc(var(--card-width)*0.75); +} + + /* arrows */ + +.requirement-tree_right.requirement-tree::before { + /* arrow from children, show only in right tree */ + content: ''; + position: absolute; + width: var(--requirement-tree-arrow-size); + height: var(--requirement-tree-arrow-size); + top: var(--requirement-tree-margin); + left: calc(var(--requirement-tree-margin)*(-1) - var(--requirement-tree-line-width)*0.5); + box-sizing: border-box; + border-top: var(--requirement-tree-line); + border-left: var(--requirement-tree-line); + transform-origin: top left; + transform: rotate(-45deg); + z-index: 2; +} + +.requirement-tree_left .requirement-tree_node::before { + /* arrow to parents inside tree */ + content: ''; + position: absolute; + width: var(--requirement-tree-arrow-size); + height: var(--requirement-tree-arrow-size); + top: var(--requirement-tree-margin); + right: calc(var(--requirement-tree-arrow-size)*(-1)); + box-sizing: border-box; + border-top: var(--requirement-tree-line); + border-left: var(--requirement-tree-line); + transform-origin: top left; + transform: rotate(-45deg); + z-index: 2; +} + +/* corner connector to node */ + +.requirement-tree_branch::before { + content: ''; + position: absolute; + width: calc(var(--requirement-tree-margin)*0.5); + height: var(--requirement-tree-margin); + top: 0; + box-sizing: border-box; + /* default aka right direction */ + border-bottom: var(--requirement-tree-line); + border-left: var(--requirement-tree-line); + left: calc(var(--requirement-tree-margin)*(-1)*0.5); +} + +.requirement-tree_right .requirement-tree_branch::before { + right: unset; + left: calc(var(--requirement-tree-margin)*(-1)*0.5); + border: none; + border-bottom: var(--requirement-tree-line); + border-left: var(--requirement-tree-line); +} + +.requirement-tree_left .requirement-tree_branch::before { + left: unset; + right: calc(var(--requirement-tree-margin)*(-1)*0.5); + border: none; + border-bottom: var(--requirement-tree-line); + border-right: var(--requirement-tree-line); +} + +/* horizontal line to top node instead corner */ + +.requirement-tree_branch:first-child::before { + width: var(--requirement-tree-margin); + border: none; + border-bottom: var(--requirement-tree-line); + /* default aka right direction */ + right: unset; + left: calc(var(--requirement-tree-margin)*(-1)); +} + +.requirement-tree_right .requirement-tree_branch:first-child::before { + right: unset; + left: calc(var(--requirement-tree-margin)*(-1)); +} + +.requirement-tree_left .requirement-tree_branch:first-child::before { + left: unset; + right: calc(var(--requirement-tree-margin)*(-1)); +} + +/* vertical line */ + +.requirement-tree_branch::after { + content: ''; + position: absolute; + width: calc(var(--requirement-tree-margin)*0.5); + top: var(--requirement-tree-margin); + bottom: calc(var(--requirement-tree-margin)*(-1)); + box-sizing: border-box; + /* default aka right direction */ + border: none; + border-left: var(--requirement-tree-line); + left: calc(var(--requirement-tree-margin)*(-1)*0.5); +} + +.requirement-tree_right .requirement-tree_branch::after { + border: none; + border-left: var(--requirement-tree-line); + right: unset; + left: calc(var(--requirement-tree-margin)*(-1)*0.5); +} + +.requirement-tree_left .requirement-tree_branch::after { + border: none; + border-right: var(--requirement-tree-line); + left: unset; + right: calc(var(--requirement-tree-margin)*(-1)*0.5); +} + +/* vertical line on last node is not showing */ +.requirement-tree_branch:last-child:after { + content: none; +} + +/* downward */ + +.requirement-tree_downward { + list-style: none; + padding: 0; + margin: 0; + margin-left: var(--requirement-tree-downward-margin); + box-sizing: border-box; + + font-size: .75rem; + line-height: 1.2; +} + +.requirement-tree_downward_node { + position: relative; + border-left: var(--requirement-tree-downward-line); +} + +.requirement-tree_downward .requirement-tree_downward_node { + padding-top: calc(var(--requirement-tree-downward-margin)*0.5); +} + +.requirement-tree_downward .requirement-tree_downward_node:first-child { + padding-top: var(--requirement-tree-downward-margin); +} + +.requirement-tree_downward .requirement-tree_downward_node:last-child { + border-color: transparent; +} + +.requirement-tree_downward .requirement-tree_downward_node::before { + position: absolute; + content: ''; + width: var(--requirement-tree-downward-margin); + border-bottom: var(--requirement-tree-downward-line); + box-sizing: border-box; + top: 0; + left: calc(var(--requirement-tree-line-width)*(-1)); + bottom: calc(100% - var(--requirement-tree-downward-margin)*0.5 - 0.75rem); +} + +.requirement-tree_downward .requirement-tree_downward_node:last-child::before { + border-left: var(--requirement-tree-downward-line); +} + +.requirement-tree_downward .requirement-tree_downward_node:first-child::before { + bottom: calc(100% - var(--requirement-tree-downward-margin)*1 - 0.75rem); +} + +.requirement-tree_downward_node .requirement-tree_downward_item { + position: relative; + /* margin-left: calc(var(--requirement-tree-downward-margin) + var(--requirement-tree-downward-string-margin)); */ + margin-left: calc(var(--requirement-tree-downward-margin) - 0.25rem); + + border-radius: 4px; + overflow: clip; + border: 1px solid var(--requirement-tree-line-color); + background-color: var(--color-bg-main); + + overflow-wrap: break-word; +} + +.requirement-tree_downward_item span, +.requirement-tree_downward_item a { + padding: 4px 6px; + display: inline-block; + width: 100%; + overflow-wrap: break-word; +} + +.requirement-tree_downward_item a { + color: var(--color-accent); + text-decoration: none; +} + +.requirement-tree_downward_item a:hover { + text-decoration: underline; +} + +/* hover */ + +/* .requirement-tree_node:hover + .requirement-tree::before, +.requirement-tree_node:hover + .requirement-tree .requirement-tree::before, +.requirement-tree_node:hover + .requirement-tree .requirement-tree_branch::before, +.requirement-tree_node:hover + .requirement-tree .requirement-tree_branch::after { + border-width: 2px; +} */ diff --git a/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/requirement__temporary.css b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/requirement__temporary.css new file mode 100644 index 0000000..24122fe --- /dev/null +++ b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/requirement__temporary.css @@ -0,0 +1,138 @@ +/* TODO: should be revised and then moved to a permanent location or removed */ + +/* requirement__title */ + +.requirement__title { + margin: 0; + line-height: 1.6; + font-weight: bold; +} + +/* requirement: parent / child / file */ + +ul.requirement__link { + font-size: .85rem; + line-height: 1.4; + list-style: none; + padding: 0; +} + +[data-viewtype="source-file"] ul.requirement__link li { + margin-top: 0.5rem; +} + +.requirement__link a, +.requirement__link li > span { + display: inline-block; + position: relative; + margin-left: 1.5rem; + width: calc(100% - 1.5rem); + overflow-wrap: break-word; +} + +.requirement__link a::before, +.requirement__link li > span::before { + color: #808080; + position: absolute; + left: -1.5rem; +} + +.requirement__link a:link, +.requirement__link a:visited { + color: var(--color-fg-contrast); + text-decoration: none; +} + +.requirement__link a:hover { + /* color: var(--color-fg-accent); */ + text-decoration: underline; +} + +/* .requirement__link a::before { + content: '\2014'; +} */ + +a.requirement__link-file::before, +.requirement__link-file::before { + content: ''; +} + +a.requirement__link-parent::before { + content: '\2190'; +} + +a.requirement__link-child::before { + content: '\2192'; +} + +.requirement__link-external::before { + content: '\21D6'; +} + +.requirement__parent-uid, +.requirement__child-uid { + position: relative; + font-weight: bold; +} + +/* switch (injected by JS) */ + +.std-switch { + display: flex; + align-items: center; + justify-content: flex-start; + + user-select: none; + cursor: pointer; +} + +.std-switch input { + opacity: 0; + width: 0; + height: 0; + position: absolute; +} + +.std-switch_slider { + + position: relative; + cursor: pointer; + background-color: #ccc; + -webkit-transition: .4s; + transition: .4s; + + display: inline-block; + width: 44px; + height: 26px; + margin-right: 10px; + + border-radius: 22px; +} + +.std-switch_slider::before { + position: absolute; + content: ""; + height: 18px; + width: 18px; + left: 4px; + bottom: 4px; + background-color: white; + -webkit-transition: .4s; + transition: .4s; + + border-radius: 50%; +} + +input:checked + .std-switch_slider { + background-color: rgb(100, 222, 50); +} + +input:focus + .std-switch_slider { + box-shadow: 0 0 1px rgb(100, 222, 50); +} + +input:checked + .std-switch_slider:before { + -webkit-transform: translateX(18px); + -ms-transform: translateX(18px); + transform: translateX(18px); +} diff --git a/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/resizable_bar.js b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/resizable_bar.js new file mode 100644 index 0000000..098482c --- /dev/null +++ b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/resizable_bar.js @@ -0,0 +1,602 @@ +// Expected in element: +// js-resizable_bar="name" +// data-state="open|closed" +// data-position="left|right" + +class ResizableBar { + constructor({ + barAttribute, + barOpenMinWidth, + barOpenMaxWidthRatio, + // styles + barPadding, + barPaddingBottom, + barClosedWidth, + barHandlerWidth, + barColorMain, + barColorBackground, + barColorActive, + barColorBorder, + barColorScrollbarTrack, + barColorScrollbarThumb, + }) { + this.barAttribute = barAttribute || 'js-resizable_bar'; + this.barOpenMaxWidthRatio = barOpenMaxWidthRatio || 0.2; + this.barOpenMinWidth = barOpenMinWidth || 77; + // styles + this.barPadding = barPadding || 'calc(var(--base-rhythm, 8px)*2)'; + this.barPaddingBottom = barPaddingBottom || 'calc(var(--base-rhythm, 8px)*8)'; + this.barClosedWidth = barClosedWidth || 12; + this.barHandlerWidth = barHandlerWidth || 8; + this.barColorMain = barColorMain || 'var(--color-fg-main, Black)'; + this.barColorBackground = barColorBackground || 'var(--color-bg-main, White)'; + this.barColorActive = barColorActive || 'var(--color-fg-accent, currentColor)'; + this.barColorBorder = barColorBorder || 'var(--color-border, rgba(0,0,0,0.1))'; + this.barColorScrollbarTrack = barColorScrollbarTrack || 'var(--scrollbarBG, transparent)'; + this.barColorScrollbarThumb = barColorScrollbarThumb || 'var(--thumbBG, rgba(0,0,0,.05))'; + + // state + this.state = { + current: { + id: null, + direction: null, // 1||-1 + pageX: null + } + }; + + this.initialState = 'open'; + this.initialWidth = `${this.barOpenMaxWidthRatio * 100}vw`; + this.initialStyle = ``; + + // subscribe + const _this = this; + this._mouseDownHandler = (e) => {_this._onMouseDown(e)}; + this._mouseMoveHandler = (e) => {_this._onMouseMove(e)}; + this._mouseUpHandler = (e) => {_this._onMouseUp(e)}; + this._toggleHandler = (e) => {_this._toggle(e)}; + } + + init() { + this._insertInitialBarStyle(); + this._insertInitialPreloaderStyle(); + } + + render() { + this._renderBars(); + this._insertBarStyle(); + this._insertPreloaderStyle(); + } + + // render + + _renderBars() { + [...document.querySelectorAll(`[${this.barAttribute}]`)] + .forEach((bar) => { + const id = bar.getAttribute(this.barAttribute); + const position = bar.dataset.position; + const direction = (bar.dataset.position === 'left') ? 1 : -1;; + const state = this._sessionStorageGetItem(id, 'state') || this.initialState; + const width = this._sessionStorageGetItem(id, 'width'); + + // Read data from element and from Storage + // and set to State: + this._setState({ + id: id, + element: bar, + position: position, + direction: direction, + state: state, + width: width, + }); + + // Update Bar with data from Storage: + this._updateBar(id); + + // Wrap the bar content in the created scrolling element: + const wrapper = this._createScrollableWrapper(id); + [ ...bar.childNodes ].forEach(child => wrapper.appendChild(child)); + bar.appendChild(wrapper); + + // Add control elements: + bar.append(this._createHandler(id)); + + // Add testID: + this._addTestID(bar, id, 'bar'); + }); + } + + _adjustWidth(width) { + let adjustedWidth = width; + const max = window.innerWidth * this.barOpenMaxWidthRatio; + if(width && width < this.barOpenMinWidth) { + adjustedWidth = this.barOpenMinWidth + } + if(width && width > max) { + adjustedWidth = null; + } + return adjustedWidth; + } + + // session storage + + _sessionStorageGet() { + return JSON.parse(sessionStorage.getItem('resizableBarStorage')) + } + + _sessionStorageSet(obj) { + const string = JSON.stringify(obj); + sessionStorage.setItem('resizableBarStorage', string) + } + + _sessionStorageGetItem(id, item) { + const storage = this._sessionStorageGet(); + const value = (storage && storage[id]) ? storage[id][item] : null; + return value; + } + + _sessionStorageSetItem(id, item, value) { + let storage = this._sessionStorageGet() || {}; + storage = { + ...storage, + [id]: { + ...storage[id], + [item]: value, + }, + }; + this._sessionStorageSet(storage); + } + + // state + + _setState({ + id, + element, + state, + position, + direction, + width, + }) { + this.state[id] = { + element: element, + state: state, + position: position, + direction: direction, + width: width, + }; + } + + _updateState({ + id, + element, + state, + position, + direction, + width, + }) { + console.assert(id, '_updateState(): ID must be provided'); + if (!this.state[id]) { this.state[id] = {} } + if (element) { this.state[id].element = element; } + if (state) { this.state[id].state = state; } + if (position) { this.state[id].position = position; } + if (direction) { this.state[id].direction = direction; } + if (width || width===null) { this.state[id].width = width; } + } + + // current + + _updateCurrent(e) { + if (e.type == "mousedown") { + // When we start a new resize, we update the currents: + this.state.current.id = e.target.dataset.content; + this.state.current.pageX = e.pageX; + this.state.current.startWidth = this.state[this.state.current.id].element.offsetWidth; + } else { + // e.type == "mouseup" + // At the end of the resize: + this.state.current.id = null; + this.state.current.pageX = null; + this.state.current.startWidth = null; + } + } + + // elements + + _addTestID(element, id, attr) { + element.dataset.testid = `${id}-${attr}`; + } + + _updateBar(id) { + const barState = this.state[id]; + const bar = this.state[id].element; + bar.dataset.position = barState.position; + bar.dataset.state = barState.state; + this._updateBarWidth(bar, barState.width); + } + + _updateBarWidth(bar, width) { + // If there is no specific width, set the maximum. + // The style tag cannot be left empty to override the preloaded styles + // set for each bar with the width taken from the storage + // before the page is rendered. + bar.style.width = width ? `${width}px` : `${this.barOpenMaxWidthRatio * 100}vw`; + } + + _createHandler(id) { + const handler = document.createElement('div'); + handler.setAttribute(`${this.barAttribute}-handler`, ''); + handler.dataset.content = id; + handler.style[this.state[id].position] = 'unset'; // 'left | right' + + const border = document.createElement('div'); + border.setAttribute(`${this.barAttribute}-border`, ''); + border.dataset.content = id; + border.title = `Resize ${id}`; + border.addEventListener('mousedown', this._mouseDownHandler); + + const button = document.createElement('div'); + button.setAttribute(`${this.barAttribute}-button`, ''); + button.dataset.content = id; + button.title = `Toggle ${id}`; + button.addEventListener('mousedown', this._toggleHandler); + + // Add testIDs: + this._addTestID(border, id, 'handler-border'); + this._addTestID(button, id, 'handler-button'); + + handler.append(border, button); + return handler; + } + + _createScrollableWrapper(id, direction = 'y') { + const wrapper = document.createElement('div'); + wrapper.setAttribute(`${this.barAttribute}-scroll`, direction); + wrapper.dataset.content = id; + return wrapper; + } + + // event listeners + + _onMouseDown(e) { + // Init resizing + if (e.button == 0) { + e.preventDefault(); + this._updateCurrent(e); + window.addEventListener('mousemove', this._mouseMoveHandler); + window.addEventListener('mouseup', this._mouseUpHandler); + } + } + + _onMouseMove(e) { + // Resizing + const currentId = this.state.current.id; + const currentX = this.state.current.pageX; + const currentStartWidth = this.state.current.startWidth; + const currentBar = this.state[currentId].element; + + // todo: _onMouseUp() does not always stop execution of requestAnimationFrame, + // and after the correct width is calculated in _adjustWidth (20vw), + // the extreme width from this function can be set again (for ex.: 789px). + // requestAnimationFrame(() => { + + // currentId exists if a resize has been initiated + if (currentId) { + + // Resize + // * delta: the distance traveled by the mouse, starting from the initial point + const delta = e.pageX - currentX; + // * this.state[currentId].direction = 1 || -1 + // * w: current bar width + this.state.current.width = currentStartWidth + this.state[currentId].direction * delta; + + // Rendering the change in width of the bar: + // currentBar.style.width = w + 'px'; + this._updateBarWidth(currentBar, this.state.current.width); + + // Close/Open + if (this.state.current.width < this.barOpenMinWidth) { + if (this.state[currentId].state == 'open') { + this._close(currentId); + } + } else { + if (this.state[currentId].state == 'closed') { + this._open(currentId); + } + } + } + + // }) + } + + _onMouseUp(e) { + // Clean up after work + window.removeEventListener('mousemove', this._mouseMoveHandler); + window.removeEventListener('mouseup', this._mouseUpHandler); + + const currentWidth = this._adjustWidth(this.state.current.width); + this._updateState({ id: this.state.current.id, width: currentWidth }); + this._sessionStorageSetItem(this.state.current.id, 'width', currentWidth); // WRITE DATA TO STORAGE + this._updateBar(this.state.current.id); + this._updateCurrent(e); + } + + _toggle(e) { + if (e.button == 0) { + const id = e.target.dataset.content; + this.state[id].state = this.state[id].state === 'open' + ? 'closed' + : 'open'; + this._sessionStorageSetItem(id, 'state', this.state[id].state); + this._updateBar(id); + } + } + + _open(id) { + this.state[id].state = 'open'; + this._sessionStorageSetItem(id, 'state', this.state[id].state); + this._updateBar(id); + } + + _close(id) { + this.state[id].state = 'closed'; + this._sessionStorageSetItem(id, 'state', this.state[id].state); + this._updateBar(id); + } + + // styles + + _insertStyle(css, attr) { + const style = document.createElement('style'); + style.setAttribute(`${this.barAttribute}-${attr}`, ''); + style.textContent = css; + document.head.append(style); + } + + _insertInitialBarStyle() { + const storage = this._sessionStorageGet(); + + let initStyle = `[${this.barAttribute}]{width:${this.barOpenMaxWidthRatio * 100}vw}`; + + // Add styles based on data from Storage: + for (let id in storage) { + const w = (storage[id].state == 'closed') ? this.barClosedWidth : storage[id].width; + // If w = null (this is possible if so in the storage), + // the base style will be in effect: + w && (initStyle += `[${this.barAttribute}="${id}"]{width:${w}px}`); + } + + this._insertStyle(initStyle, 'initial-style') + } + + _insertBarStyle() { + let barStyle = ` +[${this.barAttribute}] { + position: relative; + height: 100%; + max-width: ${this.barOpenMaxWidthRatio * 100}vw; +} + +[${this.barAttribute}]:hover { + z-index: 22; +} + +[${this.barAttribute}][data-state="open"] { + min-width: ${this.barOpenMinWidth}px; + pointer-events: auto; +} +[${this.barAttribute}][data-state="closed"] { + max-width: ${this.barClosedWidth}px; + min-width: ${this.barClosedWidth}px; + pointer-events: none; + transition: .5s; +} + +[${this.barAttribute}][data-position="left"] { + border-left: none; +} +[${this.barAttribute}][data-position="right"] { + border-right: none; +} + +[${this.barAttribute}-handler] { + pointer-events: auto; + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + z-index: 10; + width: ${this.barHandlerWidth}px; + color: ${this.barColorActive}; +} + +[${this.barAttribute}-border] { + pointer-events: auto; + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + width: ${this.barHandlerWidth}px; + background: transparent; + transition: .3s; + cursor: col-resize; +} + +[${this.barAttribute}][data-state="closed"] [${this.barAttribute}-border] { + cursor: e-resize; +} + +[${this.barAttribute}-border]::before { + content: ''; + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + width: 1px; + background: ${this.barColorBorder}; + transition: .3s; +} + +[${this.barAttribute}-border]::after { + content: ''; + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + width: ${0.5 * this.barHandlerWidth}px; + background: transparent; + transition: .3s; +} + +[${this.barAttribute}][data-position="left"] [${this.barAttribute}-border]::before { + right: 0; + left: unset; +} +[${this.barAttribute}][data-position="left"] [${this.barAttribute}-border]::after { + right: ${-0.25 * this.barHandlerWidth}px; + left: unset; +} + +[${this.barAttribute}][data-position="right"] [${this.barAttribute}-border]::before { + right: unset; + left: 0; +} +[${this.barAttribute}][data-position="right"] [${this.barAttribute}-border]::after { + right: unset; + left: ${-0.25 * this.barHandlerWidth}px; +} + +[${this.barAttribute}-border]:hover::after { + background: ${this.barColorActive}; +} + +[${this.barAttribute}-button] { + cursor: pointer; + position: absolute; + z-index: 2; + left: 0; + right: 0; + top: ${-1 * this.barHandlerWidth}px; + box-sizing: border-box; + width: ${2 * this.barHandlerWidth}px; + height: ${2 * this.barHandlerWidth}px; + font-size: ${1.5 * this.barHandlerWidth}px; + font-weight: bold; + border-radius: 50%; + border-width: 1px; + border-style: solid; + border-color: ${this.barColorBackground}; + background: ${this.barColorBackground}; + color: ${this.barColorActive}; + transition: .3s; +} + +[data-position="right"] [${this.barAttribute}-button] { + right: 0; + left: unset; +} +[data-position="left"] [${this.barAttribute}-button] { + left: 0; + right: unset; +} + +[${this.barAttribute}-button]:hover { + color: ${this.barColorMain}; + border-color: ${this.barColorMain}; +} + +/* โฎโฏ */ +[${this.barAttribute}-button]::after { + content: 'โฎ'; + position: absolute; + display: flex; + align-items: center; + justify-content: center; + left: 0; + right: 0; + top: ${-1 * this.barHandlerWidth}px; + bottom: ${-1 * this.barHandlerWidth}px; +} +[${this.barAttribute}][data-state="open"] [${this.barAttribute}-button]::after, +[${this.barAttribute}][data-state="open"][data-position="left"] [${this.barAttribute}-button]::after, +[${this.barAttribute}][data-state="closed"][data-position="right"] [${this.barAttribute}-button]::after { + content: 'โฎ'; +} +[${this.barAttribute}][data-state="closed"] [${this.barAttribute}-button]::after, +[${this.barAttribute}][data-state="closed"][data-position="left"] [${this.barAttribute}-button]::after, +[${this.barAttribute}][data-state="open"][data-position="right"] [${this.barAttribute}-button]::after { + content: 'โฏ'; +} + +[${this.barAttribute}-scroll] { + height: 100%; + overflow-x: hidden; + overflow-y: scroll; + /*padding: ${this.barPadding}; + padding-bottom: ${this.barPaddingBottom};*/ + scrollbar-color: ${this.barColorScrollbarTrack} ${this.barColorScrollbarTrack}; +} +[${this.barAttribute}-scroll='y'] { + overflow-x: hidden; + overflow-y: scroll; +} +[${this.barAttribute}-scroll]:hover { + scrollbar-color: ${this.barColorScrollbarThumb} ${this.barColorScrollbarTrack}; +} +[${this.barAttribute}-scroll]::-webkit-scrollbar-thumb { + background-color: ${this.barColorScrollbarTrack}; +} +[${this.barAttribute}-scroll]:hover::-webkit-scrollbar-thumb { + background-color: ${this.barColorScrollbarThumb} +} + +[data-state="closed"] [${this.barAttribute}-scroll] { + display: none; +} +`; + + this._insertStyle(barStyle, 'style'); + } + + _insertInitialPreloaderStyle() { + let style = ` + aside { + /* for a pseudo preloader [js-resizable_bar]::after, affects: layout_tree,layout_toc */ + position: relative; + } + [${this.barAttribute}]::after { + display: flex; + align-items: center; + justify-content: center; + content: ''; + position: absolute; + left: 0; right: 0; top: 0; bottom: 0; + z-index: 2; + background-color: ${this.barColorBackground}; + } + `; + + this._insertStyle(style, 'initial-preloader-style'); + } + + _insertPreloaderStyle() { + let style = ` + [${this.barAttribute}]::after { + opacity: 0; + transition: .3s; + pointer-events: none; + } + `; + + this._insertStyle(style, 'preloader-style'); + } +} + +const resizableBar = new ResizableBar({}); +resizableBar.init(); + +window.addEventListener("load", function () { + resizableBar.render(); +}); diff --git a/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/toc_highlighting.js b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/toc_highlighting.js new file mode 100644 index 0000000..fb96016 --- /dev/null +++ b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/toc_highlighting.js @@ -0,0 +1,291 @@ +const TOC_HIGHLIGHT_DEBUG = false; + +const TOC_FRAME_SELECTOR = 'turbo-frame#frame-toc'; // updating +const TOC_LIST_SELECTOR = 'ul#toc'; +const TOC_ELEMENT_SELECTOR = 'a'; +const CONTENT_FRAME_SELECTOR = 'turbo-frame#frame_document_content'; // replacing => parentNode is needed +const CONTENT_ELEMENT_SELECTOR = 'sdoc-anchor'; + +let tocHighlightingState = { + data: {}, + links: null, + anchors: null, + contentFrameTop: undefined, + closerForFolder: {}, + folderSet: new Set(), +}; + +function resetState() { + tocHighlightingState.data = {}; + tocHighlightingState.links = null; + tocHighlightingState.anchors = null; + tocHighlightingState.closerForFolder = {}; + tocHighlightingState.folderSet = new Set(); +} + +window.addEventListener("hashchange", handleHashChange); +window.addEventListener("load",function(){ + + // * Frames are stable and we define them once. + const tocFrame = document.querySelector(TOC_FRAME_SELECTOR); + const tocList = tocFrame ? tocFrame.querySelector(TOC_LIST_SELECTOR) : null; + const contentFrame = document.querySelector(CONTENT_FRAME_SELECTOR)?.parentNode; + + if(!tocFrame || !tocList || !contentFrame) { return } + + // ! depends on TOC markup + tocHighlightingState.contentFrameTop = contentFrame.offsetParent + ? contentFrame.offsetTop + : contentFrame.parentNode.offsetTop; + + const anchorObserver = new IntersectionObserver( + handleIntersect, + { + root: null, + rootMargin: "0px", + }); + + // * Then we will refresh when the TOC tree is updated& + // * The content in the tocFrame frame will mutate: + const mutatingFrame = tocFrame; + new MutationObserver(function (mutationsList, observer) { + // * Use requestAnimationFrame to put highlightTOC + // * at the end of the event queue and to ensure + // * the code runs after all DOM changes have been applied. + requestAnimationFrame(() => { + highlightTOC(tocFrame, contentFrame, anchorObserver); + }) + }).observe( + mutatingFrame, + { + // * We're looking at an updatable frame (mutates its contents, + // * and we don't care what mutations were made inside): + childList: true, + // attributes: true, + // characterData: true, + // subtree: true + } + ); + + // * Call for the first time only if the TOC actually contains items. + if (tocList && tocList.querySelector(TOC_ELEMENT_SELECTOR)) { + highlightTOC(tocFrame, contentFrame, anchorObserver); + } + +},false); + +function highlightTOC(tocFrame, contentFrame, anchorObserver) { + + resetState(); + processLinkList(tocFrame); + processAnchorList(contentFrame, anchorObserver); + handleHashChange(); + + TOC_HIGHLIGHT_DEBUG && console.log(tocHighlightingState); +} + +function handleHashChange() { + const hash = window.location.hash; + const match = hash.match(/#(.*)/); + const fragment = match ? match[1] : null; + + // Guard: no links collected yet (e.g., empty TOC or init race) + if (!tocHighlightingState.links || typeof tocHighlightingState.links.forEach !== 'function') { + return; + } + + tocHighlightingState.links.forEach(link => { + targetItem(link, false) + }); + // * When updating the hash + // * and there's a fragment, + fragment + // * and the corresponding link-anchor pair is registered, + && tocHighlightingState.data[fragment] + // * highlight the corresponding link. + && targetItem(tocHighlightingState.data[fragment].link) +} + +function processLinkList(tocFrame) { + // * Collects all links in the TOC + tocHighlightingState.links = tocFrame.querySelectorAll(TOC_ELEMENT_SELECTOR); + if (!tocHighlightingState.links || tocHighlightingState.links.length === 0) { + return; + } + tocHighlightingState.links.length + && tocHighlightingState.links.forEach(link => { + const id = link.getAttribute('anchor'); + tocHighlightingState.data[id] = { + 'link': link, + ...tocHighlightingState.data[id] + } + + // ! depends on TOC markup + // is link in collapsible node and precedes the UL + // ! expected UL or null + const ul = link.nextSibling; + + if (ul && ul.nodeName === 'UL') { + // register folder + tocHighlightingState.folderSet.add(id); + + // register closer + const lastLink = findDeepestLastChild(ul); + const lastAnchor = lastLink.getAttribute('anchor'); + + + if (!tocHighlightingState.closerForFolder[lastAnchor]) { + tocHighlightingState.closerForFolder[lastAnchor] = []; + } + tocHighlightingState.closerForFolder[lastAnchor].push(id); + } + }); +} + +function processAnchorList(contentFrame, anchorObserver) { + anchorObserver.disconnect(); // FIXME don`t work: have to hack at #rootBounds_null + + // * Collects all anchors in the document + tocHighlightingState.anchors = null; + tocHighlightingState.anchors = contentFrame.querySelectorAll(CONTENT_ELEMENT_SELECTOR); + tocHighlightingState.anchors.length + && tocHighlightingState.anchors.forEach(anchor => { + const id = anchor.id; + tocHighlightingState.data[id] = { + 'anchor': anchor, + ...tocHighlightingState.data[id] + }; + // * Adds an observer for the position of the anchor + anchorObserver.observe(anchor); + }); +} + +function handleIntersect(entries, observer) { + + entries.forEach((entry) => { + + // #rootBounds_null + // rootBounds: null + // after frame reload and before init + if(!entry.rootBounds) { + return + } + + const anchor = entry.target.id; + // * For anchors that go into the viewport, + // * finds the corresponding links + const link = tocHighlightingState.data[anchor].link; + + // * if there is no menu item for the section in the TOC + if(!link) { + return + } + + if (entry.isIntersecting) { //! entry.intersectionRatio > 0 -- it happens to be equal to zero at the intersection! + + TOC_HIGHLIGHT_DEBUG && console.group('๐Ÿ”ถ', entry.isIntersecting, entry.intersectionRatio, anchor, entry.intersectionRect.height); + // * and highlights them in the TOC, + fireItem(link) + + // * semi-highlights folder in the TOC, + if (tocHighlightingState.folderSet.has(anchor)) { + TOC_HIGHLIGHT_DEBUG && console.log('๐Ÿ”ด', anchor, '(visible folder)', ); + fireFolder(link) + } + + // * semi-highlights closer`s parent folder in the TOC, + if (tocHighlightingState.closerForFolder[anchor]) { + tocHighlightingState.closerForFolder[anchor].forEach(id => { + TOC_HIGHLIGHT_DEBUG && console.log(`๐Ÿ”ด`, id, `(from ${anchor})`); + fireFolder(tocHighlightingState.data[id].link) + }) + } + TOC_HIGHLIGHT_DEBUG && console.groupEnd(); + + } else { + + TOC_HIGHLIGHT_DEBUG && console.group('๐Ÿ”น', entry.isIntersecting, entry.intersectionRatio, anchor); + // * or cancels highlighting for the rest of the links. + fireItem(link, false); + + if( + // * If the node goes down โฌ‡๏ธ off the screen + entry.boundingClientRect.bottom >= entry.rootBounds.bottom + // * and it's a folder + && tocHighlightingState.folderSet.has(anchor) + ) { + // ** remove highlights from folder in the TOC + TOC_HIGHLIGHT_DEBUG && console.log(`โšซ โฌ‡๏ธ`, anchor); + fireFolder(link, false) + } + + if( + // * If the node goes up โฌ†๏ธ off the screen + entry.boundingClientRect.y < tocHighlightingState.contentFrameTop + // * and this is the last child of the section + && tocHighlightingState.closerForFolder[anchor] + ) { + // * When the LAST CHILD of the section disappears + // * over the upper boundary ( < tocHighlightingState.contentFrameTop), + // * strictly speaking, this occurs when the lower bound disappears: + // * entry.boundingClientRect.bottom. + // * But we will use the upper bound, entry.boundingClientRect.y + // * which will be less than or equal to the lower bound. + + // ** remove highlights from closer`s parent folder in the TOC + tocHighlightingState.closerForFolder[anchor].forEach(id => { + TOC_HIGHLIGHT_DEBUG && console.log(`โšซ โฌ†๏ธ`, id,); + fireFolder(tocHighlightingState.data[id].link, false) + }); + } + + TOC_HIGHLIGHT_DEBUG && console.groupEnd(); + } + }); + +} + +function findDeepestLastChild(element) { + // ! depends on TOC markup + // ul > li > div + a + ul > ... + // ul > li > a + // > li > a <---------------*** + if (element.nodeName === 'A') { + return element; + } + const children = element.children; + if (children && children.length > 0) { + return findDeepestLastChild([...children].at(-1)) + } else { + return element; + } +} + +function targetItem(element, on = true) { + if (!element) { return } // Guard against race conditions: + // hashchange or intersection events may fire + // before the TOC is fully built, resulting in undefined link elements. + if(on) { + element.setAttribute('targeted', ''); + } else { + element.removeAttribute('targeted'); + } +} + +function fireItem(element, on = true) { + if (!element) { return } // Guard against race conditions + if(on) { + element.setAttribute('intersected', ''); + } else { + element.removeAttribute('intersected'); + } +} + +function fireFolder(element, on = true) { + if (!element) { return } // Guard against race conditions + if(on) { + element.setAttribute('parented', ''); + } else { + element.removeAttribute('parented'); + } +} diff --git a/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/viewtype_menu.js b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/viewtype_menu.js new file mode 100644 index 0000000..ff46c69 --- /dev/null +++ b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/assets/viewtype_menu.js @@ -0,0 +1,29 @@ +// viewtype_ +// https://kittygiraudel.com/2021/03/18/close-on-outside-click/ + +window.addEventListener("load",function(){ + + const toggle = document.getElementById('viewtype_handler'); + const content = document.getElementById('viewtype_menu'); + + const show = () => { + toggle.setAttribute('aria-expanded', true); + content.setAttribute('aria-hidden', false); + } + + const hide = () => { + toggle.setAttribute('aria-expanded', false); + content.setAttribute('aria-hidden', true); + } + + toggle.addEventListener('click', event => { + event.stopPropagation(); + JSON.parse(toggle.getAttribute('aria-expanded')) ? hide() : show(); + }) + + const handleClosure = event => !content.contains(event.target) && hide(); + + window.addEventListener('click', handleClosure); + window.addEventListener('focusin', handleClosure); + +},false); diff --git a/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/strictdoc/docs/index.html b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/strictdoc/docs/index.html new file mode 100644 index 0000000..336d1cc --- /dev/null +++ b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/strictdoc/docs/index.html @@ -0,0 +1,862 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Test document - PDF + + + + + + +
+ +
+ +
+ +
+
+ + + + + + +
StrictDoc Documentation +
+ + + + + + + +
+ Test document +
+
+ + +
+ + +
+
+
+ +
+ + + +
+
+
+ + Table of contents + +
+ + + 1 + + + Section 1 + + + +
+ + + 2 + + + Section 2 + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ +1. Section 1

+
+ + + + + + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + STATEMENT: + + +
+

Vivamus consectetur mollis varius. Quisque posuere venenatis nulla, sit amet pulvinar metus vestibulum sed. Sed at libero nec justo leo.

+
+
+ + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ +2. Section 2

+
+ + + + + + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + STATEMENT: + + +
+

Lorem ipsum dolor sit amet, c

+
+
+ + + + + + + + + + + + + +
+ + +
+ + +
+
+ + + + + + +
+ + + + + +
+ + +
+ + + + \ No newline at end of file diff --git a/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/test.itest b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/test.itest new file mode 100644 index 0000000..cb0d4b2 --- /dev/null +++ b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/test.itest @@ -0,0 +1,4 @@ +RUN: %html2pdf print %S/strictdoc/docs/index.html %S/Output/index.pdf + +RUN: %check_exists --file "%S/Output/index.pdf" +RUN: python %S/test.py diff --git a/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/test.py b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/test.py new file mode 100644 index 0000000..916dea4 --- /dev/null +++ b/tests/integration/40_only_child_does_not_break_page_when_surrounded_by_text_nodes/test.py @@ -0,0 +1,5 @@ +from pypdf import PdfReader + +reader = PdfReader("Output/index.pdf") + +assert len(reader.pages) == 3, len(reader.pages)