mirror of
https://github.com/bunny-lab-io/Borealis.git
synced 2026-02-06 15:40:30 -07:00
12 lines
11 KiB
JavaScript
12 lines
11 KiB
JavaScript
import{n as f}from"./micromark-util-sanitize-uri-nvkIJkgW.js";import{p as b,a as x,b as C}from"./unist-util-position-KiAvrw8y.js";import{t as L}from"./trim-lines-D8znQY54.js";import{d as P}from"./mdast-util-definitions-CfSXY7bG.js";import{v as B}from"./unist-util-visit-SwKB2sUE.js";import{g as I}from"./unist-util-generated-CMz5gPdA.js";function A(t,e){const n={type:"element",tagName:"blockquote",properties:{},children:t.wrap(t.all(e),!0)};return t.patch(e,n),t.applyData(e,n)}function O(t,e){const n={type:"element",tagName:"br",properties:{},children:[]};return t.patch(e,n),[t.applyData(e,n),{type:"text",value:`
|
|
`}]}function S(t,e){const n=e.value?e.value+`
|
|
`:"",r=e.lang?e.lang.match(/^[^ \t]+(?=[ \t]|$)/):null,i={};r&&(i.className=["language-"+r]);let a={type:"element",tagName:"code",properties:i,children:[{type:"text",value:n}]};return e.meta&&(a.data={meta:e.meta}),t.patch(e,a),a=t.applyData(e,a),a={type:"element",tagName:"pre",properties:{},children:[a]},t.patch(e,a),a}function R(t,e){const n={type:"element",tagName:"del",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function T(t,e){const n={type:"element",tagName:"em",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function v(t,e){const n=String(e.identifier).toUpperCase(),r=f(n.toLowerCase()),i=t.footnoteOrder.indexOf(n);let a;i===-1?(t.footnoteOrder.push(n),t.footnoteCounts[n]=1,a=t.footnoteOrder.length):(t.footnoteCounts[n]++,a=i+1);const l=t.footnoteCounts[n],u={type:"element",tagName:"a",properties:{href:"#"+t.clobberPrefix+"fn-"+r,id:t.clobberPrefix+"fnref-"+r+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};t.patch(e,u);const s={type:"element",tagName:"sup",properties:{},children:[u]};return t.patch(e,s),t.applyData(e,s)}function H(t,e){const n=t.footnoteById;let r=1;for(;r in n;)r++;const i=String(r);return n[i]={type:"footnoteDefinition",identifier:i,children:[{type:"paragraph",children:e.children}],position:e.position},v(t,{type:"footnoteReference",identifier:i,position:e.position})}function U(t,e){const n={type:"element",tagName:"h"+e.depth,properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function F(t,e){if(t.dangerous){const n={type:"raw",value:e.value};return t.patch(e,n),t.applyData(e,n)}return null}function w(t,e){const n=e.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(e.label||e.identifier)+"]"),e.type==="imageReference")return{type:"text",value:"!["+e.alt+r};const i=t.all(e),a=i[0];a&&a.type==="text"?a.value="["+a.value:i.unshift({type:"text",value:"["});const l=i[i.length-1];return l&&l.type==="text"?l.value+=r:i.push({type:"text",value:r}),i}function E(t,e){const n=t.definition(e.identifier);if(!n)return w(t,e);const r={src:f(n.url||""),alt:e.alt};n.title!==null&&n.title!==void 0&&(r.title=n.title);const i={type:"element",tagName:"img",properties:r,children:[]};return t.patch(e,i),t.applyData(e,i)}function q(t,e){const n={src:f(e.url)};e.alt!==null&&e.alt!==void 0&&(n.alt=e.alt),e.title!==null&&e.title!==void 0&&(n.title=e.title);const r={type:"element",tagName:"img",properties:n,children:[]};return t.patch(e,r),t.applyData(e,r)}function J(t,e){const n={type:"text",value:e.value.replace(/\r?\n|\r/g," ")};t.patch(e,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return t.patch(e,r),t.applyData(e,r)}function z(t,e){const n=t.definition(e.identifier);if(!n)return w(t,e);const r={href:f(n.url||"")};n.title!==null&&n.title!==void 0&&(r.title=n.title);const i={type:"element",tagName:"a",properties:r,children:t.all(e)};return t.patch(e,i),t.applyData(e,i)}function V(t,e){const n={href:f(e.url)};e.title!==null&&e.title!==void 0&&(n.title=e.title);const r={type:"element",tagName:"a",properties:n,children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}function $(t,e,n){const r=t.all(e),i=n?j(n):D(e),a={},l=[];if(typeof e.checked=="boolean"){const o=r[0];let p;o&&o.type==="element"&&o.tagName==="p"?p=o:(p={type:"element",tagName:"p",properties:{},children:[]},r.unshift(p)),p.children.length>0&&p.children.unshift({type:"text",value:" "}),p.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:e.checked,disabled:!0},children:[]}),a.className=["task-list-item"]}let u=-1;for(;++u<r.length;){const o=r[u];(i||u!==0||o.type!=="element"||o.tagName!=="p")&&l.push({type:"text",value:`
|
|
`}),o.type==="element"&&o.tagName==="p"&&!i?l.push(...o.children):l.push(o)}const s=r[r.length-1];s&&(i||s.type!=="element"||s.tagName!=="p")&&l.push({type:"text",value:`
|
|
`});const c={type:"element",tagName:"li",properties:a,children:l};return t.patch(e,c),t.applyData(e,c)}function j(t){let e=!1;if(t.type==="list"){e=t.spread||!1;const n=t.children;let r=-1;for(;!e&&++r<n.length;)e=D(n[r])}return e}function D(t){const e=t.spread;return e??t.children.length>1}function G(t,e){const n={},r=t.all(e);let i=-1;for(typeof e.start=="number"&&e.start!==1&&(n.start=e.start);++i<r.length;){const l=r[i];if(l.type==="element"&&l.tagName==="li"&&l.properties&&Array.isArray(l.properties.className)&&l.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const a={type:"element",tagName:e.ordered?"ol":"ul",properties:n,children:t.wrap(r,!0)};return t.patch(e,a),t.applyData(e,a)}function K(t,e){const n={type:"element",tagName:"p",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function M(t,e){const n={type:"root",children:t.wrap(t.all(e))};return t.patch(e,n),t.applyData(e,n)}function Q(t,e){const n={type:"element",tagName:"strong",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function W(t,e){const n=t.all(e),r=n.shift(),i=[];if(r){const l={type:"element",tagName:"thead",properties:{},children:t.wrap([r],!0)};t.patch(e.children[0],l),i.push(l)}if(n.length>0){const l={type:"element",tagName:"tbody",properties:{},children:t.wrap(n,!0)},u=b(e.children[1]),s=x(e.children[e.children.length-1]);u.line&&s.line&&(l.position={start:u,end:s}),i.push(l)}const a={type:"element",tagName:"table",properties:{},children:t.wrap(i,!0)};return t.patch(e,a),t.applyData(e,a)}function X(t,e,n){const r=n?n.children:void 0,a=(r?r.indexOf(e):1)===0?"th":"td",l=n&&n.type==="table"?n.align:void 0,u=l?l.length:e.children.length;let s=-1;const c=[];for(;++s<u;){const p=e.children[s],h={},N=l?l[s]:void 0;N&&(h.align=N);let y={type:"element",tagName:a,properties:h,children:[]};p&&(y.children=t.all(p),t.patch(p,y),y=t.applyData(e,y)),c.push(y)}const o={type:"element",tagName:"tr",properties:{},children:t.wrap(c,!0)};return t.patch(e,o),t.applyData(e,o)}function Y(t,e){const n={type:"element",tagName:"td",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function Z(t,e){const n={type:"text",value:L(String(e.value))};return t.patch(e,n),t.applyData(e,n)}function _(t,e){const n={type:"element",tagName:"hr",properties:{},children:[]};return t.patch(e,n),t.applyData(e,n)}const ee={blockquote:A,break:O,code:S,delete:R,emphasis:T,footnoteReference:v,footnote:H,heading:U,html:F,imageReference:E,image:q,inlineCode:J,linkReference:z,link:V,listItem:$,list:G,paragraph:K,root:M,strong:Q,table:W,tableCell:Y,tableRow:X,text:Z,thematicBreak:_,toml:m,yaml:m,definition:m,footnoteDefinition:m};function m(){return null}const d={}.hasOwnProperty;function te(t,e){const n=e||{},r=n.allowDangerousHtml||!1,i={};return l.dangerous=r,l.clobberPrefix=n.clobberPrefix===void 0||n.clobberPrefix===null?"user-content-":n.clobberPrefix,l.footnoteLabel=n.footnoteLabel||"Footnotes",l.footnoteLabelTagName=n.footnoteLabelTagName||"h2",l.footnoteLabelProperties=n.footnoteLabelProperties||{className:["sr-only"]},l.footnoteBackLabel=n.footnoteBackLabel||"Back to content",l.unknownHandler=n.unknownHandler,l.passThrough=n.passThrough,l.handlers={...ee,...n.handlers},l.definition=P(t),l.footnoteById=i,l.footnoteOrder=[],l.footnoteCounts={},l.patch=ne,l.applyData=re,l.one=u,l.all=s,l.wrap=ie,l.augment=a,B(t,"footnoteDefinition",c=>{const o=String(c.identifier).toUpperCase();d.call(i,o)||(i[o]=c)}),l;function a(c,o){if(c&&"data"in c&&c.data){const p=c.data;p.hName&&(o.type!=="element"&&(o={type:"element",tagName:"",properties:{},children:[]}),o.tagName=p.hName),o.type==="element"&&p.hProperties&&(o.properties={...o.properties,...p.hProperties}),"children"in o&&o.children&&p.hChildren&&(o.children=p.hChildren)}if(c){const p="type"in c?c:{position:c};I(p)||(o.position={start:b(p),end:x(p)})}return o}function l(c,o,p,h){return Array.isArray(p)&&(h=p,p={}),a(c,{type:"element",tagName:o,properties:p||{},children:h||[]})}function u(c,o){return k(l,c,o)}function s(c){return g(l,c)}}function ne(t,e){t.position&&(e.position=C(t))}function re(t,e){let n=e;if(t&&t.data){const r=t.data.hName,i=t.data.hChildren,a=t.data.hProperties;typeof r=="string"&&(n.type==="element"?n.tagName=r:n={type:"element",tagName:r,properties:{},children:[]}),n.type==="element"&&a&&(n.properties={...n.properties,...a}),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function k(t,e,n){const r=e&&e.type;if(!r)throw new Error("Expected node, got `"+e+"`");return d.call(t.handlers,r)?t.handlers[r](t,e,n):t.passThrough&&t.passThrough.includes(r)?"children"in e?{...e,children:g(t,e)}:e:t.unknownHandler?t.unknownHandler(t,e,n):le(t,e)}function g(t,e){const n=[];if("children"in e){const r=e.children;let i=-1;for(;++i<r.length;){const a=k(t,r[i],e);if(a){if(i&&r[i-1].type==="break"&&(!Array.isArray(a)&&a.type==="text"&&(a.value=a.value.replace(/^\s+/,"")),!Array.isArray(a)&&a.type==="element")){const l=a.children[0];l&&l.type==="text"&&(l.value=l.value.replace(/^\s+/,""))}Array.isArray(a)?n.push(...a):n.push(a)}}}return n}function le(t,e){const n=e.data||{},r="value"in e&&!(d.call(n,"hProperties")||d.call(n,"hChildren"))?{type:"text",value:e.value}:{type:"element",tagName:"div",properties:{},children:g(t,e)};return t.patch(e,r),t.applyData(e,r)}function ie(t,e){const n=[];let r=-1;for(e&&n.push({type:"text",value:`
|
|
`});++r<t.length;)r&&n.push({type:"text",value:`
|
|
`}),n.push(t[r]);return e&&t.length>0&&n.push({type:"text",value:`
|
|
`}),n}function ae(t){const e=[];let n=-1;for(;++n<t.footnoteOrder.length;){const r=t.footnoteById[t.footnoteOrder[n]];if(!r)continue;const i=t.all(r),a=String(r.identifier).toUpperCase(),l=f(a.toLowerCase());let u=0;const s=[];for(;++u<=t.footnoteCounts[a];){const p={type:"element",tagName:"a",properties:{href:"#"+t.clobberPrefix+"fnref-"+l+(u>1?"-"+u:""),dataFootnoteBackref:!0,className:["data-footnote-backref"],ariaLabel:t.footnoteBackLabel},children:[{type:"text",value:"↩"}]};u>1&&p.children.push({type:"element",tagName:"sup",children:[{type:"text",value:String(u)}]}),s.length>0&&s.push({type:"text",value:" "}),s.push(p)}const c=i[i.length-1];if(c&&c.type==="element"&&c.tagName==="p"){const p=c.children[c.children.length-1];p&&p.type==="text"?p.value+=" ":c.children.push({type:"text",value:" "}),c.children.push(...s)}else i.push(...s);const o={type:"element",tagName:"li",properties:{id:t.clobberPrefix+"fn-"+l},children:t.wrap(i,!0)};t.patch(r,o),e.push(o)}if(e.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:t.footnoteLabelTagName,properties:{...JSON.parse(JSON.stringify(t.footnoteLabelProperties)),id:"footnote-label"},children:[{type:"text",value:t.footnoteLabel}]},{type:"text",value:`
|
|
`},{type:"element",tagName:"ol",properties:{},children:t.wrap(e,!0)},{type:"text",value:`
|
|
`}]}}function he(t,e){const n=te(t,e),r=n.one(t,null),i=ae(n);return i&&r.children.push({type:"text",value:`
|
|
`},i),Array.isArray(r)?{type:"root",children:r}:r}export{he as t};
|