@dvina/artifact-renderer-viewer 0.0.45 → 0.0.47
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.
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BHU2svhu.js","assets/react-vendor-Dhb16r3m.js","assets/mermaid.core-UUGPJ6yi.js","assets/pdf-renderer-DUYqGnQu.js","assets/pdf-vendor-Cxe0BN_5.js","assets/jszip-vendor-D1v1h9Q9.js","assets/pptx-renderer-DPSAG5_x.js","assets/docx-renderer-Bws5M_Ee.js","assets/docx-vendor-DalbKGQU.js","assets/spreadsheet-renderer-WVtOHmRi.js","assets/xlsx-vendor-BUW7exb-.js","assets/zip-renderer-oijmTXXF.js","assets/epub-renderer-C-aCqy3m.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as h,d as yt,j as v,_ as se,e as Ut,v as _n,o as he,u as me,i as Ye,n as Ae,k as Ie,l as Dn,t as qt,E as On,m as Ze,p as ye,q as Q,x as Fn,y as zn,z as ae,A as _e,B as $n,C as xe,D as ue,F as Vn,M as Un,G as qn}from"./react-vendor-Dhb16r3m.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();const Hn=["ui/message","ui/open-link","dvina/open-target"];function Te(e){return e==="html"||e==="widget"}const Ht="dvina-artifact-renderer",Me="1.0",Bn=new Set(["viewer.init","viewer.load-document","viewer.set-theme","viewer.set-safe-area","viewer.go-to-page","viewer.send-artifact-data","viewer.append-html","viewer.complete-html-stream","viewer.abort-html-stream","viewer.widget-response"]),Wn=new Set(["viewer.ready","viewer.document-loaded","viewer.page-changed","viewer.artifact-event","viewer.widget-request","viewer.resize","viewer.scroll","viewer.telemetry","viewer.error","viewer.unsupported"]),Gn=new Set(["viewer.ack"]);function _(e){return typeof e=="object"&&e!==null}function j(e){return typeof e=="string"&&e.length>0}function Kn(e){return Array.isArray(e)&&e.every(j)}function Xn(e){return e==="load-document"||e==="pagination"||e==="resize-notifications"||e==="artifact-runtime"}function Yn(e){return e==="allow-downloads"||e==="allow-forms"||e==="allow-modals"||e==="allow-pointer-lock"||e==="allow-popups"||e==="allow-popups-to-escape-sandbox"||e==="allow-same-origin"||e==="allow-scripts"||e==="allow-top-navigation-by-user-activation"}function Bt(e){return e==="pdf"||e==="pptx"||e==="docx"||e==="xls"||e==="xlsx"||e==="csv"||e==="audio"||e==="image"||e==="video"||e==="zip"||e==="epub"||e==="text"||e==="code"||e==="html"||e==="markdown"||e==="mermaid"||e==="json"||e==="jsonl"||e==="ndjson"||e==="tsv"||e==="xml"||e==="toml"||e==="ini"||e==="dotenv"||e==="yaml"||e==="widget"||e==="unknown"}function oe(e){return e===null||typeof e=="string"||typeof e=="boolean"?!0:typeof e=="number"?Number.isFinite(e):Array.isArray(e)?e.every(oe):_(e)?Object.values(e).every(oe):!1}function Qe(e){return _(e)&&!Array.isArray(e)&&["top","right","bottom","left"].every(t=>{const n=e[t];return n===void 0||typeof n=="number"&&Number.isFinite(n)&&n>=0})}function Je(e){if(!_(e)||e.mode!=="light"&&e.mode!=="dark")return!1;const t=n=>n===void 0||_(n)&&Object.values(n).every(r=>r===void 0||typeof r=="string");return t(e.tokens)&&t(e.variables)}function Wt(e){if(!_(e))return!1;const t=e.source;if(!_(t))return!1;const n=t.kind==="url"&&j(t.url)||t.kind==="session"&&j(t.url)&&j(t.sessionId)||t.kind==="stream",r=e.renderOptions,a=r===void 0||_(r)&&(r.spreadsheetMode===void 0||r.spreadsheetMode==="fast"||r.spreadsheetMode==="styled")&&(r.codeLanguage===void 0||j(r.codeLanguage))&&(r.html===void 0||_(r.html)&&(r.html.revisionId===void 0||j(r.html.revisionId))&&(r.html.artifactData===void 0||oe(r.html.artifactData))&&(r.html.bootstrap===void 0||r.html.bootstrap==="auto"||r.html.bootstrap==="off")&&(r.html.execution===void 0||r.html.execution==="document"||r.html.execution==="stream")&&(r.html.sandbox===void 0||Array.isArray(r.html.sandbox)&&r.html.sandbox.every(Yn)))&&(r.widget===void 0||Zn(r.widget));return j(e.id)&&j(e.name)&&Bt(e.format)&&n&&a&&(e.mimeType===void 0||typeof e.mimeType=="string")&&(e.size===void 0||typeof e.size=="number")}function Zn(e){if(!_(e))return!1;const t=e.kit,n=t===void 0||t===!1||_(t)&&["css","script","reactScript"].every(r=>t[r]===void 0||typeof t[r]=="string");return(e.kind===void 0||e.kind==="html"||e.kind==="react")&&(e.layout===void 0||e.layout==="inline"||e.layout==="panel")&&n&&(e.bridge===void 0||typeof e.bridge=="boolean")&&(e.data===void 0||typeof e.data=="boolean")&&(e.pictures===void 0||typeof e.pictures=="boolean")&&(e.viewportHeight===void 0||typeof e.viewportHeight=="number"&&Number.isFinite(e.viewportHeight)&&e.viewportHeight>0)&&(e.labels===void 0||_(e.labels)&&Object.values(e.labels).every(r=>r===void 0||typeof r=="string"))&&(e.revisionId===void 0||j(e.revisionId))&&(e.artifactData===void 0||oe(e.artifactData))}function Gt(e){return _(e)&&j(e.token)&&j(e.expiresAt)&&Kn(e.scopes)}function Qn(e){return _(e)&&j(e.name)&&j(e.origin)&&j(e.sdkVersion)}function Jn(e){return e==="format-not-supported"||e==="encrypted-document"||e==="missing-renderer"||e==="feature-not-available"}function er(e){return e==="invalid-message"||e==="origin-mismatch"||e==="session-expired"||e==="document-fetch-failed"||e==="renderer-failed"||e==="timeout"}function tr(e){return e==="info"||e==="warn"||e==="error"}function nr(e){return _(e)&&j(e.viewerVersion)&&Array.isArray(e.supportedProtocolVersions)&&e.supportedProtocolVersions.every(t=>t===Me)&&Array.isArray(e.capabilities)&&e.capabilities.every(Xn)}function rr(e){return _(e)&&Wt(e.document)&&(e.theme===void 0||Je(e.theme))&&(e.safeArea===void 0||Qe(e.safeArea))&&(e.scrollProgressDistance===void 0||vr(e.scrollProgressDistance))&&(e.session===void 0||Gt(e.session))&&Qn(e.host)}function ir(e){return _(e)&&Wt(e.document)&&(e.theme===void 0||Je(e.theme))&&(e.safeArea===void 0||Qe(e.safeArea))&&(e.session===void 0||Gt(e.session))}function ar(e){return _(e)&&typeof e.page=="number"&&Number.isInteger(e.page)&&e.page>0}function or(e){return _(e)&&Je(e.theme)}function sr(e){return _(e)&&(e.documentId===void 0||j(e.documentId))&&oe(e.data)}function lr(e){return _(e)&&(e.documentId===void 0||j(e.documentId))&&j(e.html)&&(e.sequence===void 0||typeof e.sequence=="number"&&Number.isInteger(e.sequence)&&e.sequence>=0)}function cr(e){return _(e)&&(e.documentId===void 0||j(e.documentId))}function ur(e){return _(e)&&(e.documentId===void 0||j(e.documentId))&&(e.reason===void 0||j(e.reason))}function dr(e){return _(e)&&j(e.documentId)&&Bt(e.format)&&j(e.title)&&(e.pageCount===void 0||typeof e.pageCount=="number")}function fr(e){return _(e)&&typeof e.page=="number"&&(e.pageCount===void 0||typeof e.pageCount=="number")}function pr(e){return _(e)&&j(e.documentId)&&j(e.name)&&(e.detail===void 0||oe(e.detail))}const mr=new Set(["ui/message","ui/open-link","dvina/open-target","ui/update-model-context","dvina/call"]);function Kt(e){return typeof e=="string"&&mr.has(e)}function Xt(e,t){if(!_(t)||Array.isArray(t)||!oe(t))return!1;switch(e){case"ui/message":return t.role==="user"&&Array.isArray(t.content)&&t.content.length>0&&t.content.every(n=>_(n)&&n.type==="text"&&j(n.text));case"ui/open-link":return j(t.url)&&/^https?:\/\//i.test(t.url);case"dvina/open-target":return j(t.kind)&&j(t.id);case"ui/update-model-context":return"structuredContent"in t;case"dvina/call":return j(t.name)}}function hr(e){return _(e)&&j(e.documentId)&&j(e.requestId)&&Kt(e.method)&&Xt(e.method,e.params)}function gr(e){return _(e)&&j(e.requestId)&&(e.result===void 0||oe(e.result))&&(e.error===void 0||_(e.error)&&j(e.error.code)&&typeof e.error.message=="string")}function vr(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function br(e){return _(e)&&typeof e.progress=="number"&&e.progress>=0&&e.progress<=1}function wr(e){return _(e)&&typeof e.height=="number"&&(e.reason==="content"||e.reason==="viewport"||e.reason==="renderer")}function xr(e){return _(e)&&j(e.name)&&tr(e.level)&&j(e.message)&&(e.context===void 0||_(e.context)&&Object.values(e.context).every(t=>t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"))}function yr(e){return _(e)&&j(e.documentId)&&Jn(e.reason)&&j(e.message)}function kr(e){return _(e)&&(e.documentId===void 0||j(e.documentId))&&er(e.code)&&j(e.message)&&typeof e.recoverable=="boolean"}function Er(e){return _(e)&&(e.status==="accepted"||e.status==="rejected")&&(e.reason===void 0||j(e.reason))}const Ar={"viewer.ready":nr,"viewer.init":rr,"viewer.load-document":ir,"viewer.set-theme":or,"viewer.set-safe-area":e=>_(e)&&Qe(e.safeArea),"viewer.go-to-page":ar,"viewer.send-artifact-data":sr,"viewer.append-html":lr,"viewer.complete-html-stream":cr,"viewer.abort-html-stream":ur,"viewer.widget-response":gr,"viewer.widget-request":hr,"viewer.document-loaded":dr,"viewer.page-changed":fr,"viewer.artifact-event":pr,"viewer.resize":wr,"viewer.scroll":br,"viewer.telemetry":xr,"viewer.error":kr,"viewer.unsupported":yr,"viewer.ack":Er};function Yt(e){return typeof e=="string"&&Bn.has(e)}function Sr(e){return typeof e=="string"&&Wn.has(e)}function Zt(e){return typeof e=="string"&&Gn.has(e)}function Lr(e){return Yt(e)||Sr(e)||Zt(e)}function Cr(e){return _(e)&&e.channel===Ht&&e.version===Me&&j(e.instanceId)&&j(e.messageId)&&Lr(e.type)&&typeof e.timestamp=="number"&&"payload"in e}function Rr(e){if(!Cr(e))return!1;if(Zt(e.type)){if(!j(e.requestId))return!1}else if("requestId"in e&&e.requestId!==void 0)return!1;return Ar[e.type](e.payload)}function Ir(e){return Rr(e)&&Yt(e.type)}function Tr(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`viewer-${Math.random().toString(36).slice(2,10)}`}function J(e){return{channel:Ht,version:Me,messageId:e.messageId??Tr(),timestamp:e.timestamp??Date.now(),...e}}function Qt(e,t){if(e.source.kind==="stream")return null;const n=e.source.url;if(!n)return null;const r=new Headers;let a=!1;return t!=null&&t.token&&(r.set("Authorization",`Bearer ${t.token}`),a=!0),{url:n,init:a?{headers:r}:void 0}}const jr={inline:!1,tokensCss:`@layer dvina-tokens,theme,base,dvina,components,utilities;@layer dvina-tokens{:root{color-scheme:light;--dv-font-offset: 0px;--dv-font-text: "Inter", sans-serif;--dv-font-heading: "Inter Tight", "Inter", sans-serif;--dv-font-display: "Manrope", system-ui, sans-serif;--dv-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--dv-text-xs: calc(var(--dv-font-offset) + .75rem);--dv-text-xs-leading: calc(16 / 12);--dv-text-s: calc(var(--dv-font-offset) + .8125rem);--dv-text-s-leading: calc(20 / 13);--dv-text-m: calc(var(--dv-font-offset) + .9375rem);--dv-text-m-leading: calc(22 / 15);--dv-text-l: calc(var(--dv-font-offset) + 1.0625rem);--dv-text-l-leading: calc(28 / 17);--dv-ui-xs: calc(var(--dv-font-offset) + .75rem);--dv-ui-s: calc(var(--dv-font-offset) + .8125rem);--dv-ui-m: calc(var(--dv-font-offset) + 1rem);--dv-ui-l: calc(var(--dv-font-offset) + 1.0625rem);--dv-caption: calc(var(--dv-font-offset) + .65rem);--dv-display: calc(var(--dv-font-offset) + 1.875rem);--dv-display-leading: 1.08;--dv-page: #fff;--dv-panel: color-mix(in srgb, #fff, #f3f3f3 35%);--dv-surface: #fff;--dv-surface-muted: #f3f3f3;--dv-surface-sunk: color-mix(in srgb, #fff, #f3f3f3 50%);--dv-fill: rgba(0, 0, 0, .04);--dv-fill-hover: rgba(0, 0, 0, .05);--dv-fill-strong: rgba(0, 0, 0, .08);--dv-glass: color-mix(in srgb, color-mix(in srgb, #fff, #f3f3f3 50%), transparent 30%);--dv-glass-tint: color-mix(in srgb, color-mix(in srgb, #fff, #f3f3f3 50%), transparent 30%);--dv-popover: color-mix(in srgb, color-mix(in srgb, color-mix(in srgb, #fff, #f3f3f3 50%), transparent 30%) 75%, #fff);--dv-segment-puck: #e7e7e9;--dv-switch-on: rgba(0, 0, 0, .82);--dv-text: rgb(46 46 46);--dv-text-muted: rgb(107 109 128);--dv-text-faint: rgb(127 127 127);--dv-link: #0a6e8c;--dv-link-hover: #085a73;--dv-border: rgba(0, 0, 0, .075);--dv-border-strong: rgba(0, 0, 0, .1);--dv-border-hover: rgba(0, 0, 0, .16);--dv-ring: rgba(51, 51, 51, .64);--dv-accent: rgba(0, 0, 0, .82);--dv-accent-hover: rgba(0, 0, 0, .9);--dv-on-accent: #fff;--dv-brand: #4c99f6;--dv-on-brand: rgb(255 255 255);--dv-positive: rgb(74 201 155);--dv-positive-pale: rgba(74, 201, 155, .12);--dv-positive-text: color-mix(in srgb, rgb(74 201 155) 35%, rgb(46 46 46));--dv-negative: #ff3b30;--dv-negative-pale: rgb(255 59 48 / .08);--dv-negative-text: color-mix(in srgb, #ff3b30 35%, rgb(46 46 46));--dv-warning: rgb(255 199 0);--dv-warning-pale: rgba(255, 199, 0, .12);--dv-warning-text: #946200;--dv-info: rgb(112 182 246);--dv-info-pale: rgba(126, 190, 247, .3);--dv-info-text: color-mix(in srgb, rgb(112 182 246) 35%, rgb(46 46 46));--dv-highlight: rgba(255, 199, 0, .12);--dv-chart-1: #4c99f6;--dv-red: #ff3b30;--dv-orange: #ff9500;--dv-yellow: #ffcc00;--dv-green: #34c759;--dv-teal: #30b0c7;--dv-blue: #0084f7;--dv-indigo: #5856d6;--dv-purple: #af52de;--dv-pink: #ff2d55;--dv-gray: #8e8e93;--dv-radius-xs: calc(.75rem - 8px) ;--dv-radius-s: calc(.75rem - 4px) ;--dv-radius-m: .75rem;--dv-radius-l: 1.5rem ;--dv-radius-pill: 999px;--dv-stroke: 1.6px;--dv-space-1: .25rem;--dv-space-2: .5rem;--dv-space-3: .75rem;--dv-space-4: 1rem;--dv-space-5: 1.25rem;--dv-space-6: 1.5rem;--dv-space-8: 2rem;--dv-space-10: 2.5rem;--dv-control-s: 2rem;--dv-control-m: 2.75rem;--dv-control-l: 3.5rem;--dv-disabled-opacity: .5;--dv-shadow-surface: 0px 0px 0px 1px rgb(0 0 0 / .055);--dv-shadow-control: 0px 0px 0px 1px rgb(0 0 0 / .055), 0px 1px 1px -.5px rgb(0 0 0 / .055);--dv-shadow-raised: 0 .25rem 1.25rem rgba(0, 0, 0, .1);--dv-duration: .1s;--dv-duration-slow: calc(.1s / .6);--dv-ease: cubic-bezier(.2, 0, .4, .9);--dv-ease-emphasized: cubic-bezier(.22, 1, .36, 1);--dv-ease-soft: cubic-bezier(.2, .8, .2, 1);--dv-chart-2: #50cca2;--dv-chart-3: #ccac53;--dv-chart-4: #cc7485;--dv-chart-5: #93a4cc;--dv-chart-6: #cccc2e;--dv-chart-7: #3cc2a8;--dv-chart-8: #cca569}:root[data-theme-mode=dark]{color-scheme:dark;--dv-page: #0a0a0a;--dv-panel: color-mix(in srgb, #0a0a0a, #222324 35%);--dv-surface: #292929;--dv-surface-muted: #222324;--dv-surface-sunk: #222324;--dv-fill: rgba(255, 255, 255, .08);--dv-fill-hover: rgba(255, 255, 255, .05);--dv-fill-strong: rgba(255, 255, 255, .24);--dv-glass: color-mix(in srgb, color-mix(in srgb, #0a0a0a, #222324 50%), transparent 15%);--dv-glass-tint: color-mix(in srgb, #2f3133, transparent 40%);--dv-popover: color-mix(in srgb, color-mix(in srgb, #2f3133, transparent 40%) 70%, #0a0a0a);--dv-segment-puck: #3a3a3c;--dv-switch-on: #4591f7;--dv-text: rgb(230 230 230);--dv-text-muted: rgb(186 186 186);--dv-text-faint: rgb(133 133 133);--dv-link: #7098be;--dv-link-hover: #6093c4;--dv-border: rgba(206, 206, 206, .075);--dv-border-strong: rgba(255, 255, 255, .1);--dv-border-hover: rgba(255, 255, 255, .15);--dv-ring: rgba(255, 255, 255, .64);--dv-accent: #ededed;--dv-accent-hover: #fff;--dv-on-accent: #0a0a0a;--dv-brand: #4591f7;--dv-positive-pale: rgba(74, 201, 155, .32);--dv-positive-text: color-mix(in srgb, rgb(74 201 155) 100%, rgb(230 230 230));--dv-negative: #ff453a;--dv-negative-pale: rgb(255 69 58 / .2);--dv-negative-text: color-mix(in srgb, #ff453a 100%, rgb(230 230 230));--dv-warning-pale: rgba(255, 199, 0, .32);--dv-warning-text: rgb(255 199 0);--dv-info-pale: rgba(102, 141, 176, .3);--dv-info-text: color-mix(in srgb, rgb(112 182 246) 100%, rgb(230 230 230));--dv-highlight: rgba(255, 199, 0, .32);--dv-chart-1: #4591f7;--dv-red: #ff453a;--dv-orange: #ff9f0a;--dv-yellow: #ffd60a;--dv-green: #30d158;--dv-teal: #40c8e0;--dv-blue: #0292ff;--dv-indigo: #5e5ce6;--dv-purple: #bf5af2;--dv-pink: #ff375f;--dv-gray: #98989d;--dv-shadow-surface: inset 0 1px 0 0 rgba(255, 255, 255, .05), inset 0 0 0 1px rgba(255, 255, 255, .02), 0 0 0 1px rgba(0, 0, 0, .12), 0 1px 1px -.5px rgba(0, 0, 0, .18), 0 3px 3px -1.5px rgba(0, 0, 0, .18);--dv-shadow-control: inset 0 1px 0 0 rgba(255, 255, 255, .05), inset 0 0 0 1px rgba(255, 255, 255, .04), 0 0 0 1px rgba(0, 0, 0, .14), 0 1px 1px -.5px rgba(0, 0, 0, .18), 0 3px 3px -1.5px rgba(0, 0, 0, .18), 0 6px 6px -3px rgba(0, 0, 0, .18);--dv-shadow-raised: inset 0 1px 0 0 rgba(255, 255, 255, .05), inset 0 0 0 1px rgba(255, 255, 255, .04), 0 0 0 1px rgba(0, 0, 0, .14), 0 1px 1px -.5px rgba(0, 0, 0, .18), 0 3px 3px -1.5px rgba(0, 0, 0, .18), 0 6px 6px -3px rgba(0, 0, 0, .18);--dv-chart-2: #b5ead7;--dv-chart-3: #ffdfba;--dv-chart-4: #ffb3ba;--dv-chart-5: #c7ceea;--dv-chart-6: #ffffba;--dv-chart-7: #a1d9ce;--dv-chart-8: #ffdac1}@media(prefers-color-scheme:dark){:root:not([data-theme-mode]){color-scheme:dark;--dv-page: #0a0a0a;--dv-panel: color-mix(in srgb, #0a0a0a, #222324 35%);--dv-surface: #292929;--dv-surface-muted: #222324;--dv-surface-sunk: #222324;--dv-fill: rgba(255, 255, 255, .08);--dv-fill-hover: rgba(255, 255, 255, .05);--dv-fill-strong: rgba(255, 255, 255, .24);--dv-glass: color-mix(in srgb, color-mix(in srgb, #0a0a0a, #222324 50%), transparent 15%);--dv-glass-tint: color-mix(in srgb, #2f3133, transparent 40%);--dv-popover: color-mix(in srgb, color-mix(in srgb, #2f3133, transparent 40%) 70%, #0a0a0a);--dv-segment-puck: #3a3a3c;--dv-switch-on: #4591f7;--dv-text: rgb(230 230 230);--dv-text-muted: rgb(186 186 186);--dv-text-faint: rgb(133 133 133);--dv-link: #7098be;--dv-link-hover: #6093c4;--dv-border: rgba(206, 206, 206, .075);--dv-border-strong: rgba(255, 255, 255, .1);--dv-border-hover: rgba(255, 255, 255, .15);--dv-ring: rgba(255, 255, 255, .64);--dv-accent: #ededed;--dv-accent-hover: #fff;--dv-on-accent: #0a0a0a;--dv-brand: #4591f7;--dv-positive-pale: rgba(74, 201, 155, .32);--dv-positive-text: color-mix(in srgb, rgb(74 201 155) 100%, rgb(230 230 230));--dv-negative: #ff453a;--dv-negative-pale: rgb(255 69 58 / .2);--dv-negative-text: color-mix(in srgb, #ff453a 100%, rgb(230 230 230));--dv-warning-pale: rgba(255, 199, 0, .32);--dv-warning-text: rgb(255 199 0);--dv-info-pale: rgba(102, 141, 176, .3);--dv-info-text: color-mix(in srgb, rgb(112 182 246) 100%, rgb(230 230 230));--dv-highlight: rgba(255, 199, 0, .32);--dv-chart-1: #4591f7;--dv-red: #ff453a;--dv-orange: #ff9f0a;--dv-yellow: #ffd60a;--dv-green: #30d158;--dv-teal: #40c8e0;--dv-blue: #0292ff;--dv-indigo: #5e5ce6;--dv-purple: #bf5af2;--dv-pink: #ff375f;--dv-gray: #98989d;--dv-shadow-surface: inset 0 1px 0 0 rgba(255, 255, 255, .05), inset 0 0 0 1px rgba(255, 255, 255, .02), 0 0 0 1px rgba(0, 0, 0, .12), 0 1px 1px -.5px rgba(0, 0, 0, .18), 0 3px 3px -1.5px rgba(0, 0, 0, .18);--dv-shadow-control: inset 0 1px 0 0 rgba(255, 255, 255, .05), inset 0 0 0 1px rgba(255, 255, 255, .04), 0 0 0 1px rgba(0, 0, 0, .14), 0 1px 1px -.5px rgba(0, 0, 0, .18), 0 3px 3px -1.5px rgba(0, 0, 0, .18), 0 6px 6px -3px rgba(0, 0, 0, .18);--dv-shadow-raised: inset 0 1px 0 0 rgba(255, 255, 255, .05), inset 0 0 0 1px rgba(255, 255, 255, .04), 0 0 0 1px rgba(0, 0, 0, .14), 0 1px 1px -.5px rgba(0, 0, 0, .18), 0 3px 3px -1.5px rgba(0, 0, 0, .18), 0 6px 6px -3px rgba(0, 0, 0, .18);--dv-chart-2: #b5ead7;--dv-chart-3: #ffdfba;--dv-chart-4: #ffb3ba;--dv-chart-5: #c7ceea;--dv-chart-6: #ffffba;--dv-chart-7: #a1d9ce;--dv-chart-8: #ffdac1}}@media not (min-width:48rem){:root{--dv-text-m: calc(var(--dv-font-offset) + .875rem);--dv-text-m-leading: calc(20 / 14)}}}
|
|
3
|
-
`,kitCss:new URL("widget-kit-BHFtkQRC.css",import.meta.url).href,kitScript:new URL("widget-kit-BBNeO9Gd.js",import.meta.url).href,kitReactScript:new URL("widget-kit-react-BMDV86-w.js",import.meta.url).href,tailwindScript:new URL("widget-tailwind-aFST5_Zt.js",import.meta.url).href,tailwindCss:`/*
|
|
4
|
-
* Tailwind for React artifacts (never inline widgets): Tailwind's theme and utilities over the kit's --dv-* tokens,
|
|
5
|
-
* without its preflight (the kit styles bare elements) and without its palette, so every colour is one of ours and a
|
|
6
|
-
* class follows light and dark with the tokens. Read as \`<style type="text/tailwindcss">\` by the browser build.
|
|
7
|
-
*
|
|
8
|
-
* Layers (declared first in kit.css): theme, base, dvina (the kit), components, utilities, so a utility wins over
|
|
9
|
-
* the kit's styling of the element it is on.
|
|
10
|
-
*/
|
|
11
|
-
@import "tailwindcss/theme.css" layer(theme);
|
|
12
|
-
@import "tailwindcss/utilities.css" layer(utilities);
|
|
13
|
-
|
|
14
|
-
/* Dark is the engine's mode attribute, not the system's preference. */
|
|
15
|
-
@custom-variant dark (&:where([data-theme-mode="dark"], [data-theme-mode="dark"] *));
|
|
16
|
-
|
|
17
|
-
@theme inline {
|
|
18
|
-
/* Ours only: Tailwind's palette, fonts, sizes, radii, shadows and easings are cleared first. */
|
|
19
|
-
--color-*: initial;
|
|
20
|
-
--font-*: initial;
|
|
21
|
-
--text-*: initial;
|
|
22
|
-
--radius-*: initial;
|
|
23
|
-
--shadow-*: initial;
|
|
24
|
-
--inset-shadow-*: initial;
|
|
25
|
-
--drop-shadow-*: initial;
|
|
26
|
-
--ease-*: initial;
|
|
27
|
-
|
|
28
|
-
--color-transparent: transparent;
|
|
29
|
-
--color-current: currentColor;
|
|
30
|
-
--color-white: #fff;
|
|
31
|
-
--color-black: #000;
|
|
32
|
-
|
|
33
|
-
/* Grounds: bg-page, bg-panel, bg-surface (a card), bg-surface-muted, bg-sunk, bg-fill (a quiet control),
|
|
34
|
-
bg-fill-hover, bg-fill-strong, bg-glass, bg-popover. */
|
|
35
|
-
--color-page: var(--dv-page);
|
|
36
|
-
--color-panel: var(--dv-panel);
|
|
37
|
-
--color-surface: var(--dv-surface);
|
|
38
|
-
--color-surface-muted: var(--dv-surface-muted);
|
|
39
|
-
--color-sunk: var(--dv-surface-sunk);
|
|
40
|
-
--color-fill: var(--dv-fill);
|
|
41
|
-
--color-fill-hover: var(--dv-fill-hover);
|
|
42
|
-
--color-fill-strong: var(--dv-fill-strong);
|
|
43
|
-
--color-glass: var(--dv-glass);
|
|
44
|
-
--color-popover: var(--dv-popover);
|
|
45
|
-
|
|
46
|
-
/* Text: text-foreground, text-muted, text-faint, text-link. */
|
|
47
|
-
--color-foreground: var(--dv-text);
|
|
48
|
-
--color-muted: var(--dv-text-muted);
|
|
49
|
-
--color-faint: var(--dv-text-faint);
|
|
50
|
-
--color-link: var(--dv-link);
|
|
51
|
-
|
|
52
|
-
/* Lines: border-border, border-border-strong, ring-ring. */
|
|
53
|
-
--color-border: var(--dv-border);
|
|
54
|
-
--color-border-strong: var(--dv-border-strong);
|
|
55
|
-
--color-ring: var(--dv-ring);
|
|
56
|
-
|
|
57
|
-
/* The primary action (near-black in light, near-white in dark), its text, and the brand blue. */
|
|
58
|
-
--color-accent: var(--dv-accent);
|
|
59
|
-
--color-accent-hover: var(--dv-accent-hover);
|
|
60
|
-
--color-on-accent: var(--dv-on-accent);
|
|
61
|
-
--color-brand: var(--dv-brand);
|
|
62
|
-
--color-on-brand: var(--dv-on-brand);
|
|
63
|
-
|
|
64
|
-
/* Status: the colour, its pale fill and small text on that fill (bg-positive-pale text-positive-text). */
|
|
65
|
-
--color-positive: var(--dv-positive);
|
|
66
|
-
--color-positive-pale: var(--dv-positive-pale);
|
|
67
|
-
--color-positive-text: var(--dv-positive-text);
|
|
68
|
-
--color-negative: var(--dv-negative);
|
|
69
|
-
--color-negative-pale: var(--dv-negative-pale);
|
|
70
|
-
--color-negative-text: var(--dv-negative-text);
|
|
71
|
-
--color-warning: var(--dv-warning);
|
|
72
|
-
--color-warning-pale: var(--dv-warning-pale);
|
|
73
|
-
--color-warning-text: var(--dv-warning-text);
|
|
74
|
-
--color-info: var(--dv-info);
|
|
75
|
-
--color-info-pale: var(--dv-info-pale);
|
|
76
|
-
--color-info-text: var(--dv-info-text);
|
|
77
|
-
--color-highlight: var(--dv-highlight);
|
|
78
|
-
|
|
79
|
-
/* Chart series, in order. */
|
|
80
|
-
--color-chart-1: var(--dv-chart-1);
|
|
81
|
-
--color-chart-2: var(--dv-chart-2);
|
|
82
|
-
--color-chart-3: var(--dv-chart-3);
|
|
83
|
-
--color-chart-4: var(--dv-chart-4);
|
|
84
|
-
--color-chart-5: var(--dv-chart-5);
|
|
85
|
-
--color-chart-6: var(--dv-chart-6);
|
|
86
|
-
--color-chart-7: var(--dv-chart-7);
|
|
87
|
-
--color-chart-8: var(--dv-chart-8);
|
|
88
|
-
|
|
89
|
-
/* Hues, one shade each, light and dark (bg-blue/15 for a tint). */
|
|
90
|
-
--color-red: var(--dv-red);
|
|
91
|
-
--color-orange: var(--dv-orange);
|
|
92
|
-
--color-yellow: var(--dv-yellow);
|
|
93
|
-
--color-green: var(--dv-green);
|
|
94
|
-
--color-teal: var(--dv-teal);
|
|
95
|
-
--color-blue: var(--dv-blue);
|
|
96
|
-
--color-indigo: var(--dv-indigo);
|
|
97
|
-
--color-purple: var(--dv-purple);
|
|
98
|
-
--color-pink: var(--dv-pink);
|
|
99
|
-
--color-gray: var(--dv-gray);
|
|
100
|
-
|
|
101
|
-
/* Families: font-sans (text), font-heading, font-display (figures), font-mono. */
|
|
102
|
-
--font-sans: var(--dv-font-text);
|
|
103
|
-
--font-heading: var(--dv-font-heading);
|
|
104
|
-
--font-display: var(--dv-font-display);
|
|
105
|
-
--font-mono: var(--dv-font-mono);
|
|
106
|
-
|
|
107
|
-
/* Sizes on the app's scale: text-xs 12, text-sm 13, text-base the chat's 15 (14 on a phone), text-lg 17,
|
|
108
|
-
text-xl 20, text-2xl 24, text-display 30. */
|
|
109
|
-
--text-xs: var(--dv-text-xs);
|
|
110
|
-
--text-xs--line-height: var(--dv-text-xs-leading);
|
|
111
|
-
--text-sm: var(--dv-text-s);
|
|
112
|
-
--text-sm--line-height: var(--dv-text-s-leading);
|
|
113
|
-
--text-base: var(--dv-text-m);
|
|
114
|
-
--text-base--line-height: var(--dv-text-m-leading);
|
|
115
|
-
--text-lg: var(--dv-text-l);
|
|
116
|
-
--text-lg--line-height: var(--dv-text-l-leading);
|
|
117
|
-
--text-xl: calc(var(--dv-font-offset) + 1.25rem);
|
|
118
|
-
--text-xl--line-height: 1.2;
|
|
119
|
-
--text-2xl: calc(var(--dv-font-offset) + 1.5rem);
|
|
120
|
-
--text-2xl--line-height: 1.15;
|
|
121
|
-
--text-display: var(--dv-display);
|
|
122
|
-
--text-display--line-height: var(--dv-display-leading);
|
|
123
|
-
|
|
124
|
-
/* Corners: rounded-xs 4, rounded-sm 8, rounded-md 12, rounded-lg 24 (cards), rounded-full a pill. */
|
|
125
|
-
--radius-xs: var(--dv-radius-xs);
|
|
126
|
-
--radius-sm: var(--dv-radius-s);
|
|
127
|
-
--radius-md: var(--dv-radius-m);
|
|
128
|
-
--radius-lg: var(--dv-radius-l);
|
|
129
|
-
|
|
130
|
-
/* Elevation by role: shadow-surface (a card), shadow-control, shadow-raised (something floating). */
|
|
131
|
-
--shadow-surface: var(--dv-shadow-surface);
|
|
132
|
-
--shadow-control: var(--dv-shadow-control);
|
|
133
|
-
--shadow-raised: var(--dv-shadow-raised);
|
|
134
|
-
|
|
135
|
-
/* Motion: ease-standard, ease-emphasized, ease-soft; durations stay Tailwind's numbers (duration-100…). */
|
|
136
|
-
--ease-standard: var(--dv-ease);
|
|
137
|
-
--ease-emphasized: var(--dv-ease-emphasized);
|
|
138
|
-
--ease-soft: var(--dv-ease-soft);
|
|
139
|
-
--default-transition-duration: var(--dv-duration);
|
|
140
|
-
--default-transition-timing-function: var(--dv-ease);
|
|
141
|
-
--default-font-family: var(--dv-font-text);
|
|
142
|
-
--default-mono-font-family: var(--dv-font-mono);
|
|
143
|
-
}
|
|
144
|
-
`,reactLoader:new URL("widget-react-DdwoFg4K.js",import.meta.url).href,svgMenu:new URL("widget-svg-menu-BdZCKjBm.js",import.meta.url).href},Mr=["https://cdnjs.cloudflare.com","https://cdn.jsdelivr.net","https://unpkg.com","https://esm.sh"];function Be(e){return new URL(e,window.location.href).href}function Jt(e=window.location.origin){const t=Mr.join(" ");return["default-src 'none'",`script-src 'unsafe-inline' 'unsafe-eval' blob: ${e} ${t}`,`style-src 'unsafe-inline' ${e} ${t} https://fonts.googleapis.com`,`font-src data: ${e} ${t} https://fonts.gstatic.com`,`img-src data: blob: ${t}`,"media-src data: blob:",`connect-src ${t}`,"worker-src blob:","frame-src 'none'","form-action 'none'","base-uri 'none'"].join("; ")}const Pr=["allow-scripts","allow-forms","allow-popups","allow-popups-to-escape-sandbox","allow-downloads"],en={inline:"html,body{margin:0;background:transparent}html{overflow:hidden}body{display:flow-root}",panel:"html,body{margin:0;min-height:100%}body{display:flow-root}"},fe={...jr};function Nr(e){const t=e.replace(/^\[|\]$/g,"").toLowerCase();return t==="localhost"||t.endsWith(".localhost")||t.endsWith(".local")||t==="::1"||/^127\./.test(t)||/^10\./.test(t)||/^192\.168\./.test(t)||/^172\.(1[6-9]|2\d|3[01])\./.test(t)}const _r=["kitCss","kitScript","kitReactScript","tailwindScript","reactLoader","svgMenu"];let kt=null;function Et(){return kt??(kt=fe.inline||!Nr(window.location.hostname)?Promise.resolve():Promise.all(_r.map(async e=>{const t=await fetch(fe[e]);if(!t.ok)throw new Error(`${e}: ${t.status}`);return[e,await t.text()]})).then(e=>{for(const[t,n]of e)fe[t]=n;fe.inline=!0},()=>{})),kt}const Dr=480,Or=1600;function Fr(e){if(!(e===void 0||!Number.isFinite(e)||e<=0))return Math.round(Math.min(Or,Math.max(Dr,e)))}function At(e){return{height:e,viewportSized:!1,atViewport:null,atGrown:null}}function zr(e,t,n){const r=a=>({height:a,viewportSized:!1,atViewport:a===n?t:null,atGrown:a>n?t:null});return t<=n?{frame:r(n),shown:t}:e.height>n?t<=e.height?{frame:r(t),shown:t}:{frame:{height:n,viewportSized:!0,atViewport:null,atGrown:t},shown:e.height}:e.viewportSized&&(e.atViewport===null?e.atGrown!==null&&t<e.atGrown:t===e.atViewport)?{frame:{...e,atViewport:t},shown:n}:{frame:r(t),shown:t}}const $r='"use strict";(()=>{var Je=300,je=/^[A-Za-z0-9_.:-]{1,128}$/;function le(e,t){if(typeof t!="string"||!je.test(t))throw new Error(`A ${e} is 1\\u2013128 letters, digits or . _ : - ("${String(t)}" is not).`)}function ze(e,t){return e===t?0:e==null?1:t==null||e<t?-1:1}function Ge(e,t){let r=null,n=null,i=[],o=0,p=!1,s=new Set,c=()=>s.forEach(a=>a());function E(a=!1){return r&&!a?Promise.resolve(r):(n&&!a||(n=e.read().then(d=>{n=null,r={version:d.version,collections:structuredClone(d.collections)};for(let{op:u}of i)g(u);return c(),r},d=>{throw n=null,d})),n)}function g(a){var u,m;if(!r)return;let d=(u=r.collections)[m=a.collection]??(u[m]={});a.op==="delete"?delete d[a.id]:a.op==="set"?d[a.id]=structuredClone(a.doc??{}):d[a.id]={...d[a.id]??{},...structuredClone(a.doc??{})}}async function h(){var d;if(o=0,p||i.length===0)return;p=!0;let a=i;i=[];try{let u=await e.apply(a.map(({op:m})=>m));if(r){r.version=u.version;for(let{collection:m,id:A,doc:l}of u.changed){let w=(d=r.collections)[m]??(d[m]={});l===null?delete w[A]:w[A]=l}for(let{op:m}of i)g(m)}a.forEach(({settle:m})=>m()),c()}catch(u){let m=u instanceof Error?u:new Error(String(u));a.forEach(({settle:A})=>A(m)),t(m),await E(!0).catch(()=>{})}finally{p=!1,i.length&&v()}}function v(){o||(o=window.setTimeout(()=>void h(),Je))}async function V(a){return le("collection",a.collection),le("document id",a.id),await E(),new Promise((d,u)=>{g(a),i.push({op:a,settle:m=>m?u(m):d()}),c(),v()})}return{load:E,refresh(){r&&!p&&i.length===0&&E(!0).catch(()=>{})},collection(a){le("collection",a);let d=()=>r?.collections[a]??{};return Object.freeze({async get(u){await E();let m=d()[u];return m?{...structuredClone(m),id:u}:null},async list(u={}){await E();let m=Object.entries(d()).map(([M,N])=>({...structuredClone(N),id:M})),{where:A,orderBy:l,limit:w}=u;if(typeof A=="function"?m=m.filter(A):A&&(m=m.filter(M=>Object.entries(A).every(([N,O])=>M[N]===O))),l){let[M,N]=Array.isArray(l)?l:[l,"asc"];m.sort((O,_)=>ze(O[M],_[M])*(N==="desc"?-1:1))}return typeof w=="number"?m.slice(0,Math.max(0,w)):m},set:(u,m)=>V({op:"set",collection:a,id:u,doc:m}),update:(u,m)=>V({op:"update",collection:a,id:u,doc:m}),delete:u=>V({op:"delete",collection:a,id:u}),subscribe(u){return s.add(u),()=>s.delete(u)}})}}}var We="_kv";function be(e,t=()=>{}){let r=Ge(e,t),n=()=>r.refresh();window.addEventListener("focus",n),document.addEventListener("visibilitychange",()=>document.visibilityState==="visible"&&n());let i=Object.freeze({collection:s=>r.collection(s)}),o=()=>r.collection(We),p=Object.freeze({async get(s){return(await o().get(s))?.value},set:(s,c)=>o().set(s,{value:c}),delete:s=>o().delete(s),async list(s={}){return(await o().list()).map(E=>E.id).filter(E=>!s.prefix||E.startsWith(s.prefix))}});return{db:i,storage:p}}var we=15e3;function he(e){let t=new Map,r=0;function n(l,w,M=we){return e.enabled?i(l,w,M):Promise.reject(new Error("The widget bridge is off."))}function i(l,w,M=we){let N=`w${++r}`;return new Promise((O,_)=>{let I=window.setTimeout(()=>{t.delete(N),_(new Error(`${l} timed out after ${M} ms`))},M);t.set(N,{resolve:O,reject:_,timer:I}),e.post({channel:e.channel,jsonrpc:"2.0",id:N,method:l,params:w})})}let o=(l,w)=>n(l,w).then(()=>!0,()=>!1),p={send:(l,w)=>typeof l=="string"&&l.trim()?o("ui/message",{role:"user",content:[{type:"text",text:l.trim()}],...w===void 0?{}:{context:w}}):Promise.resolve(!1)},s={open:l=>o("ui/open-link",{url:String(l)})},c={open:(l,w)=>o("dvina/open-target",{kind:l,id:w})},E={set:l=>o("ui/update-model-context",{structuredContent:l}),clear:()=>o("ui/update-model-context",{structuredContent:null})},g={call:(l,w)=>n("dvina/call",w===void 0?{name:l}:{name:l,args:w})},h={prompt:p,link:s,target:c,context:E,host:g},v=null,V={read:()=>g.call("db.read",{}),apply:l=>g.call("db.apply",{ops:l})},a=l=>!e.data||l!=="db"&&l!=="storage"?null:(v??(v=be(V,w=>console.error("[dvina] a write was refused:",w.message))),l==="db"?v.db:v.storage),d={use:l=>Promise.resolve(e.enabled?l in h?Object.freeze({...h[l]}):a(l):null)};function u(l){if(l.jsonrpc!=="2.0"||typeof l.id!="string")return!1;let w=t.get(l.id);if(!w)return!0;t.delete(l.id),window.clearTimeout(w.timer);let M=l.error;return M?w.reject(new Error(M.message||"The host refused the request.")):w.resolve(l.result??null),!0}function m(){document.addEventListener("click",l=>{if(l.defaultPrevented||l.button!==0)return;let w=l.target?.closest?.("a[href]");!w||!/^https?:/i.test(w.href)||(l.preventDefault(),s.open(w.href))})}let A=e.enabled||e.pictures?(l,w)=>i("dvina/call",w===void 0?{name:l}:{name:l,args:w}):null;return{dvina:d,prompt:p,link:s,host:g,pictures:A,receive:u,interceptLinks:m}}var q="data-dvina-image",Y="data-dvina-image-state",Ye="image.read";var Xe=/^image\\/(webp|jpeg|png|gif|avif)$/,ye=/^(data|blob):/i;function ce(e){let t=e.getAttribute("src");return!t||!ye.test(t)}function Ke(e){let t=e.getAttribute("src");t&&!ye.test(t)&&e.removeAttribute("src"),e.removeAttribute("srcset"),e.removeAttribute("sizes");let r=e.parentElement;r?.tagName==="PICTURE"&&r.querySelectorAll("source[srcset]").forEach(n=>n.removeAttribute("srcset"))}function ue(e){let{mimeType:t,data:r}=e??{};if(typeof t!="string"||!Xe.test(t)||typeof r!="string")throw new Error("The host gave no picture.");if(r.length>Math.ceil(8388608/3)*4)throw new Error("The picture is too large.");let n=atob(r),i=new Uint8Array(n.length);for(let o=0;o<n.length;o+=1)i[o]=n.charCodeAt(o);return new Blob([i],{type:t})}function Te(e){let t=new Map,r=new Map,n=[],i=0,o=0,p=typeof IntersectionObserver=="function"?new IntersectionObserver(a=>{for(let d of a)d.isIntersecting&&(p?.unobserve(d.target),g(d.target))}):null;function s(){for(;i<3&&n.length>0;){let a=n.shift();i+=1,a().finally(()=>{i-=1,s()})}}function c(a){let d=t.get(a);if(d)return d;let{call:u}=e;if(!u){r.set(a,null);let A=Promise.resolve(null);return t.set(a,A),A}let m=new Promise(A=>{let l=w=>{r.set(a,w),A(w)};n.push(async()=>{if(o>=12)return l(null);o+=1;let w=await u(Ye,{url:a}).then(M=>URL.createObjectURL(ue(M))).catch(()=>(o-=1,null));l(w)}),s()});return t.set(a,m),m}function E(a){let d=a.getAttribute(q)?.trim();if(!(!d||!ce(a))){if(Ke(a),r.has(d)){h(a,d,r.get(d)??null);return}a.setAttribute(Y,"loading"),p?p.observe(a):g(a)}}function g(a){let d=a.getAttribute(q)?.trim();!d||!ce(a)||c(d).then(u=>h(a,d,u))}function h(a,d,u){if(!(a.getAttribute(q)?.trim()!==d||!ce(a))){if(!u){a.setAttribute(Y,"failed");return}a.removeAttribute(Y),a.src=u}}function v(a){a instanceof HTMLImageElement&&E(a),a.querySelectorAll?.(`img[${q}]`).forEach(E)}function V(a){let d=new MutationObserver(u=>{for(let m of u)m.type==="attributes"?v(m.target):m.addedNodes.forEach(A=>A.nodeType===Node.ELEMENT_NODE&&v(A))});return d.observe(a,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[q,"src","srcset"]}),(a instanceof Element||a instanceof Document)&&v(a),d}return{apply:v,observe:V}}function Ee(e,t){if(e.tagName!=="IMG"||t.tagName!=="IMG")return;let r=e.getAttribute(q);if(!r||r!==t.getAttribute(q))return;let n=e.getAttribute("src");n&&/^blob:/i.test(n)&&!/^data:/i.test(t.getAttribute("src")??"")&&(t.setAttribute("src",n),t.removeAttribute("srcset"),t.removeAttribute("sizes"));let i=e.getAttribute(Y);i&&t.setAttribute(Y,i)}var z=".cite",G="data-dvina-cite",Ze="source.icon",Qe=3,de="http://www.w3.org/2000/svg",et=["M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20","M2 12h20"];function Ae(e){let t=e?.trim();if(!t)return null;try{let r=new URL(t);return r.protocol==="https:"||r.protocol==="http:"?r.href:null}catch{return null}}function W(e){return new URL(e).host.replace(/^www\\./,"")}function fe(e){let t=e.getAttribute(G);if(t!==null)return t.split(" ").filter(Boolean);let r=e.matches("a")?[e]:[...e.querySelectorAll("a[href]")];return[...new Set(r.map(n=>Ae(n.getAttribute("href"))).filter(n=>!!n))]}function tt(e,t){let r=e.matches("a")?[e]:[...e.querySelectorAll("a[href]")];return t.map(n=>{let i=r.find(o=>Ae(o.getAttribute("href"))===n)?.textContent?.trim();return i&&i!==W(n)?`${i} \\xB7 ${W(n)}`:W(n)}).join(`\n`)}function nt(){let e=document.createElementNS(de,"svg");e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("aria-hidden","true");let t=document.createElementNS(de,"circle");t.setAttribute("cx","12"),t.setAttribute("cy","12"),t.setAttribute("r","10"),e.append(t);for(let r of et){let n=document.createElementNS(de,"path");n.setAttribute("d",r),e.append(n)}return e}function xe(e){let t=new Map;function r(s){let c=W(s),E=t.get(c);if(E)return E;let{call:g}=e,h=g?g(Ze,{url:s}).then(v=>URL.createObjectURL(ue(v))).catch(()=>null):Promise.resolve(null);return t.set(c,h),h}function n(s){let c=document.createElement("span");return c.className="cite-icon",c.append(nt()),r(s).then(E=>{if(!E)return;let g=document.createElement("img");g.alt="",g.src=E,c.replaceChildren(g)}),c}function i(s){if(s.hasAttribute(G))return;let c=fe(s);if(!c.length)return;let E=[...new Map(c.map(v=>[W(v),v])).values()],g=document.createElement("span");g.className="cite-icons",g.append(...E.slice(0,Qe).map(n));let h=document.createElement("span");h.className="cite-label",h.textContent=c.length>1?`+${c.length-1}`:W(c[0]),s.setAttribute("title",tt(s,c)),s.setAttribute(G,c.join(" ")),s.matches("a")||(s.setAttribute("role","link"),s.setAttribute("tabindex","0")),s.replaceChildren(g,h)}function o(s){s instanceof Element&&s.matches(z)&&i(s),s.querySelectorAll?.(z).forEach(i)}function p(s){let c=new MutationObserver(g=>{for(let h of g)h.addedNodes.forEach(v=>{if(v.nodeType!==Node.ELEMENT_NODE)return;o(v);let V=v.parentElement?.closest(z);V&&!V.hasAttribute(G)&&i(V)})});c.observe(s,{childList:!0,subtree:!0}),(s instanceof Element||s instanceof Document)&&o(s);let E=g=>{let h=g.target?.closest?.(`${z}[${G}]`);if(!h||h.matches("a")||g instanceof KeyboardEvent&&g.key!=="Enter"&&g.key!==" ")return;g.preventDefault();let[v]=fe(h);v&&e.open(v)};return document.addEventListener("click",E),document.addEventListener("keydown",E),c}return{apply:o,observe:p}}function Se(e,t){if(!e.matches(z)||!t.matches(z))return!1;let r=e.getAttribute(G);return r!==null&&r===fe(t).join(" ")}var X=new Map;function me(e){let t=!1,r=()=>{t||(t=!0,cancelAnimationFrame(n),window.clearTimeout(X.get(n)),X.delete(n),e())},n=requestAnimationFrame(r);return X.set(n,window.setTimeout(r,100)),n}function pe(e){cancelAnimationFrame(e),window.clearTimeout(X.get(e)),X.delete(e)}var rt={requestFrame:me,cancelFrame:pe,setTimer:(e,t)=>window.setTimeout(e,t),clearTimer:e=>window.clearTimeout(e),now:()=>performance.now()};function Me(e,t=rt,r=150){let n=0,i=0,o=Number.NEGATIVE_INFINITY;function p(){n=0,o=t.now(),e()}function s(){n&&t.cancelFrame(n),i&&t.clearTimer(i),n=0,i=0}return{request(){if(n||i)return;let c=o+r-t.now();if(c<=0){n=t.requestFrame(p);return}i=t.setTimer(()=>{i=0,n=t.requestFrame(p)},c)},flushNow(){s(),p()},cancel:s}}var Le=11;function it(e,t){var r=t.attributes,n,i,o,p,s;if(!(t.nodeType===Le||e.nodeType===Le)){for(var c=r.length-1;c>=0;c--)n=r[c],i=n.name,o=n.namespaceURI,p=n.value,o?(i=n.localName||i,s=e.getAttributeNS(o,i),s!==p&&(n.prefix==="xmlns"&&(i=n.name),e.setAttributeNS(o,i,p))):(s=e.getAttribute(i),s!==p&&e.setAttribute(i,p));for(var E=e.attributes,g=E.length-1;g>=0;g--)n=E[g],i=n.name,o=n.namespaceURI,o?(i=n.localName||i,t.hasAttributeNS(o,i)||e.removeAttributeNS(o,i)):t.hasAttribute(i)||e.removeAttribute(i)}}var te,at="http://www.w3.org/1999/xhtml",P=typeof document>"u"?void 0:document,ot=!!P&&"content"in P.createElement("template"),st=!!P&&P.createRange&&"createContextualFragment"in P.createRange();function lt(e){var t=P.createElement("template");return t.innerHTML=e,t.content.childNodes[0]}function ct(e){te||(te=P.createRange(),te.selectNode(P.body));var t=te.createContextualFragment(e);return t.childNodes[0]}function ut(e){var t=P.createElement("body");return t.innerHTML=e,t.childNodes[0]}function dt(e){return e=e.trim(),ot?lt(e):st?ct(e):ut(e)}function ne(e,t){var r=e.nodeName,n=t.nodeName,i,o;return r===n?!0:(i=r.charCodeAt(0),o=n.charCodeAt(0),i<=90&&o>=97?r===n.toUpperCase():o<=90&&i>=97?n===r.toUpperCase():!1)}function ft(e,t){return!t||t===at?P.createElement(e):P.createElementNS(t,e)}function mt(e,t){for(var r=e.firstChild;r;){var n=r.nextSibling;t.appendChild(r),r=n}return t}function ve(e,t,r){e[r]!==t[r]&&(e[r]=t[r],e[r]?e.setAttribute(r,""):e.removeAttribute(r))}var Re={OPTION:function(e,t){var r=e.parentNode;if(r){var n=r.nodeName.toUpperCase();n==="OPTGROUP"&&(r=r.parentNode,n=r&&r.nodeName.toUpperCase()),n==="SELECT"&&!r.hasAttribute("multiple")&&(e.hasAttribute("selected")&&!t.selected&&(e.setAttribute("selected","selected"),e.removeAttribute("selected")),r.selectedIndex=-1)}ve(e,t,"selected")},INPUT:function(e,t){ve(e,t,"checked"),ve(e,t,"disabled"),e.value!==t.value&&(e.value=t.value),t.hasAttribute("value")||e.removeAttribute("value")},TEXTAREA:function(e,t){var r=t.value;e.value!==r&&(e.value=r);var n=e.firstChild;if(n){var i=n.nodeValue;if(i==r||!r&&i==e.placeholder)return;n.nodeValue=r}},SELECT:function(e,t){if(!t.hasAttribute("multiple")){for(var r=-1,n=0,i=e.firstChild,o,p;i;)if(p=i.nodeName&&i.nodeName.toUpperCase(),p==="OPTGROUP")o=i,i=o.firstChild,i||(i=o.nextSibling,o=null);else{if(p==="OPTION"){if(i.hasAttribute("selected")){r=n;break}n++}i=i.nextSibling,!i&&o&&(i=o.nextSibling,o=null)}e.selectedIndex=r}}},K=1,Ve=11,Ce=3,Ne=8;function U(){}function pt(e){if(e)return e.getAttribute&&e.getAttribute("id")||e.id}function vt(e){return function(r,n,i){if(i||(i={}),typeof n=="string")if(r.nodeName==="#document"||r.nodeName==="HTML"){var o=n;n=P.createElement("html"),n.innerHTML=o}else if(r.nodeName==="BODY"){var p=n;n=P.createElement("html"),n.innerHTML=p;var s=n.querySelector("body");s&&(n=s)}else n=dt(n);else n.nodeType===Ve&&(n=n.firstElementChild);var c=i.getNodeKey||pt,E=i.onBeforeNodeAdded||U,g=i.onNodeAdded||U,h=i.onBeforeElUpdated||U,v=i.onElUpdated||U,V=i.onBeforeNodeDiscarded||U,a=i.onNodeDiscarded||U,d=i.onBeforeElChildrenUpdated||U,u=i.skipFromChildren||U,m=i.addChild||function(y,T){return y.appendChild(T)},A=i.childrenOnly===!0,l=Object.create(null),w=[];function M(y){w.push(y)}function N(y,T){if(y.nodeType===K)for(var L=y.firstChild;L;){var x=void 0;T&&(x=c(L))?M(x):(a(L),L.firstChild&&N(L,T)),L=L.nextSibling}}function O(y,T,L){V(y)!==!1&&(T&&T.removeChild(y),a(y),N(y,L))}function _(y){if(y.nodeType===K||y.nodeType===Ve)for(var T=y.firstChild;T;){var L=c(T);L&&(l[L]=T),_(T),T=T.nextSibling}}_(r);function I(y){g(y);for(var T=y.firstChild;T;){var L=T.nextSibling,x=c(T);if(x){var S=l[x];S&&ne(T,S)?(T.parentNode.replaceChild(S,T),b(S,T)):I(T)}else I(T);T=L}}function f(y,T,L){for(;T;){var x=T.nextSibling;(L=c(T))?M(L):O(T,y,!0),T=x}}function b(y,T,L){var x=c(T);if(x&&delete l[x],!L){var S=h(y,T);if(S===!1||(S instanceof HTMLElement&&(y=S,_(y)),e(y,T),v(y),d(y,T)===!1))return}y.nodeName!=="TEXTAREA"?D(y,T):Re.TEXTAREA(y,T)}function D(y,T){var L=u(y,T),x=T.firstChild,S=y.firstChild,J,k,j,Q,F;e:for(;x;){for(Q=x.nextSibling,J=c(x);!L&&S;){if(j=S.nextSibling,x.isSameNode&&x.isSameNode(S)){x=Q,S=j;continue e}k=c(S);var ee=S.nodeType,H=void 0;if(ee===x.nodeType&&(ee===K?(J?J!==k&&((F=l[J])?j===F?H=!1:(y.insertBefore(F,S),k?M(k):O(S,y,!0),S=F,k=c(S)):H=!1):k&&(H=!1),H=H!==!1&&ne(S,x),H&&b(S,x)):(ee===Ce||ee==Ne)&&(H=!0,S.nodeValue!==x.nodeValue&&(S.nodeValue=x.nodeValue))),H){x=Q,S=j;continue e}k?M(k):O(S,y,!0),S=j}if(J&&(F=l[J])&&ne(F,x))L||m(y,F),b(F,x);else{var se=E(x);se!==!1&&(se&&(x=se),x.actualize&&(x=x.actualize(y.ownerDocument||P)),m(y,x),I(x))}x=Q,S=j}f(y,S,k);var ge=Re[y.nodeName];ge&&ge(y,T)}var R=r,B=R.nodeType,$=n.nodeType;if(!A){if(B===K)$===K?ne(r,n)||(a(r),R=mt(r,ft(n.nodeName,n.namespaceURI))):R=n;else if(B===Ce||B===Ne){if($===B)return R.nodeValue!==n.nodeValue&&(R.nodeValue=n.nodeValue),R;R=n}}if(R===n)a(r);else{if(n.isSameNode&&n.isSameNode(R))return;if(b(R,n,A),w)for(var ae=0,qe=w.length;ae<qe;ae++){var oe=l[w[ae]];oe&&O(oe,oe.parentNode,!1)}}return!A&&R!==r&&r.parentNode&&(R.actualize&&(R=R.actualize(r.ownerDocument||P)),r.parentNode.replaceChild(R,r)),R}}var gt=vt(it),Pe=gt;var bt=220;function wt(e){e.tagName==="STYLE"||e.tagName==="SCRIPT"||e.tagName==="LINK"||typeof e.animate=="function"&&(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches||e.animate([{opacity:0},{opacity:1}],{duration:bt,easing:"ease-out"}))}function Oe(e){let t=e.lastIndexOf("<");return t===-1?e:e.indexOf(">",t)===-1?e.slice(0,t):e}function _e(e,t,r={}){let n=r.fade??!0,i=e.cloneNode(!1);i.innerHTML=t,Pe(e,i,{childrenOnly:!0,onBeforeElUpdated(o,p){return Se(o,p)?!1:(Ee(o,p),!o.isEqualNode(p))},onNodeAdded(o){return n&&o.nodeType===Node.ELEMENT_NODE&&wt(o),o}})}function ht(e){let t=document.createElement("script");for(let r of Array.from(e.attributes))t.setAttribute(r.name,r.value);return t.textContent=e.textContent??"",t}function yt(e){return new Promise(t=>{e.addEventListener("load",()=>t(null),{once:!0}),e.addEventListener("error",()=>t(`Failed to load ${e.src}`),{once:!0})})}async function ke(e,t){for(let r of Array.from(e.querySelectorAll("script"))){let n=ht(r),o=n.hasAttribute("src")?yt(n):null;r.replaceWith(n);let p=o?await o:null;p&&t?.({src:n.src,message:p})}}function Tt(e){return Array.from(e.children).filter(t=>["STYLE","LINK","SCRIPT"].includes(t.tagName)).map(t=>t.outerHTML).join("")}function Ie(e){let{root:t}=e,r="",n=!1,i="",o=0,p=new Set;function s(h){for(let v of p)h?.hasAttribute(v)||document.body.removeAttribute(v);p=new Set;for(let v of Array.from(h?.attributes??[]))document.body.setAttribute(v.name,v.value),p.add(v.name)}function c(){let h=n?r:Oe(r);if(e.markup==="fragment")return h;if(!h)return s(null),"";let v=new DOMParser().parseFromString(h,"text/html");return s(v.body),Tt(v.head)+v.body.innerHTML}function E(){let h=c();h!==i&&(_e(t,h,{fade:!(n&&o===0)}),i=h,o+=1),e.onRender?.()}let g=Me(E,e.clock,e.intervalMs);return{append(h){n||typeof h!="string"||h.length===0||(r+=h,g.request())},async complete(){n||(n=!0,g.flushNow(),await ke(t,e.onScriptFailure),e.onComplete?.())},abort(){g.cancel(),r="",i="",o=0,n=!1,t.replaceChildren(),s(null),e.onRender?.()},get completed(){return n}}}function De(e,t){if(typeof e!="string"||e.length===0)return"";let r=e.trim();if(r.startsWith("rgb("))return r.replace(/^rgb\\((.*)\\)$/i,`rgba($1, ${t})`);if(r.startsWith("rgba("))return r.replace(/^rgba\\(([^,]+),([^,]+),([^,]+),[^)]+\\)$/i,`rgba($1,$2,$3, ${t})`);if(!r.startsWith("#"))return"";let n=r.slice(1),i=n.length===3?n.split("").map(c=>c+c).join(""):n.length===6?n:"";if(!i)return"";let[o,p,s]=[0,2,4].map(c=>Number.parseInt(i.slice(c,c+2),16));return`rgba(${o}, ${p}, ${s}, ${t})`}function Et(e){let t=e.mode==="dark",r=e.tokens?.surface||(t?"#09090b":"#ffffff"),n=e.tokens?.surfaceMuted||(t?"rgba(255, 255, 255, 0.04)":"rgba(15, 23, 42, 0.03)"),i=e.tokens?.text||(t?"#fafafa":"#09090b"),o=e.tokens?.accent||i;return{"--widget-bg":"transparent","--widget-surface":r,"--widget-surface-muted":n,"--widget-border":De(i,t?.14:.1)||(t?"rgba(255, 255, 255, 0.14)":"rgba(15, 23, 42, 0.1)"),"--widget-text":i,"--widget-text-muted":De(i,t?.7:.62)||(t?"rgba(250, 250, 250, 0.7)":"rgba(15, 23, 42, 0.62)"),"--widget-accent":o,"--widget-accent-contrast":t?"#09090b":"#ffffff","--widget-radius":"16px","--widget-font-family":\'"Inter", "Segoe UI", sans-serif\',"--widget-font-heading":\'600 1rem/1.2 "Inter", "Segoe UI", sans-serif\',"--widget-font-text-s":"0.875rem","--widget-font-text-m":"1rem","--widget-control-height":"2.75rem","--widget-shadow-1":"none"}}var Fe=new Set;function He(e){if(!e||e.mode!=="light"&&e.mode!=="dark")return!1;let t=document.documentElement,r={...Et(e),...e.variables};for(let n of Fe)n in r||t.style.removeProperty(n);for(let[n,i]of Object.entries(r))t.style.setProperty(n.startsWith("--")?n:`--${n}`,i);return Fe=new Set(Object.keys(r)),t.dataset.themeMode=e.mode,t.style.colorScheme=e.mode,!0}var re,ie=["top","right","bottom","left"];function Ue(e){let t={top:0,right:0,bottom:0,left:0};for(let n of ie){let i=e?.[n]??0;if(typeof i!="number"||!Number.isFinite(i)||i<0)return null;t[n]=i}for(let n of ie)document.documentElement.style.setProperty(`--viewer-safe-area-${n}`,`${t[n]}px`);re||(re=document.createElement("style"),document.head.appendChild(re));let r=ie.map(n=>`${t[n]}px`).join(" ");return re.textContent=ie.some(n=>t[n]>0)?`html { box-sizing: border-box !important; padding: ${r} !important; scroll-padding: ${r} !important; }`:"",t}var C={scale:1,x:0,y:0};function Be(){return C}function Z(e,t){if(!e||typeof e!="object")return;let r=e,n=Number(r.scale),i=Number(r.x),o=Number(r.y);if(!(!Number.isFinite(n)||!Number.isFinite(i)||!Number.isFinite(o))&&(C={scale:n,x:i,y:o},!!t)){if(t.setAttribute("data-viewer-zoom-target",""),n===1&&i===0&&o===0){t.style.removeProperty("transform"),t.style.removeProperty("transform-origin"),t.style.removeProperty("will-change");return}t.style.transformOrigin="0 0",t.style.willChange="transform",t.style.transform=`translate3d(${i}px, ${o}px, 0) scale(${n})`}}function $e(e){let t=new Map,r=0,n=1,i=null,o=null,p=!1,s=1,c=4,E=a=>Math.min(c,Math.max(s,a)),g=()=>{document.documentElement.style.touchAction=C.scale>s?"none":"pan-x pan-y"},h=a=>{Z(a,e()),g()};function v(){let a=Array.from(t.values());a.length<2||(r=Math.max(Math.hypot(a[1].x-a[0].x,a[1].y-a[0].y),1),n=C.scale,i=null,o=null,p=!0)}document.addEventListener("pointerdown",a=>{a.pointerType==="touch"&&(t.set(a.pointerId,{x:a.clientX,y:a.clientY}),t.size===2?(a.preventDefault(),v()):C.scale>s&&(i={x:a.clientX,y:a.clientY},o={...C},p=!1))}),document.addEventListener("pointermove",a=>{if(a.pointerType!=="touch"||!t.has(a.pointerId))return;t.set(a.pointerId,{x:a.clientX,y:a.clientY});let d=Array.from(t.values());if(d.length>=2&&r>0){a.preventDefault();let u={x:(d[0].x+d[1].x)/2,y:(d[0].y+d[1].y)/2},m=Math.hypot(d[1].x-d[0].x,d[1].y-d[0].y),A=E(n*(m/r)),l=A/C.scale;h({scale:A,x:u.x-(u.x-C.x)*l,y:u.y-(u.y-C.y)*l});return}if(d.length===1&&C.scale>s&&i&&o){let u=d[0],m=u.x-i.x,A=u.y-i.y;(Math.abs(m)>3||Math.abs(A)>3)&&(p=!0),p&&(a.preventDefault(),h({scale:C.scale,x:o.x+m,y:o.y+A}))}});let V=a=>{if(!(a.pointerType!=="touch"||!t.has(a.pointerId))){if(t.delete(a.pointerId),t.size>=2){v();return}if(t.size===1&&C.scale>s){i=Array.from(t.values())[0],o={...C};return}r=0,i=null,o=null,C.scale-s<.015&&Z({scale:s,x:0,y:0},e()),g()}};document.addEventListener("pointerup",V),document.addEventListener("pointercancel",V),document.addEventListener("wheel",a=>{if(!a.ctrlKey&&!a.metaKey)return;a.preventDefault();let d=E(C.scale*Math.exp(-a.deltaY*.002)),u=d/C.scale;h({scale:d,x:a.clientX-(a.clientX-C.x)*u,y:a.clientY-(a.clientY-C.y)*u})},{passive:!1}),g()}function At(e){let{channel:t,rootId:r}=e,n=new Set,i=!1,o=0,p=0,s=e.widget?.layout==="inline",c=(f,b)=>window.parent.postMessage({channel:t,type:f,...b},"*"),E=()=>document.getElementById(r),g=()=>E()??document.body;function h(){if(s&&document.body){let b=Math.ceil(document.body.getBoundingClientRect().height);return p=A?.completed?b:Math.max(p,b),p}let f=E();return Math.max(f?Math.ceil(f.getBoundingClientRect().height):0,document.body?.scrollHeight??0,document.body?.offsetHeight??0,document.documentElement?.scrollHeight??0,document.documentElement?.offsetHeight??0)}function v(f){o&&pe(o),o=me(()=>{o=0,c("artifact.resize",{height:h(),reason:f})})}function V(f){!f||!He(f)||(window.artifactRenderer.themeMode=f.mode,window.artifactRenderer.theme=f,window.dispatchEvent(new CustomEvent("dvina-artifact-renderer:theme",{detail:f})),document.dispatchEvent(new CustomEvent("dvina-artifact-renderer:theme",{detail:f})))}function a(f){let b=Ue(f);b&&(window.artifactRenderer.safeArea=b,window.dispatchEvent(new CustomEvent("dvina-artifact-renderer:safe-area",{detail:b})))}function d(f){window.__artifactRendererData=f,window.dispatchEvent(new CustomEvent("dvina-artifact-renderer:data",{detail:f}));for(let b of n)try{b(f)}catch{}}window.artifactRenderer={version:"0.2.0",themeMode:e.theme.mode,theme:e.theme,getData:()=>window.__artifactRendererData,onData(f){return typeof f!="function"?()=>{}:(n.add(f),()=>n.delete(f))},emit(f,b){typeof f!="string"||f.length===0||c("artifact.event",{name:f,detail:b})},requestResize:()=>v("renderer")};let u=he({channel:t,enabled:e.widget?.bridge!==!1,data:e.widget?.data===!0,pictures:e.widget?.pictures===!0,post:f=>window.parent.postMessage(f,"*")});if(window.sendPrompt=u.prompt.send,window.openLink=u.link.open,window.dvina=u.dvina,u.interceptLinks(),e.widget){let f=Te({call:u.pictures}),b=xe({call:u.pictures,open:u.link.open}),D=()=>{f.observe(document.body),b.observe(document.body)};document.body?D():document.addEventListener("DOMContentLoaded",D,{once:!0})}let m=f=>c("artifact.event",{name:"runtime.error",detail:{message:f}}),A=null;function l(){if(A)return A;let f=E();return!e.stream||!f?null:(A=Ie({root:f,markup:e.stream,onRender(){Z(Be(),g()),v("content")},onComplete(){e.widget&&window.__dvinaSvgMenu?.(e.widget.labels),document.dispatchEvent(new Event("DOMContentLoaded",{bubbles:!0})),window.dispatchEvent(new Event("load")),v("content")},onScriptFailure:b=>m(b.message)}),A)}window.addEventListener("message",f=>{let b=f.data;if(!(!b||b.channel!==t||f.source!==window.parent)&&!u.receive(b))switch(b.type){case"artifact.set-safe-area":a(b.safeArea),v("renderer");return;case"artifact.set-theme":V(b.theme),v("renderer");return;case"artifact.update-data":d(b.data);return;case"artifact.set-zoom-transform":Z(b.transform,g());return;case"artifact.stream-append-html":l()?.append(b.html);return;case"artifact.stream-complete":l()?.complete();return;case"artifact.react-module":M(b);return;case"artifact.stream-abort":l()?.abort();return}});let w=!1;async function M(f){let b=E();if(w||!b)return;w=!0;let D={text:document.getElementById("dvina-kit-react")?.textContent??void 0,url:e.kitReactUrl};try{if(f.error||!f.code)throw new Error(f.error||"The widget has no code.");if(!window.__dvinaMountReact)throw new Error("React mode is not loaded in this frame.");await window.__dvinaMountReact(b,f.code,D)}catch(R){let B=R instanceof Error?R.message:String(R),$=document.createElement("p");$.setAttribute("role","alert"),$.className="dvina-widget-error",$.textContent=`This widget could not be shown: ${B}`,b.replaceChildren($),m(B)}v("content")}function N(){i||(i=!0,c("artifact.ready",{}),v("renderer"),e.initialData!==void 0&&d(e.initialData),e.initialReact&&M(e.initialReact),e.initialHtml!==void 0&&(l()?.append(e.initialHtml),l()?.complete()))}if(window.addEventListener("load",N,{once:!0}),document.readyState==="complete"?N():document.addEventListener("DOMContentLoaded",N,{once:!0}),V(e.theme),a(e.safeArea),$e(g),typeof ResizeObserver=="function"){let f=new ResizeObserver(()=>v("content"));f.observe(document.documentElement),document.body?f.observe(document.body):document.addEventListener("DOMContentLoaded",()=>f.observe(document.body),{once:!0})}window.addEventListener("resize",()=>v("viewport"));let O=0,_=null,I=new WeakMap;document.addEventListener("scroll",f=>{let b=f.target===document?document.scrollingElement||document.documentElement:f.target;if(!b||typeof b.scrollTop!="number")return;let D=I.get(b)??0;I.set(b,b.scrollTop),b.scrollTop!==D&&(_=b.scrollTop,!O&&(O=requestAnimationFrame(()=>{O=0,c("artifact.scroll",{scrollTop:_})})))},{capture:!0,passive:!0}),window.addEventListener("error",f=>m(f.message||"Executable HTML runtime error")),window.addEventListener("unhandledrejection",f=>{let b=f.reason;m(b instanceof Error?b.message:String(b??"Unhandled rejection"))})}window.__dvinaFrame&&At(window.__dvinaFrame);})();\n';function Vr(){let e=0;const t=new Map;function n(){const r=[];for(;t.has(e);){const a=t.get(e);t.delete(e),a!==void 0&&r.push({html:a,sequence:e}),e+=1}return r}return{push(r){if(r.sequence===void 0){const a=e;return e+=1,[{html:r.html,sequence:a}]}return r.sequence<e?[]:(t.set(r.sequence,r.html),n())},reset(){t.clear(),e=0}}}var Ur="dvina-widget";function qr(e){const t=new RegExp(`<meta name="${Ur}" content="(html|react)"`).exec(e.slice(0,4096));return t?t[1]:null}const Hr=1e3,Br=30,Wr=24,Gr=1e4,Kr="image.read";function Xr(e){const t=e.gapMs??Hr,n=new Map,r={data:[],pictures:[]};return function(o,i){if(!Kt(o))return{ok:!1,error:{code:"invalid-params",message:`Unknown method ${String(o)}.`}};if(!Xt(o,i))return{ok:!1,error:{code:"invalid-params",message:`Invalid params for ${o}.`}};if(Hn.includes(o)){if(!e.isUserActive())return{ok:!1,error:{code:"user-activation-required",message:`${o} needs a click or key press first.`}};const c=e.now();if(c-(n.get(o)??Number.NEGATIVE_INFINITY)<t)return{ok:!1,error:{code:"rate-limited",message:`${o} was asked too soon again.`}};n.set(o,c)}if(o==="dvina/call"){const c=i.name===Kr?"pictures":"data",s=c==="pictures"?Wr:Br,l=e.now();if(r[c]=r[c].filter(p=>l-p<Gr),r[c].length>=s)return{ok:!1,error:{code:"rate-limited",message:"Too many host calls; wait a moment."}};r[c].push(l)}return{ok:!0,method:o,params:i}}}function Yr(){var e;return((e=navigator.userActivation)==null?void 0:e.isActive)??!1}const H="dvina-artifact-renderer-html",We="dvina-viewer:artifact-scroll",et="dvina-artifact-renderer-stream-root",Zr=["allow-downloads","allow-forms","allow-same-origin","allow-scripts"];function Qr(e){if(typeof e!="object"||e===null)return!1;const t=e;return t.channel===H&&t.jsonrpc==="2.0"&&typeof t.id=="string"&&"method"in t}function Jr(e){const t=e.params;return e.method==="dvina/call"&&(t==null?void 0:t.name)==="image.read"}function ke(e){return e.replaceAll("&","&").replaceAll('"',""").replaceAll("<","<").replaceAll(">",">")}function ei(e){var t,n,r,a;return[e.mode,((t=e.tokens)==null?void 0:t.surface)??"",((n=e.tokens)==null?void 0:n.surfaceMuted)??"",((r=e.tokens)==null?void 0:r.text)??"",((a=e.tokens)==null?void 0:a.accent)??"",JSON.stringify(e.variables??{})].join(":")}function Ge(e){return e===null||typeof e=="string"||typeof e=="boolean"?!0:typeof e=="number"?Number.isFinite(e):Array.isArray(e)?e.every(Ge):typeof e!="object"||e===null?!1:Object.values(e).every(Ge)}function ti(e){if(typeof e!="object"||e===null)return!1;const t=e;return t.channel!==H?!1:t.type==="artifact.ready"||t.type==="artifact.scroll"&&typeof t.scrollTop=="number"&&Number.isFinite(t.scrollTop)||t.type==="artifact.resize"&&typeof t.height=="number"&&(t.reason==="content"||t.reason==="viewport"||t.reason==="renderer")?!0:t.type==="artifact.event"&&(t.name===void 0||typeof t.name=="string")&&(t.detail===void 0||Ge(t.detail))}function pe(e){return e.replace(/<\/script/gi,"<\\/script").replace(/<!--/g,"<\\!--")}function De(e){return e.replace(/<\/style/gi,"<\\/style")}function Pe(e){const t={channel:H,rootId:et,...e};return`<script>window.__dvinaFrame=${pe(JSON.stringify(t))};<\/script><script>${pe($r)}<\/script>`}function ni(e,t,n,r,a={}){const o=`<base href="${ke(t)}"><style>html, body { margin: 0; padding: 0; background: transparent; }</style>${Pe({initialData:n,theme:r,safeArea:a})}`;return/<head[^>]*>/i.test(e)?e.replace(/<head([^>]*)>/i,`<head$1>${o}`):/<html[^>]*>/i.test(e)?e.replace(/<html([^>]*)>/i,`<html$1><head>${o}</head>`):`<!doctype html><html><head>${o}</head><body>${e}</body></html>`}function ri(e,t,n={}){return`<!doctype html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><style>html, body { margin: 0; padding: 0; background: transparent; }</style>${Pe({initialData:e,theme:t,safeArea:n,stream:"document"})}</head><body><div id="${et}"></div></body></html>`}function ii(e,t,n,r,a={}){const o=t.layout??"panel",i=fe,c=f=>ke(Be(f)),s=f=>i.inline?`<script>${pe(f)}<\/script>`:`<script src="${c(f)}"><\/script>`,l=Pe({initialData:n,theme:r,safeArea:a,widget:{layout:o,bridge:t.bridge!==!1,labels:t.labels,data:t.data===!0,pictures:t.pictures??t.bridge!==!1}}),p=`<meta http-equiv="Content-Security-Policy" content="${ke(Jt())}" /><style>${en[o]}</style>${l}${s(i.svgMenu)}`;return e.replace(/<html([^>]*)>/i,(f,g)=>`<html${g.replace(/\s(data-widget-layout|data-theme-mode)="[^"]*"/g,"")} data-widget-layout="${o}" data-theme-mode="${r.mode}">`).replace(/<head([^>]*)>/i,`<head$1>${p}`)}function St(e,t,n,r={},a,o){const i=e.layout??"inline",c=e.kind==="react",s=e.kit===void 0?void 0:e.kit||{},l=fe,p=Pe({initialData:t,theme:n,safeArea:r,stream:"fragment",widget:{layout:i,bridge:e.bridge!==!1,labels:e.labels,data:e.data===!0,pictures:e.pictures??e.bridge!==!1},initialHtml:a,initialReact:o,kitReactUrl:s||l.inline?void 0:Be(l.kitReactScript)}),u=s??(l.inline?{css:l.kitCss,script:l.kitScript,reactScript:l.kitReactScript}:null),f=w=>ke(Be(w)),g=u?u.css?`<style id="dvina-kit">${De(u.css)}</style>`:"":`<link rel="stylesheet" id="dvina-kit" href="${f(l.kitCss)}" />`,m=u?u.script?`<script id="dvina-kit-script">${pe(u.script)}<\/script>`:"":`<script id="dvina-kit-script" src="${f(l.kitScript)}"><\/script>`,x=w=>l.inline?`<script>${pe(w)}<\/script>`:`<script src="${f(w)}"><\/script>`,E=`<style type="text/tailwindcss" id="dvina-tailwind">${De(l.tailwindCss)}</style>${x(l.tailwindScript)}`,b=c?`${E}${x(l.reactLoader)}${u!=null&&u.reactScript?`<script type="text/plain" id="dvina-kit-react">${pe(u.reactScript)}<\/script>`:""}`:"",S=`<style id="dvina-tokens">${De(l.tokensCss)}</style>`;return`<!doctype html><html data-widget-layout="${i}" data-theme-mode="${n.mode}"><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><meta http-equiv="Content-Security-Policy" content="${ke(Jt())}" /><style>${en[i]}</style>${S}${g}${p}${x(l.svgMenu)}${m}${b}</head><body><div id="${et}"></div></body></html>`}function ai(e,t,n){return!Number.isFinite(e)||e<=0?t:n?Math.max(t,Math.ceil(e)):Math.ceil(e)}function oi({label:e}){return v.jsxs("div",{className:"document-loading",children:[v.jsx("div",{className:"document-spinner"}),v.jsx("p",{children:e})]})}function si({title:e,message:t}){return v.jsxs("div",{className:"document-empty-state",children:[v.jsx("h3",{children:e}),v.jsx("p",{children:t})]})}function li({document:e,session:t,theme:n,safeArea:r,artifactDataMessage:a,streamCommandMessage:o,onLoaded:i,onError:c,onTelemetry:s,onResize:l,onArtifactEvent:p,onWidgetRequest:u,widgetResponseMessage:f}){var lt,ct,ut,dt,ft,pt,mt,ht,gt,vt,bt;const g=h.useMemo(()=>Qt(e,t),[e,t]),m=h.useRef(null),x=h.useRef(!1),E=h.useRef(!1),b=h.useRef(n),S=h.useRef(r),w=h.useRef({chunks:[],completed:!1}),z=h.useRef((ct=(lt=e.renderOptions)==null?void 0:lt.html)==null?void 0:ct.artifactData),L=h.useRef([]),O=h.useRef(Vr()),[V,y]=h.useState({status:"loading"}),A=h.useRef(0),d=h.useRef(0);b.current=n,S.current=r;const D=h.useMemo(()=>ei(n),[n]),M=e.format==="widget",T=(ut=e.renderOptions)==null?void 0:ut.widget,K=M?T==null?void 0:T.artifactData:(ft=(dt=e.renderOptions)==null?void 0:dt.html)==null?void 0:ft.artifactData,X=Te(e.format)&&e.source.kind==="stream",ee=M&&(T==null?void 0:T.kind)==="react",Y=M&&((T==null?void 0:T.layout)??"inline")==="inline"?Fr(T==null?void 0:T.viewportHeight):void 0,I=h.useRef(At(Y??0)),[P,N]=h.useState(Y??0),k=h.useMemo(()=>{var $,U;const C=(M?T==null?void 0:T.revisionId:(U=($=e.renderOptions)==null?void 0:$.html)==null?void 0:U.revisionId)??"live",R=(g==null?void 0:g.url)??e.id;return`${e.id}:${C}:${R}`},[e.id,(mt=(pt=e.renderOptions)==null?void 0:pt.html)==null?void 0:mt.revisionId,M,T==null?void 0:T.revisionId,g==null?void 0:g.url]),B=k,F=h.useMemo(()=>{var $,U;const C=(U=($=e.renderOptions)==null?void 0:$.html)==null?void 0:U.sandbox,R=M?Pr:C&&C.length>0?C:Zr;return Array.from(new Set(R)).join(" ")},[M,(gt=(ht=e.renderOptions)==null?void 0:ht.html)==null?void 0:gt.sandbox]),Z=()=>{var C;if(!(!E.current||!((C=m.current)!=null&&C.contentWindow))){for(const R of L.current)m.current.contentWindow.postMessage(R,"*");L.current=[]}},W=C=>{var R;if(!E.current||!((R=m.current)!=null&&R.contentWindow)){L.current.push(C);return}m.current.contentWindow.postMessage(C,"*")},ge=()=>{L.current=L.current.filter(C=>{const R=C;return R.type!=="artifact.stream-append-html"&&R.type!=="artifact.stream-complete"&&R.type!=="artifact.stream-abort"})};h.useEffect(()=>{const C=m.current;if(!C)return;const R=$=>{const U=$.detail;W({channel:H,type:"artifact.set-zoom-transform",transform:U})};return C.addEventListener("viewer-zoom-transform",R),()=>C.removeEventListener("viewer-zoom-transform",R)},[B,V.status]),h.useEffect(()=>{z.current=K,ve.current=null,d.current=0,O.current.reset(),w.current={chunks:[],completed:!1}},[k,K]),h.useEffect(()=>{x.current=!1,E.current=!1,L.current=[],A.current=0,I.current=At(Y??0),N(Y??0)},[B,Y]);const ve=h.useRef(null),ot=async()=>{ve.current??(ve.current=yt(w.current.chunks.map(R=>R.html).join("")));const C=await ve.current;W({channel:H,type:"artifact.react-module",...C})},Tn=()=>{if(X){if(ee){w.current.completed&&ot();return}for(const C of w.current.chunks)W({channel:H,type:"artifact.stream-append-html",html:C.html,sequence:C.sequence});w.current.completed&&W({channel:H,type:"artifact.stream-complete"})}};h.useEffect(()=>{var $,U;if(X&&M){let q=!0;return Et().then(()=>{q&&y({status:"srcdoc",markup:St(T??{},K,b.current,S.current)})}),s==null||s("info","html.render.mode","Widget stream shell mounted.",{documentId:e.id,mode:"widget-stream-shell"}),()=>{q=!1}}if(X){y({status:"srcdoc",markup:ri(K,b.current,S.current)}),s==null||s("info","html.render.mode","Executable HTML stream shell mounted.",{documentId:e.id,mode:"stream-shell"});return}if(!g){y({status:"error",message:"The HTML artifact does not expose a preview-safe URL."});return}const C=new AbortController,R=M||((U=($=e.renderOptions)==null?void 0:$.html)==null?void 0:U.bootstrap)!=="off";return y({status:"loading"}),!R&&e.source.kind==="url"?(y({status:"url",url:g.url}),s==null||s("info","html.render.mode","HTML artifact is loading from a direct URL.",{documentId:e.id,mode:"url"}),()=>C.abort()):(fetch(g.url,{...g.init,signal:C.signal}).then(async q=>{var wt,xt;if(!q.ok)throw new Error(`Request failed with status ${q.status}`);const ce=await q.text();M&&await Et(),y({status:"srcdoc",markup:M&&qr(ce)?ii(ce,T??{},K,b.current,S.current):M?St(T??{},K,b.current,S.current,ee?void 0:ce,ee?await yt(ce):void 0):R?ni(ce,g.url,(xt=(wt=e.renderOptions)==null?void 0:wt.html)==null?void 0:xt.artifactData,b.current,S.current):ce}),s==null||s("info","html.render.mode",R?"HTML artifact is loading through sandboxed srcdoc bootstrap.":"HTML artifact is loading through sandboxed srcdoc without bootstrap.",{documentId:e.id,mode:R?"srcdoc-bootstrap":"srcdoc"})}).catch(q=>{if(!C.signal.aborted){if(e.source.kind==="url"&&!M){y({status:"url",url:g.url}),s==null||s("warn","html.render.fallback","HTML bootstrap fetch failed, falling back to direct URL mode.",{documentId:e.id,error:q instanceof Error?q.message:"Unknown fetch failure"});return}y({status:"error",message:q instanceof Error?q.message:"Unknown HTML fetch failure"})}}),()=>C.abort())},[e,X,s,g]),h.useEffect(()=>{W({channel:H,type:"artifact.set-theme",theme:n})},[D]),h.useEffect(()=>{E.current&&W({channel:H,type:"artifact.set-safe-area",safeArea:r??{}})},[r]),h.useEffect(()=>{a&&(z.current=a.data,W({channel:H,type:"artifact.update-data",data:a.data}))},[a==null?void 0:a.nonce]),h.useEffect(()=>{const C=(o==null?void 0:o.commands)??[];if(C.length<d.current&&(d.current=0),!!X){for(const R of C.slice(d.current))jn(R);d.current=C.length}},[X,o==null?void 0:o.nonce]);function jn(C){if(C.type==="append"){const R=O.current.push({html:C.html,sequence:C.sequence});for(const $ of R)w.current.chunks.push($),!ee&&W({channel:H,type:"artifact.stream-append-html",html:$.html,sequence:$.sequence});return}if(C.type==="abort"){O.current.reset(),w.current={chunks:[],completed:!1},W({channel:H,type:"artifact.stream-abort",reason:C.reason});return}if(w.current.completed=!0,ee){ot();return}W({channel:H,type:"artifact.stream-complete"})}const Mn=h.useRef(Xr({isUserActive:Yr,now:()=>performance.now()})),Ne=h.useRef(new Map),Pn=h.useRef(0),Le=(C,R)=>{var $,U;(U=($=m.current)==null?void 0:$.contentWindow)==null||U.postMessage({channel:H,jsonrpc:"2.0",id:C,...R},"*")},Nn=C=>{if(M&&(T==null?void 0:T.bridge)===!1&&!(T.pictures&&Jr(C))){Le(C.id,{error:{code:"bridge-off",message:"The widget bridge is off."}});return}const R=Mn.current(C.method,C.params);if(!R.ok){Le(C.id,{error:R.error});return}if(!u){Le(C.id,{error:{code:"no-handler",message:"The host takes no widget requests."}});return}const $=`${e.id}:${++Pn.current}`;Ne.current.set($,C.id),u({requestId:$,method:R.method,params:R.params})},Ce=h.useRef(0);if(h.useEffect(()=>{const C=(f==null?void 0:f.payloads)??[];C.length<Ce.current&&(Ce.current=0);for(const{requestId:R,result:$,error:U}of C.slice(Ce.current)){const q=Ne.current.get(R);q!==void 0&&(Ne.current.delete(R),Le(q,U?{error:U}:{result:$??null}))}Ce.current=C.length},[f==null?void 0:f.nonce]),h.useEffect(()=>{const C=R=>{var $;if(R.source===(($=m.current)==null?void 0:$.contentWindow)){if(Qr(R.data)){Nn(R.data);return}if(ti(R.data)){if(R.data.type==="artifact.ready"){E.current=!0,z.current!==void 0&&W({channel:H,type:"artifact.update-data",data:z.current}),ge(),Z(),W({channel:H,type:"artifact.set-safe-area",safeArea:S.current??{}}),Tn(),s==null||s("info","html.artifact.ready","Executable HTML artifact announced readiness.",{documentId:e.id});return}if(R.data.type==="artifact.resize"){const U=ai(R.data.height,A.current,X&&!M);if(U<=0)return;if(A.current=U,Y===void 0){l==null||l(U,R.data.reason);return}const q=zr(I.current,U,Y);I.current=q.frame,N(q.frame.height),l==null||l(q.shown,R.data.reason);return}if(R.data.type==="artifact.scroll"){window.dispatchEvent(new CustomEvent(We,{detail:{scrollTop:R.data.scrollTop}}));return}R.data.type==="artifact.event"&&R.data.name&&(p==null||p(R.data.name,R.data.detail))}}};return window.addEventListener("message",C),()=>window.removeEventListener("message",C)},[e.id,X,p,l,s,u,B,Y,T==null?void 0:T.bridge]),h.useEffect(()=>{V.status==="error"&&c("document-fetch-failed",V.message,!0)},[c,V]),V.status==="loading")return M&&((T==null?void 0:T.layout)??"inline")==="inline"?null:v.jsx(oi,{label:"Preparing executable HTML artifact"});if(V.status==="error")return v.jsx(si,{title:"HTML preview unavailable",message:V.message});const st={ref:m,key:B,className:"document-html-frame",style:Y===void 0?{colorScheme:n.mode}:{colorScheme:n.mode,height:`${P}px`},allow:"clipboard-write","data-viewer-zoom-target":"","data-viewer-zoom-bridge":"html",title:e.name,sandbox:F,onLoad:()=>{x.current||(x.current=!0,i())},onError:()=>{c("renderer-failed","The executable HTML iframe could not be mounted.",!0)}};return v.jsx("div",{className:"document-html-shell","data-safe-area-fallback":!F.split(" ").includes("allow-scripts")||V.status==="url"||!X&&((bt=(vt=e.renderOptions)==null?void 0:vt.html)==null?void 0:bt.bootstrap)==="off",children:V.status==="srcdoc"?v.jsx("iframe",{...st,srcDoc:V.markup}):v.jsx("iframe",{...st,src:V.url})})}const Lt=48;function ci({distance:e=Lt,onProgress:t,requestFrame:n=a=>window.requestAnimationFrame(a),cancelFrame:r=a=>window.cancelAnimationFrame(a)}){let a=e,o=null,i=0,c=0;const s=new WeakMap;function l(g){const m=Math.min(1,Math.max(0,g/a));return Math.round(m*100)/100}function p(){if(i=0,o===null)return;const g=l(o);o=null,g!==c&&(c=g,t(g))}function u(g){Number.isFinite(g)&&(o=g,i||(i=n(p)))}function f(g){if(g instanceof Document){const m=g.scrollingElement??g.documentElement;return{key:g,top:m.scrollTop}}return g instanceof Element?{key:g,top:g.scrollTop}:null}return{handleScroll(g){const m=f(g.target);if(!m)return;const x=s.get(m.key)??0;s.set(m.key,m.top),m.top!==x&&u(m.top)},report:u,reset(){o=null,i&&r(i),i=0,c!==0&&(c=0,t(0))},setDistance(g){a=g!==void 0&&Number.isFinite(g)&&g>0?g:Lt},dispose(){i&&r(i),i=0,o=null}}}const te=1,ui=4,di=.015,Ct=3;function Rt(e){return Math.min(ui,Math.max(te,e))}function fi(e,t){return{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}function It(e,t){return Math.hypot(t.x-e.x,t.y-e.y)}function pi(e){const t=e.querySelector("[data-viewer-zoom-target]");return t?t.dataset.viewerZoomBridge==="html"?{kind:"bridge",element:t}:{kind:"element",element:t}:null}function mi(e,t){if(e.kind==="bridge"){e.element.dispatchEvent(new CustomEvent("viewer-zoom-transform",{detail:t}));return}e.element.style.transformOrigin="0 0",e.element.style.willChange="transform",e.element.style.transform=`translate3d(${t.x}px, ${t.y}px, 0) scale(${t.scale})`}function Tt(e){if(e.kind==="bridge"){e.element.dispatchEvent(new CustomEvent("viewer-zoom-transform",{detail:{scale:te,x:0,y:0}}));return}e.element.style.removeProperty("transform"),e.element.style.removeProperty("transform-origin"),e.element.style.removeProperty("will-change")}function hi(e,t){h.useEffect(()=>{const n=e.current;if(!n||!t)return;const r=new Map;let a=null,o=null,i={scale:te,x:0,y:0},c=0,s=te,l=null,p=null,u=!1,f=0;const g=()=>{n.style.touchAction=i.scale>te?"none":"pan-x pan-y"},m=()=>{if(a??(a=pi(n)),a&&!o){const y=n.getBoundingClientRect(),A=a.element.getBoundingClientRect();o={x:A.left-y.left,y:A.top-y.top}}return a},x=y=>{const A=n.getBoundingClientRect();return{x:y.clientX-A.left,y:y.clientY-A.top}},E=()=>(m(),o??{x:0,y:0}),b=()=>{f=0;const y=m();y&&mi(y,i)},S=y=>{i=y,g(),f||(f=requestAnimationFrame(b))},w=()=>{const y=Array.from(r.values());y.length<2||!m()||(c=Math.max(It(y[0],y[1]),1),s=i.scale,l=null,p=null,u=!0)},z=y=>{var A;if(y.pointerType==="touch"){if(r.set(y.pointerId,x(y)),r.size===2){m(),y.preventDefault(),(A=n.setPointerCapture)==null||A.call(n,y.pointerId),w();return}r.size===1&&i.scale>te&&m()&&(l=x(y),p={...i},u=!1)}},L=y=>{if(y.pointerType!=="touch"||!r.has(y.pointerId))return;r.set(y.pointerId,x(y));const A=Array.from(r.values());if(A.length>=2&&c>0){y.preventDefault();const d=fi(A[0],A[1]),D=Rt(s*(It(A[0],A[1])/c)),M=D/i.scale,T=E();S({scale:D,x:d.x-T.x-(d.x-T.x-i.x)*M,y:d.y-T.y-(d.y-T.y-i.y)*M});return}if(A.length===1&&i.scale>te&&l&&p){const d=A[0],D=d.x-l.x,M=d.y-l.y;(Math.abs(D)>Ct||Math.abs(M)>Ct)&&(u=!0),u&&(y.preventDefault(),S({scale:i.scale,x:p.x+D,y:p.y+M}))}},O=y=>{var A;if(!(y.pointerType!=="touch"||!r.has(y.pointerId))){if(r.delete(y.pointerId),(A=n.releasePointerCapture)==null||A.call(n,y.pointerId),r.size>=2){w();return}if(r.size===1&&i.scale>te){l=Array.from(r.values())[0],p={...i};return}c=0,l=null,p=null,i.scale-te<di&&(f&&(cancelAnimationFrame(f),f=0),i={scale:te,x:0,y:0},a&&Tt(a)),g()}},V=y=>{if(!y.ctrlKey&&!y.metaKey||!m())return;y.preventDefault();const A=x(y),d=Rt(i.scale*Math.exp(-y.deltaY*.002)),D=d/i.scale,M=E();S({scale:d,x:A.x-M.x-(A.x-M.x-i.x)*D,y:A.y-M.y-(A.y-M.y-i.y)*D})};return g(),n.addEventListener("pointerdown",z),n.addEventListener("pointermove",L),n.addEventListener("pointerup",O),n.addEventListener("pointercancel",O),n.addEventListener("wheel",V,{passive:!1}),()=>{f&&cancelAnimationFrame(f),n.removeEventListener("pointerdown",z),n.removeEventListener("pointermove",L),n.removeEventListener("pointerup",O),n.removeEventListener("pointercancel",O),n.removeEventListener("wheel",V),n.style.removeProperty("touch-action"),a&&Tt(a)}},[e,t])}const gi={json:"json",jsonl:"json",ndjson:"json",yaml:"yaml",tsv:"tsv",xml:"xml",toml:"toml",ini:"ini",dotenv:"dotenv"},vi=new Set(["code","json","jsonl","ndjson","yaml","tsv","xml","toml","ini","dotenv"]),bi={".astro":"astro",".bash":"bash",".bat":"bat",".c":"c",".cc":"cpp",".cjs":"javascript",".cls":"apex",".cmake":"cmake",".cpp":"cpp",".cs":"csharp",".css":"css",".cts":"typescript",".cue":"cue",".dart":"dart",".dockerfile":"docker",".env":"dotenv",".go":"go",".graphql":"graphql",".groovy":"groovy",".h":"c",".hpp":"cpp",".html":"html",".ini":"ini",".java":"java",".js":"javascript",".json":"json",".jsonl":"json",".json5":"json5",".jsonc":"jsonc",".jsx":"jsx",".kt":"kotlin",".kts":"kotlin",".less":"less",".lua":"lua",".mdx":"mdx",".mjs":"javascript",".mts":"typescript",".php":"php",".pl":"perl",".ps1":"powershell",".py":"python",".r":"r",".rb":"ruby",".rs":"rust",".sass":"sass",".scala":"scala",".scss":"scss",".sh":"bash",".sol":"solidity",".sql":"sql",".svelte":"svelte",".swift":"swift",".tab":"tsv",".tsv":"tsv",".toml":"toml",".ts":"typescript",".tsx":"tsx",".vue":"vue",".xml":"xml",".xsl":"xml",".yaml":"yaml",".yml":"yaml",".zsh":"zsh"},jt={"application/ecmascript":"javascript","application/javascript":"javascript","application/jsonl":"json","application/ndjson":"json","application/sql":"sql","application/toml":"toml","application/typescript":"typescript","application/x-env":"dotenv","application/x-httpd-php":"php","application/x-jsonlines":"json","application/x-ndjson":"json","application/x-sh":"bash","application/x-toml":"toml","application/xml":"xml","text/css":"css","text/env":"dotenv","text/html":"html","text/ini":"ini","text/javascript":"javascript","text/jsx":"jsx","text/plain+dotenv":"dotenv","text/plain+php":"php","text/python":"python","text/rust":"rust","text/scala":"scala","text/sh":"bash","text/sql":"sql","text/tab-separated-values":"tsv","text/toml":"toml","text/typescript":"typescript","text/x-c":"c","text/x-c++src":"cpp","text/x-csharp":"csharp","text/x-env":"dotenv","text/x-go":"go","text/x-ini":"ini","text/x-java-source":"java","text/x-jsonl":"json","text/x-ndjson":"json","text/x-kotlin":"kotlin","text/x-python":"python","text/x-ruby":"ruby","text/x-shellscript":"bash","text/x-swift":"swift","text/x-toml":"toml","text/xml":"xml"},Mt={dockerfile:"docker",makefile:"make"};let Oe,Fe;function wi(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}function xi(e){return`<pre class="code-preview-fallback"><code>${wi(e)}</code></pre>`}function yi(e){const n=e.toLowerCase().match(/(\.[a-z0-9]+)$/);return(n==null?void 0:n[1])??null}function tn(e){var i,c,s,l;const t=(c=(i=e.renderOptions)==null?void 0:i.codeLanguage)==null?void 0:c.trim();if(t)return t;const n=gi[e.format];if(n)return n;const r=(l=(s=e.mimeType)==null?void 0:s.toLowerCase().split(";")[0])==null?void 0:l.trim();if(r&&jt[r])return jt[r];const a=e.name.toLowerCase();if(Mt[a])return Mt[a];const o=yi(e.name);return o?bi[o]:void 0}function Pt(e){return vi.has(e.format)||e.format==="text"&&!!tn(e)}async function nn(){return Oe||(Oe=se(()=>import("./index-BHU2svhu.js"),__vite__mapDeps([0,1]))),Oe}async function ki(){return Fe||(Fe=nn().then(e=>{const t=new Map;for(const n of e.bundledLanguagesInfo){t.set(n.id.toLowerCase(),{id:n.id,name:n.name});for(const r of n.aliases??[])t.set(r.toLowerCase(),{id:n.id,name:n.name})}return t})),Fe}async function Ei(e,t,n="light"){const[r,a]=await Promise.all([nn(),ki()]),o=t==null?void 0:t.trim().toLowerCase(),i=o?a.get(o):void 0;return i?{html:await r.codeToHtml(e,{lang:i.id,theme:n==="dark"?"houston":"light-plus"}),languageLabel:i.name,highlighted:!0,canonicalLanguage:i.id}:{html:xi(e),languageLabel:(t==null?void 0:t.trim())||"Plain text",highlighted:!1,canonicalLanguage:void 0}}function rn({source:e,title:t,languageHint:n,themeMode:r,onRendered:a,onError:o,onTelemetry:i}){const[c,s]=h.useState({status:"loading"}),l=h.useMemo(()=>e.replace(/\r\n/g,`
|
|
145
|
-
`),[e]),p=h.useMemo(()=>l.split(`
|
|
146
|
-
`).length,[l]);return h.useEffect(()=>{if(!l.trim()){const f="The code document is empty.";s({status:"error",error:f}),i==null||i("warn","code-preview.skipped",f,{languageHint:n??null}),o==null||o(f);return}let u=!1;return s({status:"loading"}),i==null||i("info","code-preview.started","Started code preview render.",{languageHint:n??null,lineCount:p}),Ei(l,n,r).then(f=>{u||(s({status:"ready",html:f.html,languageLabel:f.languageLabel,highlighted:f.highlighted}),i==null||i(f.highlighted?"info":"warn",f.highlighted?"code-preview.rendered":"code-preview.fallback",f.highlighted?"Rendered highlighted code preview.":"Rendered code preview without syntax highlighting.",{languageHint:n??null,resolvedLanguage:f.canonicalLanguage??null}),a==null||a())}).catch(f=>{if(u)return;const g=f instanceof Error?f.message:"The code preview could not be rendered.";s({status:"error",error:g}),i==null||i("error","code-preview.failed",g,{languageHint:n??null}),o==null||o(g)}),()=>{u=!0}},[n,p,l,o,a,i,r]),c.status==="loading"?v.jsxs("div",{className:"code-preview-shell code-preview-shell-loading","aria-live":"polite",children:[v.jsx("div",{className:"document-spinner"}),v.jsx("p",{children:"Rendering code preview..."})]}):c.status==="error"?v.jsxs("div",{className:"code-preview-shell code-preview-error",role:"status",children:[v.jsx("p",{children:c.error}),v.jsx("pre",{children:v.jsx("code",{children:e})})]}):v.jsx("div",{className:"code-preview-shell",children:v.jsx("div",{className:"code-preview-body",dangerouslySetInnerHTML:{__html:c.html}})})}function Nt(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,a=n.indexOf(t);for(;a!==-1;)r++,a=n.indexOf(t,a+t.length);return r}function Ai(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Si(e,t,n){const a=Ut((n||{}).ignore||[]),o=Li(t);let i=-1;for(;++i<o.length;)_n(e,"text",c);function c(l,p){let u=-1,f;for(;++u<p.length;){const g=p[u],m=f?f.children:void 0;if(a(g,m?m.indexOf(g):void 0,f))return;f=g}if(f)return s(l,p)}function s(l,p){const u=p[p.length-1],f=o[i][0],g=o[i][1];let m=0;const E=u.children.indexOf(l);let b=!1,S=[];f.lastIndex=0;let w=f.exec(l.value);for(;w;){const z=w.index,L={index:w.index,input:w.input,stack:[...p,l]};let O=g(...w,L);if(typeof O=="string"&&(O=O.length>0?{type:"text",value:O}:void 0),O===!1?f.lastIndex=z+1:(m!==z&&S.push({type:"text",value:l.value.slice(m,z)}),Array.isArray(O)?S.push(...O):O&&S.push(O),m=z+w[0].length,b=!0),!f.global)break;w=f.exec(l.value)}return b?(m<l.value.length&&S.push({type:"text",value:l.value.slice(m)}),u.children.splice(E,1,...S)):S=[l],E+S.length}}function Li(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const a=n[r];t.push([Ci(a[0]),Ri(a[1])])}return t}function Ci(e){return typeof e=="string"?new RegExp(Ai(e),"g"):e}function Ri(e){return typeof e=="function"?e:function(){return e}}const ze="phrasing",$e=["autolink","link","image","label"];function Ii(){return{transforms:[Di],enter:{literalAutolink:ji,literalAutolinkEmail:Ve,literalAutolinkHttp:Ve,literalAutolinkWww:Ve},exit:{literalAutolink:_i,literalAutolinkEmail:Ni,literalAutolinkHttp:Mi,literalAutolinkWww:Pi}}}function Ti(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:ze,notInConstruct:$e},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:ze,notInConstruct:$e},{character:":",before:"[ps]",after:"\\/",inConstruct:ze,notInConstruct:$e}]}}function ji(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Ve(e){this.config.enter.autolinkProtocol.call(this,e)}function Mi(e){this.config.exit.autolinkProtocol.call(this,e)}function Pi(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];he(t.type==="link"),t.url="http://"+this.sliceSerialize(e)}function Ni(e){this.config.exit.autolinkEmail.call(this,e)}function _i(e){this.exit(e)}function Di(e){Si(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Oi],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),Fi]],{ignore:["link","linkReference"]})}function Oi(e,t,n,r,a){let o="";if(!an(a)||(/^w/i.test(t)&&(n=t+n,t="",o="http://"),!zi(n)))return!1;const i=$i(n+r);if(!i[0])return!1;const c={type:"link",title:null,url:o+t+i[0],children:[{type:"text",value:t+i[0]}]};return i[1]?[c,{type:"text",value:i[1]}]:c}function Fi(e,t,n,r){return!an(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function zi(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function $i(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const a=Nt(e,"(");let o=Nt(e,")");for(;r!==-1&&a>o;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),o++;return[e,n]}function an(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||me(n)||Ye(n))&&(!t||n!==47)}on.peek=Xi;function Vi(){this.buffer()}function Ui(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function qi(){this.buffer()}function Hi(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Bi(e){const t=this.resume(),n=this.stack[this.stack.length-1];he(n.type==="footnoteReference"),n.identifier=Ae(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Wi(e){this.exit(e)}function Gi(e){const t=this.resume(),n=this.stack[this.stack.length-1];he(n.type==="footnoteDefinition"),n.identifier=Ae(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Ki(e){this.exit(e)}function Xi(){return"["}function on(e,t,n,r){const a=n.createTracker(r);let o=a.move("[^");const i=n.enter("footnoteReference"),c=n.enter("reference");return o+=a.move(n.safe(n.associationId(e),{after:"]",before:o})),c(),i(),o+=a.move("]"),o}function Yi(){return{enter:{gfmFootnoteCallString:Vi,gfmFootnoteCall:Ui,gfmFootnoteDefinitionLabelString:qi,gfmFootnoteDefinition:Hi},exit:{gfmFootnoteCallString:Bi,gfmFootnoteCall:Wi,gfmFootnoteDefinitionLabelString:Gi,gfmFootnoteDefinition:Ki}}}function Zi(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:on},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,a,o,i){const c=o.createTracker(i);let s=c.move("[^");const l=o.enter("footnoteDefinition"),p=o.enter("label");return s+=c.move(o.safe(o.associationId(r),{before:s,after:"]"})),p(),s+=c.move("]:"),r.children&&r.children.length>0&&(c.shift(4),s+=c.move((t?`
|
|
147
|
-
`:" ")+o.indentLines(o.containerFlow(r,c.current()),t?sn:Qi))),l(),s}}function Qi(e,t,n){return t===0?e:sn(e,t,n)}function sn(e,t,n){return(n?"":" ")+e}const Ji=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];ln.peek=ia;function ea(){return{canContainEols:["delete"],enter:{strikethrough:na},exit:{strikethrough:ra}}}function ta(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Ji}],handlers:{delete:ln}}}function na(e){this.enter({type:"delete",children:[]},e)}function ra(e){this.exit(e)}function ln(e,t,n,r){const a=n.createTracker(r),o=n.enter("strikethrough");let i=a.move("~~");return i+=n.containerPhrasing(e,{...a.current(),before:i,after:"~"}),i+=a.move("~~"),o(),i}function ia(){return"~"}function aa(e){return e.length}function oa(e,t){const n=t||{},r=(n.align||[]).concat(),a=n.stringLength||aa,o=[],i=[],c=[],s=[];let l=0,p=-1;for(;++p<e.length;){const x=[],E=[];let b=-1;for(e[p].length>l&&(l=e[p].length);++b<e[p].length;){const S=sa(e[p][b]);if(n.alignDelimiters!==!1){const w=a(S);E[b]=w,(s[b]===void 0||w>s[b])&&(s[b]=w)}x.push(S)}i[p]=x,c[p]=E}let u=-1;if(typeof r=="object"&&"length"in r)for(;++u<l;)o[u]=_t(r[u]);else{const x=_t(r);for(;++u<l;)o[u]=x}u=-1;const f=[],g=[];for(;++u<l;){const x=o[u];let E="",b="";x===99?(E=":",b=":"):x===108?E=":":x===114&&(b=":");let S=n.alignDelimiters===!1?1:Math.max(1,s[u]-E.length-b.length);const w=E+"-".repeat(S)+b;n.alignDelimiters!==!1&&(S=E.length+S+b.length,S>s[u]&&(s[u]=S),g[u]=S),f[u]=w}i.splice(1,0,f),c.splice(1,0,g),p=-1;const m=[];for(;++p<i.length;){const x=i[p],E=c[p];u=-1;const b=[];for(;++u<l;){const S=x[u]||"";let w="",z="";if(n.alignDelimiters!==!1){const L=s[u]-(E[u]||0),O=o[u];O===114?w=" ".repeat(L):O===99?L%2?(w=" ".repeat(L/2+.5),z=" ".repeat(L/2-.5)):(w=" ".repeat(L/2),z=w):z=" ".repeat(L)}n.delimiterStart!==!1&&!u&&b.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&S==="")&&(n.delimiterStart!==!1||u)&&b.push(" "),n.alignDelimiters!==!1&&b.push(w),b.push(S),n.alignDelimiters!==!1&&b.push(z),n.padding!==!1&&b.push(" "),(n.delimiterEnd!==!1||u!==l-1)&&b.push("|")}m.push(n.delimiterEnd===!1?b.join("").replace(/ +$/,""):b.join(""))}return m.join(`
|
|
148
|
-
`)}function sa(e){return e==null?"":String(e)}function _t(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function la(e,t,n,r){const a=n.enter("blockquote"),o=n.createTracker(r);o.move("> "),o.shift(2);const i=n.indentLines(n.containerFlow(e,o.current()),ca);return a(),i}function ca(e,t,n){return">"+(n?"":" ")+e}function ua(e,t){return Dt(e,t.inConstruct,!0)&&!Dt(e,t.notInConstruct,!1)}function Dt(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function Ot(e,t,n,r){let a=-1;for(;++a<n.unsafe.length;)if(n.unsafe[a].character===`
|
|
149
|
-
`&&ua(n.stack,n.unsafe[a]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
150
|
-
`}function da(e,t){const n=String(e);let r=n.indexOf(t),a=r,o=0,i=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===a?++o>i&&(i=o):o=1,a=r+t.length,r=n.indexOf(t,a);return i}function fa(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function pa(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function ma(e,t,n,r){const a=pa(n),o=e.value||"",i=a==="`"?"GraveAccent":"Tilde";if(fa(e,n)){const u=n.enter("codeIndented"),f=n.indentLines(o,ha);return u(),f}const c=n.createTracker(r),s=a.repeat(Math.max(da(o,a)+1,3)),l=n.enter("codeFenced");let p=c.move(s);if(e.lang){const u=n.enter(`codeFencedLang${i}`);p+=c.move(n.safe(e.lang,{before:p,after:" ",encode:["`"],...c.current()})),u()}if(e.lang&&e.meta){const u=n.enter(`codeFencedMeta${i}`);p+=c.move(" "),p+=c.move(n.safe(e.meta,{before:p,after:`
|
|
151
|
-
`,encode:["`"],...c.current()})),u()}return p+=c.move(`
|
|
152
|
-
`),o&&(p+=c.move(o+`
|
|
153
|
-
`)),p+=c.move(s),l(),p}function ha(e,t,n){return(n?"":" ")+e}function tt(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function ga(e,t,n,r){const a=tt(n),o=a==='"'?"Quote":"Apostrophe",i=n.enter("definition");let c=n.enter("label");const s=n.createTracker(r);let l=s.move("[");return l+=s.move(n.safe(n.associationId(e),{before:l,after:"]",...s.current()})),l+=s.move("]: "),c(),!e.url||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),l+=s.move("<"),l+=s.move(n.safe(e.url,{before:l,after:">",...s.current()})),l+=s.move(">")):(c=n.enter("destinationRaw"),l+=s.move(n.safe(e.url,{before:l,after:e.title?" ":`
|
|
154
|
-
`,...s.current()}))),c(),e.title&&(c=n.enter(`title${o}`),l+=s.move(" "+a),l+=s.move(n.safe(e.title,{before:l,after:a,...s.current()})),l+=s.move(a),c()),i(),l}function va(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Ee(e){return"&#x"+e.toString(16).toUpperCase()+";"}function je(e,t,n){const r=Ie(e),a=Ie(t);return r===void 0?a===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}cn.peek=ba;function cn(e,t,n,r){const a=va(n),o=n.enter("emphasis"),i=n.createTracker(r),c=i.move(a);let s=i.move(n.containerPhrasing(e,{after:a,before:c,...i.current()}));const l=s.charCodeAt(0),p=je(r.before.charCodeAt(r.before.length-1),l,a);p.inside&&(s=Ee(l)+s.slice(1));const u=s.charCodeAt(s.length-1),f=je(r.after.charCodeAt(0),u,a);f.inside&&(s=s.slice(0,-1)+Ee(u));const g=i.move(a);return o(),n.attentionEncodeSurroundingInfo={after:f.outside,before:p.outside},c+s+g}function ba(e,t,n){return n.options.emphasis||"*"}function wa(e,t){let n=!1;return Dn(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,On}),!!((!e.depth||e.depth<3)&&qt(e)&&(t.options.setext||n))}function xa(e,t,n,r){const a=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(r);if(wa(e,n)){const p=n.enter("headingSetext"),u=n.enter("phrasing"),f=n.containerPhrasing(e,{...o.current(),before:`
|
|
155
|
-
`,after:`
|
|
156
|
-
`});return u(),p(),f+`
|
|
157
|
-
`+(a===1?"=":"-").repeat(f.length-(Math.max(f.lastIndexOf("\r"),f.lastIndexOf(`
|
|
158
|
-
`))+1))}const i="#".repeat(a),c=n.enter("headingAtx"),s=n.enter("phrasing");o.move(i+" ");let l=n.containerPhrasing(e,{before:"# ",after:`
|
|
159
|
-
`,...o.current()});return/^[\t ]/.test(l)&&(l=Ee(l.charCodeAt(0))+l.slice(1)),l=l?i+" "+l:i,n.options.closeAtx&&(l+=" "+i),s(),c(),l}un.peek=ya;function un(e){return e.value||""}function ya(){return"<"}dn.peek=ka;function dn(e,t,n,r){const a=tt(n),o=a==='"'?"Quote":"Apostrophe",i=n.enter("image");let c=n.enter("label");const s=n.createTracker(r);let l=s.move("![");return l+=s.move(n.safe(e.alt,{before:l,after:"]",...s.current()})),l+=s.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),l+=s.move("<"),l+=s.move(n.safe(e.url,{before:l,after:">",...s.current()})),l+=s.move(">")):(c=n.enter("destinationRaw"),l+=s.move(n.safe(e.url,{before:l,after:e.title?" ":")",...s.current()}))),c(),e.title&&(c=n.enter(`title${o}`),l+=s.move(" "+a),l+=s.move(n.safe(e.title,{before:l,after:a,...s.current()})),l+=s.move(a),c()),l+=s.move(")"),i(),l}function ka(){return"!"}fn.peek=Ea;function fn(e,t,n,r){const a=e.referenceType,o=n.enter("imageReference");let i=n.enter("label");const c=n.createTracker(r);let s=c.move("![");const l=n.safe(e.alt,{before:s,after:"]",...c.current()});s+=c.move(l+"]["),i();const p=n.stack;n.stack=[],i=n.enter("reference");const u=n.safe(n.associationId(e),{before:s,after:"]",...c.current()});return i(),n.stack=p,o(),a==="full"||!l||l!==u?s+=c.move(u+"]"):a==="shortcut"?s=s.slice(0,-1):s+=c.move("]"),s}function Ea(){return"!"}pn.peek=Aa;function pn(e,t,n){let r=e.value||"",a="`",o=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(r);)a+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<n.unsafe.length;){const i=n.unsafe[o],c=n.compilePattern(i);let s;if(i.atBreak)for(;s=c.exec(r);){let l=s.index;r.charCodeAt(l)===10&&r.charCodeAt(l-1)===13&&l--,r=r.slice(0,l)+" "+r.slice(s.index+1)}}return a+r+a}function Aa(){return"`"}function mn(e,t){const n=qt(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}hn.peek=Sa;function hn(e,t,n,r){const a=tt(n),o=a==='"'?"Quote":"Apostrophe",i=n.createTracker(r);let c,s;if(mn(e,n)){const p=n.stack;n.stack=[],c=n.enter("autolink");let u=i.move("<");return u+=i.move(n.containerPhrasing(e,{before:u,after:">",...i.current()})),u+=i.move(">"),c(),n.stack=p,u}c=n.enter("link"),s=n.enter("label");let l=i.move("[");return l+=i.move(n.containerPhrasing(e,{before:l,after:"](",...i.current()})),l+=i.move("]("),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter("destinationLiteral"),l+=i.move("<"),l+=i.move(n.safe(e.url,{before:l,after:">",...i.current()})),l+=i.move(">")):(s=n.enter("destinationRaw"),l+=i.move(n.safe(e.url,{before:l,after:e.title?" ":")",...i.current()}))),s(),e.title&&(s=n.enter(`title${o}`),l+=i.move(" "+a),l+=i.move(n.safe(e.title,{before:l,after:a,...i.current()})),l+=i.move(a),s()),l+=i.move(")"),c(),l}function Sa(e,t,n){return mn(e,n)?"<":"["}gn.peek=La;function gn(e,t,n,r){const a=e.referenceType,o=n.enter("linkReference");let i=n.enter("label");const c=n.createTracker(r);let s=c.move("[");const l=n.containerPhrasing(e,{before:s,after:"]",...c.current()});s+=c.move(l+"]["),i();const p=n.stack;n.stack=[],i=n.enter("reference");const u=n.safe(n.associationId(e),{before:s,after:"]",...c.current()});return i(),n.stack=p,o(),a==="full"||!l||l!==u?s+=c.move(u+"]"):a==="shortcut"?s=s.slice(0,-1):s+=c.move("]"),s}function La(){return"["}function nt(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Ca(e){const t=nt(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Ra(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function vn(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function Ia(e,t,n,r){const a=n.enter("list"),o=n.bulletCurrent;let i=e.ordered?Ra(n):nt(n);const c=e.ordered?i==="."?")":".":Ca(n);let s=t&&n.bulletLastUsed?i===n.bulletLastUsed:!1;if(!e.ordered){const p=e.children?e.children[0]:void 0;if((i==="*"||i==="-")&&p&&(!p.children||!p.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(s=!0),vn(n)===i&&p){let u=-1;for(;++u<e.children.length;){const f=e.children[u];if(f&&f.type==="listItem"&&f.children&&f.children[0]&&f.children[0].type==="thematicBreak"){s=!0;break}}}}s&&(i=c),n.bulletCurrent=i;const l=n.containerFlow(e,r);return n.bulletLastUsed=i,n.bulletCurrent=o,a(),l}function Ta(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function ja(e,t,n,r){const a=Ta(n);let o=n.bulletCurrent||nt(n);t&&t.type==="list"&&t.ordered&&(o=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let i=o.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(i=Math.ceil(i/4)*4);const c=n.createTracker(r);c.move(o+" ".repeat(i-o.length)),c.shift(i);const s=n.enter("listItem"),l=n.indentLines(n.containerFlow(e,c.current()),p);return s(),l;function p(u,f,g){return f?(g?"":" ".repeat(i))+u:(g?o:o+" ".repeat(i-o.length))+u}}function Ma(e,t,n,r){const a=n.enter("paragraph"),o=n.enter("phrasing"),i=n.containerPhrasing(e,r);return o(),a(),i}const Pa=Ut(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Na(e,t,n,r){return(e.children.some(function(i){return Pa(i)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function _a(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}bn.peek=Da;function bn(e,t,n,r){const a=_a(n),o=n.enter("strong"),i=n.createTracker(r),c=i.move(a+a);let s=i.move(n.containerPhrasing(e,{after:a,before:c,...i.current()}));const l=s.charCodeAt(0),p=je(r.before.charCodeAt(r.before.length-1),l,a);p.inside&&(s=Ee(l)+s.slice(1));const u=s.charCodeAt(s.length-1),f=je(r.after.charCodeAt(0),u,a);f.inside&&(s=s.slice(0,-1)+Ee(u));const g=i.move(a+a);return o(),n.attentionEncodeSurroundingInfo={after:f.outside,before:p.outside},c+s+g}function Da(e,t,n){return n.options.strong||"*"}function Oa(e,t,n,r){return n.safe(e.value,r)}function Fa(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function za(e,t,n){const r=(vn(n)+(n.options.ruleSpaces?" ":"")).repeat(Fa(n));return n.options.ruleSpaces?r.slice(0,-1):r}const wn={blockquote:la,break:Ot,code:ma,definition:ga,emphasis:cn,hardBreak:Ot,heading:xa,html:un,image:dn,imageReference:fn,inlineCode:pn,link:hn,linkReference:gn,list:Ia,listItem:ja,paragraph:Ma,root:Na,strong:bn,text:Oa,thematicBreak:za};function $a(){return{enter:{table:Va,tableData:Ft,tableHeader:Ft,tableRow:qa},exit:{codeText:Ha,table:Ua,tableData:Ue,tableHeader:Ue,tableRow:Ue}}}function Va(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function Ua(e){this.exit(e),this.data.inTable=void 0}function qa(e){this.enter({type:"tableRow",children:[]},e)}function Ue(e){this.exit(e)}function Ft(e){this.enter({type:"tableCell",children:[]},e)}function Ha(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Ba));const n=this.stack[this.stack.length-1];he(n.type==="inlineCode"),n.value=t,this.exit(e)}function Ba(e,t){return t==="|"?t:e}function Wa(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,a=t.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
160
|
-
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:f,table:i,tableCell:s,tableRow:c}};function i(g,m,x,E){return l(p(g,x,E),g.align)}function c(g,m,x,E){const b=u(g,x,E),S=l([b]);return S.slice(0,S.indexOf(`
|
|
161
|
-
`))}function s(g,m,x,E){const b=x.enter("tableCell"),S=x.enter("phrasing"),w=x.containerPhrasing(g,{...E,before:o,after:o});return S(),b(),w}function l(g,m){return oa(g,{align:m,alignDelimiters:r,padding:n,stringLength:a})}function p(g,m,x){const E=g.children;let b=-1;const S=[],w=m.enter("table");for(;++b<E.length;)S[b]=u(E[b],m,x);return w(),S}function u(g,m,x){const E=g.children;let b=-1;const S=[],w=m.enter("tableRow");for(;++b<E.length;)S[b]=s(E[b],g,m,x);return w(),S}function f(g,m,x){let E=wn.inlineCode(g,m,x);return x.stack.includes("tableCell")&&(E=E.replace(/\|/g,"\\$&")),E}}function Ga(){return{exit:{taskListCheckValueChecked:zt,taskListCheckValueUnchecked:zt,paragraph:Xa}}}function Ka(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Ya}}}function zt(e){const t=this.stack[this.stack.length-2];he(t.type==="listItem"),t.checked=e.type==="taskListCheckValueChecked"}function Xa(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];he(n.type==="paragraph");const r=n.children[0];if(r&&r.type==="text"){const a=t.children;let o=-1,i;for(;++o<a.length;){const c=a[o];if(c.type==="paragraph"){i=c;break}}i===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function Ya(e,t,n,r){const a=e.children[0],o=typeof e.checked=="boolean"&&a&&a.type==="paragraph",i="["+(e.checked?"x":" ")+"] ",c=n.createTracker(r);o&&c.move(i);let s=wn.listItem(e,t,n,{...r,...c.current()});return o&&(s=s.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),s;function l(p){return p+i}}function Za(){return[Ii(),Yi(),ea(),$a(),Ga()]}function Qa(e){return{extensions:[Ti(),Zi(e),ta(),Wa(e),Ka()]}}const Ja={tokenize:ao,partial:!0},xn={tokenize:oo,partial:!0},yn={tokenize:so,partial:!0},kn={tokenize:lo,partial:!0},eo={tokenize:co,partial:!0},En={name:"wwwAutolink",tokenize:ro,previous:Sn},An={name:"protocolAutolink",tokenize:io,previous:Ln},ie={name:"emailAutolink",tokenize:no,previous:Cn},re={};function to(){return{text:re}}let le=48;for(;le<123;)re[le]=ie,le++,le===58?le=65:le===91&&(le=97);re[43]=ie;re[45]=ie;re[46]=ie;re[95]=ie;re[72]=[ie,An];re[104]=[ie,An];re[87]=[ie,En];re[119]=[ie,En];function no(e,t,n){const r=this;let a,o;return i;function i(u){return!Ke(u)||!Cn.call(r,r.previous)||rt(r.events)?n(u):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),c(u))}function c(u){return Ke(u)?(e.consume(u),c):u===64?(e.consume(u),s):n(u)}function s(u){return u===46?e.check(eo,p,l)(u):u===45||u===95||Ze(u)?(o=!0,e.consume(u),s):p(u)}function l(u){return e.consume(u),a=!0,s}function p(u){return o&&a&&ye(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(u)):n(u)}}function ro(e,t,n){const r=this;return a;function a(i){return i!==87&&i!==119||!Sn.call(r,r.previous)||rt(r.events)?n(i):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(Ja,e.attempt(xn,e.attempt(yn,o),n),n)(i))}function o(i){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(i)}}function io(e,t,n){const r=this;let a="",o=!1;return i;function i(u){return(u===72||u===104)&&Ln.call(r,r.previous)&&!rt(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(u),e.consume(u),c):n(u)}function c(u){if(ye(u)&&a.length<5)return a+=String.fromCodePoint(u),e.consume(u),c;if(u===58){const f=a.toLowerCase();if(f==="http"||f==="https")return e.consume(u),s}return n(u)}function s(u){return u===47?(e.consume(u),o?l:(o=!0,s)):n(u)}function l(u){return u===null||Fn(u)||Q(u)||me(u)||Ye(u)?n(u):e.attempt(xn,e.attempt(yn,p),n)(u)}function p(u){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(u)}}function ao(e,t,n){let r=0;return a;function a(i){return(i===87||i===119)&&r<3?(r++,e.consume(i),a):i===46&&r===3?(e.consume(i),o):n(i)}function o(i){return i===null?n(i):t(i)}}function oo(e,t,n){let r,a,o;return i;function i(l){return l===46||l===95?e.check(kn,s,c)(l):l===null||Q(l)||me(l)||l!==45&&Ye(l)?s(l):(o=!0,e.consume(l),i)}function c(l){return l===95?r=!0:(a=r,r=void 0),e.consume(l),i}function s(l){return a||r||!o?n(l):t(l)}}function so(e,t){let n=0,r=0;return a;function a(i){return i===40?(n++,e.consume(i),a):i===41&&r<n?o(i):i===33||i===34||i===38||i===39||i===41||i===42||i===44||i===46||i===58||i===59||i===60||i===63||i===93||i===95||i===126?e.check(kn,t,o)(i):i===null||Q(i)||me(i)?t(i):(e.consume(i),a)}function o(i){return i===41&&r++,e.consume(i),a}}function lo(e,t,n){return r;function r(c){return c===33||c===34||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===63||c===95||c===126?(e.consume(c),r):c===38?(e.consume(c),o):c===93?(e.consume(c),a):c===60||c===null||Q(c)||me(c)?t(c):n(c)}function a(c){return c===null||c===40||c===91||Q(c)||me(c)?t(c):r(c)}function o(c){return ye(c)?i(c):n(c)}function i(c){return c===59?(e.consume(c),r):ye(c)?(e.consume(c),i):n(c)}}function co(e,t,n){return r;function r(o){return e.consume(o),a}function a(o){return Ze(o)?n(o):t(o)}}function Sn(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Q(e)}function Ln(e){return!ye(e)}function Cn(e){return!(e===47||Ke(e))}function Ke(e){return e===43||e===45||e===46||e===95||Ze(e)}function rt(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const uo={tokenize:wo,partial:!0};function fo(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:go,continuation:{tokenize:vo},exit:bo}},text:{91:{name:"gfmFootnoteCall",tokenize:ho},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:po,resolveTo:mo}}}}function po(e,t,n){const r=this;let a=r.events.length;const o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i;for(;a--;){const s=r.events[a][1];if(s.type==="labelImage"){i=s;break}if(s.type==="gfmFootnoteCall"||s.type==="labelLink"||s.type==="label"||s.type==="image"||s.type==="link")break}return c;function c(s){if(!i||!i._balanced)return n(s);const l=Ae(r.sliceSerialize({start:i.end,end:r.now()}));return l.codePointAt(0)!==94||!o.includes(l.slice(1))?n(s):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(s),e.exit("gfmFootnoteCallLabelMarker"),t(s))}}function mo(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},i={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},c=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",o,t],["enter",i,t],["exit",i,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...c),e}function ho(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o=0,i;return c;function c(u){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(u),e.exit("gfmFootnoteCallLabelMarker"),s}function s(u){return u!==94?n(u):(e.enter("gfmFootnoteCallMarker"),e.consume(u),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",l)}function l(u){if(o>999||u===93&&!i||u===null||u===91||Q(u))return n(u);if(u===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return a.includes(Ae(r.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(u),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(u)}return Q(u)||(i=!0),o++,e.consume(u),u===92?p:l}function p(u){return u===91||u===92||u===93?(e.consume(u),o++,l):l(u)}}function go(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o,i=0,c;return s;function s(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),l}function l(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",p):n(m)}function p(m){if(i>999||m===93&&!c||m===null||m===91||Q(m))return n(m);if(m===93){e.exit("chunkString");const x=e.exit("gfmFootnoteDefinitionLabelString");return o=Ae(r.sliceSerialize(x)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return Q(m)||(c=!0),i++,e.consume(m),m===92?u:p}function u(m){return m===91||m===92||m===93?(e.consume(m),i++,p):p(m)}function f(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),a.includes(o)||a.push(o),ae(e,g,"gfmFootnoteDefinitionWhitespace")):n(m)}function g(m){return t(m)}}function vo(e,t,n){return e.check(zn,t,e.attempt(uo,t,n))}function bo(e){e.exit("gfmFootnoteDefinition")}function wo(e,t,n){const r=this;return ae(e,a,"gfmFootnoteDefinitionIndent",5);function a(o){const i=r.events[r.events.length-1];return i&&i[1].type==="gfmFootnoteDefinitionIndent"&&i[2].sliceSerialize(i[1],!0).length===4?t(o):n(o)}}function xo(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:o,resolveAll:a};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function a(i,c){let s=-1;for(;++s<i.length;)if(i[s][0]==="enter"&&i[s][1].type==="strikethroughSequenceTemporary"&&i[s][1]._close){let l=s;for(;l--;)if(i[l][0]==="exit"&&i[l][1].type==="strikethroughSequenceTemporary"&&i[l][1]._open&&i[s][1].end.offset-i[s][1].start.offset===i[l][1].end.offset-i[l][1].start.offset){i[s][1].type="strikethroughSequence",i[l][1].type="strikethroughSequence";const p={type:"strikethrough",start:Object.assign({},i[l][1].start),end:Object.assign({},i[s][1].end)},u={type:"strikethroughText",start:Object.assign({},i[l][1].end),end:Object.assign({},i[s][1].start)},f=[["enter",p,c],["enter",i[l][1],c],["exit",i[l][1],c],["enter",u,c]],g=c.parser.constructs.insideSpan.null;g&&_e(f,f.length,0,$n(g,i.slice(l+1,s),c)),_e(f,f.length,0,[["exit",u,c],["enter",i[s][1],c],["exit",i[s][1],c],["exit",p,c]]),_e(i,l-1,s-l+3,f),s=l+f.length-2;break}}for(s=-1;++s<i.length;)i[s][1].type==="strikethroughSequenceTemporary"&&(i[s][1].type="data");return i}function o(i,c,s){const l=this.previous,p=this.events;let u=0;return f;function f(m){return l===126&&p[p.length-1][1].type!=="characterEscape"?s(m):(i.enter("strikethroughSequenceTemporary"),g(m))}function g(m){const x=Ie(l);if(m===126)return u>1?s(m):(i.consume(m),u++,g);if(u<2&&!n)return s(m);const E=i.exit("strikethroughSequenceTemporary"),b=Ie(m);return E._open=!b||b===2&&!!x,E._close=!x||x===2&&!!b,c(m)}}}class yo{constructor(){this.map=[]}add(t,n,r){ko(this,t,n,r)}consume(t){if(this.map.sort(function(o,i){return o[0]-i[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let a=r.pop();for(;a;){for(const o of a)t.push(o);a=r.pop()}this.map.length=0}}function ko(e,t,n,r){let a=0;if(!(n===0&&r.length===0)){for(;a<e.map.length;){if(e.map[a][0]===t){e.map[a][1]+=n,e.map[a][2].push(...r);return}a+=1}e.map.push([t,n,r])}}function Eo(e,t){let n=!1;const r=[];for(;t<e.length;){const a=e[t];if(n){if(a[0]==="enter")a[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(a[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const o=r.length-1;r[o]=r[o]==="left"?"center":"right"}}else if(a[1].type==="tableDelimiterRow")break}else a[0]==="enter"&&a[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function Ao(){return{flow:{null:{name:"table",tokenize:So,resolveAll:Lo}}}}function So(e,t,n){const r=this;let a=0,o=0,i;return c;function c(d){let D=r.events.length-1;for(;D>-1;){const K=r.events[D][1].type;if(K==="lineEnding"||K==="linePrefix")D--;else break}const M=D>-1?r.events[D][1].type:null,T=M==="tableHead"||M==="tableRow"?O:s;return T===O&&r.parser.lazy[r.now().line]?n(d):T(d)}function s(d){return e.enter("tableHead"),e.enter("tableRow"),l(d)}function l(d){return d===124||(i=!0,o+=1),p(d)}function p(d){return d===null?n(d):xe(d)?o>1?(o=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),g):n(d):ue(d)?ae(e,p,"whitespace")(d):(o+=1,i&&(i=!1,a+=1),d===124?(e.enter("tableCellDivider"),e.consume(d),e.exit("tableCellDivider"),i=!0,p):(e.enter("data"),u(d)))}function u(d){return d===null||d===124||Q(d)?(e.exit("data"),p(d)):(e.consume(d),d===92?f:u)}function f(d){return d===92||d===124?(e.consume(d),u):u(d)}function g(d){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(d):(e.enter("tableDelimiterRow"),i=!1,ue(d)?ae(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d):m(d))}function m(d){return d===45||d===58?E(d):d===124?(i=!0,e.enter("tableCellDivider"),e.consume(d),e.exit("tableCellDivider"),x):L(d)}function x(d){return ue(d)?ae(e,E,"whitespace")(d):E(d)}function E(d){return d===58?(o+=1,i=!0,e.enter("tableDelimiterMarker"),e.consume(d),e.exit("tableDelimiterMarker"),b):d===45?(o+=1,b(d)):d===null||xe(d)?z(d):L(d)}function b(d){return d===45?(e.enter("tableDelimiterFiller"),S(d)):L(d)}function S(d){return d===45?(e.consume(d),S):d===58?(i=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(d),e.exit("tableDelimiterMarker"),w):(e.exit("tableDelimiterFiller"),w(d))}function w(d){return ue(d)?ae(e,z,"whitespace")(d):z(d)}function z(d){return d===124?m(d):d===null||xe(d)?!i||a!==o?L(d):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(d)):L(d)}function L(d){return n(d)}function O(d){return e.enter("tableRow"),V(d)}function V(d){return d===124?(e.enter("tableCellDivider"),e.consume(d),e.exit("tableCellDivider"),V):d===null||xe(d)?(e.exit("tableRow"),t(d)):ue(d)?ae(e,V,"whitespace")(d):(e.enter("data"),y(d))}function y(d){return d===null||d===124||Q(d)?(e.exit("data"),V(d)):(e.consume(d),d===92?A:y)}function A(d){return d===92||d===124?(e.consume(d),y):y(d)}}function Lo(e,t){let n=-1,r=!0,a=0,o=[0,0,0,0],i=[0,0,0,0],c=!1,s=0,l,p,u;const f=new yo;for(;++n<e.length;){const g=e[n],m=g[1];g[0]==="enter"?m.type==="tableHead"?(c=!1,s!==0&&($t(f,t,s,l,p),p=void 0,s=0),l={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[["enter",l,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,u=void 0,o=[0,0,0,0],i=[0,n+1,0,0],c&&(c=!1,p={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[["enter",p,t]])),a=m.type==="tableDelimiterRow"?2:p?3:1):a&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,i[2]===0&&(o[1]!==0&&(i[0]=i[1],u=Re(f,t,o,a,void 0,u),o=[0,0,0,0]),i[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(o[1]!==0&&(i[0]=i[1],u=Re(f,t,o,a,void 0,u)),o=i,i=[o[1],n,0,0])):m.type==="tableHead"?(c=!0,s=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(s=n,o[1]!==0?(i[0]=i[1],u=Re(f,t,o,a,n,u)):i[1]!==0&&(u=Re(f,t,i,a,n,u)),a=0):a&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(i[3]=n)}for(s!==0&&$t(f,t,s,l,p),f.consume(t.events),n=-1;++n<t.events.length;){const g=t.events[n];g[0]==="enter"&&g[1].type==="table"&&(g[1]._align=Eo(t.events,n))}return e}function Re(e,t,n,r,a,o){const i=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",c="tableContent";n[0]!==0&&(o.end=Object.assign({},de(t.events,n[0])),e.add(n[0],0,[["exit",o,t]]));const s=de(t.events,n[1]);if(o={type:i,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[["enter",o,t]]),n[2]!==0){const l=de(t.events,n[2]),p=de(t.events,n[3]),u={type:c,start:Object.assign({},l),end:Object.assign({},p)};if(e.add(n[2],0,[["enter",u,t]]),r!==2){const f=t.events[n[2]],g=t.events[n[3]];if(f[1].end=Object.assign({},g[1].end),f[1].type="chunkText",f[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,x=n[3]-n[2]-1;e.add(m,x,[])}}e.add(n[3]+1,0,[["exit",u,t]])}return a!==void 0&&(o.end=Object.assign({},de(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function $t(e,t,n,r,a){const o=[],i=de(t.events,n);a&&(a.end=Object.assign({},i),o.push(["exit",a,t])),r.end=Object.assign({},i),o.push(["exit",r,t]),e.add(n+1,0,o)}function de(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const Co={name:"tasklistCheck",tokenize:Io};function Ro(){return{text:{91:Co}}}function Io(e,t,n){const r=this;return a;function a(s){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(s):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(s),e.exit("taskListCheckMarker"),o)}function o(s){return Q(s)?(e.enter("taskListCheckValueUnchecked"),e.consume(s),e.exit("taskListCheckValueUnchecked"),i):s===88||s===120?(e.enter("taskListCheckValueChecked"),e.consume(s),e.exit("taskListCheckValueChecked"),i):n(s)}function i(s){return s===93?(e.enter("taskListCheckMarker"),e.consume(s),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),c):n(s)}function c(s){return xe(s)?t(s):ue(s)?e.check({tokenize:To},t,n)(s):n(s)}}function To(e,t,n){return ae(e,r,"whitespace");function r(a){return a===null?n(a):t(a)}}function jo(e){return Vn([to(),fo(),xo(e),Ao(),Ro()])}const Mo={};function Po(e){const t=this,n=e||Mo,r=t.data(),a=r.micromarkExtensions||(r.micromarkExtensions=[]),o=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),i=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);a.push(jo(n)),o.push(Za()),i.push(Qa(n))}let qe;async function No(){return qe||(qe=se(()=>import("./mermaid.core-UUGPJ6yi.js").then(e=>e.bF),__vite__mapDeps([2,1])).then(e=>e.default)),qe}function Rn({source:e,title:t,themeMode:n="light",onRendered:r,onError:a,onTelemetry:o}){const i=h.useId(),c=h.useMemo(()=>`mermaid-${i.replace(/[^a-zA-Z0-9_-]/g,"")}`,[i]),[s,l]=h.useState({status:"loading"});return h.useEffect(()=>{const p=e.trim();if(!p){const f="The Mermaid diagram is empty.";l({status:"error",error:f}),o==null||o("warn","mermaid.render.skipped",f,{definitionLength:0}),a==null||a(f);return}let u=!1;return l({status:"loading"}),o==null||o("info","mermaid.render.started","Started Mermaid render.",{definitionLength:p.length}),No().then(f=>(f.initialize({startOnLoad:!1,securityLevel:"strict",theme:n==="dark"?"dark":"neutral",suppressErrorRendering:!0,fontFamily:'"Inter", "Segoe UI", sans-serif'}),f.render(c,p))).then(({svg:f})=>{u||(l({status:"ready",svg:f}),o==null||o("info","mermaid.rendered","Rendered Mermaid diagram.",{definitionLength:p.length}),r==null||r())}).catch(f=>{if(u)return;const g=f instanceof Error?f.message:"The Mermaid diagram could not be rendered.";l({status:"error",error:g}),o==null||o("error","mermaid.render.failed",g,{definitionLength:p.length}),a==null||a(g)}),()=>{u=!0}},[c,a,r,o,e,n]),s.status==="loading"?v.jsxs("div",{className:"document-mermaid-shell document-mermaid-shell-loading","aria-live":"polite",children:[v.jsx("div",{className:"document-spinner"}),v.jsx("p",{children:"Rendering Mermaid diagram..."})]}):s.status==="error"?v.jsxs("div",{className:"document-mermaid-shell document-mermaid-error",role:"status",children:[v.jsx("h3",{children:"Mermaid preview unavailable"}),v.jsx("p",{children:s.error}),v.jsxs("pre",{children:[t?v.jsx("span",{children:t}):null,v.jsx("code",{children:e})]})]}):v.jsx("div",{className:"document-mermaid-shell",children:v.jsx("div",{className:"document-mermaid-frame","data-viewer-zoom-target":!0,"aria-label":t??"Mermaid diagram",dangerouslySetInnerHTML:{__html:s.svg}})})}function Xe(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(t=>Xe(t)).join(""):h.isValidElement(e)?Xe(e.props.children):""}function _o(e){var n;const t=e==null?void 0:e.match(/language-([^\s]+)/);return(n=t==null?void 0:t[1])==null?void 0:n.toLowerCase()}function Do(e){return h.Children.toArray(e).find(n=>h.isValidElement(n)&&n.type==="code")??null}function Oo(e){return{a({href:t,children:n}){return v.jsx("a",{href:t,target:"_blank",rel:"noreferrer",children:n})},img({src:t,alt:n}){return t?v.jsx("img",{src:t,alt:n??"",loading:"lazy"}):null},pre({children:t}){const n=Do(t);if(!n)return v.jsx("pre",{children:t});const r=_o(n.props.className),a=Xe(n.props.children).replace(/\n$/,"");return["mermaid","mmd"].includes(r??"")?v.jsx(Rn,{source:a,title:"Embedded Mermaid diagram",themeMode:e==null?void 0:e.themeMode,onTelemetry:e==null?void 0:e.onTelemetry}):v.jsx(rn,{source:a,title:r?`${r} code block`:"Code block",languageHint:r,themeMode:e==null?void 0:e.themeMode,onTelemetry:e==null?void 0:e.onTelemetry})},table({children:t}){return v.jsx("div",{className:"document-markdown-table-wrap",children:v.jsx("table",{children:t})})}}}function Fo(e,t){return v.jsx("article",{className:"document-markdown-prose",children:v.jsx(Un,{remarkPlugins:[Po],components:Oo(t),children:e})})}const zo=h.lazy(()=>se(()=>import("./pdf-renderer-DUYqGnQu.js"),__vite__mapDeps([3,1,4,5]))),$o=h.lazy(()=>se(()=>import("./pptx-renderer-DPSAG5_x.js"),__vite__mapDeps([6,1,4,5]))),Vo=h.lazy(()=>se(()=>import("./docx-renderer-Bws5M_Ee.js"),__vite__mapDeps([7,1,8,5]))),Uo=h.lazy(()=>se(()=>import("./spreadsheet-renderer-WVtOHmRi.js"),__vite__mapDeps([9,1,10]))),qo=h.lazy(()=>se(()=>import("./zip-renderer-oijmTXXF.js"),__vite__mapDeps([11,1,5]))),Ho=h.lazy(()=>se(()=>import("./epub-renderer-C-aCqy3m.js"),__vite__mapDeps([12,1,5]))),Bo=new Set([".md",".markdown"]),Wo=new Set(["application/markdown","application/x-markdown","text/markdown","text/x-markdown"]);function Go(e){var t;return(t=e.toLowerCase().match(/(\.[a-z0-9]+)$/))==null?void 0:t[1]}function Ko(e){var t;return(t=e==null?void 0:e.toLowerCase().split(";")[0])==null?void 0:t.trim()}function Xo(e){if(e.format!=="text")return!1;const t=Go(e.name);if(t&&Bo.has(t))return!0;const n=Ko(e.mimeType);return!!(n&&Wo.has(n))}function Se(e,t){return h.useMemo(()=>Qt(e,t),[e,t])}function it(e,t){const[n,r]=h.useState({status:t?"loading":"idle"});return h.useEffect(()=>{if(!t){r({status:"idle"});return}if(!e){r({status:"error",error:"The document does not expose a preview-safe URL for binary rendering."});return}const a=new AbortController;let o;return r({status:"loading"}),fetch(e.url,{...e.init,signal:a.signal}).then(async i=>{if(!i.ok)throw new Error(`Request failed with status ${i.status}`);const c=await i.blob();o=URL.createObjectURL(c),r({status:"ready",url:o})}).catch(i=>{a.signal.aborted||r({status:"error",error:i instanceof Error?i.message:"Unknown binary fetch failure"})}),()=>{a.abort(),o&&URL.revokeObjectURL(o)}},[t,e]),n}function Yo(e,t){const[n,r]=h.useState({status:"loading"});return h.useEffect(()=>{if(!e){r({status:"error",error:"The document does not expose a preview-safe URL for text rendering."});return}const a=new AbortController;return r({status:"loading"}),fetch(e.url,{...e.init,signal:a.signal}).then(async o=>{if(!o.ok)throw new Error(`Request failed with status ${o.status}`);const i=await o.text();r({status:"ready",text:i})}).catch(o=>{a.signal.aborted||r({status:"error",error:o instanceof Error?o.message:"Unknown text fetch failure"})}),()=>{a.abort()}},[t,e]),n}function ne(e,t){h.useLayoutEffect(()=>{if(!e.current||!t)return;const n=o=>{if(!e.current)return;const i=Math.ceil(e.current.getBoundingClientRect().height);t(i,o)},r=new ResizeObserver(()=>n("content"));r.observe(e.current);const a=()=>n("viewport");return window.addEventListener("resize",a),n("renderer"),()=>{r.disconnect(),window.removeEventListener("resize",a)}},[t,e])}function G({label:e}){return v.jsxs("div",{className:"document-loading",children:[v.jsx("div",{className:"document-spinner"}),v.jsx("p",{children:e})]})}function at({title:e,message:t}){return v.jsxs("div",{className:"document-empty-state",children:[v.jsx("h3",{children:e}),v.jsx("p",{children:t})]})}function Zo({document:e,session:t,onLoaded:n,onError:r,onResize:a}){const o=Se(e,t),i=e.source.kind==="session",c=it(o,i),s=h.useRef(null);ne(s,a);const l=i?c.url:o==null?void 0:o.url;return h.useEffect(()=>{i&&c.status==="error"&&r("document-fetch-failed",c.error??"Image failed to load",!0)},[e,c.error,c.status,r,i]),i&&c.status==="loading"?v.jsx(G,{label:"Fetching secure image preview"}):l?v.jsx("div",{ref:s,className:"document-media-shell",children:v.jsx("img",{src:l,alt:e.name,className:"document-image","data-viewer-zoom-target":!0,onLoad:()=>n(),onError:()=>r("document-fetch-failed","The image preview could not be loaded.",!0)})}):v.jsx(at,{title:"Image preview unavailable",message:"This image does not expose a preview-safe URL."})}function Qo({document:e,session:t,onLoaded:n,onError:r,onResize:a}){const o=Se(e,t),i=e.source.kind==="session",c=it(o,i),s=h.useRef(null);ne(s,a);const l=i?c.url:o==null?void 0:o.url;return h.useEffect(()=>{i&&c.status==="error"&&r("document-fetch-failed",c.error??"Video failed to load",!0)},[e,c.error,c.status,r,i]),i&&c.status==="loading"?v.jsx(G,{label:"Preparing secure video preview"}):l?v.jsx("div",{ref:s,className:"document-media-shell",children:v.jsx("video",{className:"document-video",controls:!0,playsInline:!0,src:l,onLoadedMetadata:()=>n(),onError:()=>r("document-fetch-failed","The video preview could not be loaded.",!0)})}):v.jsx(at,{title:"Video preview unavailable",message:"This video does not expose a preview-safe URL."})}function Jo({document:e,session:t,onLoaded:n,onError:r,onResize:a}){const o=Se(e,t),i=e.source.kind==="session",c=it(o,i),s=h.useRef(null);ne(s,a);const l=i?c.url:o==null?void 0:o.url;return h.useEffect(()=>{i&&c.status==="error"&&r("document-fetch-failed",c.error??"Audio failed to load",!0)},[e,c.error,c.status,r,i]),i&&c.status==="loading"?v.jsx(G,{label:"Preparing secure audio preview"}):l?v.jsx("div",{ref:s,className:"document-media-shell document-audio-shell",children:v.jsx("audio",{className:"document-audio",controls:!0,preload:"metadata",src:l,onLoadedMetadata:()=>n(),onError:()=>r("document-fetch-failed","The audio preview could not be loaded.",!0)})}):v.jsx(at,{title:"Audio preview unavailable",message:"This audio file does not expose a preview-safe URL."})}function be({document:e,session:t,onLoaded:n,onError:r,onResize:a,onTelemetry:o,themeMode:i,presentation:c}){const s=Se(e,t),l=Yo(s,!0),p=h.useRef(null),u=h.useRef(!1),f=h.useRef(!1),g=h.useRef(!1),m=h.useRef(!1),x=Pt(e);return ne(p,a),h.useEffect(()=>{u.current=!1,f.current=!1,g.current=!1,m.current=!1},[e.id]),h.useEffect(()=>{l.status==="ready"&&c!=="mermaid"&&!x&&n(),l.status==="error"&&r("document-fetch-failed",l.error??"Text preview failed to load.",!0)},[e,r,n,c,l.error,l.status,x]),l.status==="loading"?v.jsx(G,{label:c==="markdown"?"Rendering markdown preview":c==="mermaid"?"Rendering Mermaid preview":x?"Rendering code preview":"Loading text preview"}):l.status!=="ready"?null:c==="mermaid"?v.jsx("div",{ref:p,className:"document-mermaid-document",children:v.jsx(Rn,{source:l.text??"",title:e.name,themeMode:i,onTelemetry:o,onRendered:()=>{u.current||(u.current=!0,n())},onError:E=>{f.current||(f.current=!0,r("renderer-failed",E,!1))}})}):Pt(e)?v.jsx("div",{ref:p,className:"document-code-document","data-viewer-zoom-target":!0,children:v.jsx(rn,{source:l.text??"",title:e.name,languageHint:tn(e),themeMode:i,onTelemetry:o,onRendered:()=>{g.current||(g.current=!0,n())},onError:E=>{m.current||(m.current=!0,r("renderer-failed",E,!1))}})}):v.jsx("div",{ref:p,"data-viewer-zoom-target":!0,className:c==="markdown"?"document-markdown":"document-text-shell",children:c==="markdown"?Fo(l.text??"",{onTelemetry:o,themeMode:i}):v.jsx("pre",{children:l.text})})}function es({document:e,onUnsupported:t}){return h.useEffect(()=>{t("format-not-supported",`Format "${e.format}" is not supported in the current viewer phase.`)},[e,t]),null}function ts(e){const{document:t,pageNavigationRequest:n}=e,r=Se(t,e.session);switch(t.format){case"audio":return v.jsx(Jo,{...e});case"image":return v.jsx(Zo,{...e});case"video":return v.jsx(Qo,{...e});case"text":return v.jsx(be,{...e,presentation:Xo(t)?"markdown":"text"});case"code":return v.jsx(be,{...e,presentation:"text"});case"json":case"jsonl":case"ndjson":case"tsv":case"xml":case"toml":case"ini":case"dotenv":case"yaml":return v.jsx(be,{...e,presentation:"text"});case"html":case"widget":return v.jsx(li,{...e});case"markdown":return v.jsx(be,{...e,presentation:"markdown"});case"mermaid":return v.jsx(be,{...e,presentation:"mermaid"});case"pdf":return v.jsx(h.Suspense,{fallback:v.jsx(G,{label:"Loading PDF renderer"}),children:v.jsx(zo,{...e,request:r,useContainerResize:ne,pageNavigationRequest:n})});case"pptx":return v.jsx(h.Suspense,{fallback:v.jsx(G,{label:"Loading PPTX renderer"}),children:v.jsx($o,{...e,request:r,useContainerResize:ne,pageNavigationRequest:n,LoadingState:G})});case"docx":return v.jsx(h.Suspense,{fallback:v.jsx(G,{label:"Loading DOCX renderer"}),children:v.jsx(Vo,{...e,request:r,useContainerResize:ne,LoadingState:G})});case"xls":case"xlsx":case"csv":return v.jsx(h.Suspense,{fallback:v.jsx(G,{label:"Loading spreadsheet renderer"}),children:v.jsx(Uo,{...e,request:r,useContainerResize:ne,LoadingState:G})});case"zip":return v.jsx(h.Suspense,{fallback:v.jsx(G,{label:"Loading archive renderer"}),children:v.jsx(qo,{...e,request:r,useContainerResize:ne,LoadingState:G})});case"epub":return v.jsx(h.Suspense,{fallback:v.jsx(G,{label:"Loading EPUB renderer"}),children:v.jsx(Ho,{...e,request:r,useContainerResize:ne,LoadingState:G})});default:return v.jsx(es,{document:t,onUnsupported:e.onUnsupported})}}function ns({state:e,theme:t,safeArea:n,currentDocument:r,session:a,pageNavigationRequest:o,artifactDataMessage:i,streamCommandMessage:c,onLoaded:s,onUnsupported:l,onError:p,onTelemetry:u,onResize:f,onPageChanged:g,onArtifactEvent:m,onWidgetRequest:x,widgetResponseMessage:E}){var O,V,y,A;const b=h.useRef(null),S=h.useRef(null),w=h.useRef(0);hi(S,r==null?void 0:r.id);const z=h.useMemo(()=>{var d,D,M,T,K,X,ee,Y;return{...(d=t.tokens)!=null&&d.surface?{"--bg":t.tokens.surface}:{},...(D=t.tokens)!=null&&D.surfaceMuted?{"--panel":t.tokens.surfaceMuted}:{},...(M=t.tokens)!=null&&M.surface?{"--panel-strong":t.tokens.surface}:{},...(T=t.tokens)!=null&&T.surface?{"--message-panel-bg":t.tokens.surface}:{},...(K=t.tokens)!=null&&K.surface?{"--document-surface":t.tokens.surface}:{},...(X=t.tokens)!=null&&X.text?{"--text":t.tokens.text}:{},...(ee=t.tokens)!=null&&ee.text?{"--document-code-text":t.tokens.text}:{},...(Y=t.tokens)!=null&&Y.accent?{"--accent":t.tokens.accent}:{}}},[(O=t.tokens)==null?void 0:O.accent,(V=t.tokens)==null?void 0:V.surface,(y=t.tokens)==null?void 0:y.surfaceMuted,(A=t.tokens)==null?void 0:A.text]),L=h.useCallback((d,D)=>{if(Number.isFinite(D)&&(D??0)>0&&(w.current=Math.ceil(D??0)),!b.current)return;const M=Math.ceil(b.current.getBoundingClientRect().height),T=r&&Te(r.format)&&w.current>0?w.current:Math.max(M,w.current);T<=0||f(T,d)},[r==null?void 0:r.format,f]);return h.useLayoutEffect(()=>{w.current=0},[r==null?void 0:r.id]),h.useLayoutEffect(()=>{const d=document.documentElement;for(const D of["top","right","bottom","left"])d.style.setProperty(`--viewer-safe-area-${D}`,`${n[D]??0}px`);return()=>{for(const D of["top","right","bottom","left"])d.style.removeProperty(`--viewer-safe-area-${D}`)}},[n]),h.useLayoutEffect(()=>{const d=document.documentElement,D=Object.entries(z);d.dataset.themeMode=t.mode,d.dataset.documentFormat=(r==null?void 0:r.format)??"unknown";for(const[M,T]of D)d.style.setProperty(M,T);return()=>{delete d.dataset.themeMode,delete d.dataset.documentFormat;for(const[M]of D)d.style.removeProperty(M)}},[r==null?void 0:r.format,t.mode,z]),h.useLayoutEffect(()=>{if(!b.current)return;const d=new ResizeObserver(()=>L("content"));d.observe(b.current);const D=()=>L("viewport");return window.addEventListener("resize",D),L("renderer"),()=>{d.disconnect(),window.removeEventListener("resize",D)}},[L,e.phase,r==null?void 0:r.id]),(e.phase==="initializing"||e.phase==="loading-document"||e.phase==="ready")&&r?v.jsx("main",{ref:b,className:"viewer-shell viewer-shell-document",children:v.jsx("section",{className:"viewer-panel",children:v.jsx("div",{ref:S,className:"viewer-stage",children:v.jsx(ts,{document:r,session:a,theme:t,safeArea:n,themeMode:t.mode,onLoaded:s,onUnsupported:l,onError:p,onTelemetry:u,onResize:(d,D)=>L(D,d),onPageChanged:g,onArtifactEvent:m,onWidgetRequest:x,widgetResponseMessage:E,pageNavigationRequest:o,artifactDataMessage:i,streamCommandMessage:c})})})}):v.jsx("main",{ref:b,className:"viewer-shell"})}function He(e){if(e.phase==="initializing"||e.phase==="loading-document"||e.phase==="ready"||e.phase==="unsupported"||e.phase==="error")return e.document}const rs="0.1.0",is=["load-document","pagination","resize-notifications","artifact-runtime"];function as(){var r;const e=new URLSearchParams(window.location.search),t=e.get("themeMode"),n=t==="dark"||t==="light"?t:(r=window.matchMedia)!=null&&r.call(window,"(prefers-color-scheme: dark)").matches?"dark":"light";return{instanceId:e.get("instanceId")??"",parentOrigin:e.get("parentOrigin")??"",initialThemeMode:n}}function os(e){return e?Number.isNaN(Date.parse(e.expiresAt))||Date.parse(e.expiresAt)<=Date.now():!1}function ss(e){return J({instanceId:e,type:"viewer.ready",payload:{viewerVersion:rs,supportedProtocolVersions:[Me],capabilities:[...is]}})}function Vt(e,t,n,r){return J({instanceId:e,requestId:t,type:"viewer.ack",payload:{status:n,reason:r}})}function ls(e,t,n){return J({instanceId:e,type:"viewer.document-loaded",payload:{documentId:t.id,format:t.format,title:t.name,pageCount:n.pageCount}})}function cs(e,t,n,r){return J({instanceId:e,type:"viewer.unsupported",payload:{documentId:t.id,reason:n,message:r}})}function us(e,t,n,r,a){return J({instanceId:e,type:"viewer.error",payload:{documentId:a,code:t,message:n,recoverable:r}})}function ds(e,t,n){return J({instanceId:e,type:"viewer.resize",payload:{height:t,reason:n}})}function fs(e,t){return J({instanceId:e,type:"viewer.scroll",payload:{progress:t}})}function ps(e,t,n,r,a){return J({instanceId:e,type:"viewer.telemetry",payload:{level:t,name:n,message:r,context:a}})}function ms(e,t,n){return J({instanceId:e,type:"viewer.page-changed",payload:{page:t,pageCount:n}})}function hs(e,t,n,r){return J({instanceId:e,type:"viewer.artifact-event",payload:{documentId:t.id,name:n,detail:r}})}function gs(e,t){return J({instanceId:e,type:"viewer.widget-request",payload:t})}function vs(e){return e.instanceId&&e.parentOrigin&&e.parentOrigin!=="*"?{phase:"booting"}:{phase:"error",code:"invalid-message",message:"Viewer bootstrap is missing a secure instanceId or parent origin.",recoverable:!1}}function we(e){return e.phase==="initializing"||e.phase==="loading-document"||e.phase==="ready"?e.document:void 0}function bs(e){return e.type==="viewer.append-html"?{type:"append",html:e.payload.html,sequence:e.payload.sequence}:e.type==="viewer.abort-html-stream"?{type:"abort",reason:e.payload.reason}:{type:"complete"}}function ws(){const e=h.useMemo(()=>as(),[]),[t,n]=h.useState(()=>vs(e)),[r,a]=h.useState({}),[o,i]=h.useState({}),[c,s]=h.useState({mode:e.initialThemeMode}),[l,p]=h.useState(),[u,f]=h.useState(),[g,m]=h.useState(),[x,E]=h.useState(),b=h.useRef(t),S=h.useRef(r);h.useEffect(()=>{b.current=t},[t]),h.useEffect(()=>{S.current=r},[r]);const w=h.useCallback(I=>{window.parent!==window&&e.parentOrigin&&window.parent.postMessage(I,e.parentOrigin)},[e.parentOrigin]),z=h.useRef(null);h.useEffect(()=>{if(!e.instanceId)return;const I=ci({onProgress:k=>w(fs(e.instanceId,k))});z.current=I;const P=k=>I.handleScroll(k),N=k=>{var F;const B=(F=k.detail)==null?void 0:F.scrollTop;typeof B=="number"&&I.report(B)};return document.addEventListener("scroll",P,{capture:!0,passive:!0}),window.addEventListener(We,N),()=>{document.removeEventListener("scroll",P,{capture:!0}),window.removeEventListener(We,N),I.dispose(),z.current=null}},[e.instanceId,w]);const L=h.useCallback((I,P,N,k)=>{e.instanceId&&e.parentOrigin&&window.parent!==window&&window.parent.postMessage(ps(e.instanceId,I,P,N,k),e.parentOrigin)},[e.instanceId,e.parentOrigin]),O=h.useCallback((I,P,N,k)=>{n({phase:"error",code:I,message:P,recoverable:N,document:k}),w(us(e.instanceId,I,P,N,k==null?void 0:k.id)),L("error",I,P,{recoverable:N,documentId:(k==null?void 0:k.id)??null})},[e.instanceId,w,L]);h.useEffect(()=>{if(!e.instanceId||!e.parentOrigin||e.parentOrigin==="*")return;const I=(N,k)=>{var W;const B=N.payload.document,F=N.payload.session;if(s(ge=>N.payload.theme??ge),os(F)){w(Vt(e.instanceId,N.messageId,"rejected","Session has expired.")),O("session-expired","The secure viewer session is missing or expired.",!0,B);return}i(ge=>N.payload.safeArea??(N.type==="viewer.init"?{}:ge)),N.type==="viewer.init"&&((W=z.current)==null||W.setDistance(N.payload.scrollProgressDistance));const Z=k??(b.current.phase==="ready"||b.current.phase==="initializing"||b.current.phase==="loading-document"?b.current.host:{name:"unknown-host",origin:e.parentOrigin,sdkVersion:"unknown"});a({}),p(void 0),f(void 0),m(void 0),L("info",N.type,"Viewer accepted a parent command.",{documentId:B.id,format:B.format}),n({phase:N.type==="viewer.init"?"initializing":"loading-document",document:B,session:F,host:Z}),w(Vt(e.instanceId,N.messageId,"accepted"))},P=N=>{var B;if(N.source!==window.parent)return;if(N.origin!==e.parentOrigin){O("origin-mismatch",`Rejected parent message from unexpected origin ${N.origin}.`,!1,we(b.current));return}if(!Ir(N.data)){L("warn","viewer.parent-message.ignored","Ignored a parent window message that did not match the viewer protocol.",{phase:b.current.phase});return}const k=N.data;if(k.instanceId===e.instanceId){if(k.type==="viewer.init"){I(k,k.payload.host);return}if(k.type==="viewer.go-to-page"){p(F=>({page:k.payload.page,nonce:((F==null?void 0:F.nonce)??0)+1}));return}if(k.type==="viewer.set-safe-area"){i(k.payload.safeArea);return}if(k.type==="viewer.set-theme"){const F=k.payload.theme;s(F),L("info","viewer.set-theme","Viewer updated theme without reloading the document.",{documentId:((B=we(b.current))==null?void 0:B.id)??null,mode:F.mode});return}if(k.type==="viewer.widget-response"){E(F=>({nonce:((F==null?void 0:F.nonce)??0)+1,payloads:[...(F==null?void 0:F.payloads)??[],k.payload]}));return}if(k.type==="viewer.send-artifact-data"){const F=we(b.current)??He(b.current);if(!F||!Te(F.format)){L("warn","artifact.data.ignored","Artifact runtime data was ignored because no HTML artifact is active.",{requestedDocumentId:k.payload.documentId??null});return}if(k.payload.documentId&&k.payload.documentId!==F.id){L("warn","artifact.data.mismatch","Artifact runtime data targeted a different document and was ignored.",{activeDocumentId:F.id,requestedDocumentId:k.payload.documentId});return}f(Z=>({nonce:((Z==null?void 0:Z.nonce)??0)+1,data:k.payload.data}));return}if(k.type==="viewer.append-html"||k.type==="viewer.complete-html-stream"||k.type==="viewer.abort-html-stream"){const F=we(b.current)??He(b.current);if(!F||!Te(F.format)||F.source.kind!=="stream"){L("warn","html.stream.ignored","HTML stream command was ignored because no stream HTML document is active.",{commandType:k.type,requestedDocumentId:k.payload.documentId??null});return}if(k.payload.documentId&&k.payload.documentId!==F.id){L("warn","html.stream.mismatch","HTML stream command targeted a different document and was ignored.",{activeDocumentId:F.id,requestedDocumentId:k.payload.documentId,commandType:k.type});return}m(Z=>({nonce:((Z==null?void 0:Z.nonce)??0)+1,commands:[...(Z==null?void 0:Z.commands)??[],bs(k)]}));return}I(k)}};return window.addEventListener("message",P),n({phase:"waiting-for-init"}),w(ss(e.instanceId)),L("info","viewer.ready","Viewer shell announced readiness."),()=>{window.removeEventListener("message",P)}},[e.instanceId,e.parentOrigin,O,w,L]);const V=h.useCallback(I=>{a(P=>({...P,pageCount:I==null?void 0:I.pageCount})),n(P=>P.phase!=="initializing"&&P.phase!=="loading-document"?P:(w(ls(e.instanceId,P.document,{...S.current,...I})),L("info","document.loaded","Renderer finished loading the document.",{documentId:P.document.id,format:P.document.format,pageCount:(I==null?void 0:I.pageCount)??null}),{phase:"ready",document:P.document,session:P.session,host:P.host}))},[e.instanceId,w,L]),y=h.useCallback((I,P)=>{n(N=>{const k=we(N)??(N.phase==="ready"?N.document:void 0);return k&&(w(cs(e.instanceId,k,I,P)),L("warn",I,P,{documentId:k.id})),{phase:"unsupported",document:k,reason:I,message:P}})},[e.instanceId,w,L]),A=He(t),d=A==null?void 0:A.id;h.useEffect(()=>{var I;(I=z.current)==null||I.reset()},[d]);const D=t.phase==="initializing"||t.phase==="loading-document"||t.phase==="ready"?t.session:void 0,M=h.useCallback((I,P,N)=>{O(I,P,N,A)},[A,O]),T=h.useCallback((I,P,N,k)=>{L(I,P,N,{documentId:(A==null?void 0:A.id)??null,format:(A==null?void 0:A.format)??null,...k})},[A,L]),K=h.useCallback((I,P)=>{w(ds(e.instanceId,I,P))},[e.instanceId,w]),X=h.useCallback((I,P)=>{A&&(w(hs(e.instanceId,A,I,P)),L("info","artifact.event","HTML artifact emitted a runtime event.",{eventName:I,documentId:A.id}))},[e.instanceId,A,w,L]),ee=h.useCallback(I=>{A&&(w(gs(e.instanceId,{documentId:A.id,...I})),L("info","widget.request","A widget asked its host.",{method:I.method,documentId:A.id}))},[e.instanceId,A,w,L]),Y=h.useCallback((I,P)=>{a(N=>({...N,currentPage:I,pageCount:P??N.pageCount})),w(ms(e.instanceId,I,P)),L("info","page.changed","PDF page changed.",{page:I,pageCount:P??null})},[e.instanceId,w,L]);return v.jsx(ns,{state:t,theme:c,safeArea:o,currentDocument:A,session:D,pageNavigationRequest:l,artifactDataMessage:u,streamCommandMessage:g,onLoaded:V,onUnsupported:y,onError:M,onTelemetry:T,onResize:K,onPageChanged:Y,onArtifactEvent:X,onWidgetRequest:ee,widgetResponseMessage:x})}const In=document.getElementById("root");if(!In)throw new Error("Root element not found");qn.createRoot(In).render(v.jsx(h.StrictMode,{children:v.jsx(ws,{})}));export{Nt as c};
|