@formfeed/engine 0.3.17 → 0.3.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,19 +14,38 @@ npm install @formfeed/engine
14
14
  ```
15
15
 
16
16
  ```ts
17
- import { getEngine, defaultHelpers, defaultLimits, assembleDocument } from '@formfeed/engine';
17
+ import {
18
+ getEngine,
19
+ defaultHelpers,
20
+ defaultLimits,
21
+ assembleDocument,
22
+ } from '@formfeed/engine';
18
23
 
19
24
  const engine = getEngine('liquid');
20
25
  const compiled = engine.compile('<h1>{{ title | upper }}</h1>', {});
21
26
  const analysis = engine.analyze('<h1>{{ title | upper }}</h1>');
22
27
  // analysis.variables → [{ path: ['title'], ... }], analysis.diagnostics → []
23
28
 
24
- const html = await engine.render(compiled, { title: 'Hello' }, {
25
- locale: 'de-DE', timezone: 'Europe/Berlin', currency: 'EUR',
26
- partials: async () => null, helpers: defaultHelpers(), limits: defaultLimits,
27
- });
29
+ const html = await engine.render(
30
+ compiled,
31
+ { title: 'Hello' },
32
+ {
33
+ locale: 'de-DE',
34
+ timezone: 'Europe/Berlin',
35
+ currency: 'EUR',
36
+ partials: () => undefined,
37
+ helpers: defaultHelpers(),
38
+ limits: defaultLimits,
39
+ },
40
+ );
28
41
 
29
- const document = assembleDocument({ html, css: '', head: '', settings: { paper: { format: 'A4' } }, kind: 'pdf' });
42
+ const document = assembleDocument({
43
+ html,
44
+ css: '',
45
+ head: '',
46
+ settings: { paper: { format: 'A4' } },
47
+ kind: 'pdf',
48
+ });
30
49
  ```
31
50
 
32
51
  The supported surface is the `Engine` interface (`compile`, `analyze`, `render`) returned by
@@ -35,15 +54,15 @@ The supported surface is the `Engine` interface (`compile`, `analyze`, `render`)
35
54
 
36
55
  ## What is inside
37
56
 
38
- | Module | Contents |
39
- |---|---|
40
- | `engines/` | `jinja2` (Nunjucks with a Python compatibility layer), `liquid` (LiquidJS), `handlebars`, each implementing `Engine` |
41
- | `helpers/` | One helper registry for all three dialects: formatting (`money`, `date`, `number`, `numToWords`, `t`), text, collections, codes (`qrcode`, `barcode`, `epcQr`), document (`asset`, `pageBreak`, `image`, `chart`) |
42
- | `analysis/` | Block pairing and sample-data checks behind every `analyze()` |
43
- | `schema.ts` | `inferSchema(sample)` to JSON Schema 2020-12 |
44
- | `assemble.ts` | Template settings, print reset, `assembleDocument()` and `renderVersion()` (body, header, footer, title) |
45
- | `import/` | `importApitemplate()` and `importApitemplateFromApi()`, `importPdfmonkey()` and `importJsreport()`: convert templates of apitemplate.io, PDFMonkey and jsreport into Formfeed drafts |
46
- | `office/` | Word and PowerPoint templates: `renderOffice()` fills a `.docx` or `.pptx` file, `analyzeOffice()` lists its tags, variables and findings per part and paragraph, `OfficeTemplateError` carries the findings of a document that cannot be filled, and `starterDocument()` and `starterPresentation()` return example files with their sample data |
57
+ | Module | Contents |
58
+ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
59
+ | `engines/` | `jinja2` (Nunjucks with a Python compatibility layer), `liquid` (LiquidJS), `handlebars`, each implementing `Engine` |
60
+ | `helpers/` | One helper registry for all three dialects: formatting (`money`, `date`, `number`, `numToWords`, `t`), text, collections, codes (`qrcode`, `barcode`, `epcQr`), document (`asset`, `pageBreak`, `image`, `chart`) |
61
+ | `analysis/` | Block pairing and sample-data checks behind every `analyze()` |
62
+ | `schema.ts` | `inferSchema(sample)` to JSON Schema 2020-12 |
63
+ | `assemble.ts` | Template settings, print reset, `assembleDocument()` and `renderVersion()` (body, header, footer, title) |
64
+ | `import/` | `importApitemplate()` and `importApitemplateFromApi()`, `importPdfmonkey()` and `importJsreport()`: convert templates of apitemplate.io, PDFMonkey and jsreport into Formfeed drafts |
65
+ | `office/` | Word and PowerPoint templates: `renderOffice()` fills a `.docx` or `.pptx` file, `analyzeOffice()` lists its tags, variables and findings per part and paragraph, `OfficeTemplateError` carries the findings of a document that cannot be filled, and `starterDocument()` and `starterPresentation()` return example files with their sample data |
47
66
 
48
67
  ## Documentation
49
68
 
package/index.cjs CHANGED
@@ -523,11 +523,11 @@ var codeHelpers = [
523
523
  aliases: ["epc_qr", "girocode"],
524
524
  doc: {
525
525
  signature: "epcQr({ name, iban, bic?, amount?, reference?, text? }, { size })",
526
- description: "SEPA credit transfer QR code (EPC069-12 / GiroCode) that banking apps scan to prefill a payment. Give the image an `alt`, and print the bank details as text as well: the code is a picture.",
526
+ description: "SEPA credit transfer QR code (EPC069-12 / GiroCode) that banking apps scan to prefill a payment. Put an invoice number into `text` (the remittance line); `reference` is only for a structured creditor reference (RF\u2026). Give the image an `alt`, and print the bank details as text as well: the code is a picture.",
527
527
  examples: {
528
- jinja2: '<img src="{{ epcQr({ name: company.name, iban: company.iban, amount: invoice.total, reference: invoice.number }) }}" alt="QR code to pay invoice {{ invoice.number }}">',
529
- liquid: '<img src="{{ company.iban | epcQr: name: company.name, amount: invoice.total, reference: invoice.number }}" alt="QR code to pay invoice {{ invoice.number }}">',
530
- handlebars: '<img src="{{epcQr name=company.name iban=company.iban amount=invoice.total reference=invoice.number}}" alt="QR code to pay invoice {{invoice.number}}">'
528
+ jinja2: '<img src="{{ epcQr({ name: company.name, iban: company.iban, amount: invoice.total, text: invoice.number }) }}" alt="QR code to pay invoice {{ invoice.number }}">',
529
+ liquid: '<img src="{{ company.iban | epcQr: name: company.name, amount: invoice.total, text: invoice.number }}" alt="QR code to pay invoice {{ invoice.number }}">',
530
+ handlebars: '<img src="{{epcQr name=company.name iban=company.iban amount=invoice.total text=invoice.number}}" alt="QR code to pay invoice {{invoice.number}}">'
531
531
  },
532
532
  category: "code"
533
533
  },
@@ -5698,6 +5698,7 @@ var textEditRuntime = '"use strict";(()=>{var O=`\nhtml.ff-edit-mode [data-ff-ed
5698
5698
  var fitRuntime = '"use strict";(()=>{function a(t,e,n){if(e===t)return t.scrollHeight<=t.clientHeight+.5&&t.scrollWidth<=t.clientWidth+.5;let o=n.getComputedStyle(t),i=t.clientHeight-(parseFloat(o.paddingTop)||0)-(parseFloat(o.paddingBottom)||0);return e.scrollHeight<=i+.5&&e.scrollWidth<=e.clientWidth+.5}function m(t,e){let n=t.firstElementChild??t;n.style.fontSize="";let o=parseFloat(e.getComputedStyle(n).fontSize)||16,i=Math.min(o,parseFloat(t.getAttribute("data-ff-fit-min")??"")||o/2);if(a(t,n,e))return o;let l=i,s=o;for(let d=0;d<14;d++){let r=(l+s)/2;n.style.fontSize=`${r}px`,a(t,n,e)?l=r:s=r}let f=Math.floor(l*100)/100;return n.style.fontSize=`${f}px`,f}function c(t){let e=()=>{for(let o of Array.from(t.document.querySelectorAll(\'[data-ff-fit="shrink"]\')))m(o,t);t.document.documentElement.setAttribute("data-ff-fit","done")};t.formfeedFit=e;let n=t.document.fonts;n?n.ready.then(e):t.addEventListener("load",e)}c(window);})();';
5699
5699
  var stageRuntime = '"use strict";(()=>{var W=`\nhtml.ff-edit-mode [data-ff-edit] { cursor: text; }\nhtml.ff-edit-mode [data-ff-edit]:hover { outline: 1px dashed rgba(37,99,235,.85); outline-offset: 2px; }\nhtml.ff-edit-mode [data-ff-edit="t"]:hover { outline-color: rgba(147,51,234,.9); }\n.ff-editing { outline: 2px solid #2563eb !important; outline-offset: 2px; cursor: text; }\n.ff-editing .ff-chip { background: rgba(37,99,235,.14) !important; box-shadow: inset 0 0 0 1px rgba(37,99,235,.45) !important; border-radius: 3px !important; padding: 0 1px !important; cursor: default; }\n.ff-edit-badge { position: absolute; z-index: 2147483647; font: 500 11px/1.4 system-ui, sans-serif !important; color: #fff !important; background: #2563eb !important; padding: 1px 6px !important; border-radius: 4px !important; pointer-events: none; white-space: nowrap; }\n`;function H(a,l={}){let f=l.clicks!==!1,p=l.live===!0,n=a.document,o=null,d=null,u=e=>{try{a.parent.postMessage(e,"*")}catch{}},m=f?n.querySelector(\'meta[name="formfeed:document"]\')?.getAttribute("content")??null:null,s=!1;a.addEventListener("blur",()=>{s=!0}),a.addEventListener("focus",()=>{s=!1});let g=n.createElement("style");g.setAttribute("data-formfeed","edit"),g.setAttribute("data-pagedjs-ignore",""),g.textContent=W,(n.head??n.documentElement).appendChild(g),f&&n.documentElement.classList.add("ff-edit-mode");let x=e=>(e&&typeof e.closest=="function"?e:null)?.closest("[data-ff-edit]")??null;n.addEventListener("click",e=>{if(!f)return;if(o&&!o.done&&o.element.contains(e.target)){e.stopImmediatePropagation();return}let t=x(e.target);t&&(e.preventDefault(),e.stopImmediatePropagation(),v(t,{x:e.clientX,y:e.clientY}))},!0);function v(e,t){o&&!o.done&&L();let r=e.getAttribute("data-ff-src")??"",i=e.getBoundingClientRect(),b=Array.from(n.querySelectorAll(`[data-ff-src="${r.replace(/"/g,"")}"]`));d={src:r,element:e,point:t},u({type:"formfeed:edit-request",src:r,doc:m,edit:e.getAttribute("data-ff-edit"),text:e.textContent??"",elements:e.childElementCount,count:b.length,index:Math.max(0,b.indexOf(e)),split:e.hasAttribute("data-split-from")||e.hasAttribute("data-split-to"),rect:{left:i.left,top:i.top,width:i.width,height:i.height}})}n.addEventListener("keydown",e=>{if(!f||o&&!o.done||!(e.ctrlKey||e.metaKey)||e.altKey)return;let t=e.key.toLowerCase();(t==="z"||t==="y")&&(e.preventDefault(),u({type:t==="y"||e.shiftKey?"formfeed:redo":"formfeed:undo"}))}),a.addEventListener("message",e=>{if(e.source!==a.parent)return;let t=e.data;!t||typeof t.type!="string"||(t.type==="formfeed:edit-begin"?B(t):t.type==="formfeed:edit-refuse"||t.type==="formfeed:edit-end"?(d=null,o&&!o.done&&S(!1)):t.type==="formfeed:edit-open"&&E(t))});function E(e){if(!f||typeof e.src!="string"||o&&!o.done)return;let t=Array.from(n.querySelectorAll(`[data-ff-src="${e.src.replace(/"/g,"")}"][data-ff-edit]`)),r=Number.isInteger(e.index)?Number(e.index):0,i=t[r]??t[0];i&&v(i,null)}if(f){let e=()=>u({type:"formfeed:edit-ready",doc:m}),t=a;t.PagedConfig?t.formfeedEditReady=e:n.readyState==="loading"?n.addEventListener("DOMContentLoaded",e):e()}function B(e){o&&!o.done&&S(!1);let t=e.layer?n.querySelector(`[data-ff-layer="${String(e.layer).replace(/"/g,"")}"] > .ff-text`):d&&d.src===e.src?d.element:n.querySelector(`[data-ff-src="${String(e.src).replace(/"/g,"")}"]`),r=e.at,i=e.layer?r&&Number.isFinite(r.x)&&Number.isFinite(r.y)?{x:Number(r.x),y:Number(r.y)}:null:d&&d.src===e.src?d.point:null;d=null;let b=s&&!n.hasFocus();if(!t||!Array.isArray(e.items)||b){u({type:"formfeed:edit-cancel",token:String(e.token)});return}let y=Array.from(t.childNodes),k=n.createDocumentFragment();for(let c of e.items)if(c.kind==="text")k.appendChild(n.createTextNode(String(c.text)));else if(c.kind==="break")k.appendChild(n.createElement("br"));else if(c.kind==="chip"){let h=n.createElement("span");h.className="ff-chip",h.setAttribute("data-ff-chip",String(c.index)),h.setAttribute("contenteditable","false"),c.title&&(h.title=String(c.title)),h.textContent=String(c.text),k.appendChild(h)}for(let c of y)t.removeChild(c);t.appendChild(k),t.contentEditable="true",t.classList.add("ff-editing"),t.setAttribute("role","textbox"),e.label&&t.setAttribute("aria-label",String(e.label)),t.spellcheck=!0,o={token:String(e.token),element:t,saved:y,allowBreaks:e.allowBreaks===!0,badge:e.note?I(t,String(e.note)):null,done:!1},t.addEventListener("keydown",T),t.addEventListener("beforeinput",N),t.addEventListener("paste",w),t.addEventListener("drop",R),t.addEventListener("focusout",F),p&&t.addEventListener("input",C),t.focus(),e.select==="all"?q(t):K(t,i),u({type:"formfeed:edit-started",token:o.token}),typeof e.insert=="string"&&e.insert&&A(e.insert.replace(/\\r\\n?|\\n/g," "))}function A(e){if(typeof n.execCommand=="function"&&n.execCommand("insertText",!1,e))return;let t=a.getSelection(),r=t&&t.rangeCount?t.getRangeAt(0):null;r&&(r.deleteContents(),r.insertNode(n.createTextNode(e)),r.collapse(!1),p&&C())}function C(){o&&!o.done&&u({type:"formfeed:edit-input",token:o.token,items:D(o.element)})}function I(e,t){let r=n.createElement("div");r.className="ff-edit-badge",r.textContent=t;let i=e.getBoundingClientRect();return r.style.left=`${i.left+a.scrollX}px`,r.style.top=`${Math.max(0,i.top+a.scrollY-22)}px`,n.body.appendChild(r),r}function q(e){let t=a.getSelection();if(!t)return;let r=n.createRange();r.selectNodeContents(e),t.removeAllRanges(),t.addRange(r)}function K(e,t){let r=a.getSelection();if(!r)return;let i=null,b=n;if(t){if(b.caretRangeFromPoint)i=b.caretRangeFromPoint(t.x,t.y);else if(b.caretPositionFromPoint){let y=b.caretPositionFromPoint(t.x,t.y);y&&(i=n.createRange(),i.setStart(y.offsetNode,y.offset))}}if(!i||!e.contains(i.startContainer))i=n.createRange(),i.selectNodeContents(e),i.collapse(!1);else if(t){let y=i.startContainer,c=(y.nodeType===1?y:y.parentElement)?.closest("[data-ff-chip]")??null;if(c&&c!==e&&e.contains(c)){let h=c.getBoundingClientRect();i=n.createRange(),t.x<h.left+h.width/2?i.setStartBefore(c):i.setStartAfter(c),i.collapse(!0)}}r.removeAllRanges(),r.addRange(i)}function T(e){let t=e.key;t==="Escape"?(e.preventDefault(),S(!0)):t==="Enter"&&!e.shiftKey?(e.preventDefault(),L()):t==="Enter"?(e.preventDefault(),o?.allowBreaks&&$()):t==="Tab"?(e.preventDefault(),L()):(e.ctrlKey||e.metaKey)&&["b","i","u"].includes(t.toLowerCase())&&(e.preventDefault(),p&&o&&!e.altKey&&u({type:"formfeed:edit-style",token:o.token,key:t.toLowerCase()}))}function N(e){let t=e.inputType??"";(t.startsWith("format")||t==="insertFromDrop"||t==="insertParagraph"||t==="insertLineBreak")&&e.preventDefault()}function w(e){e.preventDefault(),A((e.clipboardData?.getData("text/plain")??"").replace(/\\r\\n?|\\n/g," "))}function R(e){e.preventDefault()}function F(){a.setTimeout(()=>{o&&!o.done&&(!n.hasFocus()||!o.element.contains(n.activeElement))&&L()},0)}function $(){let e=a.getSelection();if(!e||!e.rangeCount)return;let t=e.getRangeAt(0);t.deleteContents();let r=n.createElement("br");t.insertNode(r),r.nextSibling||r.parentNode?.appendChild(n.createElement("br"));let i=n.createRange();i.setStartAfter(r),i.collapse(!0),e.removeAllRanges(),e.addRange(i)}function M(e){e.done=!0;let t=e.element;t.removeEventListener("keydown",T),t.removeEventListener("beforeinput",N),t.removeEventListener("paste",w),t.removeEventListener("drop",R),t.removeEventListener("focusout",F),t.removeEventListener("input",C),t.removeAttribute("contenteditable"),t.removeAttribute("role"),t.removeAttribute("aria-label"),t.classList.remove("ff-editing"),e.badge?.remove(),o===e&&(o=null)}function L(){let e=o;if(!e||e.done)return;let t=D(e.element);M(e),u({type:"formfeed:edit-commit",token:e.token,items:t})}function S(e){let t=o;if(!t||t.done)return;let r=t.element;for(;r.firstChild;)r.removeChild(r.firstChild);for(let i of t.saved)r.appendChild(i);M(t),e&&u({type:"formfeed:edit-cancel",token:t.token})}}function D(a){let l=[],f=n=>{let o=l[l.length-1];o?.kind==="text"?o.text+=n:n&&l.push({kind:"text",text:n})},p=n=>{for(let o of Array.from(n.childNodes))if(o.nodeType===3)f(o.data);else if(o.nodeType===1){let d=o,u=d.getAttribute("data-ff-chip");u!==null?l.push({kind:"chip",index:Number(u)}):d.tagName==="BR"?l.push({kind:"break"}):((d.tagName==="DIV"||d.tagName==="P")&&l.length&&l.push({kind:"break"}),p(d))}};for(p(a);l[l.length-1]?.kind==="break";)l.pop();return l}function O(a,l){return Array.from(a.querySelectorAll("[data-ff-layer]")).map(f=>{let p=f.querySelector(":scope > .ff-text"),n=!1;if(p&&f.style.height!=="auto"){let o=l.getComputedStyle(f),d=f.clientHeight-(parseFloat(o.paddingTop)||0)-(parseFloat(o.paddingBottom)||0);n=o.overflow==="hidden"&&(p.scrollHeight>d+1||p.scrollWidth>p.clientWidth+1)}return{id:f.getAttribute("data-ff-layer")??"",width:f.offsetWidth,height:f.offsetHeight,overflow:n}})}function P(a){let l=a.document,f=m=>{try{a.parent.postMessage(m,"*")}catch{}},p=m=>typeof m=="string"?l.querySelector(`[data-ff-layer="${m.replace(/"/g,"")}"]`):null,n=()=>{for(let m of Array.from(l.querySelectorAll("[data-ff-layer]")))for(let s of["left","top","width","height","transform"])m.style.removeProperty(s)},o=()=>{a.formfeedFit?.(),f({type:"formfeed:ready",layers:O(l,a)})};a.addEventListener("message",m=>{if(m.source!==a.parent)return;let s=m.data;if(!(!s||typeof s.type!="string")){if(s.type==="formfeed:layer-style"){let g=p(s.id);if(!g)return;let x=(v,E)=>{typeof E=="number"&&Number.isFinite(E)&&g.style.setProperty(v,`${E}px`)};x("left",s.left),x("top",s.top),x("width",s.width),x("height",s.height),typeof s.rotation=="number"&&Number.isFinite(s.rotation)&&g.style.setProperty("transform",s.rotation?`rotate(${s.rotation}deg)`:"none")}else if(s.type==="formfeed:layer-style-clear")n();else if(s.type==="formfeed:css"&&typeof s.css=="string"){let g=l.querySelector(\'style[data-formfeed="template"]\');g&&(g.textContent=s.css),n(),o()}}}),H(a,{clicks:!1,live:!0});let d=l.fonts,u=()=>d?void d.ready.then(o):o();l.readyState==="complete"?u():a.addEventListener("load",u)}P(window);})();';
5700
5700
  var auditRuntime = '"use strict";(()=>{var I={"document-title":"error","image-alt":"error","figure-name":"error","heading-order":"error","table-rows":"error","table-cell-empty":"error","masked-text":"error","filtered-text":"warning","document-language":"warning","table-headers":"warning","link-name":"warning","generated-text":"warning","fixed-text":"warning","running-text":"warning"};var S=120;var O=".formfeed-chrome, .ff-running-header, .ff-running-footer",_=".pageNumber, .totalPages, .date, .title, .url, .ff-page-no, .ff-page-total",k=new Set(["script","style","template","noscript","head"]),j=2e4,q=10,B=new Set(["page","pages","of","seite","seiten","von","p","s"]),u=t=>(t??"").replace(/\\s+/g," ").trim(),D=t=>t.replace(/\\s+/g,"").toLowerCase(),$=t=>/[\\p{L}\\p{N}]/u.test(t),Y=/^data-(ref|id|split-(from|to|original)|(previous-|next-)?break-(before|after|inside)|(align-)?last-split-element|nth-of-type|counter-.+|page(-number)?|undisplayed|after-page|following|has-notes|children|item-num)$/;function X(t){let n=t.cloneNode(!1);n.removeAttribute("data-ff-src"),n.removeAttribute("data-ff-edit");let i=t.closest(".pagedjs_page")!==null;for(let s of Array.from(n.attributes))i&&Y.test(s.name)?n.removeAttribute(s.name):s.value.length>48&&n.setAttribute(s.name,`${s.value.slice(0,40)}\\u2026`);let o=n.outerHTML.replace(new RegExp(`</${t.tagName}>$`,"i"),"");return o.length>S?`${o.slice(0,S-1)}\\u2026`:o}function F(t,n={}){let i=t.document,o=i.body,s=[],d=new Set,a=n.findings!==!1,c=(e,r,l={})=>{if(!a)return;let m=r?.closest("[data-ff-src]")?.getAttribute("data-ff-src")??null,h=r?X(r):"",g=`${e}|${m??h}|${JSON.stringify(l)}`;d.has(g)||(d.add(g),s.push({code:e,severity:I[e],src:m,snippet:h,args:l}))},f=new WeakMap,A=e=>{let r=f.get(e);if(r!==void 0)return r;let l=t.getComputedStyle(e),m=l.display==="none"||l.visibility==="hidden"||l.visibility==="collapse"||e.parentElement!==null&&e.parentElement!==i.documentElement&&A(e.parentElement);return f.set(e,m),m},p=e=>e.closest(\'[aria-hidden="true"]\')!==null,E=e=>/^(presentation|none)$/.test(e.getAttribute("role")??""),H=e=>e.closest(O)!==null,y=e=>$(e.textContent??""),x=e=>{let r=u(e.getAttribute("aria-label"));return r||u((e.getAttribute("aria-labelledby")??"").split(/\\s+/).filter(Boolean).map(l=>e.ownerDocument.getElementById(l)?.textContent??"").join(" "))},P=e=>x(e)||u(e.textContent)||u(Array.from(e.querySelectorAll("img[alt]")).map(r=>r.getAttribute("alt")).join(" "))||u(e.getAttribute("title")),T=e=>{let r=e.getAttribute("href")??"";return{href:r.startsWith("#")?r:e.href??r,name:P(e)}};u(i.title)||c("document-title",null),!u(i.documentElement.getAttribute("lang"))&&!n.locale&&c("document-language",null);let M=n.pages??(n.pageHeight&&n.pageHeight>0?Math.ceil(i.documentElement.scrollHeight/n.pageHeight):1),C=[],v=[],R={"masked-text":[],"filtered-text":[],"fixed-text":[]},w=(e,r)=>{R[e].some(l=>l.contains(r))||(R[e].push(r),c(e,r))},V=a&&ne(i),G=o?Array.from(o.querySelectorAll("*")).slice(0,j):[];for(let e of G){let r=e.tagName.toLowerCase();if(k.has(r)||H(e)||A(e))continue;if(r==="a"&&e.hasAttribute("href")){let g=T(e);C.push(g),!g.name&&!p(e)&&c("link-name",e)}if(!a)continue;let l=t.getComputedStyle(e),m=l.getPropertyValue("mask-image")||l.getPropertyValue("-webkit-mask-image");if(m&&m!=="none"&&y(e)&&w("masked-text",e),l.filter&&l.filter!=="none"&&y(e)&&w("filtered-text",e),l.position==="fixed"&&M>1&&y(e)&&w("fixed-text",e),V)for(let g of["::before","::after"]){let U=re(t.getComputedStyle(e,g).content);U&&c("generated-text",e,{text:U})}if(p(e))continue;r==="img"&&!E(e)?e.hasAttribute("alt")||x(e)||u(e.getAttribute("title"))||c("image-alt",e):(r==="canvas"||e.getAttribute("role")==="img"&&r!=="img")&&(x(e)||u(e.getAttribute("title"))||u(e.querySelector(":scope > title")?.textContent)||c("figure-name",e,{tag:r}));let h=/^h[1-6]$/.test(r)?Number(r[1]):e.getAttribute("role")==="heading"?Number(e.getAttribute("aria-level"))||2:0;h&&v.push({element:e,level:h}),r==="table"&&!E(e)&&Q(e,c)}let b=0;for(let{element:e,level:r}of v)(b===0?r!==1:r>b+1)&&c("heading-order",e,{level:r,previous:b}),b=r;let N=[],W=a&&o?D(J(o)):"",L=0;for(let e of["header","footer"])for(let r of z(i,e,n[e])){for(let l of Array.from(r.querySelectorAll("a[href]")))N.push(T(l));if(a)for(let{text:l,element:m}of K(r)){if(L>=q||W.includes(D(l)))continue;let h=s.length;c("running-text",m,{text:l.slice(0,80),part:e}),s.length>h&&L++}}return{findings:s,links:C,templateLinks:N}}function z(t,n,i){if(i!==void 0){if(!i.trim())return[];let o=new DOMParser().parseFromString(`<!doctype html><body>${i}</body>`,"text/html");return o.body?[o.body]:[]}return Array.from(t.querySelectorAll(`.ff-running-${n}, .formfeed-chrome[data-ff-chrome="${n}"]`))}function J(t){let n=[],i=o=>{if(o.nodeType===3){n.push(o.nodeValue??"");return}if(o.nodeType!==1)return;let s=o;if(!(k.has(s.tagName.toLowerCase())||s.matches(O)))for(let d of Array.from(o.childNodes))i(d)};return i(t),n.join(" ")}function K(t){let n=[],i=o=>{let s=o.tagName.toLowerCase();if(k.has(s)||o.matches(_))return;let d=Array.from(o.children).some(a=>a.matches(_));for(let a of Array.from(o.childNodes))if(a.nodeType===1)i(a);else if(a.nodeType===3&&!d)for(let c of(a.nodeValue??"").split(/\\s*[\xB7\u2022|]\\s*|\\s{2,}|\\n/)){let f=u(c);(f.toLowerCase().match(/[\\p{L}\\p{N}]+/gu)??[]).some(p=>!B.has(p))&&n.push({text:f,element:o})}};return i(t),n}function Q(t,n){let i=Array.from(t.rows);if(!(t.querySelector(\'th, [role="columnheader"], [role="rowheader"]\')!==null)){i.length>=2&&n("table-headers",t);return}let s=te(i),d=s.find(c=>c!==s[0]);d!==void 0&&n("table-rows",t,{first:s[0]??0,other:d});let a=i.flatMap(c=>Array.from(c.cells).filter(f=>f.tagName==="TD"&&ee(f)));a[0]&&n("table-cell-empty",a[0],{count:a.length})}var Z=\'img[alt]:not([alt=""]), svg, canvas, input, select, textarea, button, meter, progress\';function ee(t){return!/[^ \\t\\n\\r\\f]/.test(t.textContent??"")&&t.querySelector(Z)===null}function te(t){let n=[];return t.map(i=>{let o=[],s=0,d=()=>{for(;(n[s]??0)>0;)o[s]=n[s]-1,s++};for(let a of Array.from(i.cells)){d();let c=Math.max(1,a.rowSpan||1)-1;for(let f=Math.max(1,a.colSpan||1);f>0;f--)o[s++]=c}d();for(let a=s;a<n.length;a++)(n[a]??0)>0&&(o[a]=n[a]-1,s=a+1);return n=o,s})}function ne(t){let n=i=>{for(let o of Array.from(i??[])){let s=o;if(s.selectorText&&/::?(before|after)/.test(s.selectorText)&&s.style?.content||o.cssRules&&n(o.cssRules))return!0}return!1};for(let i of Array.from(t.styleSheets))try{if(n(i.cssRules))return!0}catch{return!0}return!1}function re(t){if(!t||t==="none"||t==="normal")return"";let n=(t.match(/"(?:[^"\\\\]|\\\\.)*"/g)??[]).map(o=>o.slice(1,-1).replace(/\\\\(.)/g,"$1"));if(/\\bcounters?\\(/.test(t))return u(t).slice(0,80);let i=u(n.join(""));return $(i)?i.slice(0,80):""}window.formfeedAudit=t=>F(window,t);})();';
5701
+ var pagedPrintRuntime = '"use strict";(()=>{var N=t=>!!t&&t.nodeType===1,y=t=>N(t)?t:t?.parentElement??null;function b(t,o){for(let e=t.firstElementChild;e;e=e.nextElementSibling)if(e.nodeName===o)return e;return null}var T=t=>Array.from(t.querySelectorAll(":scope > tbody > tr, :scope > tr"));function v(t,o){for(let e=t.parentElement;e&&!e.classList.contains("pagedjs_page_content");e=e.parentElement)if(o.getComputedStyle(e).display.startsWith("inline"))return!0;return!1}function O(t,o){for(let e=t;e&&e!==o;e=e.parentElement)for(let r=e.previousSibling;r;r=r.previousSibling)if(N(r)||(r.textContent??"").trim())return!0;return!1}function P(t){let o=t.cloneNode(!0);for(let e of[o,...Array.from(o.querySelectorAll("[id]"))])e.id&&(e.setAttribute("data-id",e.id),e.removeAttribute("id"));return o.setAttribute("data-ff-repeated",""),o}function k(t,o){for(let e of Array.from(t.querySelectorAll("table > tfoot"))){let r=e.nextElementSibling;for(;r&&r.nodeName!=="TBODY"&&r.nodeName!=="TR";)r=r.nextElementSibling;r&&o.getComputedStyle(e).display==="table-footer-group"&&e.parentNode?.appendChild(e)}}function H(t,o,e){let r=y(t),n=r?.closest("table");if(!r||!n||!n.hasAttribute("data-split-from")||n.hasAttribute("data-ff-head")||(n.setAttribute("data-ff-head",""),b(n,"THEAD")))return;let a=y(o)?.closest("table"),f=a&&b(a,"THEAD");if(!a||!f||v(n,e))return;let l=P(f),d=n.firstChild;for(;d&&(d.nodeName==="CAPTION"||d.nodeName==="COLGROUP");)d=d.nextSibling;if(n.insertBefore(l,d),e.getComputedStyle(l).display!=="table-header-group"){l.remove();return}for(let s=a.firstElementChild;s;s=s.nextElementSibling)s.nodeName==="COLGROUP"&&n.insertBefore(s.cloneNode(!0),l);let i=r.closest("tr"),u=i?.parentElement;i&&u&&u.parentElement===n&&u.nodeName!=="THEAD"&&(i.style.breakInside="auto",i.removeAttribute("data-break-inside"))}function w(t,o,e,r,n){let a=t.startContainer,f=N(a)?a.childNodes[t.startOffset]??a:a,l=y(f);if(!l)return;let d=l.nodeName==="TBODY"?l.querySelector("tr"):l.closest("tr"),i=d?.closest("table"),u=d?.parentElement;if(!d||!i||!u||u.nodeName==="THEAD"||u.nodeName==="TFOOT"||v(i,n))return;let s=T(i),h=s.indexOf(d);if(h<0)return;let m=h,E=0;if(h>0&&(f===d||f===u)){let p=r.querySelector(`[data-ref="${i.getAttribute("data-ref")??""}"]`),g=p&&b(p,"TFOOT");if(g){let c=g.cloneNode(!0);i.appendChild(c),n.getComputedStyle(c).display==="table-footer-group"&&(E=c.getBoundingClientRect().height),c.remove()}let C=Math.round(e),S=c=>!c||Math.floor(c.getBoundingClientRect().bottom)+E<=C;for(;m>0&&!S(s[m-1]);)m--}if(m===0){if(i.hasAttribute("data-split-from")||!b(i,"THEAD"))return;let p=i.previousElementSibling,g=i.getAttribute("data-previous-break-after")==="avoid"&&p?p:i;return O(g,o)?(t.setStartBefore(g),t):void 0}let A=s[m];return m<h&&A&&t.setStartBefore(A),E&&i.setAttribute("data-ff-foot",""),t}function R(t,o){let e=t.querySelector("table[data-ff-foot]");if(!e)return;e.removeAttribute("data-ff-foot");let r=o.querySelector(`[data-ref="${e.getAttribute("data-ref")??""}"]`),n=r&&b(r,"TFOOT");n&&e.appendChild(P(n))}function B(t){let o=t.querySelector(".pagedjs_pagebox");if(!o)return;let e=Array.from(o.children).filter(n=>!(n.getAttribute("class")??"").includes("pagedjs_")&&!n.hasAttribute("data-ff-fixed"));if(!e.length)return;let r=o.ownerDocument.createElement("div");r.setAttribute("data-ff-fixed",""),r.setAttribute("style","grid-column: center; grid-row: page; position: relative; pointer-events: none;");for(let n of e)"style"in n&&(n.style.pointerEvents="auto"),r.appendChild(n);o.appendChild(r)}function x(t){t.formfeedMoveTableFeet=()=>k(t.document,t);let o=t.Paged;if(!o?.Handler)return;class e extends o.Handler{renderNode(n,a){H(n,a,t)}onOverflow(n,a,f){return n?w(n,a,f.bottom,this.chunker.source,t):void 0}afterOverflowRemoved(n,a){R(a,this.chunker.source)}afterPageLayout(n){B(n)}}o.registerHandlers(e)}x(window);})();';
5701
5702
 
5702
5703
  // packages/engine/src/lib/assemble.ts
5703
5704
  var DEFAULT_CHROME_PADDING = "0 10mm";
@@ -5717,7 +5718,12 @@ function defaultSettings() {
5717
5718
  scale: 1,
5718
5719
  preferCssPageSize: false,
5719
5720
  pageRanges: "",
5720
- waitFor: { networkIdle: true, selector: null, timeoutMs: 5e3, delayMs: 0 },
5721
+ waitFor: {
5722
+ networkIdle: "auto",
5723
+ selector: null,
5724
+ timeoutMs: 5e3,
5725
+ delayMs: 0
5726
+ },
5721
5727
  pdf: { tagged: false, outline: false, metadata: { title: "", author: "" } },
5722
5728
  image: {
5723
5729
  width: 1200,
@@ -5792,12 +5798,12 @@ function fontFaceCss(fonts, referencedIn) {
5792
5798
  }).join("\n");
5793
5799
  }
5794
5800
  function chartInitScript() {
5795
- return `<script>window.formfeedDrawCharts=function(){if(typeof Chart==='undefined')return;var all=Chart.instances||{};for(var k in all){if(all[k]&&all[k].canvas&&!all[k].canvas.isConnected){try{all[k].destroy();}catch(e){}}}var cs=document.querySelectorAll('canvas[data-ff-chart]');for(var i=0;i<cs.length;i++){var c=cs[i];try{if(Chart.getChart(c))continue;var s=JSON.parse(c.getAttribute('data-ff-chart')||'{}');new Chart(c.getContext('2d'),s);c.setAttribute('data-ff-chart-ready','1');}catch(e){console.error('formfeed chart',e);}}};if(!window.PagedConfig){window.formfeedDrawCharts();}</script>`;
5801
+ return `<script data-formfeed="charts">window.formfeedDrawCharts=function(){if(typeof Chart==='undefined')return;var all=Chart.instances||{};for(var k in all){if(all[k]&&all[k].canvas&&!all[k].canvas.isConnected){try{all[k].destroy();}catch(e){}}}var cs=document.querySelectorAll('canvas[data-ff-chart]');for(var i=0;i<cs.length;i++){var c=cs[i];try{if(Chart.getChart(c))continue;var s=JSON.parse(c.getAttribute('data-ff-chart')||'{}');new Chart(c.getContext('2d'),s);c.setAttribute('data-ff-chart-ready','1');}catch(e){console.error('formfeed chart',e);}}};if(!window.PagedConfig){window.formfeedDrawCharts();}</script>`;
5796
5802
  }
5797
5803
  function chartScripts(html, vendor) {
5798
5804
  if (!vendor?.chartJs || !html.includes("data-ff-chart"))
5799
5805
  return { head: "", body: "" };
5800
- const lib = "inline" in vendor.chartJs ? `<script>${vendor.chartJs.inline}</script>` : `<script src="${escapeHtml(vendor.chartJs.src)}"></script>`;
5806
+ const lib = "inline" in vendor.chartJs ? `<script data-formfeed="chartjs">${vendor.chartJs.inline}</script>` : `<script data-formfeed="chartjs" src="${escapeHtml(vendor.chartJs.src)}"></script>`;
5801
5807
  return {
5802
5808
  head: `${lib}
5803
5809
  `,
@@ -5826,11 +5832,11 @@ ${brandFontFamilies(input.brand)}`
5826
5832
  const brandStyle = brand ? `<style data-formfeed="brand">${brand}</style>
5827
5833
  ` : "";
5828
5834
  const tailwind = settings.tailwind ? input.extraCss ? `<style data-formfeed="tailwind">${input.extraCss}</style>
5829
- ` : input.vendor?.tailwind ? `<script src="${escapeHtml(input.vendor.tailwind.src)}"></script>
5835
+ ` : input.vendor?.tailwind ? `<script data-formfeed="tailwind" src="${escapeHtml(input.vendor.tailwind.src)}"></script>
5830
5836
  ` : "" : input.extraCss ? `<style data-formfeed="extra">${input.extraCss}</style>
5831
5837
  ` : "";
5832
5838
  const charts = chartScripts(input.html, input.vendor);
5833
- const fit = input.html.includes("data-ff-fit") ? `<script>${fitRuntime.replace(/<\/script/gi, "<\\/script")}</script>
5839
+ const fit = input.html.includes("data-ff-fit") ? `<script data-formfeed="fit">${fitRuntime.replace(/<\/script/gi, "<\\/script")}</script>
5834
5840
  ` : "";
5835
5841
  return `<!doctype html>
5836
5842
  <html lang="${escapeHtml(locale.split("_")[0] ?? locale)}">
@@ -6148,14 +6154,15 @@ html { background: #e5e7eb; }
6148
6154
  `;
6149
6155
  const selectorGuard = `<script>(function(){var q=DocumentFragment.prototype.querySelectorAll;DocumentFragment.prototype.querySelectorAll=function(s){try{return q.call(this,s);}catch(e){console.warn('formfeed paged preview: skipped a selector Paged.js could not use:',s);return q.call(this,':not(*)');}};})();</script>`;
6150
6156
  const boxSizingGuard = `<script>(function(){var rule='.pagedjs_pagebox *';var o=new MutationObserver(function(ms){ms.forEach(function(m){m.addedNodes.forEach(function(n){if(n.nodeName==='STYLE'&&n.textContent&&n.textContent.indexOf(rule)>=0){n.textContent=n.textContent.split(rule).join('.pagedjs_pagebox [class*="pagedjs_"]');o.disconnect();}});});});o.observe(document.documentElement,{childList:true,subtree:true});})();</script>`;
6151
- const config = `<script>window.PagedConfig = { auto: true, after: function (flow) { try { if (window.formfeedDrawCharts) window.formfeedDrawCharts(); } catch (e) {} try { if (window.formfeedFit) window.formfeedFit(); } catch (e) {} try { parent.postMessage({ type: 'formfeed:pages', pages: flow.total }, '*'); } catch (e) {} if (window.formfeedCheckOverflow) window.formfeedCheckOverflow(); if (window.formfeedRunAudit) window.formfeedRunAudit(flow.total); try { if (window.formfeedEditReady) window.formfeedEditReady(); } catch (e) {} } };</script>`;
6157
+ const tables = `<script data-formfeed="paged-print">${pagedPrintRuntime.replace(/<\/script/gi, "<\\/script")}</script>`;
6158
+ const config = `<script>window.PagedConfig = { auto: true, before: function () { try { if (window.formfeedMoveTableFeet) window.formfeedMoveTableFeet(); } catch (e) {} }, after: function (flow) { try { if (window.formfeedDrawCharts) window.formfeedDrawCharts(); } catch (e) {} try { if (window.formfeedFit) window.formfeedFit(); } catch (e) {} try { parent.postMessage({ type: 'formfeed:pages', pages: flow.total }, '*'); } catch (e) {} if (window.formfeedCheckOverflow) window.formfeedCheckOverflow(); if (window.formfeedRunAudit) window.formfeedRunAudit(flow.total); try { if (window.formfeedEditReady) window.formfeedEditReady(); } catch (e) {} } };</script>`;
6152
6159
  const script = `<script src="${options.pagedScriptUrl}"></script>`;
6153
6160
  const header = headerHtml ? `<div class="ff-running-header">${pageNumberSpans(headerHtml, '<span class="ff-page-no"></span>', '<span class="ff-page-total"></span>')}</div>` : "";
6154
6161
  const footer = footerHtml ? `<div class="ff-running-footer">${pageNumberSpans(footerHtml, '<span class="ff-page-no"></span>', '<span class="ff-page-total"></span>')}</div>` : "";
6155
6162
  return intoBody(
6156
6163
  intoHead(
6157
6164
  draft.document,
6158
- `${documentMeta(options)}<style data-formfeed="paged">${runningCss}</style>${selectorGuard}${boxSizingGuard}${overflowScript("paged")}${options.audit ? auditScript("paged") : ""}${config}${script}${options.editing ? textEditScript : ""}${inspectScript}${pageNavScript}${zoomGestureScript}`
6165
+ `${documentMeta(options)}<style data-formfeed="paged">${runningCss}</style>${selectorGuard}${boxSizingGuard}${overflowScript("paged")}${options.audit ? auditScript("paged") : ""}${config}${script}${tables}${options.editing ? textEditScript : ""}${inspectScript}${pageNavScript}${zoomGestureScript}`
6159
6166
  ),
6160
6167
  `${header}${footer}`
6161
6168
  );
package/index.js CHANGED
@@ -303,11 +303,11 @@ var codeHelpers = [
303
303
  aliases: ["epc_qr", "girocode"],
304
304
  doc: {
305
305
  signature: "epcQr({ name, iban, bic?, amount?, reference?, text? }, { size })",
306
- description: "SEPA credit transfer QR code (EPC069-12 / GiroCode) that banking apps scan to prefill a payment. Give the image an `alt`, and print the bank details as text as well: the code is a picture.",
306
+ description: "SEPA credit transfer QR code (EPC069-12 / GiroCode) that banking apps scan to prefill a payment. Put an invoice number into `text` (the remittance line); `reference` is only for a structured creditor reference (RF\u2026). Give the image an `alt`, and print the bank details as text as well: the code is a picture.",
307
307
  examples: {
308
- jinja2: '<img src="{{ epcQr({ name: company.name, iban: company.iban, amount: invoice.total, reference: invoice.number }) }}" alt="QR code to pay invoice {{ invoice.number }}">',
309
- liquid: '<img src="{{ company.iban | epcQr: name: company.name, amount: invoice.total, reference: invoice.number }}" alt="QR code to pay invoice {{ invoice.number }}">',
310
- handlebars: '<img src="{{epcQr name=company.name iban=company.iban amount=invoice.total reference=invoice.number}}" alt="QR code to pay invoice {{invoice.number}}">'
308
+ jinja2: '<img src="{{ epcQr({ name: company.name, iban: company.iban, amount: invoice.total, text: invoice.number }) }}" alt="QR code to pay invoice {{ invoice.number }}">',
309
+ liquid: '<img src="{{ company.iban | epcQr: name: company.name, amount: invoice.total, text: invoice.number }}" alt="QR code to pay invoice {{ invoice.number }}">',
310
+ handlebars: '<img src="{{epcQr name=company.name iban=company.iban amount=invoice.total text=invoice.number}}" alt="QR code to pay invoice {{invoice.number}}">'
311
311
  },
312
312
  category: "code"
313
313
  },
@@ -5478,6 +5478,7 @@ var textEditRuntime = '"use strict";(()=>{var O=`\nhtml.ff-edit-mode [data-ff-ed
5478
5478
  var fitRuntime = '"use strict";(()=>{function a(t,e,n){if(e===t)return t.scrollHeight<=t.clientHeight+.5&&t.scrollWidth<=t.clientWidth+.5;let o=n.getComputedStyle(t),i=t.clientHeight-(parseFloat(o.paddingTop)||0)-(parseFloat(o.paddingBottom)||0);return e.scrollHeight<=i+.5&&e.scrollWidth<=e.clientWidth+.5}function m(t,e){let n=t.firstElementChild??t;n.style.fontSize="";let o=parseFloat(e.getComputedStyle(n).fontSize)||16,i=Math.min(o,parseFloat(t.getAttribute("data-ff-fit-min")??"")||o/2);if(a(t,n,e))return o;let l=i,s=o;for(let d=0;d<14;d++){let r=(l+s)/2;n.style.fontSize=`${r}px`,a(t,n,e)?l=r:s=r}let f=Math.floor(l*100)/100;return n.style.fontSize=`${f}px`,f}function c(t){let e=()=>{for(let o of Array.from(t.document.querySelectorAll(\'[data-ff-fit="shrink"]\')))m(o,t);t.document.documentElement.setAttribute("data-ff-fit","done")};t.formfeedFit=e;let n=t.document.fonts;n?n.ready.then(e):t.addEventListener("load",e)}c(window);})();';
5479
5479
  var stageRuntime = '"use strict";(()=>{var W=`\nhtml.ff-edit-mode [data-ff-edit] { cursor: text; }\nhtml.ff-edit-mode [data-ff-edit]:hover { outline: 1px dashed rgba(37,99,235,.85); outline-offset: 2px; }\nhtml.ff-edit-mode [data-ff-edit="t"]:hover { outline-color: rgba(147,51,234,.9); }\n.ff-editing { outline: 2px solid #2563eb !important; outline-offset: 2px; cursor: text; }\n.ff-editing .ff-chip { background: rgba(37,99,235,.14) !important; box-shadow: inset 0 0 0 1px rgba(37,99,235,.45) !important; border-radius: 3px !important; padding: 0 1px !important; cursor: default; }\n.ff-edit-badge { position: absolute; z-index: 2147483647; font: 500 11px/1.4 system-ui, sans-serif !important; color: #fff !important; background: #2563eb !important; padding: 1px 6px !important; border-radius: 4px !important; pointer-events: none; white-space: nowrap; }\n`;function H(a,l={}){let f=l.clicks!==!1,p=l.live===!0,n=a.document,o=null,d=null,u=e=>{try{a.parent.postMessage(e,"*")}catch{}},m=f?n.querySelector(\'meta[name="formfeed:document"]\')?.getAttribute("content")??null:null,s=!1;a.addEventListener("blur",()=>{s=!0}),a.addEventListener("focus",()=>{s=!1});let g=n.createElement("style");g.setAttribute("data-formfeed","edit"),g.setAttribute("data-pagedjs-ignore",""),g.textContent=W,(n.head??n.documentElement).appendChild(g),f&&n.documentElement.classList.add("ff-edit-mode");let x=e=>(e&&typeof e.closest=="function"?e:null)?.closest("[data-ff-edit]")??null;n.addEventListener("click",e=>{if(!f)return;if(o&&!o.done&&o.element.contains(e.target)){e.stopImmediatePropagation();return}let t=x(e.target);t&&(e.preventDefault(),e.stopImmediatePropagation(),v(t,{x:e.clientX,y:e.clientY}))},!0);function v(e,t){o&&!o.done&&L();let r=e.getAttribute("data-ff-src")??"",i=e.getBoundingClientRect(),b=Array.from(n.querySelectorAll(`[data-ff-src="${r.replace(/"/g,"")}"]`));d={src:r,element:e,point:t},u({type:"formfeed:edit-request",src:r,doc:m,edit:e.getAttribute("data-ff-edit"),text:e.textContent??"",elements:e.childElementCount,count:b.length,index:Math.max(0,b.indexOf(e)),split:e.hasAttribute("data-split-from")||e.hasAttribute("data-split-to"),rect:{left:i.left,top:i.top,width:i.width,height:i.height}})}n.addEventListener("keydown",e=>{if(!f||o&&!o.done||!(e.ctrlKey||e.metaKey)||e.altKey)return;let t=e.key.toLowerCase();(t==="z"||t==="y")&&(e.preventDefault(),u({type:t==="y"||e.shiftKey?"formfeed:redo":"formfeed:undo"}))}),a.addEventListener("message",e=>{if(e.source!==a.parent)return;let t=e.data;!t||typeof t.type!="string"||(t.type==="formfeed:edit-begin"?B(t):t.type==="formfeed:edit-refuse"||t.type==="formfeed:edit-end"?(d=null,o&&!o.done&&S(!1)):t.type==="formfeed:edit-open"&&E(t))});function E(e){if(!f||typeof e.src!="string"||o&&!o.done)return;let t=Array.from(n.querySelectorAll(`[data-ff-src="${e.src.replace(/"/g,"")}"][data-ff-edit]`)),r=Number.isInteger(e.index)?Number(e.index):0,i=t[r]??t[0];i&&v(i,null)}if(f){let e=()=>u({type:"formfeed:edit-ready",doc:m}),t=a;t.PagedConfig?t.formfeedEditReady=e:n.readyState==="loading"?n.addEventListener("DOMContentLoaded",e):e()}function B(e){o&&!o.done&&S(!1);let t=e.layer?n.querySelector(`[data-ff-layer="${String(e.layer).replace(/"/g,"")}"] > .ff-text`):d&&d.src===e.src?d.element:n.querySelector(`[data-ff-src="${String(e.src).replace(/"/g,"")}"]`),r=e.at,i=e.layer?r&&Number.isFinite(r.x)&&Number.isFinite(r.y)?{x:Number(r.x),y:Number(r.y)}:null:d&&d.src===e.src?d.point:null;d=null;let b=s&&!n.hasFocus();if(!t||!Array.isArray(e.items)||b){u({type:"formfeed:edit-cancel",token:String(e.token)});return}let y=Array.from(t.childNodes),k=n.createDocumentFragment();for(let c of e.items)if(c.kind==="text")k.appendChild(n.createTextNode(String(c.text)));else if(c.kind==="break")k.appendChild(n.createElement("br"));else if(c.kind==="chip"){let h=n.createElement("span");h.className="ff-chip",h.setAttribute("data-ff-chip",String(c.index)),h.setAttribute("contenteditable","false"),c.title&&(h.title=String(c.title)),h.textContent=String(c.text),k.appendChild(h)}for(let c of y)t.removeChild(c);t.appendChild(k),t.contentEditable="true",t.classList.add("ff-editing"),t.setAttribute("role","textbox"),e.label&&t.setAttribute("aria-label",String(e.label)),t.spellcheck=!0,o={token:String(e.token),element:t,saved:y,allowBreaks:e.allowBreaks===!0,badge:e.note?I(t,String(e.note)):null,done:!1},t.addEventListener("keydown",T),t.addEventListener("beforeinput",N),t.addEventListener("paste",w),t.addEventListener("drop",R),t.addEventListener("focusout",F),p&&t.addEventListener("input",C),t.focus(),e.select==="all"?q(t):K(t,i),u({type:"formfeed:edit-started",token:o.token}),typeof e.insert=="string"&&e.insert&&A(e.insert.replace(/\\r\\n?|\\n/g," "))}function A(e){if(typeof n.execCommand=="function"&&n.execCommand("insertText",!1,e))return;let t=a.getSelection(),r=t&&t.rangeCount?t.getRangeAt(0):null;r&&(r.deleteContents(),r.insertNode(n.createTextNode(e)),r.collapse(!1),p&&C())}function C(){o&&!o.done&&u({type:"formfeed:edit-input",token:o.token,items:D(o.element)})}function I(e,t){let r=n.createElement("div");r.className="ff-edit-badge",r.textContent=t;let i=e.getBoundingClientRect();return r.style.left=`${i.left+a.scrollX}px`,r.style.top=`${Math.max(0,i.top+a.scrollY-22)}px`,n.body.appendChild(r),r}function q(e){let t=a.getSelection();if(!t)return;let r=n.createRange();r.selectNodeContents(e),t.removeAllRanges(),t.addRange(r)}function K(e,t){let r=a.getSelection();if(!r)return;let i=null,b=n;if(t){if(b.caretRangeFromPoint)i=b.caretRangeFromPoint(t.x,t.y);else if(b.caretPositionFromPoint){let y=b.caretPositionFromPoint(t.x,t.y);y&&(i=n.createRange(),i.setStart(y.offsetNode,y.offset))}}if(!i||!e.contains(i.startContainer))i=n.createRange(),i.selectNodeContents(e),i.collapse(!1);else if(t){let y=i.startContainer,c=(y.nodeType===1?y:y.parentElement)?.closest("[data-ff-chip]")??null;if(c&&c!==e&&e.contains(c)){let h=c.getBoundingClientRect();i=n.createRange(),t.x<h.left+h.width/2?i.setStartBefore(c):i.setStartAfter(c),i.collapse(!0)}}r.removeAllRanges(),r.addRange(i)}function T(e){let t=e.key;t==="Escape"?(e.preventDefault(),S(!0)):t==="Enter"&&!e.shiftKey?(e.preventDefault(),L()):t==="Enter"?(e.preventDefault(),o?.allowBreaks&&$()):t==="Tab"?(e.preventDefault(),L()):(e.ctrlKey||e.metaKey)&&["b","i","u"].includes(t.toLowerCase())&&(e.preventDefault(),p&&o&&!e.altKey&&u({type:"formfeed:edit-style",token:o.token,key:t.toLowerCase()}))}function N(e){let t=e.inputType??"";(t.startsWith("format")||t==="insertFromDrop"||t==="insertParagraph"||t==="insertLineBreak")&&e.preventDefault()}function w(e){e.preventDefault(),A((e.clipboardData?.getData("text/plain")??"").replace(/\\r\\n?|\\n/g," "))}function R(e){e.preventDefault()}function F(){a.setTimeout(()=>{o&&!o.done&&(!n.hasFocus()||!o.element.contains(n.activeElement))&&L()},0)}function $(){let e=a.getSelection();if(!e||!e.rangeCount)return;let t=e.getRangeAt(0);t.deleteContents();let r=n.createElement("br");t.insertNode(r),r.nextSibling||r.parentNode?.appendChild(n.createElement("br"));let i=n.createRange();i.setStartAfter(r),i.collapse(!0),e.removeAllRanges(),e.addRange(i)}function M(e){e.done=!0;let t=e.element;t.removeEventListener("keydown",T),t.removeEventListener("beforeinput",N),t.removeEventListener("paste",w),t.removeEventListener("drop",R),t.removeEventListener("focusout",F),t.removeEventListener("input",C),t.removeAttribute("contenteditable"),t.removeAttribute("role"),t.removeAttribute("aria-label"),t.classList.remove("ff-editing"),e.badge?.remove(),o===e&&(o=null)}function L(){let e=o;if(!e||e.done)return;let t=D(e.element);M(e),u({type:"formfeed:edit-commit",token:e.token,items:t})}function S(e){let t=o;if(!t||t.done)return;let r=t.element;for(;r.firstChild;)r.removeChild(r.firstChild);for(let i of t.saved)r.appendChild(i);M(t),e&&u({type:"formfeed:edit-cancel",token:t.token})}}function D(a){let l=[],f=n=>{let o=l[l.length-1];o?.kind==="text"?o.text+=n:n&&l.push({kind:"text",text:n})},p=n=>{for(let o of Array.from(n.childNodes))if(o.nodeType===3)f(o.data);else if(o.nodeType===1){let d=o,u=d.getAttribute("data-ff-chip");u!==null?l.push({kind:"chip",index:Number(u)}):d.tagName==="BR"?l.push({kind:"break"}):((d.tagName==="DIV"||d.tagName==="P")&&l.length&&l.push({kind:"break"}),p(d))}};for(p(a);l[l.length-1]?.kind==="break";)l.pop();return l}function O(a,l){return Array.from(a.querySelectorAll("[data-ff-layer]")).map(f=>{let p=f.querySelector(":scope > .ff-text"),n=!1;if(p&&f.style.height!=="auto"){let o=l.getComputedStyle(f),d=f.clientHeight-(parseFloat(o.paddingTop)||0)-(parseFloat(o.paddingBottom)||0);n=o.overflow==="hidden"&&(p.scrollHeight>d+1||p.scrollWidth>p.clientWidth+1)}return{id:f.getAttribute("data-ff-layer")??"",width:f.offsetWidth,height:f.offsetHeight,overflow:n}})}function P(a){let l=a.document,f=m=>{try{a.parent.postMessage(m,"*")}catch{}},p=m=>typeof m=="string"?l.querySelector(`[data-ff-layer="${m.replace(/"/g,"")}"]`):null,n=()=>{for(let m of Array.from(l.querySelectorAll("[data-ff-layer]")))for(let s of["left","top","width","height","transform"])m.style.removeProperty(s)},o=()=>{a.formfeedFit?.(),f({type:"formfeed:ready",layers:O(l,a)})};a.addEventListener("message",m=>{if(m.source!==a.parent)return;let s=m.data;if(!(!s||typeof s.type!="string")){if(s.type==="formfeed:layer-style"){let g=p(s.id);if(!g)return;let x=(v,E)=>{typeof E=="number"&&Number.isFinite(E)&&g.style.setProperty(v,`${E}px`)};x("left",s.left),x("top",s.top),x("width",s.width),x("height",s.height),typeof s.rotation=="number"&&Number.isFinite(s.rotation)&&g.style.setProperty("transform",s.rotation?`rotate(${s.rotation}deg)`:"none")}else if(s.type==="formfeed:layer-style-clear")n();else if(s.type==="formfeed:css"&&typeof s.css=="string"){let g=l.querySelector(\'style[data-formfeed="template"]\');g&&(g.textContent=s.css),n(),o()}}}),H(a,{clicks:!1,live:!0});let d=l.fonts,u=()=>d?void d.ready.then(o):o();l.readyState==="complete"?u():a.addEventListener("load",u)}P(window);})();';
5480
5480
  var auditRuntime = '"use strict";(()=>{var I={"document-title":"error","image-alt":"error","figure-name":"error","heading-order":"error","table-rows":"error","table-cell-empty":"error","masked-text":"error","filtered-text":"warning","document-language":"warning","table-headers":"warning","link-name":"warning","generated-text":"warning","fixed-text":"warning","running-text":"warning"};var S=120;var O=".formfeed-chrome, .ff-running-header, .ff-running-footer",_=".pageNumber, .totalPages, .date, .title, .url, .ff-page-no, .ff-page-total",k=new Set(["script","style","template","noscript","head"]),j=2e4,q=10,B=new Set(["page","pages","of","seite","seiten","von","p","s"]),u=t=>(t??"").replace(/\\s+/g," ").trim(),D=t=>t.replace(/\\s+/g,"").toLowerCase(),$=t=>/[\\p{L}\\p{N}]/u.test(t),Y=/^data-(ref|id|split-(from|to|original)|(previous-|next-)?break-(before|after|inside)|(align-)?last-split-element|nth-of-type|counter-.+|page(-number)?|undisplayed|after-page|following|has-notes|children|item-num)$/;function X(t){let n=t.cloneNode(!1);n.removeAttribute("data-ff-src"),n.removeAttribute("data-ff-edit");let i=t.closest(".pagedjs_page")!==null;for(let s of Array.from(n.attributes))i&&Y.test(s.name)?n.removeAttribute(s.name):s.value.length>48&&n.setAttribute(s.name,`${s.value.slice(0,40)}\\u2026`);let o=n.outerHTML.replace(new RegExp(`</${t.tagName}>$`,"i"),"");return o.length>S?`${o.slice(0,S-1)}\\u2026`:o}function F(t,n={}){let i=t.document,o=i.body,s=[],d=new Set,a=n.findings!==!1,c=(e,r,l={})=>{if(!a)return;let m=r?.closest("[data-ff-src]")?.getAttribute("data-ff-src")??null,h=r?X(r):"",g=`${e}|${m??h}|${JSON.stringify(l)}`;d.has(g)||(d.add(g),s.push({code:e,severity:I[e],src:m,snippet:h,args:l}))},f=new WeakMap,A=e=>{let r=f.get(e);if(r!==void 0)return r;let l=t.getComputedStyle(e),m=l.display==="none"||l.visibility==="hidden"||l.visibility==="collapse"||e.parentElement!==null&&e.parentElement!==i.documentElement&&A(e.parentElement);return f.set(e,m),m},p=e=>e.closest(\'[aria-hidden="true"]\')!==null,E=e=>/^(presentation|none)$/.test(e.getAttribute("role")??""),H=e=>e.closest(O)!==null,y=e=>$(e.textContent??""),x=e=>{let r=u(e.getAttribute("aria-label"));return r||u((e.getAttribute("aria-labelledby")??"").split(/\\s+/).filter(Boolean).map(l=>e.ownerDocument.getElementById(l)?.textContent??"").join(" "))},P=e=>x(e)||u(e.textContent)||u(Array.from(e.querySelectorAll("img[alt]")).map(r=>r.getAttribute("alt")).join(" "))||u(e.getAttribute("title")),T=e=>{let r=e.getAttribute("href")??"";return{href:r.startsWith("#")?r:e.href??r,name:P(e)}};u(i.title)||c("document-title",null),!u(i.documentElement.getAttribute("lang"))&&!n.locale&&c("document-language",null);let M=n.pages??(n.pageHeight&&n.pageHeight>0?Math.ceil(i.documentElement.scrollHeight/n.pageHeight):1),C=[],v=[],R={"masked-text":[],"filtered-text":[],"fixed-text":[]},w=(e,r)=>{R[e].some(l=>l.contains(r))||(R[e].push(r),c(e,r))},V=a&&ne(i),G=o?Array.from(o.querySelectorAll("*")).slice(0,j):[];for(let e of G){let r=e.tagName.toLowerCase();if(k.has(r)||H(e)||A(e))continue;if(r==="a"&&e.hasAttribute("href")){let g=T(e);C.push(g),!g.name&&!p(e)&&c("link-name",e)}if(!a)continue;let l=t.getComputedStyle(e),m=l.getPropertyValue("mask-image")||l.getPropertyValue("-webkit-mask-image");if(m&&m!=="none"&&y(e)&&w("masked-text",e),l.filter&&l.filter!=="none"&&y(e)&&w("filtered-text",e),l.position==="fixed"&&M>1&&y(e)&&w("fixed-text",e),V)for(let g of["::before","::after"]){let U=re(t.getComputedStyle(e,g).content);U&&c("generated-text",e,{text:U})}if(p(e))continue;r==="img"&&!E(e)?e.hasAttribute("alt")||x(e)||u(e.getAttribute("title"))||c("image-alt",e):(r==="canvas"||e.getAttribute("role")==="img"&&r!=="img")&&(x(e)||u(e.getAttribute("title"))||u(e.querySelector(":scope > title")?.textContent)||c("figure-name",e,{tag:r}));let h=/^h[1-6]$/.test(r)?Number(r[1]):e.getAttribute("role")==="heading"?Number(e.getAttribute("aria-level"))||2:0;h&&v.push({element:e,level:h}),r==="table"&&!E(e)&&Q(e,c)}let b=0;for(let{element:e,level:r}of v)(b===0?r!==1:r>b+1)&&c("heading-order",e,{level:r,previous:b}),b=r;let N=[],W=a&&o?D(J(o)):"",L=0;for(let e of["header","footer"])for(let r of z(i,e,n[e])){for(let l of Array.from(r.querySelectorAll("a[href]")))N.push(T(l));if(a)for(let{text:l,element:m}of K(r)){if(L>=q||W.includes(D(l)))continue;let h=s.length;c("running-text",m,{text:l.slice(0,80),part:e}),s.length>h&&L++}}return{findings:s,links:C,templateLinks:N}}function z(t,n,i){if(i!==void 0){if(!i.trim())return[];let o=new DOMParser().parseFromString(`<!doctype html><body>${i}</body>`,"text/html");return o.body?[o.body]:[]}return Array.from(t.querySelectorAll(`.ff-running-${n}, .formfeed-chrome[data-ff-chrome="${n}"]`))}function J(t){let n=[],i=o=>{if(o.nodeType===3){n.push(o.nodeValue??"");return}if(o.nodeType!==1)return;let s=o;if(!(k.has(s.tagName.toLowerCase())||s.matches(O)))for(let d of Array.from(o.childNodes))i(d)};return i(t),n.join(" ")}function K(t){let n=[],i=o=>{let s=o.tagName.toLowerCase();if(k.has(s)||o.matches(_))return;let d=Array.from(o.children).some(a=>a.matches(_));for(let a of Array.from(o.childNodes))if(a.nodeType===1)i(a);else if(a.nodeType===3&&!d)for(let c of(a.nodeValue??"").split(/\\s*[\xB7\u2022|]\\s*|\\s{2,}|\\n/)){let f=u(c);(f.toLowerCase().match(/[\\p{L}\\p{N}]+/gu)??[]).some(p=>!B.has(p))&&n.push({text:f,element:o})}};return i(t),n}function Q(t,n){let i=Array.from(t.rows);if(!(t.querySelector(\'th, [role="columnheader"], [role="rowheader"]\')!==null)){i.length>=2&&n("table-headers",t);return}let s=te(i),d=s.find(c=>c!==s[0]);d!==void 0&&n("table-rows",t,{first:s[0]??0,other:d});let a=i.flatMap(c=>Array.from(c.cells).filter(f=>f.tagName==="TD"&&ee(f)));a[0]&&n("table-cell-empty",a[0],{count:a.length})}var Z=\'img[alt]:not([alt=""]), svg, canvas, input, select, textarea, button, meter, progress\';function ee(t){return!/[^ \\t\\n\\r\\f]/.test(t.textContent??"")&&t.querySelector(Z)===null}function te(t){let n=[];return t.map(i=>{let o=[],s=0,d=()=>{for(;(n[s]??0)>0;)o[s]=n[s]-1,s++};for(let a of Array.from(i.cells)){d();let c=Math.max(1,a.rowSpan||1)-1;for(let f=Math.max(1,a.colSpan||1);f>0;f--)o[s++]=c}d();for(let a=s;a<n.length;a++)(n[a]??0)>0&&(o[a]=n[a]-1,s=a+1);return n=o,s})}function ne(t){let n=i=>{for(let o of Array.from(i??[])){let s=o;if(s.selectorText&&/::?(before|after)/.test(s.selectorText)&&s.style?.content||o.cssRules&&n(o.cssRules))return!0}return!1};for(let i of Array.from(t.styleSheets))try{if(n(i.cssRules))return!0}catch{return!0}return!1}function re(t){if(!t||t==="none"||t==="normal")return"";let n=(t.match(/"(?:[^"\\\\]|\\\\.)*"/g)??[]).map(o=>o.slice(1,-1).replace(/\\\\(.)/g,"$1"));if(/\\bcounters?\\(/.test(t))return u(t).slice(0,80);let i=u(n.join(""));return $(i)?i.slice(0,80):""}window.formfeedAudit=t=>F(window,t);})();';
5481
+ var pagedPrintRuntime = '"use strict";(()=>{var N=t=>!!t&&t.nodeType===1,y=t=>N(t)?t:t?.parentElement??null;function b(t,o){for(let e=t.firstElementChild;e;e=e.nextElementSibling)if(e.nodeName===o)return e;return null}var T=t=>Array.from(t.querySelectorAll(":scope > tbody > tr, :scope > tr"));function v(t,o){for(let e=t.parentElement;e&&!e.classList.contains("pagedjs_page_content");e=e.parentElement)if(o.getComputedStyle(e).display.startsWith("inline"))return!0;return!1}function O(t,o){for(let e=t;e&&e!==o;e=e.parentElement)for(let r=e.previousSibling;r;r=r.previousSibling)if(N(r)||(r.textContent??"").trim())return!0;return!1}function P(t){let o=t.cloneNode(!0);for(let e of[o,...Array.from(o.querySelectorAll("[id]"))])e.id&&(e.setAttribute("data-id",e.id),e.removeAttribute("id"));return o.setAttribute("data-ff-repeated",""),o}function k(t,o){for(let e of Array.from(t.querySelectorAll("table > tfoot"))){let r=e.nextElementSibling;for(;r&&r.nodeName!=="TBODY"&&r.nodeName!=="TR";)r=r.nextElementSibling;r&&o.getComputedStyle(e).display==="table-footer-group"&&e.parentNode?.appendChild(e)}}function H(t,o,e){let r=y(t),n=r?.closest("table");if(!r||!n||!n.hasAttribute("data-split-from")||n.hasAttribute("data-ff-head")||(n.setAttribute("data-ff-head",""),b(n,"THEAD")))return;let a=y(o)?.closest("table"),f=a&&b(a,"THEAD");if(!a||!f||v(n,e))return;let l=P(f),d=n.firstChild;for(;d&&(d.nodeName==="CAPTION"||d.nodeName==="COLGROUP");)d=d.nextSibling;if(n.insertBefore(l,d),e.getComputedStyle(l).display!=="table-header-group"){l.remove();return}for(let s=a.firstElementChild;s;s=s.nextElementSibling)s.nodeName==="COLGROUP"&&n.insertBefore(s.cloneNode(!0),l);let i=r.closest("tr"),u=i?.parentElement;i&&u&&u.parentElement===n&&u.nodeName!=="THEAD"&&(i.style.breakInside="auto",i.removeAttribute("data-break-inside"))}function w(t,o,e,r,n){let a=t.startContainer,f=N(a)?a.childNodes[t.startOffset]??a:a,l=y(f);if(!l)return;let d=l.nodeName==="TBODY"?l.querySelector("tr"):l.closest("tr"),i=d?.closest("table"),u=d?.parentElement;if(!d||!i||!u||u.nodeName==="THEAD"||u.nodeName==="TFOOT"||v(i,n))return;let s=T(i),h=s.indexOf(d);if(h<0)return;let m=h,E=0;if(h>0&&(f===d||f===u)){let p=r.querySelector(`[data-ref="${i.getAttribute("data-ref")??""}"]`),g=p&&b(p,"TFOOT");if(g){let c=g.cloneNode(!0);i.appendChild(c),n.getComputedStyle(c).display==="table-footer-group"&&(E=c.getBoundingClientRect().height),c.remove()}let C=Math.round(e),S=c=>!c||Math.floor(c.getBoundingClientRect().bottom)+E<=C;for(;m>0&&!S(s[m-1]);)m--}if(m===0){if(i.hasAttribute("data-split-from")||!b(i,"THEAD"))return;let p=i.previousElementSibling,g=i.getAttribute("data-previous-break-after")==="avoid"&&p?p:i;return O(g,o)?(t.setStartBefore(g),t):void 0}let A=s[m];return m<h&&A&&t.setStartBefore(A),E&&i.setAttribute("data-ff-foot",""),t}function R(t,o){let e=t.querySelector("table[data-ff-foot]");if(!e)return;e.removeAttribute("data-ff-foot");let r=o.querySelector(`[data-ref="${e.getAttribute("data-ref")??""}"]`),n=r&&b(r,"TFOOT");n&&e.appendChild(P(n))}function B(t){let o=t.querySelector(".pagedjs_pagebox");if(!o)return;let e=Array.from(o.children).filter(n=>!(n.getAttribute("class")??"").includes("pagedjs_")&&!n.hasAttribute("data-ff-fixed"));if(!e.length)return;let r=o.ownerDocument.createElement("div");r.setAttribute("data-ff-fixed",""),r.setAttribute("style","grid-column: center; grid-row: page; position: relative; pointer-events: none;");for(let n of e)"style"in n&&(n.style.pointerEvents="auto"),r.appendChild(n);o.appendChild(r)}function x(t){t.formfeedMoveTableFeet=()=>k(t.document,t);let o=t.Paged;if(!o?.Handler)return;class e extends o.Handler{renderNode(n,a){H(n,a,t)}onOverflow(n,a,f){return n?w(n,a,f.bottom,this.chunker.source,t):void 0}afterOverflowRemoved(n,a){R(a,this.chunker.source)}afterPageLayout(n){B(n)}}o.registerHandlers(e)}x(window);})();';
5481
5482
 
5482
5483
  // packages/engine/src/lib/assemble.ts
5483
5484
  var DEFAULT_CHROME_PADDING = "0 10mm";
@@ -5497,7 +5498,12 @@ function defaultSettings() {
5497
5498
  scale: 1,
5498
5499
  preferCssPageSize: false,
5499
5500
  pageRanges: "",
5500
- waitFor: { networkIdle: true, selector: null, timeoutMs: 5e3, delayMs: 0 },
5501
+ waitFor: {
5502
+ networkIdle: "auto",
5503
+ selector: null,
5504
+ timeoutMs: 5e3,
5505
+ delayMs: 0
5506
+ },
5501
5507
  pdf: { tagged: false, outline: false, metadata: { title: "", author: "" } },
5502
5508
  image: {
5503
5509
  width: 1200,
@@ -5572,12 +5578,12 @@ function fontFaceCss(fonts, referencedIn) {
5572
5578
  }).join("\n");
5573
5579
  }
5574
5580
  function chartInitScript() {
5575
- return `<script>window.formfeedDrawCharts=function(){if(typeof Chart==='undefined')return;var all=Chart.instances||{};for(var k in all){if(all[k]&&all[k].canvas&&!all[k].canvas.isConnected){try{all[k].destroy();}catch(e){}}}var cs=document.querySelectorAll('canvas[data-ff-chart]');for(var i=0;i<cs.length;i++){var c=cs[i];try{if(Chart.getChart(c))continue;var s=JSON.parse(c.getAttribute('data-ff-chart')||'{}');new Chart(c.getContext('2d'),s);c.setAttribute('data-ff-chart-ready','1');}catch(e){console.error('formfeed chart',e);}}};if(!window.PagedConfig){window.formfeedDrawCharts();}</script>`;
5581
+ return `<script data-formfeed="charts">window.formfeedDrawCharts=function(){if(typeof Chart==='undefined')return;var all=Chart.instances||{};for(var k in all){if(all[k]&&all[k].canvas&&!all[k].canvas.isConnected){try{all[k].destroy();}catch(e){}}}var cs=document.querySelectorAll('canvas[data-ff-chart]');for(var i=0;i<cs.length;i++){var c=cs[i];try{if(Chart.getChart(c))continue;var s=JSON.parse(c.getAttribute('data-ff-chart')||'{}');new Chart(c.getContext('2d'),s);c.setAttribute('data-ff-chart-ready','1');}catch(e){console.error('formfeed chart',e);}}};if(!window.PagedConfig){window.formfeedDrawCharts();}</script>`;
5576
5582
  }
5577
5583
  function chartScripts(html, vendor) {
5578
5584
  if (!vendor?.chartJs || !html.includes("data-ff-chart"))
5579
5585
  return { head: "", body: "" };
5580
- const lib = "inline" in vendor.chartJs ? `<script>${vendor.chartJs.inline}</script>` : `<script src="${escapeHtml(vendor.chartJs.src)}"></script>`;
5586
+ const lib = "inline" in vendor.chartJs ? `<script data-formfeed="chartjs">${vendor.chartJs.inline}</script>` : `<script data-formfeed="chartjs" src="${escapeHtml(vendor.chartJs.src)}"></script>`;
5581
5587
  return {
5582
5588
  head: `${lib}
5583
5589
  `,
@@ -5606,11 +5612,11 @@ ${brandFontFamilies(input.brand)}`
5606
5612
  const brandStyle = brand ? `<style data-formfeed="brand">${brand}</style>
5607
5613
  ` : "";
5608
5614
  const tailwind = settings.tailwind ? input.extraCss ? `<style data-formfeed="tailwind">${input.extraCss}</style>
5609
- ` : input.vendor?.tailwind ? `<script src="${escapeHtml(input.vendor.tailwind.src)}"></script>
5615
+ ` : input.vendor?.tailwind ? `<script data-formfeed="tailwind" src="${escapeHtml(input.vendor.tailwind.src)}"></script>
5610
5616
  ` : "" : input.extraCss ? `<style data-formfeed="extra">${input.extraCss}</style>
5611
5617
  ` : "";
5612
5618
  const charts = chartScripts(input.html, input.vendor);
5613
- const fit = input.html.includes("data-ff-fit") ? `<script>${fitRuntime.replace(/<\/script/gi, "<\\/script")}</script>
5619
+ const fit = input.html.includes("data-ff-fit") ? `<script data-formfeed="fit">${fitRuntime.replace(/<\/script/gi, "<\\/script")}</script>
5614
5620
  ` : "";
5615
5621
  return `<!doctype html>
5616
5622
  <html lang="${escapeHtml(locale.split("_")[0] ?? locale)}">
@@ -5928,14 +5934,15 @@ html { background: #e5e7eb; }
5928
5934
  `;
5929
5935
  const selectorGuard = `<script>(function(){var q=DocumentFragment.prototype.querySelectorAll;DocumentFragment.prototype.querySelectorAll=function(s){try{return q.call(this,s);}catch(e){console.warn('formfeed paged preview: skipped a selector Paged.js could not use:',s);return q.call(this,':not(*)');}};})();</script>`;
5930
5936
  const boxSizingGuard = `<script>(function(){var rule='.pagedjs_pagebox *';var o=new MutationObserver(function(ms){ms.forEach(function(m){m.addedNodes.forEach(function(n){if(n.nodeName==='STYLE'&&n.textContent&&n.textContent.indexOf(rule)>=0){n.textContent=n.textContent.split(rule).join('.pagedjs_pagebox [class*="pagedjs_"]');o.disconnect();}});});});o.observe(document.documentElement,{childList:true,subtree:true});})();</script>`;
5931
- const config = `<script>window.PagedConfig = { auto: true, after: function (flow) { try { if (window.formfeedDrawCharts) window.formfeedDrawCharts(); } catch (e) {} try { if (window.formfeedFit) window.formfeedFit(); } catch (e) {} try { parent.postMessage({ type: 'formfeed:pages', pages: flow.total }, '*'); } catch (e) {} if (window.formfeedCheckOverflow) window.formfeedCheckOverflow(); if (window.formfeedRunAudit) window.formfeedRunAudit(flow.total); try { if (window.formfeedEditReady) window.formfeedEditReady(); } catch (e) {} } };</script>`;
5937
+ const tables = `<script data-formfeed="paged-print">${pagedPrintRuntime.replace(/<\/script/gi, "<\\/script")}</script>`;
5938
+ const config = `<script>window.PagedConfig = { auto: true, before: function () { try { if (window.formfeedMoveTableFeet) window.formfeedMoveTableFeet(); } catch (e) {} }, after: function (flow) { try { if (window.formfeedDrawCharts) window.formfeedDrawCharts(); } catch (e) {} try { if (window.formfeedFit) window.formfeedFit(); } catch (e) {} try { parent.postMessage({ type: 'formfeed:pages', pages: flow.total }, '*'); } catch (e) {} if (window.formfeedCheckOverflow) window.formfeedCheckOverflow(); if (window.formfeedRunAudit) window.formfeedRunAudit(flow.total); try { if (window.formfeedEditReady) window.formfeedEditReady(); } catch (e) {} } };</script>`;
5932
5939
  const script = `<script src="${options.pagedScriptUrl}"></script>`;
5933
5940
  const header = headerHtml ? `<div class="ff-running-header">${pageNumberSpans(headerHtml, '<span class="ff-page-no"></span>', '<span class="ff-page-total"></span>')}</div>` : "";
5934
5941
  const footer = footerHtml ? `<div class="ff-running-footer">${pageNumberSpans(footerHtml, '<span class="ff-page-no"></span>', '<span class="ff-page-total"></span>')}</div>` : "";
5935
5942
  return intoBody(
5936
5943
  intoHead(
5937
5944
  draft.document,
5938
- `${documentMeta(options)}<style data-formfeed="paged">${runningCss}</style>${selectorGuard}${boxSizingGuard}${overflowScript("paged")}${options.audit ? auditScript("paged") : ""}${config}${script}${options.editing ? textEditScript : ""}${inspectScript}${pageNavScript}${zoomGestureScript}`
5945
+ `${documentMeta(options)}<style data-formfeed="paged">${runningCss}</style>${selectorGuard}${boxSizingGuard}${overflowScript("paged")}${options.audit ? auditScript("paged") : ""}${config}${script}${tables}${options.editing ? textEditScript : ""}${inspectScript}${pageNavScript}${zoomGestureScript}`
5939
5946
  ),
5940
5947
  `${header}${footer}`
5941
5948
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formfeed/engine",
3
- "version": "0.3.17",
3
+ "version": "0.3.18",
4
4
  "description": "The Formfeed template engine (Jinja2, Liquid, Handlebars) for the browser and Node.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -0,0 +1,66 @@
1
+ /**
2
+ * What Chromium's print does that Paged.js does not, for the paged preview (the editor's and
3
+ * `formfeed dev`'s). Paged.js lays a page out in CSS columns, treats what reaches the second column
4
+ * as the next page's, and rebuilds a table that goes on to the next page from its body alone.
5
+ * Chromium repeats a table's head at the top of every page the table reaches and its footer group at
6
+ * the foot of every page it goes on from, and keeps room for both. Without that, page 2 of an invoice
7
+ * had no header row, its rows drifted by one a page, and at 120 lines the preview had five pages where
8
+ * the PDF had six. And a `position: fixed` footer stood in the page's margin, where Chromium puts it
9
+ * over the last row of a full page.
10
+ *
11
+ * Measured on 2026-10-18 against the PDFs of the blog post `page-breaks-in-tables` (21 tables, Paged.js
12
+ * 0.4.3): Paged.js alone laid out 2 of them as the PDF does, with this runtime all 21. The render-worker's
13
+ * `paged-preview.spec.ts` holds the preview to those PDFs.
14
+ *
15
+ * `pagedDocument` adds it after Paged.js's script; its `PagedConfig.before` calls
16
+ * `formfeedMoveTableFeet` while the document is still the one the template wrote. Bundled by
17
+ * `engine:frames`; keep it self-contained.
18
+ */
19
+ /** The part of Paged.js this runtime uses (`window.Paged`, a UMD global of the polyfill). */
20
+ interface PagedChunker {
21
+ source: ParentNode;
22
+ }
23
+ interface PagedGlobal {
24
+ Handler: new (chunker: PagedChunker, polisher: unknown, caller: unknown) => {
25
+ chunker: PagedChunker;
26
+ };
27
+ registerHandlers: (...handlers: unknown[]) => void;
28
+ }
29
+ type PagedWindow = Window & {
30
+ Paged?: PagedGlobal;
31
+ formfeedMoveTableFeet?: () => void;
32
+ };
33
+ /**
34
+ * HTML lets a `tfoot` stand before the `tbody`. Chromium draws a footer group at the table's foot
35
+ * wherever it stands; Paged.js lays it out where it stands and then laid the first page's rows out
36
+ * twice. Moved to the end of its table it draws the same, before Paged.js takes the document. A
37
+ * `tfoot` the template made a row group stays where it is, because that one prints where it stands.
38
+ */
39
+ export declare function moveTableFeet(doc: Document, win: Window): void;
40
+ /**
41
+ * Paged.js's `renderNode` hook: the first node placed on a page in a table that goes on from the page
42
+ * before gets the table's head in front of it, as Chromium prints it. The row it is in is at the top
43
+ * of its page then, so a row taller than what is left may break there (Chromium's view), instead of
44
+ * moving on to the next page and the next with `tr { break-inside: avoid }`.
45
+ */
46
+ export declare function repeatHead(clone: Node, node: Node, win: Window): void;
47
+ /**
48
+ * Paged.js's `onOverflow` hook, where the page's last content is settled: a table row that does not
49
+ * fit moves on, also one a wrapper with `overflow` clips at the page's foot, which Paged.js would
50
+ * keep; a table with a footer group keeps room for its copy (`data-ff-foot`, filled in by
51
+ * `repeatFoot`); and a head with no row under it at the foot of a page moves on with its table, and a
52
+ * heading kept to that by `break-after: avoid` with both. Returns the range, changed or not.
53
+ */
54
+ export declare function settleTable(overflow: Range, rendered: Node, bottom: number, source: ParentNode, win: Window): Range | undefined;
55
+ /** Paged.js's `afterOverflowRemoved` hook: the footer group's copy at the foot of the page `settleTable` kept room on. */
56
+ export declare function repeatFoot(rendered: ParentNode, source: ParentNode): void;
57
+ /**
58
+ * Paged.js's `afterPageLayout` hook. Paged.js puts a copy of every `position: fixed` element on every
59
+ * page, as Chromium prints it, but measures it from the whole sheet: a footer with `bottom: 0` stood in
60
+ * the bottom margin. Chromium measures it from the page area inside the margins, where it covers the
61
+ * last row of a full page (the post's `fixed-footer` case). The copies move into a layer laid over
62
+ * that area; clicks go through the layer to the page, and still reach the copies.
63
+ */
64
+ export declare function anchorFixed(pageElement: Element): void;
65
+ export declare function installPagedPrint(win: PagedWindow): void;
66
+ export {};
@@ -0,0 +1,66 @@
1
+ /**
2
+ * What Chromium's print does that Paged.js does not, for the paged preview (the editor's and
3
+ * `formfeed dev`'s). Paged.js lays a page out in CSS columns, treats what reaches the second column
4
+ * as the next page's, and rebuilds a table that goes on to the next page from its body alone.
5
+ * Chromium repeats a table's head at the top of every page the table reaches and its footer group at
6
+ * the foot of every page it goes on from, and keeps room for both. Without that, page 2 of an invoice
7
+ * had no header row, its rows drifted by one a page, and at 120 lines the preview had five pages where
8
+ * the PDF had six. And a `position: fixed` footer stood in the page's margin, where Chromium puts it
9
+ * over the last row of a full page.
10
+ *
11
+ * Measured on 2026-10-18 against the PDFs of the blog post `page-breaks-in-tables` (21 tables, Paged.js
12
+ * 0.4.3): Paged.js alone laid out 2 of them as the PDF does, with this runtime all 21. The render-worker's
13
+ * `paged-preview.spec.ts` holds the preview to those PDFs.
14
+ *
15
+ * `pagedDocument` adds it after Paged.js's script; its `PagedConfig.before` calls
16
+ * `formfeedMoveTableFeet` while the document is still the one the template wrote. Bundled by
17
+ * `engine:frames`; keep it self-contained.
18
+ */
19
+ /** The part of Paged.js this runtime uses (`window.Paged`, a UMD global of the polyfill). */
20
+ interface PagedChunker {
21
+ source: ParentNode;
22
+ }
23
+ interface PagedGlobal {
24
+ Handler: new (chunker: PagedChunker, polisher: unknown, caller: unknown) => {
25
+ chunker: PagedChunker;
26
+ };
27
+ registerHandlers: (...handlers: unknown[]) => void;
28
+ }
29
+ type PagedWindow = Window & {
30
+ Paged?: PagedGlobal;
31
+ formfeedMoveTableFeet?: () => void;
32
+ };
33
+ /**
34
+ * HTML lets a `tfoot` stand before the `tbody`. Chromium draws a footer group at the table's foot
35
+ * wherever it stands; Paged.js lays it out where it stands and then laid the first page's rows out
36
+ * twice. Moved to the end of its table it draws the same, before Paged.js takes the document. A
37
+ * `tfoot` the template made a row group stays where it is, because that one prints where it stands.
38
+ */
39
+ export declare function moveTableFeet(doc: Document, win: Window): void;
40
+ /**
41
+ * Paged.js's `renderNode` hook: the first node placed on a page in a table that goes on from the page
42
+ * before gets the table's head in front of it, as Chromium prints it. The row it is in is at the top
43
+ * of its page then, so a row taller than what is left may break there (Chromium's view), instead of
44
+ * moving on to the next page and the next with `tr { break-inside: avoid }`.
45
+ */
46
+ export declare function repeatHead(clone: Node, node: Node, win: Window): void;
47
+ /**
48
+ * Paged.js's `onOverflow` hook, where the page's last content is settled: a table row that does not
49
+ * fit moves on, also one a wrapper with `overflow` clips at the page's foot, which Paged.js would
50
+ * keep; a table with a footer group keeps room for its copy (`data-ff-foot`, filled in by
51
+ * `repeatFoot`); and a head with no row under it at the foot of a page moves on with its table, and a
52
+ * heading kept to that by `break-after: avoid` with both. Returns the range, changed or not.
53
+ */
54
+ export declare function settleTable(overflow: Range, rendered: Node, bottom: number, source: ParentNode, win: Window): Range | undefined;
55
+ /** Paged.js's `afterOverflowRemoved` hook: the footer group's copy at the foot of the page `settleTable` kept room on. */
56
+ export declare function repeatFoot(rendered: ParentNode, source: ParentNode): void;
57
+ /**
58
+ * Paged.js's `afterPageLayout` hook. Paged.js puts a copy of every `position: fixed` element on every
59
+ * page, as Chromium prints it, but measures it from the whole sheet: a footer with `bottom: 0` stood in
60
+ * the bottom margin. Chromium measures it from the page area inside the margins, where it covers the
61
+ * last row of a full page (the post's `fixed-footer` case). The copies move into a layer laid over
62
+ * that area; clicks go through the layer to the page, and still reach the copies.
63
+ */
64
+ export declare function anchorFixed(pageElement: Element): void;
65
+ export declare function installPagedPrint(win: PagedWindow): void;
66
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -35,7 +35,13 @@ export interface TemplateSettings {
35
35
  preferCssPageSize?: boolean;
36
36
  pageRanges?: string;
37
37
  waitFor?: {
38
- networkIdle?: boolean;
38
+ /**
39
+ * `true` waits until the network has been idle for half a second, `false` only for the `load`
40
+ * event. `'auto'`, the default, waits for `load` and then for the requests still in flight, and as
41
+ * `true` does for a URL source or a document with code of its own (the render-worker's
42
+ * `render/load-wait.ts`).
43
+ */
44
+ networkIdle?: boolean | 'auto';
39
45
  selector?: string | null;
40
46
  timeoutMs?: number;
41
47
  delayMs?: number;
@@ -35,7 +35,13 @@ export interface TemplateSettings {
35
35
  preferCssPageSize?: boolean;
36
36
  pageRanges?: string;
37
37
  waitFor?: {
38
- networkIdle?: boolean;
38
+ /**
39
+ * `true` waits until the network has been idle for half a second, `false` only for the `load`
40
+ * event. `'auto'`, the default, waits for `load` and then for the requests still in flight, and as
41
+ * `true` does for a URL source or a document with code of its own (the render-worker's
42
+ * `render/load-wait.ts`).
43
+ */
44
+ networkIdle?: boolean | 'auto';
39
45
  selector?: string | null;
40
46
  timeoutMs?: number;
41
47
  delayMs?: number;
@@ -6,3 +6,5 @@ export declare const fitRuntime = "\"use strict\";(()=>{function a(t,e,n){if(e==
6
6
  export declare const stageRuntime = "\"use strict\";(()=>{var W=`\nhtml.ff-edit-mode [data-ff-edit] { cursor: text; }\nhtml.ff-edit-mode [data-ff-edit]:hover { outline: 1px dashed rgba(37,99,235,.85); outline-offset: 2px; }\nhtml.ff-edit-mode [data-ff-edit=\"t\"]:hover { outline-color: rgba(147,51,234,.9); }\n.ff-editing { outline: 2px solid #2563eb !important; outline-offset: 2px; cursor: text; }\n.ff-editing .ff-chip { background: rgba(37,99,235,.14) !important; box-shadow: inset 0 0 0 1px rgba(37,99,235,.45) !important; border-radius: 3px !important; padding: 0 1px !important; cursor: default; }\n.ff-edit-badge { position: absolute; z-index: 2147483647; font: 500 11px/1.4 system-ui, sans-serif !important; color: #fff !important; background: #2563eb !important; padding: 1px 6px !important; border-radius: 4px !important; pointer-events: none; white-space: nowrap; }\n`;function H(a,l={}){let f=l.clicks!==!1,p=l.live===!0,n=a.document,o=null,d=null,u=e=>{try{a.parent.postMessage(e,\"*\")}catch{}},m=f?n.querySelector('meta[name=\"formfeed:document\"]')?.getAttribute(\"content\")??null:null,s=!1;a.addEventListener(\"blur\",()=>{s=!0}),a.addEventListener(\"focus\",()=>{s=!1});let g=n.createElement(\"style\");g.setAttribute(\"data-formfeed\",\"edit\"),g.setAttribute(\"data-pagedjs-ignore\",\"\"),g.textContent=W,(n.head??n.documentElement).appendChild(g),f&&n.documentElement.classList.add(\"ff-edit-mode\");let x=e=>(e&&typeof e.closest==\"function\"?e:null)?.closest(\"[data-ff-edit]\")??null;n.addEventListener(\"click\",e=>{if(!f)return;if(o&&!o.done&&o.element.contains(e.target)){e.stopImmediatePropagation();return}let t=x(e.target);t&&(e.preventDefault(),e.stopImmediatePropagation(),v(t,{x:e.clientX,y:e.clientY}))},!0);function v(e,t){o&&!o.done&&L();let r=e.getAttribute(\"data-ff-src\")??\"\",i=e.getBoundingClientRect(),b=Array.from(n.querySelectorAll(`[data-ff-src=\"${r.replace(/\"/g,\"\")}\"]`));d={src:r,element:e,point:t},u({type:\"formfeed:edit-request\",src:r,doc:m,edit:e.getAttribute(\"data-ff-edit\"),text:e.textContent??\"\",elements:e.childElementCount,count:b.length,index:Math.max(0,b.indexOf(e)),split:e.hasAttribute(\"data-split-from\")||e.hasAttribute(\"data-split-to\"),rect:{left:i.left,top:i.top,width:i.width,height:i.height}})}n.addEventListener(\"keydown\",e=>{if(!f||o&&!o.done||!(e.ctrlKey||e.metaKey)||e.altKey)return;let t=e.key.toLowerCase();(t===\"z\"||t===\"y\")&&(e.preventDefault(),u({type:t===\"y\"||e.shiftKey?\"formfeed:redo\":\"formfeed:undo\"}))}),a.addEventListener(\"message\",e=>{if(e.source!==a.parent)return;let t=e.data;!t||typeof t.type!=\"string\"||(t.type===\"formfeed:edit-begin\"?B(t):t.type===\"formfeed:edit-refuse\"||t.type===\"formfeed:edit-end\"?(d=null,o&&!o.done&&S(!1)):t.type===\"formfeed:edit-open\"&&E(t))});function E(e){if(!f||typeof e.src!=\"string\"||o&&!o.done)return;let t=Array.from(n.querySelectorAll(`[data-ff-src=\"${e.src.replace(/\"/g,\"\")}\"][data-ff-edit]`)),r=Number.isInteger(e.index)?Number(e.index):0,i=t[r]??t[0];i&&v(i,null)}if(f){let e=()=>u({type:\"formfeed:edit-ready\",doc:m}),t=a;t.PagedConfig?t.formfeedEditReady=e:n.readyState===\"loading\"?n.addEventListener(\"DOMContentLoaded\",e):e()}function B(e){o&&!o.done&&S(!1);let t=e.layer?n.querySelector(`[data-ff-layer=\"${String(e.layer).replace(/\"/g,\"\")}\"] > .ff-text`):d&&d.src===e.src?d.element:n.querySelector(`[data-ff-src=\"${String(e.src).replace(/\"/g,\"\")}\"]`),r=e.at,i=e.layer?r&&Number.isFinite(r.x)&&Number.isFinite(r.y)?{x:Number(r.x),y:Number(r.y)}:null:d&&d.src===e.src?d.point:null;d=null;let b=s&&!n.hasFocus();if(!t||!Array.isArray(e.items)||b){u({type:\"formfeed:edit-cancel\",token:String(e.token)});return}let y=Array.from(t.childNodes),k=n.createDocumentFragment();for(let c of e.items)if(c.kind===\"text\")k.appendChild(n.createTextNode(String(c.text)));else if(c.kind===\"break\")k.appendChild(n.createElement(\"br\"));else if(c.kind===\"chip\"){let h=n.createElement(\"span\");h.className=\"ff-chip\",h.setAttribute(\"data-ff-chip\",String(c.index)),h.setAttribute(\"contenteditable\",\"false\"),c.title&&(h.title=String(c.title)),h.textContent=String(c.text),k.appendChild(h)}for(let c of y)t.removeChild(c);t.appendChild(k),t.contentEditable=\"true\",t.classList.add(\"ff-editing\"),t.setAttribute(\"role\",\"textbox\"),e.label&&t.setAttribute(\"aria-label\",String(e.label)),t.spellcheck=!0,o={token:String(e.token),element:t,saved:y,allowBreaks:e.allowBreaks===!0,badge:e.note?I(t,String(e.note)):null,done:!1},t.addEventListener(\"keydown\",T),t.addEventListener(\"beforeinput\",N),t.addEventListener(\"paste\",w),t.addEventListener(\"drop\",R),t.addEventListener(\"focusout\",F),p&&t.addEventListener(\"input\",C),t.focus(),e.select===\"all\"?q(t):K(t,i),u({type:\"formfeed:edit-started\",token:o.token}),typeof e.insert==\"string\"&&e.insert&&A(e.insert.replace(/\\r\\n?|\\n/g,\" \"))}function A(e){if(typeof n.execCommand==\"function\"&&n.execCommand(\"insertText\",!1,e))return;let t=a.getSelection(),r=t&&t.rangeCount?t.getRangeAt(0):null;r&&(r.deleteContents(),r.insertNode(n.createTextNode(e)),r.collapse(!1),p&&C())}function C(){o&&!o.done&&u({type:\"formfeed:edit-input\",token:o.token,items:D(o.element)})}function I(e,t){let r=n.createElement(\"div\");r.className=\"ff-edit-badge\",r.textContent=t;let i=e.getBoundingClientRect();return r.style.left=`${i.left+a.scrollX}px`,r.style.top=`${Math.max(0,i.top+a.scrollY-22)}px`,n.body.appendChild(r),r}function q(e){let t=a.getSelection();if(!t)return;let r=n.createRange();r.selectNodeContents(e),t.removeAllRanges(),t.addRange(r)}function K(e,t){let r=a.getSelection();if(!r)return;let i=null,b=n;if(t){if(b.caretRangeFromPoint)i=b.caretRangeFromPoint(t.x,t.y);else if(b.caretPositionFromPoint){let y=b.caretPositionFromPoint(t.x,t.y);y&&(i=n.createRange(),i.setStart(y.offsetNode,y.offset))}}if(!i||!e.contains(i.startContainer))i=n.createRange(),i.selectNodeContents(e),i.collapse(!1);else if(t){let y=i.startContainer,c=(y.nodeType===1?y:y.parentElement)?.closest(\"[data-ff-chip]\")??null;if(c&&c!==e&&e.contains(c)){let h=c.getBoundingClientRect();i=n.createRange(),t.x<h.left+h.width/2?i.setStartBefore(c):i.setStartAfter(c),i.collapse(!0)}}r.removeAllRanges(),r.addRange(i)}function T(e){let t=e.key;t===\"Escape\"?(e.preventDefault(),S(!0)):t===\"Enter\"&&!e.shiftKey?(e.preventDefault(),L()):t===\"Enter\"?(e.preventDefault(),o?.allowBreaks&&$()):t===\"Tab\"?(e.preventDefault(),L()):(e.ctrlKey||e.metaKey)&&[\"b\",\"i\",\"u\"].includes(t.toLowerCase())&&(e.preventDefault(),p&&o&&!e.altKey&&u({type:\"formfeed:edit-style\",token:o.token,key:t.toLowerCase()}))}function N(e){let t=e.inputType??\"\";(t.startsWith(\"format\")||t===\"insertFromDrop\"||t===\"insertParagraph\"||t===\"insertLineBreak\")&&e.preventDefault()}function w(e){e.preventDefault(),A((e.clipboardData?.getData(\"text/plain\")??\"\").replace(/\\r\\n?|\\n/g,\" \"))}function R(e){e.preventDefault()}function F(){a.setTimeout(()=>{o&&!o.done&&(!n.hasFocus()||!o.element.contains(n.activeElement))&&L()},0)}function $(){let e=a.getSelection();if(!e||!e.rangeCount)return;let t=e.getRangeAt(0);t.deleteContents();let r=n.createElement(\"br\");t.insertNode(r),r.nextSibling||r.parentNode?.appendChild(n.createElement(\"br\"));let i=n.createRange();i.setStartAfter(r),i.collapse(!0),e.removeAllRanges(),e.addRange(i)}function M(e){e.done=!0;let t=e.element;t.removeEventListener(\"keydown\",T),t.removeEventListener(\"beforeinput\",N),t.removeEventListener(\"paste\",w),t.removeEventListener(\"drop\",R),t.removeEventListener(\"focusout\",F),t.removeEventListener(\"input\",C),t.removeAttribute(\"contenteditable\"),t.removeAttribute(\"role\"),t.removeAttribute(\"aria-label\"),t.classList.remove(\"ff-editing\"),e.badge?.remove(),o===e&&(o=null)}function L(){let e=o;if(!e||e.done)return;let t=D(e.element);M(e),u({type:\"formfeed:edit-commit\",token:e.token,items:t})}function S(e){let t=o;if(!t||t.done)return;let r=t.element;for(;r.firstChild;)r.removeChild(r.firstChild);for(let i of t.saved)r.appendChild(i);M(t),e&&u({type:\"formfeed:edit-cancel\",token:t.token})}}function D(a){let l=[],f=n=>{let o=l[l.length-1];o?.kind===\"text\"?o.text+=n:n&&l.push({kind:\"text\",text:n})},p=n=>{for(let o of Array.from(n.childNodes))if(o.nodeType===3)f(o.data);else if(o.nodeType===1){let d=o,u=d.getAttribute(\"data-ff-chip\");u!==null?l.push({kind:\"chip\",index:Number(u)}):d.tagName===\"BR\"?l.push({kind:\"break\"}):((d.tagName===\"DIV\"||d.tagName===\"P\")&&l.length&&l.push({kind:\"break\"}),p(d))}};for(p(a);l[l.length-1]?.kind===\"break\";)l.pop();return l}function O(a,l){return Array.from(a.querySelectorAll(\"[data-ff-layer]\")).map(f=>{let p=f.querySelector(\":scope > .ff-text\"),n=!1;if(p&&f.style.height!==\"auto\"){let o=l.getComputedStyle(f),d=f.clientHeight-(parseFloat(o.paddingTop)||0)-(parseFloat(o.paddingBottom)||0);n=o.overflow===\"hidden\"&&(p.scrollHeight>d+1||p.scrollWidth>p.clientWidth+1)}return{id:f.getAttribute(\"data-ff-layer\")??\"\",width:f.offsetWidth,height:f.offsetHeight,overflow:n}})}function P(a){let l=a.document,f=m=>{try{a.parent.postMessage(m,\"*\")}catch{}},p=m=>typeof m==\"string\"?l.querySelector(`[data-ff-layer=\"${m.replace(/\"/g,\"\")}\"]`):null,n=()=>{for(let m of Array.from(l.querySelectorAll(\"[data-ff-layer]\")))for(let s of[\"left\",\"top\",\"width\",\"height\",\"transform\"])m.style.removeProperty(s)},o=()=>{a.formfeedFit?.(),f({type:\"formfeed:ready\",layers:O(l,a)})};a.addEventListener(\"message\",m=>{if(m.source!==a.parent)return;let s=m.data;if(!(!s||typeof s.type!=\"string\")){if(s.type===\"formfeed:layer-style\"){let g=p(s.id);if(!g)return;let x=(v,E)=>{typeof E==\"number\"&&Number.isFinite(E)&&g.style.setProperty(v,`${E}px`)};x(\"left\",s.left),x(\"top\",s.top),x(\"width\",s.width),x(\"height\",s.height),typeof s.rotation==\"number\"&&Number.isFinite(s.rotation)&&g.style.setProperty(\"transform\",s.rotation?`rotate(${s.rotation}deg)`:\"none\")}else if(s.type===\"formfeed:layer-style-clear\")n();else if(s.type===\"formfeed:css\"&&typeof s.css==\"string\"){let g=l.querySelector('style[data-formfeed=\"template\"]');g&&(g.textContent=s.css),n(),o()}}}),H(a,{clicks:!1,live:!0});let d=l.fonts,u=()=>d?void d.ready.then(o):o();l.readyState===\"complete\"?u():a.addEventListener(\"load\",u)}P(window);})();";
7
7
  /** Bundled from src/frame/audit.entry.ts. */
8
8
  export declare const auditRuntime = "\"use strict\";(()=>{var I={\"document-title\":\"error\",\"image-alt\":\"error\",\"figure-name\":\"error\",\"heading-order\":\"error\",\"table-rows\":\"error\",\"table-cell-empty\":\"error\",\"masked-text\":\"error\",\"filtered-text\":\"warning\",\"document-language\":\"warning\",\"table-headers\":\"warning\",\"link-name\":\"warning\",\"generated-text\":\"warning\",\"fixed-text\":\"warning\",\"running-text\":\"warning\"};var S=120;var O=\".formfeed-chrome, .ff-running-header, .ff-running-footer\",_=\".pageNumber, .totalPages, .date, .title, .url, .ff-page-no, .ff-page-total\",k=new Set([\"script\",\"style\",\"template\",\"noscript\",\"head\"]),j=2e4,q=10,B=new Set([\"page\",\"pages\",\"of\",\"seite\",\"seiten\",\"von\",\"p\",\"s\"]),u=t=>(t??\"\").replace(/\\s+/g,\" \").trim(),D=t=>t.replace(/\\s+/g,\"\").toLowerCase(),$=t=>/[\\p{L}\\p{N}]/u.test(t),Y=/^data-(ref|id|split-(from|to|original)|(previous-|next-)?break-(before|after|inside)|(align-)?last-split-element|nth-of-type|counter-.+|page(-number)?|undisplayed|after-page|following|has-notes|children|item-num)$/;function X(t){let n=t.cloneNode(!1);n.removeAttribute(\"data-ff-src\"),n.removeAttribute(\"data-ff-edit\");let i=t.closest(\".pagedjs_page\")!==null;for(let s of Array.from(n.attributes))i&&Y.test(s.name)?n.removeAttribute(s.name):s.value.length>48&&n.setAttribute(s.name,`${s.value.slice(0,40)}\\u2026`);let o=n.outerHTML.replace(new RegExp(`</${t.tagName}>$`,\"i\"),\"\");return o.length>S?`${o.slice(0,S-1)}\\u2026`:o}function F(t,n={}){let i=t.document,o=i.body,s=[],d=new Set,a=n.findings!==!1,c=(e,r,l={})=>{if(!a)return;let m=r?.closest(\"[data-ff-src]\")?.getAttribute(\"data-ff-src\")??null,h=r?X(r):\"\",g=`${e}|${m??h}|${JSON.stringify(l)}`;d.has(g)||(d.add(g),s.push({code:e,severity:I[e],src:m,snippet:h,args:l}))},f=new WeakMap,A=e=>{let r=f.get(e);if(r!==void 0)return r;let l=t.getComputedStyle(e),m=l.display===\"none\"||l.visibility===\"hidden\"||l.visibility===\"collapse\"||e.parentElement!==null&&e.parentElement!==i.documentElement&&A(e.parentElement);return f.set(e,m),m},p=e=>e.closest('[aria-hidden=\"true\"]')!==null,E=e=>/^(presentation|none)$/.test(e.getAttribute(\"role\")??\"\"),H=e=>e.closest(O)!==null,y=e=>$(e.textContent??\"\"),x=e=>{let r=u(e.getAttribute(\"aria-label\"));return r||u((e.getAttribute(\"aria-labelledby\")??\"\").split(/\\s+/).filter(Boolean).map(l=>e.ownerDocument.getElementById(l)?.textContent??\"\").join(\" \"))},P=e=>x(e)||u(e.textContent)||u(Array.from(e.querySelectorAll(\"img[alt]\")).map(r=>r.getAttribute(\"alt\")).join(\" \"))||u(e.getAttribute(\"title\")),T=e=>{let r=e.getAttribute(\"href\")??\"\";return{href:r.startsWith(\"#\")?r:e.href??r,name:P(e)}};u(i.title)||c(\"document-title\",null),!u(i.documentElement.getAttribute(\"lang\"))&&!n.locale&&c(\"document-language\",null);let M=n.pages??(n.pageHeight&&n.pageHeight>0?Math.ceil(i.documentElement.scrollHeight/n.pageHeight):1),C=[],v=[],R={\"masked-text\":[],\"filtered-text\":[],\"fixed-text\":[]},w=(e,r)=>{R[e].some(l=>l.contains(r))||(R[e].push(r),c(e,r))},V=a&&ne(i),G=o?Array.from(o.querySelectorAll(\"*\")).slice(0,j):[];for(let e of G){let r=e.tagName.toLowerCase();if(k.has(r)||H(e)||A(e))continue;if(r===\"a\"&&e.hasAttribute(\"href\")){let g=T(e);C.push(g),!g.name&&!p(e)&&c(\"link-name\",e)}if(!a)continue;let l=t.getComputedStyle(e),m=l.getPropertyValue(\"mask-image\")||l.getPropertyValue(\"-webkit-mask-image\");if(m&&m!==\"none\"&&y(e)&&w(\"masked-text\",e),l.filter&&l.filter!==\"none\"&&y(e)&&w(\"filtered-text\",e),l.position===\"fixed\"&&M>1&&y(e)&&w(\"fixed-text\",e),V)for(let g of[\"::before\",\"::after\"]){let U=re(t.getComputedStyle(e,g).content);U&&c(\"generated-text\",e,{text:U})}if(p(e))continue;r===\"img\"&&!E(e)?e.hasAttribute(\"alt\")||x(e)||u(e.getAttribute(\"title\"))||c(\"image-alt\",e):(r===\"canvas\"||e.getAttribute(\"role\")===\"img\"&&r!==\"img\")&&(x(e)||u(e.getAttribute(\"title\"))||u(e.querySelector(\":scope > title\")?.textContent)||c(\"figure-name\",e,{tag:r}));let h=/^h[1-6]$/.test(r)?Number(r[1]):e.getAttribute(\"role\")===\"heading\"?Number(e.getAttribute(\"aria-level\"))||2:0;h&&v.push({element:e,level:h}),r===\"table\"&&!E(e)&&Q(e,c)}let b=0;for(let{element:e,level:r}of v)(b===0?r!==1:r>b+1)&&c(\"heading-order\",e,{level:r,previous:b}),b=r;let N=[],W=a&&o?D(J(o)):\"\",L=0;for(let e of[\"header\",\"footer\"])for(let r of z(i,e,n[e])){for(let l of Array.from(r.querySelectorAll(\"a[href]\")))N.push(T(l));if(a)for(let{text:l,element:m}of K(r)){if(L>=q||W.includes(D(l)))continue;let h=s.length;c(\"running-text\",m,{text:l.slice(0,80),part:e}),s.length>h&&L++}}return{findings:s,links:C,templateLinks:N}}function z(t,n,i){if(i!==void 0){if(!i.trim())return[];let o=new DOMParser().parseFromString(`<!doctype html><body>${i}</body>`,\"text/html\");return o.body?[o.body]:[]}return Array.from(t.querySelectorAll(`.ff-running-${n}, .formfeed-chrome[data-ff-chrome=\"${n}\"]`))}function J(t){let n=[],i=o=>{if(o.nodeType===3){n.push(o.nodeValue??\"\");return}if(o.nodeType!==1)return;let s=o;if(!(k.has(s.tagName.toLowerCase())||s.matches(O)))for(let d of Array.from(o.childNodes))i(d)};return i(t),n.join(\" \")}function K(t){let n=[],i=o=>{let s=o.tagName.toLowerCase();if(k.has(s)||o.matches(_))return;let d=Array.from(o.children).some(a=>a.matches(_));for(let a of Array.from(o.childNodes))if(a.nodeType===1)i(a);else if(a.nodeType===3&&!d)for(let c of(a.nodeValue??\"\").split(/\\s*[\u00B7\u2022|]\\s*|\\s{2,}|\\n/)){let f=u(c);(f.toLowerCase().match(/[\\p{L}\\p{N}]+/gu)??[]).some(p=>!B.has(p))&&n.push({text:f,element:o})}};return i(t),n}function Q(t,n){let i=Array.from(t.rows);if(!(t.querySelector('th, [role=\"columnheader\"], [role=\"rowheader\"]')!==null)){i.length>=2&&n(\"table-headers\",t);return}let s=te(i),d=s.find(c=>c!==s[0]);d!==void 0&&n(\"table-rows\",t,{first:s[0]??0,other:d});let a=i.flatMap(c=>Array.from(c.cells).filter(f=>f.tagName===\"TD\"&&ee(f)));a[0]&&n(\"table-cell-empty\",a[0],{count:a.length})}var Z='img[alt]:not([alt=\"\"]), svg, canvas, input, select, textarea, button, meter, progress';function ee(t){return!/[^ \\t\\n\\r\\f]/.test(t.textContent??\"\")&&t.querySelector(Z)===null}function te(t){let n=[];return t.map(i=>{let o=[],s=0,d=()=>{for(;(n[s]??0)>0;)o[s]=n[s]-1,s++};for(let a of Array.from(i.cells)){d();let c=Math.max(1,a.rowSpan||1)-1;for(let f=Math.max(1,a.colSpan||1);f>0;f--)o[s++]=c}d();for(let a=s;a<n.length;a++)(n[a]??0)>0&&(o[a]=n[a]-1,s=a+1);return n=o,s})}function ne(t){let n=i=>{for(let o of Array.from(i??[])){let s=o;if(s.selectorText&&/::?(before|after)/.test(s.selectorText)&&s.style?.content||o.cssRules&&n(o.cssRules))return!0}return!1};for(let i of Array.from(t.styleSheets))try{if(n(i.cssRules))return!0}catch{return!0}return!1}function re(t){if(!t||t===\"none\"||t===\"normal\")return\"\";let n=(t.match(/\"(?:[^\"\\\\]|\\\\.)*\"/g)??[]).map(o=>o.slice(1,-1).replace(/\\\\(.)/g,\"$1\"));if(/\\bcounters?\\(/.test(t))return u(t).slice(0,80);let i=u(n.join(\"\"));return $(i)?i.slice(0,80):\"\"}window.formfeedAudit=t=>F(window,t);})();";
9
+ /** Bundled from src/frame/paged-print.entry.ts. */
10
+ export declare const pagedPrintRuntime = "\"use strict\";(()=>{var N=t=>!!t&&t.nodeType===1,y=t=>N(t)?t:t?.parentElement??null;function b(t,o){for(let e=t.firstElementChild;e;e=e.nextElementSibling)if(e.nodeName===o)return e;return null}var T=t=>Array.from(t.querySelectorAll(\":scope > tbody > tr, :scope > tr\"));function v(t,o){for(let e=t.parentElement;e&&!e.classList.contains(\"pagedjs_page_content\");e=e.parentElement)if(o.getComputedStyle(e).display.startsWith(\"inline\"))return!0;return!1}function O(t,o){for(let e=t;e&&e!==o;e=e.parentElement)for(let r=e.previousSibling;r;r=r.previousSibling)if(N(r)||(r.textContent??\"\").trim())return!0;return!1}function P(t){let o=t.cloneNode(!0);for(let e of[o,...Array.from(o.querySelectorAll(\"[id]\"))])e.id&&(e.setAttribute(\"data-id\",e.id),e.removeAttribute(\"id\"));return o.setAttribute(\"data-ff-repeated\",\"\"),o}function k(t,o){for(let e of Array.from(t.querySelectorAll(\"table > tfoot\"))){let r=e.nextElementSibling;for(;r&&r.nodeName!==\"TBODY\"&&r.nodeName!==\"TR\";)r=r.nextElementSibling;r&&o.getComputedStyle(e).display===\"table-footer-group\"&&e.parentNode?.appendChild(e)}}function H(t,o,e){let r=y(t),n=r?.closest(\"table\");if(!r||!n||!n.hasAttribute(\"data-split-from\")||n.hasAttribute(\"data-ff-head\")||(n.setAttribute(\"data-ff-head\",\"\"),b(n,\"THEAD\")))return;let a=y(o)?.closest(\"table\"),f=a&&b(a,\"THEAD\");if(!a||!f||v(n,e))return;let l=P(f),d=n.firstChild;for(;d&&(d.nodeName===\"CAPTION\"||d.nodeName===\"COLGROUP\");)d=d.nextSibling;if(n.insertBefore(l,d),e.getComputedStyle(l).display!==\"table-header-group\"){l.remove();return}for(let s=a.firstElementChild;s;s=s.nextElementSibling)s.nodeName===\"COLGROUP\"&&n.insertBefore(s.cloneNode(!0),l);let i=r.closest(\"tr\"),u=i?.parentElement;i&&u&&u.parentElement===n&&u.nodeName!==\"THEAD\"&&(i.style.breakInside=\"auto\",i.removeAttribute(\"data-break-inside\"))}function w(t,o,e,r,n){let a=t.startContainer,f=N(a)?a.childNodes[t.startOffset]??a:a,l=y(f);if(!l)return;let d=l.nodeName===\"TBODY\"?l.querySelector(\"tr\"):l.closest(\"tr\"),i=d?.closest(\"table\"),u=d?.parentElement;if(!d||!i||!u||u.nodeName===\"THEAD\"||u.nodeName===\"TFOOT\"||v(i,n))return;let s=T(i),h=s.indexOf(d);if(h<0)return;let m=h,E=0;if(h>0&&(f===d||f===u)){let p=r.querySelector(`[data-ref=\"${i.getAttribute(\"data-ref\")??\"\"}\"]`),g=p&&b(p,\"TFOOT\");if(g){let c=g.cloneNode(!0);i.appendChild(c),n.getComputedStyle(c).display===\"table-footer-group\"&&(E=c.getBoundingClientRect().height),c.remove()}let C=Math.round(e),S=c=>!c||Math.floor(c.getBoundingClientRect().bottom)+E<=C;for(;m>0&&!S(s[m-1]);)m--}if(m===0){if(i.hasAttribute(\"data-split-from\")||!b(i,\"THEAD\"))return;let p=i.previousElementSibling,g=i.getAttribute(\"data-previous-break-after\")===\"avoid\"&&p?p:i;return O(g,o)?(t.setStartBefore(g),t):void 0}let A=s[m];return m<h&&A&&t.setStartBefore(A),E&&i.setAttribute(\"data-ff-foot\",\"\"),t}function R(t,o){let e=t.querySelector(\"table[data-ff-foot]\");if(!e)return;e.removeAttribute(\"data-ff-foot\");let r=o.querySelector(`[data-ref=\"${e.getAttribute(\"data-ref\")??\"\"}\"]`),n=r&&b(r,\"TFOOT\");n&&e.appendChild(P(n))}function B(t){let o=t.querySelector(\".pagedjs_pagebox\");if(!o)return;let e=Array.from(o.children).filter(n=>!(n.getAttribute(\"class\")??\"\").includes(\"pagedjs_\")&&!n.hasAttribute(\"data-ff-fixed\"));if(!e.length)return;let r=o.ownerDocument.createElement(\"div\");r.setAttribute(\"data-ff-fixed\",\"\"),r.setAttribute(\"style\",\"grid-column: center; grid-row: page; position: relative; pointer-events: none;\");for(let n of e)\"style\"in n&&(n.style.pointerEvents=\"auto\"),r.appendChild(n);o.appendChild(r)}function x(t){t.formfeedMoveTableFeet=()=>k(t.document,t);let o=t.Paged;if(!o?.Handler)return;class e extends o.Handler{renderNode(n,a){H(n,a,t)}onOverflow(n,a,f){return n?w(n,a,f.bottom,this.chunker.source,t):void 0}afterOverflowRemoved(n,a){R(a,this.chunker.source)}afterPageLayout(n){B(n)}}o.registerHandlers(e)}x(window);})();";
@@ -6,3 +6,5 @@ export declare const fitRuntime = "\"use strict\";(()=>{function a(t,e,n){if(e==
6
6
  export declare const stageRuntime = "\"use strict\";(()=>{var W=`\nhtml.ff-edit-mode [data-ff-edit] { cursor: text; }\nhtml.ff-edit-mode [data-ff-edit]:hover { outline: 1px dashed rgba(37,99,235,.85); outline-offset: 2px; }\nhtml.ff-edit-mode [data-ff-edit=\"t\"]:hover { outline-color: rgba(147,51,234,.9); }\n.ff-editing { outline: 2px solid #2563eb !important; outline-offset: 2px; cursor: text; }\n.ff-editing .ff-chip { background: rgba(37,99,235,.14) !important; box-shadow: inset 0 0 0 1px rgba(37,99,235,.45) !important; border-radius: 3px !important; padding: 0 1px !important; cursor: default; }\n.ff-edit-badge { position: absolute; z-index: 2147483647; font: 500 11px/1.4 system-ui, sans-serif !important; color: #fff !important; background: #2563eb !important; padding: 1px 6px !important; border-radius: 4px !important; pointer-events: none; white-space: nowrap; }\n`;function H(a,l={}){let f=l.clicks!==!1,p=l.live===!0,n=a.document,o=null,d=null,u=e=>{try{a.parent.postMessage(e,\"*\")}catch{}},m=f?n.querySelector('meta[name=\"formfeed:document\"]')?.getAttribute(\"content\")??null:null,s=!1;a.addEventListener(\"blur\",()=>{s=!0}),a.addEventListener(\"focus\",()=>{s=!1});let g=n.createElement(\"style\");g.setAttribute(\"data-formfeed\",\"edit\"),g.setAttribute(\"data-pagedjs-ignore\",\"\"),g.textContent=W,(n.head??n.documentElement).appendChild(g),f&&n.documentElement.classList.add(\"ff-edit-mode\");let x=e=>(e&&typeof e.closest==\"function\"?e:null)?.closest(\"[data-ff-edit]\")??null;n.addEventListener(\"click\",e=>{if(!f)return;if(o&&!o.done&&o.element.contains(e.target)){e.stopImmediatePropagation();return}let t=x(e.target);t&&(e.preventDefault(),e.stopImmediatePropagation(),v(t,{x:e.clientX,y:e.clientY}))},!0);function v(e,t){o&&!o.done&&L();let r=e.getAttribute(\"data-ff-src\")??\"\",i=e.getBoundingClientRect(),b=Array.from(n.querySelectorAll(`[data-ff-src=\"${r.replace(/\"/g,\"\")}\"]`));d={src:r,element:e,point:t},u({type:\"formfeed:edit-request\",src:r,doc:m,edit:e.getAttribute(\"data-ff-edit\"),text:e.textContent??\"\",elements:e.childElementCount,count:b.length,index:Math.max(0,b.indexOf(e)),split:e.hasAttribute(\"data-split-from\")||e.hasAttribute(\"data-split-to\"),rect:{left:i.left,top:i.top,width:i.width,height:i.height}})}n.addEventListener(\"keydown\",e=>{if(!f||o&&!o.done||!(e.ctrlKey||e.metaKey)||e.altKey)return;let t=e.key.toLowerCase();(t===\"z\"||t===\"y\")&&(e.preventDefault(),u({type:t===\"y\"||e.shiftKey?\"formfeed:redo\":\"formfeed:undo\"}))}),a.addEventListener(\"message\",e=>{if(e.source!==a.parent)return;let t=e.data;!t||typeof t.type!=\"string\"||(t.type===\"formfeed:edit-begin\"?B(t):t.type===\"formfeed:edit-refuse\"||t.type===\"formfeed:edit-end\"?(d=null,o&&!o.done&&S(!1)):t.type===\"formfeed:edit-open\"&&E(t))});function E(e){if(!f||typeof e.src!=\"string\"||o&&!o.done)return;let t=Array.from(n.querySelectorAll(`[data-ff-src=\"${e.src.replace(/\"/g,\"\")}\"][data-ff-edit]`)),r=Number.isInteger(e.index)?Number(e.index):0,i=t[r]??t[0];i&&v(i,null)}if(f){let e=()=>u({type:\"formfeed:edit-ready\",doc:m}),t=a;t.PagedConfig?t.formfeedEditReady=e:n.readyState===\"loading\"?n.addEventListener(\"DOMContentLoaded\",e):e()}function B(e){o&&!o.done&&S(!1);let t=e.layer?n.querySelector(`[data-ff-layer=\"${String(e.layer).replace(/\"/g,\"\")}\"] > .ff-text`):d&&d.src===e.src?d.element:n.querySelector(`[data-ff-src=\"${String(e.src).replace(/\"/g,\"\")}\"]`),r=e.at,i=e.layer?r&&Number.isFinite(r.x)&&Number.isFinite(r.y)?{x:Number(r.x),y:Number(r.y)}:null:d&&d.src===e.src?d.point:null;d=null;let b=s&&!n.hasFocus();if(!t||!Array.isArray(e.items)||b){u({type:\"formfeed:edit-cancel\",token:String(e.token)});return}let y=Array.from(t.childNodes),k=n.createDocumentFragment();for(let c of e.items)if(c.kind===\"text\")k.appendChild(n.createTextNode(String(c.text)));else if(c.kind===\"break\")k.appendChild(n.createElement(\"br\"));else if(c.kind===\"chip\"){let h=n.createElement(\"span\");h.className=\"ff-chip\",h.setAttribute(\"data-ff-chip\",String(c.index)),h.setAttribute(\"contenteditable\",\"false\"),c.title&&(h.title=String(c.title)),h.textContent=String(c.text),k.appendChild(h)}for(let c of y)t.removeChild(c);t.appendChild(k),t.contentEditable=\"true\",t.classList.add(\"ff-editing\"),t.setAttribute(\"role\",\"textbox\"),e.label&&t.setAttribute(\"aria-label\",String(e.label)),t.spellcheck=!0,o={token:String(e.token),element:t,saved:y,allowBreaks:e.allowBreaks===!0,badge:e.note?I(t,String(e.note)):null,done:!1},t.addEventListener(\"keydown\",T),t.addEventListener(\"beforeinput\",N),t.addEventListener(\"paste\",w),t.addEventListener(\"drop\",R),t.addEventListener(\"focusout\",F),p&&t.addEventListener(\"input\",C),t.focus(),e.select===\"all\"?q(t):K(t,i),u({type:\"formfeed:edit-started\",token:o.token}),typeof e.insert==\"string\"&&e.insert&&A(e.insert.replace(/\\r\\n?|\\n/g,\" \"))}function A(e){if(typeof n.execCommand==\"function\"&&n.execCommand(\"insertText\",!1,e))return;let t=a.getSelection(),r=t&&t.rangeCount?t.getRangeAt(0):null;r&&(r.deleteContents(),r.insertNode(n.createTextNode(e)),r.collapse(!1),p&&C())}function C(){o&&!o.done&&u({type:\"formfeed:edit-input\",token:o.token,items:D(o.element)})}function I(e,t){let r=n.createElement(\"div\");r.className=\"ff-edit-badge\",r.textContent=t;let i=e.getBoundingClientRect();return r.style.left=`${i.left+a.scrollX}px`,r.style.top=`${Math.max(0,i.top+a.scrollY-22)}px`,n.body.appendChild(r),r}function q(e){let t=a.getSelection();if(!t)return;let r=n.createRange();r.selectNodeContents(e),t.removeAllRanges(),t.addRange(r)}function K(e,t){let r=a.getSelection();if(!r)return;let i=null,b=n;if(t){if(b.caretRangeFromPoint)i=b.caretRangeFromPoint(t.x,t.y);else if(b.caretPositionFromPoint){let y=b.caretPositionFromPoint(t.x,t.y);y&&(i=n.createRange(),i.setStart(y.offsetNode,y.offset))}}if(!i||!e.contains(i.startContainer))i=n.createRange(),i.selectNodeContents(e),i.collapse(!1);else if(t){let y=i.startContainer,c=(y.nodeType===1?y:y.parentElement)?.closest(\"[data-ff-chip]\")??null;if(c&&c!==e&&e.contains(c)){let h=c.getBoundingClientRect();i=n.createRange(),t.x<h.left+h.width/2?i.setStartBefore(c):i.setStartAfter(c),i.collapse(!0)}}r.removeAllRanges(),r.addRange(i)}function T(e){let t=e.key;t===\"Escape\"?(e.preventDefault(),S(!0)):t===\"Enter\"&&!e.shiftKey?(e.preventDefault(),L()):t===\"Enter\"?(e.preventDefault(),o?.allowBreaks&&$()):t===\"Tab\"?(e.preventDefault(),L()):(e.ctrlKey||e.metaKey)&&[\"b\",\"i\",\"u\"].includes(t.toLowerCase())&&(e.preventDefault(),p&&o&&!e.altKey&&u({type:\"formfeed:edit-style\",token:o.token,key:t.toLowerCase()}))}function N(e){let t=e.inputType??\"\";(t.startsWith(\"format\")||t===\"insertFromDrop\"||t===\"insertParagraph\"||t===\"insertLineBreak\")&&e.preventDefault()}function w(e){e.preventDefault(),A((e.clipboardData?.getData(\"text/plain\")??\"\").replace(/\\r\\n?|\\n/g,\" \"))}function R(e){e.preventDefault()}function F(){a.setTimeout(()=>{o&&!o.done&&(!n.hasFocus()||!o.element.contains(n.activeElement))&&L()},0)}function $(){let e=a.getSelection();if(!e||!e.rangeCount)return;let t=e.getRangeAt(0);t.deleteContents();let r=n.createElement(\"br\");t.insertNode(r),r.nextSibling||r.parentNode?.appendChild(n.createElement(\"br\"));let i=n.createRange();i.setStartAfter(r),i.collapse(!0),e.removeAllRanges(),e.addRange(i)}function M(e){e.done=!0;let t=e.element;t.removeEventListener(\"keydown\",T),t.removeEventListener(\"beforeinput\",N),t.removeEventListener(\"paste\",w),t.removeEventListener(\"drop\",R),t.removeEventListener(\"focusout\",F),t.removeEventListener(\"input\",C),t.removeAttribute(\"contenteditable\"),t.removeAttribute(\"role\"),t.removeAttribute(\"aria-label\"),t.classList.remove(\"ff-editing\"),e.badge?.remove(),o===e&&(o=null)}function L(){let e=o;if(!e||e.done)return;let t=D(e.element);M(e),u({type:\"formfeed:edit-commit\",token:e.token,items:t})}function S(e){let t=o;if(!t||t.done)return;let r=t.element;for(;r.firstChild;)r.removeChild(r.firstChild);for(let i of t.saved)r.appendChild(i);M(t),e&&u({type:\"formfeed:edit-cancel\",token:t.token})}}function D(a){let l=[],f=n=>{let o=l[l.length-1];o?.kind===\"text\"?o.text+=n:n&&l.push({kind:\"text\",text:n})},p=n=>{for(let o of Array.from(n.childNodes))if(o.nodeType===3)f(o.data);else if(o.nodeType===1){let d=o,u=d.getAttribute(\"data-ff-chip\");u!==null?l.push({kind:\"chip\",index:Number(u)}):d.tagName===\"BR\"?l.push({kind:\"break\"}):((d.tagName===\"DIV\"||d.tagName===\"P\")&&l.length&&l.push({kind:\"break\"}),p(d))}};for(p(a);l[l.length-1]?.kind===\"break\";)l.pop();return l}function O(a,l){return Array.from(a.querySelectorAll(\"[data-ff-layer]\")).map(f=>{let p=f.querySelector(\":scope > .ff-text\"),n=!1;if(p&&f.style.height!==\"auto\"){let o=l.getComputedStyle(f),d=f.clientHeight-(parseFloat(o.paddingTop)||0)-(parseFloat(o.paddingBottom)||0);n=o.overflow===\"hidden\"&&(p.scrollHeight>d+1||p.scrollWidth>p.clientWidth+1)}return{id:f.getAttribute(\"data-ff-layer\")??\"\",width:f.offsetWidth,height:f.offsetHeight,overflow:n}})}function P(a){let l=a.document,f=m=>{try{a.parent.postMessage(m,\"*\")}catch{}},p=m=>typeof m==\"string\"?l.querySelector(`[data-ff-layer=\"${m.replace(/\"/g,\"\")}\"]`):null,n=()=>{for(let m of Array.from(l.querySelectorAll(\"[data-ff-layer]\")))for(let s of[\"left\",\"top\",\"width\",\"height\",\"transform\"])m.style.removeProperty(s)},o=()=>{a.formfeedFit?.(),f({type:\"formfeed:ready\",layers:O(l,a)})};a.addEventListener(\"message\",m=>{if(m.source!==a.parent)return;let s=m.data;if(!(!s||typeof s.type!=\"string\")){if(s.type===\"formfeed:layer-style\"){let g=p(s.id);if(!g)return;let x=(v,E)=>{typeof E==\"number\"&&Number.isFinite(E)&&g.style.setProperty(v,`${E}px`)};x(\"left\",s.left),x(\"top\",s.top),x(\"width\",s.width),x(\"height\",s.height),typeof s.rotation==\"number\"&&Number.isFinite(s.rotation)&&g.style.setProperty(\"transform\",s.rotation?`rotate(${s.rotation}deg)`:\"none\")}else if(s.type===\"formfeed:layer-style-clear\")n();else if(s.type===\"formfeed:css\"&&typeof s.css==\"string\"){let g=l.querySelector('style[data-formfeed=\"template\"]');g&&(g.textContent=s.css),n(),o()}}}),H(a,{clicks:!1,live:!0});let d=l.fonts,u=()=>d?void d.ready.then(o):o();l.readyState===\"complete\"?u():a.addEventListener(\"load\",u)}P(window);})();";
7
7
  /** Bundled from src/frame/audit.entry.ts. */
8
8
  export declare const auditRuntime = "\"use strict\";(()=>{var I={\"document-title\":\"error\",\"image-alt\":\"error\",\"figure-name\":\"error\",\"heading-order\":\"error\",\"table-rows\":\"error\",\"table-cell-empty\":\"error\",\"masked-text\":\"error\",\"filtered-text\":\"warning\",\"document-language\":\"warning\",\"table-headers\":\"warning\",\"link-name\":\"warning\",\"generated-text\":\"warning\",\"fixed-text\":\"warning\",\"running-text\":\"warning\"};var S=120;var O=\".formfeed-chrome, .ff-running-header, .ff-running-footer\",_=\".pageNumber, .totalPages, .date, .title, .url, .ff-page-no, .ff-page-total\",k=new Set([\"script\",\"style\",\"template\",\"noscript\",\"head\"]),j=2e4,q=10,B=new Set([\"page\",\"pages\",\"of\",\"seite\",\"seiten\",\"von\",\"p\",\"s\"]),u=t=>(t??\"\").replace(/\\s+/g,\" \").trim(),D=t=>t.replace(/\\s+/g,\"\").toLowerCase(),$=t=>/[\\p{L}\\p{N}]/u.test(t),Y=/^data-(ref|id|split-(from|to|original)|(previous-|next-)?break-(before|after|inside)|(align-)?last-split-element|nth-of-type|counter-.+|page(-number)?|undisplayed|after-page|following|has-notes|children|item-num)$/;function X(t){let n=t.cloneNode(!1);n.removeAttribute(\"data-ff-src\"),n.removeAttribute(\"data-ff-edit\");let i=t.closest(\".pagedjs_page\")!==null;for(let s of Array.from(n.attributes))i&&Y.test(s.name)?n.removeAttribute(s.name):s.value.length>48&&n.setAttribute(s.name,`${s.value.slice(0,40)}\\u2026`);let o=n.outerHTML.replace(new RegExp(`</${t.tagName}>$`,\"i\"),\"\");return o.length>S?`${o.slice(0,S-1)}\\u2026`:o}function F(t,n={}){let i=t.document,o=i.body,s=[],d=new Set,a=n.findings!==!1,c=(e,r,l={})=>{if(!a)return;let m=r?.closest(\"[data-ff-src]\")?.getAttribute(\"data-ff-src\")??null,h=r?X(r):\"\",g=`${e}|${m??h}|${JSON.stringify(l)}`;d.has(g)||(d.add(g),s.push({code:e,severity:I[e],src:m,snippet:h,args:l}))},f=new WeakMap,A=e=>{let r=f.get(e);if(r!==void 0)return r;let l=t.getComputedStyle(e),m=l.display===\"none\"||l.visibility===\"hidden\"||l.visibility===\"collapse\"||e.parentElement!==null&&e.parentElement!==i.documentElement&&A(e.parentElement);return f.set(e,m),m},p=e=>e.closest('[aria-hidden=\"true\"]')!==null,E=e=>/^(presentation|none)$/.test(e.getAttribute(\"role\")??\"\"),H=e=>e.closest(O)!==null,y=e=>$(e.textContent??\"\"),x=e=>{let r=u(e.getAttribute(\"aria-label\"));return r||u((e.getAttribute(\"aria-labelledby\")??\"\").split(/\\s+/).filter(Boolean).map(l=>e.ownerDocument.getElementById(l)?.textContent??\"\").join(\" \"))},P=e=>x(e)||u(e.textContent)||u(Array.from(e.querySelectorAll(\"img[alt]\")).map(r=>r.getAttribute(\"alt\")).join(\" \"))||u(e.getAttribute(\"title\")),T=e=>{let r=e.getAttribute(\"href\")??\"\";return{href:r.startsWith(\"#\")?r:e.href??r,name:P(e)}};u(i.title)||c(\"document-title\",null),!u(i.documentElement.getAttribute(\"lang\"))&&!n.locale&&c(\"document-language\",null);let M=n.pages??(n.pageHeight&&n.pageHeight>0?Math.ceil(i.documentElement.scrollHeight/n.pageHeight):1),C=[],v=[],R={\"masked-text\":[],\"filtered-text\":[],\"fixed-text\":[]},w=(e,r)=>{R[e].some(l=>l.contains(r))||(R[e].push(r),c(e,r))},V=a&&ne(i),G=o?Array.from(o.querySelectorAll(\"*\")).slice(0,j):[];for(let e of G){let r=e.tagName.toLowerCase();if(k.has(r)||H(e)||A(e))continue;if(r===\"a\"&&e.hasAttribute(\"href\")){let g=T(e);C.push(g),!g.name&&!p(e)&&c(\"link-name\",e)}if(!a)continue;let l=t.getComputedStyle(e),m=l.getPropertyValue(\"mask-image\")||l.getPropertyValue(\"-webkit-mask-image\");if(m&&m!==\"none\"&&y(e)&&w(\"masked-text\",e),l.filter&&l.filter!==\"none\"&&y(e)&&w(\"filtered-text\",e),l.position===\"fixed\"&&M>1&&y(e)&&w(\"fixed-text\",e),V)for(let g of[\"::before\",\"::after\"]){let U=re(t.getComputedStyle(e,g).content);U&&c(\"generated-text\",e,{text:U})}if(p(e))continue;r===\"img\"&&!E(e)?e.hasAttribute(\"alt\")||x(e)||u(e.getAttribute(\"title\"))||c(\"image-alt\",e):(r===\"canvas\"||e.getAttribute(\"role\")===\"img\"&&r!==\"img\")&&(x(e)||u(e.getAttribute(\"title\"))||u(e.querySelector(\":scope > title\")?.textContent)||c(\"figure-name\",e,{tag:r}));let h=/^h[1-6]$/.test(r)?Number(r[1]):e.getAttribute(\"role\")===\"heading\"?Number(e.getAttribute(\"aria-level\"))||2:0;h&&v.push({element:e,level:h}),r===\"table\"&&!E(e)&&Q(e,c)}let b=0;for(let{element:e,level:r}of v)(b===0?r!==1:r>b+1)&&c(\"heading-order\",e,{level:r,previous:b}),b=r;let N=[],W=a&&o?D(J(o)):\"\",L=0;for(let e of[\"header\",\"footer\"])for(let r of z(i,e,n[e])){for(let l of Array.from(r.querySelectorAll(\"a[href]\")))N.push(T(l));if(a)for(let{text:l,element:m}of K(r)){if(L>=q||W.includes(D(l)))continue;let h=s.length;c(\"running-text\",m,{text:l.slice(0,80),part:e}),s.length>h&&L++}}return{findings:s,links:C,templateLinks:N}}function z(t,n,i){if(i!==void 0){if(!i.trim())return[];let o=new DOMParser().parseFromString(`<!doctype html><body>${i}</body>`,\"text/html\");return o.body?[o.body]:[]}return Array.from(t.querySelectorAll(`.ff-running-${n}, .formfeed-chrome[data-ff-chrome=\"${n}\"]`))}function J(t){let n=[],i=o=>{if(o.nodeType===3){n.push(o.nodeValue??\"\");return}if(o.nodeType!==1)return;let s=o;if(!(k.has(s.tagName.toLowerCase())||s.matches(O)))for(let d of Array.from(o.childNodes))i(d)};return i(t),n.join(\" \")}function K(t){let n=[],i=o=>{let s=o.tagName.toLowerCase();if(k.has(s)||o.matches(_))return;let d=Array.from(o.children).some(a=>a.matches(_));for(let a of Array.from(o.childNodes))if(a.nodeType===1)i(a);else if(a.nodeType===3&&!d)for(let c of(a.nodeValue??\"\").split(/\\s*[\u00B7\u2022|]\\s*|\\s{2,}|\\n/)){let f=u(c);(f.toLowerCase().match(/[\\p{L}\\p{N}]+/gu)??[]).some(p=>!B.has(p))&&n.push({text:f,element:o})}};return i(t),n}function Q(t,n){let i=Array.from(t.rows);if(!(t.querySelector('th, [role=\"columnheader\"], [role=\"rowheader\"]')!==null)){i.length>=2&&n(\"table-headers\",t);return}let s=te(i),d=s.find(c=>c!==s[0]);d!==void 0&&n(\"table-rows\",t,{first:s[0]??0,other:d});let a=i.flatMap(c=>Array.from(c.cells).filter(f=>f.tagName===\"TD\"&&ee(f)));a[0]&&n(\"table-cell-empty\",a[0],{count:a.length})}var Z='img[alt]:not([alt=\"\"]), svg, canvas, input, select, textarea, button, meter, progress';function ee(t){return!/[^ \\t\\n\\r\\f]/.test(t.textContent??\"\")&&t.querySelector(Z)===null}function te(t){let n=[];return t.map(i=>{let o=[],s=0,d=()=>{for(;(n[s]??0)>0;)o[s]=n[s]-1,s++};for(let a of Array.from(i.cells)){d();let c=Math.max(1,a.rowSpan||1)-1;for(let f=Math.max(1,a.colSpan||1);f>0;f--)o[s++]=c}d();for(let a=s;a<n.length;a++)(n[a]??0)>0&&(o[a]=n[a]-1,s=a+1);return n=o,s})}function ne(t){let n=i=>{for(let o of Array.from(i??[])){let s=o;if(s.selectorText&&/::?(before|after)/.test(s.selectorText)&&s.style?.content||o.cssRules&&n(o.cssRules))return!0}return!1};for(let i of Array.from(t.styleSheets))try{if(n(i.cssRules))return!0}catch{return!0}return!1}function re(t){if(!t||t===\"none\"||t===\"normal\")return\"\";let n=(t.match(/\"(?:[^\"\\\\]|\\\\.)*\"/g)??[]).map(o=>o.slice(1,-1).replace(/\\\\(.)/g,\"$1\"));if(/\\bcounters?\\(/.test(t))return u(t).slice(0,80);let i=u(n.join(\"\"));return $(i)?i.slice(0,80):\"\"}window.formfeedAudit=t=>F(window,t);})();";
9
+ /** Bundled from src/frame/paged-print.entry.ts. */
10
+ export declare const pagedPrintRuntime = "\"use strict\";(()=>{var N=t=>!!t&&t.nodeType===1,y=t=>N(t)?t:t?.parentElement??null;function b(t,o){for(let e=t.firstElementChild;e;e=e.nextElementSibling)if(e.nodeName===o)return e;return null}var T=t=>Array.from(t.querySelectorAll(\":scope > tbody > tr, :scope > tr\"));function v(t,o){for(let e=t.parentElement;e&&!e.classList.contains(\"pagedjs_page_content\");e=e.parentElement)if(o.getComputedStyle(e).display.startsWith(\"inline\"))return!0;return!1}function O(t,o){for(let e=t;e&&e!==o;e=e.parentElement)for(let r=e.previousSibling;r;r=r.previousSibling)if(N(r)||(r.textContent??\"\").trim())return!0;return!1}function P(t){let o=t.cloneNode(!0);for(let e of[o,...Array.from(o.querySelectorAll(\"[id]\"))])e.id&&(e.setAttribute(\"data-id\",e.id),e.removeAttribute(\"id\"));return o.setAttribute(\"data-ff-repeated\",\"\"),o}function k(t,o){for(let e of Array.from(t.querySelectorAll(\"table > tfoot\"))){let r=e.nextElementSibling;for(;r&&r.nodeName!==\"TBODY\"&&r.nodeName!==\"TR\";)r=r.nextElementSibling;r&&o.getComputedStyle(e).display===\"table-footer-group\"&&e.parentNode?.appendChild(e)}}function H(t,o,e){let r=y(t),n=r?.closest(\"table\");if(!r||!n||!n.hasAttribute(\"data-split-from\")||n.hasAttribute(\"data-ff-head\")||(n.setAttribute(\"data-ff-head\",\"\"),b(n,\"THEAD\")))return;let a=y(o)?.closest(\"table\"),f=a&&b(a,\"THEAD\");if(!a||!f||v(n,e))return;let l=P(f),d=n.firstChild;for(;d&&(d.nodeName===\"CAPTION\"||d.nodeName===\"COLGROUP\");)d=d.nextSibling;if(n.insertBefore(l,d),e.getComputedStyle(l).display!==\"table-header-group\"){l.remove();return}for(let s=a.firstElementChild;s;s=s.nextElementSibling)s.nodeName===\"COLGROUP\"&&n.insertBefore(s.cloneNode(!0),l);let i=r.closest(\"tr\"),u=i?.parentElement;i&&u&&u.parentElement===n&&u.nodeName!==\"THEAD\"&&(i.style.breakInside=\"auto\",i.removeAttribute(\"data-break-inside\"))}function w(t,o,e,r,n){let a=t.startContainer,f=N(a)?a.childNodes[t.startOffset]??a:a,l=y(f);if(!l)return;let d=l.nodeName===\"TBODY\"?l.querySelector(\"tr\"):l.closest(\"tr\"),i=d?.closest(\"table\"),u=d?.parentElement;if(!d||!i||!u||u.nodeName===\"THEAD\"||u.nodeName===\"TFOOT\"||v(i,n))return;let s=T(i),h=s.indexOf(d);if(h<0)return;let m=h,E=0;if(h>0&&(f===d||f===u)){let p=r.querySelector(`[data-ref=\"${i.getAttribute(\"data-ref\")??\"\"}\"]`),g=p&&b(p,\"TFOOT\");if(g){let c=g.cloneNode(!0);i.appendChild(c),n.getComputedStyle(c).display===\"table-footer-group\"&&(E=c.getBoundingClientRect().height),c.remove()}let C=Math.round(e),S=c=>!c||Math.floor(c.getBoundingClientRect().bottom)+E<=C;for(;m>0&&!S(s[m-1]);)m--}if(m===0){if(i.hasAttribute(\"data-split-from\")||!b(i,\"THEAD\"))return;let p=i.previousElementSibling,g=i.getAttribute(\"data-previous-break-after\")===\"avoid\"&&p?p:i;return O(g,o)?(t.setStartBefore(g),t):void 0}let A=s[m];return m<h&&A&&t.setStartBefore(A),E&&i.setAttribute(\"data-ff-foot\",\"\"),t}function R(t,o){let e=t.querySelector(\"table[data-ff-foot]\");if(!e)return;e.removeAttribute(\"data-ff-foot\");let r=o.querySelector(`[data-ref=\"${e.getAttribute(\"data-ref\")??\"\"}\"]`),n=r&&b(r,\"TFOOT\");n&&e.appendChild(P(n))}function B(t){let o=t.querySelector(\".pagedjs_pagebox\");if(!o)return;let e=Array.from(o.children).filter(n=>!(n.getAttribute(\"class\")??\"\").includes(\"pagedjs_\")&&!n.hasAttribute(\"data-ff-fixed\"));if(!e.length)return;let r=o.ownerDocument.createElement(\"div\");r.setAttribute(\"data-ff-fixed\",\"\"),r.setAttribute(\"style\",\"grid-column: center; grid-row: page; position: relative; pointer-events: none;\");for(let n of e)\"style\"in n&&(n.style.pointerEvents=\"auto\"),r.appendChild(n);o.appendChild(r)}function x(t){t.formfeedMoveTableFeet=()=>k(t.document,t);let o=t.Paged;if(!o?.Handler)return;class e extends o.Handler{renderNode(n,a){H(n,a,t)}onOverflow(n,a,f){return n?w(n,a,f.bottom,this.chunker.source,t):void 0}afterOverflowRemoved(n,a){R(a,this.chunker.source)}afterPageLayout(n){B(n)}}o.registerHandlers(e)}x(window);})();";