@dvina/artifact-renderer-viewer 0.0.41 → 0.0.42
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-DRpEhT3s.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 wt,j as v,_ as ae,e as Ft,v as Tn,o as me,u as pe,i as Xe,n as ke,k as Re,l as jn,t as $t,E as Mn,m as Ye,p as we,q as X,x as Pn,y as _n,z as re,A as _e,B as Nn,C as be,D as ce,F as Dn,M as On,G as zn}from"./react-vendor-Dhb16r3m.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.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 t(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=t(a);fetch(a.href,o)}})();const Fn=["ui/message","ui/open-link","dvina/open-target"];function Ie(e){return e==="html"||e==="widget"}const Vt="dvina-artifact-renderer",je="1.0",$n=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"]),Vn=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"]),Un=new Set(["viewer.ack"]);function N(e){return typeof e=="object"&&e!==null}function T(e){return typeof e=="string"&&e.length>0}function qn(e){return Array.isArray(e)&&e.every(T)}function Hn(e){return e==="load-document"||e==="pagination"||e==="resize-notifications"||e==="artifact-runtime"}function Bn(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 Ut(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 ie(e){return e===null||typeof e=="string"||typeof e=="boolean"?!0:typeof e=="number"?Number.isFinite(e):Array.isArray(e)?e.every(ie):N(e)?Object.values(e).every(ie):!1}function Ze(e){return N(e)&&!Array.isArray(e)&&["top","right","bottom","left"].every(n=>{const t=e[n];return t===void 0||typeof t=="number"&&Number.isFinite(t)&&t>=0})}function Je(e){if(!N(e)||e.mode!=="light"&&e.mode!=="dark")return!1;const n=t=>t===void 0||N(t)&&Object.values(t).every(r=>r===void 0||typeof r=="string");return n(e.tokens)&&n(e.variables)}function qt(e){if(!N(e))return!1;const n=e.source;if(!N(n))return!1;const t=n.kind==="url"&&T(n.url)||n.kind==="session"&&T(n.url)&&T(n.sessionId)||n.kind==="stream",r=e.renderOptions,a=r===void 0||N(r)&&(r.spreadsheetMode===void 0||r.spreadsheetMode==="fast"||r.spreadsheetMode==="styled")&&(r.codeLanguage===void 0||T(r.codeLanguage))&&(r.html===void 0||N(r.html)&&(r.html.revisionId===void 0||T(r.html.revisionId))&&(r.html.artifactData===void 0||ie(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(Bn)))&&(r.widget===void 0||Wn(r.widget));return T(e.id)&&T(e.name)&&Ut(e.format)&&t&&a&&(e.mimeType===void 0||typeof e.mimeType=="string")&&(e.size===void 0||typeof e.size=="number")}function Wn(e){if(!N(e))return!1;const n=e.kit,t=n===void 0||n===!1||N(n)&&["css","script","reactScript"].every(r=>n[r]===void 0||typeof n[r]=="string");return(e.kind===void 0||e.kind==="html"||e.kind==="react")&&(e.layout===void 0||e.layout==="inline"||e.layout==="panel")&&t&&(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.labels===void 0||N(e.labels)&&Object.values(e.labels).every(r=>r===void 0||typeof r=="string"))&&(e.revisionId===void 0||T(e.revisionId))&&(e.artifactData===void 0||ie(e.artifactData))}function Ht(e){return N(e)&&T(e.token)&&T(e.expiresAt)&&qn(e.scopes)}function Gn(e){return N(e)&&T(e.name)&&T(e.origin)&&T(e.sdkVersion)}function Kn(e){return e==="format-not-supported"||e==="encrypted-document"||e==="missing-renderer"||e==="feature-not-available"}function Xn(e){return e==="invalid-message"||e==="origin-mismatch"||e==="session-expired"||e==="document-fetch-failed"||e==="renderer-failed"||e==="timeout"}function Yn(e){return e==="info"||e==="warn"||e==="error"}function Zn(e){return N(e)&&T(e.viewerVersion)&&Array.isArray(e.supportedProtocolVersions)&&e.supportedProtocolVersions.every(n=>n===je)&&Array.isArray(e.capabilities)&&e.capabilities.every(Hn)}function Jn(e){return N(e)&&qt(e.document)&&(e.theme===void 0||Je(e.theme))&&(e.safeArea===void 0||Ze(e.safeArea))&&(e.scrollProgressDistance===void 0||fr(e.scrollProgressDistance))&&(e.session===void 0||Ht(e.session))&&Gn(e.host)}function Qn(e){return N(e)&&qt(e.document)&&(e.theme===void 0||Je(e.theme))&&(e.safeArea===void 0||Ze(e.safeArea))&&(e.session===void 0||Ht(e.session))}function er(e){return N(e)&&typeof e.page=="number"&&Number.isInteger(e.page)&&e.page>0}function tr(e){return N(e)&&Je(e.theme)}function nr(e){return N(e)&&(e.documentId===void 0||T(e.documentId))&&ie(e.data)}function rr(e){return N(e)&&(e.documentId===void 0||T(e.documentId))&&T(e.html)&&(e.sequence===void 0||typeof e.sequence=="number"&&Number.isInteger(e.sequence)&&e.sequence>=0)}function ir(e){return N(e)&&(e.documentId===void 0||T(e.documentId))}function ar(e){return N(e)&&(e.documentId===void 0||T(e.documentId))&&(e.reason===void 0||T(e.reason))}function or(e){return N(e)&&T(e.documentId)&&Ut(e.format)&&T(e.title)&&(e.pageCount===void 0||typeof e.pageCount=="number")}function sr(e){return N(e)&&typeof e.page=="number"&&(e.pageCount===void 0||typeof e.pageCount=="number")}function lr(e){return N(e)&&T(e.documentId)&&T(e.name)&&(e.detail===void 0||ie(e.detail))}const cr=new Set(["ui/message","ui/open-link","dvina/open-target","ui/update-model-context","dvina/call"]);function Bt(e){return typeof e=="string"&&cr.has(e)}function Wt(e,n){if(!N(n)||Array.isArray(n)||!ie(n))return!1;switch(e){case"ui/message":return n.role==="user"&&Array.isArray(n.content)&&n.content.length>0&&n.content.every(t=>N(t)&&t.type==="text"&&T(t.text));case"ui/open-link":return T(n.url)&&/^https?:\/\//i.test(n.url);case"dvina/open-target":return T(n.kind)&&T(n.id);case"ui/update-model-context":return"structuredContent"in n;case"dvina/call":return T(n.name)}}function ur(e){return N(e)&&T(e.documentId)&&T(e.requestId)&&Bt(e.method)&&Wt(e.method,e.params)}function dr(e){return N(e)&&T(e.requestId)&&(e.result===void 0||ie(e.result))&&(e.error===void 0||N(e.error)&&T(e.error.code)&&typeof e.error.message=="string")}function fr(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function pr(e){return N(e)&&typeof e.progress=="number"&&e.progress>=0&&e.progress<=1}function mr(e){return N(e)&&typeof e.height=="number"&&(e.reason==="content"||e.reason==="viewport"||e.reason==="renderer")}function hr(e){return N(e)&&T(e.name)&&Yn(e.level)&&T(e.message)&&(e.context===void 0||N(e.context)&&Object.values(e.context).every(n=>n===null||typeof n=="string"||typeof n=="number"||typeof n=="boolean"))}function gr(e){return N(e)&&T(e.documentId)&&Kn(e.reason)&&T(e.message)}function vr(e){return N(e)&&(e.documentId===void 0||T(e.documentId))&&Xn(e.code)&&T(e.message)&&typeof e.recoverable=="boolean"}function br(e){return N(e)&&(e.status==="accepted"||e.status==="rejected")&&(e.reason===void 0||T(e.reason))}const wr={"viewer.ready":Zn,"viewer.init":Jn,"viewer.load-document":Qn,"viewer.set-theme":tr,"viewer.set-safe-area":e=>N(e)&&Ze(e.safeArea),"viewer.go-to-page":er,"viewer.send-artifact-data":nr,"viewer.append-html":rr,"viewer.complete-html-stream":ir,"viewer.abort-html-stream":ar,"viewer.widget-response":dr,"viewer.widget-request":ur,"viewer.document-loaded":or,"viewer.page-changed":sr,"viewer.artifact-event":lr,"viewer.resize":mr,"viewer.scroll":pr,"viewer.telemetry":hr,"viewer.error":vr,"viewer.unsupported":gr,"viewer.ack":br};function Gt(e){return typeof e=="string"&&$n.has(e)}function xr(e){return typeof e=="string"&&Vn.has(e)}function Kt(e){return typeof e=="string"&&Un.has(e)}function yr(e){return Gt(e)||xr(e)||Kt(e)}function kr(e){return N(e)&&e.channel===Vt&&e.version===je&&T(e.instanceId)&&T(e.messageId)&&yr(e.type)&&typeof e.timestamp=="number"&&"payload"in e}function Er(e){if(!kr(e))return!1;if(Kt(e.type)){if(!T(e.requestId))return!1}else if("requestId"in e&&e.requestId!==void 0)return!1;return wr[e.type](e.payload)}function Ar(e){return Er(e)&&Gt(e.type)}function Sr(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`viewer-${Math.random().toString(36).slice(2,10)}`}function Z(e){return{channel:Vt,version:je,messageId:e.messageId??Sr(),timestamp:e.timestamp??Date.now(),...e}}function Xt(e,n){if(e.source.kind==="stream")return null;const t=e.source.url;if(!t)return null;const r=new Headers;let a=!1;return n!=null&&n.token&&(r.set("Authorization",`Bearer ${n.token}`),a=!0),{url:t,init:a?{headers:r}:void 0}}const Lr={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-CS21e6NP.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},Cr=["https://cdnjs.cloudflare.com","https://cdn.jsdelivr.net","https://unpkg.com","https://esm.sh"];function He(e){return new URL(e,window.location.href).href}function Yt(e=window.location.origin){const n=Cr.join(" ");return["default-src 'none'",`script-src 'unsafe-inline' 'unsafe-eval' blob: ${e} ${n}`,`style-src 'unsafe-inline' ${e} ${n} https://fonts.googleapis.com`,`font-src data: ${e} ${n} https://fonts.gstatic.com`,`img-src data: blob: ${n}`,"media-src data: blob:",`connect-src ${n}`,"worker-src blob:","frame-src 'none'","form-action 'none'","base-uri 'none'"].join("; ")}const Rr=["allow-scripts","allow-forms","allow-popups","allow-popups-to-escape-sandbox","allow-downloads"],Zt={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}"},de={...Lr};function Ir(e){const n=e.replace(/^\[|\]$/g,"").toLowerCase();return n==="localhost"||n.endsWith(".localhost")||n.endsWith(".local")||n==="::1"||/^127\./.test(n)||/^10\./.test(n)||/^192\.168\./.test(n)||/^172\.(1[6-9]|2\d|3[01])\./.test(n)}const Tr=["kitCss","kitScript","kitReactScript","tailwindScript","reactLoader","svgMenu"];let xt=null;function yt(){return xt??(xt=de.inline||!Ir(window.location.hostname)?Promise.resolve():Promise.all(Tr.map(async e=>{const n=await fetch(de[e]);if(!n.ok)throw new Error(`${e}: ${n.status}`);return[e,await n.text()]})).then(e=>{for(const[n,t]of e)de[n]=t;de.inline=!0},()=>{})),xt}const jr='"use strict";(()=>{var Ie=300,Fe=/^[A-Za-z0-9_.:-]{1,128}$/;function ae(e,t){if(typeof t!="string"||!Fe.test(t))throw new Error(`A ${e} is 1\\u2013128 letters, digits or . _ : - ("${String(t)}" is not).`)}function De(e,t){return e===t?0:e==null?1:t==null||e<t?-1:1}function ke(e,t){let n=null,r=null,i=[],o=0,f=!1,m=new Set,g=()=>m.forEach(a=>a());function A(a=!1){return n&&!a?Promise.resolve(n):(r&&!a||(r=e.read().then(l=>{r=null,n={version:l.version,collections:structuredClone(l.collections)};for(let{op:c}of i)x(c);return g(),n},l=>{throw r=null,l})),r)}function x(a){var c,d;if(!n)return;let l=(c=n.collections)[d=a.collection]??(c[d]={});a.op==="delete"?delete l[a.id]:a.op==="set"?l[a.id]=structuredClone(a.doc??{}):l[a.id]={...l[a.id]??{},...structuredClone(a.doc??{})}}async function E(){var l;if(o=0,f||i.length===0)return;f=!0;let a=i;i=[];try{let c=await e.apply(a.map(({op:d})=>d));if(n){n.version=c.version;for(let{collection:d,id:y,doc:s}of c.changed){let p=(l=n.collections)[d]??(l[d]={});s===null?delete p[y]:p[y]=s}for(let{op:d}of i)x(d)}a.forEach(({settle:d})=>d()),g()}catch(c){let d=c instanceof Error?c:new Error(String(c));a.forEach(({settle:y})=>y(d)),t(d),await A(!0).catch(()=>{})}finally{f=!1,i.length&&h()}}function h(){o||(o=window.setTimeout(()=>void E(),Ie))}async function N(a){return ae("collection",a.collection),ae("document id",a.id),await A(),new Promise((l,c)=>{x(a),i.push({op:a,settle:d=>d?c(d):l()}),g(),h()})}return{load:A,refresh(){n&&!f&&i.length===0&&A(!0).catch(()=>{})},collection(a){ae("collection",a);let l=()=>n?.collections[a]??{};return Object.freeze({async get(c){await A();let d=l()[c];return d?{...structuredClone(d),id:c}:null},async list(c={}){await A();let d=Object.entries(l()).map(([S,C])=>({...structuredClone(C),id:S})),{where:y,orderBy:s,limit:p}=c;if(typeof y=="function"?d=d.filter(y):y&&(d=d.filter(S=>Object.entries(y).every(([C,_])=>S[C]===_))),s){let[S,C]=Array.isArray(s)?s:[s,"asc"];d.sort((_,O)=>De(_[S],O[S])*(C==="desc"?-1:1))}return typeof p=="number"?d.slice(0,Math.max(0,p)):d},set:(c,d)=>N({op:"set",collection:a,id:c,doc:d}),update:(c,d)=>N({op:"update",collection:a,id:c,doc:d}),delete:c=>N({op:"delete",collection:a,id:c}),subscribe(c){return m.add(c),()=>m.delete(c)}})}}}var He="_kv";function de(e,t=()=>{}){let n=ke(e,t),r=()=>n.refresh();window.addEventListener("focus",r),document.addEventListener("visibilitychange",()=>document.visibilityState==="visible"&&r());let i=Object.freeze({collection:m=>n.collection(m)}),o=()=>n.collection(He),f=Object.freeze({async get(m){return(await o().get(m))?.value},set:(m,g)=>o().set(m,{value:g}),delete:m=>o().delete(m),async list(m={}){return(await o().list()).map(A=>A.id).filter(A=>!m.prefix||A.startsWith(m.prefix))}});return{db:i,storage:f}}var fe=15e3;function me(e){let t=new Map,n=0;function r(s,p,S=fe){return e.enabled?i(s,p,S):Promise.reject(new Error("The widget bridge is off."))}function i(s,p,S=fe){let C=`w${++n}`;return new Promise((_,O)=>{let F=window.setTimeout(()=>{t.delete(C),O(new Error(`${s} timed out after ${S} ms`))},S);t.set(C,{resolve:_,reject:O,timer:F}),e.post({channel:e.channel,jsonrpc:"2.0",id:C,method:s,params:p})})}let o=(s,p)=>r(s,p).then(()=>!0,()=>!1),f={send:(s,p)=>typeof s=="string"&&s.trim()?o("ui/message",{role:"user",content:[{type:"text",text:s.trim()}],...p===void 0?{}:{context:p}}):Promise.resolve(!1)},m={open:s=>o("ui/open-link",{url:String(s)})},g={open:(s,p)=>o("dvina/open-target",{kind:s,id:p})},A={set:s=>o("ui/update-model-context",{structuredContent:s}),clear:()=>o("ui/update-model-context",{structuredContent:null})},x={call:(s,p)=>r("dvina/call",p===void 0?{name:s}:{name:s,args:p})},E={prompt:f,link:m,target:g,context:A,host:x},h=null,N={read:()=>x.call("db.read",{}),apply:s=>x.call("db.apply",{ops:s})},a=s=>!e.data||s!=="db"&&s!=="storage"?null:(h??(h=de(N,p=>console.error("[dvina] a write was refused:",p.message))),s==="db"?h.db:h.storage),l={use:s=>Promise.resolve(e.enabled?s in E?Object.freeze({...E[s]}):a(s):null)};function c(s){if(s.jsonrpc!=="2.0"||typeof s.id!="string")return!1;let p=t.get(s.id);if(!p)return!0;t.delete(s.id),window.clearTimeout(p.timer);let S=s.error;return S?p.reject(new Error(S.message||"The host refused the request.")):p.resolve(s.result??null),!0}function d(){document.addEventListener("click",s=>{if(s.defaultPrevented||s.button!==0)return;let p=s.target?.closest?.("a[href]");!p||!/^https?:/i.test(p.href)||(s.preventDefault(),m.open(p.href))})}let y=e.enabled||e.pictures?(s,p)=>i("dvina/call",p===void 0?{name:s}:{name:s,args:p}):null;return{dvina:l,prompt:f,link:m,host:x,pictures:y,receive:c,interceptLinks:d}}var $="data-dvina-image",j="data-dvina-image-state",Ue="image.read";var Be=/^image\\/(webp|jpeg|png|gif|avif)$/,pe=/^(data|blob):/i;function oe(e){let t=e.getAttribute("src");return!t||!pe.test(t)}function $e(e){let t=e.getAttribute("src");t&&!pe.test(t)&&e.removeAttribute("src"),e.removeAttribute("srcset"),e.removeAttribute("sizes");let n=e.parentElement;n?.tagName==="PICTURE"&&n.querySelectorAll("source[srcset]").forEach(r=>r.removeAttribute("srcset"))}function Je(e){let{mimeType:t,data:n}=e??{};if(typeof t!="string"||!Be.test(t)||typeof n!="string")throw new Error("The host gave no picture.");if(n.length>Math.ceil(8388608/3)*4)throw new Error("The picture is too large.");let r=atob(n),i=new Uint8Array(r.length);for(let o=0;o<r.length;o+=1)i[o]=r.charCodeAt(o);return new Blob([i],{type:t})}function ve(e){let t=new Map,n=new Map,r=[],i=0,o=0,f=typeof IntersectionObserver=="function"?new IntersectionObserver(a=>{for(let l of a)l.isIntersecting&&(f?.unobserve(l.target),x(l.target))}):null;function m(){for(;i<3&&r.length>0;){let a=r.shift();i+=1,a().finally(()=>{i-=1,m()})}}function g(a){let l=t.get(a);if(l)return l;let{call:c}=e;if(!c){n.set(a,null);let y=Promise.resolve(null);return t.set(a,y),y}let d=new Promise(y=>{let s=p=>{n.set(a,p),y(p)};r.push(async()=>{if(o>=12)return s(null);o+=1;let p=await c(Ue,{url:a}).then(S=>URL.createObjectURL(Je(S))).catch(()=>(o-=1,null));s(p)}),m()});return t.set(a,d),d}function A(a){let l=a.getAttribute($)?.trim();if(!(!l||!oe(a))){if($e(a),n.has(l)){E(a,l,n.get(l)??null);return}a.setAttribute(j,"loading"),f?f.observe(a):x(a)}}function x(a){let l=a.getAttribute($)?.trim();!l||!oe(a)||g(l).then(c=>E(a,l,c))}function E(a,l,c){if(!(a.getAttribute($)?.trim()!==l||!oe(a))){if(!c){a.setAttribute(j,"failed");return}a.removeAttribute(j),a.src=c}}function h(a){a instanceof HTMLImageElement&&A(a),a.querySelectorAll?.(`img[${$}]`).forEach(A)}function N(a){let l=new MutationObserver(c=>{for(let d of c)d.type==="attributes"?h(d.target):d.addedNodes.forEach(y=>y.nodeType===Node.ELEMENT_NODE&&h(y))});return l.observe(a,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[$,"src","srcset"]}),(a instanceof Element||a instanceof Document)&&h(a),l}return{apply:h,observe:N}}function ge(e,t){if(e.tagName!=="IMG"||t.tagName!=="IMG")return;let n=e.getAttribute($);if(!n||n!==t.getAttribute($))return;let r=e.getAttribute("src");r&&/^blob:/i.test(r)&&!/^data:/i.test(t.getAttribute("src")??"")&&(t.setAttribute("src",r),t.removeAttribute("srcset"),t.removeAttribute("sizes"));let i=e.getAttribute(j);i&&t.setAttribute(j,i)}var W=new Map;function se(e){let t=!1,n=()=>{t||(t=!0,cancelAnimationFrame(r),window.clearTimeout(W.get(r)),W.delete(r),e())},r=requestAnimationFrame(n);return W.set(r,window.setTimeout(n,100)),r}function le(e){cancelAnimationFrame(e),window.clearTimeout(W.get(e)),W.delete(e)}var ze={requestFrame:se,cancelFrame:le,setTimer:(e,t)=>window.setTimeout(e,t),clearTimer:e=>window.clearTimeout(e),now:()=>performance.now()};function be(e,t=ze,n=150){let r=0,i=0,o=Number.NEGATIVE_INFINITY;function f(){r=0,o=t.now(),e()}function m(){r&&t.cancelFrame(r),i&&t.clearTimer(i),r=0,i=0}return{request(){if(r||i)return;let g=o+n-t.now();if(g<=0){r=t.requestFrame(f);return}i=t.setTimer(()=>{i=0,r=t.requestFrame(f)},g)},flushNow(){m(),f()},cancel:m}}var we=11;function qe(e,t){var n=t.attributes,r,i,o,f,m;if(!(t.nodeType===we||e.nodeType===we)){for(var g=n.length-1;g>=0;g--)r=n[g],i=r.name,o=r.namespaceURI,f=r.value,o?(i=r.localName||i,m=e.getAttributeNS(o,i),m!==f&&(r.prefix==="xmlns"&&(i=r.name),e.setAttributeNS(o,i,f))):(m=e.getAttribute(i),m!==f&&e.setAttribute(i,f));for(var A=e.attributes,x=A.length-1;x>=0;x--)r=A[x],i=r.name,o=r.namespaceURI,o?(i=r.localName||i,t.hasAttributeNS(o,i)||e.removeAttributeNS(o,i)):t.hasAttribute(i)||e.removeAttribute(i)}}var Z,je="http://www.w3.org/1999/xhtml",P=typeof document>"u"?void 0:document,We=!!P&&"content"in P.createElement("template"),Ge=!!P&&P.createRange&&"createContextualFragment"in P.createRange();function Ye(e){var t=P.createElement("template");return t.innerHTML=e,t.content.childNodes[0]}function Xe(e){Z||(Z=P.createRange(),Z.selectNode(P.body));var t=Z.createContextualFragment(e);return t.childNodes[0]}function Ke(e){var t=P.createElement("body");return t.innerHTML=e,t.childNodes[0]}function Ze(e){return e=e.trim(),We?Ye(e):Ge?Xe(e):Ke(e)}function Q(e,t){var n=e.nodeName,r=t.nodeName,i,o;return n===r?!0:(i=n.charCodeAt(0),o=r.charCodeAt(0),i<=90&&o>=97?n===r.toUpperCase():o<=90&&i>=97?r===n.toUpperCase():!1)}function Qe(e,t){return!t||t===je?P.createElement(e):P.createElementNS(t,e)}function et(e,t){for(var n=e.firstChild;n;){var r=n.nextSibling;t.appendChild(n),n=r}return t}function ce(e,t,n){e[n]!==t[n]&&(e[n]=t[n],e[n]?e.setAttribute(n,""):e.removeAttribute(n))}var he={OPTION:function(e,t){var n=e.parentNode;if(n){var r=n.nodeName.toUpperCase();r==="OPTGROUP"&&(n=n.parentNode,r=n&&n.nodeName.toUpperCase()),r==="SELECT"&&!n.hasAttribute("multiple")&&(e.hasAttribute("selected")&&!t.selected&&(e.setAttribute("selected","selected"),e.removeAttribute("selected")),n.selectedIndex=-1)}ce(e,t,"selected")},INPUT:function(e,t){ce(e,t,"checked"),ce(e,t,"disabled"),e.value!==t.value&&(e.value=t.value),t.hasAttribute("value")||e.removeAttribute("value")},TEXTAREA:function(e,t){var n=t.value;e.value!==n&&(e.value=n);var r=e.firstChild;if(r){var i=r.nodeValue;if(i==n||!n&&i==e.placeholder)return;r.nodeValue=n}},SELECT:function(e,t){if(!t.hasAttribute("multiple")){for(var n=-1,r=0,i=e.firstChild,o,f;i;)if(f=i.nodeName&&i.nodeName.toUpperCase(),f==="OPTGROUP")o=i,i=o.firstChild,i||(i=o.nextSibling,o=null);else{if(f==="OPTION"){if(i.hasAttribute("selected")){n=r;break}r++}i=i.nextSibling,!i&&o&&(i=o.nextSibling,o=null)}e.selectedIndex=n}}},G=1,ye=11,Te=3,Ae=8;function H(){}function tt(e){if(e)return e.getAttribute&&e.getAttribute("id")||e.id}function rt(e){return function(n,r,i){if(i||(i={}),typeof r=="string")if(n.nodeName==="#document"||n.nodeName==="HTML"){var o=r;r=P.createElement("html"),r.innerHTML=o}else if(n.nodeName==="BODY"){var f=r;r=P.createElement("html"),r.innerHTML=f;var m=r.querySelector("body");m&&(r=m)}else r=Ze(r);else r.nodeType===ye&&(r=r.firstElementChild);var g=i.getNodeKey||tt,A=i.onBeforeNodeAdded||H,x=i.onNodeAdded||H,E=i.onBeforeElUpdated||H,h=i.onElUpdated||H,N=i.onBeforeNodeDiscarded||H,a=i.onNodeDiscarded||H,l=i.onBeforeElChildrenUpdated||H,c=i.skipFromChildren||H,d=i.addChild||function(b,w){return b.appendChild(w)},y=i.childrenOnly===!0,s=Object.create(null),p=[];function S(b){p.push(b)}function C(b,w){if(b.nodeType===G)for(var R=b.firstChild;R;){var T=void 0;w&&(T=g(R))?S(T):(a(R),R.firstChild&&C(R,w)),R=R.nextSibling}}function _(b,w,R){N(b)!==!1&&(w&&w.removeChild(b),a(b),C(b,R))}function O(b){if(b.nodeType===G||b.nodeType===ye)for(var w=b.firstChild;w;){var R=g(w);R&&(s[R]=w),O(w),w=w.nextSibling}}O(n);function F(b){x(b);for(var w=b.firstChild;w;){var R=w.nextSibling,T=g(w);if(T){var M=s[T];M&&Q(w,M)?(w.parentNode.replaceChild(M,w),v(M,w)):F(w)}else F(w);w=R}}function u(b,w,R){for(;w;){var T=w.nextSibling;(R=g(w))?S(R):_(w,b,!0),w=T}}function v(b,w,R){var T=g(w);if(T&&delete s[T],!R){var M=E(b,w);if(M===!1||(M instanceof HTMLElement&&(b=M,O(b)),e(b,w),h(b),l(b,w)===!1))return}b.nodeName!=="TEXTAREA"?q(b,w):he.TEXTAREA(b,w)}function q(b,w){var R=c(b,w),T=w.firstChild,M=b.firstChild,J,I,z,X,D;e:for(;T;){for(X=T.nextSibling,J=g(T);!R&&M;){if(z=M.nextSibling,T.isSameNode&&T.isSameNode(M)){T=X,M=z;continue e}I=g(M);var K=M.nodeType,k=void 0;if(K===T.nodeType&&(K===G?(J?J!==I&&((D=s[J])?z===D?k=!1:(b.insertBefore(D,M),I?S(I):_(M,b,!0),M=D,I=g(M)):k=!1):I&&(k=!1),k=k!==!1&&Q(M,T),k&&v(M,T)):(K===Te||K==Ae)&&(k=!0,M.nodeValue!==T.nodeValue&&(M.nodeValue=T.nodeValue))),k){T=X,M=z;continue e}I?S(I):_(M,b,!0),M=z}if(J&&(D=s[J])&&Q(D,T))R||d(b,D),v(D,T);else{var ie=A(T);ie!==!1&&(ie&&(T=ie),T.actualize&&(T=T.actualize(b.ownerDocument||P)),d(b,T),F(T))}T=X,M=z}u(b,M,I);var ue=he[b.nodeName];ue&&ue(b,w)}var V=n,U=V.nodeType,B=r.nodeType;if(!y){if(U===G)B===G?Q(n,r)||(a(n),V=et(n,Qe(r.nodeName,r.namespaceURI))):V=r;else if(U===Te||U===Ae){if(B===U)return V.nodeValue!==r.nodeValue&&(V.nodeValue=r.nodeValue),V;V=r}}if(V===r)a(n);else{if(r.isSameNode&&r.isSameNode(V))return;if(v(V,r,y),p)for(var re=0,Oe=p.length;re<Oe;re++){var ne=s[p[re]];ne&&_(ne,ne.parentNode,!1)}}return!y&&V!==n&&n.parentNode&&(V.actualize&&(V=V.actualize(n.ownerDocument||P)),n.parentNode.replaceChild(V,n)),V}}var nt=rt(qe),Ee=nt;var it=220;function at(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:it,easing:"ease-out"}))}function xe(e){let t=e.lastIndexOf("<");return t===-1?e:e.indexOf(">",t)===-1?e.slice(0,t):e}function Me(e,t,n={}){let r=n.fade??!0,i=e.cloneNode(!1);i.innerHTML=t,Ee(e,i,{childrenOnly:!0,onBeforeElUpdated(o,f){return ge(o,f),!o.isEqualNode(f)},onNodeAdded(o){return r&&o.nodeType===Node.ELEMENT_NODE&&at(o),o}})}function ot(e){let t=document.createElement("script");for(let n of Array.from(e.attributes))t.setAttribute(n.name,n.value);return t.textContent=e.textContent??"",t}function st(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 Se(e,t){for(let n of Array.from(e.querySelectorAll("script"))){let r=ot(n),o=r.hasAttribute("src")?st(r):null;n.replaceWith(r);let f=o?await o:null;f&&t?.({src:r.src,message:f})}}function lt(e){return Array.from(e.children).filter(t=>["STYLE","LINK","SCRIPT"].includes(t.tagName)).map(t=>t.outerHTML).join("")}function Re(e){let{root:t}=e,n="",r=!1,i="",o=0,f=new Set;function m(E){for(let h of f)E?.hasAttribute(h)||document.body.removeAttribute(h);f=new Set;for(let h of Array.from(E?.attributes??[]))document.body.setAttribute(h.name,h.value),f.add(h.name)}function g(){let E=r?n:xe(n);if(e.markup==="fragment")return E;if(!E)return m(null),"";let h=new DOMParser().parseFromString(E,"text/html");return m(h.body),lt(h.head)+h.body.innerHTML}function A(){let E=g();E!==i&&(Me(t,E,{fade:!(r&&o===0)}),i=E,o+=1),e.onRender?.()}let x=be(A,e.clock,e.intervalMs);return{append(E){r||typeof E!="string"||E.length===0||(n+=E,x.request())},async complete(){r||(r=!0,x.flushNow(),await Se(t,e.onScriptFailure),e.onComplete?.())},abort(){x.cancel(),n="",i="",o=0,r=!1,t.replaceChildren(),m(null),e.onRender?.()},get completed(){return r}}}function Ve(e,t){if(typeof e!="string"||e.length===0)return"";let n=e.trim();if(n.startsWith("rgb("))return n.replace(/^rgb\\((.*)\\)$/i,`rgba($1, ${t})`);if(n.startsWith("rgba("))return n.replace(/^rgba\\(([^,]+),([^,]+),([^,]+),[^)]+\\)$/i,`rgba($1,$2,$3, ${t})`);if(!n.startsWith("#"))return"";let r=n.slice(1),i=r.length===3?r.split("").map(g=>g+g).join(""):r.length===6?r:"";if(!i)return"";let[o,f,m]=[0,2,4].map(g=>Number.parseInt(i.slice(g,g+2),16));return`rgba(${o}, ${f}, ${m}, ${t})`}function ct(e){let t=e.mode==="dark",n=e.tokens?.surface||(t?"#09090b":"#ffffff"),r=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":n,"--widget-surface-muted":r,"--widget-border":Ve(i,t?.14:.1)||(t?"rgba(255, 255, 255, 0.14)":"rgba(15, 23, 42, 0.1)"),"--widget-text":i,"--widget-text-muted":Ve(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 Le=new Set;function Ce(e){if(!e||e.mode!=="light"&&e.mode!=="dark")return!1;let t=document.documentElement,n={...ct(e),...e.variables};for(let r of Le)r in n||t.style.removeProperty(r);for(let[r,i]of Object.entries(n))t.style.setProperty(r.startsWith("--")?r:`--${r}`,i);return Le=new Set(Object.keys(n)),t.dataset.themeMode=e.mode,t.style.colorScheme=e.mode,!0}var ee,te=["top","right","bottom","left"];function Ne(e){let t={top:0,right:0,bottom:0,left:0};for(let r of te){let i=e?.[r]??0;if(typeof i!="number"||!Number.isFinite(i)||i<0)return null;t[r]=i}for(let r of te)document.documentElement.style.setProperty(`--viewer-safe-area-${r}`,`${t[r]}px`);ee||(ee=document.createElement("style"),document.head.appendChild(ee));let n=te.map(r=>`${t[r]}px`).join(" ");return ee.textContent=te.some(r=>t[r]>0)?`html { box-sizing: border-box !important; padding: ${n} !important; scroll-padding: ${n} !important; }`:"",t}var L={scale:1,x:0,y:0};function Pe(){return L}function Y(e,t){if(!e||typeof e!="object")return;let n=e,r=Number(n.scale),i=Number(n.x),o=Number(n.y);if(!(!Number.isFinite(r)||!Number.isFinite(i)||!Number.isFinite(o))&&(L={scale:r,x:i,y:o},!!t)){if(t.setAttribute("data-viewer-zoom-target",""),r===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(${r})`}}function _e(e){let t=new Map,n=0,r=1,i=null,o=null,f=!1,m=1,g=4,A=a=>Math.min(g,Math.max(m,a)),x=()=>{document.documentElement.style.touchAction=L.scale>m?"none":"pan-x pan-y"},E=a=>{Y(a,e()),x()};function h(){let a=Array.from(t.values());a.length<2||(n=Math.max(Math.hypot(a[1].x-a[0].x,a[1].y-a[0].y),1),r=L.scale,i=null,o=null,f=!0)}document.addEventListener("pointerdown",a=>{a.pointerType==="touch"&&(t.set(a.pointerId,{x:a.clientX,y:a.clientY}),t.size===2?(a.preventDefault(),h()):L.scale>m&&(i={x:a.clientX,y:a.clientY},o={...L},f=!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 l=Array.from(t.values());if(l.length>=2&&n>0){a.preventDefault();let c={x:(l[0].x+l[1].x)/2,y:(l[0].y+l[1].y)/2},d=Math.hypot(l[1].x-l[0].x,l[1].y-l[0].y),y=A(r*(d/n)),s=y/L.scale;E({scale:y,x:c.x-(c.x-L.x)*s,y:c.y-(c.y-L.y)*s});return}if(l.length===1&&L.scale>m&&i&&o){let c=l[0],d=c.x-i.x,y=c.y-i.y;(Math.abs(d)>3||Math.abs(y)>3)&&(f=!0),f&&(a.preventDefault(),E({scale:L.scale,x:o.x+d,y:o.y+y}))}});let N=a=>{if(!(a.pointerType!=="touch"||!t.has(a.pointerId))){if(t.delete(a.pointerId),t.size>=2){h();return}if(t.size===1&&L.scale>m){i=Array.from(t.values())[0],o={...L};return}n=0,i=null,o=null,L.scale-m<.015&&Y({scale:m,x:0,y:0},e()),x()}};document.addEventListener("pointerup",N),document.addEventListener("pointercancel",N),document.addEventListener("wheel",a=>{if(!a.ctrlKey&&!a.metaKey)return;a.preventDefault();let l=A(L.scale*Math.exp(-a.deltaY*.002)),c=l/L.scale;E({scale:l,x:a.clientX-(a.clientX-L.x)*c,y:a.clientY-(a.clientY-L.y)*c})},{passive:!1}),x()}function ut(e){let{channel:t,rootId:n}=e,r=new Set,i=!1,o=0,f=0,m=e.widget?.layout==="inline",g=(u,v)=>window.parent.postMessage({channel:t,type:u,...v},"*"),A=()=>document.getElementById(n),x=()=>A()??document.body;function E(){if(m&&document.body){let v=Math.ceil(document.body.getBoundingClientRect().height);return f=y?.completed?v:Math.max(f,v),f}let u=A();return Math.max(u?Math.ceil(u.getBoundingClientRect().height):0,document.body?.scrollHeight??0,document.body?.offsetHeight??0,document.documentElement?.scrollHeight??0,document.documentElement?.offsetHeight??0)}function h(u){o&&le(o),o=se(()=>{o=0,g("artifact.resize",{height:E(),reason:u})})}function N(u){!u||!Ce(u)||(window.artifactRenderer.themeMode=u.mode,window.artifactRenderer.theme=u,window.dispatchEvent(new CustomEvent("dvina-artifact-renderer:theme",{detail:u})),document.dispatchEvent(new CustomEvent("dvina-artifact-renderer:theme",{detail:u})))}function a(u){let v=Ne(u);v&&(window.artifactRenderer.safeArea=v,window.dispatchEvent(new CustomEvent("dvina-artifact-renderer:safe-area",{detail:v})))}function l(u){window.__artifactRendererData=u,window.dispatchEvent(new CustomEvent("dvina-artifact-renderer:data",{detail:u}));for(let v of r)try{v(u)}catch{}}window.artifactRenderer={version:"0.2.0",themeMode:e.theme.mode,theme:e.theme,getData:()=>window.__artifactRendererData,onData(u){return typeof u!="function"?()=>{}:(r.add(u),()=>r.delete(u))},emit(u,v){typeof u!="string"||u.length===0||g("artifact.event",{name:u,detail:v})},requestResize:()=>h("renderer")};let c=me({channel:t,enabled:e.widget?.bridge!==!1,data:e.widget?.data===!0,pictures:e.widget?.pictures===!0,post:u=>window.parent.postMessage(u,"*")});if(window.sendPrompt=c.prompt.send,window.openLink=c.link.open,window.dvina=c.dvina,c.interceptLinks(),e.widget){let u=ve({call:c.pictures});document.body?u.observe(document.body):document.addEventListener("DOMContentLoaded",()=>u.observe(document.body),{once:!0})}let d=u=>g("artifact.event",{name:"runtime.error",detail:{message:u}}),y=null;function s(){if(y)return y;let u=A();return!e.stream||!u?null:(y=Re({root:u,markup:e.stream,onRender(){Y(Pe(),x()),h("content")},onComplete(){e.widget&&window.__dvinaSvgMenu?.(e.widget.labels),document.dispatchEvent(new Event("DOMContentLoaded",{bubbles:!0})),window.dispatchEvent(new Event("load")),h("content")},onScriptFailure:v=>d(v.message)}),y)}window.addEventListener("message",u=>{let v=u.data;if(!(!v||v.channel!==t||u.source!==window.parent)&&!c.receive(v))switch(v.type){case"artifact.set-safe-area":a(v.safeArea),h("renderer");return;case"artifact.set-theme":N(v.theme),h("renderer");return;case"artifact.update-data":l(v.data);return;case"artifact.set-zoom-transform":Y(v.transform,x());return;case"artifact.stream-append-html":s()?.append(v.html);return;case"artifact.stream-complete":s()?.complete();return;case"artifact.react-module":S(v);return;case"artifact.stream-abort":s()?.abort();return}});let p=!1;async function S(u){let v=A();if(p||!v)return;p=!0;let q={text:document.getElementById("dvina-kit-react")?.textContent??void 0,url:e.kitReactUrl};try{if(u.error||!u.code)throw new Error(u.error||"The widget has no code.");if(!window.__dvinaMountReact)throw new Error("React mode is not loaded in this frame.");await window.__dvinaMountReact(v,u.code,q)}catch(V){let U=V instanceof Error?V.message:String(V),B=document.createElement("p");B.setAttribute("role","alert"),B.className="dvina-widget-error",B.textContent=`This widget could not be shown: ${U}`,v.replaceChildren(B),d(U)}h("content")}function C(){i||(i=!0,g("artifact.ready",{}),h("renderer"),e.initialData!==void 0&&l(e.initialData),e.initialReact&&S(e.initialReact),e.initialHtml!==void 0&&(s()?.append(e.initialHtml),s()?.complete()))}if(window.addEventListener("load",C,{once:!0}),document.readyState==="complete"?C():document.addEventListener("DOMContentLoaded",C,{once:!0}),N(e.theme),a(e.safeArea),_e(x),typeof ResizeObserver=="function"){let u=new ResizeObserver(()=>h("content"));u.observe(document.documentElement),document.body?u.observe(document.body):document.addEventListener("DOMContentLoaded",()=>u.observe(document.body),{once:!0})}window.addEventListener("resize",()=>h("viewport"));let _=0,O=null,F=new WeakMap;document.addEventListener("scroll",u=>{let v=u.target===document?document.scrollingElement||document.documentElement:u.target;if(!v||typeof v.scrollTop!="number")return;let q=F.get(v)??0;F.set(v,v.scrollTop),v.scrollTop!==q&&(O=v.scrollTop,!_&&(_=requestAnimationFrame(()=>{_=0,g("artifact.scroll",{scrollTop:O})})))},{capture:!0,passive:!0}),window.addEventListener("error",u=>d(u.message||"Executable HTML runtime error")),window.addEventListener("unhandledrejection",u=>{let v=u.reason;d(v instanceof Error?v.message:String(v??"Unhandled rejection"))})}window.__dvinaFrame&&ut(window.__dvinaFrame);})();\n';function Mr(){let e=0;const n=new Map;function t(){const r=[];for(;n.has(e);){const a=n.get(e);n.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?[]:(n.set(r.sequence,r.html),t())},reset(){n.clear(),e=0}}}var Pr="dvina-widget";function _r(e){const n=new RegExp(`<meta name="${Pr}" content="(html|react)"`).exec(e.slice(0,4096));return n?n[1]:null}const Nr=1e3,Dr=30,Or=24,zr=1e4,Fr="image.read";function $r(e){const n=e.gapMs??Nr,t=new Map,r={data:[],pictures:[]};return function(o,i){if(!Bt(o))return{ok:!1,error:{code:"invalid-params",message:`Unknown method ${String(o)}.`}};if(!Wt(o,i))return{ok:!1,error:{code:"invalid-params",message:`Invalid params for ${o}.`}};if(Fn.includes(o)){if(!e.isUserActive())return{ok:!1,error:{code:"user-activation-required",message:`${o} needs a click or key press first.`}};const l=e.now();if(l-(t.get(o)??Number.NEGATIVE_INFINITY)<n)return{ok:!1,error:{code:"rate-limited",message:`${o} was asked too soon again.`}};t.set(o,l)}if(o==="dvina/call"){const l=i.name===Fr?"pictures":"data",s=l==="pictures"?Or:Dr,c=e.now();if(r[l]=r[l].filter(p=>c-p<zr),r[l].length>=s)return{ok:!1,error:{code:"rate-limited",message:"Too many host calls; wait a moment."}};r[l].push(c)}return{ok:!0,method:o,params:i}}}function Vr(){var e;return((e=navigator.userActivation)==null?void 0:e.isActive)??!1}const q="dvina-artifact-renderer-html",Be="dvina-viewer:artifact-scroll",Qe="dvina-artifact-renderer-stream-root",Ur=["allow-downloads","allow-forms","allow-same-origin","allow-scripts"];function qr(e){if(typeof e!="object"||e===null)return!1;const n=e;return n.channel===q&&n.jsonrpc==="2.0"&&typeof n.id=="string"&&"method"in n}function Hr(e){const n=e.params;return e.method==="dvina/call"&&(n==null?void 0:n.name)==="image.read"}function xe(e){return e.replaceAll("&","&").replaceAll('"',""").replaceAll("<","<").replaceAll(">",">")}function Br(e){var n,t,r,a;return[e.mode,((n=e.tokens)==null?void 0:n.surface)??"",((t=e.tokens)==null?void 0:t.surfaceMuted)??"",((r=e.tokens)==null?void 0:r.text)??"",((a=e.tokens)==null?void 0:a.accent)??"",JSON.stringify(e.variables??{})].join(":")}function We(e){return e===null||typeof e=="string"||typeof e=="boolean"?!0:typeof e=="number"?Number.isFinite(e):Array.isArray(e)?e.every(We):typeof e!="object"||e===null?!1:Object.values(e).every(We)}function Wr(e){if(typeof e!="object"||e===null)return!1;const n=e;return n.channel!==q?!1:n.type==="artifact.ready"||n.type==="artifact.scroll"&&typeof n.scrollTop=="number"&&Number.isFinite(n.scrollTop)||n.type==="artifact.resize"&&typeof n.height=="number"&&(n.reason==="content"||n.reason==="viewport"||n.reason==="renderer")?!0:n.type==="artifact.event"&&(n.name===void 0||typeof n.name=="string")&&(n.detail===void 0||We(n.detail))}function fe(e){return e.replace(/<\/script/gi,"<\\/script").replace(/<!--/g,"<\\!--")}function Ne(e){return e.replace(/<\/style/gi,"<\\/style")}function Me(e){const n={channel:q,rootId:Qe,...e};return`<script>window.__dvinaFrame=${fe(JSON.stringify(n))};<\/script><script>${fe(jr)}<\/script>`}function Gr(e,n,t,r,a={}){const o=`<base href="${xe(n)}"><style>html, body { margin: 0; padding: 0; background: transparent; }</style>${Me({initialData:t,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 Kr(e,n,t={}){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>${Me({initialData:e,theme:n,safeArea:t,stream:"document"})}</head><body><div id="${Qe}"></div></body></html>`}function Xr(e,n,t,r,a={}){const o=n.layout??"panel",i=de,l=f=>xe(He(f)),s=f=>i.inline?`<script>${fe(f)}<\/script>`:`<script src="${l(f)}"><\/script>`,c=Me({initialData:t,theme:r,safeArea:a,widget:{layout:o,bridge:n.bridge!==!1,labels:n.labels,data:n.data===!0,pictures:n.pictures??n.bridge!==!1}}),p=`<meta http-equiv="Content-Security-Policy" content="${xe(Yt())}" /><style>${Zt[o]}</style>${c}${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 kt(e,n,t,r={},a,o){const i=e.layout??"inline",l=e.kind==="react",s=e.kit===void 0?void 0:e.kit||{},c=de,p=Me({initialData:n,theme:t,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||c.inline?void 0:He(c.kitReactScript)}),u=s??(c.inline?{css:c.kitCss,script:c.kitScript,reactScript:c.kitReactScript}:null),f=w=>xe(He(w)),g=u?u.css?`<style id="dvina-kit">${Ne(u.css)}</style>`:"":`<link rel="stylesheet" id="dvina-kit" href="${f(c.kitCss)}" />`,m=u?u.script?`<script id="dvina-kit-script">${fe(u.script)}<\/script>`:"":`<script id="dvina-kit-script" src="${f(c.kitScript)}"><\/script>`,y=w=>c.inline?`<script>${fe(w)}<\/script>`:`<script src="${f(w)}"><\/script>`,E=`<style type="text/tailwindcss" id="dvina-tailwind">${Ne(c.tailwindCss)}</style>${y(c.tailwindScript)}`,b=l?`${E}${y(c.reactLoader)}${u!=null&&u.reactScript?`<script type="text/plain" id="dvina-kit-react">${fe(u.reactScript)}<\/script>`:""}`:"",S=`<style id="dvina-tokens">${Ne(c.tokensCss)}</style>`;return`<!doctype html><html data-widget-layout="${i}" data-theme-mode="${t.mode}"><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><meta http-equiv="Content-Security-Policy" content="${xe(Yt())}" /><style>${Zt[i]}</style>${S}${g}${p}${y(c.svgMenu)}${m}${b}</head><body><div id="${Qe}"></div></body></html>`}function Yr(e,n,t){return!Number.isFinite(e)||e<=0?n:t?Math.max(n,Math.ceil(e)):Math.ceil(e)}function Zr({label:e}){return v.jsxs("div",{className:"document-loading",children:[v.jsx("div",{className:"document-spinner"}),v.jsx("p",{children:e})]})}function Jr({title:e,message:n}){return v.jsxs("div",{className:"document-empty-state",children:[v.jsx("h3",{children:e}),v.jsx("p",{children:n})]})}function Qr({document:e,session:n,theme:t,safeArea:r,artifactDataMessage:a,streamCommandMessage:o,onLoaded:i,onError:l,onTelemetry:s,onResize:c,onArtifactEvent:p,onWidgetRequest:u,widgetResponseMessage:f}){var ot,st,lt,ct,ut,dt,ft,pt,mt,ht,gt;const g=h.useMemo(()=>Xt(e,n),[e,n]),m=h.useRef(null),y=h.useRef(!1),E=h.useRef(!1),b=h.useRef(t),S=h.useRef(r),w=h.useRef({chunks:[],completed:!1}),F=h.useRef((st=(ot=e.renderOptions)==null?void 0:ot.html)==null?void 0:st.artifactData),L=h.useRef([]),z=h.useRef(Mr()),[V,k]=h.useState({status:"loading"}),A=h.useRef(0),d=h.useRef(0);b.current=t,S.current=r;const D=h.useMemo(()=>Br(t),[t]),P=e.format==="widget",j=(lt=e.renderOptions)==null?void 0:lt.widget,W=P?j==null?void 0:j.artifactData:(ut=(ct=e.renderOptions)==null?void 0:ct.html)==null?void 0:ut.artifactData,G=Ie(e.format)&&e.source.kind==="stream",J=P&&(j==null?void 0:j.kind)==="react",oe=h.useMemo(()=>{var $,U;const C=(P?j==null?void 0:j.revisionId:(U=($=e.renderOptions)==null?void 0:$.html)==null?void 0:U.revisionId)??"live",I=(g==null?void 0:g.url)??e.id;return`${e.id}:${C}:${I}`},[e.id,(ft=(dt=e.renderOptions)==null?void 0:dt.html)==null?void 0:ft.revisionId,P,j==null?void 0:j.revisionId,g==null?void 0:g.url]),R=oe,M=h.useMemo(()=>{var $,U;const C=(U=($=e.renderOptions)==null?void 0:$.html)==null?void 0:U.sandbox,I=P?Rr:C&&C.length>0?C:Ur;return Array.from(new Set(I)).join(" ")},[P,(mt=(pt=e.renderOptions)==null?void 0:pt.html)==null?void 0:mt.sandbox]),_=()=>{var C;if(!(!E.current||!((C=m.current)!=null&&C.contentWindow))){for(const I of L.current)m.current.contentWindow.postMessage(I,"*");L.current=[]}},x=C=>{var I;if(!E.current||!((I=m.current)!=null&&I.contentWindow)){L.current.push(C);return}m.current.contentWindow.postMessage(C,"*")},Y=()=>{L.current=L.current.filter(C=>{const I=C;return I.type!=="artifact.stream-append-html"&&I.type!=="artifact.stream-complete"&&I.type!=="artifact.stream-abort"})};h.useEffect(()=>{const C=m.current;if(!C)return;const I=$=>{const U=$.detail;x({channel:q,type:"artifact.set-zoom-transform",transform:U})};return C.addEventListener("viewer-zoom-transform",I),()=>C.removeEventListener("viewer-zoom-transform",I)},[R,V.status]),h.useEffect(()=>{F.current=W,O.current=null,d.current=0,z.current.reset(),w.current={chunks:[],completed:!1}},[oe,W]),h.useEffect(()=>{y.current=!1,E.current=!1,L.current=[],A.current=0},[R]);const O=h.useRef(null),H=async()=>{O.current??(O.current=wt(w.current.chunks.map(I=>I.html).join("")));const C=await O.current;x({channel:q,type:"artifact.react-module",...C})},Ae=()=>{if(G){if(J){w.current.completed&&H();return}for(const C of w.current.chunks)x({channel:q,type:"artifact.stream-append-html",html:C.html,sequence:C.sequence});w.current.completed&&x({channel:q,type:"artifact.stream-complete"})}};h.useEffect(()=>{var $,U;if(G&&P){let K=!0;return yt().then(()=>{K&&k({status:"srcdoc",markup:kt(j??{},W,b.current,S.current)})}),s==null||s("info","html.render.mode","Widget stream shell mounted.",{documentId:e.id,mode:"widget-stream-shell"}),()=>{K=!1}}if(G){k({status:"srcdoc",markup:Kr(W,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){k({status:"error",message:"The HTML artifact does not expose a preview-safe URL."});return}const C=new AbortController,I=P||((U=($=e.renderOptions)==null?void 0:$.html)==null?void 0:U.bootstrap)!=="off";return k({status:"loading"}),!I&&e.source.kind==="url"?(k({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 K=>{var vt,bt;if(!K.ok)throw new Error(`Request failed with status ${K.status}`);const le=await K.text();P&&await yt(),k({status:"srcdoc",markup:P&&_r(le)?Xr(le,j??{},W,b.current,S.current):P?kt(j??{},W,b.current,S.current,J?void 0:le,J?await wt(le):void 0):I?Gr(le,g.url,(bt=(vt=e.renderOptions)==null?void 0:vt.html)==null?void 0:bt.artifactData,b.current,S.current):le}),s==null||s("info","html.render.mode",I?"HTML artifact is loading through sandboxed srcdoc bootstrap.":"HTML artifact is loading through sandboxed srcdoc without bootstrap.",{documentId:e.id,mode:I?"srcdoc-bootstrap":"srcdoc"})}).catch(K=>{if(!C.signal.aborted){if(e.source.kind==="url"&&!P){k({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:K instanceof Error?K.message:"Unknown fetch failure"});return}k({status:"error",message:K instanceof Error?K.message:"Unknown HTML fetch failure"})}}),()=>C.abort())},[e,G,s,g]),h.useEffect(()=>{x({channel:q,type:"artifact.set-theme",theme:t})},[D]),h.useEffect(()=>{E.current&&x({channel:q,type:"artifact.set-safe-area",safeArea:r??{}})},[r]),h.useEffect(()=>{a&&(F.current=a.data,x({channel:q,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),!!G){for(const I of C.slice(d.current))he(I);d.current=C.length}},[G,o==null?void 0:o.nonce]);function he(C){if(C.type==="append"){const I=z.current.push({html:C.html,sequence:C.sequence});for(const $ of I)w.current.chunks.push($),!J&&x({channel:q,type:"artifact.stream-append-html",html:$.html,sequence:$.sequence});return}if(C.type==="abort"){z.current.reset(),w.current={chunks:[],completed:!1},x({channel:q,type:"artifact.stream-abort",reason:C.reason});return}if(w.current.completed=!0,J){H();return}x({channel:q,type:"artifact.stream-complete"})}const Cn=h.useRef($r({isUserActive:Vr,now:()=>performance.now()})),Pe=h.useRef(new Map),Rn=h.useRef(0),Se=(C,I)=>{var $,U;(U=($=m.current)==null?void 0:$.contentWindow)==null||U.postMessage({channel:q,jsonrpc:"2.0",id:C,...I},"*")},In=C=>{if(P&&(j==null?void 0:j.bridge)===!1&&!(j.pictures&&Hr(C))){Se(C.id,{error:{code:"bridge-off",message:"The widget bridge is off."}});return}const I=Cn.current(C.method,C.params);if(!I.ok){Se(C.id,{error:I.error});return}if(!u){Se(C.id,{error:{code:"no-handler",message:"The host takes no widget requests."}});return}const $=`${e.id}:${++Rn.current}`;Pe.current.set($,C.id),u({requestId:$,method:I.method,params:I.params})},Le=h.useRef(0);if(h.useEffect(()=>{const C=(f==null?void 0:f.payloads)??[];C.length<Le.current&&(Le.current=0);for(const{requestId:I,result:$,error:U}of C.slice(Le.current)){const K=Pe.current.get(I);K!==void 0&&(Pe.current.delete(I),Se(K,U?{error:U}:{result:$??null}))}Le.current=C.length},[f==null?void 0:f.nonce]),h.useEffect(()=>{const C=I=>{var $;if(I.source===(($=m.current)==null?void 0:$.contentWindow)){if(qr(I.data)){In(I.data);return}if(Wr(I.data)){if(I.data.type==="artifact.ready"){E.current=!0,F.current!==void 0&&x({channel:q,type:"artifact.update-data",data:F.current}),Y(),_(),x({channel:q,type:"artifact.set-safe-area",safeArea:S.current??{}}),Ae(),s==null||s("info","html.artifact.ready","Executable HTML artifact announced readiness.",{documentId:e.id});return}if(I.data.type==="artifact.resize"){const U=Yr(I.data.height,A.current,G&&!P);if(U<=0)return;A.current=U,c==null||c(U,I.data.reason);return}if(I.data.type==="artifact.scroll"){window.dispatchEvent(new CustomEvent(Be,{detail:{scrollTop:I.data.scrollTop}}));return}I.data.type==="artifact.event"&&I.data.name&&(p==null||p(I.data.name,I.data.detail))}}};return window.addEventListener("message",C),()=>window.removeEventListener("message",C)},[e.id,G,p,c,s,u,R,j==null?void 0:j.bridge]),h.useEffect(()=>{V.status==="error"&&l("document-fetch-failed",V.message,!0)},[l,V]),V.status==="loading")return P&&((j==null?void 0:j.layout)??"inline")==="inline"?null:v.jsx(Zr,{label:"Preparing executable HTML artifact"});if(V.status==="error")return v.jsx(Jr,{title:"HTML preview unavailable",message:V.message});const at={ref:m,key:R,className:"document-html-frame",style:{colorScheme:t.mode},allow:"clipboard-write","data-viewer-zoom-target":"","data-viewer-zoom-bridge":"html",title:e.name,sandbox:M,onLoad:()=>{y.current||(y.current=!0,i())},onError:()=>{l("renderer-failed","The executable HTML iframe could not be mounted.",!0)}};return v.jsx("div",{className:"document-html-shell","data-safe-area-fallback":!M.split(" ").includes("allow-scripts")||V.status==="url"||!G&&((gt=(ht=e.renderOptions)==null?void 0:ht.html)==null?void 0:gt.bootstrap)==="off",children:V.status==="srcdoc"?v.jsx("iframe",{...at,srcDoc:V.markup}):v.jsx("iframe",{...at,src:V.url})})}const Et=48;function ei({distance:e=Et,onProgress:n,requestFrame:t=a=>window.requestAnimationFrame(a),cancelFrame:r=a=>window.cancelAnimationFrame(a)}){let a=e,o=null,i=0,l=0;const s=new WeakMap;function c(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=c(o);o=null,g!==l&&(l=g,n(g))}function u(g){Number.isFinite(g)&&(o=g,i||(i=t(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 y=s.get(m.key)??0;s.set(m.key,m.top),m.top!==y&&u(m.top)},report:u,reset(){o=null,i&&r(i),i=0,l!==0&&(l=0,n(0))},setDistance(g){a=g!==void 0&&Number.isFinite(g)&&g>0?g:Et},dispose(){i&&r(i),i=0,o=null}}}const Q=1,ti=4,ni=.015,At=3;function St(e){return Math.min(ti,Math.max(Q,e))}function ri(e,n){return{x:(e.x+n.x)/2,y:(e.y+n.y)/2}}function Lt(e,n){return Math.hypot(n.x-e.x,n.y-e.y)}function ii(e){const n=e.querySelector("[data-viewer-zoom-target]");return n?n.dataset.viewerZoomBridge==="html"?{kind:"bridge",element:n}:{kind:"element",element:n}:null}function ai(e,n){if(e.kind==="bridge"){e.element.dispatchEvent(new CustomEvent("viewer-zoom-transform",{detail:n}));return}e.element.style.transformOrigin="0 0",e.element.style.willChange="transform",e.element.style.transform=`translate3d(${n.x}px, ${n.y}px, 0) scale(${n.scale})`}function Ct(e){if(e.kind==="bridge"){e.element.dispatchEvent(new CustomEvent("viewer-zoom-transform",{detail:{scale:Q,x:0,y:0}}));return}e.element.style.removeProperty("transform"),e.element.style.removeProperty("transform-origin"),e.element.style.removeProperty("will-change")}function oi(e,n){h.useEffect(()=>{const t=e.current;if(!t||!n)return;const r=new Map;let a=null,o=null,i={scale:Q,x:0,y:0},l=0,s=Q,c=null,p=null,u=!1,f=0;const g=()=>{t.style.touchAction=i.scale>Q?"none":"pan-x pan-y"},m=()=>{if(a??(a=ii(t)),a&&!o){const k=t.getBoundingClientRect(),A=a.element.getBoundingClientRect();o={x:A.left-k.left,y:A.top-k.top}}return a},y=k=>{const A=t.getBoundingClientRect();return{x:k.clientX-A.left,y:k.clientY-A.top}},E=()=>(m(),o??{x:0,y:0}),b=()=>{f=0;const k=m();k&&ai(k,i)},S=k=>{i=k,g(),f||(f=requestAnimationFrame(b))},w=()=>{const k=Array.from(r.values());k.length<2||!m()||(l=Math.max(Lt(k[0],k[1]),1),s=i.scale,c=null,p=null,u=!0)},F=k=>{var A;if(k.pointerType==="touch"){if(r.set(k.pointerId,y(k)),r.size===2){m(),k.preventDefault(),(A=t.setPointerCapture)==null||A.call(t,k.pointerId),w();return}r.size===1&&i.scale>Q&&m()&&(c=y(k),p={...i},u=!1)}},L=k=>{if(k.pointerType!=="touch"||!r.has(k.pointerId))return;r.set(k.pointerId,y(k));const A=Array.from(r.values());if(A.length>=2&&l>0){k.preventDefault();const d=ri(A[0],A[1]),D=St(s*(Lt(A[0],A[1])/l)),P=D/i.scale,j=E();S({scale:D,x:d.x-j.x-(d.x-j.x-i.x)*P,y:d.y-j.y-(d.y-j.y-i.y)*P});return}if(A.length===1&&i.scale>Q&&c&&p){const d=A[0],D=d.x-c.x,P=d.y-c.y;(Math.abs(D)>At||Math.abs(P)>At)&&(u=!0),u&&(k.preventDefault(),S({scale:i.scale,x:p.x+D,y:p.y+P}))}},z=k=>{var A;if(!(k.pointerType!=="touch"||!r.has(k.pointerId))){if(r.delete(k.pointerId),(A=t.releasePointerCapture)==null||A.call(t,k.pointerId),r.size>=2){w();return}if(r.size===1&&i.scale>Q){c=Array.from(r.values())[0],p={...i};return}l=0,c=null,p=null,i.scale-Q<ni&&(f&&(cancelAnimationFrame(f),f=0),i={scale:Q,x:0,y:0},a&&Ct(a)),g()}},V=k=>{if(!k.ctrlKey&&!k.metaKey||!m())return;k.preventDefault();const A=y(k),d=St(i.scale*Math.exp(-k.deltaY*.002)),D=d/i.scale,P=E();S({scale:d,x:A.x-P.x-(A.x-P.x-i.x)*D,y:A.y-P.y-(A.y-P.y-i.y)*D})};return g(),t.addEventListener("pointerdown",F),t.addEventListener("pointermove",L),t.addEventListener("pointerup",z),t.addEventListener("pointercancel",z),t.addEventListener("wheel",V,{passive:!1}),()=>{f&&cancelAnimationFrame(f),t.removeEventListener("pointerdown",F),t.removeEventListener("pointermove",L),t.removeEventListener("pointerup",z),t.removeEventListener("pointercancel",z),t.removeEventListener("wheel",V),t.style.removeProperty("touch-action"),a&&Ct(a)}},[e,n])}const si={json:"json",jsonl:"json",ndjson:"json",yaml:"yaml",tsv:"tsv",xml:"xml",toml:"toml",ini:"ini",dotenv:"dotenv"},li=new Set(["code","json","jsonl","ndjson","yaml","tsv","xml","toml","ini","dotenv"]),ci={".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"},Rt={"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"},It={dockerfile:"docker",makefile:"make"};let De,Oe;function ui(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}function di(e){return`<pre class="code-preview-fallback"><code>${ui(e)}</code></pre>`}function fi(e){const t=e.toLowerCase().match(/(\.[a-z0-9]+)$/);return(t==null?void 0:t[1])??null}function Jt(e){var i,l,s,c;const n=(l=(i=e.renderOptions)==null?void 0:i.codeLanguage)==null?void 0:l.trim();if(n)return n;const t=si[e.format];if(t)return t;const r=(c=(s=e.mimeType)==null?void 0:s.toLowerCase().split(";")[0])==null?void 0:c.trim();if(r&&Rt[r])return Rt[r];const a=e.name.toLowerCase();if(It[a])return It[a];const o=fi(e.name);return o?ci[o]:void 0}function Tt(e){return li.has(e.format)||e.format==="text"&&!!Jt(e)}async function Qt(){return De||(De=ae(()=>import("./index-DRpEhT3s.js"),__vite__mapDeps([0,1]))),De}async function pi(){return Oe||(Oe=Qt().then(e=>{const n=new Map;for(const t of e.bundledLanguagesInfo){n.set(t.id.toLowerCase(),{id:t.id,name:t.name});for(const r of t.aliases??[])n.set(r.toLowerCase(),{id:t.id,name:t.name})}return n})),Oe}async function mi(e,n,t="light"){const[r,a]=await Promise.all([Qt(),pi()]),o=n==null?void 0:n.trim().toLowerCase(),i=o?a.get(o):void 0;return i?{html:await r.codeToHtml(e,{lang:i.id,theme:t==="dark"?"houston":"light-plus"}),languageLabel:i.name,highlighted:!0,canonicalLanguage:i.id}:{html:di(e),languageLabel:(n==null?void 0:n.trim())||"Plain text",highlighted:!1,canonicalLanguage:void 0}}function en({source:e,title:n,languageHint:t,themeMode:r,onRendered:a,onError:o,onTelemetry:i}){const[l,s]=h.useState({status:"loading"}),c=h.useMemo(()=>e.replace(/\r\n/g,`
|
|
145
|
-
`),[e]),p=h.useMemo(()=>c.split(`
|
|
146
|
-
`).length,[c]);return h.useEffect(()=>{if(!c.trim()){const f="The code document is empty.";s({status:"error",error:f}),i==null||i("warn","code-preview.skipped",f,{languageHint:t??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:t??null,lineCount:p}),mi(c,t,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:t??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:t??null}),o==null||o(g)}),()=>{u=!0}},[t,p,c,o,a,i,r]),l.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..."})]}):l.status==="error"?v.jsxs("div",{className:"code-preview-shell code-preview-error",role:"status",children:[v.jsx("p",{children:l.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:l.html}})})}function jt(e,n){const t=String(e);if(typeof n!="string")throw new TypeError("Expected character");let r=0,a=t.indexOf(n);for(;a!==-1;)r++,a=t.indexOf(n,a+n.length);return r}function hi(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function gi(e,n,t){const a=Ft((t||{}).ignore||[]),o=vi(n);let i=-1;for(;++i<o.length;)Tn(e,"text",l);function l(c,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(c,p)}function s(c,p){const u=p[p.length-1],f=o[i][0],g=o[i][1];let m=0;const E=u.children.indexOf(c);let b=!1,S=[];f.lastIndex=0;let w=f.exec(c.value);for(;w;){const F=w.index,L={index:w.index,input:w.input,stack:[...p,c]};let z=g(...w,L);if(typeof z=="string"&&(z=z.length>0?{type:"text",value:z}:void 0),z===!1?f.lastIndex=F+1:(m!==F&&S.push({type:"text",value:c.value.slice(m,F)}),Array.isArray(z)?S.push(...z):z&&S.push(z),m=F+w[0].length,b=!0),!f.global)break;w=f.exec(c.value)}return b?(m<c.value.length&&S.push({type:"text",value:c.value.slice(m)}),u.children.splice(E,1,...S)):S=[c],E+S.length}}function vi(e){const n=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const t=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<t.length;){const a=t[r];n.push([bi(a[0]),wi(a[1])])}return n}function bi(e){return typeof e=="string"?new RegExp(hi(e),"g"):e}function wi(e){return typeof e=="function"?e:function(){return e}}const ze="phrasing",Fe=["autolink","link","image","label"];function xi(){return{transforms:[Ci],enter:{literalAutolink:ki,literalAutolinkEmail:$e,literalAutolinkHttp:$e,literalAutolinkWww:$e},exit:{literalAutolink:Li,literalAutolinkEmail:Si,literalAutolinkHttp:Ei,literalAutolinkWww:Ai}}}function yi(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:ze,notInConstruct:Fe},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:ze,notInConstruct:Fe},{character:":",before:"[ps]",after:"\\/",inConstruct:ze,notInConstruct:Fe}]}}function ki(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function $e(e){this.config.enter.autolinkProtocol.call(this,e)}function Ei(e){this.config.exit.autolinkProtocol.call(this,e)}function Ai(e){this.config.exit.data.call(this,e);const n=this.stack[this.stack.length-1];me(n.type==="link"),n.url="http://"+this.sliceSerialize(e)}function Si(e){this.config.exit.autolinkEmail.call(this,e)}function Li(e){this.exit(e)}function Ci(e){gi(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Ri],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),Ii]],{ignore:["link","linkReference"]})}function Ri(e,n,t,r,a){let o="";if(!tn(a)||(/^w/i.test(n)&&(t=n+t,n="",o="http://"),!Ti(t)))return!1;const i=ji(t+r);if(!i[0])return!1;const l={type:"link",title:null,url:o+n+i[0],children:[{type:"text",value:n+i[0]}]};return i[1]?[l,{type:"text",value:i[1]}]:l}function Ii(e,n,t,r){return!tn(r,!0)||/[-\d_]$/.test(t)?!1:{type:"link",title:null,url:"mailto:"+n+"@"+t,children:[{type:"text",value:n+"@"+t}]}}function Ti(e){const n=e.split(".");return!(n.length<2||n[n.length-1]&&(/_/.test(n[n.length-1])||!/[a-zA-Z\d]/.test(n[n.length-1]))||n[n.length-2]&&(/_/.test(n[n.length-2])||!/[a-zA-Z\d]/.test(n[n.length-2])))}function ji(e){const n=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!n)return[e,void 0];e=e.slice(0,n.index);let t=n[0],r=t.indexOf(")");const a=jt(e,"(");let o=jt(e,")");for(;r!==-1&&a>o;)e+=t.slice(0,r+1),t=t.slice(r+1),r=t.indexOf(")"),o++;return[e,t]}function tn(e,n){const t=e.input.charCodeAt(e.index-1);return(e.index===0||pe(t)||Xe(t))&&(!n||t!==47)}nn.peek=$i;function Mi(){this.buffer()}function Pi(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function _i(){this.buffer()}function Ni(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Di(e){const n=this.resume(),t=this.stack[this.stack.length-1];me(t.type==="footnoteReference"),t.identifier=ke(this.sliceSerialize(e)).toLowerCase(),t.label=n}function Oi(e){this.exit(e)}function zi(e){const n=this.resume(),t=this.stack[this.stack.length-1];me(t.type==="footnoteDefinition"),t.identifier=ke(this.sliceSerialize(e)).toLowerCase(),t.label=n}function Fi(e){this.exit(e)}function $i(){return"["}function nn(e,n,t,r){const a=t.createTracker(r);let o=a.move("[^");const i=t.enter("footnoteReference"),l=t.enter("reference");return o+=a.move(t.safe(t.associationId(e),{after:"]",before:o})),l(),i(),o+=a.move("]"),o}function Vi(){return{enter:{gfmFootnoteCallString:Mi,gfmFootnoteCall:Pi,gfmFootnoteDefinitionLabelString:_i,gfmFootnoteDefinition:Ni},exit:{gfmFootnoteCallString:Di,gfmFootnoteCall:Oi,gfmFootnoteDefinitionLabelString:zi,gfmFootnoteDefinition:Fi}}}function Ui(e){let n=!1;return e&&e.firstLineBlank&&(n=!0),{handlers:{footnoteDefinition:t,footnoteReference:nn},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function t(r,a,o,i){const l=o.createTracker(i);let s=l.move("[^");const c=o.enter("footnoteDefinition"),p=o.enter("label");return s+=l.move(o.safe(o.associationId(r),{before:s,after:"]"})),p(),s+=l.move("]:"),r.children&&r.children.length>0&&(l.shift(4),s+=l.move((n?`
|
|
147
|
-
`:" ")+o.indentLines(o.containerFlow(r,l.current()),n?rn:qi))),c(),s}}function qi(e,n,t){return n===0?e:rn(e,n,t)}function rn(e,n,t){return(t?"":" ")+e}const Hi=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];an.peek=Xi;function Bi(){return{canContainEols:["delete"],enter:{strikethrough:Gi},exit:{strikethrough:Ki}}}function Wi(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Hi}],handlers:{delete:an}}}function Gi(e){this.enter({type:"delete",children:[]},e)}function Ki(e){this.exit(e)}function an(e,n,t,r){const a=t.createTracker(r),o=t.enter("strikethrough");let i=a.move("~~");return i+=t.containerPhrasing(e,{...a.current(),before:i,after:"~"}),i+=a.move("~~"),o(),i}function Xi(){return"~"}function Yi(e){return e.length}function Zi(e,n){const t=n||{},r=(t.align||[]).concat(),a=t.stringLength||Yi,o=[],i=[],l=[],s=[];let c=0,p=-1;for(;++p<e.length;){const y=[],E=[];let b=-1;for(e[p].length>c&&(c=e[p].length);++b<e[p].length;){const S=Ji(e[p][b]);if(t.alignDelimiters!==!1){const w=a(S);E[b]=w,(s[b]===void 0||w>s[b])&&(s[b]=w)}y.push(S)}i[p]=y,l[p]=E}let u=-1;if(typeof r=="object"&&"length"in r)for(;++u<c;)o[u]=Mt(r[u]);else{const y=Mt(r);for(;++u<c;)o[u]=y}u=-1;const f=[],g=[];for(;++u<c;){const y=o[u];let E="",b="";y===99?(E=":",b=":"):y===108?E=":":y===114&&(b=":");let S=t.alignDelimiters===!1?1:Math.max(1,s[u]-E.length-b.length);const w=E+"-".repeat(S)+b;t.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),l.splice(1,0,g),p=-1;const m=[];for(;++p<i.length;){const y=i[p],E=l[p];u=-1;const b=[];for(;++u<c;){const S=y[u]||"";let w="",F="";if(t.alignDelimiters!==!1){const L=s[u]-(E[u]||0),z=o[u];z===114?w=" ".repeat(L):z===99?L%2?(w=" ".repeat(L/2+.5),F=" ".repeat(L/2-.5)):(w=" ".repeat(L/2),F=w):F=" ".repeat(L)}t.delimiterStart!==!1&&!u&&b.push("|"),t.padding!==!1&&!(t.alignDelimiters===!1&&S==="")&&(t.delimiterStart!==!1||u)&&b.push(" "),t.alignDelimiters!==!1&&b.push(w),b.push(S),t.alignDelimiters!==!1&&b.push(F),t.padding!==!1&&b.push(" "),(t.delimiterEnd!==!1||u!==c-1)&&b.push("|")}m.push(t.delimiterEnd===!1?b.join("").replace(/ +$/,""):b.join(""))}return m.join(`
|
|
148
|
-
`)}function Ji(e){return e==null?"":String(e)}function Mt(e){const n=typeof e=="string"?e.codePointAt(0):0;return n===67||n===99?99:n===76||n===108?108:n===82||n===114?114:0}function Qi(e,n,t,r){const a=t.enter("blockquote"),o=t.createTracker(r);o.move("> "),o.shift(2);const i=t.indentLines(t.containerFlow(e,o.current()),ea);return a(),i}function ea(e,n,t){return">"+(t?"":" ")+e}function ta(e,n){return Pt(e,n.inConstruct,!0)&&!Pt(e,n.notInConstruct,!1)}function Pt(e,n,t){if(typeof n=="string"&&(n=[n]),!n||n.length===0)return t;let r=-1;for(;++r<n.length;)if(e.includes(n[r]))return!0;return!1}function _t(e,n,t,r){let a=-1;for(;++a<t.unsafe.length;)if(t.unsafe[a].character===`
|
|
149
|
-
`&&ta(t.stack,t.unsafe[a]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
150
|
-
`}function na(e,n){const t=String(e);let r=t.indexOf(n),a=r,o=0,i=0;if(typeof n!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===a?++o>i&&(i=o):o=1,a=r+n.length,r=t.indexOf(n,a);return i}function ra(e,n){return!!(n.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function ia(e){const n=e.options.fence||"`";if(n!=="`"&&n!=="~")throw new Error("Cannot serialize code with `"+n+"` for `options.fence`, expected `` ` `` or `~`");return n}function aa(e,n,t,r){const a=ia(t),o=e.value||"",i=a==="`"?"GraveAccent":"Tilde";if(ra(e,t)){const u=t.enter("codeIndented"),f=t.indentLines(o,oa);return u(),f}const l=t.createTracker(r),s=a.repeat(Math.max(na(o,a)+1,3)),c=t.enter("codeFenced");let p=l.move(s);if(e.lang){const u=t.enter(`codeFencedLang${i}`);p+=l.move(t.safe(e.lang,{before:p,after:" ",encode:["`"],...l.current()})),u()}if(e.lang&&e.meta){const u=t.enter(`codeFencedMeta${i}`);p+=l.move(" "),p+=l.move(t.safe(e.meta,{before:p,after:`
|
|
151
|
-
`,encode:["`"],...l.current()})),u()}return p+=l.move(`
|
|
152
|
-
`),o&&(p+=l.move(o+`
|
|
153
|
-
`)),p+=l.move(s),c(),p}function oa(e,n,t){return(t?"":" ")+e}function et(e){const n=e.options.quote||'"';if(n!=='"'&&n!=="'")throw new Error("Cannot serialize title with `"+n+"` for `options.quote`, expected `\"`, or `'`");return n}function sa(e,n,t,r){const a=et(t),o=a==='"'?"Quote":"Apostrophe",i=t.enter("definition");let l=t.enter("label");const s=t.createTracker(r);let c=s.move("[");return c+=s.move(t.safe(t.associationId(e),{before:c,after:"]",...s.current()})),c+=s.move("]: "),l(),!e.url||/[\0- \u007F]/.test(e.url)?(l=t.enter("destinationLiteral"),c+=s.move("<"),c+=s.move(t.safe(e.url,{before:c,after:">",...s.current()})),c+=s.move(">")):(l=t.enter("destinationRaw"),c+=s.move(t.safe(e.url,{before:c,after:e.title?" ":`
|
|
154
|
-
`,...s.current()}))),l(),e.title&&(l=t.enter(`title${o}`),c+=s.move(" "+a),c+=s.move(t.safe(e.title,{before:c,after:a,...s.current()})),c+=s.move(a),l()),i(),c}function la(e){const n=e.options.emphasis||"*";if(n!=="*"&&n!=="_")throw new Error("Cannot serialize emphasis with `"+n+"` for `options.emphasis`, expected `*`, or `_`");return n}function ye(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Te(e,n,t){const r=Re(e),a=Re(n);return r===void 0?a===void 0?t==="_"?{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}}on.peek=ca;function on(e,n,t,r){const a=la(t),o=t.enter("emphasis"),i=t.createTracker(r),l=i.move(a);let s=i.move(t.containerPhrasing(e,{after:a,before:l,...i.current()}));const c=s.charCodeAt(0),p=Te(r.before.charCodeAt(r.before.length-1),c,a);p.inside&&(s=ye(c)+s.slice(1));const u=s.charCodeAt(s.length-1),f=Te(r.after.charCodeAt(0),u,a);f.inside&&(s=s.slice(0,-1)+ye(u));const g=i.move(a);return o(),t.attentionEncodeSurroundingInfo={after:f.outside,before:p.outside},l+s+g}function ca(e,n,t){return t.options.emphasis||"*"}function ua(e,n){let t=!1;return jn(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return t=!0,Mn}),!!((!e.depth||e.depth<3)&&$t(e)&&(n.options.setext||t))}function da(e,n,t,r){const a=Math.max(Math.min(6,e.depth||1),1),o=t.createTracker(r);if(ua(e,t)){const p=t.enter("headingSetext"),u=t.enter("phrasing"),f=t.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),l=t.enter("headingAtx"),s=t.enter("phrasing");o.move(i+" ");let c=t.containerPhrasing(e,{before:"# ",after:`
|
|
159
|
-
`,...o.current()});return/^[\t ]/.test(c)&&(c=ye(c.charCodeAt(0))+c.slice(1)),c=c?i+" "+c:i,t.options.closeAtx&&(c+=" "+i),s(),l(),c}sn.peek=fa;function sn(e){return e.value||""}function fa(){return"<"}ln.peek=pa;function ln(e,n,t,r){const a=et(t),o=a==='"'?"Quote":"Apostrophe",i=t.enter("image");let l=t.enter("label");const s=t.createTracker(r);let c=s.move("![");return c+=s.move(t.safe(e.alt,{before:c,after:"]",...s.current()})),c+=s.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=t.enter("destinationLiteral"),c+=s.move("<"),c+=s.move(t.safe(e.url,{before:c,after:">",...s.current()})),c+=s.move(">")):(l=t.enter("destinationRaw"),c+=s.move(t.safe(e.url,{before:c,after:e.title?" ":")",...s.current()}))),l(),e.title&&(l=t.enter(`title${o}`),c+=s.move(" "+a),c+=s.move(t.safe(e.title,{before:c,after:a,...s.current()})),c+=s.move(a),l()),c+=s.move(")"),i(),c}function pa(){return"!"}cn.peek=ma;function cn(e,n,t,r){const a=e.referenceType,o=t.enter("imageReference");let i=t.enter("label");const l=t.createTracker(r);let s=l.move("![");const c=t.safe(e.alt,{before:s,after:"]",...l.current()});s+=l.move(c+"]["),i();const p=t.stack;t.stack=[],i=t.enter("reference");const u=t.safe(t.associationId(e),{before:s,after:"]",...l.current()});return i(),t.stack=p,o(),a==="full"||!c||c!==u?s+=l.move(u+"]"):a==="shortcut"?s=s.slice(0,-1):s+=l.move("]"),s}function ma(){return"!"}un.peek=ha;function un(e,n,t){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<t.unsafe.length;){const i=t.unsafe[o],l=t.compilePattern(i);let s;if(i.atBreak)for(;s=l.exec(r);){let c=s.index;r.charCodeAt(c)===10&&r.charCodeAt(c-1)===13&&c--,r=r.slice(0,c)+" "+r.slice(s.index+1)}}return a+r+a}function ha(){return"`"}function dn(e,n){const t=$t(e);return!!(!n.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(t===e.url||"mailto:"+t===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}fn.peek=ga;function fn(e,n,t,r){const a=et(t),o=a==='"'?"Quote":"Apostrophe",i=t.createTracker(r);let l,s;if(dn(e,t)){const p=t.stack;t.stack=[],l=t.enter("autolink");let u=i.move("<");return u+=i.move(t.containerPhrasing(e,{before:u,after:">",...i.current()})),u+=i.move(">"),l(),t.stack=p,u}l=t.enter("link"),s=t.enter("label");let c=i.move("[");return c+=i.move(t.containerPhrasing(e,{before:c,after:"](",...i.current()})),c+=i.move("]("),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=t.enter("destinationLiteral"),c+=i.move("<"),c+=i.move(t.safe(e.url,{before:c,after:">",...i.current()})),c+=i.move(">")):(s=t.enter("destinationRaw"),c+=i.move(t.safe(e.url,{before:c,after:e.title?" ":")",...i.current()}))),s(),e.title&&(s=t.enter(`title${o}`),c+=i.move(" "+a),c+=i.move(t.safe(e.title,{before:c,after:a,...i.current()})),c+=i.move(a),s()),c+=i.move(")"),l(),c}function ga(e,n,t){return dn(e,t)?"<":"["}pn.peek=va;function pn(e,n,t,r){const a=e.referenceType,o=t.enter("linkReference");let i=t.enter("label");const l=t.createTracker(r);let s=l.move("[");const c=t.containerPhrasing(e,{before:s,after:"]",...l.current()});s+=l.move(c+"]["),i();const p=t.stack;t.stack=[],i=t.enter("reference");const u=t.safe(t.associationId(e),{before:s,after:"]",...l.current()});return i(),t.stack=p,o(),a==="full"||!c||c!==u?s+=l.move(u+"]"):a==="shortcut"?s=s.slice(0,-1):s+=l.move("]"),s}function va(){return"["}function tt(e){const n=e.options.bullet||"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bullet`, expected `*`, `+`, or `-`");return n}function ba(e){const n=tt(e),t=e.options.bulletOther;if(!t)return n==="*"?"-":"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(t===n)throw new Error("Expected `bullet` (`"+n+"`) and `bulletOther` (`"+t+"`) to be different");return t}function wa(e){const n=e.options.bulletOrdered||".";if(n!=="."&&n!==")")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOrdered`, expected `.` or `)`");return n}function mn(e){const n=e.options.rule||"*";if(n!=="*"&&n!=="-"&&n!=="_")throw new Error("Cannot serialize rules with `"+n+"` for `options.rule`, expected `*`, `-`, or `_`");return n}function xa(e,n,t,r){const a=t.enter("list"),o=t.bulletCurrent;let i=e.ordered?wa(t):tt(t);const l=e.ordered?i==="."?")":".":ba(t);let s=n&&t.bulletLastUsed?i===t.bulletLastUsed:!1;if(!e.ordered){const p=e.children?e.children[0]:void 0;if((i==="*"||i==="-")&&p&&(!p.children||!p.children[0])&&t.stack[t.stack.length-1]==="list"&&t.stack[t.stack.length-2]==="listItem"&&t.stack[t.stack.length-3]==="list"&&t.stack[t.stack.length-4]==="listItem"&&t.indexStack[t.indexStack.length-1]===0&&t.indexStack[t.indexStack.length-2]===0&&t.indexStack[t.indexStack.length-3]===0&&(s=!0),mn(t)===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=l),t.bulletCurrent=i;const c=t.containerFlow(e,r);return t.bulletLastUsed=i,t.bulletCurrent=o,a(),c}function ya(e){const n=e.options.listItemIndent||"one";if(n!=="tab"&&n!=="one"&&n!=="mixed")throw new Error("Cannot serialize items with `"+n+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return n}function ka(e,n,t,r){const a=ya(t);let o=t.bulletCurrent||tt(t);n&&n.type==="list"&&n.ordered&&(o=(typeof n.start=="number"&&n.start>-1?n.start:1)+(t.options.incrementListMarker===!1?0:n.children.indexOf(e))+o);let i=o.length+1;(a==="tab"||a==="mixed"&&(n&&n.type==="list"&&n.spread||e.spread))&&(i=Math.ceil(i/4)*4);const l=t.createTracker(r);l.move(o+" ".repeat(i-o.length)),l.shift(i);const s=t.enter("listItem"),c=t.indentLines(t.containerFlow(e,l.current()),p);return s(),c;function p(u,f,g){return f?(g?"":" ".repeat(i))+u:(g?o:o+" ".repeat(i-o.length))+u}}function Ea(e,n,t,r){const a=t.enter("paragraph"),o=t.enter("phrasing"),i=t.containerPhrasing(e,r);return o(),a(),i}const Aa=Ft(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Sa(e,n,t,r){return(e.children.some(function(i){return Aa(i)})?t.containerPhrasing:t.containerFlow).call(t,e,r)}function La(e){const n=e.options.strong||"*";if(n!=="*"&&n!=="_")throw new Error("Cannot serialize strong with `"+n+"` for `options.strong`, expected `*`, or `_`");return n}hn.peek=Ca;function hn(e,n,t,r){const a=La(t),o=t.enter("strong"),i=t.createTracker(r),l=i.move(a+a);let s=i.move(t.containerPhrasing(e,{after:a,before:l,...i.current()}));const c=s.charCodeAt(0),p=Te(r.before.charCodeAt(r.before.length-1),c,a);p.inside&&(s=ye(c)+s.slice(1));const u=s.charCodeAt(s.length-1),f=Te(r.after.charCodeAt(0),u,a);f.inside&&(s=s.slice(0,-1)+ye(u));const g=i.move(a+a);return o(),t.attentionEncodeSurroundingInfo={after:f.outside,before:p.outside},l+s+g}function Ca(e,n,t){return t.options.strong||"*"}function Ra(e,n,t,r){return t.safe(e.value,r)}function Ia(e){const n=e.options.ruleRepetition||3;if(n<3)throw new Error("Cannot serialize rules with repetition `"+n+"` for `options.ruleRepetition`, expected `3` or more");return n}function Ta(e,n,t){const r=(mn(t)+(t.options.ruleSpaces?" ":"")).repeat(Ia(t));return t.options.ruleSpaces?r.slice(0,-1):r}const gn={blockquote:Qi,break:_t,code:aa,definition:sa,emphasis:on,hardBreak:_t,heading:da,html:sn,image:ln,imageReference:cn,inlineCode:un,link:fn,linkReference:pn,list:xa,listItem:ka,paragraph:Ea,root:Sa,strong:hn,text:Ra,thematicBreak:Ta};function ja(){return{enter:{table:Ma,tableData:Nt,tableHeader:Nt,tableRow:_a},exit:{codeText:Na,table:Pa,tableData:Ve,tableHeader:Ve,tableRow:Ve}}}function Ma(e){const n=e._align;this.enter({type:"table",align:n.map(function(t){return t==="none"?null:t}),children:[]},e),this.data.inTable=!0}function Pa(e){this.exit(e),this.data.inTable=void 0}function _a(e){this.enter({type:"tableRow",children:[]},e)}function Ve(e){this.exit(e)}function Nt(e){this.enter({type:"tableCell",children:[]},e)}function Na(e){let n=this.resume();this.data.inTable&&(n=n.replace(/\\([\\|])/g,Da));const t=this.stack[this.stack.length-1];me(t.type==="inlineCode"),t.value=n,this.exit(e)}function Da(e,n){return n==="|"?n:e}function Oa(e){const n=e||{},t=n.tableCellPadding,r=n.tablePipeAlign,a=n.stringLength,o=t?" ":"|";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:l}};function i(g,m,y,E){return c(p(g,y,E),g.align)}function l(g,m,y,E){const b=u(g,y,E),S=c([b]);return S.slice(0,S.indexOf(`
|
|
161
|
-
`))}function s(g,m,y,E){const b=y.enter("tableCell"),S=y.enter("phrasing"),w=y.containerPhrasing(g,{...E,before:o,after:o});return S(),b(),w}function c(g,m){return Zi(g,{align:m,alignDelimiters:r,padding:t,stringLength:a})}function p(g,m,y){const E=g.children;let b=-1;const S=[],w=m.enter("table");for(;++b<E.length;)S[b]=u(E[b],m,y);return w(),S}function u(g,m,y){const E=g.children;let b=-1;const S=[],w=m.enter("tableRow");for(;++b<E.length;)S[b]=s(E[b],g,m,y);return w(),S}function f(g,m,y){let E=gn.inlineCode(g,m,y);return y.stack.includes("tableCell")&&(E=E.replace(/\|/g,"\\$&")),E}}function za(){return{exit:{taskListCheckValueChecked:Dt,taskListCheckValueUnchecked:Dt,paragraph:$a}}}function Fa(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Va}}}function Dt(e){const n=this.stack[this.stack.length-2];me(n.type==="listItem"),n.checked=e.type==="taskListCheckValueChecked"}function $a(e){const n=this.stack[this.stack.length-2];if(n&&n.type==="listItem"&&typeof n.checked=="boolean"){const t=this.stack[this.stack.length-1];me(t.type==="paragraph");const r=t.children[0];if(r&&r.type==="text"){const a=n.children;let o=-1,i;for(;++o<a.length;){const l=a[o];if(l.type==="paragraph"){i=l;break}}i===t&&(r.value=r.value.slice(1),r.value.length===0?t.children.shift():t.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,t.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function Va(e,n,t,r){const a=e.children[0],o=typeof e.checked=="boolean"&&a&&a.type==="paragraph",i="["+(e.checked?"x":" ")+"] ",l=t.createTracker(r);o&&l.move(i);let s=gn.listItem(e,n,t,{...r,...l.current()});return o&&(s=s.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),s;function c(p){return p+i}}function Ua(){return[xi(),Vi(),Bi(),ja(),za()]}function qa(e){return{extensions:[yi(),Ui(e),Wi(),Oa(e),Fa()]}}const Ha={tokenize:Ya,partial:!0},vn={tokenize:Za,partial:!0},bn={tokenize:Ja,partial:!0},wn={tokenize:Qa,partial:!0},Ba={tokenize:eo,partial:!0},xn={name:"wwwAutolink",tokenize:Ka,previous:kn},yn={name:"protocolAutolink",tokenize:Xa,previous:En},ne={name:"emailAutolink",tokenize:Ga,previous:An},te={};function Wa(){return{text:te}}let se=48;for(;se<123;)te[se]=ne,se++,se===58?se=65:se===91&&(se=97);te[43]=ne;te[45]=ne;te[46]=ne;te[95]=ne;te[72]=[ne,yn];te[104]=[ne,yn];te[87]=[ne,xn];te[119]=[ne,xn];function Ga(e,n,t){const r=this;let a,o;return i;function i(u){return!Ge(u)||!An.call(r,r.previous)||nt(r.events)?t(u):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),l(u))}function l(u){return Ge(u)?(e.consume(u),l):u===64?(e.consume(u),s):t(u)}function s(u){return u===46?e.check(Ba,p,c)(u):u===45||u===95||Ye(u)?(o=!0,e.consume(u),s):p(u)}function c(u){return e.consume(u),a=!0,s}function p(u){return o&&a&&we(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),n(u)):t(u)}}function Ka(e,n,t){const r=this;return a;function a(i){return i!==87&&i!==119||!kn.call(r,r.previous)||nt(r.events)?t(i):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(Ha,e.attempt(vn,e.attempt(bn,o),t),t)(i))}function o(i){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),n(i)}}function Xa(e,n,t){const r=this;let a="",o=!1;return i;function i(u){return(u===72||u===104)&&En.call(r,r.previous)&&!nt(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(u),e.consume(u),l):t(u)}function l(u){if(we(u)&&a.length<5)return a+=String.fromCodePoint(u),e.consume(u),l;if(u===58){const f=a.toLowerCase();if(f==="http"||f==="https")return e.consume(u),s}return t(u)}function s(u){return u===47?(e.consume(u),o?c:(o=!0,s)):t(u)}function c(u){return u===null||Pn(u)||X(u)||pe(u)||Xe(u)?t(u):e.attempt(vn,e.attempt(bn,p),t)(u)}function p(u){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),n(u)}}function Ya(e,n,t){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):t(i)}function o(i){return i===null?t(i):n(i)}}function Za(e,n,t){let r,a,o;return i;function i(c){return c===46||c===95?e.check(wn,s,l)(c):c===null||X(c)||pe(c)||c!==45&&Xe(c)?s(c):(o=!0,e.consume(c),i)}function l(c){return c===95?r=!0:(a=r,r=void 0),e.consume(c),i}function s(c){return a||r||!o?t(c):n(c)}}function Ja(e,n){let t=0,r=0;return a;function a(i){return i===40?(t++,e.consume(i),a):i===41&&r<t?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(wn,n,o)(i):i===null||X(i)||pe(i)?n(i):(e.consume(i),a)}function o(i){return i===41&&r++,e.consume(i),a}}function Qa(e,n,t){return r;function r(l){return l===33||l===34||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===63||l===95||l===126?(e.consume(l),r):l===38?(e.consume(l),o):l===93?(e.consume(l),a):l===60||l===null||X(l)||pe(l)?n(l):t(l)}function a(l){return l===null||l===40||l===91||X(l)||pe(l)?n(l):r(l)}function o(l){return we(l)?i(l):t(l)}function i(l){return l===59?(e.consume(l),r):we(l)?(e.consume(l),i):t(l)}}function eo(e,n,t){return r;function r(o){return e.consume(o),a}function a(o){return Ye(o)?t(o):n(o)}}function kn(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||X(e)}function En(e){return!we(e)}function An(e){return!(e===47||Ge(e))}function Ge(e){return e===43||e===45||e===46||e===95||Ye(e)}function nt(e){let n=e.length,t=!1;for(;n--;){const r=e[n][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){t=!0;break}if(r._gfmAutolinkLiteralWalkedInto){t=!1;break}}return e.length>0&&!t&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),t}const to={tokenize:co,partial:!0};function no(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:oo,continuation:{tokenize:so},exit:lo}},text:{91:{name:"gfmFootnoteCall",tokenize:ao},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:ro,resolveTo:io}}}}function ro(e,n,t){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 l;function l(s){if(!i||!i._balanced)return t(s);const c=ke(r.sliceSerialize({start:i.end,end:r.now()}));return c.codePointAt(0)!==94||!o.includes(c.slice(1))?t(s):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(s),e.exit("gfmFootnoteCallLabelMarker"),n(s))}}function io(e,n){let t=e.length;for(;t--;)if(e[t][1].type==="labelImage"&&e[t][0]==="enter"){e[t][1];break}e[t+1][1].type="data",e[t+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[t+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[t+3][1].end),end:Object.assign({},e[t+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)},l=[e[t+1],e[t+2],["enter",r,n],e[t+3],e[t+4],["enter",a,n],["exit",a,n],["enter",o,n],["enter",i,n],["exit",i,n],["exit",o,n],e[e.length-2],e[e.length-1],["exit",r,n]];return e.splice(t,e.length-t+1,...l),e}function ao(e,n,t){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o=0,i;return l;function l(u){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(u),e.exit("gfmFootnoteCallLabelMarker"),s}function s(u){return u!==94?t(u):(e.enter("gfmFootnoteCallMarker"),e.consume(u),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(u){if(o>999||u===93&&!i||u===null||u===91||X(u))return t(u);if(u===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return a.includes(ke(r.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(u),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),n):t(u)}return X(u)||(i=!0),o++,e.consume(u),u===92?p:c}function p(u){return u===91||u===92||u===93?(e.consume(u),o++,c):c(u)}}function oo(e,n,t){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o,i=0,l;return s;function s(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",p):t(m)}function p(m){if(i>999||m===93&&!l||m===null||m===91||X(m))return t(m);if(m===93){e.exit("chunkString");const y=e.exit("gfmFootnoteDefinitionLabelString");return o=ke(r.sliceSerialize(y)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return X(m)||(l=!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),re(e,g,"gfmFootnoteDefinitionWhitespace")):t(m)}function g(m){return n(m)}}function so(e,n,t){return e.check(_n,n,e.attempt(to,n,t))}function lo(e){e.exit("gfmFootnoteDefinition")}function co(e,n,t){const r=this;return re(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?n(o):t(o)}}function uo(e){let t=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:o,resolveAll:a};return t==null&&(t=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function a(i,l){let s=-1;for(;++s<i.length;)if(i[s][0]==="enter"&&i[s][1].type==="strikethroughSequenceTemporary"&&i[s][1]._close){let c=s;for(;c--;)if(i[c][0]==="exit"&&i[c][1].type==="strikethroughSequenceTemporary"&&i[c][1]._open&&i[s][1].end.offset-i[s][1].start.offset===i[c][1].end.offset-i[c][1].start.offset){i[s][1].type="strikethroughSequence",i[c][1].type="strikethroughSequence";const p={type:"strikethrough",start:Object.assign({},i[c][1].start),end:Object.assign({},i[s][1].end)},u={type:"strikethroughText",start:Object.assign({},i[c][1].end),end:Object.assign({},i[s][1].start)},f=[["enter",p,l],["enter",i[c][1],l],["exit",i[c][1],l],["enter",u,l]],g=l.parser.constructs.insideSpan.null;g&&_e(f,f.length,0,Nn(g,i.slice(c+1,s),l)),_e(f,f.length,0,[["exit",u,l],["enter",i[s][1],l],["exit",i[s][1],l],["exit",p,l]]),_e(i,c-1,s-c+3,f),s=c+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,l,s){const c=this.previous,p=this.events;let u=0;return f;function f(m){return c===126&&p[p.length-1][1].type!=="characterEscape"?s(m):(i.enter("strikethroughSequenceTemporary"),g(m))}function g(m){const y=Re(c);if(m===126)return u>1?s(m):(i.consume(m),u++,g);if(u<2&&!t)return s(m);const E=i.exit("strikethroughSequenceTemporary"),b=Re(m);return E._open=!b||b===2&&!!y,E._close=!y||y===2&&!!b,l(m)}}}class fo{constructor(){this.map=[]}add(n,t,r){po(this,n,t,r)}consume(n){if(this.map.sort(function(o,i){return o[0]-i[0]}),this.map.length===0)return;let t=this.map.length;const r=[];for(;t>0;)t-=1,r.push(n.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),n.length=this.map[t][0];r.push(n.slice()),n.length=0;let a=r.pop();for(;a;){for(const o of a)n.push(o);a=r.pop()}this.map.length=0}}function po(e,n,t,r){let a=0;if(!(t===0&&r.length===0)){for(;a<e.map.length;){if(e.map[a][0]===n){e.map[a][1]+=t,e.map[a][2].push(...r);return}a+=1}e.map.push([n,t,r])}}function mo(e,n){let t=!1;const r=[];for(;n<e.length;){const a=e[n];if(t){if(a[0]==="enter")a[1].type==="tableContent"&&r.push(e[n+1][1].type==="tableDelimiterMarker"?"left":"none");else if(a[1].type==="tableContent"){if(e[n-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"&&(t=!0);n+=1}return r}function ho(){return{flow:{null:{name:"table",tokenize:go,resolveAll:vo}}}}function go(e,n,t){const r=this;let a=0,o=0,i;return l;function l(d){let D=r.events.length-1;for(;D>-1;){const W=r.events[D][1].type;if(W==="lineEnding"||W==="linePrefix")D--;else break}const P=D>-1?r.events[D][1].type:null,j=P==="tableHead"||P==="tableRow"?z:s;return j===z&&r.parser.lazy[r.now().line]?t(d):j(d)}function s(d){return e.enter("tableHead"),e.enter("tableRow"),c(d)}function c(d){return d===124||(i=!0,o+=1),p(d)}function p(d){return d===null?t(d):be(d)?o>1?(o=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),g):t(d):ce(d)?re(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||X(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]?t(d):(e.enter("tableDelimiterRow"),i=!1,ce(d)?re(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"),y):L(d)}function y(d){return ce(d)?re(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||be(d)?F(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 ce(d)?re(e,F,"whitespace")(d):F(d)}function F(d){return d===124?m(d):d===null||be(d)?!i||a!==o?L(d):(e.exit("tableDelimiterRow"),e.exit("tableHead"),n(d)):L(d)}function L(d){return t(d)}function z(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||be(d)?(e.exit("tableRow"),n(d)):ce(d)?re(e,V,"whitespace")(d):(e.enter("data"),k(d))}function k(d){return d===null||d===124||X(d)?(e.exit("data"),V(d)):(e.consume(d),d===92?A:k)}function A(d){return d===92||d===124?(e.consume(d),k):k(d)}}function vo(e,n){let t=-1,r=!0,a=0,o=[0,0,0,0],i=[0,0,0,0],l=!1,s=0,c,p,u;const f=new fo;for(;++t<e.length;){const g=e[t],m=g[1];g[0]==="enter"?m.type==="tableHead"?(l=!1,s!==0&&(Ot(f,n,s,c,p),p=void 0,s=0),c={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(t,0,[["enter",c,n]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,u=void 0,o=[0,0,0,0],i=[0,t+1,0,0],l&&(l=!1,p={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(t,0,[["enter",p,n]])),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=Ce(f,n,o,a,void 0,u),o=[0,0,0,0]),i[2]=t)):m.type==="tableCellDivider"&&(r?r=!1:(o[1]!==0&&(i[0]=i[1],u=Ce(f,n,o,a,void 0,u)),o=i,i=[o[1],t,0,0])):m.type==="tableHead"?(l=!0,s=t):m.type==="tableRow"||m.type==="tableDelimiterRow"?(s=t,o[1]!==0?(i[0]=i[1],u=Ce(f,n,o,a,t,u)):i[1]!==0&&(u=Ce(f,n,i,a,t,u)),a=0):a&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(i[3]=t)}for(s!==0&&Ot(f,n,s,c,p),f.consume(n.events),t=-1;++t<n.events.length;){const g=n.events[t];g[0]==="enter"&&g[1].type==="table"&&(g[1]._align=mo(n.events,t))}return e}function Ce(e,n,t,r,a,o){const i=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",l="tableContent";t[0]!==0&&(o.end=Object.assign({},ue(n.events,t[0])),e.add(t[0],0,[["exit",o,n]]));const s=ue(n.events,t[1]);if(o={type:i,start:Object.assign({},s),end:Object.assign({},s)},e.add(t[1],0,[["enter",o,n]]),t[2]!==0){const c=ue(n.events,t[2]),p=ue(n.events,t[3]),u={type:l,start:Object.assign({},c),end:Object.assign({},p)};if(e.add(t[2],0,[["enter",u,n]]),r!==2){const f=n.events[t[2]],g=n.events[t[3]];if(f[1].end=Object.assign({},g[1].end),f[1].type="chunkText",f[1].contentType="text",t[3]>t[2]+1){const m=t[2]+1,y=t[3]-t[2]-1;e.add(m,y,[])}}e.add(t[3]+1,0,[["exit",u,n]])}return a!==void 0&&(o.end=Object.assign({},ue(n.events,a)),e.add(a,0,[["exit",o,n]]),o=void 0),o}function Ot(e,n,t,r,a){const o=[],i=ue(n.events,t);a&&(a.end=Object.assign({},i),o.push(["exit",a,n])),r.end=Object.assign({},i),o.push(["exit",r,n]),e.add(t+1,0,o)}function ue(e,n){const t=e[n],r=t[0]==="enter"?"start":"end";return t[1][r]}const bo={name:"tasklistCheck",tokenize:xo};function wo(){return{text:{91:bo}}}function xo(e,n,t){const r=this;return a;function a(s){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?t(s):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(s),e.exit("taskListCheckMarker"),o)}function o(s){return X(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):t(s)}function i(s){return s===93?(e.enter("taskListCheckMarker"),e.consume(s),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),l):t(s)}function l(s){return be(s)?n(s):ce(s)?e.check({tokenize:yo},n,t)(s):t(s)}}function yo(e,n,t){return re(e,r,"whitespace");function r(a){return a===null?t(a):n(a)}}function ko(e){return Dn([Wa(),no(),uo(e),ho(),wo()])}const Eo={};function Ao(e){const n=this,t=e||Eo,r=n.data(),a=r.micromarkExtensions||(r.micromarkExtensions=[]),o=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),i=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);a.push(ko(t)),o.push(Ua()),i.push(qa(t))}let Ue;async function So(){return Ue||(Ue=ae(()=>import("./mermaid.core-UUGPJ6yi.js").then(e=>e.bF),__vite__mapDeps([2,1])).then(e=>e.default)),Ue}function Sn({source:e,title:n,themeMode:t="light",onRendered:r,onError:a,onTelemetry:o}){const i=h.useId(),l=h.useMemo(()=>`mermaid-${i.replace(/[^a-zA-Z0-9_-]/g,"")}`,[i]),[s,c]=h.useState({status:"loading"});return h.useEffect(()=>{const p=e.trim();if(!p){const f="The Mermaid diagram is empty.";c({status:"error",error:f}),o==null||o("warn","mermaid.render.skipped",f,{definitionLength:0}),a==null||a(f);return}let u=!1;return c({status:"loading"}),o==null||o("info","mermaid.render.started","Started Mermaid render.",{definitionLength:p.length}),So().then(f=>(f.initialize({startOnLoad:!1,securityLevel:"strict",theme:t==="dark"?"dark":"neutral",suppressErrorRendering:!0,fontFamily:'"Inter", "Segoe UI", sans-serif'}),f.render(l,p))).then(({svg:f})=>{u||(c({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.";c({status:"error",error:g}),o==null||o("error","mermaid.render.failed",g,{definitionLength:p.length}),a==null||a(g)}),()=>{u=!0}},[l,a,r,o,e,t]),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:[n?v.jsx("span",{children:n}):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":n??"Mermaid diagram",dangerouslySetInnerHTML:{__html:s.svg}})})}function Ke(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(n=>Ke(n)).join(""):h.isValidElement(e)?Ke(e.props.children):""}function Lo(e){var t;const n=e==null?void 0:e.match(/language-([^\s]+)/);return(t=n==null?void 0:n[1])==null?void 0:t.toLowerCase()}function Co(e){return h.Children.toArray(e).find(t=>h.isValidElement(t)&&t.type==="code")??null}function Ro(e){return{a({href:n,children:t}){return v.jsx("a",{href:n,target:"_blank",rel:"noreferrer",children:t})},img({src:n,alt:t}){return n?v.jsx("img",{src:n,alt:t??"",loading:"lazy"}):null},pre({children:n}){const t=Co(n);if(!t)return v.jsx("pre",{children:n});const r=Lo(t.props.className),a=Ke(t.props.children).replace(/\n$/,"");return["mermaid","mmd"].includes(r??"")?v.jsx(Sn,{source:a,title:"Embedded Mermaid diagram",themeMode:e==null?void 0:e.themeMode,onTelemetry:e==null?void 0:e.onTelemetry}):v.jsx(en,{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:n}){return v.jsx("div",{className:"document-markdown-table-wrap",children:v.jsx("table",{children:n})})}}}function Io(e,n){return v.jsx("article",{className:"document-markdown-prose",children:v.jsx(On,{remarkPlugins:[Ao],components:Ro(n),children:e})})}const To=h.lazy(()=>ae(()=>import("./pdf-renderer-DUYqGnQu.js"),__vite__mapDeps([3,1,4,5]))),jo=h.lazy(()=>ae(()=>import("./pptx-renderer-DPSAG5_x.js"),__vite__mapDeps([6,1,4,5]))),Mo=h.lazy(()=>ae(()=>import("./docx-renderer-Bws5M_Ee.js"),__vite__mapDeps([7,1,8,5]))),Po=h.lazy(()=>ae(()=>import("./spreadsheet-renderer-WVtOHmRi.js"),__vite__mapDeps([9,1,10]))),_o=h.lazy(()=>ae(()=>import("./zip-renderer-oijmTXXF.js"),__vite__mapDeps([11,1,5]))),No=h.lazy(()=>ae(()=>import("./epub-renderer-C-aCqy3m.js"),__vite__mapDeps([12,1,5]))),Do=new Set([".md",".markdown"]),Oo=new Set(["application/markdown","application/x-markdown","text/markdown","text/x-markdown"]);function zo(e){var n;return(n=e.toLowerCase().match(/(\.[a-z0-9]+)$/))==null?void 0:n[1]}function Fo(e){var n;return(n=e==null?void 0:e.toLowerCase().split(";")[0])==null?void 0:n.trim()}function $o(e){if(e.format!=="text")return!1;const n=zo(e.name);if(n&&Do.has(n))return!0;const t=Fo(e.mimeType);return!!(t&&Oo.has(t))}function Ee(e,n){return h.useMemo(()=>Xt(e,n),[e,n])}function rt(e,n){const[t,r]=h.useState({status:n?"loading":"idle"});return h.useEffect(()=>{if(!n){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 l=await i.blob();o=URL.createObjectURL(l),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)}},[n,e]),t}function Vo(e,n){const[t,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()}},[n,e]),t}function ee(e,n){h.useLayoutEffect(()=>{if(!e.current||!n)return;const t=o=>{if(!e.current)return;const i=Math.ceil(e.current.getBoundingClientRect().height);n(i,o)},r=new ResizeObserver(()=>t("content"));r.observe(e.current);const a=()=>t("viewport");return window.addEventListener("resize",a),t("renderer"),()=>{r.disconnect(),window.removeEventListener("resize",a)}},[n,e])}function B({label:e}){return v.jsxs("div",{className:"document-loading",children:[v.jsx("div",{className:"document-spinner"}),v.jsx("p",{children:e})]})}function it({title:e,message:n}){return v.jsxs("div",{className:"document-empty-state",children:[v.jsx("h3",{children:e}),v.jsx("p",{children:n})]})}function Uo({document:e,session:n,onLoaded:t,onError:r,onResize:a}){const o=Ee(e,n),i=e.source.kind==="session",l=rt(o,i),s=h.useRef(null);ee(s,a);const c=i?l.url:o==null?void 0:o.url;return h.useEffect(()=>{i&&l.status==="error"&&r("document-fetch-failed",l.error??"Image failed to load",!0)},[e,l.error,l.status,r,i]),i&&l.status==="loading"?v.jsx(B,{label:"Fetching secure image preview"}):c?v.jsx("div",{ref:s,className:"document-media-shell",children:v.jsx("img",{src:c,alt:e.name,className:"document-image","data-viewer-zoom-target":!0,onLoad:()=>t(),onError:()=>r("document-fetch-failed","The image preview could not be loaded.",!0)})}):v.jsx(it,{title:"Image preview unavailable",message:"This image does not expose a preview-safe URL."})}function qo({document:e,session:n,onLoaded:t,onError:r,onResize:a}){const o=Ee(e,n),i=e.source.kind==="session",l=rt(o,i),s=h.useRef(null);ee(s,a);const c=i?l.url:o==null?void 0:o.url;return h.useEffect(()=>{i&&l.status==="error"&&r("document-fetch-failed",l.error??"Video failed to load",!0)},[e,l.error,l.status,r,i]),i&&l.status==="loading"?v.jsx(B,{label:"Preparing secure video preview"}):c?v.jsx("div",{ref:s,className:"document-media-shell",children:v.jsx("video",{className:"document-video",controls:!0,playsInline:!0,src:c,onLoadedMetadata:()=>t(),onError:()=>r("document-fetch-failed","The video preview could not be loaded.",!0)})}):v.jsx(it,{title:"Video preview unavailable",message:"This video does not expose a preview-safe URL."})}function Ho({document:e,session:n,onLoaded:t,onError:r,onResize:a}){const o=Ee(e,n),i=e.source.kind==="session",l=rt(o,i),s=h.useRef(null);ee(s,a);const c=i?l.url:o==null?void 0:o.url;return h.useEffect(()=>{i&&l.status==="error"&&r("document-fetch-failed",l.error??"Audio failed to load",!0)},[e,l.error,l.status,r,i]),i&&l.status==="loading"?v.jsx(B,{label:"Preparing secure audio preview"}):c?v.jsx("div",{ref:s,className:"document-media-shell document-audio-shell",children:v.jsx("audio",{className:"document-audio",controls:!0,preload:"metadata",src:c,onLoadedMetadata:()=>t(),onError:()=>r("document-fetch-failed","The audio preview could not be loaded.",!0)})}):v.jsx(it,{title:"Audio preview unavailable",message:"This audio file does not expose a preview-safe URL."})}function ge({document:e,session:n,onLoaded:t,onError:r,onResize:a,onTelemetry:o,themeMode:i,presentation:l}){const s=Ee(e,n),c=Vo(s,!0),p=h.useRef(null),u=h.useRef(!1),f=h.useRef(!1),g=h.useRef(!1),m=h.useRef(!1),y=Tt(e);return ee(p,a),h.useEffect(()=>{u.current=!1,f.current=!1,g.current=!1,m.current=!1},[e.id]),h.useEffect(()=>{c.status==="ready"&&l!=="mermaid"&&!y&&t(),c.status==="error"&&r("document-fetch-failed",c.error??"Text preview failed to load.",!0)},[e,r,t,l,c.error,c.status,y]),c.status==="loading"?v.jsx(B,{label:l==="markdown"?"Rendering markdown preview":l==="mermaid"?"Rendering Mermaid preview":y?"Rendering code preview":"Loading text preview"}):c.status!=="ready"?null:l==="mermaid"?v.jsx("div",{ref:p,className:"document-mermaid-document",children:v.jsx(Sn,{source:c.text??"",title:e.name,themeMode:i,onTelemetry:o,onRendered:()=>{u.current||(u.current=!0,t())},onError:E=>{f.current||(f.current=!0,r("renderer-failed",E,!1))}})}):Tt(e)?v.jsx("div",{ref:p,className:"document-code-document","data-viewer-zoom-target":!0,children:v.jsx(en,{source:c.text??"",title:e.name,languageHint:Jt(e),themeMode:i,onTelemetry:o,onRendered:()=>{g.current||(g.current=!0,t())},onError:E=>{m.current||(m.current=!0,r("renderer-failed",E,!1))}})}):v.jsx("div",{ref:p,"data-viewer-zoom-target":!0,className:l==="markdown"?"document-markdown":"document-text-shell",children:l==="markdown"?Io(c.text??"",{onTelemetry:o,themeMode:i}):v.jsx("pre",{children:c.text})})}function Bo({document:e,onUnsupported:n}){return h.useEffect(()=>{n("format-not-supported",`Format "${e.format}" is not supported in the current viewer phase.`)},[e,n]),null}function Wo(e){const{document:n,pageNavigationRequest:t}=e,r=Ee(n,e.session);switch(n.format){case"audio":return v.jsx(Ho,{...e});case"image":return v.jsx(Uo,{...e});case"video":return v.jsx(qo,{...e});case"text":return v.jsx(ge,{...e,presentation:$o(n)?"markdown":"text"});case"code":return v.jsx(ge,{...e,presentation:"text"});case"json":case"jsonl":case"ndjson":case"tsv":case"xml":case"toml":case"ini":case"dotenv":case"yaml":return v.jsx(ge,{...e,presentation:"text"});case"html":case"widget":return v.jsx(Qr,{...e});case"markdown":return v.jsx(ge,{...e,presentation:"markdown"});case"mermaid":return v.jsx(ge,{...e,presentation:"mermaid"});case"pdf":return v.jsx(h.Suspense,{fallback:v.jsx(B,{label:"Loading PDF renderer"}),children:v.jsx(To,{...e,request:r,useContainerResize:ee,pageNavigationRequest:t})});case"pptx":return v.jsx(h.Suspense,{fallback:v.jsx(B,{label:"Loading PPTX renderer"}),children:v.jsx(jo,{...e,request:r,useContainerResize:ee,pageNavigationRequest:t,LoadingState:B})});case"docx":return v.jsx(h.Suspense,{fallback:v.jsx(B,{label:"Loading DOCX renderer"}),children:v.jsx(Mo,{...e,request:r,useContainerResize:ee,LoadingState:B})});case"xls":case"xlsx":case"csv":return v.jsx(h.Suspense,{fallback:v.jsx(B,{label:"Loading spreadsheet renderer"}),children:v.jsx(Po,{...e,request:r,useContainerResize:ee,LoadingState:B})});case"zip":return v.jsx(h.Suspense,{fallback:v.jsx(B,{label:"Loading archive renderer"}),children:v.jsx(_o,{...e,request:r,useContainerResize:ee,LoadingState:B})});case"epub":return v.jsx(h.Suspense,{fallback:v.jsx(B,{label:"Loading EPUB renderer"}),children:v.jsx(No,{...e,request:r,useContainerResize:ee,LoadingState:B})});default:return v.jsx(Bo,{document:n,onUnsupported:e.onUnsupported})}}function Go({state:e,theme:n,safeArea:t,currentDocument:r,session:a,pageNavigationRequest:o,artifactDataMessage:i,streamCommandMessage:l,onLoaded:s,onUnsupported:c,onError:p,onTelemetry:u,onResize:f,onPageChanged:g,onArtifactEvent:m,onWidgetRequest:y,widgetResponseMessage:E}){var z,V,k,A;const b=h.useRef(null),S=h.useRef(null),w=h.useRef(0);oi(S,r==null?void 0:r.id);const F=h.useMemo(()=>{var d,D,P,j,W,G,J,oe;return{...(d=n.tokens)!=null&&d.surface?{"--bg":n.tokens.surface}:{},...(D=n.tokens)!=null&&D.surfaceMuted?{"--panel":n.tokens.surfaceMuted}:{},...(P=n.tokens)!=null&&P.surface?{"--panel-strong":n.tokens.surface}:{},...(j=n.tokens)!=null&&j.surface?{"--message-panel-bg":n.tokens.surface}:{},...(W=n.tokens)!=null&&W.surface?{"--document-surface":n.tokens.surface}:{},...(G=n.tokens)!=null&&G.text?{"--text":n.tokens.text}:{},...(J=n.tokens)!=null&&J.text?{"--document-code-text":n.tokens.text}:{},...(oe=n.tokens)!=null&&oe.accent?{"--accent":n.tokens.accent}:{}}},[(z=n.tokens)==null?void 0:z.accent,(V=n.tokens)==null?void 0:V.surface,(k=n.tokens)==null?void 0:k.surfaceMuted,(A=n.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 P=Math.ceil(b.current.getBoundingClientRect().height),j=r&&Ie(r.format)&&w.current>0?w.current:Math.max(P,w.current);j<=0||f(j,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}`,`${t[D]??0}px`);return()=>{for(const D of["top","right","bottom","left"])d.style.removeProperty(`--viewer-safe-area-${D}`)}},[t]),h.useLayoutEffect(()=>{const d=document.documentElement,D=Object.entries(F);d.dataset.themeMode=n.mode,d.dataset.documentFormat=(r==null?void 0:r.format)??"unknown";for(const[P,j]of D)d.style.setProperty(P,j);return()=>{delete d.dataset.themeMode,delete d.dataset.documentFormat;for(const[P]of D)d.style.removeProperty(P)}},[r==null?void 0:r.format,n.mode,F]),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(Wo,{document:r,session:a,theme:n,safeArea:t,themeMode:n.mode,onLoaded:s,onUnsupported:c,onError:p,onTelemetry:u,onResize:(d,D)=>L(D,d),onPageChanged:g,onArtifactEvent:m,onWidgetRequest:y,widgetResponseMessage:E,pageNavigationRequest:o,artifactDataMessage:i,streamCommandMessage:l})})})}):v.jsx("main",{ref:b,className:"viewer-shell"})}function qe(e){if(e.phase==="initializing"||e.phase==="loading-document"||e.phase==="ready"||e.phase==="unsupported"||e.phase==="error")return e.document}const Ko="0.1.0",Xo=["load-document","pagination","resize-notifications","artifact-runtime"];function Yo(){var r;const e=new URLSearchParams(window.location.search),n=e.get("themeMode"),t=n==="dark"||n==="light"?n:(r=window.matchMedia)!=null&&r.call(window,"(prefers-color-scheme: dark)").matches?"dark":"light";return{instanceId:e.get("instanceId")??"",parentOrigin:e.get("parentOrigin")??"",initialThemeMode:t}}function Zo(e){return e?Number.isNaN(Date.parse(e.expiresAt))||Date.parse(e.expiresAt)<=Date.now():!1}function Jo(e){return Z({instanceId:e,type:"viewer.ready",payload:{viewerVersion:Ko,supportedProtocolVersions:[je],capabilities:[...Xo]}})}function zt(e,n,t,r){return Z({instanceId:e,requestId:n,type:"viewer.ack",payload:{status:t,reason:r}})}function Qo(e,n,t){return Z({instanceId:e,type:"viewer.document-loaded",payload:{documentId:n.id,format:n.format,title:n.name,pageCount:t.pageCount}})}function es(e,n,t,r){return Z({instanceId:e,type:"viewer.unsupported",payload:{documentId:n.id,reason:t,message:r}})}function ts(e,n,t,r,a){return Z({instanceId:e,type:"viewer.error",payload:{documentId:a,code:n,message:t,recoverable:r}})}function ns(e,n,t){return Z({instanceId:e,type:"viewer.resize",payload:{height:n,reason:t}})}function rs(e,n){return Z({instanceId:e,type:"viewer.scroll",payload:{progress:n}})}function is(e,n,t,r,a){return Z({instanceId:e,type:"viewer.telemetry",payload:{level:n,name:t,message:r,context:a}})}function as(e,n,t){return Z({instanceId:e,type:"viewer.page-changed",payload:{page:n,pageCount:t}})}function os(e,n,t,r){return Z({instanceId:e,type:"viewer.artifact-event",payload:{documentId:n.id,name:t,detail:r}})}function ss(e,n){return Z({instanceId:e,type:"viewer.widget-request",payload:n})}function ls(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 ve(e){return e.phase==="initializing"||e.phase==="loading-document"||e.phase==="ready"?e.document:void 0}function cs(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 us(){const e=h.useMemo(()=>Yo(),[]),[n,t]=h.useState(()=>ls(e)),[r,a]=h.useState({}),[o,i]=h.useState({}),[l,s]=h.useState({mode:e.initialThemeMode}),[c,p]=h.useState(),[u,f]=h.useState(),[g,m]=h.useState(),[y,E]=h.useState(),b=h.useRef(n),S=h.useRef(r);h.useEffect(()=>{b.current=n},[n]),h.useEffect(()=>{S.current=r},[r]);const w=h.useCallback(R=>{window.parent!==window&&e.parentOrigin&&window.parent.postMessage(R,e.parentOrigin)},[e.parentOrigin]),F=h.useRef(null);h.useEffect(()=>{if(!e.instanceId)return;const R=ei({onProgress:x=>w(rs(e.instanceId,x))});F.current=R;const M=x=>R.handleScroll(x),_=x=>{var O;const Y=(O=x.detail)==null?void 0:O.scrollTop;typeof Y=="number"&&R.report(Y)};return document.addEventListener("scroll",M,{capture:!0,passive:!0}),window.addEventListener(Be,_),()=>{document.removeEventListener("scroll",M,{capture:!0}),window.removeEventListener(Be,_),R.dispose(),F.current=null}},[e.instanceId,w]);const L=h.useCallback((R,M,_,x)=>{e.instanceId&&e.parentOrigin&&window.parent!==window&&window.parent.postMessage(is(e.instanceId,R,M,_,x),e.parentOrigin)},[e.instanceId,e.parentOrigin]),z=h.useCallback((R,M,_,x)=>{t({phase:"error",code:R,message:M,recoverable:_,document:x}),w(ts(e.instanceId,R,M,_,x==null?void 0:x.id)),L("error",R,M,{recoverable:_,documentId:(x==null?void 0:x.id)??null})},[e.instanceId,w,L]);h.useEffect(()=>{if(!e.instanceId||!e.parentOrigin||e.parentOrigin==="*")return;const R=(_,x)=>{var Ae;const Y=_.payload.document,O=_.payload.session;if(s(he=>_.payload.theme??he),Zo(O)){w(zt(e.instanceId,_.messageId,"rejected","Session has expired.")),z("session-expired","The secure viewer session is missing or expired.",!0,Y);return}i(he=>_.payload.safeArea??(_.type==="viewer.init"?{}:he)),_.type==="viewer.init"&&((Ae=F.current)==null||Ae.setDistance(_.payload.scrollProgressDistance));const H=x??(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",_.type,"Viewer accepted a parent command.",{documentId:Y.id,format:Y.format}),t({phase:_.type==="viewer.init"?"initializing":"loading-document",document:Y,session:O,host:H}),w(zt(e.instanceId,_.messageId,"accepted"))},M=_=>{var Y;if(_.source!==window.parent)return;if(_.origin!==e.parentOrigin){z("origin-mismatch",`Rejected parent message from unexpected origin ${_.origin}.`,!1,ve(b.current));return}if(!Ar(_.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 x=_.data;if(x.instanceId===e.instanceId){if(x.type==="viewer.init"){R(x,x.payload.host);return}if(x.type==="viewer.go-to-page"){p(O=>({page:x.payload.page,nonce:((O==null?void 0:O.nonce)??0)+1}));return}if(x.type==="viewer.set-safe-area"){i(x.payload.safeArea);return}if(x.type==="viewer.set-theme"){const O=x.payload.theme;s(O),L("info","viewer.set-theme","Viewer updated theme without reloading the document.",{documentId:((Y=ve(b.current))==null?void 0:Y.id)??null,mode:O.mode});return}if(x.type==="viewer.widget-response"){E(O=>({nonce:((O==null?void 0:O.nonce)??0)+1,payloads:[...(O==null?void 0:O.payloads)??[],x.payload]}));return}if(x.type==="viewer.send-artifact-data"){const O=ve(b.current)??qe(b.current);if(!O||!Ie(O.format)){L("warn","artifact.data.ignored","Artifact runtime data was ignored because no HTML artifact is active.",{requestedDocumentId:x.payload.documentId??null});return}if(x.payload.documentId&&x.payload.documentId!==O.id){L("warn","artifact.data.mismatch","Artifact runtime data targeted a different document and was ignored.",{activeDocumentId:O.id,requestedDocumentId:x.payload.documentId});return}f(H=>({nonce:((H==null?void 0:H.nonce)??0)+1,data:x.payload.data}));return}if(x.type==="viewer.append-html"||x.type==="viewer.complete-html-stream"||x.type==="viewer.abort-html-stream"){const O=ve(b.current)??qe(b.current);if(!O||!Ie(O.format)||O.source.kind!=="stream"){L("warn","html.stream.ignored","HTML stream command was ignored because no stream HTML document is active.",{commandType:x.type,requestedDocumentId:x.payload.documentId??null});return}if(x.payload.documentId&&x.payload.documentId!==O.id){L("warn","html.stream.mismatch","HTML stream command targeted a different document and was ignored.",{activeDocumentId:O.id,requestedDocumentId:x.payload.documentId,commandType:x.type});return}m(H=>({nonce:((H==null?void 0:H.nonce)??0)+1,commands:[...(H==null?void 0:H.commands)??[],cs(x)]}));return}R(x)}};return window.addEventListener("message",M),t({phase:"waiting-for-init"}),w(Jo(e.instanceId)),L("info","viewer.ready","Viewer shell announced readiness."),()=>{window.removeEventListener("message",M)}},[e.instanceId,e.parentOrigin,z,w,L]);const V=h.useCallback(R=>{a(M=>({...M,pageCount:R==null?void 0:R.pageCount})),t(M=>M.phase!=="initializing"&&M.phase!=="loading-document"?M:(w(Qo(e.instanceId,M.document,{...S.current,...R})),L("info","document.loaded","Renderer finished loading the document.",{documentId:M.document.id,format:M.document.format,pageCount:(R==null?void 0:R.pageCount)??null}),{phase:"ready",document:M.document,session:M.session,host:M.host}))},[e.instanceId,w,L]),k=h.useCallback((R,M)=>{t(_=>{const x=ve(_)??(_.phase==="ready"?_.document:void 0);return x&&(w(es(e.instanceId,x,R,M)),L("warn",R,M,{documentId:x.id})),{phase:"unsupported",document:x,reason:R,message:M}})},[e.instanceId,w,L]),A=qe(n),d=A==null?void 0:A.id;h.useEffect(()=>{var R;(R=F.current)==null||R.reset()},[d]);const D=n.phase==="initializing"||n.phase==="loading-document"||n.phase==="ready"?n.session:void 0,P=h.useCallback((R,M,_)=>{z(R,M,_,A)},[A,z]),j=h.useCallback((R,M,_,x)=>{L(R,M,_,{documentId:(A==null?void 0:A.id)??null,format:(A==null?void 0:A.format)??null,...x})},[A,L]),W=h.useCallback((R,M)=>{w(ns(e.instanceId,R,M))},[e.instanceId,w]),G=h.useCallback((R,M)=>{A&&(w(os(e.instanceId,A,R,M)),L("info","artifact.event","HTML artifact emitted a runtime event.",{eventName:R,documentId:A.id}))},[e.instanceId,A,w,L]),J=h.useCallback(R=>{A&&(w(ss(e.instanceId,{documentId:A.id,...R})),L("info","widget.request","A widget asked its host.",{method:R.method,documentId:A.id}))},[e.instanceId,A,w,L]),oe=h.useCallback((R,M)=>{a(_=>({..._,currentPage:R,pageCount:M??_.pageCount})),w(as(e.instanceId,R,M)),L("info","page.changed","PDF page changed.",{page:R,pageCount:M??null})},[e.instanceId,w,L]);return v.jsx(Go,{state:n,theme:l,safeArea:o,currentDocument:A,session:D,pageNavigationRequest:c,artifactDataMessage:u,streamCommandMessage:g,onLoaded:V,onUnsupported:k,onError:P,onTelemetry:j,onResize:W,onPageChanged:oe,onArtifactEvent:G,onWidgetRequest:J,widgetResponseMessage:y})}const Ln=document.getElementById("root");if(!Ln)throw new Error("Root element not found");zn.createRoot(Ln).render(v.jsx(h.StrictMode,{children:v.jsx(us,{})}));export{jt as c};
|