vde-open 0.1.7 → 0.1.8

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.
@@ -92,7 +92,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
92
92
  `||/\s/.test(e[n-1]))){let r=e.indexOf(`
93
93
  `,n),i=r<0?e.length:r;t.push({start:n,end:i,className:`comment`}),n=i;continue}n++}return t}function BT(e){let t=[],n=/:\s*([^\n]*)/g,r;for(;r=n.exec(e);){let n=r[1],i=n.trimEnd();if(!i)continue;let a=r.index+r[0].indexOf(n),o=a+i.length,s=/\s+#/.exec(i);for(s&&(o=a+s.index);o>a&&/\s/.test(e[o-1]);)o--;o>a&&t.push({start:a,end:o,className:`string`})}return t}var VT=/(?:(?:\/\/|#)[ \t]*\[!code[ \t]+(\+\+|--)\]|\/\*[ \t]*\[!code[ \t]+(\+\+|--)\][ \t]*\*\/|<!--[ \t]*\[!code[ \t]+(\+\+|--)\][ \t]*-->)[ \t]*\r?$/;function HT(e){let t=[];if(!e.includes(`[!code`))return{code:e,decorations:t};let n=e.split(`
94
94
  `);for(let e=0;e<n.length;e++){let r=n[e],i=VT.exec(r);if(!i)continue;let a=i[1]||i[2]||i[3];t.push({className:a===`++`?`th-line--inserted`:`th-line--deleted`,lines:e+1}),n[e]=r.slice(0,i.index).replace(/[ \t]+$/,``)+(r.endsWith(`\r`)?`\r`:``)}return{code:n.join(`
95
- `),decorations:t}}function UT(e){return(t,n=`plaintext`,r={})=>{let i=HT(t),a=e.tokenize(i.code,{lang:n});for(let e of r.highlightLines||[])i.decorations.push({className:`th-line--highlighted`,lines:e});return Pw(Nw(a.tokens,{lineNumbers:r.lineNumbers,decorations:i.decorations}))}}var WT=262144,GT=Mw({languages:[wT,ET,FT,IT,TT,LT,lT,eT,jT,DT,AT]}),KT=new Set(GT.listLanguages()),qT=UT(GT),JT=(e,t,n)=>{let r=t?GT.normalizeLanguage(t):`plaintext`;return qT(e,KT.has(r)&&e.length<=WT?r:`plaintext`,n)};function YT(e){return e.closest(`[data-code-block]`)?.querySelector(`pre code`)?.textContent??``}function XT(e,t,n){function r({href:e,children:n,...r}){let i=gw(e);return i===`fragment`?(0,H.jsx)(`a`,{href:e,...r,children:n}):i===`external`?(0,H.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,...r,children:n}):i===`document`&&t&&e!==void 0?(0,H.jsx)(`button`,{type:`button`,"data-local-link":``,onClick:()=>t(e),children:n}):(0,H.jsx)(`span`,{children:n})}function i({src:t,alt:n,title:r}){let i=typeof t==`string`?e?.(t)??null:null;return i===null?(0,H.jsx)(`span`,{"data-blocked-image":``,children:n?`[image: ${n}]`:`[image]`}):(0,H.jsx)(`img`,{src:i,alt:n??``,title:r,loading:`lazy`,referrerPolicy:`no-referrer`})}function a({children:e,...t}){return n===void 0?(0,H.jsx)(`pre`,{...t,children:e}):(0,H.jsxs)(`div`,{"data-code-block":``,children:[(0,H.jsx)(`div`,{"data-code-actions":``,children:n}),(0,H.jsx)(`pre`,{...t,children:e})]})}return{a:r,img:i,pre:a}}function ZT({document:e,resolveImage:t,onOpenLink:n,codeActions:r}){let i=(0,D.useMemo)(()=>XT(t,n,r),[t,n,r]);return vw(e,{...mw,allowHtml:!1,highlighter:JT,components:i})}var QT=3e3;function $T(){let[e,t]=(0,D.useState)(null),[n,r]=(0,D.useState)(!1),i=(0,D.useRef)(null),a=(0,D.useRef)(0);return(0,D.useEffect)(()=>()=>{a.current+=1,i.current&&clearTimeout(i.current)},[]),{result:e,copy:(0,D.useCallback)(async(e,n)=>{let o=++a.current;i.current&&clearTimeout(i.current),r(!0);let s;try{if(typeof navigator.clipboard?.writeText!=`function`)throw Error(`This browser cannot write to the clipboard`);await navigator.clipboard.writeText(n),s={ok:!0,message:`Copied the ${e}.`}}catch(t){s={ok:!1,message:`Could not copy the ${e} (${t instanceof Error?t.message:`unknown reason`}).`}}o===a.current&&(r(!1),t(s),s.ok&&(i.current=setTimeout(()=>t(null),QT)))},[]),pending:n,dismiss:()=>t(null)}}function eE({label:e,text:t,icon:n=te,title:r,code:i=!1}){let{result:a,copy:o,pending:s,dismiss:c}=$T(),l=(0,D.useRef)(``),u=a?.ok===!1,d=u?P:a?.ok===!0?M:n;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(mx,{enabled:u,title:`Copy failed`,trigger:(0,H.jsxs)(lb,{variant:i?`outline`:`ghost`,size:i?`xs`:`icon-sm`,"aria-label":`Copy ${e}`,title:u?`${a.message} Click for details.`:r??`Copy ${e}`,disabled:s,className:u?`text-destructive`:void 0,"data-copy-state":u?`failed`:a?.ok===!0?`copied`:`idle`,onClick:n=>{u||(l.current=typeof t==`string`?t:t(n.currentTarget),o(e,l.current))},children:[(0,H.jsx)(d,{"aria-hidden":`true`}),i&&`Copy code`]}),children:[(0,H.jsx)(`p`,{children:a?.message}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(lb,{variant:`outline`,size:`sm`,disabled:s,onClick:()=>void o(e,l.current),children:`Try again`}),(0,H.jsx)(lb,{variant:`ghost`,size:`sm`,onClick:c,children:`Dismiss`})]})]}),(0,H.jsx)(`span`,{role:u?`alert`:`status`,className:`sr-only`,"data-testid":`copy-result`,children:a?.message})]})}function tE(){return(0,H.jsx)(H.Fragment,{children:`Scripts can load only the files registered for this document and cannot reach this app, its management API, or unregistered files. Some outbound requests, including navigation inside the view, are not blocked.`})}var nE={navigated:`View reloaded`,"request-closed":`Question closed`,expired:`Render permission expired`,replaced:`Draft connection ended`};function rE(e){return e.status===`connected`?`Drafts linked (not sent)`:e.status===`closed`?nE[e.reason]??`Invalid draft message`:null}function iE({mode:e,bridge:t,needsPermission:n,pinnedStatic:r,modeError:i,onRunScripts:a,onStopScripts:o,onReload:s}){let c=e===`interactive`,l=t.status===`closed`,u=rE(t);return(0,H.jsxs)(`div`,{className:`flex min-h-9 flex-wrap items-center gap-x-3 gap-y-1 border-b bg-muted/50 px-3 py-1 text-[0.8rem]`,"data-testid":`html-view-bar`,children:[(0,H.jsx)(`span`,{className:`font-medium`,children:`Document content`}),(0,H.jsx)(`span`,{className:`text-muted-foreground`,"data-testid":`html-mode`,children:c?`Scripts running`:r?`Scripts off for this question`:`Scripts off`}),n&&(0,H.jsx)(`span`,{className:`text-destructive`,children:`Permission cleared`}),u!==null&&(0,H.jsx)(`span`,{role:`status`,className:l?`text-destructive`:`text-muted-foreground`,"data-testid":`bridge-status`,children:u}),i&&(0,H.jsx)(`span`,{role:`alert`,className:`text-destructive`,children:`Script change failed`}),(0,H.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[l&&t.reason!==`request-closed`&&(0,H.jsx)(lb,{size:`xs`,variant:`ghost`,onClick:s,children:`Reload view`}),(0,H.jsx)(mx,{title:`Document view`,trigger:(0,H.jsxs)(lb,{size:`xs`,variant:`ghost`,children:[l||i?(0,H.jsx)(P,{"aria-hidden":`true`}):(0,H.jsx)(V,{"aria-hidden":`true`}),`Details`]}),children:(0,H.jsx)(aE,{mode:e,bridge:t,needsPermission:n,pinnedStatic:r,modeError:i,connection:u})}),c&&(0,H.jsx)(lb,{size:`xs`,variant:`ghost`,onClick:o,children:`Turn off scripts`}),n&&(0,H.jsx)(lb,{size:`xs`,variant:`outline`,onClick:a,children:`Run scripts…`})]})]})}function aE({mode:e,bridge:t,needsPermission:n,pinnedStatic:r,modeError:i,connection:a}){let o=e===`interactive`,s=t.status===`closed`;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`p`,{children:`Buttons and text inside the view belong to the opened document, rather than this app.`}),(0,H.jsx)(`p`,{children:`Links and form submission inside the view are disabled. Open links from “Links in this document”.`}),o?(0,H.jsx)(`p`,{children:(0,H.jsx)(tE,{})}):(0,H.jsx)(`p`,{children:`Scripts do not run in this view.`}),r&&(0,H.jsx)(`p`,{children:`This question was created in the Static view, so scripts stay off until it is answered.`}),n&&(0,H.jsx)(`p`,{children:`The permission to run scripts was cleared, for example by a daemon restart. Use “Run scripts…” to allow them again.`}),t.status===`connected`&&(0,H.jsx)(`p`,{children:`The document can read and replace draft answers. It cannot submit them. Only “Send answers to the agent” in the answer panel submits answers.`}),s&&(0,H.jsxs)(`p`,{children:[`Draft answers from this view are no longer accepted. `,a,`.`,` `,t.reason===`request-closed`?`Reloading cannot reopen the question.`:`Reload the view to reconnect.`]}),s&&!nE[t.reason]&&(0,H.jsx)(`p`,{children:`The document sent a message that breaks the rules, such as a malformed or oversized message or too many messages.`}),i&&(0,H.jsx)(`p`,{className:`text-destructive`,children:i})]})}function oE(e){return mh(e.defaultTagName??`div`,e,e)}var sE=sb(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function cE({className:e,variant:t=`default`,render:n,...r}){return oE({defaultTagName:`span`,props:eh({className:tb(sE({variant:t}),e)},r),render:n,state:{slot:`badge`,variant:t}})}var lE=D.createContext(void 0);function uE(){return D.useContext(lE)}var dE=D.forwardRef(function(e,t){let{className:n,defaultPressed:r=!1,disabled:i=!1,form:a,onPressedChange:o,pressed:s,render:c,type:l,value:u,nativeButton:d=!0,style:f,...p}=e,m=Fv(u||void 0),h=uE(),g=h?.value??[],_=(i||h?.disabled)??!1,[v,y]=hx({controlled:h?m!==void 0&&g.indexOf(m)>-1:s,default:r,name:`Toggle`,state:`pressed`}),{getButtonProps:b,buttonRef:x}=jv({disabled:_,native:d}),S={disabled:_,pressed:v},C=[x,t],w=[{"aria-pressed":v,onClick(e){let t=!v,n=$f(Gf,e.nativeEvent);o?.(t,n),!n.isCanceled&&(m&&h?.setGroupValue?.(m,t,n),!n.isCanceled&&y(t))}},p,b],T=mh(`button`,e,{enabled:!h,state:S,ref:C,props:w}),E=D.useMemo(()=>({disabled:_,focusableWhenDisabled:!1}),[_]);return h?(0,H.jsx)(cS,{tag:`button`,render:c,className:n,style:f,metadata:E,state:S,refs:C,props:w}):T}),fE=D.createContext(void 0);function pE(){return D.useContext(fE)}var mE=D.forwardRef(function(e,t){let{defaultValue:n,disabled:r=!1,loopFocus:i=!0,onValueChange:a,orientation:o=`horizontal`,multiple:s=!1,value:c,className:l,render:u,style:d,...f}=e,p=sx(!0),m=pE(),h=n??Pd,g=c!==void 0||n!==void 0,_=(p?.disabled??!1)||(m?.disabled??!1)||r,[v,y]=hx({controlled:c,default:h,name:`ToggleGroup`,state:`value`}),b=X((e,t,n)=>{let r;s?(r=v.slice(),t?r.push(e):r.splice(v.indexOf(e),1)):r=t?[e]:[],a?.(r,n),!n.isCanceled&&y(r)}),x={disabled:_,multiple:s,orientation:o},S=D.useMemo(()=>({disabled:_,setGroupValue:b,value:v,isValueInitialized:g}),[_,b,v,g]),C={role:`group`},w=mh(`div`,e,{enabled:!!p,state:x,ref:t,props:[C,f]});return(0,H.jsx)(lE.Provider,{value:S,children:p?w:(0,H.jsx)(DS,{render:u,className:l,style:d,state:x,refs:[t],props:[C,f],loopFocus:i,enableHomeAndEndKeys:!0,orientation:o})})}),hE=sb(`group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-transparent`,outline:`border border-input bg-transparent hover:bg-muted`},size:{default:`h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,sm:`h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`}},defaultVariants:{variant:`default`,size:`default`}}),gE=D.createContext({size:`default`,variant:`default`,spacing:2,orientation:`horizontal`});function _E({className:e,variant:t,size:n,spacing:r=2,orientation:i=`horizontal`,children:a,...o}){return(0,H.jsx)(mE,{"data-slot":`toggle-group`,"data-variant":t,"data-size":n,"data-spacing":r,"data-orientation":i,style:{"--gap":r},className:tb(`group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-vertical:flex-col data-vertical:items-stretch`,e),...o,children:(0,H.jsx)(gE.Provider,{value:{variant:t,size:n,spacing:r,orientation:i},children:a})})}function vE({className:e,children:t,variant:n=`default`,size:r=`default`,...i}){let a=D.useContext(gE);return(0,H.jsx)(dE,{"data-slot":`toggle-group-item`,"data-variant":a.variant||n,"data-size":a.size||r,"data-spacing":a.spacing,className:tb(`shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t`,hE({variant:a.variant||n,size:a.size||r}),e),...i,children:t})}var yE=(e,t)=>`${String(e)} ${t}${e===1?``:`s`}`,bE={"asset-scan-failed":()=>`Scanning the files this document references did not finish in time or exceeded the structure limits, so images and CSS were not registered. Run vo refresh <document ID> to scan again.`,"script-removed":(e,t)=>`Removed ${yE(t,`script`)}. Scripts do not run in this view, so content that scripts would create is not shown.`,"script-not-loaded":(e,t)=>`Removed ${yE(t,`script`)} that could not be loaded (referencing unregistered files or external URLs).`,"noscript-removed":(e,t)=>`Removed ${yE(t,`noscript element`)}. In the Interactive view, noscript content is not shown.`,"asset-requested":e=>`The view tried to load ${e}, but it is not registered, so it could not be loaded. Register it with vo open <document> --assets-root <dir> --asset ${e} to make it loadable (files that scripts load at run time are not registered automatically).`,"event-handler-removed":(e,t)=>`Removed event attributes such as onclick from ${yE(t,`element`)}.`,"embed-removed":(e,t)=>`Removed ${yE(t,`embedded element`)} (iframe, object, embed, and similar). Other pages and plugins cannot be embedded.`,"inline-svg-removed":(e,t)=>`Removed ${yE(t,`inline SVG`)}. Save the SVG as a file (.svg) and reference it with <img> to show it.`,"mathml-removed":(e,t)=>`Removed ${yE(t,`MathML element`)}.`,"meta-refresh-removed":()=>`Removed the automatic redirect (meta refresh).`,"base-removed":()=>`Removed the base element. Relative references resolve against the document location.`,"network-hint-removed":(e,t)=>`Removed ${yE(t,`resource hint`)} (prefetch, preconnect, and similar).`,"form-action-removed":()=>`Removed the form action. Form controls are display-only and cannot submit.`,"element-removed":(e,t)=>`Removed ${yE(t,`legacy element`)} that treats the rest of the document as text (such as plaintext).`,"media-blocked":e=>`Video and audio (${e}) cannot be shown.`,"remote-asset-blocked":e=>`External URL (${e}) is not loaded. Put the file under the document's directory and reference it with a relative path to show it.`,"asset-not-registered":e=>`${e} was not found. Make sure the file is under the assets-root used when the document was opened (the document's directory if none was given).`,"asset-rejected":e=>`${e} cannot be loaded. References outside the assets-root, file: URLs, and encoded separators are not allowed. To widen the range, reopen with vo open <document> --assets-root <dir>.`,"asset-hidden":e=>`${e} is not loaded. Files and directories whose names start with "." (such as .env and .git) cannot be referenced from documents.`,"asset-unsupported":e=>`${e} is a file type that cannot be used here. Allowed types are images (PNG, JPEG, WebP, GIF, AVIF, SVG), CSS, fonts (WOFF, WOFF2), and, in the Interactive view, scripts (.js, .mjs) and JSON registered with --asset.`,"data-url-blocked":e=>`data URL (${e}) cannot be used. Only PNG, JPEG, WebP, GIF, and AVIF images are allowed as data URLs.`,"css-invalid":e=>`${e===``?`The CSS in the document`:e} has parts that could not be parsed, and those parts were disabled.`,"link-disabled":(e,t)=>`Links in this document (${String(t)}) cannot be clicked inside the view. Open them from the "Links in this document" list.`};function xE(e){let t=bE[e.code],n=e.target??``;if(!t)return`${e.code}${n===``?``:`: ${n}`}`;let r=t(n,e.count);return e.target!==null&&e.count>1?`${r} (${String(e.count)} occurrences)`:r}function SE(e){if(!(e instanceof RS))return`Could not export the PDF.`;switch(e.code){case`E_BROWSER_NOT_FOUND`:return e.message;case`E_REVISION_UNAVAILABLE`:return`This revision is no longer kept. Show the latest revision and export again.`;case`E_PARSE_FAILED`:return`The document could not be prepared for printing (it is too large or too deeply nested).`;case`E_LIMIT_EXCEEDED`:return e.details.reason===`page-size`?`The document is too large to print (its images make the page too large).`:`Other PDF exports are still waiting. Try again after they finish.`;case`E_EXPORT_FAILED`:return e.details.reason===`timeout`?`The browser did not finish printing the PDF in time.`:`The browser could not print the PDF.`;default:return`Could not export the PDF. ${e.message}`}}var CE={exporting:!1,error:null};function wE(e,t){let n=URL.createObjectURL(e),r=window.document.createElement(`a`);r.href=n,r.download=t,window.document.body.append(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),6e4)}function TE(e=wE){let t=new Map,n=new Set,r=(e,r)=>{r===CE?t.delete(e):t.set(e,r);for(let e of n)e()};return{state:e=>t.get(e)??CE,subscribe(e){return n.add(e),()=>n.delete(e)},start(n,i,a){let{documentId:o}=i;t.get(o)?.exporting!==!0&&(r(o,{exporting:!0,error:null}),n.exportPdf(o,a).then(t=>{r(o,CE),e(t,Wu(i))},e=>{r(o,{exporting:!1,error:SE(e)})}))},dismiss(e){t.get(e)?.exporting===!1&&r(e,CE)}}}var EE=TE();function DE(e){return(0,D.useSyncExternalStore)(EE.subscribe,()=>EE.state(e))}function OE(e,t,n){let r=`vde-open.pref.${e}`,[i,a]=(0,D.useState)(()=>{try{let e=JSON.parse(window.localStorage.getItem(r)??`null`);return n(e)?e:t}catch{return t}});return[i,(0,D.useCallback)(e=>{a(e);try{window.localStorage.setItem(r,JSON.stringify(e))}catch{}},[r])]}var kE=e=>e===`light`||e===`dark`||e===`system`,AE=e=>e===`flat`||e===`tree`,jE=e=>e===`preview`||e===`source`,ME=1e3,NE=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null),PE=(e,t)=>Object.keys(e).every(e=>t.includes(e));function FE(e){try{let t=JSON.stringify(e);return t===void 0?null:Nu(t)}catch{return null}}function IE(e){return e instanceof RS?{code:e.code,message:e.message}:{code:`E_BRIDGE_FAILED`,message:`Could not handle the draft answer.`}}function LE(e){let{instanceId:t,port:n,handlers:r}=e,i=e.now??Date.now,a=!1,o=0,s=[],c=new Set,l=-1,u=0,d=null,f=e=>{if(a)return;let t=FE(e);if(t===null||t>Kl.bridgeOutboundFrameBytes){e.type===`response`&&n.postMessage({type:`response`,sequence:e.sequence,ok:!1,error:{code:`E_LIMIT_EXCEEDED`,message:`The response is too large.`}});return}n.postMessage(e)},p=(e,t)=>t.then(t=>f({type:`response`,sequence:e,ok:!0,result:t}),t=>f({type:`response`,sequence:e,ok:!1,error:IE(t)})),m=(e,t,n)=>f({type:`response`,sequence:e,ok:!1,error:{code:t,message:n}}),h=e=>{a||e.draftVersion<=l||c.has(e.draftVersion)||(l=e.draftVersion,f({type:`event`,method:`draftChanged`,payload:e}))},g=({sequence:e,method:t,payload:n})=>{if(t===`ready`){if(!PE(n,[])){m(e,`E_INVALID_ARGUMENT`,`ready takes no arguments.`);return}p(e,r.ready().then(e=>(l=Math.max(l,e.draftVersion),e)));return}if(t===`updateDraft`){let{answers:t,baseDraftVersion:i}=n;if(!PE(n,[`answers`,`baseDraftVersion`])||!NE(t)||typeof i!=`number`||!Number.isSafeInteger(i)||i<0){m(e,`E_INVALID_ARGUMENT`,`updateDraft requires a draft-answer object and baseDraftVersion.`);return}let a=FE(t);if(a===null||a>Kl.answerBytes){m(e,`E_LIMIT_EXCEEDED`,`The draft answer is too large.`);return}if(Object.hasOwn(t,`__proto__`)||!ju.safeParse(t).success){m(e,`E_ANSWER_INVALID`,`Draft answer values must be strings, finite numbers, booleans, or arrays of strings, keyed by field name.`);return}u+=1,p(e,r.updateDraft(t,i).then(e=>(c.add(e.draftVersion),l=Math.max(l,e.draftVersion),e)).finally(()=>{if(--u,u===0&&d!==null){let e=d;d=null,h(e)}}));return}m(e,`E_METHOD_NOT_ALLOWED`,`${t.slice(0,64)} cannot be called from HTML.`)},_={get closed(){return a},notifyDraft(e){if(!a){if(u>0){d=e;return}h(e)}},close(t){if(!a){try{n.postMessage({type:`closed`,reason:t})}catch{}a=!0,n.removeEventListener(`message`,v),n.close(),e.onClose?.(t)}}};function v(e){if(a)return;let n=i();if(s=s.filter(e=>n-e<ME),s.push(n),s.length>Kl.bridgeMessagesPerSecond){_.close(`rate`);return}let r=e.data,c=FE(r);if(c===null){_.close(`malformed`);return}if(c>Kl.bridgeInboundFrameBytes){_.close(`too-large`);return}if(!NE(r)||r.protocolVersion!==1||typeof r.sequence!=`number`||!Number.isSafeInteger(r.sequence)||typeof r.method!=`string`||!NE(r.payload)){_.close(`malformed`);return}if(r.instanceId!==t){_.close(`instance`);return}if(r.sequence<=o){_.close(`sequence`);return}o=r.sequence,g({sequence:r.sequence,method:r.method,payload:r.payload})}return n.addEventListener(`message`,v),n.start(),_}var RE=(e,t)=>typeof e==`object`&&!!e&&e.type===`vde-bridge-hello`&&e.protocolVersion===1&&e.instanceId===t;function zE(e,t,n,r,i){let a=n?.bridge?.instanceId??null,o=n?.bridge?.requestId??null,s=n?.grant??null,c=n?.documentUrl??null,[l,u]=(0,D.useState)(null),d=(0,D.useRef)(null);return(0,D.useEffect)(()=>{if(a===null||o===null||s===null)return;let n=t.current,r=i.current?.url===c?i.current.count:0,l=r>1,f=null,p=e=>u({instanceId:a,status:{status:`closed`,reason:e}}),m=t=>{let r=n?.contentWindow;if(!r||t.source!==r||!RE(t.data,a)||l)return;l=!0;let i=new MessageChannel,o=async e=>{try{return await e}catch(e){throw e instanceof RS&&e.code===`E_RENDER_GRANT_INVALID`&&setTimeout(()=>f?.close(`expired`),0),e}};f=LE({instanceId:a,port:i.port1,handlers:{async ready(){let t=await o(e.bridgeReady(s));return{protocolVersion:1,requestId:t.requestId,documentId:t.documentId,revision:t.revision,questionnaire:t.questionnaire,draftVersion:t.draftVersion,answers:t.draftAnswers}},updateDraft:(t,n)=>o(e.bridgeDraft(s,n,t))},onClose:p}),d.current=f,r.postMessage({type:et,instanceId:a},`*`,[i.port2]),u({instanceId:a,status:{status:`connected`}})},h=()=>{r+=1,!(r<2)&&(l=!0,f?f.close(`navigated`):p(`navigated`))};return window.addEventListener(`message`,m),n?.addEventListener(`load`,h),()=>{window.removeEventListener(`message`,m),n?.removeEventListener(`load`,h),f?.close(`replaced`),d.current=null}},[e,t,a,o,s,c,i]),(0,D.useEffect)(()=>{let t=d.current;if(t===null||r===null||r.requestId!==o||s===null)return;if(r.status!==`pending`){t.close(`request-closed`);return}let n=!1;return e.bridgeReady(s).then(e=>{n||e.status!==`pending`||t.notifyDraft({answers:e.draftAnswers,draftVersion:e.draftVersion})},e=>{e instanceof RS&&e.code===`E_RENDER_GRANT_INVALID`&&t.close(`expired`)}),()=>{n=!0}},[e,r,o,s]),a===null?{status:`none`}:i.current?.url===c&&i.current.count>1?{status:`closed`,reason:`navigated`}:l?.instanceId===a?l.status:{status:`waiting`}}var BE=2e3;function VE(e){let[t,n]=(0,D.useState)(null);return(0,D.useEffect)(()=>{if(e===null)return;let t=new Worker(new URL(`/assets/markdown.worker-BhrAVXtB.js`,``+import.meta.url),{type:`module`}),r=r=>{clearTimeout(i),t.terminate(),n({source:e,state:r})},i=setTimeout(()=>r({status:`failed`,reason:`timeout`}),BE);return t.addEventListener(`message`,e=>{r(e.data.ok?{status:`ready`,document:e.data.document}:{status:`failed`,reason:e.data.reason})}),t.addEventListener(`error`,()=>r({status:`failed`,reason:`parse-error`})),t.postMessage({id:1,source:e}),()=>{clearTimeout(i),t.terminate()}},[e]),t!==null&&t.source===e?t.state:{status:`parsing`}}function HE(e,t,n){let[r,i]=(0,D.useState)(null);return(0,D.useEffect)(()=>{if(t===null)return;let r=!1;return e.renderMissing(t).then(e=>{r||i({grant:t,fetchedFor:n,missing:e})},()=>void 0),()=>{r=!0}},[e,t,n]),r!==null&&r.grant===t?r.missing:[]}function UE(e,t){return e===null||e.state.status===`ready`&&e.state.grant.diagnostics.some(e=>e.code===`asset-scan-failed`)?t:e.updatedAt}function WE(e,t){return{release:e.filter(e=>e!==t),keep:e.filter(e=>e===t)}}var GE={mode:`static`,requestId:null,nonce:0};function KE(e,t,n,r,i=GE){let{mode:a,requestId:o,nonce:s}=i,[c,l]=(0,D.useState)(null),u=(0,D.useRef)(null),d=(0,D.useRef)([]),f=`${t}\n${n??``}\n${a}\n${o??``}\n${String(s)}`,p=c!==null&&c.key===f?c:null,m=UE(p,r),h=p?.state.status===`ready`?p.state.grant.grant:null;return(0,D.useEffect)(()=>{let r=()=>{u.current!==null&&d.current.push(u.current.grant),u.current=null};if(n===null){r();return}let i=!1;return(o===null?e.renderGrant(t,n,{mode:a}):e.feedbackRenderGrant(o)).then(t=>{if(i){e.releaseGrants([t.grant]).catch(()=>void 0);return}r(),u.current={key:f,grant:t.grant},l({key:f,updatedAt:m,state:{status:`ready`,grant:t}})},e=>{if(!i){if(u.current?.key===f){l(e=>e!==null&&e.key===f?{...e,updatedAt:m}:e);return}r(),l({key:f,updatedAt:m,state:{status:`failed`,message:e instanceof Error?e.message:`Could not prepare the view.`}})}}),()=>{i=!0}},[e,t,n,a,o,f,m]),(0,D.useEffect)(()=>{let{release:t,keep:n}=WE(d.current,h);t.length!==0&&(d.current=n,e.releaseGrants(t).catch(()=>void 0))}),(0,D.useEffect)(()=>()=>{let t=d.current.splice(0);u.current!==null&&t.push(u.current.grant),u.current=null,t.length>0&&e.releaseGrants(t).catch(()=>void 0)},[e]),p?.state??{status:`loading`}}var qE=160,JE=480,YE=240,XE=e=>typeof e==`number`&&Number.isInteger(e)&&e>=qE&&e<=JE,ZE={timeout:`Parsing did not finish within 2 seconds, so the source is shown.`,"limit-nodes":`The document has more than 100,000 elements, so the source is shown.`,"limit-depth":`The document is nested deeper than 64 levels, so the source is shown.`,"parse-error":`The document could not be parsed, so the source is shown.`},QE={missing:`The file was not found. Showing the last content that could be read.`,unreadable:`No permission to read the file. Showing the last content that could be read.`,error:`The file cannot be read as a document. Showing the last content that could be read.`};function $E(e,t){if(e===null)return null;for(let n of e.querySelectorAll(`[id]`))if(n.id===t)return n;return null}function eD({api:e,document:t,fixedRevision:n=null,request:r=null,renderSignal:i=0,waitingForRequest:a=!1,sectionTarget:o=null,restoreHeading:s=null,onHeadingShown:c,displayed:l=!0,onReady:u}){let[d,f]=OE(`view-mode`,`preview`,jE),[p,m]=OE(`outline-width`,YE,XE),h=(0,D.useId)(),g=(0,D.useRef)(null),[_,v]=(0,D.useState)(0),y=(0,D.useRef)(null),b=Math.max(qE,Math.min(JE,_-248)),x=Math.min(p,b);(0,D.useLayoutEffect)(()=>{let e=g.current;if(!e)return;let t=()=>v(e.clientWidth);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let S=e=>{m(Math.round(Math.min(b,Math.max(qE,e))))},C=e=>{e.button===0&&e.isPrimary&&(e.preventDefault(),e.currentTarget.focus(),y.current={pointerId:e.pointerId,x:e.clientX,width:x},e.currentTarget.setPointerCapture(e.pointerId))},w=e=>{let t=y.current;t&&t.pointerId===e.pointerId&&e.currentTarget.hasPointerCapture(e.pointerId)&&S(t.width+t.x-e.clientX)},[T,E]=(0,D.useState)(null),O=T!==null,k=n!==null,A=a?null:n??T??t.revision,[j,ee]=(0,D.useState)(null),[M,N]=(0,D.useState)(null),[F,te]=(0,D.useState)(null),[I,L]=(0,D.useState)(null),R=(0,D.useRef)(null),re=(0,D.useRef)(0);(0,D.useEffect)(()=>{if(A===null)return;let n=!1;return re.current=R.current?.scrollTop??0,Promise.all([e.content(t.documentId,A),e.outline(t.documentId,A).then(e=>({items:e,error:null}),e=>({items:[],error:e instanceof Error?e.message:`Could not be fetched.`}))]).then(([e,t])=>{n||(ee({revision:A,text:e,outline:t.items,outlineError:t.error}),N(null))},e=>{n||N({revision:A,message:e instanceof Error?e.message:`Could not be loaded.`})}),()=>{n=!0}},[e,t.documentId,A]);let ie=j?.text??null,ae=j?.outline??[],z=j?.outlineError??null,oe=M!==null&&M.revision===A?M.message:null,se=t.format===`markdown`,ce=d===`preview`,le=VE(se&&ce?ie:null),ue=n!==null&&r?.status===`pending`&&r.revision===n?r.requestId:null,B=ue!==null&&r?.renderMode===`static`,de=!se&&t.htmlMode===`interactive`&&t.interactiveAllowed,[fe,pe]=(0,D.useState)(0),he=KE(e,t.documentId,A,t.updatedAt,{mode:de?`interactive`:`static`,requestId:ue,nonce:fe}),V=he.status===`ready`?he.grant:null,ge=HE(e,V?.grant??null,i),[_e,ve]=(0,D.useState)(!1),[ye,be]=(0,D.useState)(null),xe=DE(t.documentId),Se=n=>{ve(!1),be(null),e.setHtmlMode(t.documentId,n).catch(e=>be(e instanceof Error?e.message:`Could not change the view mode.`))},Ce=se&&ce&&le.status===`ready`,we=!se&&ce?V?.documentUrl??null:null,Ee=(0,D.useRef)(null),Oe=(0,D.useRef)(null),[Ae,je]=(0,D.useState)(null),Me=zE(e,Ee,l&&we!==null?V:null,r,Oe),Ne=ie!==null&&(!ce||(se?le.status===`failed`||le.status===`ready`&&he.status!==`loading`:he.status===`failed`)),Pe=!a&&(A===null||(we===null?oe!==null||Ne:Ae===we)),Fe=(0,D.useCallback)(e=>{e!==null&&Pe&&u?.()},[Pe,u]);(0,D.useLayoutEffect)(()=>{R.current&&(ie!==null||Ce)&&(R.current.scrollTop=re.current)},[ie,Ce]);let Ie=(0,D.useMemo)(()=>{if(!V)return;let e=new Set(V.assets.filter(e=>e.role===`image`||e.role===`svg`).map(e=>e.logicalPath));return t=>{let n=_w(t,V.documentLogicalPath);return n===null||!e.has(n)?null:`${V.filesBaseUrl}${sw(n)}`}},[V]),Le=(0,D.useCallback)(async(n,r,i)=>{L(null);try{await e.openLink(t.documentId,r,n,i),te(null)}catch(e){if(e instanceof RS&&e.code===`E_CONFIRMATION_REQUIRED`){te({linkId:n,revision:r,path:String(e.details.path??``),confirmation:String(e.details.confirmation??``),changed:e.details.changed===!0});return}te(null),L({linkId:n,revision:r,message:e instanceof Error?e.message:`Could not open the link.`})}},[e,t.documentId]),Re=(0,D.useCallback)(e=>{let t=V?.links.find(t=>t.href===e);V&&t?.kind===`document`&&Le(t.linkId,V.revision)},[V,Le]),ze=(0,D.useMemo)(()=>(0,H.jsx)(eE,{code:!0,label:`code`,text:YT}),[]),Be=O&&!k&&t.revision!==A,Ve=(0,D.useMemo)(()=>new Map(V?.headingTargets.map(e=>[e.sectionId,e.anchor])??[]),[V]),He=Ce?null:we===null?se?`Available in the Markdown preview`:`Available in the HTML preview`:V?.mode===`static`?j?.revision===V.revision?null:`Available once the outline of the shown revision has loaded`:`Not available in the Interactive view (jumping reloads the view and restarts its scripts)`,Ue=e=>He===null&&(Ce||Ve.get(e.sectionId)===e.anchor),We=(0,D.useCallback)(e=>{if(Ce){$E(R.current,e.anchor)?.scrollIntoView({block:`start`});return}we!==null&&Ee.current?.contentWindow?.location.replace(`${we}#${hw(e.anchor)}`)},[Ce,we]),Ge=o?.nonce??0,[Ke,qe]=(0,D.useState)(0),Je=o!==null&&A!==null&&j?.revision===A,Ye=Je&&o.revision===A,Xe=Ye&&Ce?ae.find(e=>e.sectionId===o.sectionId)??null:null,Ze=o===null||Ge===Ke?null:Je?Ye?Ce?null:`This view does not jump to sections (only the Markdown preview does).`:k?`The search result is in a different revision than the one shown. The view is showing the question's revision while awaiting an answer, so it did not jump.`:O?`The search result is in a different revision than the one shown. Updates are paused, so the view did not jump.`:`The document was updated after the search, so the view did not jump to the section. Search again.`:oe===null?null:`The revision to show could not be loaded, so the view did not jump to the section.`;(0,D.useEffect)(()=>{Xe!==null&&Ge!==0&&(We(Xe),c?.({sectionId:Xe.sectionId,title:Xe.title}))},[Xe,Ge,We,c]);let Qe=s!==null&&He===null&&A!==null&&j?.revision===A&&z===null,et=Qe?ae.find(e=>e.sectionId===s.sectionId&&e.title===s.title)??ae.find(e=>e.title===s.title)??null:null,tt=et!==null&&Ue(et),nt=s?.id??null,rt=(0,D.useRef)(null);(0,D.useEffect)(()=>{if(Qe&&nt!==null&&rt.current!==nt){if(rt.current=nt,et===null||!tt){c?.(null);return}We(et),c?.({sectionId:et.sectionId,title:et.title})}},[Qe,nt,et,tt,We,c]);let it=[...V?.diagnostics??[],...ge.map(e=>({code:`asset-requested`,target:e,count:1}))],at=V?.mode??`static`,ot=se?[]:V?.links??[],st=[...Ze?[{label:`Section not reached`,message:Ze,dismiss:()=>qe(Ge),testId:`section-target-notice`}]:[],...t.sourceState!==`ready`&&QE[t.sourceState]?[{label:t.sourceState===`missing`?`File missing`:`File unreadable`,message:QE[t.sourceState]}]:[],...!se&&ce&&he.status===`failed`?[{label:`Showing source`,message:`The HTML could not be converted for display, so the source is shown (${he.message}).`}]:[],...se&&ce&&le.status===`failed`?[{label:`Showing source`,message:ZE[le.reason]??ZE[`parse-error`]}]:[],...oe?[{label:`Could not load document`,message:oe}]:[],...se&&I?[{label:`Could not open link`,message:I.message,dismiss:()=>L(null)}]:[],...we===null&&ye?[{label:`Script change failed`,message:ye,dismiss:()=>be(null)}]:[]];return(0,H.jsxs)(`section`,{ref:Fe,className:`flex h-full min-h-0 min-w-0 flex-1 flex-col`,"aria-label":`Document view`,children:[(0,H.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-b px-4 py-2`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1 basis-56`,children:[(0,H.jsx)(`h1`,{className:`truncate text-base font-semibold`,children:t.title}),(0,H.jsxs)(`p`,{className:`text-xs [overflow-wrap:anywhere] text-muted-foreground`,title:t.canonicalPath??void 0,"data-testid":`document-location`,children:[(0,H.jsx)($e,{document:t}),A&&(0,H.jsxs)(`span`,{title:A,children:[` · Revision `,A.slice(4,12)]})]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[t.displayPath!==null&&(0,H.jsx)(eE,{label:`document path`,text:t.displayPath}),(0,H.jsx)(eE,{label:`document ID`,text:t.documentId,icon:me,title:`Copy document ID (${t.documentId})`})]}),(0,H.jsx)(cE,{variant:`outline`,children:se?`Markdown`:`HTML`}),k?(0,H.jsx)(cE,{variant:`secondary`,children:`Showing the question's revision`}):O&&(Be?(0,H.jsxs)(mx,{title:`A newer revision is available`,trigger:(0,H.jsxs)(lb,{variant:`ghost`,size:`xs`,children:[(0,H.jsx)(P,{"aria-hidden":`true`}),`Update available`]}),children:[(0,H.jsx)(`p`,{children:`Updates are paused. The view stays on the revision from when they were paused.`}),(0,H.jsx)(lb,{size:`sm`,variant:`outline`,onClick:()=>E(null),children:`Resume updates`})]}):(0,H.jsx)(cE,{variant:`secondary`,children:`Updates paused`})),(0,H.jsxs)(_E,{value:[d],onValueChange:e=>{let t=e[0];jE(t)&&(t===`preview`&&d!==`preview`&&!se&&pe(e=>e+1),f(t))},size:`sm`,"aria-label":`View`,children:[(0,H.jsx)(vE,{value:`preview`,children:`Preview`}),(0,H.jsx)(vE,{value:`source`,children:`Source`})]}),(0,H.jsxs)(lb,{variant:`outline`,size:`sm`,"aria-pressed":O,disabled:k,title:k?`A question is awaiting an answer, so the question's revision is shown`:void 0,onClick:()=>E(O?null:t.revision),children:[O?(0,H.jsx)(De,{"aria-hidden":`true`}):(0,H.jsx)(Te,{"aria-hidden":`true`}),O?`Resume updates`:`Pause updates`]}),(0,H.jsxs)(lb,{variant:`ghost`,size:`sm`,onClick:()=>void e.refresh(t.documentId).catch(()=>void 0),children:[(0,H.jsx)(ke,{"aria-hidden":`true`}),`Refresh`]}),se&&(0,H.jsxs)(mx,{title:`PDF export failed`,enabled:xe.error!==null,trigger:(0,H.jsxs)(lb,{variant:`ghost`,size:`sm`,disabled:xe.exporting||j===null,onClick:()=>{xe.error===null&&j!==null&&EE.start(e,t,j.revision)},children:[xe.error?(0,H.jsx)(P,{"aria-hidden":`true`,className:`text-destructive`}):(0,H.jsx)(ne,{"aria-hidden":`true`}),(0,H.jsxs)(`span`,{className:`inline-grid`,children:[(0,H.jsx)(`span`,{className:`invisible col-start-1 row-start-1`,"aria-hidden":`true`,children:`Export PDF`}),(0,H.jsx)(`span`,{className:`invisible col-start-1 row-start-1`,"aria-hidden":`true`,children:`Exporting…`}),(0,H.jsx)(`span`,{className:`col-start-1 row-start-1`,children:xe.exporting?`Exporting…`:`Export PDF`})]})]}),children:[(0,H.jsx)(`p`,{children:xe.error}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(lb,{size:`sm`,variant:`outline`,onClick:()=>{j&&EE.start(e,t,j.revision)},children:`Try again`}),(0,H.jsx)(lb,{size:`sm`,variant:`ghost`,onClick:()=>EE.dismiss(t.documentId),children:`Dismiss`})]})]})]}),(xe.error||I)&&(0,H.jsxs)(`span`,{role:`alert`,className:`sr-only`,children:[xe.error,I?.message]}),st.length>0&&(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 border-b px-3 py-1`,"data-testid":`document-notices`,children:[st.map(e=>(0,H.jsxs)(mx,{title:e.label,trigger:(0,H.jsxs)(lb,{variant:`ghost`,size:`xs`,className:`text-destructive`,"data-testid":`testId`in e?e.testId:void 0,children:[(0,H.jsx)(P,{"aria-hidden":`true`}),e.label]}),children:[(0,H.jsx)(`p`,{children:e.message}),`dismiss`in e&&(0,H.jsx)(lb,{variant:`outline`,size:`sm`,onClick:e.dismiss,children:`Dismiss`})]},e.label)),(0,H.jsx)(`span`,{role:`status`,className:`sr-only`,children:st.map(e=>e.message).join(` `)})]}),(it.length>0||ot.length>0)&&(0,H.jsxs)(`div`,{className:`flex flex-col border-b text-sm`,children:[it.length>0&&(0,H.jsxs)(`details`,{className:`px-4 py-2`,"data-testid":`render-diagnostics`,children:[(0,H.jsxs)(`summary`,{className:`cursor-pointer`,children:[`Differences from the original document (`,it.length,` kinds)`]}),(0,H.jsx)(`ul`,{className:`mt-2 flex max-h-40 list-disc flex-col gap-1 overflow-y-auto pl-5 text-muted-foreground`,children:it.map(e=>(0,H.jsx)(`li`,{className:`break-words`,children:xE(e)},`${e.code}:${e.target??``}`))})]}),ot.length>0&&(0,H.jsxs)(`details`,{className:`border-t px-4 py-2 first:border-t-0`,"data-testid":`render-links`,children:[(0,H.jsxs)(`summary`,{className:`cursor-pointer`,children:[`Links in this document (`,ot.length,`)`]}),(0,H.jsx)(`ul`,{className:`mt-2 flex max-h-40 flex-col gap-1 overflow-y-auto`,children:ot.map(e=>(0,H.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[e.kind===`external`&&(0,H.jsx)(`a`,{className:`underline underline-offset-2`,href:e.href,target:`_blank`,rel:`noopener noreferrer`,children:e.text||e.href}),e.kind===`document`&&(0,H.jsxs)(mx,{title:`Could not open link`,enabled:I?.linkId===e.linkId,trigger:(0,H.jsxs)(lb,{variant:`link`,size:`xs`,className:`h-auto p-0`,onClick:()=>{V&&I?.linkId!==e.linkId&&Le(e.linkId,V.revision)},children:[I?.linkId===e.linkId&&(0,H.jsx)(P,{"aria-hidden":`true`,className:`text-destructive`}),e.text||e.href]}),children:[(0,H.jsx)(`p`,{children:I?.message}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(lb,{size:`sm`,variant:`outline`,onClick:()=>{I&&Le(I.linkId,I.revision)},children:`Try again`}),(0,H.jsx)(lb,{size:`sm`,variant:`ghost`,onClick:()=>L(null),children:`Dismiss`})]})]}),e.kind===`other`&&(0,H.jsx)(`span`,{children:e.text||e.href}),(0,H.jsxs)(`span`,{className:`text-xs break-all text-muted-foreground`,children:[e.href,e.kind===`other`&&` (this kind of link cannot be opened)`]})]},e.linkId))})]})]}),(0,H.jsxs)(`div`,{ref:g,className:`flex min-h-0 min-w-0 flex-1`,children:[we?(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,H.jsx)(iE,{mode:at,bridge:Me,pinnedStatic:B,needsPermission:t.htmlMode===`interactive`&&!t.interactiveAllowed&&!B,modeError:ye,onRunScripts:()=>ve(!0),onStopScripts:()=>Se(`static`),onReload:()=>pe(e=>e+1)}),(0,H.jsx)(`iframe`,{ref:Ee,title:`View of ${t.title}`,src:we,onLoad:()=>{let e=Oe.current;Oe.current={url:we,count:e?.url===we?e.count+1:1},je(we)},sandbox:at===`interactive`?`allow-scripts`:``,referrerPolicy:`no-referrer`,className:`min-h-0 w-full flex-1 border-0 bg-white`,"data-testid":`document-frame`},we)]}):(0,H.jsx)(`div`,{ref:R,className:`min-w-0 flex-1 overflow-y-auto px-6 py-5`,"data-testid":`document-body`,children:ie===null?(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:oe===null?`Loading…`:`Could not load this document.`}):Ce?(0,H.jsx)(`article`,{className:`markdown-body mx-auto max-w-3xl`,children:(0,H.jsx)(ZT,{document:le.document,...Ie?{resolveImage:Ie}:{},onOpenLink:Re,codeActions:ze})}):ce&&(se?le.status===`parsing`:he.status===`loading`)?(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Preparing the view…`}):(0,H.jsx)(`pre`,{className:`font-mono text-sm leading-relaxed break-words whitespace-pre-wrap`,children:ie})}),(ae.length>0||z!==null)&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize outline`,"aria-controls":h,"aria-valuemin":qE,"aria-valuemax":b,"aria-valuenow":x,tabIndex:0,className:`relative hidden w-2 shrink-0 touch-none cursor-col-resize before:absolute before:inset-y-0 before:left-1/2 before:w-px before:bg-border hover:bg-muted hover:before:bg-primary/60 focus-visible:bg-primary/10 focus-visible:before:bg-primary focus-visible:outline-none active:bg-primary/10 active:before:bg-primary lg:block`,onPointerDown:C,onPointerMove:w,onLostPointerCapture:()=>{y.current=null},onKeyDown:e=>{let t=e.key===`ArrowLeft`?x+16:e.key===`ArrowRight`?x-16:e.key===`Home`?qE:e.key===`End`?b:null;t!==null&&(e.preventDefault(),S(t))}}),(0,H.jsxs)(`aside`,{id:h,style:{width:x},className:`hidden shrink-0 overflow-y-auto px-3 py-4 lg:block`,"aria-label":`Outline`,children:[(0,H.jsx)(`h2`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:`Outline`}),z!==null&&(0,H.jsxs)(`p`,{className:`text-xs text-destructive`,role:`alert`,children:[`Could not fetch the outline (`,z,`).`]}),(0,H.jsx)(`ul`,{className:`flex flex-col gap-0.5 text-sm`,children:ae.map(e=>{let t=Ue(e);return(0,H.jsx)(`li`,{style:{paddingLeft:`${String((e.level-1)*.75)}rem`},children:(0,H.jsx)(`button`,{type:`button`,className:`w-full truncate rounded px-2 py-1 text-left hover:bg-muted disabled:opacity-50`,disabled:!t,title:t?e.title:He??`This heading is not in the view (removed from the display, or an earlier element has the same id)`,onClick:()=>{We(e),c?.({sectionId:e.sectionId,title:e.title})},children:e.title})},e.sectionId)})})]})]})]}),(0,H.jsx)(ub,{open:_e,onOpenChange:ve,children:(0,H.jsxs)(pb,{children:[(0,H.jsxs)(mb,{children:[(0,H.jsx)(gb,{children:`Run the scripts in this document?`}),(0,H.jsxs)(_b,{children:[`This runs the scripts in this HTML inside your browser. `,(0,H.jsx)(tE,{}),` This is not a mechanism for running arbitrary scripts safely. Enable it only for trusted HTML that you or your agent prepared.`]})]}),(0,H.jsxs)(hb,{children:[(0,H.jsx)(yb,{children:`Back`}),(0,H.jsx)(vb,{onClick:()=>Se(`interactive`),children:`Run scripts`})]})]})}),(0,H.jsx)(ub,{open:F!==null,onOpenChange:e=>{e||te(null)},children:(0,H.jsxs)(pb,{children:[(0,H.jsxs)(mb,{children:[(0,H.jsx)(gb,{children:`Add this document to the list and open it?`}),(0,H.jsx)(_b,{className:`break-all`,children:F?.path})]}),F?.changed&&(0,H.jsx)(`p`,{className:`text-sm font-medium`,children:`While you were confirming, the link target changed or the confirmation expired. Check the path above again.`}),(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This is the file that a link in the document points to. It is not open yet. Opening it adds it to the document list and to search.`}),(0,H.jsxs)(hb,{children:[(0,H.jsx)(yb,{children:`Don't open`}),(0,H.jsx)(vb,{onClick:()=>{F&&Le(F.linkId,F.revision,F.confirmation)},children:`Add to list and open`})]})]})})]})}function tD(e,t,n,r){let[i,a]=(0,D.useState)(null),[o,s]=(0,D.useState)(0),c=(0,D.useCallback)(()=>s(e=>e+1),[]),l=`${String(n)}\n${r??``}\n${String(o)}`;(0,D.useEffect)(()=>{if(t===null)return;let n=!1;return e.feedback(t).then(e=>{n||a({requestId:t,fetchedFor:l,request:e,error:null})},e=>{n||a(n=>({requestId:t,fetchedFor:l,request:n?.requestId===t?n.request:null,error:e instanceof Error?e.message:`Could not fetch the question.`}))}),()=>{n=!0}},[e,t,l]);let u=i!==null&&i.requestId===t?i:null;return{request:u?.request??null,error:u?.error??null,reload:c}}function nD({documents:e,...t}){let[n,r]=(0,D.useState)(t.document.documentId),i=e.find(e=>e.documentId===n),a=i!==void 0&&i.documentId!==t.document.documentId,o=a?[i,t.document]:[t.document],s=(0,D.useCallback)(()=>r(t.document.documentId),[t.document.documentId]);return(0,H.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1`,"aria-busy":a,children:o.map(e=>{let n=e.documentId===t.document.documentId,r=!a||!n;return(0,H.jsx)(`div`,{className:r?`flex min-h-0 min-w-0 flex-1`:`invisible absolute inset-0 flex min-h-0 min-w-0`,"aria-hidden":!r,inert:a,"data-testid":`document-workspace`,children:(0,H.jsx)(rD,{...t,document:e,displayed:r,onReady:n?s:void 0,sectionTarget:n&&r?t.sectionTarget:null,restoreHeading:n&&r?t.restoreHeading:null,onHeadingShown:n&&r?t.onHeadingShown:void 0})},e.documentId)})})}function rD({api:e,document:t,feedbackSignal:n,renderSignal:r,sectionTarget:i=null,restoreHeading:a=null,onHeadingShown:o,displayed:s=!0,onReady:c}){let l=t.pendingRequestIds[0]??null,[u,d]=(0,D.useState)(l);l!==null&&l!==u&&d(l);let f=l??u,{request:p,error:m,reload:h}=tD(e,f,n,t.revision),g=p?.status===`pending`?p.revision:null;return(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col min-[900px]:flex-row`,children:[(0,H.jsx)(eD,{api:e,document:t,fixedRevision:g,request:p,renderSignal:r,waitingForRequest:l!==null&&p===null&&m===null,sectionTarget:i,restoreHeading:a,displayed:s,...c?{onReady:c}:{},...o?{onHeadingShown:o}:{}}),p?(0,H.jsx)(nC,{api:e,request:p,reload:h},p.requestId):m!==null&&f!==null&&(0,H.jsx)(`aside`,{"aria-label":`Answer the question`,className:`w-full shrink-0 border-t px-4 py-4 min-[900px]:w-96 min-[900px]:border-t-0 min-[900px]:border-l`,children:(0,H.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Could not fetch the question (`,m,`).`]})})]})}var iD=d_(function(e){return wv(`dialog`,e)});function aD({...e}){return(0,H.jsx)(iD,{"data-slot":`dialog`,...e})}function oD({...e}){return(0,H.jsx)(ry,{"data-slot":`dialog-portal`,...e})}function sD({className:e,...t}){return(0,H.jsx)(Ev,{"data-slot":`dialog-overlay`,className:tb(`fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function cD({className:e,children:t,showCloseButton:n=!0,...r}){return(0,H.jsxs)(oD,{children:[(0,H.jsx)(sD,{}),(0,H.jsxs)(ey,{"data-slot":`dialog-content`,className:tb(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:[t,n&&(0,H.jsxs)(Pv,{"data-slot":`dialog-close`,render:(0,H.jsx)(lb,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`}),children:[(0,H.jsx)(Fe,{}),(0,H.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function lD({className:e,...t}){return(0,H.jsx)(`div`,{"data-slot":`dialog-header`,className:tb(`flex flex-col gap-2`,e),...t})}function uD({className:e,...t}){return(0,H.jsx)(iy,{"data-slot":`dialog-title`,className:tb(`font-heading text-base leading-none font-medium`,e),...t})}function dD({className:e,...t}){return(0,H.jsx)(Iv,{"data-slot":`dialog-description`,className:tb(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}var fD=200,pD=20;function mD({api:e,open:t,onOpenChange:n,onSelect:r}){let[i,a]=(0,D.useState)(``),[o,s]=(0,D.useState)(null),[c,l]=(0,D.useState)(0),u=(0,D.useId)(),d=i.trim();(0,D.useEffect)(()=>{if(!t||d===``)return;let n=!1,r=setTimeout(()=>{e.search(d,pD).then(e=>{n||s({query:d,result:e,error:null})},e=>{n||s({query:d,result:null,error:e instanceof Error?e.message:`Search failed.`})})},fD);return()=>{n=!0,clearTimeout(r)}},[e,t,d]);let f=o!==null&&o.query===d?o:null,p=f?.result?.hits??[],m=e=>Math.max(0,Math.min(e,p.length-1)),h=m(c);(0,D.useEffect)(()=>{p.length!==0&&window.document.getElementById(`${u}-${String(h)}`)?.scrollIntoView?.({block:`nearest`})},[h,p.length,u]);let g=e=>{e&&(n(!1),r(e))};return(0,H.jsx)(aD,{open:t,onOpenChange:e=>{n(e),e||(a(``),l(0))},children:(0,H.jsxs)(cD,{className:`top-[15%] translate-y-0 sm:max-w-xl`,children:[(0,H.jsxs)(lD,{children:[(0,H.jsx)(uD,{children:`Search open documents`}),(0,H.jsx)(dD,{children:`Only documents that are currently open are searched. Closed documents and other files are not.`})]}),(0,H.jsx)(Qx,{"aria-label":`Search query`,"aria-controls":u,"aria-activedescendant":p.length>0?`${u}-${String(h)}`:void 0,placeholder:`Words or a file name`,value:i,onChange:e=>{a(e.target.value),l(0)},onKeyDown:e=>{e.nativeEvent.isComposing||p.length!==0&&(e.key===`ArrowDown`?(e.preventDefault(),l(e=>m(m(e)+1))):e.key===`ArrowUp`?(e.preventDefault(),l(e=>m(m(e)-1))):e.key===`Enter`&&(e.preventDefault(),g(p[h])))}}),(0,H.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`text-xs text-muted-foreground`,children:d===``?`Type to search the open documents. Use ↑↓ to select and Enter to jump.`:f===null?`Searching…`:f.error===null?`${String(p.length)} ${p.length===1?`result`:`results`}${f.result?.incomplete===!0?` (some documents are not indexed yet, so not all documents were searched)`:``}`:`Search failed (${f.error}).`}),(0,H.jsx)(`div`,{id:u,role:`listbox`,"aria-label":`Search results`,className:`flex max-h-80 flex-col gap-1 overflow-y-auto`,children:p.map((e,t)=>(0,H.jsxs)(`div`,{id:`${u}-${String(t)}`,role:`option`,"aria-selected":t===h,className:`cursor-pointer rounded-md px-3 py-2 text-sm aria-selected:bg-muted`,tabIndex:-1,onMouseEnter:()=>l(t),onClick:()=>g(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),g(e))},children:[(0,H.jsxs)(`p`,{className:`truncate font-medium`,children:[e.title,e.headingPath.length>0&&(0,H.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[` `,`— `,e.headingPath.join(` › `)]})]}),(0,H.jsx)(`p`,{className:`line-clamp-2 text-xs text-muted-foreground`,children:e.excerpt}),e.displayPath&&(0,H.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:e.displayPath})]},`${e.documentId}:${e.sectionId}`))})]})})}var hD=Symbol.for(`preact-signals`);function gD(){if(SD>1)SD--;else{var e,t=!1;for((function(){var e=ED;for(ED=void 0;e!==void 0;){var t=e.S;if(t.v===e.v)for(var n=t.t;n!==void 0;n=n.x)n.i===e.i&&(n.i=t.i);e=e.o}})();xD!==void 0;){var n=xD;for(xD=void 0,CD++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&jD(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(CD=0,SD--,t)throw e}}function _D(e){if(SD>0)return e();TD=++wD,SD++;try{return e()}finally{gD()}}var vD,yD=void 0;function bD(e){var t=yD,n=vD;yD=void 0,vD=void 0;try{return e()}finally{yD=t,vD=n}}var xD=void 0,SD=0,CD=0,wD=0,TD=0,ED=void 0,DD=0;function OD(e){if(yD!==void 0){var t=e.n;if(t===void 0||t.t!==yD)return t={i:0,S:e,p:yD.s,n:void 0,t:yD,e:void 0,x:void 0,r:t},yD.s!==void 0&&(yD.s.n=t),yD.s=t,e.n=t,32&yD.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=yD.s,t.n=void 0,yD.s.n=t,yD.s=t),t}}function kD(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}kD.prototype.brand=hD,kD.prototype.h=function(){return!0},kD.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n===void 0?bD(function(){var e;(e=t.W)==null||e.call(t)}):n.e=e)},kD.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&bD(function(){var e;(e=t.Z)==null||e.call(t)}))}},kD.prototype.subscribe=function(e){var t=this;return BD(function(){var n=t.value;bD(function(){return e(n)})},{name:`sub`})},kD.prototype.valueOf=function(){return this.value},kD.prototype.toString=function(){return this.value+``},kD.prototype.toJSON=function(){return this.value},kD.prototype.peek=function(){var e=this;return bD(function(){return e.value})},Object.defineProperty(kD.prototype,"value",{get:function(){var e=OD(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(CD>100)throw Error(`Cycle detected`);(function(e){SD!==0&&CD===0&&e.l!==TD&&(e.l=TD,ED={S:e,v:e.v,i:e.i,o:ED})})(this),this.v=e,this.i++,DD++,SD++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{gD()}}}});function AD(e,t){return new kD(e,t)}function jD(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function MD(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function ND(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function PD(e,t){kD.call(this,void 0,t),this.x=e,this.s=void 0,this.g=DD-1,this.f=4}PD.prototype=new kD,PD.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===DD))return!0;if(this.g=DD,this.f|=1,this.i>0&&!jD(this))return this.f&=-2,!0;var e=yD;try{MD(this),yD=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return yD=e,ND(this),this.f&=-2,!0},PD.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}kD.prototype.S.call(this,e)},PD.prototype.U=function(e){if(this.t!==void 0&&(kD.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}},PD.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(PD.prototype,"value",{get:function(){if(1&this.f)throw Error(`Cycle detected`);var e=OD(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function FD(e,t){return new PD(e,t)}function ID(e){var t=e.m;if(e.m=void 0,typeof t==`function`){SD++;var n=yD;yD=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,LD(e),t}finally{yD=n,gD()}}}function LD(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,ID(e)}function RD(e){if(yD!==this)throw Error(`Out-of-order effect`);ND(this),yD=e,this.f&=-2,8&this.f&&LD(this),gD()}function zD(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,vD&&vD.push(this)}zD.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t==`function`&&(this.m=t)}finally{e()}},zD.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,ID(this),MD(this),SD++;var e=yD;return yD=this,RD.bind(this,e)},zD.prototype.N=function(){2&this.f||(this.f|=2,this.u=xD,xD=this)},zD.prototype.d=function(){this.f|=8,1&this.f||LD(this)},zD.prototype.dispose=function(){this.d()};function BD(e,t){var n=new zD(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var VD=Object.create,HD=Object.defineProperty,UD=Object.defineProperties,WD=Object.getOwnPropertyDescriptor,GD=Object.getOwnPropertyDescriptors,KD=Object.getOwnPropertySymbols,qD=Object.prototype.hasOwnProperty,JD=Object.prototype.propertyIsEnumerable,YD=(e,t)=>(t=Symbol[e])?t:Symbol.for(`Symbol.`+e),XD=e=>{throw TypeError(e)},ZD=(e,t,n)=>t in e?HD(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,QD=(e,t)=>{for(var n in t||={})qD.call(t,n)&&ZD(e,n,t[n]);if(KD)for(var n of KD(t))JD.call(t,n)&&ZD(e,n,t[n]);return e},$D=(e,t)=>UD(e,GD(t)),eO=(e,t)=>HD(e,`name`,{value:t,configurable:!0}),tO=e=>[,,,VD(e?.[YD(`metadata`)]??null)],nO=[`class`,`method`,`getter`,`setter`,`accessor`,`field`,`value`,`get`,`set`],rO=e=>e!==void 0&&typeof e!=`function`?XD(`Function expected`):e,iO=(e,t,n,r,i)=>({kind:nO[e],name:t,metadata:r,addInitializer:e=>n._?XD(`Already initialized`):i.push(rO(e||null))}),aO=(e,t)=>ZD(t,YD(`metadata`),e[3]),oO=(e,t,n,r)=>{for(var i=0,a=e[t>>1],o=a&&a.length;i<o;i++)t&1?a[i].call(n):r=a[i].call(n,r);return r},sO=(e,t,n,r,i,a)=>{var o,s,c,l,u,d=t&7,f=!!(t&8),p=!!(t&16),m=d>3?e.length+1:d?f?1:2:0,h=nO[d+5],g=d>3&&(e[m-1]=[]),_=e[m]||(e[m]=[]),v=d&&(!p&&!f&&(i=i.prototype),d<5&&(d>3||!p)&&WD(d<4?i:{get[n](){return uO(this,a)},set[n](e){return fO(this,a,e)}},n));d?p&&d<4&&eO(a,(d>2?`set `:d>1?`get `:``)+n):eO(i,n);for(var y=r.length-1;y>=0;y--)l=iO(d,n,c={},e[3],_),d&&(l.static=f,l.private=p,u=l.access={has:p?e=>lO(i,e):e=>n in e},d^3&&(u.get=p?e=>(d^1?uO:pO)(e,i,d^4?a:v.get):e=>e[n]),d>2&&(u.set=p?(e,t)=>fO(e,i,t,d^4?a:v.set):(e,t)=>e[n]=t)),s=(0,r[y])(d?d<4?p?a:v[h]:d>4?void 0:{get:v.get,set:v.set}:i,l),c._=1,d^4||s===void 0?rO(s)&&(d>4?g.unshift(s):d?p?a=s:v[h]=s:i=s):typeof s!=`object`||!s?XD(`Object expected`):(rO(o=s.get)&&(v.get=o),rO(o=s.set)&&(v.set=o),rO(o=s.init)&&g.unshift(o));return d||aO(e,i),v&&HD(i,n,v),p?d^4?a:v:i},cO=(e,t,n)=>t.has(e)||XD(`Cannot `+n),lO=(e,t)=>Object(t)===t?e.has(t):XD(`Cannot use the "in" operator on this value`),uO=(e,t,n)=>(cO(e,t,`read from private field`),n?n.call(e):t.get(e)),dO=(e,t,n)=>t.has(e)?XD(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),fO=(e,t,n,r)=>(cO(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n),pO=(e,t,n)=>(cO(e,t,`access private method`),n);function mO(e,t){if(t){let n;return FD(()=>{let r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return FD(e)}function hO(e,t){if(Object.is(e,t))return!0;if(e===null||t===null)return!1;if(typeof e==`function`&&typeof t==`function`)return e===t;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:!e.some((e,n)=>!hO(e,t[n]));if(typeof e==`object`&&typeof t==`object`){let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&!n.some(n=>!hO(e[n],t[n]))}return!1}function gO({get:e},t){return{init(e){return AD(e)},get(){return e.call(this).value},set(t){let n=e.call(this);n.peek()!==t&&(n.value=t)}}}function _O(e,t){let n=new WeakMap;return function(){let t=n.get(this);return t||(t=mO(e.bind(this)),n.set(this,t)),t.value}}function vO(e=!0){return function(t,n){n.addInitializer(function(){let t=n.kind===`field`||n.static?this:Object.getPrototypeOf(this),r=Object.getOwnPropertyDescriptor(t,n.name);r&&Object.defineProperty(t,n.name,$D(QD({},r),{enumerable:e}))})}}function yO(...e){let t=e.map(e=>BD(e));return()=>t.forEach(e=>e())}var bO,xO,SO,CO,wO,TO=[gO],EO,DO,OO,kO,AO,jO,MO,NO,PO,FO,IO,LO,RO,zO;wO=[gO],CO=[gO],SO=[vO()],xO=[vO()],bO=[vO()];var BO=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,oO(EO,5,this),dO(this,jO),dO(this,DO,oO(EO,8,this)),oO(EO,11,this),dO(this,MO,oO(EO,12,this)),oO(EO,15,this),dO(this,IO,oO(EO,16,this)),oO(EO,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return uO(this,jO,RO)}get initial(){return uO(this,jO,kO)}get previous(){return uO(this,jO,PO)}set current(e){let t=bD(()=>uO(this,jO,RO));e&&t&&this.equals(t,e)||_D(()=>{uO(this,jO,kO)||fO(this,jO,e,AO),fO(this,jO,t,FO),fO(this,jO,e,zO)})}reset(e=this.defaultValue){_D(()=>{fO(this,jO,void 0,FO),fO(this,jO,e,AO),fO(this,jO,e,zO)})}};EO=tO(null),DO=new WeakMap,jO=new WeakSet,MO=new WeakMap,IO=new WeakMap,OO=sO(EO,20,`#initial`,TO,jO,DO),kO=OO.get,AO=OO.set,NO=sO(EO,20,`#previous`,wO,jO,MO),PO=NO.get,FO=NO.set,LO=sO(EO,20,`#current`,CO,jO,IO),RO=LO.get,zO=LO.set,sO(EO,2,`current`,SO,BO),sO(EO,2,`initial`,xO,BO),sO(EO,2,`previous`,bO,BO),aO(EO,BO);function VO(e){return bD(()=>{let t={};for(let n in e)t[n]=e[n];return t})}var HO,UO=class{constructor(){dO(this,HO,new WeakMap)}get(e,t){return e?uO(this,HO).get(e)?.get(t):void 0}set(e,t,n){if(e)return uO(this,HO).has(e)||uO(this,HO).set(e,new Map),uO(this,HO).get(e)?.set(t,n)}clear(e){return e?uO(this,HO).get(e)?.clear():void 0}};HO=new WeakMap;var WO=Object.create,GO=Object.defineProperty,KO=Object.getOwnPropertyDescriptor,qO=Object.getOwnPropertySymbols,JO=Object.prototype.hasOwnProperty,YO=Object.prototype.propertyIsEnumerable,XO=(e,t)=>(t=Symbol[e])?t:Symbol.for(`Symbol.`+e),ZO=e=>{throw TypeError(e)},QO=Math.pow,$O=(e,t,n)=>t in e?GO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ek=(e,t)=>{for(var n in t||={})JO.call(t,n)&&$O(e,n,t[n]);if(qO)for(var n of qO(t))YO.call(t,n)&&$O(e,n,t[n]);return e},tk=(e,t)=>GO(e,`name`,{value:t,configurable:!0}),nk=e=>[,,,WO(e?.[XO(`metadata`)]??null)],rk=[`class`,`method`,`getter`,`setter`,`accessor`,`field`,`value`,`get`,`set`],ik=e=>e!==void 0&&typeof e!=`function`?ZO(`Function expected`):e,ak=(e,t,n,r,i)=>({kind:rk[e],name:t,metadata:r,addInitializer:e=>n._?ZO(`Already initialized`):i.push(ik(e||null))}),ok=(e,t)=>$O(t,XO(`metadata`),e[3]),sk=(e,t,n,r)=>{for(var i=0,a=e[t>>1],o=a&&a.length;i<o;i++)t&1?a[i].call(n):r=a[i].call(n,r);return r},ck=(e,t,n,r,i,a)=>{var o,s,c,l,u,d=t&7,f=!!(t&8),p=!!(t&16),m=d>3?e.length+1:d?f?1:2:0,h=rk[d+5],g=d>3&&(e[m-1]=[]),_=e[m]||(e[m]=[]),v=d&&(!p&&!f&&(i=i.prototype),d<5&&(d>3||!p)&&KO(d<4?i:{get[n](){return dk(this,a)},set[n](e){return pk(this,a,e)}},n));d?p&&d<4&&tk(a,(d>2?`set `:d>1?`get `:``)+n):tk(i,n);for(var y=r.length-1;y>=0;y--)l=ak(d,n,c={},e[3],_),d&&(l.static=f,l.private=p,u=l.access={has:p?e=>uk(i,e):e=>n in e},d^3&&(u.get=p?e=>(d^1?dk:mk)(e,i,d^4?a:v.get):e=>e[n]),d>2&&(u.set=p?(e,t)=>pk(e,i,t,d^4?a:v.set):(e,t)=>e[n]=t)),s=(0,r[y])(d?d<4?p?a:v[h]:d>4?void 0:{get:v.get,set:v.set}:i,l),c._=1,d^4||s===void 0?ik(s)&&(d>4?g.unshift(s):d?p?a=s:v[h]=s:i=s):typeof s!=`object`||!s?ZO(`Object expected`):(ik(o=s.get)&&(v.get=o),ik(o=s.set)&&(v.set=o),ik(o=s.init)&&g.unshift(o));return d||ok(e,i),v&&GO(i,n,v),p?d^4?a:v:i},lk=(e,t,n)=>t.has(e)||ZO(`Cannot `+n),uk=(e,t)=>Object(t)===t?e.has(t):ZO(`Cannot use the "in" operator on this value`),dk=(e,t,n)=>(lk(e,t,`read from private field`),n?n.call(e):t.get(e)),fk=(e,t,n)=>t.has(e)?ZO(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),pk=(e,t,n,r)=>(lk(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n),mk=(e,t,n)=>(lk(e,t,`access private method`),n),hk=class e{constructor(e,t){this.x=e,this.y=t}static delta(t,n){return new e(t.x-n.x,t.y-n.y)}static distance(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}static equals(e,t){return e.x===t.x&&e.y===t.y}static from({x:t,y:n}){return new e(t,n)}},gk=class e{constructor(e,t,n,r){this.left=e,this.top=t,this.width=n,this.height=r,this.scale={x:1,y:1}}get inverseScale(){return{x:1/this.scale.x,y:1/this.scale.y}}translate(t,n){let{top:r,left:i,width:a,height:o,scale:s}=this,c=new e(i+t,r+n,a,o);return c.scale=ek({},s),c}get boundingRectangle(){let{width:e,height:t,left:n,top:r,right:i,bottom:a}=this;return{width:e,height:t,left:n,top:r,right:i,bottom:a}}get center(){let{left:e,top:t,right:n,bottom:r}=this;return new hk((e+n)/2,(t+r)/2)}get area(){let{width:e,height:t}=this;return e*t}equals(t){if(!(t instanceof e))return!1;let{left:n,top:r,width:i,height:a}=this;return n===t.left&&r===t.top&&i===t.width&&a===t.height}containsPoint(e){let{top:t,left:n,bottom:r,right:i}=this;return t<=e.y&&e.y<=r&&n<=e.x&&e.x<=i}intersectionArea(t){return t instanceof e?_k(this,t):0}intersectionRatio(e){let{area:t}=this,n=this.intersectionArea(e);return n/(e.area+t-n)}get bottom(){let{top:e,height:t}=this;return e+t}get right(){let{left:e,width:t}=this;return e+t}get aspectRatio(){let{width:e,height:t}=this;return e/t}get corners(){return[{x:this.left,y:this.top},{x:this.right,y:this.top},{x:this.left,y:this.bottom},{x:this.right,y:this.bottom}]}static from({top:t,left:n,width:r,height:i}){return new e(n,t,r,i)}static delta(e,t,n={x:`center`,y:`center`}){let r=(e,t)=>{let r=n[t],i=t===`x`?e.left:e.top,a=t===`x`?e.width:e.height;return r==`start`?i:r==`end`?i+a:i+a/2};return hk.delta({x:r(e,`x`),y:r(e,`y`)},{x:r(t,`x`),y:r(t,`y`)})}static intersectionRatio(t,n){return e.from(t).intersectionRatio(e.from(n))}};function _k(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;return r<i&&n<a?o*s:0}var vk,yk,bk,xk,Sk,Ck=class extends (bk=BO,yk=[_O],vk=[_O],bk){constructor(e){let t=hk.from(e);super(t,(e,t)=>hk.equals(e,t)),sk(Sk,5,this),fk(this,xk,0),this.velocity={x:0,y:0}}get delta(){return hk.delta(this.current,this.initial)}get direction(){let{current:e,previous:t}=this;if(!t)return null;let n={x:e.x-t.x,y:e.y-t.y};return!n.x&&!n.y?null:Math.abs(n.x)>Math.abs(n.y)?n.x>0?`right`:`left`:n.y>0?`down`:`up`}get current(){return super.current}set current(e){let{current:t}=this,n=hk.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),a=i-dk(this,xk),o=e=>Math.round(e/a*100);_D(()=>{pk(this,xk,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(hk.from(e)),this.velocity={x:0,y:0}}};Sk=nk(bk),xk=new WeakMap,ck(Sk,2,`delta`,yk,Ck),ck(Sk,2,`direction`,vk,Ck),ok(Sk,Ck);function wk({x:e,y:t},n){let r=Math.abs(e),i=Math.abs(t);return typeof n==`number`?Math.sqrt(QO(r,2)+QO(i,2))>n:`x`in n&&`y`in n?r>n.x&&i>n.y:`x`in n?r>n.x:`y`in n&&i>n.y}var Tk=(e=>(e.Horizontal=`x`,e.Vertical=`y`,e))(Tk||{}),Ek=Object.values(Tk),Dk=Object.create,Ok=Object.defineProperty,kk=Object.defineProperties,Ak=Object.getOwnPropertyDescriptor,jk=Object.getOwnPropertyDescriptors,Mk=Object.getOwnPropertySymbols,Nk=Object.prototype.hasOwnProperty,Pk=Object.prototype.propertyIsEnumerable,Fk=(e,t)=>(t=Symbol[e])?t:Symbol.for(`Symbol.`+e),Ik=e=>{throw TypeError(e)},Lk=(e,t,n)=>t in e?Ok(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Rk=(e,t)=>{for(var n in t||={})Nk.call(t,n)&&Lk(e,n,t[n]);if(Mk)for(var n of Mk(t))Pk.call(t,n)&&Lk(e,n,t[n]);return e},zk=(e,t)=>kk(e,jk(t)),Bk=(e,t)=>Ok(e,`name`,{value:t,configurable:!0}),Vk=(e,t)=>{var n={};for(var r in e)Nk.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Mk)for(var r of Mk(e))t.indexOf(r)<0&&Pk.call(e,r)&&(n[r]=e[r]);return n},Hk=e=>[,,,Dk(e?.[Fk(`metadata`)]??null)],Uk=[`class`,`method`,`getter`,`setter`,`accessor`,`field`,`value`,`get`,`set`],Wk=e=>e!==void 0&&typeof e!=`function`?Ik(`Function expected`):e,Gk=(e,t,n,r,i)=>({kind:Uk[e],name:t,metadata:r,addInitializer:e=>n._?Ik(`Already initialized`):i.push(Wk(e||null))}),Kk=(e,t)=>Lk(t,Fk(`metadata`),e[3]),qk=(e,t,n,r)=>{for(var i=0,a=e[t>>1],o=a&&a.length;i<o;i++)t&1?a[i].call(n):r=a[i].call(n,r);return r},Jk=(e,t,n,r,i,a)=>{var o,s,c,l,u,d=t&7,f=!!(t&8),p=!!(t&16),m=d>3?e.length+1:d?f?1:2:0,h=Uk[d+5],g=d>3&&(e[m-1]=[]),_=e[m]||(e[m]=[]),v=d&&(!p&&!f&&(i=i.prototype),d<5&&(d>3||!p)&&Ak(d<4?i:{get[n](){return Zk(this,a)},set[n](e){return $k(this,a,e)}},n));d?p&&d<4&&Bk(a,(d>2?`set `:d>1?`get `:``)+n):Bk(i,n);for(var y=r.length-1;y>=0;y--)l=Gk(d,n,c={},e[3],_),d&&(l.static=f,l.private=p,u=l.access={has:p?e=>Xk(i,e):e=>n in e},d^3&&(u.get=p?e=>(d^1?Zk:eA)(e,i,d^4?a:v.get):e=>e[n]),d>2&&(u.set=p?(e,t)=>$k(e,i,t,d^4?a:v.set):(e,t)=>e[n]=t)),s=(0,r[y])(d?d<4?p?a:v[h]:d>4?void 0:{get:v.get,set:v.set}:i,l),c._=1,d^4||s===void 0?Wk(s)&&(d>4?g.unshift(s):d?p?a=s:v[h]=s:i=s):typeof s!=`object`||!s?Ik(`Object expected`):(Wk(o=s.get)&&(v.get=o),Wk(o=s.set)&&(v.set=o),Wk(o=s.init)&&g.unshift(o));return d||Kk(e,i),v&&Ok(i,n,v),p?d^4?a:v:i},Yk=(e,t,n)=>t.has(e)||Ik(`Cannot `+n),Xk=(e,t)=>Object(t)===t?e.has(t):Ik(`Cannot use the "in" operator on this value`),Zk=(e,t,n)=>(Yk(e,t,`read from private field`),n?n.call(e):t.get(e)),Qk=(e,t,n)=>t.has(e)?Ik(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),$k=(e,t,n,r)=>(Yk(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n),eA=(e,t,n)=>(Yk(e,t,`access private method`),n);function tA(e,t){return{plugin:e,options:t}}function nA(e){return t=>tA(e,t)}function rA(e){return typeof e==`function`?{plugin:e,options:void 0}:e}var iA=[gO],aA,oA,sA,cA=class{constructor(e,t){this.manager=e,this.options=t,Qk(this,oA,qk(aA,8,this,!1)),qk(aA,11,this),Qk(this,sA,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return bD(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){let t=BD(e.bind(this));return Zk(this,sA).add(t),t}destroy(){Zk(this,sA).forEach(e=>e())}static configure(e){return tA(this,e)}};aA=Hk(null),oA=new WeakMap,sA=new WeakMap,Jk(aA,4,`disabled`,iA,cA,oA),Kk(aA,cA);var lA=class extends cA{},uA,dA=class{constructor(e){this.manager=e,this.instances=new Map,Qk(this,uA,[])}get values(){return Array.from(this.instances.values())}set values(e){let t=e.map(rA).reduce((e,t)=>{let n=e.find(({plugin:e})=>e===t.plugin);return n?(n.options=t.options,e):[...e,t]},[]),n=t.map(({plugin:e})=>e);for(let e of Zk(this,uA))if(!n.includes(e)){if(e.prototype instanceof lA)continue;this.unregister(e)}for(let{plugin:e,options:n}of t)this.register(e,n);$k(this,uA,n)}get(e){return this.instances.get(e)}register(e,t){let n=this.instances.get(e);if(n)return n.options!==t&&(n.options=t),n;let r=new e(this.manager,t);return this.instances.set(e,r),r}unregister(e){let t=this.instances.get(e);t&&(t.destroy(),this.instances.delete(e))}destroy(){for(let e of this.instances.values())e.destroy();this.instances.clear()}};uA=new WeakMap;function fA(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var pA=[],mA,hA,gA=class extends cA{constructor(e){super(e),Qk(this,mA),Qk(this,hA),this.computeCollisions=this.computeCollisions.bind(this),$k(this,hA,AD(pA)),this.destroy=yO(()=>{let e=this.computeCollisions(),t=bD(()=>this.manager.dragOperation.position.current);if(e!==pA){let e=Zk(this,mA);if($k(this,mA,t),e&&t.x==e.x&&t.y==e.y)return}else $k(this,mA,void 0);Zk(this,hA).value=e},()=>{let{dragOperation:e}=this.manager;e.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){bD(()=>{e?Zk(this,hA).value=this.computeCollisions():$k(this,mA,void 0)})}computeCollisions(e,t){let{registry:n,dragOperation:r}=this.manager,{source:i,shape:a,status:o}=r;if(!o.initialized||!a)return pA;let s=[],c=[];for(let a of e??n.droppables){if(a.disabled||i&&!a.accepts(i))continue;let e=t??a.collisionDetector;if(!e)continue;c.push(a),a.shape;let n=bD(()=>e({droppable:a,dragOperation:r}));n&&(a.collisionPriority!=null&&(n.priority=a.collisionPriority),s.push(n))}return c.length===0?pA:(s.sort(fA),s)}get collisions(){return Zk(this,hA).value}};mA=new WeakMap,hA=new WeakMap;var _A,vA,yA=[gO],bA,xA,SA,CA,wA,TA,EA;vA=[gO],_A=[gO];var DA=class e{constructor(e,t){Qk(this,CA,qk(SA,8,this)),qk(SA,11,this),Qk(this,wA),Qk(this,TA,qk(SA,12,this)),qk(SA,15,this),Qk(this,EA,qk(SA,16,this)),qk(SA,19,this);let{effects:n,id:r,data:i={},disabled:a=!1,register:o=!0}=e,s=r;$k(this,wA,AD(r)),this.manager=t,this.data=i,this.disabled=a,this.effects=()=>[()=>{let{id:e,manager:t}=this;if(e!==s)return s=e,t?.registry.register(this),()=>t?.registry.unregister(this)},...n?.()??[]],this.register=this.register.bind(this),this.unregister=this.unregister.bind(this),this.destroy=this.destroy.bind(this),t&&o&&queueMicrotask(this.register)}get id(){let t=Zk(this,wA).value;return e.pendingIdChanges?.get(this)??t}set id(t){t!==(e.pendingIdChanges?.get(this)??Zk(this,wA).peek())&&(e.pendingIdChanges||(e.pendingIdChanges=new Map,queueMicrotask(()=>{var t;return eA(t=e,bA,xA).call(t)})),e.pendingIdChanges.set(this,t))}register(){return this.manager?.registry.register(this)}unregister(){var e;(e=this.manager)==null||e.registry.unregister(this)}destroy(){var e;(e=this.manager)==null||e.registry.unregister(this)}};SA=Hk(null),bA=new WeakSet,xA=function(){let e=DA.pendingIdChanges;DA.pendingIdChanges=null,e&&_D(()=>{for(let[t,n]of e)Zk(t,wA).value=n})},CA=new WeakMap,wA=new WeakMap,TA=new WeakMap,EA=new WeakMap,Jk(SA,4,`manager`,yA,DA,CA),Jk(SA,4,`data`,vA,DA,TA),Jk(SA,4,`disabled`,_A,DA,EA),Qk(DA,bA),Kk(SA,DA),DA.pendingIdChanges=null;var OA=DA,kA=class{constructor(){this.map=AD(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,t)=>{let n=this.map.peek(),r=n.get(e),i=()=>this.unregister(e,t);if(r===t)return i;r&&r.id===e&&(this.cleanupFunctions.get(r)?.(),this.cleanupFunctions.delete(r));let a=new Map(n);for(let[r,i]of n)if(i===t&&r!==e){a.delete(r);break}a.set(e,t),this.map.value=a;let o=yO(...t.effects());return this.cleanupFunctions.set(t,o),i},this.unregister=(e,t)=>{let n=this.map.peek();if(n.get(e)!==t)return;this.cleanupFunctions.get(t)?.(),this.cleanupFunctions.delete(t);let r=new Map(n);r.delete(e),this.map.value=r}}[Symbol.iterator](){return this.map.peek().values()}get value(){return this.map.value.values()}has(e){return this.map.value.has(e)}get(e){return this.map.value.get(e)}destroy(){for(let e of this)this.cleanupFunctions.get(e)?.(),e.destroy();this.map.value=new Map}},AA,jA,MA,NA,PA,FA,IA,LA,RA,zA,BA,VA=class extends (IA=OA,FA=[gO],PA=[gO],NA=[gO],MA=[_O],jA=[_O],AA=[_O],IA){constructor(e,t){var n=e,{modifiers:r,type:i,sensors:a,plugins:o,effects:s}=n,c=Vk(n,[`modifiers`,`type`,`sensors`,`plugins`,`effects`]);super(zk(Rk({},c),{effects:()=>[...s?.()??[],()=>{let{manager:e,plugins:t}=this;if(e&&t)for(let n of t){let{plugin:t}=rA(n);e.registry.plugins.register(t)}}]}),t),qk(LA,5,this),Qk(this,RA,qk(LA,8,this)),qk(LA,11,this),Qk(this,zA,qk(LA,12,this)),qk(LA,15,this),Qk(this,BA,qk(LA,16,this,this.isDragSource?`dragging`:`idle`)),qk(LA,19,this),this.type=i,this.sensors=a,this.modifiers=r,this.alignment=c.alignment,this.plugins=o}pluginConfig(e){if(this.plugins)for(let t of this.plugins){let n=rA(t);if(n.plugin===e)return n.options}}get isDropping(){return this.status===`dropping`&&this.isDragSource}get isDragging(){return this.status===`dragging`&&this.isDragSource}get isDragSource(){return this.manager?.dragOperation.source?.id===this.id}};LA=Hk(IA),RA=new WeakMap,zA=new WeakMap,BA=new WeakMap,Jk(LA,4,`type`,FA,VA,RA),Jk(LA,4,`modifiers`,PA,VA,zA),Jk(LA,4,`status`,NA,VA,BA),Jk(LA,2,`isDropping`,MA,VA),Jk(LA,2,`isDragging`,jA,VA),Jk(LA,2,`isDragSource`,AA,VA),Kk(LA,VA);var HA,UA,WA,GA,KA,qA,JA,YA,XA,ZA,QA,$A,ej,tj=class extends (JA=OA,qA=[gO],KA=[gO],GA=[gO],WA=[gO],UA=[gO],HA=[_O],JA){constructor(e,t){var n=e,{accept:r,collisionDetector:i,collisionPriority:a,type:o}=n,s=Vk(n,[`accept`,`collisionDetector`,`collisionPriority`,`type`]);super(s,t),qk(YA,5,this),Qk(this,XA,qk(YA,8,this)),qk(YA,11,this),Qk(this,ZA,qk(YA,12,this)),qk(YA,15,this),Qk(this,QA,qk(YA,16,this)),qk(YA,19,this),Qk(this,$A,qk(YA,20,this)),qk(YA,23,this),Qk(this,ej,qk(YA,24,this)),qk(YA,27,this),this.accept=r,this.collisionDetector=i,this.collisionPriority=a,this.type=o}accepts(e){let{accept:t}=this;return t?typeof t==`function`?t(e):e.type?Array.isArray(t)?t.includes(e.type):e.type===t:!1:!0}get isDropTarget(){return this.manager?.dragOperation.target?.id===this.id}};YA=Hk(JA),XA=new WeakMap,ZA=new WeakMap,QA=new WeakMap,$A=new WeakMap,ej=new WeakMap,Jk(YA,4,`accept`,qA,tj,XA),Jk(YA,4,`type`,KA,tj,ZA),Jk(YA,4,`collisionDetector`,GA,tj,QA),Jk(YA,4,`collisionPriority`,WA,tj,$A),Jk(YA,4,`shape`,UA,tj,ej),Jk(YA,2,`isDropTarget`,HA,tj),Kk(YA,tj);var nj=class{constructor(){this.registry=new Map}addEventListener(e,t){let{registry:n}=this,r=new Set(n.get(e));return r.add(t),n.set(e,r),()=>this.removeEventListener(e,t)}removeEventListener(e,t){let{registry:n}=this,r=new Set(n.get(e));r.delete(t),n.set(e,r)}dispatch(e,...t){let{registry:n}=this,r=n.get(e);if(r)for(let e of r)e(...t)}},rj=class extends nj{constructor(e){super(),this.manager=e}dispatch(e,t){let n=[t,this.manager];super.dispatch(e,...n)}};function ij(e,t=!0){let n=!1;return zk(Rk({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var aj=class extends lA{constructor(e){super(e);let t=(e,t)=>e.map(({id:e})=>e).join(``)===t.map(({id:e})=>e).join(``),n=[];this.destroy=yO(()=>{let{dragOperation:t,collisionObserver:r}=e;t.status.initializing&&(n=[],r.enable())},()=>{let{collisionObserver:r,monitor:i}=e,{collisions:a}=r;if(r.isDisabled()||OA.pendingIdChanges)return;let o=ij({collisions:a});if(i.dispatch(`collision`,o),o.defaultPrevented||t(a,n))return;n=a;let[s]=a;bD(()=>{s?.id!==e.dragOperation.target?.id&&(r.disable(),e.actions.setDropTarget(s?.id).then(()=>{r.enable()}))})})}},oj=(e=>(e[e.Lowest=0]=`Lowest`,e[e.Low=1]=`Low`,e[e.Normal=2]=`Normal`,e[e.High=3]=`High`,e[e.Highest=4]=`Highest`,e))(oj||{}),sj=(e=>(e[e.Collision=0]=`Collision`,e[e.ShapeIntersection=1]=`ShapeIntersection`,e[e.PointerIntersection=2]=`PointerIntersection`,e))(sj||{}),cj,lj,uj,dj,fj,pj,mj=[gO],hj,gj;pj=[_O],fj=[_O],dj=[_O],uj=[_O],lj=[_O],cj=[_O];var _j=class{constructor(){qk(hj,5,this),Qk(this,gj,qk(hj,8,this,`idle`)),qk(hj,11,this)}get current(){return this.value}get idle(){return this.value===`idle`}get initializing(){return this.value===`initializing`}get initialized(){let{value:e}=this;return e!==`idle`&&e!==`initialization-pending`}get dragging(){return this.value===`dragging`}get dropped(){return this.value===`dropped`}set(e){this.value=e}};hj=Hk(null),gj=new WeakMap,Jk(hj,4,`value`,mj,_j,gj),Jk(hj,2,`current`,pj,_j),Jk(hj,2,`idle`,fj,_j),Jk(hj,2,`initializing`,dj,_j),Jk(hj,2,`initialized`,uj,_j),Jk(hj,2,`dragging`,lj,_j),Jk(hj,2,`dropped`,cj,_j),Kk(hj,_j);var vj=class{constructor(e){this.manager=e}setDragSource(e){let{dragOperation:t}=this.manager;t.sourceIdentifier=typeof e==`string`||typeof e==`number`?e:e.id}setDropTarget(e){return bD(()=>{let{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;let r=ij({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch(`dragover`,r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return bD(()=>{let{dragOperation:t}=this.manager;if(e.source!=null&&this.setDragSource(e.source),!t.source)throw Error(`Cannot start a drag operation without a drag source`);if(!t.status.idle)throw Error(`Cannot start a drag operation while another is active`);let n=new AbortController,{event:r,coordinates:i}=e;_D(()=>{t.status.set(`initialization-pending`),t.shape=null,t.canceled=!1,t.activatorEvent=r??null,t.position.reset(i)});let a=ij({operation:t.snapshot()});return this.manager.monitor.dispatch(`beforedragstart`,a),a.defaultPrevented?(t.reset(),n.abort(),n):(t.status.set(`initializing`),t.controller=n,this.manager.renderer.rendering.then(()=>{if(n.signal.aborted)return;let{status:e}=t;e.current===`initializing`&&_D(()=>{t.status.set(`dragging`),this.manager.monitor.dispatch(`dragstart`,{nativeEvent:r,operation:t.snapshot(),cancelable:!1})})}),n)})}move(e){return bD(()=>{let{dragOperation:t}=this.manager,{status:n,controller:r}=t;if(!n.dragging||!r||r.signal.aborted)return;let i=ij({nativeEvent:e.event,operation:t.snapshot(),by:e.by,to:e.to},e.cancelable??!0);(e.propagate??!0)&&this.manager.monitor.dispatch(`dragmove`,i),queueMicrotask(()=>{if(i.defaultPrevented)return;let n=e.to??{x:t.position.current.x+(e.by?.x??0),y:t.position.current.y+(e.by?.y??0)};t.position.current=n})})}stop(e={}){return bD(()=>{let{dragOperation:t}=this.manager,{controller:n}=t;if(!n||n.signal.aborted)return;let r,i=()=>{let e={resume:()=>{},abort:()=>{}};return r=new Promise((t,n)=>{e.resume=t,e.abort=n}),e};n.abort();let a=()=>{this.manager.renderer.rendering.then(()=>{t.status.set(`dropped`);let e=bD(()=>t.source?.status===`dropping`),r=()=>{t.controller===n&&(t.controller=void 0),t.reset()};if(e){let{source:e}=t,n=BD(()=>{e?.status===`idle`&&(n(),r())})}else this.manager.renderer.rendering.then(r)})};t.canceled=e.canceled??!1,this.manager.monitor.dispatch(`dragend`,{nativeEvent:e.event,operation:t.snapshot(),canceled:e.canceled??!1,suspend:i}),r?r.then(a).catch(()=>t.reset()):a()})}},yj=class extends cA{constructor(e,t){super(e,t),this.manager=e,this.options=t}},bj=class extends AbortController{constructor(e,t){super(),this.constraints=e,this.onActivate=t,this.activated=!1;for(let t of e??[])t.controller=this}onEvent(e){if(!this.activated){if(this.constraints?.length)for(let t of this.constraints)t.onEvent(e);else this.activate(e)}}activate(e){this.activated||(this.activated=!0,this.onActivate(e))}abort(e){this.activated=!1,super.abort(e)}},xj,Sj=class{constructor(e){this.options=e,Qk(this,xj)}set controller(e){$k(this,xj,e),e.signal.addEventListener(`abort`,()=>this.abort())}activate(e){var t;(t=Zk(this,xj))==null||t.activate(e)}};xj=new WeakMap;var Cj=class extends cA{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},wj=class{constructor(e){this.draggables=new kA,this.droppables=new kA,this.plugins=new dA(e),this.sensors=new dA(e),this.modifiers=new dA(e)}register(e,t){if(e instanceof VA)return this.draggables.register(e.id,e);if(e instanceof tj)return this.droppables.register(e.id,e);if(e.prototype instanceof Cj)return this.modifiers.register(e,t);if(e.prototype instanceof yj)return this.sensors.register(e,t);if(e.prototype instanceof cA)return this.plugins.register(e,t);throw Error(`Invalid instance type`)}unregister(e){if(e instanceof OA)return e instanceof VA?this.draggables.unregister(e.id,e):e instanceof tj?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof Cj)return this.modifiers.unregister(e);if(e.prototype instanceof yj)return this.sensors.unregister(e);if(e.prototype instanceof cA)return this.plugins.unregister(e);throw Error(`Invalid instance type`)}destroy(){this.draggables.destroy(),this.droppables.destroy(),this.plugins.destroy(),this.sensors.destroy(),this.modifiers.destroy()}},Tj,Ej,Dj,Oj,kj,Aj,jj,Mj,Nj=[_O],Pj,Fj,Ij,Lj,Rj,zj,Bj,Vj,Hj,Uj;Mj=[gO],jj=[gO],Aj=[gO],kj=[gO],Oj=[gO],Dj=[_O],Ej=[_O],Tj=[_O];var Wj=class{constructor(e){qk(Lj,5,this),Qk(this,Pj),Qk(this,Fj),Qk(this,Ij,new BO(void 0,(e,t)=>e&&t?e.equals(t):e===t)),this.status=new _j,Qk(this,Rj,qk(Lj,8,this,!1)),qk(Lj,11,this),Qk(this,zj,qk(Lj,12,this,null)),qk(Lj,15,this),Qk(this,Bj,qk(Lj,16,this,null)),qk(Lj,19,this),Qk(this,Vj,qk(Lj,20,this,null)),qk(Lj,23,this),Qk(this,Hj,qk(Lj,24,this,[])),qk(Lj,27,this),this.position=new Ck({x:0,y:0}),Qk(this,Uj,{x:0,y:0}),$k(this,Pj,e)}get shape(){let{current:e,initial:t,previous:n}=Zk(this,Ij);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?Zk(this,Ij).current=e:Zk(this,Ij).reset()}get source(){let e=this.sourceIdentifier;if(e==null)return null;let t=Zk(this,Pj).registry.draggables.get(e);return t&&$k(this,Fj,t),t??Zk(this,Fj)??null}get target(){let e=this.targetIdentifier;return e==null?null:Zk(this,Pj).registry.droppables.get(e)??null}get transform(){let{x:e,y:t}=this.position.delta,n={x:e,y:t};for(let e of this.modifiers)n=e.apply(zk(Rk({},this.snapshot()),{transform:n}));return $k(this,Uj,n),n}snapshot(){return bD(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:Zk(this,Uj),shape:this.shape?VO(this.shape):null,position:VO(this.position),status:VO(this.status),canceled:this.canceled}))}reset(){_D(()=>{this.status.set(`idle`),this.sourceIdentifier=null,this.targetIdentifier=null,Zk(this,Ij).reset(),this.position.reset({x:0,y:0}),$k(this,Uj,{x:0,y:0}),this.modifiers=[]})}};Lj=Hk(null),Pj=new WeakMap,Fj=new WeakMap,Ij=new WeakMap,Rj=new WeakMap,zj=new WeakMap,Bj=new WeakMap,Vj=new WeakMap,Hj=new WeakMap,Uj=new WeakMap,Jk(Lj,2,`shape`,Nj,Wj),Jk(Lj,4,`canceled`,Mj,Wj,Rj),Jk(Lj,4,`activatorEvent`,jj,Wj,zj),Jk(Lj,4,`sourceIdentifier`,Aj,Wj,Bj),Jk(Lj,4,`targetIdentifier`,kj,Wj,Vj),Jk(Lj,4,`modifiers`,Oj,Wj,Hj),Jk(Lj,2,`source`,Dj,Wj),Jk(Lj,2,`target`,Ej,Wj),Jk(Lj,2,`transform`,Tj,Wj),Kk(Lj,Wj);var Gj={get rendering(){return Promise.resolve()}};function Kj(e,t){return typeof e==`function`?e(t):e??t}var qj=class{constructor(e){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(e=>e.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};let t=e??{},n=Kj(t.plugins,[]),r=Kj(t.sensors,[]),i=Kj(t.modifiers,[]),a=t.renderer??Gj,o=new rj(this),s=new wj(this);this.registry=s,this.monitor=o,this.renderer=a,this.actions=new vj(this),this.dragOperation=new Wj(this),this.collisionObserver=new gA(this),this.plugins=[aj,...n],this.modifiers=i,this.sensors=r;let{destroy:c}=this,l=yO(()=>{let e=bD(()=>this.dragOperation.modifiers),t=this.modifiers;for(let n of e)t.includes(n)||n.destroy();this.dragOperation.modifiers=(this.dragOperation.source?.modifiers)?.map(e=>{let{plugin:t,options:n}=rA(e);return new t(this,n)})??t});this.destroy=()=>{l(),c()}}get plugins(){return this.registry.plugins.values}set plugins(e){this.registry.plugins.values=e}get modifiers(){return this.registry.modifiers.values}set modifiers(e){this.registry.modifiers.values=e}get sensors(){return this.registry.sensors.values}set sensors(e){this.registry.sensors.values=e}},Jj=e=>{throw TypeError(e)},Yj=(e,t,n)=>t.has(e)||Jj(`Cannot `+n),Xj=(e,t,n)=>(Yj(e,t,`read from private field`),t.get(e)),Zj=(e,t,n)=>t.has(e)?Jj(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),Qj=(e,t,n,r)=>(Yj(e,t,`write to private field`),t.set(e,n),n),$j=(e,t,n)=>(Yj(e,t,`access private method`),n);function eM(e){return e?e instanceof KeyframeEffect||`getKeyframes`in e&&typeof e.getKeyframes==`function`:!1}function tM(e,t){let n=e.getAnimations(),r=null;for(let e of n){if(e.playState!==`running`)continue;let{effect:n}=e,i=(eM(n)?n.getKeyframes():[]).filter(t);i.length>0&&(r=[i[i.length-1],e])}return r}function nM(e){let{width:t,height:n,top:r,left:i,bottom:a,right:o}=e.getBoundingClientRect();return{width:t,height:n,top:r,left:i,bottom:a,right:o}}function rM(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function iM(e){return`nodeType`in e}function aM(e){return e?rM(e)?e:iM(e)?`defaultView`in e?e.defaultView??window:e.ownerDocument?.defaultView??window:window:window}function oM(e){let{Document:t}=aM(e);return e instanceof t||`nodeType`in e&&e.nodeType===Node.DOCUMENT_NODE}function sM(e){return!e||rM(e)?!1:e instanceof aM(e).HTMLElement||`namespaceURI`in e&&typeof e.namespaceURI==`string`&&e.namespaceURI.endsWith(`html`)}function cM(e){return e instanceof aM(e).SVGElement||`namespaceURI`in e&&typeof e.namespaceURI==`string`&&e.namespaceURI.endsWith(`svg`)}function lM(e){return e?rM(e)?e.document:iM(e)?oM(e)?e:sM(e)||cM(e)?e.ownerDocument:document:document:document}function uM(e){let{documentElement:t}=lM(e),n=aM(e).visualViewport,r=n?.width??t.clientWidth,i=n?.height??t.clientHeight,a=n?.offsetTop??0,o=n?.offsetLeft??0;return{top:a,left:o,right:o+r,bottom:a+i,width:r,height:i}}function dM(e,t){if(fM(e)&&e.open===!1)return!1;let{overflow:n,overflowX:r,overflowY:i}=getComputedStyle(e);return n===`visible`&&r===`visible`&&i===`visible`}function fM(e){return e.tagName===`DETAILS`}function pM(e,t=e.getBoundingClientRect(),n=0){let r=t,{ownerDocument:i}=e,a=i.defaultView??window,o=e.parentElement;for(;o&&o!==i.documentElement;){if(!dM(o)){let e=o.getBoundingClientRect(),t=n*(e.bottom-e.top),i=n*(e.right-e.left),a=n*(e.bottom-e.top),s=n*(e.right-e.left);r={top:Math.max(r.top,e.top-t),right:Math.min(r.right,e.right+i),bottom:Math.min(r.bottom,e.bottom+a),left:Math.max(r.left,e.left-s),width:0,height:0},r.width=r.right-r.left,r.height=r.bottom-r.top}o=o.parentElement}let s=a.visualViewport,c=s?.offsetTop??0,l=s?.offsetLeft??0,u=s?.width??a.innerWidth,d=s?.height??a.innerHeight,f=n*d,p=n*u;return r={top:Math.max(r.top,c-f),right:Math.min(r.right,l+u+p),bottom:Math.min(r.bottom,c+d+f),left:Math.max(r.left,l-p),width:0,height:0},r.width=r.right-r.left,r.height=r.bottom-r.top,r.width<0&&(r.width=0),r.height<0&&(r.height=0),r}function mM(e){return{x:e.clientX,y:e.clientY}}var hM=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function gM(e=document,t=new Set){if(t.has(e))return[];t.add(e);let n=[e];for(let r of Array.from(e.querySelectorAll(`iframe, frame`)))try{let e=r.contentDocument;e&&!t.has(e)&&n.push(...gM(e,t))}catch{}try{let r=e.defaultView;if(r&&r!==window.top){let i=r.parent;i&&i.document&&i.document!==e&&n.push(...gM(i.document,t))}}catch{}return n}function _M(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function vM(){let e=_M()?window.visualViewport:null;return{x:e?.offsetLeft??0,y:e?.offsetTop??0}}function yM(e){return!e||!iM(e)?!1:e instanceof aM(e).ShadowRoot}function bM(e){if(e&&iM(e)){let t=e.getRootNode();if(yM(t)||t instanceof Document)return t}return lM(e)}function xM(e){return e.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function SM(e){let t=`input, textarea, select, canvas, [contenteditable]`,n=e.cloneNode(!0),r=Array.from(e.querySelectorAll(t));return Array.from(n.querySelectorAll(t)).forEach((e,t)=>{let n=r[t];CM(e)&&CM(n)&&(e.type!==`file`&&(e.value=n.value),e.type===`radio`&&e.name&&(e.name=`Cloned__${e.name}`)),wM(e)&&wM(n)&&n.width>0&&n.height>0&&e.getContext(`2d`)?.drawImage(n,0,0)}),n}function CM(e){return`value`in e}function wM(e){return e.tagName===`CANVAS`}function TM(e,{x:t,y:n}){let r=e.elementFromPoint(t,n);if(EM(r)){let{contentDocument:e}=r;if(e){let{left:i,top:a}=r.getBoundingClientRect();return TM(e,{x:t-i,y:n-a})}}return r}function EM(e){return e?.tagName===`IFRAME`}var DM=new WeakMap;function OM(e){return e.closest(`
95
+ `),decorations:t}}function UT(e){return(t,n=`plaintext`,r={})=>{let i=HT(t),a=e.tokenize(i.code,{lang:n});for(let e of r.highlightLines||[])i.decorations.push({className:`th-line--highlighted`,lines:e});return Pw(Nw(a.tokens,{lineNumbers:r.lineNumbers,decorations:i.decorations}))}}var WT=262144,GT=Mw({languages:[wT,ET,FT,IT,TT,LT,lT,eT,jT,DT,AT]}),KT=new Set(GT.listLanguages()),qT=UT(GT),JT=(e,t,n)=>{let r=t?GT.normalizeLanguage(t):`plaintext`;return qT(e,KT.has(r)&&e.length<=WT?r:`plaintext`,n)};function YT(e){return e.closest(`[data-code-block]`)?.querySelector(`pre code`)?.textContent??``}function XT(e,t,n){function r({href:e,children:n,...r}){let i=gw(e);return i===`fragment`?(0,H.jsx)(`a`,{href:e,...r,children:n}):i===`external`?(0,H.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,...r,children:n}):i===`document`&&t&&e!==void 0?(0,H.jsx)(`button`,{type:`button`,"data-local-link":``,onClick:()=>t(e),children:n}):(0,H.jsx)(`span`,{children:n})}function i({src:t,alt:n,title:r}){let i=typeof t==`string`?e?.(t)??null:null;return i===null?(0,H.jsx)(`span`,{"data-blocked-image":``,children:n?`[image: ${n}]`:`[image]`}):(0,H.jsx)(`img`,{src:i,alt:n??``,title:r,loading:`lazy`,referrerPolicy:`no-referrer`})}function a({children:e,...t}){return n===void 0?(0,H.jsx)(`pre`,{...t,children:e}):(0,H.jsxs)(`div`,{"data-code-block":``,children:[(0,H.jsx)(`div`,{"data-code-actions":``,children:n}),(0,H.jsx)(`pre`,{...t,children:e})]})}return{a:r,img:i,pre:a}}function ZT({document:e,resolveImage:t,onOpenLink:n,codeActions:r}){let i=(0,D.useMemo)(()=>XT(t,n,r),[t,n,r]);return vw(e,{...mw,allowHtml:!1,highlighter:JT,components:i})}var QT=3e3;function $T(){let[e,t]=(0,D.useState)(null),[n,r]=(0,D.useState)(!1),i=(0,D.useRef)(null),a=(0,D.useRef)(0);return(0,D.useEffect)(()=>()=>{a.current+=1,i.current&&clearTimeout(i.current)},[]),{result:e,copy:(0,D.useCallback)(async(e,n)=>{let o=++a.current;i.current&&clearTimeout(i.current),r(!0);let s;try{if(typeof navigator.clipboard?.writeText!=`function`)throw Error(`This browser cannot write to the clipboard`);await navigator.clipboard.writeText(n),s={ok:!0,message:`Copied the ${e}.`}}catch(t){s={ok:!1,message:`Could not copy the ${e} (${t instanceof Error?t.message:`unknown reason`}).`}}o===a.current&&(r(!1),t(s),s.ok&&(i.current=setTimeout(()=>t(null),QT)))},[]),pending:n,dismiss:()=>t(null)}}function eE({label:e,text:t,icon:n=te,title:r,code:i=!1}){let{result:a,copy:o,pending:s,dismiss:c}=$T(),l=(0,D.useRef)(``),u=a?.ok===!1,d=u?P:a?.ok===!0?M:n;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(mx,{enabled:u,title:`Copy failed`,trigger:(0,H.jsxs)(lb,{variant:i?`outline`:`ghost`,size:i?`xs`:`icon-sm`,"aria-label":`Copy ${e}`,title:u?`${a.message} Click for details.`:r??`Copy ${e}`,disabled:s,className:u?`text-destructive`:void 0,"data-copy-state":u?`failed`:a?.ok===!0?`copied`:`idle`,onClick:n=>{u||(l.current=typeof t==`string`?t:t(n.currentTarget),o(e,l.current))},children:[(0,H.jsx)(d,{"aria-hidden":`true`}),i&&`Copy code`]}),children:[(0,H.jsx)(`p`,{children:a?.message}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(lb,{variant:`outline`,size:`sm`,disabled:s,onClick:()=>void o(e,l.current),children:`Try again`}),(0,H.jsx)(lb,{variant:`ghost`,size:`sm`,onClick:c,children:`Dismiss`})]})]}),(0,H.jsx)(`span`,{role:u?`alert`:`status`,className:`sr-only`,"data-testid":`copy-result`,children:a?.message})]})}function tE(){return(0,H.jsx)(H.Fragment,{children:`Scripts can load only the files registered for this document and cannot reach this app, its management API, or unregistered files. Some outbound requests, including navigation inside the view, are not blocked.`})}var nE={navigated:`View reloaded`,"request-closed":`Question closed`,expired:`Render permission expired`,replaced:`Draft connection ended`};function rE(e){return e.status===`connected`?`Drafts linked (not sent)`:e.status===`closed`?nE[e.reason]??`Invalid draft message`:null}function iE({mode:e,bridge:t,needsPermission:n,pinnedStatic:r,modeError:i,onRunScripts:a,onStopScripts:o,onReload:s}){let c=e===`interactive`,l=t.status===`closed`,u=rE(t);return(0,H.jsxs)(`div`,{className:`flex min-h-9 flex-wrap items-center gap-x-3 gap-y-1 border-b bg-muted/50 px-3 py-1 text-[0.8rem]`,"data-testid":`html-view-bar`,children:[(0,H.jsx)(`span`,{className:`font-medium`,children:`Document content`}),(0,H.jsx)(`span`,{className:`text-muted-foreground`,"data-testid":`html-mode`,children:c?`Scripts running`:r?`Scripts off for this question`:`Scripts off`}),n&&(0,H.jsx)(`span`,{className:`text-destructive`,children:`Permission cleared`}),u!==null&&(0,H.jsx)(`span`,{role:`status`,className:l?`text-destructive`:`text-muted-foreground`,"data-testid":`bridge-status`,children:u}),i&&(0,H.jsx)(`span`,{role:`alert`,className:`text-destructive`,children:`Script change failed`}),(0,H.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[l&&t.reason!==`request-closed`&&(0,H.jsx)(lb,{size:`xs`,variant:`ghost`,onClick:s,children:`Reload view`}),(0,H.jsx)(mx,{title:`Document view`,trigger:(0,H.jsxs)(lb,{size:`xs`,variant:`ghost`,children:[l||i?(0,H.jsx)(P,{"aria-hidden":`true`}):(0,H.jsx)(V,{"aria-hidden":`true`}),`Details`]}),children:(0,H.jsx)(aE,{mode:e,bridge:t,needsPermission:n,pinnedStatic:r,modeError:i,connection:u})}),c&&(0,H.jsx)(lb,{size:`xs`,variant:`ghost`,onClick:o,children:`Turn off scripts`}),n&&(0,H.jsx)(lb,{size:`xs`,variant:`outline`,onClick:a,children:`Run scripts…`})]})]})}function aE({mode:e,bridge:t,needsPermission:n,pinnedStatic:r,modeError:i,connection:a}){let o=e===`interactive`,s=t.status===`closed`;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`p`,{children:`Buttons and text inside the view belong to the opened document, rather than this app.`}),(0,H.jsx)(`p`,{children:`Links and form submission inside the view are disabled. Open links from “Links in this document”.`}),o?(0,H.jsx)(`p`,{children:(0,H.jsx)(tE,{})}):(0,H.jsx)(`p`,{children:`Scripts do not run in this view.`}),r&&(0,H.jsx)(`p`,{children:`This question was created in the Static view, so scripts stay off until it is answered.`}),n&&(0,H.jsx)(`p`,{children:`The permission to run scripts was cleared, for example by a daemon restart. Use “Run scripts…” to allow them again.`}),t.status===`connected`&&(0,H.jsx)(`p`,{children:`The document can read and replace draft answers. It cannot submit them. Only “Send answers to the agent” in the answer panel submits answers.`}),s&&(0,H.jsxs)(`p`,{children:[`Draft answers from this view are no longer accepted. `,a,`.`,` `,t.reason===`request-closed`?`Reloading cannot reopen the question.`:`Reload the view to reconnect.`]}),s&&!nE[t.reason]&&(0,H.jsx)(`p`,{children:`The document sent a message that breaks the rules, such as a malformed or oversized message or too many messages.`}),i&&(0,H.jsx)(`p`,{className:`text-destructive`,children:i})]})}function oE(e){return mh(e.defaultTagName??`div`,e,e)}var sE=sb(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function cE({className:e,variant:t=`default`,render:n,...r}){return oE({defaultTagName:`span`,props:eh({className:tb(sE({variant:t}),e)},r),render:n,state:{slot:`badge`,variant:t}})}var lE=D.createContext(void 0);function uE(){return D.useContext(lE)}var dE=D.forwardRef(function(e,t){let{className:n,defaultPressed:r=!1,disabled:i=!1,form:a,onPressedChange:o,pressed:s,render:c,type:l,value:u,nativeButton:d=!0,style:f,...p}=e,m=Fv(u||void 0),h=uE(),g=h?.value??[],_=(i||h?.disabled)??!1,[v,y]=hx({controlled:h?m!==void 0&&g.indexOf(m)>-1:s,default:r,name:`Toggle`,state:`pressed`}),{getButtonProps:b,buttonRef:x}=jv({disabled:_,native:d}),S={disabled:_,pressed:v},C=[x,t],w=[{"aria-pressed":v,onClick(e){let t=!v,n=$f(Gf,e.nativeEvent);o?.(t,n),!n.isCanceled&&(m&&h?.setGroupValue?.(m,t,n),!n.isCanceled&&y(t))}},p,b],T=mh(`button`,e,{enabled:!h,state:S,ref:C,props:w}),E=D.useMemo(()=>({disabled:_,focusableWhenDisabled:!1}),[_]);return h?(0,H.jsx)(cS,{tag:`button`,render:c,className:n,style:f,metadata:E,state:S,refs:C,props:w}):T}),fE=D.createContext(void 0);function pE(){return D.useContext(fE)}var mE=D.forwardRef(function(e,t){let{defaultValue:n,disabled:r=!1,loopFocus:i=!0,onValueChange:a,orientation:o=`horizontal`,multiple:s=!1,value:c,className:l,render:u,style:d,...f}=e,p=sx(!0),m=pE(),h=n??Pd,g=c!==void 0||n!==void 0,_=(p?.disabled??!1)||(m?.disabled??!1)||r,[v,y]=hx({controlled:c,default:h,name:`ToggleGroup`,state:`value`}),b=X((e,t,n)=>{let r;s?(r=v.slice(),t?r.push(e):r.splice(v.indexOf(e),1)):r=t?[e]:[],a?.(r,n),!n.isCanceled&&y(r)}),x={disabled:_,multiple:s,orientation:o},S=D.useMemo(()=>({disabled:_,setGroupValue:b,value:v,isValueInitialized:g}),[_,b,v,g]),C={role:`group`},w=mh(`div`,e,{enabled:!!p,state:x,ref:t,props:[C,f]});return(0,H.jsx)(lE.Provider,{value:S,children:p?w:(0,H.jsx)(DS,{render:u,className:l,style:d,state:x,refs:[t],props:[C,f],loopFocus:i,enableHomeAndEndKeys:!0,orientation:o})})}),hE=sb(`group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-transparent`,outline:`border border-input bg-transparent hover:bg-muted`},size:{default:`h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,sm:`h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`}},defaultVariants:{variant:`default`,size:`default`}}),gE=D.createContext({size:`default`,variant:`default`,spacing:2,orientation:`horizontal`});function _E({className:e,variant:t,size:n,spacing:r=2,orientation:i=`horizontal`,children:a,...o}){return(0,H.jsx)(mE,{"data-slot":`toggle-group`,"data-variant":t,"data-size":n,"data-spacing":r,"data-orientation":i,style:{"--gap":r},className:tb(`group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-vertical:flex-col data-vertical:items-stretch`,e),...o,children:(0,H.jsx)(gE.Provider,{value:{variant:t,size:n,spacing:r,orientation:i},children:a})})}function vE({className:e,children:t,variant:n=`default`,size:r=`default`,...i}){let a=D.useContext(gE);return(0,H.jsx)(dE,{"data-slot":`toggle-group-item`,"data-variant":a.variant||n,"data-size":a.size||r,"data-spacing":a.spacing,className:tb(`shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t`,hE({variant:a.variant||n,size:a.size||r}),e),...i,children:t})}var yE=(e,t)=>`${String(e)} ${t}${e===1?``:`s`}`,bE={"asset-scan-failed":()=>`Scanning the files this document references did not finish in time or exceeded the structure limits, so images and CSS were not registered. Run vo refresh <document ID> to scan again.`,"script-removed":(e,t)=>`Removed ${yE(t,`script`)}. Scripts do not run in this view, so content that scripts would create is not shown.`,"script-not-loaded":(e,t)=>`Removed ${yE(t,`script`)} that could not be loaded (referencing unregistered files or external URLs).`,"noscript-removed":(e,t)=>`Removed ${yE(t,`noscript element`)}. In the Interactive view, noscript content is not shown.`,"asset-requested":e=>`The view tried to load ${e}, but it is not registered, so it could not be loaded. Register it with vo open <document> --assets-root <dir> --asset ${e} to make it loadable (files that scripts load at run time are not registered automatically).`,"event-handler-removed":(e,t)=>`Removed event attributes such as onclick from ${yE(t,`element`)}.`,"embed-removed":(e,t)=>`Removed ${yE(t,`embedded element`)} (iframe, object, embed, and similar). Other pages and plugins cannot be embedded.`,"inline-svg-removed":(e,t)=>`Removed ${yE(t,`inline SVG`)}. Save the SVG as a file (.svg) and reference it with <img> to show it.`,"mathml-removed":(e,t)=>`Removed ${yE(t,`MathML element`)}.`,"meta-refresh-removed":()=>`Removed the automatic redirect (meta refresh).`,"base-removed":()=>`Removed the base element. Relative references resolve against the document location.`,"network-hint-removed":(e,t)=>`Removed ${yE(t,`resource hint`)} (prefetch, preconnect, and similar).`,"form-action-removed":()=>`Removed the form action. Form controls are display-only and cannot submit.`,"element-removed":(e,t)=>`Removed ${yE(t,`legacy element`)} that treats the rest of the document as text (such as plaintext).`,"media-blocked":e=>`Video and audio (${e}) cannot be shown.`,"remote-asset-blocked":e=>`External URL (${e}) is not loaded. Put the file under the document's directory and reference it with a relative path to show it.`,"asset-not-registered":e=>`${e} was not found. Make sure the file is under the assets-root used when the document was opened (the document's directory if none was given).`,"asset-rejected":e=>`${e} cannot be loaded. References outside the assets-root, file: URLs, and encoded separators are not allowed. To widen the range, reopen with vo open <document> --assets-root <dir>.`,"asset-hidden":e=>`${e} is not loaded. Files and directories whose names start with "." (such as .env and .git) cannot be referenced from documents.`,"asset-unsupported":e=>`${e} is a file type that cannot be used here. Allowed types are images (PNG, JPEG, WebP, GIF, AVIF, SVG), CSS, fonts (WOFF, WOFF2), and, in the Interactive view, scripts (.js, .mjs) and JSON registered with --asset.`,"data-url-blocked":e=>`data URL (${e}) cannot be used. Only PNG, JPEG, WebP, GIF, and AVIF images are allowed as data URLs.`,"css-invalid":e=>`${e===``?`The CSS in the document`:e} has parts that could not be parsed, and those parts were disabled.`,"link-disabled":(e,t)=>`Links in this document (${String(t)}) cannot be clicked inside the view. Open them from the "Links in this document" list.`};function xE(e){let t=bE[e.code],n=e.target??``;if(!t)return`${e.code}${n===``?``:`: ${n}`}`;let r=t(n,e.count);return e.target!==null&&e.count>1?`${r} (${String(e.count)} occurrences)`:r}function SE(e){if(!(e instanceof RS))return`Could not export the PDF.`;switch(e.code){case`E_BROWSER_NOT_FOUND`:return e.message;case`E_REVISION_UNAVAILABLE`:return`This revision is no longer kept. Show the latest revision and export again.`;case`E_PARSE_FAILED`:return`The document could not be prepared for printing (it is too large or too deeply nested).`;case`E_LIMIT_EXCEEDED`:return e.details.reason===`page-size`?`The document is too large to print (including images, fonts, and stylesheets).`:`Other PDF exports are still waiting. Try again after they finish.`;case`E_EXPORT_FAILED`:return e.details.reason===`timeout`?`The browser did not finish printing the PDF in time.`:`The browser could not print the PDF.`;default:return`Could not export the PDF. ${e.message}`}}var CE={exporting:!1,error:null};function wE(e,t){let n=URL.createObjectURL(e),r=window.document.createElement(`a`);r.href=n,r.download=t,window.document.body.append(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),6e4)}function TE(e=wE){let t=new Map,n=new Set,r=(e,r)=>{r===CE?t.delete(e):t.set(e,r);for(let e of n)e()};return{state:e=>t.get(e)??CE,subscribe(e){return n.add(e),()=>n.delete(e)},start(n,i,a){let{documentId:o}=i;t.get(o)?.exporting!==!0&&(r(o,{exporting:!0,error:null}),n.exportPdf(o,a).then(t=>{r(o,CE),e(t,Wu(i))},e=>{r(o,{exporting:!1,error:SE(e)})}))},dismiss(e){t.get(e)?.exporting===!1&&r(e,CE)}}}var EE=TE();function DE(e){return(0,D.useSyncExternalStore)(EE.subscribe,()=>EE.state(e))}function OE(e,t,n){let r=`vde-open.pref.${e}`,[i,a]=(0,D.useState)(()=>{try{let e=JSON.parse(window.localStorage.getItem(r)??`null`);return n(e)?e:t}catch{return t}});return[i,(0,D.useCallback)(e=>{a(e);try{window.localStorage.setItem(r,JSON.stringify(e))}catch{}},[r])]}var kE=e=>e===`light`||e===`dark`||e===`system`,AE=e=>e===`flat`||e===`tree`,jE=e=>e===`preview`||e===`source`,ME=1e3,NE=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null),PE=(e,t)=>Object.keys(e).every(e=>t.includes(e));function FE(e){try{let t=JSON.stringify(e);return t===void 0?null:Nu(t)}catch{return null}}function IE(e){return e instanceof RS?{code:e.code,message:e.message}:{code:`E_BRIDGE_FAILED`,message:`Could not handle the draft answer.`}}function LE(e){let{instanceId:t,port:n,handlers:r}=e,i=e.now??Date.now,a=!1,o=0,s=[],c=new Set,l=-1,u=0,d=null,f=e=>{if(a)return;let t=FE(e);if(t===null||t>Kl.bridgeOutboundFrameBytes){e.type===`response`&&n.postMessage({type:`response`,sequence:e.sequence,ok:!1,error:{code:`E_LIMIT_EXCEEDED`,message:`The response is too large.`}});return}n.postMessage(e)},p=(e,t)=>t.then(t=>f({type:`response`,sequence:e,ok:!0,result:t}),t=>f({type:`response`,sequence:e,ok:!1,error:IE(t)})),m=(e,t,n)=>f({type:`response`,sequence:e,ok:!1,error:{code:t,message:n}}),h=e=>{a||e.draftVersion<=l||c.has(e.draftVersion)||(l=e.draftVersion,f({type:`event`,method:`draftChanged`,payload:e}))},g=({sequence:e,method:t,payload:n})=>{if(t===`ready`){if(!PE(n,[])){m(e,`E_INVALID_ARGUMENT`,`ready takes no arguments.`);return}p(e,r.ready().then(e=>(l=Math.max(l,e.draftVersion),e)));return}if(t===`updateDraft`){let{answers:t,baseDraftVersion:i}=n;if(!PE(n,[`answers`,`baseDraftVersion`])||!NE(t)||typeof i!=`number`||!Number.isSafeInteger(i)||i<0){m(e,`E_INVALID_ARGUMENT`,`updateDraft requires a draft-answer object and baseDraftVersion.`);return}let a=FE(t);if(a===null||a>Kl.answerBytes){m(e,`E_LIMIT_EXCEEDED`,`The draft answer is too large.`);return}if(Object.hasOwn(t,`__proto__`)||!ju.safeParse(t).success){m(e,`E_ANSWER_INVALID`,`Draft answer values must be strings, finite numbers, booleans, or arrays of strings, keyed by field name.`);return}u+=1,p(e,r.updateDraft(t,i).then(e=>(c.add(e.draftVersion),l=Math.max(l,e.draftVersion),e)).finally(()=>{if(--u,u===0&&d!==null){let e=d;d=null,h(e)}}));return}m(e,`E_METHOD_NOT_ALLOWED`,`${t.slice(0,64)} cannot be called from HTML.`)},_={get closed(){return a},notifyDraft(e){if(!a){if(u>0){d=e;return}h(e)}},close(t){if(!a){try{n.postMessage({type:`closed`,reason:t})}catch{}a=!0,n.removeEventListener(`message`,v),n.close(),e.onClose?.(t)}}};function v(e){if(a)return;let n=i();if(s=s.filter(e=>n-e<ME),s.push(n),s.length>Kl.bridgeMessagesPerSecond){_.close(`rate`);return}let r=e.data,c=FE(r);if(c===null){_.close(`malformed`);return}if(c>Kl.bridgeInboundFrameBytes){_.close(`too-large`);return}if(!NE(r)||r.protocolVersion!==1||typeof r.sequence!=`number`||!Number.isSafeInteger(r.sequence)||typeof r.method!=`string`||!NE(r.payload)){_.close(`malformed`);return}if(r.instanceId!==t){_.close(`instance`);return}if(r.sequence<=o){_.close(`sequence`);return}o=r.sequence,g({sequence:r.sequence,method:r.method,payload:r.payload})}return n.addEventListener(`message`,v),n.start(),_}var RE=(e,t)=>typeof e==`object`&&!!e&&e.type===`vde-bridge-hello`&&e.protocolVersion===1&&e.instanceId===t;function zE(e,t,n,r,i){let a=n?.bridge?.instanceId??null,o=n?.bridge?.requestId??null,s=n?.grant??null,c=n?.documentUrl??null,[l,u]=(0,D.useState)(null),d=(0,D.useRef)(null);return(0,D.useEffect)(()=>{if(a===null||o===null||s===null)return;let n=t.current,r=i.current?.url===c?i.current.count:0,l=r>1,f=null,p=e=>u({instanceId:a,status:{status:`closed`,reason:e}}),m=t=>{let r=n?.contentWindow;if(!r||t.source!==r||!RE(t.data,a)||l)return;l=!0;let i=new MessageChannel,o=async e=>{try{return await e}catch(e){throw e instanceof RS&&e.code===`E_RENDER_GRANT_INVALID`&&setTimeout(()=>f?.close(`expired`),0),e}};f=LE({instanceId:a,port:i.port1,handlers:{async ready(){let t=await o(e.bridgeReady(s));return{protocolVersion:1,requestId:t.requestId,documentId:t.documentId,revision:t.revision,questionnaire:t.questionnaire,draftVersion:t.draftVersion,answers:t.draftAnswers}},updateDraft:(t,n)=>o(e.bridgeDraft(s,n,t))},onClose:p}),d.current=f,r.postMessage({type:et,instanceId:a},`*`,[i.port2]),u({instanceId:a,status:{status:`connected`}})},h=()=>{r+=1,!(r<2)&&(l=!0,f?f.close(`navigated`):p(`navigated`))};return window.addEventListener(`message`,m),n?.addEventListener(`load`,h),()=>{window.removeEventListener(`message`,m),n?.removeEventListener(`load`,h),f?.close(`replaced`),d.current=null}},[e,t,a,o,s,c,i]),(0,D.useEffect)(()=>{let t=d.current;if(t===null||r===null||r.requestId!==o||s===null)return;if(r.status!==`pending`){t.close(`request-closed`);return}let n=!1;return e.bridgeReady(s).then(e=>{n||e.status!==`pending`||t.notifyDraft({answers:e.draftAnswers,draftVersion:e.draftVersion})},e=>{e instanceof RS&&e.code===`E_RENDER_GRANT_INVALID`&&t.close(`expired`)}),()=>{n=!0}},[e,r,o,s]),a===null?{status:`none`}:i.current?.url===c&&i.current.count>1?{status:`closed`,reason:`navigated`}:l?.instanceId===a?l.status:{status:`waiting`}}var BE=2e3;function VE(e){let[t,n]=(0,D.useState)(null);return(0,D.useEffect)(()=>{if(e===null)return;let t=new Worker(new URL(`/assets/markdown.worker-BhrAVXtB.js`,``+import.meta.url),{type:`module`}),r=r=>{clearTimeout(i),t.terminate(),n({source:e,state:r})},i=setTimeout(()=>r({status:`failed`,reason:`timeout`}),BE);return t.addEventListener(`message`,e=>{r(e.data.ok?{status:`ready`,document:e.data.document}:{status:`failed`,reason:e.data.reason})}),t.addEventListener(`error`,()=>r({status:`failed`,reason:`parse-error`})),t.postMessage({id:1,source:e}),()=>{clearTimeout(i),t.terminate()}},[e]),t!==null&&t.source===e?t.state:{status:`parsing`}}function HE(e,t,n){let[r,i]=(0,D.useState)(null);return(0,D.useEffect)(()=>{if(t===null)return;let r=!1;return e.renderMissing(t).then(e=>{r||i({grant:t,fetchedFor:n,missing:e})},()=>void 0),()=>{r=!0}},[e,t,n]),r!==null&&r.grant===t?r.missing:[]}function UE(e,t){return e===null||e.state.status===`ready`&&e.state.grant.diagnostics.some(e=>e.code===`asset-scan-failed`)?t:e.updatedAt}function WE(e,t){return{release:e.filter(e=>e!==t),keep:e.filter(e=>e===t)}}var GE={mode:`static`,requestId:null,nonce:0};function KE(e,t,n,r,i=GE){let{mode:a,requestId:o,nonce:s}=i,[c,l]=(0,D.useState)(null),u=(0,D.useRef)(null),d=(0,D.useRef)([]),f=`${t}\n${n??``}\n${a}\n${o??``}\n${String(s)}`,p=c!==null&&c.key===f?c:null,m=UE(p,r),h=p?.state.status===`ready`?p.state.grant.grant:null;return(0,D.useEffect)(()=>{let r=()=>{u.current!==null&&d.current.push(u.current.grant),u.current=null};if(n===null){r();return}let i=!1;return(o===null?e.renderGrant(t,n,{mode:a}):e.feedbackRenderGrant(o)).then(t=>{if(i){e.releaseGrants([t.grant]).catch(()=>void 0);return}r(),u.current={key:f,grant:t.grant},l({key:f,updatedAt:m,state:{status:`ready`,grant:t}})},e=>{if(!i){if(u.current?.key===f){l(e=>e!==null&&e.key===f?{...e,updatedAt:m}:e);return}r(),l({key:f,updatedAt:m,state:{status:`failed`,message:e instanceof Error?e.message:`Could not prepare the view.`}})}}),()=>{i=!0}},[e,t,n,a,o,f,m]),(0,D.useEffect)(()=>{let{release:t,keep:n}=WE(d.current,h);t.length!==0&&(d.current=n,e.releaseGrants(t).catch(()=>void 0))}),(0,D.useEffect)(()=>()=>{let t=d.current.splice(0);u.current!==null&&t.push(u.current.grant),u.current=null,t.length>0&&e.releaseGrants(t).catch(()=>void 0)},[e]),p?.state??{status:`loading`}}var qE=160,JE=480,YE=240,XE=e=>typeof e==`number`&&Number.isInteger(e)&&e>=qE&&e<=JE,ZE={timeout:`Parsing did not finish within 2 seconds, so the source is shown.`,"limit-nodes":`The document has more than 100,000 elements, so the source is shown.`,"limit-depth":`The document is nested deeper than 64 levels, so the source is shown.`,"parse-error":`The document could not be parsed, so the source is shown.`},QE={missing:`The file was not found. Showing the last content that could be read.`,unreadable:`No permission to read the file. Showing the last content that could be read.`,error:`The file cannot be read as a document. Showing the last content that could be read.`};function $E(e,t){if(e===null)return null;for(let n of e.querySelectorAll(`[id]`))if(n.id===t)return n;return null}function eD({api:e,document:t,fixedRevision:n=null,request:r=null,renderSignal:i=0,waitingForRequest:a=!1,sectionTarget:o=null,restoreHeading:s=null,onHeadingShown:c,displayed:l=!0,onReady:u}){let[d,f]=OE(`view-mode`,`preview`,jE),[p,m]=OE(`outline-width`,YE,XE),h=(0,D.useId)(),g=(0,D.useRef)(null),[_,v]=(0,D.useState)(0),y=(0,D.useRef)(null),b=Math.max(qE,Math.min(JE,_-248)),x=Math.min(p,b);(0,D.useLayoutEffect)(()=>{let e=g.current;if(!e)return;let t=()=>v(e.clientWidth);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let S=e=>{m(Math.round(Math.min(b,Math.max(qE,e))))},C=e=>{e.button===0&&e.isPrimary&&(e.preventDefault(),e.currentTarget.focus(),y.current={pointerId:e.pointerId,x:e.clientX,width:x},e.currentTarget.setPointerCapture(e.pointerId))},w=e=>{let t=y.current;t&&t.pointerId===e.pointerId&&e.currentTarget.hasPointerCapture(e.pointerId)&&S(t.width+t.x-e.clientX)},[T,E]=(0,D.useState)(null),O=T!==null,k=n!==null,A=a?null:n??T??t.revision,[j,ee]=(0,D.useState)(null),[M,N]=(0,D.useState)(null),[F,te]=(0,D.useState)(null),[I,L]=(0,D.useState)(null),R=(0,D.useRef)(null),re=(0,D.useRef)(0);(0,D.useEffect)(()=>{if(A===null)return;let n=!1;return re.current=R.current?.scrollTop??0,Promise.all([e.content(t.documentId,A),e.outline(t.documentId,A).then(e=>({items:e,error:null}),e=>({items:[],error:e instanceof Error?e.message:`Could not be fetched.`}))]).then(([e,t])=>{n||(ee({revision:A,text:e,outline:t.items,outlineError:t.error}),N(null))},e=>{n||N({revision:A,message:e instanceof Error?e.message:`Could not be loaded.`})}),()=>{n=!0}},[e,t.documentId,A]);let ie=j?.text??null,ae=j?.outline??[],z=j?.outlineError??null,oe=M!==null&&M.revision===A?M.message:null,se=t.format===`markdown`,ce=d===`preview`,le=VE(se&&ce?ie:null),ue=n!==null&&r?.status===`pending`&&r.revision===n?r.requestId:null,B=ue!==null&&r?.renderMode===`static`,de=!se&&t.htmlMode===`interactive`&&t.interactiveAllowed,[fe,pe]=(0,D.useState)(0),he=KE(e,t.documentId,A,t.updatedAt,{mode:de?`interactive`:`static`,requestId:ue,nonce:fe}),V=he.status===`ready`?he.grant:null,ge=HE(e,V?.grant??null,i),[_e,ve]=(0,D.useState)(!1),[ye,be]=(0,D.useState)(null),xe=DE(t.documentId),Se=n=>{ve(!1),be(null),e.setHtmlMode(t.documentId,n).catch(e=>be(e instanceof Error?e.message:`Could not change the view mode.`))},Ce=se&&ce&&le.status===`ready`,we=!se&&ce?V?.documentUrl??null:null,Ee=(0,D.useRef)(null),Oe=(0,D.useRef)(null),[Ae,je]=(0,D.useState)(null),Me=zE(e,Ee,l&&we!==null?V:null,r,Oe),Ne=ie!==null&&(!ce||(se?le.status===`failed`||le.status===`ready`&&he.status!==`loading`:he.status===`failed`)),Pe=!a&&(A===null||(we===null?oe!==null||Ne:Ae===we)),Fe=(0,D.useCallback)(e=>{e!==null&&Pe&&u?.()},[Pe,u]);(0,D.useLayoutEffect)(()=>{R.current&&(ie!==null||Ce)&&(R.current.scrollTop=re.current)},[ie,Ce]);let Ie=(0,D.useMemo)(()=>{if(!V)return;let e=new Set(V.assets.filter(e=>e.role===`image`||e.role===`svg`).map(e=>e.logicalPath));return t=>{let n=_w(t,V.documentLogicalPath);return n===null||!e.has(n)?null:`${V.filesBaseUrl}${sw(n)}`}},[V]),Le=(0,D.useCallback)(async(n,r,i)=>{L(null);try{await e.openLink(t.documentId,r,n,i),te(null)}catch(e){if(e instanceof RS&&e.code===`E_CONFIRMATION_REQUIRED`){te({linkId:n,revision:r,path:String(e.details.path??``),confirmation:String(e.details.confirmation??``),changed:e.details.changed===!0});return}te(null),L({linkId:n,revision:r,message:e instanceof Error?e.message:`Could not open the link.`})}},[e,t.documentId]),Re=(0,D.useCallback)(e=>{let t=V?.links.find(t=>t.href===e);V&&t?.kind===`document`&&Le(t.linkId,V.revision)},[V,Le]),ze=(0,D.useMemo)(()=>(0,H.jsx)(eE,{code:!0,label:`code`,text:YT}),[]),Be=O&&!k&&t.revision!==A,Ve=(0,D.useMemo)(()=>new Map(V?.headingTargets.map(e=>[e.sectionId,e.anchor])??[]),[V]),He=Ce?null:we===null?se?`Available in the Markdown preview`:`Available in the HTML preview`:V?.mode===`static`?j?.revision===V.revision?null:`Available once the outline of the shown revision has loaded`:`Not available in the Interactive view (jumping reloads the view and restarts its scripts)`,Ue=e=>He===null&&(Ce||Ve.get(e.sectionId)===e.anchor),We=(0,D.useCallback)(e=>{if(Ce){$E(R.current,e.anchor)?.scrollIntoView({block:`start`});return}we!==null&&Ee.current?.contentWindow?.location.replace(`${we}#${hw(e.anchor)}`)},[Ce,we]),Ge=o?.nonce??0,[Ke,qe]=(0,D.useState)(0),Je=o!==null&&A!==null&&j?.revision===A,Ye=Je&&o.revision===A,Xe=Ye&&Ce?ae.find(e=>e.sectionId===o.sectionId)??null:null,Ze=o===null||Ge===Ke?null:Je?Ye?Ce?null:`This view does not jump to sections (only the Markdown preview does).`:k?`The search result is in a different revision than the one shown. The view is showing the question's revision while awaiting an answer, so it did not jump.`:O?`The search result is in a different revision than the one shown. Updates are paused, so the view did not jump.`:`The document was updated after the search, so the view did not jump to the section. Search again.`:oe===null?null:`The revision to show could not be loaded, so the view did not jump to the section.`;(0,D.useEffect)(()=>{Xe!==null&&Ge!==0&&(We(Xe),c?.({sectionId:Xe.sectionId,title:Xe.title}))},[Xe,Ge,We,c]);let Qe=s!==null&&He===null&&A!==null&&j?.revision===A&&z===null,et=Qe?ae.find(e=>e.sectionId===s.sectionId&&e.title===s.title)??ae.find(e=>e.title===s.title)??null:null,tt=et!==null&&Ue(et),nt=s?.id??null,rt=(0,D.useRef)(null);(0,D.useEffect)(()=>{if(Qe&&nt!==null&&rt.current!==nt){if(rt.current=nt,et===null||!tt){c?.(null);return}We(et),c?.({sectionId:et.sectionId,title:et.title})}},[Qe,nt,et,tt,We,c]);let it=[...V?.diagnostics??[],...ge.map(e=>({code:`asset-requested`,target:e,count:1}))],at=V?.mode??`static`,ot=se?[]:V?.links??[],st=[...Ze?[{label:`Section not reached`,message:Ze,dismiss:()=>qe(Ge),testId:`section-target-notice`}]:[],...t.sourceState!==`ready`&&QE[t.sourceState]?[{label:t.sourceState===`missing`?`File missing`:`File unreadable`,message:QE[t.sourceState]}]:[],...!se&&ce&&he.status===`failed`?[{label:`Showing source`,message:`The HTML could not be converted for display, so the source is shown (${he.message}).`}]:[],...se&&ce&&le.status===`failed`?[{label:`Showing source`,message:ZE[le.reason]??ZE[`parse-error`]}]:[],...oe?[{label:`Could not load document`,message:oe}]:[],...se&&I?[{label:`Could not open link`,message:I.message,dismiss:()=>L(null)}]:[],...we===null&&ye?[{label:`Script change failed`,message:ye,dismiss:()=>be(null)}]:[]];return(0,H.jsxs)(`section`,{ref:Fe,className:`flex h-full min-h-0 min-w-0 flex-1 flex-col`,"aria-label":`Document view`,children:[(0,H.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-b px-4 py-2`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1 basis-56`,children:[(0,H.jsx)(`h1`,{className:`truncate text-base font-semibold`,children:t.title}),(0,H.jsxs)(`p`,{className:`text-xs [overflow-wrap:anywhere] text-muted-foreground`,title:t.canonicalPath??void 0,"data-testid":`document-location`,children:[(0,H.jsx)($e,{document:t}),A&&(0,H.jsxs)(`span`,{title:A,children:[` · Revision `,A.slice(4,12)]})]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[t.displayPath!==null&&(0,H.jsx)(eE,{label:`document path`,text:t.displayPath}),(0,H.jsx)(eE,{label:`document ID`,text:t.documentId,icon:me,title:`Copy document ID (${t.documentId})`})]}),(0,H.jsx)(cE,{variant:`outline`,children:se?`Markdown`:`HTML`}),k?(0,H.jsx)(cE,{variant:`secondary`,children:`Showing the question's revision`}):O&&(Be?(0,H.jsxs)(mx,{title:`A newer revision is available`,trigger:(0,H.jsxs)(lb,{variant:`ghost`,size:`xs`,children:[(0,H.jsx)(P,{"aria-hidden":`true`}),`Update available`]}),children:[(0,H.jsx)(`p`,{children:`Updates are paused. The view stays on the revision from when they were paused.`}),(0,H.jsx)(lb,{size:`sm`,variant:`outline`,onClick:()=>E(null),children:`Resume updates`})]}):(0,H.jsx)(cE,{variant:`secondary`,children:`Updates paused`})),(0,H.jsxs)(_E,{value:[d],onValueChange:e=>{let t=e[0];jE(t)&&(t===`preview`&&d!==`preview`&&!se&&pe(e=>e+1),f(t))},size:`sm`,"aria-label":`View`,children:[(0,H.jsx)(vE,{value:`preview`,children:`Preview`}),(0,H.jsx)(vE,{value:`source`,children:`Source`})]}),(0,H.jsxs)(lb,{variant:`outline`,size:`sm`,"aria-pressed":O,disabled:k,title:k?`A question is awaiting an answer, so the question's revision is shown`:void 0,onClick:()=>E(O?null:t.revision),children:[O?(0,H.jsx)(De,{"aria-hidden":`true`}):(0,H.jsx)(Te,{"aria-hidden":`true`}),O?`Resume updates`:`Pause updates`]}),(0,H.jsxs)(lb,{variant:`ghost`,size:`sm`,onClick:()=>void e.refresh(t.documentId).catch(()=>void 0),children:[(0,H.jsx)(ke,{"aria-hidden":`true`}),`Refresh`]}),(0,H.jsxs)(mx,{title:`PDF export failed`,enabled:xe.error!==null,trigger:(0,H.jsxs)(lb,{variant:`ghost`,size:`sm`,disabled:xe.exporting||j===null,title:se?void 0:`Exports static HTML; scripts and interactive changes are not included`,onClick:()=>{xe.error===null&&j!==null&&EE.start(e,t,j.revision)},children:[xe.error?(0,H.jsx)(P,{"aria-hidden":`true`,className:`text-destructive`}):(0,H.jsx)(ne,{"aria-hidden":`true`}),(0,H.jsxs)(`span`,{className:`inline-grid`,children:[(0,H.jsx)(`span`,{className:`invisible col-start-1 row-start-1`,"aria-hidden":`true`,children:`Export PDF`}),(0,H.jsx)(`span`,{className:`invisible col-start-1 row-start-1`,"aria-hidden":`true`,children:`Exporting…`}),(0,H.jsx)(`span`,{className:`col-start-1 row-start-1`,children:xe.exporting?`Exporting…`:`Export PDF`})]})]}),children:[(0,H.jsx)(`p`,{children:xe.error}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(lb,{size:`sm`,variant:`outline`,onClick:()=>{j&&EE.start(e,t,j.revision)},children:`Try again`}),(0,H.jsx)(lb,{size:`sm`,variant:`ghost`,onClick:()=>EE.dismiss(t.documentId),children:`Dismiss`})]})]})]}),(xe.error||I)&&(0,H.jsxs)(`span`,{role:`alert`,className:`sr-only`,children:[xe.error,I?.message]}),st.length>0&&(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 border-b px-3 py-1`,"data-testid":`document-notices`,children:[st.map(e=>(0,H.jsxs)(mx,{title:e.label,trigger:(0,H.jsxs)(lb,{variant:`ghost`,size:`xs`,className:`text-destructive`,"data-testid":`testId`in e?e.testId:void 0,children:[(0,H.jsx)(P,{"aria-hidden":`true`}),e.label]}),children:[(0,H.jsx)(`p`,{children:e.message}),`dismiss`in e&&(0,H.jsx)(lb,{variant:`outline`,size:`sm`,onClick:e.dismiss,children:`Dismiss`})]},e.label)),(0,H.jsx)(`span`,{role:`status`,className:`sr-only`,children:st.map(e=>e.message).join(` `)})]}),(it.length>0||ot.length>0)&&(0,H.jsxs)(`div`,{className:`flex flex-col border-b text-sm`,children:[it.length>0&&(0,H.jsxs)(`details`,{className:`px-4 py-2`,"data-testid":`render-diagnostics`,children:[(0,H.jsxs)(`summary`,{className:`cursor-pointer`,children:[`Differences from the original document (`,it.length,` kinds)`]}),(0,H.jsx)(`ul`,{className:`mt-2 flex max-h-40 list-disc flex-col gap-1 overflow-y-auto pl-5 text-muted-foreground`,children:it.map(e=>(0,H.jsx)(`li`,{className:`break-words`,children:xE(e)},`${e.code}:${e.target??``}`))})]}),ot.length>0&&(0,H.jsxs)(`details`,{className:`border-t px-4 py-2 first:border-t-0`,"data-testid":`render-links`,children:[(0,H.jsxs)(`summary`,{className:`cursor-pointer`,children:[`Links in this document (`,ot.length,`)`]}),(0,H.jsx)(`ul`,{className:`mt-2 flex max-h-40 flex-col gap-1 overflow-y-auto`,children:ot.map(e=>(0,H.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[e.kind===`external`&&(0,H.jsx)(`a`,{className:`underline underline-offset-2`,href:e.href,target:`_blank`,rel:`noopener noreferrer`,children:e.text||e.href}),e.kind===`document`&&(0,H.jsxs)(mx,{title:`Could not open link`,enabled:I?.linkId===e.linkId,trigger:(0,H.jsxs)(lb,{variant:`link`,size:`xs`,className:`h-auto p-0`,onClick:()=>{V&&I?.linkId!==e.linkId&&Le(e.linkId,V.revision)},children:[I?.linkId===e.linkId&&(0,H.jsx)(P,{"aria-hidden":`true`,className:`text-destructive`}),e.text||e.href]}),children:[(0,H.jsx)(`p`,{children:I?.message}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(lb,{size:`sm`,variant:`outline`,onClick:()=>{I&&Le(I.linkId,I.revision)},children:`Try again`}),(0,H.jsx)(lb,{size:`sm`,variant:`ghost`,onClick:()=>L(null),children:`Dismiss`})]})]}),e.kind===`other`&&(0,H.jsx)(`span`,{children:e.text||e.href}),(0,H.jsxs)(`span`,{className:`text-xs break-all text-muted-foreground`,children:[e.href,e.kind===`other`&&` (this kind of link cannot be opened)`]})]},e.linkId))})]})]}),(0,H.jsxs)(`div`,{ref:g,className:`flex min-h-0 min-w-0 flex-1`,children:[we?(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,H.jsx)(iE,{mode:at,bridge:Me,pinnedStatic:B,needsPermission:t.htmlMode===`interactive`&&!t.interactiveAllowed&&!B,modeError:ye,onRunScripts:()=>ve(!0),onStopScripts:()=>Se(`static`),onReload:()=>pe(e=>e+1)}),(0,H.jsx)(`iframe`,{ref:Ee,title:`View of ${t.title}`,src:we,onLoad:()=>{let e=Oe.current;Oe.current={url:we,count:e?.url===we?e.count+1:1},je(we)},sandbox:at===`interactive`?`allow-scripts`:``,referrerPolicy:`no-referrer`,className:`min-h-0 w-full flex-1 border-0 bg-white`,"data-testid":`document-frame`},we)]}):(0,H.jsx)(`div`,{ref:R,className:`min-w-0 flex-1 overflow-y-auto px-6 py-5`,"data-testid":`document-body`,children:ie===null?(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:oe===null?`Loading…`:`Could not load this document.`}):Ce?(0,H.jsx)(`article`,{className:`markdown-body mx-auto max-w-3xl`,children:(0,H.jsx)(ZT,{document:le.document,...Ie?{resolveImage:Ie}:{},onOpenLink:Re,codeActions:ze})}):ce&&(se?le.status===`parsing`:he.status===`loading`)?(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Preparing the view…`}):(0,H.jsx)(`pre`,{className:`font-mono text-sm leading-relaxed break-words whitespace-pre-wrap`,children:ie})}),(ae.length>0||z!==null)&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize outline`,"aria-controls":h,"aria-valuemin":qE,"aria-valuemax":b,"aria-valuenow":x,tabIndex:0,className:`relative hidden w-2 shrink-0 touch-none cursor-col-resize before:absolute before:inset-y-0 before:left-1/2 before:w-px before:bg-border hover:bg-muted hover:before:bg-primary/60 focus-visible:bg-primary/10 focus-visible:before:bg-primary focus-visible:outline-none active:bg-primary/10 active:before:bg-primary lg:block`,onPointerDown:C,onPointerMove:w,onLostPointerCapture:()=>{y.current=null},onKeyDown:e=>{let t=e.key===`ArrowLeft`?x+16:e.key===`ArrowRight`?x-16:e.key===`Home`?qE:e.key===`End`?b:null;t!==null&&(e.preventDefault(),S(t))}}),(0,H.jsxs)(`aside`,{id:h,style:{width:x},className:`hidden shrink-0 overflow-y-auto px-3 py-4 lg:block`,"aria-label":`Outline`,children:[(0,H.jsx)(`h2`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:`Outline`}),z!==null&&(0,H.jsxs)(`p`,{className:`text-xs text-destructive`,role:`alert`,children:[`Could not fetch the outline (`,z,`).`]}),(0,H.jsx)(`ul`,{className:`flex flex-col gap-0.5 text-sm`,children:ae.map(e=>{let t=Ue(e);return(0,H.jsx)(`li`,{style:{paddingLeft:`${String((e.level-1)*.75)}rem`},children:(0,H.jsx)(`button`,{type:`button`,className:`w-full truncate rounded px-2 py-1 text-left hover:bg-muted disabled:opacity-50`,disabled:!t,title:t?e.title:He??`This heading is not in the view (removed from the display, or an earlier element has the same id)`,onClick:()=>{We(e),c?.({sectionId:e.sectionId,title:e.title})},children:e.title})},e.sectionId)})})]})]})]}),(0,H.jsx)(ub,{open:_e,onOpenChange:ve,children:(0,H.jsxs)(pb,{children:[(0,H.jsxs)(mb,{children:[(0,H.jsx)(gb,{children:`Run the scripts in this document?`}),(0,H.jsxs)(_b,{children:[`This runs the scripts in this HTML inside your browser. `,(0,H.jsx)(tE,{}),` This is not a mechanism for running arbitrary scripts safely. Enable it only for trusted HTML that you or your agent prepared.`]})]}),(0,H.jsxs)(hb,{children:[(0,H.jsx)(yb,{children:`Back`}),(0,H.jsx)(vb,{onClick:()=>Se(`interactive`),children:`Run scripts`})]})]})}),(0,H.jsx)(ub,{open:F!==null,onOpenChange:e=>{e||te(null)},children:(0,H.jsxs)(pb,{children:[(0,H.jsxs)(mb,{children:[(0,H.jsx)(gb,{children:`Add this document to the list and open it?`}),(0,H.jsx)(_b,{className:`break-all`,children:F?.path})]}),F?.changed&&(0,H.jsx)(`p`,{className:`text-sm font-medium`,children:`While you were confirming, the link target changed or the confirmation expired. Check the path above again.`}),(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This is the file that a link in the document points to. It is not open yet. Opening it adds it to the document list and to search.`}),(0,H.jsxs)(hb,{children:[(0,H.jsx)(yb,{children:`Don't open`}),(0,H.jsx)(vb,{onClick:()=>{F&&Le(F.linkId,F.revision,F.confirmation)},children:`Add to list and open`})]})]})})]})}function tD(e,t,n,r){let[i,a]=(0,D.useState)(null),[o,s]=(0,D.useState)(0),c=(0,D.useCallback)(()=>s(e=>e+1),[]),l=`${String(n)}\n${r??``}\n${String(o)}`;(0,D.useEffect)(()=>{if(t===null)return;let n=!1;return e.feedback(t).then(e=>{n||a({requestId:t,fetchedFor:l,request:e,error:null})},e=>{n||a(n=>({requestId:t,fetchedFor:l,request:n?.requestId===t?n.request:null,error:e instanceof Error?e.message:`Could not fetch the question.`}))}),()=>{n=!0}},[e,t,l]);let u=i!==null&&i.requestId===t?i:null;return{request:u?.request??null,error:u?.error??null,reload:c}}function nD({documents:e,...t}){let[n,r]=(0,D.useState)(t.document.documentId),i=e.find(e=>e.documentId===n),a=i!==void 0&&i.documentId!==t.document.documentId,o=a?[i,t.document]:[t.document],s=(0,D.useCallback)(()=>r(t.document.documentId),[t.document.documentId]);return(0,H.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1`,"aria-busy":a,children:o.map(e=>{let n=e.documentId===t.document.documentId,r=!a||!n;return(0,H.jsx)(`div`,{className:r?`flex min-h-0 min-w-0 flex-1`:`invisible absolute inset-0 flex min-h-0 min-w-0`,"aria-hidden":!r,inert:a,"data-testid":`document-workspace`,children:(0,H.jsx)(rD,{...t,document:e,displayed:r,onReady:n?s:void 0,sectionTarget:n&&r?t.sectionTarget:null,restoreHeading:n&&r?t.restoreHeading:null,onHeadingShown:n&&r?t.onHeadingShown:void 0})},e.documentId)})})}function rD({api:e,document:t,feedbackSignal:n,renderSignal:r,sectionTarget:i=null,restoreHeading:a=null,onHeadingShown:o,displayed:s=!0,onReady:c}){let l=t.pendingRequestIds[0]??null,[u,d]=(0,D.useState)(l);l!==null&&l!==u&&d(l);let f=l??u,{request:p,error:m,reload:h}=tD(e,f,n,t.revision),g=p?.status===`pending`?p.revision:null;return(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col min-[900px]:flex-row`,children:[(0,H.jsx)(eD,{api:e,document:t,fixedRevision:g,request:p,renderSignal:r,waitingForRequest:l!==null&&p===null&&m===null,sectionTarget:i,restoreHeading:a,displayed:s,...c?{onReady:c}:{},...o?{onHeadingShown:o}:{}}),p?(0,H.jsx)(nC,{api:e,request:p,reload:h},p.requestId):m!==null&&f!==null&&(0,H.jsx)(`aside`,{"aria-label":`Answer the question`,className:`w-full shrink-0 border-t px-4 py-4 min-[900px]:w-96 min-[900px]:border-t-0 min-[900px]:border-l`,children:(0,H.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Could not fetch the question (`,m,`).`]})})]})}var iD=d_(function(e){return wv(`dialog`,e)});function aD({...e}){return(0,H.jsx)(iD,{"data-slot":`dialog`,...e})}function oD({...e}){return(0,H.jsx)(ry,{"data-slot":`dialog-portal`,...e})}function sD({className:e,...t}){return(0,H.jsx)(Ev,{"data-slot":`dialog-overlay`,className:tb(`fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function cD({className:e,children:t,showCloseButton:n=!0,...r}){return(0,H.jsxs)(oD,{children:[(0,H.jsx)(sD,{}),(0,H.jsxs)(ey,{"data-slot":`dialog-content`,className:tb(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:[t,n&&(0,H.jsxs)(Pv,{"data-slot":`dialog-close`,render:(0,H.jsx)(lb,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`}),children:[(0,H.jsx)(Fe,{}),(0,H.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function lD({className:e,...t}){return(0,H.jsx)(`div`,{"data-slot":`dialog-header`,className:tb(`flex flex-col gap-2`,e),...t})}function uD({className:e,...t}){return(0,H.jsx)(iy,{"data-slot":`dialog-title`,className:tb(`font-heading text-base leading-none font-medium`,e),...t})}function dD({className:e,...t}){return(0,H.jsx)(Iv,{"data-slot":`dialog-description`,className:tb(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}var fD=200,pD=20;function mD({api:e,open:t,onOpenChange:n,onSelect:r}){let[i,a]=(0,D.useState)(``),[o,s]=(0,D.useState)(null),[c,l]=(0,D.useState)(0),u=(0,D.useId)(),d=i.trim();(0,D.useEffect)(()=>{if(!t||d===``)return;let n=!1,r=setTimeout(()=>{e.search(d,pD).then(e=>{n||s({query:d,result:e,error:null})},e=>{n||s({query:d,result:null,error:e instanceof Error?e.message:`Search failed.`})})},fD);return()=>{n=!0,clearTimeout(r)}},[e,t,d]);let f=o!==null&&o.query===d?o:null,p=f?.result?.hits??[],m=e=>Math.max(0,Math.min(e,p.length-1)),h=m(c);(0,D.useEffect)(()=>{p.length!==0&&window.document.getElementById(`${u}-${String(h)}`)?.scrollIntoView?.({block:`nearest`})},[h,p.length,u]);let g=e=>{e&&(n(!1),r(e))};return(0,H.jsx)(aD,{open:t,onOpenChange:e=>{n(e),e||(a(``),l(0))},children:(0,H.jsxs)(cD,{className:`top-[15%] translate-y-0 sm:max-w-xl`,children:[(0,H.jsxs)(lD,{children:[(0,H.jsx)(uD,{children:`Search open documents`}),(0,H.jsx)(dD,{children:`Only documents that are currently open are searched. Closed documents and other files are not.`})]}),(0,H.jsx)(Qx,{"aria-label":`Search query`,"aria-controls":u,"aria-activedescendant":p.length>0?`${u}-${String(h)}`:void 0,placeholder:`Words or a file name`,value:i,onChange:e=>{a(e.target.value),l(0)},onKeyDown:e=>{e.nativeEvent.isComposing||p.length!==0&&(e.key===`ArrowDown`?(e.preventDefault(),l(e=>m(m(e)+1))):e.key===`ArrowUp`?(e.preventDefault(),l(e=>m(m(e)-1))):e.key===`Enter`&&(e.preventDefault(),g(p[h])))}}),(0,H.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`text-xs text-muted-foreground`,children:d===``?`Type to search the open documents. Use ↑↓ to select and Enter to jump.`:f===null?`Searching…`:f.error===null?`${String(p.length)} ${p.length===1?`result`:`results`}${f.result?.incomplete===!0?` (some documents are not indexed yet, so not all documents were searched)`:``}`:`Search failed (${f.error}).`}),(0,H.jsx)(`div`,{id:u,role:`listbox`,"aria-label":`Search results`,className:`flex max-h-80 flex-col gap-1 overflow-y-auto`,children:p.map((e,t)=>(0,H.jsxs)(`div`,{id:`${u}-${String(t)}`,role:`option`,"aria-selected":t===h,className:`cursor-pointer rounded-md px-3 py-2 text-sm aria-selected:bg-muted`,tabIndex:-1,onMouseEnter:()=>l(t),onClick:()=>g(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),g(e))},children:[(0,H.jsxs)(`p`,{className:`truncate font-medium`,children:[e.title,e.headingPath.length>0&&(0,H.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[` `,`— `,e.headingPath.join(` › `)]})]}),(0,H.jsx)(`p`,{className:`line-clamp-2 text-xs text-muted-foreground`,children:e.excerpt}),e.displayPath&&(0,H.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:e.displayPath})]},`${e.documentId}:${e.sectionId}`))})]})})}var hD=Symbol.for(`preact-signals`);function gD(){if(SD>1)SD--;else{var e,t=!1;for((function(){var e=ED;for(ED=void 0;e!==void 0;){var t=e.S;if(t.v===e.v)for(var n=t.t;n!==void 0;n=n.x)n.i===e.i&&(n.i=t.i);e=e.o}})();xD!==void 0;){var n=xD;for(xD=void 0,CD++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&jD(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(CD=0,SD--,t)throw e}}function _D(e){if(SD>0)return e();TD=++wD,SD++;try{return e()}finally{gD()}}var vD,yD=void 0;function bD(e){var t=yD,n=vD;yD=void 0,vD=void 0;try{return e()}finally{yD=t,vD=n}}var xD=void 0,SD=0,CD=0,wD=0,TD=0,ED=void 0,DD=0;function OD(e){if(yD!==void 0){var t=e.n;if(t===void 0||t.t!==yD)return t={i:0,S:e,p:yD.s,n:void 0,t:yD,e:void 0,x:void 0,r:t},yD.s!==void 0&&(yD.s.n=t),yD.s=t,e.n=t,32&yD.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=yD.s,t.n=void 0,yD.s.n=t,yD.s=t),t}}function kD(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}kD.prototype.brand=hD,kD.prototype.h=function(){return!0},kD.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n===void 0?bD(function(){var e;(e=t.W)==null||e.call(t)}):n.e=e)},kD.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&bD(function(){var e;(e=t.Z)==null||e.call(t)}))}},kD.prototype.subscribe=function(e){var t=this;return BD(function(){var n=t.value;bD(function(){return e(n)})},{name:`sub`})},kD.prototype.valueOf=function(){return this.value},kD.prototype.toString=function(){return this.value+``},kD.prototype.toJSON=function(){return this.value},kD.prototype.peek=function(){var e=this;return bD(function(){return e.value})},Object.defineProperty(kD.prototype,"value",{get:function(){var e=OD(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(CD>100)throw Error(`Cycle detected`);(function(e){SD!==0&&CD===0&&e.l!==TD&&(e.l=TD,ED={S:e,v:e.v,i:e.i,o:ED})})(this),this.v=e,this.i++,DD++,SD++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{gD()}}}});function AD(e,t){return new kD(e,t)}function jD(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function MD(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function ND(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function PD(e,t){kD.call(this,void 0,t),this.x=e,this.s=void 0,this.g=DD-1,this.f=4}PD.prototype=new kD,PD.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===DD))return!0;if(this.g=DD,this.f|=1,this.i>0&&!jD(this))return this.f&=-2,!0;var e=yD;try{MD(this),yD=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return yD=e,ND(this),this.f&=-2,!0},PD.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}kD.prototype.S.call(this,e)},PD.prototype.U=function(e){if(this.t!==void 0&&(kD.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}},PD.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(PD.prototype,"value",{get:function(){if(1&this.f)throw Error(`Cycle detected`);var e=OD(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function FD(e,t){return new PD(e,t)}function ID(e){var t=e.m;if(e.m=void 0,typeof t==`function`){SD++;var n=yD;yD=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,LD(e),t}finally{yD=n,gD()}}}function LD(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,ID(e)}function RD(e){if(yD!==this)throw Error(`Out-of-order effect`);ND(this),yD=e,this.f&=-2,8&this.f&&LD(this),gD()}function zD(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,vD&&vD.push(this)}zD.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t==`function`&&(this.m=t)}finally{e()}},zD.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,ID(this),MD(this),SD++;var e=yD;return yD=this,RD.bind(this,e)},zD.prototype.N=function(){2&this.f||(this.f|=2,this.u=xD,xD=this)},zD.prototype.d=function(){this.f|=8,1&this.f||LD(this)},zD.prototype.dispose=function(){this.d()};function BD(e,t){var n=new zD(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var VD=Object.create,HD=Object.defineProperty,UD=Object.defineProperties,WD=Object.getOwnPropertyDescriptor,GD=Object.getOwnPropertyDescriptors,KD=Object.getOwnPropertySymbols,qD=Object.prototype.hasOwnProperty,JD=Object.prototype.propertyIsEnumerable,YD=(e,t)=>(t=Symbol[e])?t:Symbol.for(`Symbol.`+e),XD=e=>{throw TypeError(e)},ZD=(e,t,n)=>t in e?HD(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,QD=(e,t)=>{for(var n in t||={})qD.call(t,n)&&ZD(e,n,t[n]);if(KD)for(var n of KD(t))JD.call(t,n)&&ZD(e,n,t[n]);return e},$D=(e,t)=>UD(e,GD(t)),eO=(e,t)=>HD(e,`name`,{value:t,configurable:!0}),tO=e=>[,,,VD(e?.[YD(`metadata`)]??null)],nO=[`class`,`method`,`getter`,`setter`,`accessor`,`field`,`value`,`get`,`set`],rO=e=>e!==void 0&&typeof e!=`function`?XD(`Function expected`):e,iO=(e,t,n,r,i)=>({kind:nO[e],name:t,metadata:r,addInitializer:e=>n._?XD(`Already initialized`):i.push(rO(e||null))}),aO=(e,t)=>ZD(t,YD(`metadata`),e[3]),oO=(e,t,n,r)=>{for(var i=0,a=e[t>>1],o=a&&a.length;i<o;i++)t&1?a[i].call(n):r=a[i].call(n,r);return r},sO=(e,t,n,r,i,a)=>{var o,s,c,l,u,d=t&7,f=!!(t&8),p=!!(t&16),m=d>3?e.length+1:d?f?1:2:0,h=nO[d+5],g=d>3&&(e[m-1]=[]),_=e[m]||(e[m]=[]),v=d&&(!p&&!f&&(i=i.prototype),d<5&&(d>3||!p)&&WD(d<4?i:{get[n](){return uO(this,a)},set[n](e){return fO(this,a,e)}},n));d?p&&d<4&&eO(a,(d>2?`set `:d>1?`get `:``)+n):eO(i,n);for(var y=r.length-1;y>=0;y--)l=iO(d,n,c={},e[3],_),d&&(l.static=f,l.private=p,u=l.access={has:p?e=>lO(i,e):e=>n in e},d^3&&(u.get=p?e=>(d^1?uO:pO)(e,i,d^4?a:v.get):e=>e[n]),d>2&&(u.set=p?(e,t)=>fO(e,i,t,d^4?a:v.set):(e,t)=>e[n]=t)),s=(0,r[y])(d?d<4?p?a:v[h]:d>4?void 0:{get:v.get,set:v.set}:i,l),c._=1,d^4||s===void 0?rO(s)&&(d>4?g.unshift(s):d?p?a=s:v[h]=s:i=s):typeof s!=`object`||!s?XD(`Object expected`):(rO(o=s.get)&&(v.get=o),rO(o=s.set)&&(v.set=o),rO(o=s.init)&&g.unshift(o));return d||aO(e,i),v&&HD(i,n,v),p?d^4?a:v:i},cO=(e,t,n)=>t.has(e)||XD(`Cannot `+n),lO=(e,t)=>Object(t)===t?e.has(t):XD(`Cannot use the "in" operator on this value`),uO=(e,t,n)=>(cO(e,t,`read from private field`),n?n.call(e):t.get(e)),dO=(e,t,n)=>t.has(e)?XD(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),fO=(e,t,n,r)=>(cO(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n),pO=(e,t,n)=>(cO(e,t,`access private method`),n);function mO(e,t){if(t){let n;return FD(()=>{let r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return FD(e)}function hO(e,t){if(Object.is(e,t))return!0;if(e===null||t===null)return!1;if(typeof e==`function`&&typeof t==`function`)return e===t;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:!e.some((e,n)=>!hO(e,t[n]));if(typeof e==`object`&&typeof t==`object`){let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&!n.some(n=>!hO(e[n],t[n]))}return!1}function gO({get:e},t){return{init(e){return AD(e)},get(){return e.call(this).value},set(t){let n=e.call(this);n.peek()!==t&&(n.value=t)}}}function _O(e,t){let n=new WeakMap;return function(){let t=n.get(this);return t||(t=mO(e.bind(this)),n.set(this,t)),t.value}}function vO(e=!0){return function(t,n){n.addInitializer(function(){let t=n.kind===`field`||n.static?this:Object.getPrototypeOf(this),r=Object.getOwnPropertyDescriptor(t,n.name);r&&Object.defineProperty(t,n.name,$D(QD({},r),{enumerable:e}))})}}function yO(...e){let t=e.map(e=>BD(e));return()=>t.forEach(e=>e())}var bO,xO,SO,CO,wO,TO=[gO],EO,DO,OO,kO,AO,jO,MO,NO,PO,FO,IO,LO,RO,zO;wO=[gO],CO=[gO],SO=[vO()],xO=[vO()],bO=[vO()];var BO=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,oO(EO,5,this),dO(this,jO),dO(this,DO,oO(EO,8,this)),oO(EO,11,this),dO(this,MO,oO(EO,12,this)),oO(EO,15,this),dO(this,IO,oO(EO,16,this)),oO(EO,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return uO(this,jO,RO)}get initial(){return uO(this,jO,kO)}get previous(){return uO(this,jO,PO)}set current(e){let t=bD(()=>uO(this,jO,RO));e&&t&&this.equals(t,e)||_D(()=>{uO(this,jO,kO)||fO(this,jO,e,AO),fO(this,jO,t,FO),fO(this,jO,e,zO)})}reset(e=this.defaultValue){_D(()=>{fO(this,jO,void 0,FO),fO(this,jO,e,AO),fO(this,jO,e,zO)})}};EO=tO(null),DO=new WeakMap,jO=new WeakSet,MO=new WeakMap,IO=new WeakMap,OO=sO(EO,20,`#initial`,TO,jO,DO),kO=OO.get,AO=OO.set,NO=sO(EO,20,`#previous`,wO,jO,MO),PO=NO.get,FO=NO.set,LO=sO(EO,20,`#current`,CO,jO,IO),RO=LO.get,zO=LO.set,sO(EO,2,`current`,SO,BO),sO(EO,2,`initial`,xO,BO),sO(EO,2,`previous`,bO,BO),aO(EO,BO);function VO(e){return bD(()=>{let t={};for(let n in e)t[n]=e[n];return t})}var HO,UO=class{constructor(){dO(this,HO,new WeakMap)}get(e,t){return e?uO(this,HO).get(e)?.get(t):void 0}set(e,t,n){if(e)return uO(this,HO).has(e)||uO(this,HO).set(e,new Map),uO(this,HO).get(e)?.set(t,n)}clear(e){return e?uO(this,HO).get(e)?.clear():void 0}};HO=new WeakMap;var WO=Object.create,GO=Object.defineProperty,KO=Object.getOwnPropertyDescriptor,qO=Object.getOwnPropertySymbols,JO=Object.prototype.hasOwnProperty,YO=Object.prototype.propertyIsEnumerable,XO=(e,t)=>(t=Symbol[e])?t:Symbol.for(`Symbol.`+e),ZO=e=>{throw TypeError(e)},QO=Math.pow,$O=(e,t,n)=>t in e?GO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ek=(e,t)=>{for(var n in t||={})JO.call(t,n)&&$O(e,n,t[n]);if(qO)for(var n of qO(t))YO.call(t,n)&&$O(e,n,t[n]);return e},tk=(e,t)=>GO(e,`name`,{value:t,configurable:!0}),nk=e=>[,,,WO(e?.[XO(`metadata`)]??null)],rk=[`class`,`method`,`getter`,`setter`,`accessor`,`field`,`value`,`get`,`set`],ik=e=>e!==void 0&&typeof e!=`function`?ZO(`Function expected`):e,ak=(e,t,n,r,i)=>({kind:rk[e],name:t,metadata:r,addInitializer:e=>n._?ZO(`Already initialized`):i.push(ik(e||null))}),ok=(e,t)=>$O(t,XO(`metadata`),e[3]),sk=(e,t,n,r)=>{for(var i=0,a=e[t>>1],o=a&&a.length;i<o;i++)t&1?a[i].call(n):r=a[i].call(n,r);return r},ck=(e,t,n,r,i,a)=>{var o,s,c,l,u,d=t&7,f=!!(t&8),p=!!(t&16),m=d>3?e.length+1:d?f?1:2:0,h=rk[d+5],g=d>3&&(e[m-1]=[]),_=e[m]||(e[m]=[]),v=d&&(!p&&!f&&(i=i.prototype),d<5&&(d>3||!p)&&KO(d<4?i:{get[n](){return dk(this,a)},set[n](e){return pk(this,a,e)}},n));d?p&&d<4&&tk(a,(d>2?`set `:d>1?`get `:``)+n):tk(i,n);for(var y=r.length-1;y>=0;y--)l=ak(d,n,c={},e[3],_),d&&(l.static=f,l.private=p,u=l.access={has:p?e=>uk(i,e):e=>n in e},d^3&&(u.get=p?e=>(d^1?dk:mk)(e,i,d^4?a:v.get):e=>e[n]),d>2&&(u.set=p?(e,t)=>pk(e,i,t,d^4?a:v.set):(e,t)=>e[n]=t)),s=(0,r[y])(d?d<4?p?a:v[h]:d>4?void 0:{get:v.get,set:v.set}:i,l),c._=1,d^4||s===void 0?ik(s)&&(d>4?g.unshift(s):d?p?a=s:v[h]=s:i=s):typeof s!=`object`||!s?ZO(`Object expected`):(ik(o=s.get)&&(v.get=o),ik(o=s.set)&&(v.set=o),ik(o=s.init)&&g.unshift(o));return d||ok(e,i),v&&GO(i,n,v),p?d^4?a:v:i},lk=(e,t,n)=>t.has(e)||ZO(`Cannot `+n),uk=(e,t)=>Object(t)===t?e.has(t):ZO(`Cannot use the "in" operator on this value`),dk=(e,t,n)=>(lk(e,t,`read from private field`),n?n.call(e):t.get(e)),fk=(e,t,n)=>t.has(e)?ZO(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),pk=(e,t,n,r)=>(lk(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n),mk=(e,t,n)=>(lk(e,t,`access private method`),n),hk=class e{constructor(e,t){this.x=e,this.y=t}static delta(t,n){return new e(t.x-n.x,t.y-n.y)}static distance(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}static equals(e,t){return e.x===t.x&&e.y===t.y}static from({x:t,y:n}){return new e(t,n)}},gk=class e{constructor(e,t,n,r){this.left=e,this.top=t,this.width=n,this.height=r,this.scale={x:1,y:1}}get inverseScale(){return{x:1/this.scale.x,y:1/this.scale.y}}translate(t,n){let{top:r,left:i,width:a,height:o,scale:s}=this,c=new e(i+t,r+n,a,o);return c.scale=ek({},s),c}get boundingRectangle(){let{width:e,height:t,left:n,top:r,right:i,bottom:a}=this;return{width:e,height:t,left:n,top:r,right:i,bottom:a}}get center(){let{left:e,top:t,right:n,bottom:r}=this;return new hk((e+n)/2,(t+r)/2)}get area(){let{width:e,height:t}=this;return e*t}equals(t){if(!(t instanceof e))return!1;let{left:n,top:r,width:i,height:a}=this;return n===t.left&&r===t.top&&i===t.width&&a===t.height}containsPoint(e){let{top:t,left:n,bottom:r,right:i}=this;return t<=e.y&&e.y<=r&&n<=e.x&&e.x<=i}intersectionArea(t){return t instanceof e?_k(this,t):0}intersectionRatio(e){let{area:t}=this,n=this.intersectionArea(e);return n/(e.area+t-n)}get bottom(){let{top:e,height:t}=this;return e+t}get right(){let{left:e,width:t}=this;return e+t}get aspectRatio(){let{width:e,height:t}=this;return e/t}get corners(){return[{x:this.left,y:this.top},{x:this.right,y:this.top},{x:this.left,y:this.bottom},{x:this.right,y:this.bottom}]}static from({top:t,left:n,width:r,height:i}){return new e(n,t,r,i)}static delta(e,t,n={x:`center`,y:`center`}){let r=(e,t)=>{let r=n[t],i=t===`x`?e.left:e.top,a=t===`x`?e.width:e.height;return r==`start`?i:r==`end`?i+a:i+a/2};return hk.delta({x:r(e,`x`),y:r(e,`y`)},{x:r(t,`x`),y:r(t,`y`)})}static intersectionRatio(t,n){return e.from(t).intersectionRatio(e.from(n))}};function _k(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;return r<i&&n<a?o*s:0}var vk,yk,bk,xk,Sk,Ck=class extends (bk=BO,yk=[_O],vk=[_O],bk){constructor(e){let t=hk.from(e);super(t,(e,t)=>hk.equals(e,t)),sk(Sk,5,this),fk(this,xk,0),this.velocity={x:0,y:0}}get delta(){return hk.delta(this.current,this.initial)}get direction(){let{current:e,previous:t}=this;if(!t)return null;let n={x:e.x-t.x,y:e.y-t.y};return!n.x&&!n.y?null:Math.abs(n.x)>Math.abs(n.y)?n.x>0?`right`:`left`:n.y>0?`down`:`up`}get current(){return super.current}set current(e){let{current:t}=this,n=hk.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),a=i-dk(this,xk),o=e=>Math.round(e/a*100);_D(()=>{pk(this,xk,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(hk.from(e)),this.velocity={x:0,y:0}}};Sk=nk(bk),xk=new WeakMap,ck(Sk,2,`delta`,yk,Ck),ck(Sk,2,`direction`,vk,Ck),ok(Sk,Ck);function wk({x:e,y:t},n){let r=Math.abs(e),i=Math.abs(t);return typeof n==`number`?Math.sqrt(QO(r,2)+QO(i,2))>n:`x`in n&&`y`in n?r>n.x&&i>n.y:`x`in n?r>n.x:`y`in n&&i>n.y}var Tk=(e=>(e.Horizontal=`x`,e.Vertical=`y`,e))(Tk||{}),Ek=Object.values(Tk),Dk=Object.create,Ok=Object.defineProperty,kk=Object.defineProperties,Ak=Object.getOwnPropertyDescriptor,jk=Object.getOwnPropertyDescriptors,Mk=Object.getOwnPropertySymbols,Nk=Object.prototype.hasOwnProperty,Pk=Object.prototype.propertyIsEnumerable,Fk=(e,t)=>(t=Symbol[e])?t:Symbol.for(`Symbol.`+e),Ik=e=>{throw TypeError(e)},Lk=(e,t,n)=>t in e?Ok(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Rk=(e,t)=>{for(var n in t||={})Nk.call(t,n)&&Lk(e,n,t[n]);if(Mk)for(var n of Mk(t))Pk.call(t,n)&&Lk(e,n,t[n]);return e},zk=(e,t)=>kk(e,jk(t)),Bk=(e,t)=>Ok(e,`name`,{value:t,configurable:!0}),Vk=(e,t)=>{var n={};for(var r in e)Nk.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Mk)for(var r of Mk(e))t.indexOf(r)<0&&Pk.call(e,r)&&(n[r]=e[r]);return n},Hk=e=>[,,,Dk(e?.[Fk(`metadata`)]??null)],Uk=[`class`,`method`,`getter`,`setter`,`accessor`,`field`,`value`,`get`,`set`],Wk=e=>e!==void 0&&typeof e!=`function`?Ik(`Function expected`):e,Gk=(e,t,n,r,i)=>({kind:Uk[e],name:t,metadata:r,addInitializer:e=>n._?Ik(`Already initialized`):i.push(Wk(e||null))}),Kk=(e,t)=>Lk(t,Fk(`metadata`),e[3]),qk=(e,t,n,r)=>{for(var i=0,a=e[t>>1],o=a&&a.length;i<o;i++)t&1?a[i].call(n):r=a[i].call(n,r);return r},Jk=(e,t,n,r,i,a)=>{var o,s,c,l,u,d=t&7,f=!!(t&8),p=!!(t&16),m=d>3?e.length+1:d?f?1:2:0,h=Uk[d+5],g=d>3&&(e[m-1]=[]),_=e[m]||(e[m]=[]),v=d&&(!p&&!f&&(i=i.prototype),d<5&&(d>3||!p)&&Ak(d<4?i:{get[n](){return Zk(this,a)},set[n](e){return $k(this,a,e)}},n));d?p&&d<4&&Bk(a,(d>2?`set `:d>1?`get `:``)+n):Bk(i,n);for(var y=r.length-1;y>=0;y--)l=Gk(d,n,c={},e[3],_),d&&(l.static=f,l.private=p,u=l.access={has:p?e=>Xk(i,e):e=>n in e},d^3&&(u.get=p?e=>(d^1?Zk:eA)(e,i,d^4?a:v.get):e=>e[n]),d>2&&(u.set=p?(e,t)=>$k(e,i,t,d^4?a:v.set):(e,t)=>e[n]=t)),s=(0,r[y])(d?d<4?p?a:v[h]:d>4?void 0:{get:v.get,set:v.set}:i,l),c._=1,d^4||s===void 0?Wk(s)&&(d>4?g.unshift(s):d?p?a=s:v[h]=s:i=s):typeof s!=`object`||!s?Ik(`Object expected`):(Wk(o=s.get)&&(v.get=o),Wk(o=s.set)&&(v.set=o),Wk(o=s.init)&&g.unshift(o));return d||Kk(e,i),v&&Ok(i,n,v),p?d^4?a:v:i},Yk=(e,t,n)=>t.has(e)||Ik(`Cannot `+n),Xk=(e,t)=>Object(t)===t?e.has(t):Ik(`Cannot use the "in" operator on this value`),Zk=(e,t,n)=>(Yk(e,t,`read from private field`),n?n.call(e):t.get(e)),Qk=(e,t,n)=>t.has(e)?Ik(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),$k=(e,t,n,r)=>(Yk(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n),eA=(e,t,n)=>(Yk(e,t,`access private method`),n);function tA(e,t){return{plugin:e,options:t}}function nA(e){return t=>tA(e,t)}function rA(e){return typeof e==`function`?{plugin:e,options:void 0}:e}var iA=[gO],aA,oA,sA,cA=class{constructor(e,t){this.manager=e,this.options=t,Qk(this,oA,qk(aA,8,this,!1)),qk(aA,11,this),Qk(this,sA,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return bD(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){let t=BD(e.bind(this));return Zk(this,sA).add(t),t}destroy(){Zk(this,sA).forEach(e=>e())}static configure(e){return tA(this,e)}};aA=Hk(null),oA=new WeakMap,sA=new WeakMap,Jk(aA,4,`disabled`,iA,cA,oA),Kk(aA,cA);var lA=class extends cA{},uA,dA=class{constructor(e){this.manager=e,this.instances=new Map,Qk(this,uA,[])}get values(){return Array.from(this.instances.values())}set values(e){let t=e.map(rA).reduce((e,t)=>{let n=e.find(({plugin:e})=>e===t.plugin);return n?(n.options=t.options,e):[...e,t]},[]),n=t.map(({plugin:e})=>e);for(let e of Zk(this,uA))if(!n.includes(e)){if(e.prototype instanceof lA)continue;this.unregister(e)}for(let{plugin:e,options:n}of t)this.register(e,n);$k(this,uA,n)}get(e){return this.instances.get(e)}register(e,t){let n=this.instances.get(e);if(n)return n.options!==t&&(n.options=t),n;let r=new e(this.manager,t);return this.instances.set(e,r),r}unregister(e){let t=this.instances.get(e);t&&(t.destroy(),this.instances.delete(e))}destroy(){for(let e of this.instances.values())e.destroy();this.instances.clear()}};uA=new WeakMap;function fA(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var pA=[],mA,hA,gA=class extends cA{constructor(e){super(e),Qk(this,mA),Qk(this,hA),this.computeCollisions=this.computeCollisions.bind(this),$k(this,hA,AD(pA)),this.destroy=yO(()=>{let e=this.computeCollisions(),t=bD(()=>this.manager.dragOperation.position.current);if(e!==pA){let e=Zk(this,mA);if($k(this,mA,t),e&&t.x==e.x&&t.y==e.y)return}else $k(this,mA,void 0);Zk(this,hA).value=e},()=>{let{dragOperation:e}=this.manager;e.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){bD(()=>{e?Zk(this,hA).value=this.computeCollisions():$k(this,mA,void 0)})}computeCollisions(e,t){let{registry:n,dragOperation:r}=this.manager,{source:i,shape:a,status:o}=r;if(!o.initialized||!a)return pA;let s=[],c=[];for(let a of e??n.droppables){if(a.disabled||i&&!a.accepts(i))continue;let e=t??a.collisionDetector;if(!e)continue;c.push(a),a.shape;let n=bD(()=>e({droppable:a,dragOperation:r}));n&&(a.collisionPriority!=null&&(n.priority=a.collisionPriority),s.push(n))}return c.length===0?pA:(s.sort(fA),s)}get collisions(){return Zk(this,hA).value}};mA=new WeakMap,hA=new WeakMap;var _A,vA,yA=[gO],bA,xA,SA,CA,wA,TA,EA;vA=[gO],_A=[gO];var DA=class e{constructor(e,t){Qk(this,CA,qk(SA,8,this)),qk(SA,11,this),Qk(this,wA),Qk(this,TA,qk(SA,12,this)),qk(SA,15,this),Qk(this,EA,qk(SA,16,this)),qk(SA,19,this);let{effects:n,id:r,data:i={},disabled:a=!1,register:o=!0}=e,s=r;$k(this,wA,AD(r)),this.manager=t,this.data=i,this.disabled=a,this.effects=()=>[()=>{let{id:e,manager:t}=this;if(e!==s)return s=e,t?.registry.register(this),()=>t?.registry.unregister(this)},...n?.()??[]],this.register=this.register.bind(this),this.unregister=this.unregister.bind(this),this.destroy=this.destroy.bind(this),t&&o&&queueMicrotask(this.register)}get id(){let t=Zk(this,wA).value;return e.pendingIdChanges?.get(this)??t}set id(t){t!==(e.pendingIdChanges?.get(this)??Zk(this,wA).peek())&&(e.pendingIdChanges||(e.pendingIdChanges=new Map,queueMicrotask(()=>{var t;return eA(t=e,bA,xA).call(t)})),e.pendingIdChanges.set(this,t))}register(){return this.manager?.registry.register(this)}unregister(){var e;(e=this.manager)==null||e.registry.unregister(this)}destroy(){var e;(e=this.manager)==null||e.registry.unregister(this)}};SA=Hk(null),bA=new WeakSet,xA=function(){let e=DA.pendingIdChanges;DA.pendingIdChanges=null,e&&_D(()=>{for(let[t,n]of e)Zk(t,wA).value=n})},CA=new WeakMap,wA=new WeakMap,TA=new WeakMap,EA=new WeakMap,Jk(SA,4,`manager`,yA,DA,CA),Jk(SA,4,`data`,vA,DA,TA),Jk(SA,4,`disabled`,_A,DA,EA),Qk(DA,bA),Kk(SA,DA),DA.pendingIdChanges=null;var OA=DA,kA=class{constructor(){this.map=AD(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,t)=>{let n=this.map.peek(),r=n.get(e),i=()=>this.unregister(e,t);if(r===t)return i;r&&r.id===e&&(this.cleanupFunctions.get(r)?.(),this.cleanupFunctions.delete(r));let a=new Map(n);for(let[r,i]of n)if(i===t&&r!==e){a.delete(r);break}a.set(e,t),this.map.value=a;let o=yO(...t.effects());return this.cleanupFunctions.set(t,o),i},this.unregister=(e,t)=>{let n=this.map.peek();if(n.get(e)!==t)return;this.cleanupFunctions.get(t)?.(),this.cleanupFunctions.delete(t);let r=new Map(n);r.delete(e),this.map.value=r}}[Symbol.iterator](){return this.map.peek().values()}get value(){return this.map.value.values()}has(e){return this.map.value.has(e)}get(e){return this.map.value.get(e)}destroy(){for(let e of this)this.cleanupFunctions.get(e)?.(),e.destroy();this.map.value=new Map}},AA,jA,MA,NA,PA,FA,IA,LA,RA,zA,BA,VA=class extends (IA=OA,FA=[gO],PA=[gO],NA=[gO],MA=[_O],jA=[_O],AA=[_O],IA){constructor(e,t){var n=e,{modifiers:r,type:i,sensors:a,plugins:o,effects:s}=n,c=Vk(n,[`modifiers`,`type`,`sensors`,`plugins`,`effects`]);super(zk(Rk({},c),{effects:()=>[...s?.()??[],()=>{let{manager:e,plugins:t}=this;if(e&&t)for(let n of t){let{plugin:t}=rA(n);e.registry.plugins.register(t)}}]}),t),qk(LA,5,this),Qk(this,RA,qk(LA,8,this)),qk(LA,11,this),Qk(this,zA,qk(LA,12,this)),qk(LA,15,this),Qk(this,BA,qk(LA,16,this,this.isDragSource?`dragging`:`idle`)),qk(LA,19,this),this.type=i,this.sensors=a,this.modifiers=r,this.alignment=c.alignment,this.plugins=o}pluginConfig(e){if(this.plugins)for(let t of this.plugins){let n=rA(t);if(n.plugin===e)return n.options}}get isDropping(){return this.status===`dropping`&&this.isDragSource}get isDragging(){return this.status===`dragging`&&this.isDragSource}get isDragSource(){return this.manager?.dragOperation.source?.id===this.id}};LA=Hk(IA),RA=new WeakMap,zA=new WeakMap,BA=new WeakMap,Jk(LA,4,`type`,FA,VA,RA),Jk(LA,4,`modifiers`,PA,VA,zA),Jk(LA,4,`status`,NA,VA,BA),Jk(LA,2,`isDropping`,MA,VA),Jk(LA,2,`isDragging`,jA,VA),Jk(LA,2,`isDragSource`,AA,VA),Kk(LA,VA);var HA,UA,WA,GA,KA,qA,JA,YA,XA,ZA,QA,$A,ej,tj=class extends (JA=OA,qA=[gO],KA=[gO],GA=[gO],WA=[gO],UA=[gO],HA=[_O],JA){constructor(e,t){var n=e,{accept:r,collisionDetector:i,collisionPriority:a,type:o}=n,s=Vk(n,[`accept`,`collisionDetector`,`collisionPriority`,`type`]);super(s,t),qk(YA,5,this),Qk(this,XA,qk(YA,8,this)),qk(YA,11,this),Qk(this,ZA,qk(YA,12,this)),qk(YA,15,this),Qk(this,QA,qk(YA,16,this)),qk(YA,19,this),Qk(this,$A,qk(YA,20,this)),qk(YA,23,this),Qk(this,ej,qk(YA,24,this)),qk(YA,27,this),this.accept=r,this.collisionDetector=i,this.collisionPriority=a,this.type=o}accepts(e){let{accept:t}=this;return t?typeof t==`function`?t(e):e.type?Array.isArray(t)?t.includes(e.type):e.type===t:!1:!0}get isDropTarget(){return this.manager?.dragOperation.target?.id===this.id}};YA=Hk(JA),XA=new WeakMap,ZA=new WeakMap,QA=new WeakMap,$A=new WeakMap,ej=new WeakMap,Jk(YA,4,`accept`,qA,tj,XA),Jk(YA,4,`type`,KA,tj,ZA),Jk(YA,4,`collisionDetector`,GA,tj,QA),Jk(YA,4,`collisionPriority`,WA,tj,$A),Jk(YA,4,`shape`,UA,tj,ej),Jk(YA,2,`isDropTarget`,HA,tj),Kk(YA,tj);var nj=class{constructor(){this.registry=new Map}addEventListener(e,t){let{registry:n}=this,r=new Set(n.get(e));return r.add(t),n.set(e,r),()=>this.removeEventListener(e,t)}removeEventListener(e,t){let{registry:n}=this,r=new Set(n.get(e));r.delete(t),n.set(e,r)}dispatch(e,...t){let{registry:n}=this,r=n.get(e);if(r)for(let e of r)e(...t)}},rj=class extends nj{constructor(e){super(),this.manager=e}dispatch(e,t){let n=[t,this.manager];super.dispatch(e,...n)}};function ij(e,t=!0){let n=!1;return zk(Rk({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var aj=class extends lA{constructor(e){super(e);let t=(e,t)=>e.map(({id:e})=>e).join(``)===t.map(({id:e})=>e).join(``),n=[];this.destroy=yO(()=>{let{dragOperation:t,collisionObserver:r}=e;t.status.initializing&&(n=[],r.enable())},()=>{let{collisionObserver:r,monitor:i}=e,{collisions:a}=r;if(r.isDisabled()||OA.pendingIdChanges)return;let o=ij({collisions:a});if(i.dispatch(`collision`,o),o.defaultPrevented||t(a,n))return;n=a;let[s]=a;bD(()=>{s?.id!==e.dragOperation.target?.id&&(r.disable(),e.actions.setDropTarget(s?.id).then(()=>{r.enable()}))})})}},oj=(e=>(e[e.Lowest=0]=`Lowest`,e[e.Low=1]=`Low`,e[e.Normal=2]=`Normal`,e[e.High=3]=`High`,e[e.Highest=4]=`Highest`,e))(oj||{}),sj=(e=>(e[e.Collision=0]=`Collision`,e[e.ShapeIntersection=1]=`ShapeIntersection`,e[e.PointerIntersection=2]=`PointerIntersection`,e))(sj||{}),cj,lj,uj,dj,fj,pj,mj=[gO],hj,gj;pj=[_O],fj=[_O],dj=[_O],uj=[_O],lj=[_O],cj=[_O];var _j=class{constructor(){qk(hj,5,this),Qk(this,gj,qk(hj,8,this,`idle`)),qk(hj,11,this)}get current(){return this.value}get idle(){return this.value===`idle`}get initializing(){return this.value===`initializing`}get initialized(){let{value:e}=this;return e!==`idle`&&e!==`initialization-pending`}get dragging(){return this.value===`dragging`}get dropped(){return this.value===`dropped`}set(e){this.value=e}};hj=Hk(null),gj=new WeakMap,Jk(hj,4,`value`,mj,_j,gj),Jk(hj,2,`current`,pj,_j),Jk(hj,2,`idle`,fj,_j),Jk(hj,2,`initializing`,dj,_j),Jk(hj,2,`initialized`,uj,_j),Jk(hj,2,`dragging`,lj,_j),Jk(hj,2,`dropped`,cj,_j),Kk(hj,_j);var vj=class{constructor(e){this.manager=e}setDragSource(e){let{dragOperation:t}=this.manager;t.sourceIdentifier=typeof e==`string`||typeof e==`number`?e:e.id}setDropTarget(e){return bD(()=>{let{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;let r=ij({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch(`dragover`,r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return bD(()=>{let{dragOperation:t}=this.manager;if(e.source!=null&&this.setDragSource(e.source),!t.source)throw Error(`Cannot start a drag operation without a drag source`);if(!t.status.idle)throw Error(`Cannot start a drag operation while another is active`);let n=new AbortController,{event:r,coordinates:i}=e;_D(()=>{t.status.set(`initialization-pending`),t.shape=null,t.canceled=!1,t.activatorEvent=r??null,t.position.reset(i)});let a=ij({operation:t.snapshot()});return this.manager.monitor.dispatch(`beforedragstart`,a),a.defaultPrevented?(t.reset(),n.abort(),n):(t.status.set(`initializing`),t.controller=n,this.manager.renderer.rendering.then(()=>{if(n.signal.aborted)return;let{status:e}=t;e.current===`initializing`&&_D(()=>{t.status.set(`dragging`),this.manager.monitor.dispatch(`dragstart`,{nativeEvent:r,operation:t.snapshot(),cancelable:!1})})}),n)})}move(e){return bD(()=>{let{dragOperation:t}=this.manager,{status:n,controller:r}=t;if(!n.dragging||!r||r.signal.aborted)return;let i=ij({nativeEvent:e.event,operation:t.snapshot(),by:e.by,to:e.to},e.cancelable??!0);(e.propagate??!0)&&this.manager.monitor.dispatch(`dragmove`,i),queueMicrotask(()=>{if(i.defaultPrevented)return;let n=e.to??{x:t.position.current.x+(e.by?.x??0),y:t.position.current.y+(e.by?.y??0)};t.position.current=n})})}stop(e={}){return bD(()=>{let{dragOperation:t}=this.manager,{controller:n}=t;if(!n||n.signal.aborted)return;let r,i=()=>{let e={resume:()=>{},abort:()=>{}};return r=new Promise((t,n)=>{e.resume=t,e.abort=n}),e};n.abort();let a=()=>{this.manager.renderer.rendering.then(()=>{t.status.set(`dropped`);let e=bD(()=>t.source?.status===`dropping`),r=()=>{t.controller===n&&(t.controller=void 0),t.reset()};if(e){let{source:e}=t,n=BD(()=>{e?.status===`idle`&&(n(),r())})}else this.manager.renderer.rendering.then(r)})};t.canceled=e.canceled??!1,this.manager.monitor.dispatch(`dragend`,{nativeEvent:e.event,operation:t.snapshot(),canceled:e.canceled??!1,suspend:i}),r?r.then(a).catch(()=>t.reset()):a()})}},yj=class extends cA{constructor(e,t){super(e,t),this.manager=e,this.options=t}},bj=class extends AbortController{constructor(e,t){super(),this.constraints=e,this.onActivate=t,this.activated=!1;for(let t of e??[])t.controller=this}onEvent(e){if(!this.activated){if(this.constraints?.length)for(let t of this.constraints)t.onEvent(e);else this.activate(e)}}activate(e){this.activated||(this.activated=!0,this.onActivate(e))}abort(e){this.activated=!1,super.abort(e)}},xj,Sj=class{constructor(e){this.options=e,Qk(this,xj)}set controller(e){$k(this,xj,e),e.signal.addEventListener(`abort`,()=>this.abort())}activate(e){var t;(t=Zk(this,xj))==null||t.activate(e)}};xj=new WeakMap;var Cj=class extends cA{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},wj=class{constructor(e){this.draggables=new kA,this.droppables=new kA,this.plugins=new dA(e),this.sensors=new dA(e),this.modifiers=new dA(e)}register(e,t){if(e instanceof VA)return this.draggables.register(e.id,e);if(e instanceof tj)return this.droppables.register(e.id,e);if(e.prototype instanceof Cj)return this.modifiers.register(e,t);if(e.prototype instanceof yj)return this.sensors.register(e,t);if(e.prototype instanceof cA)return this.plugins.register(e,t);throw Error(`Invalid instance type`)}unregister(e){if(e instanceof OA)return e instanceof VA?this.draggables.unregister(e.id,e):e instanceof tj?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof Cj)return this.modifiers.unregister(e);if(e.prototype instanceof yj)return this.sensors.unregister(e);if(e.prototype instanceof cA)return this.plugins.unregister(e);throw Error(`Invalid instance type`)}destroy(){this.draggables.destroy(),this.droppables.destroy(),this.plugins.destroy(),this.sensors.destroy(),this.modifiers.destroy()}},Tj,Ej,Dj,Oj,kj,Aj,jj,Mj,Nj=[_O],Pj,Fj,Ij,Lj,Rj,zj,Bj,Vj,Hj,Uj;Mj=[gO],jj=[gO],Aj=[gO],kj=[gO],Oj=[gO],Dj=[_O],Ej=[_O],Tj=[_O];var Wj=class{constructor(e){qk(Lj,5,this),Qk(this,Pj),Qk(this,Fj),Qk(this,Ij,new BO(void 0,(e,t)=>e&&t?e.equals(t):e===t)),this.status=new _j,Qk(this,Rj,qk(Lj,8,this,!1)),qk(Lj,11,this),Qk(this,zj,qk(Lj,12,this,null)),qk(Lj,15,this),Qk(this,Bj,qk(Lj,16,this,null)),qk(Lj,19,this),Qk(this,Vj,qk(Lj,20,this,null)),qk(Lj,23,this),Qk(this,Hj,qk(Lj,24,this,[])),qk(Lj,27,this),this.position=new Ck({x:0,y:0}),Qk(this,Uj,{x:0,y:0}),$k(this,Pj,e)}get shape(){let{current:e,initial:t,previous:n}=Zk(this,Ij);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?Zk(this,Ij).current=e:Zk(this,Ij).reset()}get source(){let e=this.sourceIdentifier;if(e==null)return null;let t=Zk(this,Pj).registry.draggables.get(e);return t&&$k(this,Fj,t),t??Zk(this,Fj)??null}get target(){let e=this.targetIdentifier;return e==null?null:Zk(this,Pj).registry.droppables.get(e)??null}get transform(){let{x:e,y:t}=this.position.delta,n={x:e,y:t};for(let e of this.modifiers)n=e.apply(zk(Rk({},this.snapshot()),{transform:n}));return $k(this,Uj,n),n}snapshot(){return bD(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:Zk(this,Uj),shape:this.shape?VO(this.shape):null,position:VO(this.position),status:VO(this.status),canceled:this.canceled}))}reset(){_D(()=>{this.status.set(`idle`),this.sourceIdentifier=null,this.targetIdentifier=null,Zk(this,Ij).reset(),this.position.reset({x:0,y:0}),$k(this,Uj,{x:0,y:0}),this.modifiers=[]})}};Lj=Hk(null),Pj=new WeakMap,Fj=new WeakMap,Ij=new WeakMap,Rj=new WeakMap,zj=new WeakMap,Bj=new WeakMap,Vj=new WeakMap,Hj=new WeakMap,Uj=new WeakMap,Jk(Lj,2,`shape`,Nj,Wj),Jk(Lj,4,`canceled`,Mj,Wj,Rj),Jk(Lj,4,`activatorEvent`,jj,Wj,zj),Jk(Lj,4,`sourceIdentifier`,Aj,Wj,Bj),Jk(Lj,4,`targetIdentifier`,kj,Wj,Vj),Jk(Lj,4,`modifiers`,Oj,Wj,Hj),Jk(Lj,2,`source`,Dj,Wj),Jk(Lj,2,`target`,Ej,Wj),Jk(Lj,2,`transform`,Tj,Wj),Kk(Lj,Wj);var Gj={get rendering(){return Promise.resolve()}};function Kj(e,t){return typeof e==`function`?e(t):e??t}var qj=class{constructor(e){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(e=>e.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};let t=e??{},n=Kj(t.plugins,[]),r=Kj(t.sensors,[]),i=Kj(t.modifiers,[]),a=t.renderer??Gj,o=new rj(this),s=new wj(this);this.registry=s,this.monitor=o,this.renderer=a,this.actions=new vj(this),this.dragOperation=new Wj(this),this.collisionObserver=new gA(this),this.plugins=[aj,...n],this.modifiers=i,this.sensors=r;let{destroy:c}=this,l=yO(()=>{let e=bD(()=>this.dragOperation.modifiers),t=this.modifiers;for(let n of e)t.includes(n)||n.destroy();this.dragOperation.modifiers=(this.dragOperation.source?.modifiers)?.map(e=>{let{plugin:t,options:n}=rA(e);return new t(this,n)})??t});this.destroy=()=>{l(),c()}}get plugins(){return this.registry.plugins.values}set plugins(e){this.registry.plugins.values=e}get modifiers(){return this.registry.modifiers.values}set modifiers(e){this.registry.modifiers.values=e}get sensors(){return this.registry.sensors.values}set sensors(e){this.registry.sensors.values=e}},Jj=e=>{throw TypeError(e)},Yj=(e,t,n)=>t.has(e)||Jj(`Cannot `+n),Xj=(e,t,n)=>(Yj(e,t,`read from private field`),t.get(e)),Zj=(e,t,n)=>t.has(e)?Jj(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),Qj=(e,t,n,r)=>(Yj(e,t,`write to private field`),t.set(e,n),n),$j=(e,t,n)=>(Yj(e,t,`access private method`),n);function eM(e){return e?e instanceof KeyframeEffect||`getKeyframes`in e&&typeof e.getKeyframes==`function`:!1}function tM(e,t){let n=e.getAnimations(),r=null;for(let e of n){if(e.playState!==`running`)continue;let{effect:n}=e,i=(eM(n)?n.getKeyframes():[]).filter(t);i.length>0&&(r=[i[i.length-1],e])}return r}function nM(e){let{width:t,height:n,top:r,left:i,bottom:a,right:o}=e.getBoundingClientRect();return{width:t,height:n,top:r,left:i,bottom:a,right:o}}function rM(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function iM(e){return`nodeType`in e}function aM(e){return e?rM(e)?e:iM(e)?`defaultView`in e?e.defaultView??window:e.ownerDocument?.defaultView??window:window:window}function oM(e){let{Document:t}=aM(e);return e instanceof t||`nodeType`in e&&e.nodeType===Node.DOCUMENT_NODE}function sM(e){return!e||rM(e)?!1:e instanceof aM(e).HTMLElement||`namespaceURI`in e&&typeof e.namespaceURI==`string`&&e.namespaceURI.endsWith(`html`)}function cM(e){return e instanceof aM(e).SVGElement||`namespaceURI`in e&&typeof e.namespaceURI==`string`&&e.namespaceURI.endsWith(`svg`)}function lM(e){return e?rM(e)?e.document:iM(e)?oM(e)?e:sM(e)||cM(e)?e.ownerDocument:document:document:document}function uM(e){let{documentElement:t}=lM(e),n=aM(e).visualViewport,r=n?.width??t.clientWidth,i=n?.height??t.clientHeight,a=n?.offsetTop??0,o=n?.offsetLeft??0;return{top:a,left:o,right:o+r,bottom:a+i,width:r,height:i}}function dM(e,t){if(fM(e)&&e.open===!1)return!1;let{overflow:n,overflowX:r,overflowY:i}=getComputedStyle(e);return n===`visible`&&r===`visible`&&i===`visible`}function fM(e){return e.tagName===`DETAILS`}function pM(e,t=e.getBoundingClientRect(),n=0){let r=t,{ownerDocument:i}=e,a=i.defaultView??window,o=e.parentElement;for(;o&&o!==i.documentElement;){if(!dM(o)){let e=o.getBoundingClientRect(),t=n*(e.bottom-e.top),i=n*(e.right-e.left),a=n*(e.bottom-e.top),s=n*(e.right-e.left);r={top:Math.max(r.top,e.top-t),right:Math.min(r.right,e.right+i),bottom:Math.min(r.bottom,e.bottom+a),left:Math.max(r.left,e.left-s),width:0,height:0},r.width=r.right-r.left,r.height=r.bottom-r.top}o=o.parentElement}let s=a.visualViewport,c=s?.offsetTop??0,l=s?.offsetLeft??0,u=s?.width??a.innerWidth,d=s?.height??a.innerHeight,f=n*d,p=n*u;return r={top:Math.max(r.top,c-f),right:Math.min(r.right,l+u+p),bottom:Math.min(r.bottom,c+d+f),left:Math.max(r.left,l-p),width:0,height:0},r.width=r.right-r.left,r.height=r.bottom-r.top,r.width<0&&(r.width=0),r.height<0&&(r.height=0),r}function mM(e){return{x:e.clientX,y:e.clientY}}var hM=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function gM(e=document,t=new Set){if(t.has(e))return[];t.add(e);let n=[e];for(let r of Array.from(e.querySelectorAll(`iframe, frame`)))try{let e=r.contentDocument;e&&!t.has(e)&&n.push(...gM(e,t))}catch{}try{let r=e.defaultView;if(r&&r!==window.top){let i=r.parent;i&&i.document&&i.document!==e&&n.push(...gM(i.document,t))}}catch{}return n}function _M(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function vM(){let e=_M()?window.visualViewport:null;return{x:e?.offsetLeft??0,y:e?.offsetTop??0}}function yM(e){return!e||!iM(e)?!1:e instanceof aM(e).ShadowRoot}function bM(e){if(e&&iM(e)){let t=e.getRootNode();if(yM(t)||t instanceof Document)return t}return lM(e)}function xM(e){return e.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function SM(e){let t=`input, textarea, select, canvas, [contenteditable]`,n=e.cloneNode(!0),r=Array.from(e.querySelectorAll(t));return Array.from(n.querySelectorAll(t)).forEach((e,t)=>{let n=r[t];CM(e)&&CM(n)&&(e.type!==`file`&&(e.value=n.value),e.type===`radio`&&e.name&&(e.name=`Cloned__${e.name}`)),wM(e)&&wM(n)&&n.width>0&&n.height>0&&e.getContext(`2d`)?.drawImage(n,0,0)}),n}function CM(e){return`value`in e}function wM(e){return e.tagName===`CANVAS`}function TM(e,{x:t,y:n}){let r=e.elementFromPoint(t,n);if(EM(r)){let{contentDocument:e}=r;if(e){let{left:i,top:a}=r.getBoundingClientRect();return TM(e,{x:t-i,y:n-a})}}return r}function EM(e){return e?.tagName===`IFRAME`}var DM=new WeakMap;function OM(e){return e.closest(`
96
96
  input:not([disabled]),
97
97
  select:not([disabled]),
98
98
  textarea:not([disabled]),
@@ -4,7 +4,7 @@
4
4
  <meta charset="utf-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
6
  <title>vde-open</title>
7
- <script type="module" crossorigin src="/assets/index-D_AZ0n--.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-BKrIIMW1.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/assets/index-BfusO5QE.css">
9
9
  </head>
10
10
  <body>
@@ -1,5 +1,5 @@
1
- import { a as ParseLimitError, o as analyzeDocument } from "../rendering-rules-DiE2jI7I.js";
2
- import { n as scanReferences, t as renderDocument } from "../render-BJnuEfHt.js";
1
+ import { d as analyzeDocument, u as ParseLimitError } from "../html-static-BDV6MgA7.js";
2
+ import { n as scanReferences, t as renderDocument } from "../render-BX3arVZj.js";
3
3
  import { n as measureHeap, t as collectGarbage } from "../heap-C3qHm7SE.js";
4
4
  import { parentPort } from "node:worker_threads";
5
5
  //#region src/workers/parse-worker.ts
@@ -15,9 +15,10 @@ async function run(request) {
15
15
  }
16
16
  if (request.op === "analyze") return analyzeDocument(request.text, request.format);
17
17
  if (request.op === "scan") return scanReferences(request.kind, request.text);
18
- if (request.op === "print") {
19
- printModule ??= import("../print-CR5-GDjQ.js");
20
- return (await printModule).renderPrintDocument(request.input);
18
+ if (request.op === "print" || request.op === "printHtml") {
19
+ printModule ??= import("../print-Cfa1Ytrj.js");
20
+ const printer = await printModule;
21
+ return request.op === "print" ? printer.renderPrintDocument(request.input) : printer.renderHtmlPrintDocument(request.input);
21
22
  }
22
23
  return renderDocument(request.input);
23
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vde-open",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "A local document viewer shared by agents and people: open Markdown and HTML documents, search and read them from the CLI, and ask the person questions.",
5
5
  "keywords": [
6
6
  "agent",