@emailmaker/emailmaker 1.1.103 → 1.1.104

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +1 -0
  3. package/emailmaker-core.d92031f0.js +859 -0
  4. package/emailmaker-esm.js +11 -11
  5. package/{emailmaker-po.3529b1de.js → emailmaker-po.d92031f0.js} +1 -1
  6. package/emailmaker.d.ts +7 -0
  7. package/emailmaker.js +11 -11
  8. package/iframe/.vite/manifest.json +4 -4
  9. package/iframe/css/sandbox.css +2 -1
  10. package/iframe/{iframe-eblock.3529b1de.html → iframe-eblock.d92031f0.html} +2 -2
  11. package/iframe/{iframe.3529b1de.html → iframe.d92031f0.html} +2 -2
  12. package/iframe/js/discussHandlers.cyZrdU7c.js +88 -0
  13. package/iframe/js/{iframe-eblock.body.3529b1de.js → iframe-eblock.body.d92031f0.js} +1 -1
  14. package/iframe/js/iframe-eblock.js +2 -2
  15. package/iframe/js/{iframe.body.3529b1de.js → iframe.body.d92031f0.js} +71 -71
  16. package/iframe/js/iframe.js +2 -2
  17. package/package.json +1 -1
  18. package/runtime/react/index.js +1 -1
  19. package/static/core/{c9a013a6.js → 123fc796.js} +2 -2
  20. package/static/core/{a4d1fdc5.js → 1cdd0eaa.js} +1 -1
  21. package/static/core/{82f5152d.js → 20fae5cb.js} +1 -1
  22. package/static/core/{fbd1b42a.js → 25095aa6.js} +1 -1
  23. package/static/core/{6efc4a78.js → 2d570b04.js} +1 -1
  24. package/static/core/{9ca4cda3.js → 360afb24.js} +1 -1
  25. package/static/core/{73291b7c.js → 36f15937.js} +1 -1
  26. package/static/core/{682a8e2c.js → 432ad49d.js} +1 -1
  27. package/static/core/{3b315cf0.js → 448f5a93.js} +1 -1
  28. package/static/core/{9909de51.js → 4b7442c5.js} +1 -1
  29. package/static/core/5dc1b7fa.js +7 -0
  30. package/static/core/{71d7c710.js → 62b7892b.js} +1 -1
  31. package/static/core/{b3d5871e.js → 9596ee39.js} +1 -1
  32. package/static/core/{6dd152e5.js → a866296c.js} +3 -3
  33. package/static/core/{e420456c.js → ba4d44b4.js} +1 -1
  34. package/static/core/{c1460335.js → bd852c3b.js} +1 -1
  35. package/static/core/{91e9b542.js → c100433a.js} +1 -1
  36. package/static/core/{7fd8d843.js → c67adee2.js} +1 -1
  37. package/static/core/cd6c8848.js +28 -0
  38. package/static/core/{8fe408ef.js → d3f1d83d.js} +1 -1
  39. package/static/core/{5eaa42ac.js → dc45a033.js} +1 -1
  40. package/static/core/{b99c36c9.js → e76ed3bd.js} +1 -1
  41. package/static/core/{5de7475e.js → eee25d75.js} +1 -1
  42. package/static/core/{48387a41.js → f173fdc6.js} +1 -1
  43. package/static/core/{66be8204.js → fff40495.js} +1 -1
  44. package/static/umd-runtime/{runtime.D9PiY8Jx.js → runtime.Wy6_YzQx.js} +1 -1
  45. package/vendor/@emailmaker/ui-kit/package.json +1 -1
  46. package/emailmaker-core.3529b1de.js +0 -859
  47. package/iframe/js/discussHandlers.BrvInbT7.js +0 -88
  48. package/static/core/90715222.js +0 -28
  49. package/static/core/d4619860.js +0 -7
@@ -1,4 +1,4 @@
1
- __emailmaker__.define("static/core/71d7c710.js",["require","exports","module","static/core/5dc34752.js","static/core/3acdfe13.js"],function(g,$,L){const T=g("./5dc34752.js"),u=g("./3acdfe13.js");function w(t,e){const d={bytes:0,hidden:0,byKind:{}};for(const n of e)if(!(n.finishedAt>t.end||n.finishedAt<t.start)){if(n.transferred===null){d.hidden+=1;continue}d.bytes+=n.transferred,d.byKind[n.kind]=(d.byKind[n.kind]??0)+n.transferred}return d}var y="core:module:";function v(t){const e=[...t].sort((n,r)=>n.start-r.start),d=[];return e.forEach(n=>{const r=d[d.length-1];if(r&&n.start<=r.end){r.end=Math.max(r.end,n.end);return}d.push({start:n.start,end:n.end})}),d}function A(t,e){const d=Math.max(0,t.end-t.start),n=v(e.map(r=>({start:Math.max(t.start,r.startedAt),end:Math.min(t.end,r.finishedAt)})).filter(r=>r.end>r.start)).reduce((r,a)=>r+(a.end-a.start),0);return{networkMs:n,quietMs:d-n}}function P(t){const e=new Map;t.forEach(n=>{if(!n.phase.startsWith(y))return;const r=n.phase.slice(12),a=r.lastIndexOf(":");if(a<=0)return;const s=r.slice(0,a),o=r.slice(a+1),i=e.get(s)??{};o==="ask"?(i.ask=n.at,n.parent&&(i.parent=n.parent)):o==="loaded"?i.loaded=n.at:o==="deps"?i.deps=n.at:o==="ready"&&(i.ready=n.at),e.set(s,i)});const d=[];return e.forEach((n,r)=>{if(n.ask===void 0||n.ready===void 0)return;const a=n.ask,s=n.ready,o=n.deps,i=n.loaded;d.push({id:r,parent:n.parent,askedAt:a,loadedAt:i,depsAt:o,readyAt:s,networkMs:i===void 0?0:i-a,waitingMs:o===void 0?0:o-(i??a),executionMs:o===void 0?0:s-o})}),d}function S(t){const e=new Map;t.forEach(a=>{if(a.parent===void 0)return;const s=e.get(a.parent)??[];s.push(a),e.set(a.parent,s)});let d=t.filter(a=>a.parent===void 0).reduce((a,s)=>a===void 0||s.readyAt>a.readyAt?s:a,void 0);const n=[],r=new Set;for(;d&&!r.has(d.id);)r.add(d.id),n.push(d),d=(e.get(d.id)??[]).reduce((a,s)=>a===void 0||s.readyAt>a.readyAt?s:a,void 0);return n}function E(t,e){const d=u.detectMount(t),n=u.requiredPhases(d),r=new Map;t.forEach(l=>{n.includes(l.phase)&&!r.has(l.phase)&&r.set(l.phase,l.at)});const a=[...r.entries()].sort((l,h)=>l[1]-h[1]),s=q(d),o=a.findIndex(([l])=>l===s),i=o===-1?a:a.slice(0,o+1);return i.slice(1).map(([l,h],m)=>{const[x,p]=i[m],f=A({start:p,end:h},e);return{from:x,to:l,startedAt:p,endedAt:h,durationMs:h-p,networkMs:f.networkMs,quietMs:f.quietMs}})}function q(t){return t==="headless"?u.PHASES.showEnd:u.PHASES.canvasSettled}function M(t,e){const d=t.find(n=>n.phase===e);return d?d.at:null}function j(t,e){return t===null?e:e===null?t:Math.max(t,e)}function z(t,e){const d=u.missingRequiredPhases(t),n=d.length===0,r=t.reduce((p,f)=>p===null||f.at<p?f.at:p,null),a=u.detectMount(t),s=M(t,u.PHASES.canvasPainted),o=a==="headless"?M(t,u.PHASES.showEnd):j(M(t,u.PHASES.canvasSettled),M(t,u.PHASES.editorVisible)),i=P(t),l=i.reduce((p,f)=>p+f.executionMs,0),h=r!==null&&n&&(a==="headless"||s!==null),m=a==="headless"?o:s,x=h&&m!==null?A({start:r,end:m},e):{networkMs:0,quietMs:0};return{startedAt:r,paintedAt:s,settledAt:o,totalMs:h&&s!==null?s-r:null,settledMs:h&&o!==null?o-r:null,settleGapMs:h&&o!==null&&s!==null?o-s:null,segments:h?E(t,e):[],complete:n,missingPhases:d,networkMs:x.networkMs,quietMs:x.quietMs,moduleExecutionMs:l,criticalPath:S(i),transferBeforeFrame:h&&r!==null&&m!==null?w({start:r,end:m},e):{bytes:0,hidden:0,byKind:{}}}}function c(t){return t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function H(){return"dev"}function k(t,e){return{mode:H(),summary:z(t,e),marks:[...t],resources:[...e]}}function b(t){return t===null?"—":`${Math.round(t)} мс`}function _(t){return t==="dev"?"dev-сервер — AMD-ядро не работает, слой модулей пуст":t==="build"?"собранная версия":"режим неизвестен"}function R(t){const{summary:e}=t,d=e.complete?'<span class="ok">прогон полный</span>':'<span class="bad">прогон неполный — в сравнение не идёт</span>',n=e.missingPhases.length===0?"":`<p class="bad">Не хватает фаз: ${e.missingPhases.map(c).join(", ")}</p>`;return`
1
+ __emailmaker__.define("static/core/62b7892b.js",["require","exports","module","static/core/5dc34752.js","static/core/1245487b.js"],function(g,$,L){const T=g("./5dc34752.js"),u=g("./1245487b.js");function w(t,e){const d={bytes:0,hidden:0,byKind:{}};for(const n of e)if(!(n.finishedAt>t.end||n.finishedAt<t.start)){if(n.transferred===null){d.hidden+=1;continue}d.bytes+=n.transferred,d.byKind[n.kind]=(d.byKind[n.kind]??0)+n.transferred}return d}var y="core:module:";function v(t){const e=[...t].sort((n,r)=>n.start-r.start),d=[];return e.forEach(n=>{const r=d[d.length-1];if(r&&n.start<=r.end){r.end=Math.max(r.end,n.end);return}d.push({start:n.start,end:n.end})}),d}function A(t,e){const d=Math.max(0,t.end-t.start),n=v(e.map(r=>({start:Math.max(t.start,r.startedAt),end:Math.min(t.end,r.finishedAt)})).filter(r=>r.end>r.start)).reduce((r,a)=>r+(a.end-a.start),0);return{networkMs:n,quietMs:d-n}}function P(t){const e=new Map;t.forEach(n=>{if(!n.phase.startsWith(y))return;const r=n.phase.slice(12),a=r.lastIndexOf(":");if(a<=0)return;const s=r.slice(0,a),o=r.slice(a+1),i=e.get(s)??{};o==="ask"?(i.ask=n.at,n.parent&&(i.parent=n.parent)):o==="loaded"?i.loaded=n.at:o==="deps"?i.deps=n.at:o==="ready"&&(i.ready=n.at),e.set(s,i)});const d=[];return e.forEach((n,r)=>{if(n.ask===void 0||n.ready===void 0)return;const a=n.ask,s=n.ready,o=n.deps,i=n.loaded;d.push({id:r,parent:n.parent,askedAt:a,loadedAt:i,depsAt:o,readyAt:s,networkMs:i===void 0?0:i-a,waitingMs:o===void 0?0:o-(i??a),executionMs:o===void 0?0:s-o})}),d}function S(t){const e=new Map;t.forEach(a=>{if(a.parent===void 0)return;const s=e.get(a.parent)??[];s.push(a),e.set(a.parent,s)});let d=t.filter(a=>a.parent===void 0).reduce((a,s)=>a===void 0||s.readyAt>a.readyAt?s:a,void 0);const n=[],r=new Set;for(;d&&!r.has(d.id);)r.add(d.id),n.push(d),d=(e.get(d.id)??[]).reduce((a,s)=>a===void 0||s.readyAt>a.readyAt?s:a,void 0);return n}function E(t,e){const d=u.detectMount(t),n=u.requiredPhases(d),r=new Map;t.forEach(l=>{n.includes(l.phase)&&!r.has(l.phase)&&r.set(l.phase,l.at)});const a=[...r.entries()].sort((l,h)=>l[1]-h[1]),s=q(d),o=a.findIndex(([l])=>l===s),i=o===-1?a:a.slice(0,o+1);return i.slice(1).map(([l,h],m)=>{const[x,p]=i[m],f=A({start:p,end:h},e);return{from:x,to:l,startedAt:p,endedAt:h,durationMs:h-p,networkMs:f.networkMs,quietMs:f.quietMs}})}function q(t){return t==="headless"?u.PHASES.showEnd:u.PHASES.canvasSettled}function M(t,e){const d=t.find(n=>n.phase===e);return d?d.at:null}function j(t,e){return t===null?e:e===null?t:Math.max(t,e)}function z(t,e){const d=u.missingRequiredPhases(t),n=d.length===0,r=t.reduce((p,f)=>p===null||f.at<p?f.at:p,null),a=u.detectMount(t),s=M(t,u.PHASES.canvasPainted),o=a==="headless"?M(t,u.PHASES.showEnd):j(M(t,u.PHASES.canvasSettled),M(t,u.PHASES.editorVisible)),i=P(t),l=i.reduce((p,f)=>p+f.executionMs,0),h=r!==null&&n&&(a==="headless"||s!==null),m=a==="headless"?o:s,x=h&&m!==null?A({start:r,end:m},e):{networkMs:0,quietMs:0};return{startedAt:r,paintedAt:s,settledAt:o,totalMs:h&&s!==null?s-r:null,settledMs:h&&o!==null?o-r:null,settleGapMs:h&&o!==null&&s!==null?o-s:null,segments:h?E(t,e):[],complete:n,missingPhases:d,networkMs:x.networkMs,quietMs:x.quietMs,moduleExecutionMs:l,criticalPath:S(i),transferBeforeFrame:h&&r!==null&&m!==null?w({start:r,end:m},e):{bytes:0,hidden:0,byKind:{}}}}function c(t){return t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function H(){return"dev"}function k(t,e){return{mode:H(),summary:z(t,e),marks:[...t],resources:[...e]}}function b(t){return t===null?"—":`${Math.round(t)} мс`}function _(t){return t==="dev"?"dev-сервер — AMD-ядро не работает, слой модулей пуст":t==="build"?"собранная версия":"режим неизвестен"}function R(t){const{summary:e}=t,d=e.complete?'<span class="ok">прогон полный</span>':'<span class="bad">прогон неполный — в сравнение не идёт</span>',n=e.missingPhases.length===0?"":`<p class="bad">Не хватает фаз: ${e.missingPhases.map(c).join(", ")}</p>`;return`
2
2
  <header>
3
3
  <h1>Куда ушло время до показа письма</h1>
4
4
  <p class="mode">${c(_(t.mode))}</p>
@@ -1 +1 @@
1
- __emailmaker__.define("static/core/b3d5871e.js",["require","exports","module","static/core/5dc34752.js","static/core/3acdfe13.js","static/core/c1460335.js"],function(f,M,it){const D=f("./5dc34752.js"),s=f("./3acdfe13.js"),h=f("./c1460335.js");var F=1.25,O=80,$=3,k=1,p=16,L="p, div, td, th";function d(t){if(!t)return;const e=parseFloat(t);if(Number.isFinite(e))return t.trim().endsWith("pt")?e*4/3:e}function A(t){return t.style}function l(t){const e=A(t);if(!e)return!1;if(e.display==="none"||e.visibility==="hidden"||e.opacity==="0")return!0;const r=d(e.fontSize);return r!==void 0&&r<=k&&N(t)<=k?!0:d(e.maxHeight)===0}function u(t){for(let e=t;e;e=e.parentElement){const r=d(A(e)?.fontSize);if(r!==void 0)return r}return p}function w(t,e){for(const r of Array.from(t.childNodes)){if(s.isTextNode(r)){const n=r.data.trim().length;if(n){const i=u(r.parentElement);e.set(i,(e.get(i)??0)+n)}continue}!s.isElement(r)||l(r)||w(r,e)}}function j(t){const e=new Map;w(t,e);let r=p,n=0;for(const[i,o]of e)o>n&&(r=i,n=o);return r}function N(t){let e=u(t);for(const r of Array.from(t.querySelectorAll("*")))r.textContent?.trim()&&(e=Math.max(e,u(r)));return e}function q(t,e){return t.querySelector("a")?.textContent?.trim()===e}function b(t){return Array.from(t.querySelectorAll(L)).some(e=>e.textContent?.trim())}function G(t){const e=j(t),r=[];for(const o of Array.from(t.querySelectorAll(L))){if(l(o)||b(o))continue;const a=o.textContent?.trim()??"";if(!a||a.length>O||q(o,a))continue;const c=N(o);c>=e*F&&r.push({elem:o,size:c})}const n=[...new Set(r.map(o=>o.size))].sort((o,a)=>a-o),i=new Map;for(const{elem:o,size:a}of r)i.set(o,Math.min(n.indexOf(a)+1,$));return{headingLevels:i}}var R=D.__exportAll({markdownAnchor:()=>Y,markdownBlock:()=>X,markdownImage:()=>Q,markdownInline:()=>J,markdownOrderedList:()=>Z,markdownStrong:()=>K,markdownUnorderedList:()=>U}),E=h.formatList,_=20;function W(t){return!t||t.includes("%")?NaN:parseFloat(t)}function m(t,e){const r=t.style,n=e==="width"?"maxWidth":"maxHeight";for(const i of[t.getAttribute(e),r?.[e],r?.[n]]){const o=W(i);if(Number.isFinite(o))return o}return NaN}function x(t){return(t.getAttribute("alt")??"").trim()?!1:m(t,"width")<=_||m(t,"height")<=_}function S(t){return t.replace(/ /g,"%20").replace(/\(/g,"%28").replace(/\)/g,"%29")}function B(t){const e=t.getAttribute("href");return!e||e.startsWith("#")?"":e}function g(t){for(const e of Array.from(t.childNodes)){if(s.isTextNode(e)){if(/\S/.test(e.data))return!0;continue}if(!s.isElement(e))continue;const r=e.tagName.toLowerCase();if(r==="img"){if(e.getAttribute("src")&&!x(e))return!0;continue}if(r==="hr"||r==="a"&&B(e)&&v(e)||g(e))return!0}return!1}function v(t){const e=(t.getAttribute("title")??"").trim();if(e)return e;const r=t.querySelector("img");return r?(r.getAttribute("title")??"").trim():""}function y(t,e,r){r.addLiteral("["),e(),r.addLiteral(`](${S(t)})`)}function I(t,e){return t.parentElement?.tagName.toLowerCase()!=="li"?e:{...e,leadingLineBreaks:1,trailingLineBreaks:1}}var U=(t,e,r,n)=>{E(t,e,r,I(t,n),()=>"- ")},Z=(t,e,r,n)=>{let i=Number(t.getAttribute("start")??"1")||1;E(t,e,r,I(t,n),()=>`${i++}. `)},V={h1:1,h2:2,h3:3,h4:4,h5:5,h6:6};function z(t,e){return V[t.tagName.toLowerCase()]??e.metadata?.headingLevels.get(t)}var X=(t,e,r,n)=>{if(l(t)||!g(t))return;const i=z(t,r);r.openBlock({leadingLineBreaks:i?2:n.leadingLineBreaks}),i&&r.addLiteral(`${"#".repeat(i)} `),e(Array.from(t.childNodes),r),r.closeBlock({trailingLineBreaks:i?2:n.trailingLineBreaks})};function P(t,e){for(let r=t.parentElement;r;r=r.parentElement)if(z(r,e))return!0;return!1}function C(t){return s.isTextNode(t)?!/\S/.test(t.data):s.isElement(t)&&t.tagName.toLowerCase()==="br"}var K=(t,e,r)=>{const n=Array.from(t.childNodes);if(P(t,r)){e(n,r);return}let i=0,o=n.length;for(;i<o&&C(n[i]);)i++;for(;o>i&&C(n[o-1]);)o--;const a=n.slice(i,o),c=a.map(nt=>nt.textContent??"").join("");if(!a.length||c!==c.trim()){e(n,r);return}e(n.slice(0,i),r),r.addLiteral("**"),e(a,r),r.addLiteral("**"),e(n.slice(o),r)},J=(t,e,r)=>{l(t)||e(Array.from(t.childNodes),r)};function T(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function H(t,e){const r=m(t,e);return Number.isFinite(r)?` ${e}="${Math.round(r)}"`:""}var Q=(t,e,r)=>{const n=t.getAttribute("src");if(!n||x(t))return;const i=t.getAttribute("alt")??"",o=H(t,"width"),a=H(t,"height");if(o||a){r.addLiteral(`<img src="${T(n)}" alt="${T(i)}"${o}${a}>`);return}r.addLiteral("!["),r.addInline(i),r.addLiteral(`](${S(n)})`)},Y=(t,e,r)=>{const n=B(t);if(!n){e(Array.from(t.childNodes),r);return}if(g(t)){y(n,()=>e(Array.from(t.childNodes),r),r);return}const i=v(t);i&&y(n,()=>r.addInline(i),r)},tt={"\\":"\\\\","`":"\\`","*":"\\*",_:"\\_","[":"\\[","]":"\\]","#":"\\#",">":"\\>"},et={wordwrap:!1,encodeCharacters:tt,baseElements:{selectors:["body"]},formatters:R,selectors:[{selector:"*",format:"markdownInline"},{selector:"p",format:"markdownBlock",options:{leadingLineBreaks:2,trailingLineBreaks:2}},{selector:"div",format:"markdownBlock",options:{leadingLineBreaks:1,trailingLineBreaks:1}},{selector:"td",format:"markdownBlock",options:{leadingLineBreaks:1,trailingLineBreaks:1}},{selector:"table",format:"markdownBlock",options:{leadingLineBreaks:2,trailingLineBreaks:2}},{selector:"th",format:"markdownBlock",options:{leadingLineBreaks:1,trailingLineBreaks:1}},...["h1","h2","h3","h4","h5","h6"].map(t=>({selector:t,format:"markdownBlock"})),{selector:"a",format:"markdownAnchor"},{selector:"img",format:"markdownImage"},{selector:"ul",format:"markdownUnorderedList"},{selector:"ol",format:"markdownOrderedList"},{selector:"hr",format:"blockString",options:{string:"---",leadingLineBreaks:2,trailingLineBreaks:2}},{selector:"b",format:"markdownStrong"},{selector:"strong",format:"markdownStrong"},{selector:"i",format:"inlineSurround",options:{prefix:"*",suffix:"*"}},{selector:"em",format:"inlineSurround",options:{prefix:"*",suffix:"*"}}]};function rt(t){return h.convert(t,et,G(t))}M.htmlToMarkdown=rt});
1
+ __emailmaker__.define("static/core/9596ee39.js",["require","exports","module","static/core/5dc34752.js","static/core/1245487b.js","static/core/bd852c3b.js"],function(f,M,it){const D=f("./5dc34752.js"),s=f("./1245487b.js"),h=f("./bd852c3b.js");var F=1.25,O=80,$=3,k=1,p=16,L="p, div, td, th";function d(t){if(!t)return;const e=parseFloat(t);if(Number.isFinite(e))return t.trim().endsWith("pt")?e*4/3:e}function A(t){return t.style}function l(t){const e=A(t);if(!e)return!1;if(e.display==="none"||e.visibility==="hidden"||e.opacity==="0")return!0;const r=d(e.fontSize);return r!==void 0&&r<=k&&N(t)<=k?!0:d(e.maxHeight)===0}function u(t){for(let e=t;e;e=e.parentElement){const r=d(A(e)?.fontSize);if(r!==void 0)return r}return p}function w(t,e){for(const r of Array.from(t.childNodes)){if(s.isTextNode(r)){const n=r.data.trim().length;if(n){const i=u(r.parentElement);e.set(i,(e.get(i)??0)+n)}continue}!s.isElement(r)||l(r)||w(r,e)}}function j(t){const e=new Map;w(t,e);let r=p,n=0;for(const[i,o]of e)o>n&&(r=i,n=o);return r}function N(t){let e=u(t);for(const r of Array.from(t.querySelectorAll("*")))r.textContent?.trim()&&(e=Math.max(e,u(r)));return e}function q(t,e){return t.querySelector("a")?.textContent?.trim()===e}function b(t){return Array.from(t.querySelectorAll(L)).some(e=>e.textContent?.trim())}function G(t){const e=j(t),r=[];for(const o of Array.from(t.querySelectorAll(L))){if(l(o)||b(o))continue;const a=o.textContent?.trim()??"";if(!a||a.length>O||q(o,a))continue;const c=N(o);c>=e*F&&r.push({elem:o,size:c})}const n=[...new Set(r.map(o=>o.size))].sort((o,a)=>a-o),i=new Map;for(const{elem:o,size:a}of r)i.set(o,Math.min(n.indexOf(a)+1,$));return{headingLevels:i}}var R=D.__exportAll({markdownAnchor:()=>Y,markdownBlock:()=>X,markdownImage:()=>Q,markdownInline:()=>J,markdownOrderedList:()=>Z,markdownStrong:()=>K,markdownUnorderedList:()=>U}),E=h.formatList,_=20;function W(t){return!t||t.includes("%")?NaN:parseFloat(t)}function m(t,e){const r=t.style,n=e==="width"?"maxWidth":"maxHeight";for(const i of[t.getAttribute(e),r?.[e],r?.[n]]){const o=W(i);if(Number.isFinite(o))return o}return NaN}function x(t){return(t.getAttribute("alt")??"").trim()?!1:m(t,"width")<=_||m(t,"height")<=_}function S(t){return t.replace(/ /g,"%20").replace(/\(/g,"%28").replace(/\)/g,"%29")}function B(t){const e=t.getAttribute("href");return!e||e.startsWith("#")?"":e}function g(t){for(const e of Array.from(t.childNodes)){if(s.isTextNode(e)){if(/\S/.test(e.data))return!0;continue}if(!s.isElement(e))continue;const r=e.tagName.toLowerCase();if(r==="img"){if(e.getAttribute("src")&&!x(e))return!0;continue}if(r==="hr"||r==="a"&&B(e)&&v(e)||g(e))return!0}return!1}function v(t){const e=(t.getAttribute("title")??"").trim();if(e)return e;const r=t.querySelector("img");return r?(r.getAttribute("title")??"").trim():""}function y(t,e,r){r.addLiteral("["),e(),r.addLiteral(`](${S(t)})`)}function I(t,e){return t.parentElement?.tagName.toLowerCase()!=="li"?e:{...e,leadingLineBreaks:1,trailingLineBreaks:1}}var U=(t,e,r,n)=>{E(t,e,r,I(t,n),()=>"- ")},Z=(t,e,r,n)=>{let i=Number(t.getAttribute("start")??"1")||1;E(t,e,r,I(t,n),()=>`${i++}. `)},V={h1:1,h2:2,h3:3,h4:4,h5:5,h6:6};function z(t,e){return V[t.tagName.toLowerCase()]??e.metadata?.headingLevels.get(t)}var X=(t,e,r,n)=>{if(l(t)||!g(t))return;const i=z(t,r);r.openBlock({leadingLineBreaks:i?2:n.leadingLineBreaks}),i&&r.addLiteral(`${"#".repeat(i)} `),e(Array.from(t.childNodes),r),r.closeBlock({trailingLineBreaks:i?2:n.trailingLineBreaks})};function P(t,e){for(let r=t.parentElement;r;r=r.parentElement)if(z(r,e))return!0;return!1}function C(t){return s.isTextNode(t)?!/\S/.test(t.data):s.isElement(t)&&t.tagName.toLowerCase()==="br"}var K=(t,e,r)=>{const n=Array.from(t.childNodes);if(P(t,r)){e(n,r);return}let i=0,o=n.length;for(;i<o&&C(n[i]);)i++;for(;o>i&&C(n[o-1]);)o--;const a=n.slice(i,o),c=a.map(nt=>nt.textContent??"").join("");if(!a.length||c!==c.trim()){e(n,r);return}e(n.slice(0,i),r),r.addLiteral("**"),e(a,r),r.addLiteral("**"),e(n.slice(o),r)},J=(t,e,r)=>{l(t)||e(Array.from(t.childNodes),r)};function T(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function H(t,e){const r=m(t,e);return Number.isFinite(r)?` ${e}="${Math.round(r)}"`:""}var Q=(t,e,r)=>{const n=t.getAttribute("src");if(!n||x(t))return;const i=t.getAttribute("alt")??"",o=H(t,"width"),a=H(t,"height");if(o||a){r.addLiteral(`<img src="${T(n)}" alt="${T(i)}"${o}${a}>`);return}r.addLiteral("!["),r.addInline(i),r.addLiteral(`](${S(n)})`)},Y=(t,e,r)=>{const n=B(t);if(!n){e(Array.from(t.childNodes),r);return}if(g(t)){y(n,()=>e(Array.from(t.childNodes),r),r);return}const i=v(t);i&&y(n,()=>r.addInline(i),r)},tt={"\\":"\\\\","`":"\\`","*":"\\*",_:"\\_","[":"\\[","]":"\\]","#":"\\#",">":"\\>"},et={wordwrap:!1,encodeCharacters:tt,baseElements:{selectors:["body"]},formatters:R,selectors:[{selector:"*",format:"markdownInline"},{selector:"p",format:"markdownBlock",options:{leadingLineBreaks:2,trailingLineBreaks:2}},{selector:"div",format:"markdownBlock",options:{leadingLineBreaks:1,trailingLineBreaks:1}},{selector:"td",format:"markdownBlock",options:{leadingLineBreaks:1,trailingLineBreaks:1}},{selector:"table",format:"markdownBlock",options:{leadingLineBreaks:2,trailingLineBreaks:2}},{selector:"th",format:"markdownBlock",options:{leadingLineBreaks:1,trailingLineBreaks:1}},...["h1","h2","h3","h4","h5","h6"].map(t=>({selector:t,format:"markdownBlock"})),{selector:"a",format:"markdownAnchor"},{selector:"img",format:"markdownImage"},{selector:"ul",format:"markdownUnorderedList"},{selector:"ol",format:"markdownOrderedList"},{selector:"hr",format:"blockString",options:{string:"---",leadingLineBreaks:2,trailingLineBreaks:2}},{selector:"b",format:"markdownStrong"},{selector:"strong",format:"markdownStrong"},{selector:"i",format:"inlineSurround",options:{prefix:"*",suffix:"*"}},{selector:"em",format:"inlineSurround",options:{prefix:"*",suffix:"*"}}]};function rt(t){return h.convert(t,et,G(t))}M.htmlToMarkdown=rt});