@hienlh/ppm 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{i as e,n as t,r as n,t as r}from"./jsx-runtime-BnxRlLMJ.js";import{n as i,t as a}from"./utils-Cgi2TYRi.js";var o=n((e=>{var n=t();function r(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(){}var a={d:{f:i,r:function(){throw Error(r(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for(`react.portal`);function s(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var c=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(r(299));return s(e,t,null,n)},e.flushSync=function(e){var t=c.T,n=a.p;try{if(c.T=null,a.p=2,e)return e()}finally{c.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=l(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??a.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=l(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else a.d.m(e)},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return c.H.useFormState(e,t,n)},e.useFormStatus=function(){return c.H.useHostTransitionStatus()},e.version=`19.2.4`})),s=n(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=o()})),c=e(t(),1);function l(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function u(...e){return t=>{let n=!1,r=e.map(e=>{let r=l(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():l(e[t],null)}}}}function d(...e){return c.useCallback(u(...e),e)}var f=r();function p(e){let t=h(e),n=c.forwardRef((e,n)=>{let{children:r,...i}=e,a=c.Children.toArray(r),o=a.find(v);if(o){let e=o.props.children,r=a.map(t=>t===o?c.Children.count(e)>1?c.Children.only(null):c.isValidElement(e)?e.props.children:null:t);return(0,f.jsx)(t,{...i,ref:n,children:c.isValidElement(e)?c.cloneElement(e,void 0,r):null})}return(0,f.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}var m=p(`Slot`);function h(e){let t=c.forwardRef((e,t)=>{let{children:n,...r}=e;if(c.isValidElement(n)){let e=b(n),i=y(r,n.props);return n.type!==c.Fragment&&(i.ref=t?u(t,e):e),c.cloneElement(n,i)}return c.Children.count(n)>1?c.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var g=Symbol(`radix.slottable`);function _(e){let t=({children:e})=>(0,f.jsx)(f.Fragment,{children:e});return t.displayName=`${e}.Slottable`,t.__radixId=g,t}function v(e){return c.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===g}function y(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function b(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var x=e(s(),1),S=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=p(`Primitive.${t}`),r=c.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,f.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function C(e,t){e&&x.flushSync(()=>e.dispatchEvent(t))}var w=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,T=i,E=((e,t)=>n=>{if(t?.variants==null)return T(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=w(t)||w(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return T(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)})(`inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none 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 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/90`,destructive:`bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40`,outline:`border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-4 py-2 has-[>svg]:px-3`,xs:`h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5`,lg:`h-10 rounded-md px-6 has-[>svg]:px-4`,icon:`size-9`,"icon-xs":`size-6 rounded-md [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-8`,"icon-lg":`size-10`}},defaultVariants:{variant:`default`,size:`default`}});function D({className:e,variant:t=`default`,size:n=`default`,asChild:r=!1,...i}){return(0,f.jsx)(r?m:`button`,{"data-slot":`button`,"data-variant":t,"data-size":n,className:a(E({variant:t,size:n,className:e})),...i})}export{_ as a,s as c,p as i,S as n,u as o,C as r,d as s,D as t};
1
+ import{i as e,n as t,r as n,t as r}from"./jsx-runtime-BnxRlLMJ.js";import{r as i,t as a}from"./utils-CiBGfeHD.js";var o=n((e=>{var n=t();function r(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(){}var a={d:{f:i,r:function(){throw Error(r(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for(`react.portal`);function s(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var c=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(r(299));return s(e,t,null,n)},e.flushSync=function(e){var t=c.T,n=a.p;try{if(c.T=null,a.p=2,e)return e()}finally{c.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=l(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??a.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=l(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else a.d.m(e)},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return c.H.useFormState(e,t,n)},e.useFormStatus=function(){return c.H.useHostTransitionStatus()},e.version=`19.2.4`})),s=n(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=o()})),c=e(t(),1);function l(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function u(...e){return t=>{let n=!1,r=e.map(e=>{let r=l(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():l(e[t],null)}}}}function d(...e){return c.useCallback(u(...e),e)}var f=r();function p(e){let t=h(e),n=c.forwardRef((e,n)=>{let{children:r,...i}=e,a=c.Children.toArray(r),o=a.find(v);if(o){let e=o.props.children,r=a.map(t=>t===o?c.Children.count(e)>1?c.Children.only(null):c.isValidElement(e)?e.props.children:null:t);return(0,f.jsx)(t,{...i,ref:n,children:c.isValidElement(e)?c.cloneElement(e,void 0,r):null})}return(0,f.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}var m=p(`Slot`);function h(e){let t=c.forwardRef((e,t)=>{let{children:n,...r}=e;if(c.isValidElement(n)){let e=b(n),i=y(r,n.props);return n.type!==c.Fragment&&(i.ref=t?u(t,e):e),c.cloneElement(n,i)}return c.Children.count(n)>1?c.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var g=Symbol(`radix.slottable`);function _(e){let t=({children:e})=>(0,f.jsx)(f.Fragment,{children:e});return t.displayName=`${e}.Slottable`,t.__radixId=g,t}function v(e){return c.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===g}function y(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function b(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var x=e(s(),1),S=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=p(`Primitive.${t}`),r=c.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,f.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function C(e,t){e&&x.flushSync(()=>e.dispatchEvent(t))}var w=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,T=i,E=((e,t)=>n=>{if(t?.variants==null)return T(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=w(t)||w(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return T(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)})(`inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none 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 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/90`,destructive:`bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40`,outline:`border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-4 py-2 has-[>svg]:px-3`,xs:`h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5`,lg:`h-10 rounded-md px-6 has-[>svg]:px-4`,icon:`size-9`,"icon-xs":`size-6 rounded-md [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-8`,"icon-lg":`size-10`}},defaultVariants:{variant:`default`,size:`default`}});function D({className:e,variant:t=`default`,size:n=`default`,asChild:r=!1,...i}){return(0,f.jsx)(r?m:`button`,{"data-slot":`button`,"data-variant":t,"data-size":n,className:a(E({variant:t,size:n,className:e})),...i})}export{_ as a,s as c,p as i,S as n,u as o,C as r,d as s,D as t};
@@ -0,0 +1,61 @@
1
+ import{i as e,n as t,t as n}from"./jsx-runtime-BnxRlLMJ.js";import{t as r}from"./createLucideIcon-Dy1wlrF7.js";import{a as i,n as a,r as o,t as s}from"./api-client-Bnf9LAt4.js";import{t as c}from"./refresh-cw-DtopuYJf.js";import{t as l}from"./trash-2-CHLebaNh.js";import{t as u}from"./x-BISR7bpK.js";import{n as d}from"./utils-CiBGfeHD.js";import{C as f,S as p,f as m,g as h,l as g,m as _,p as v,u as y,v as b,w as x,x as S,y as C}from"./index-BHEFCU01.js";var w=r(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),T=r(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),ee=r(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),E=r(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),te=r(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),ne=r(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),re=r(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),D=r(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),O=r(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),ie=r(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),k=r(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),A=e(t(),1),ae=3e4,oe=1e3,se=class{ws=null;url;handlers=[];reconnectAttempts=0;reconnectTimer=null;intentionalClose=!1;constructor(e){this.url=e}connect(){this.intentionalClose=!1,this.cleanup();let e=window.location.protocol===`https:`?`wss:`:`ws:`,t=this.url.startsWith(`ws`)?this.url:`${e}//${window.location.host}${this.url}`;this.ws=new WebSocket(t),this.ws.onopen=()=>{this.reconnectAttempts=0},this.ws.onmessage=e=>{for(let t of this.handlers)t(e)},this.ws.onclose=()=>{this.intentionalClose||this.scheduleReconnect()},this.ws.onerror=()=>{this.ws?.close()}}disconnect(){this.intentionalClose=!0,this.cleanup(),this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null)}send(e){this.ws?.readyState===WebSocket.OPEN&&this.ws.send(e)}onMessage(e){return this.handlers.push(e),()=>{this.handlers=this.handlers.filter(t=>t!==e)}}get isConnected(){return this.ws?.readyState===WebSocket.OPEN}cleanup(){this.ws&&=(this.ws.onopen=null,this.ws.onclose=null,this.ws.onmessage=null,this.ws.onerror=null,(this.ws.readyState===WebSocket.OPEN||this.ws.readyState===WebSocket.CONNECTING)&&this.ws.close(),null)}scheduleReconnect(){let e=Math.min(oe*2**this.reconnectAttempts,ae);this.reconnectAttempts++,this.reconnectTimer=setTimeout(()=>this.connect(),e)}};function ce({url:e,onMessage:t,autoConnect:n=!0}){let r=(0,A.useRef)(null);return(0,A.useEffect)(()=>{let i=new se(e);return r.current=i,t&&i.onMessage(t),n&&i.connect(),()=>{i.disconnect(),r.current=null}},[e,n]),{send:(0,A.useCallback)(e=>{r.current?.send(e)},[]),connect:(0,A.useCallback)(()=>{r.current?.connect()},[]),disconnect:(0,A.useCallback)(()=>{r.current?.disconnect()},[])}}function le(e,t=`claude-sdk`,n=``){let[r,i]=(0,A.useState)([]),[s,c]=(0,A.useState)(!1),[l,u]=(0,A.useState)(!1),[d,f]=(0,A.useState)(null),[p,m]=(0,A.useState)(!1),[h,g]=(0,A.useState)({}),[_,v]=(0,A.useState)(!1),y=(0,A.useRef)(``),b=(0,A.useRef)([]),x=(0,A.useRef)(!1),S=(0,A.useRef)(null),C=(0,A.useRef)(()=>{}),w=(0,A.useCallback)(e=>{let t;try{t=JSON.parse(e.data)}catch{return}if(t.type!==`ping`){if(t.type===`connected`){m(!0);return}switch(t.type){case`text`:{y.current+=t.content,b.current.push(t);let e=y.current,n=[...b.current];i(t=>{let r=t[t.length-1];return r?.role===`assistant`&&!r.id.startsWith(`final-`)?[...t.slice(0,-1),{...r,content:e,events:n}]:[...t,{id:`streaming-${Date.now()}`,role:`assistant`,content:e,events:n,timestamp:new Date().toISOString()}]});break}case`tool_use`:{b.current.push(t);let e=y.current,n=[...b.current];i(t=>{let r=t[t.length-1];return r?.role===`assistant`?[...t.slice(0,-1),{...r,events:n}]:[...t,{id:`streaming-${Date.now()}`,role:`assistant`,content:e,events:n,timestamp:new Date().toISOString()}]});break}case`tool_result`:{b.current.push(t);let e=[...b.current];i(t=>{let n=t[t.length-1];return n?.role===`assistant`?[...t.slice(0,-1),{...n,events:e}]:t});break}case`approval_request`:b.current.push(t),f({requestId:t.requestId,tool:t.tool,input:t.input});break;case`usage`:g(e=>{let n={...e,...t.usage};return t.usage.totalCostUsd!=null&&(n.queryCostUsd=t.usage.totalCostUsd,n.totalCostUsd=(e.totalCostUsd??0)+t.usage.totalCostUsd),n});break;case`error`:{b.current.push(t);let e=[...b.current];i(n=>{let r=n[n.length-1];return r?.role===`assistant`?[...n.slice(0,-1),{...r,events:e}]:[...n,{id:`error-${Date.now()}`,role:`system`,content:t.message,events:[t],timestamp:new Date().toISOString()}]}),x.current=!1,u(!1);break}case`done`:{let e=y.current,t=[...b.current];i(n=>{let r=n[n.length-1];return r?.role===`assistant`?[...n.slice(0,-1),{...r,id:`final-${Date.now()}`,content:e||r.content,events:t.length>0?t:r.events}]:n}),y.current=``,b.current=[];let n=S.current;n?(S.current=null,i(e=>[...e,{id:`user-${Date.now()}`,role:`user`,content:n,timestamp:new Date().toISOString()}]),y.current=``,b.current=[],x.current=!0,u(!0),C.current(JSON.stringify({type:`message`,content:n}))):(x.current=!1,u(!1));break}}}},[]),{send:T}=ce({url:e&&n?`/ws/project/${encodeURIComponent(n)}/chat/${e}`:``,onMessage:w,autoConnect:!!e&&!!n});return C.current=T,(0,A.useEffect)(()=>{let r=!1;return u(!1),f(null),y.current=``,b.current=[],m(!1),n&&fetch(`${o(n)}/chat/usage?providerId=${t}`,{headers:{Authorization:`Bearer ${a()}`}}).then(e=>e.json()).then(e=>{!r&&e.ok&&e.data&&g(t=>({...t,...e.data}))}).catch(()=>{}),e&&n?(c(!0),fetch(`${o(n)}/chat/sessions/${e}/messages?providerId=${t}`,{headers:{Authorization:`Bearer ${a()}`}}).then(e=>e.json()).then(e=>{r||x.current||(e.ok&&Array.isArray(e.data)&&e.data.length>0?i(e.data):i([]))}).catch(()=>{!r&&!x.current&&i([])}).finally(()=>{r||c(!1)})):i([]),()=>{r=!0}},[e,t,n]),{messages:r,messagesLoading:s,isStreaming:l,pendingApproval:d,usageInfo:h,usageLoading:_,sendMessage:(0,A.useCallback)(e=>{if(e.trim()){if(l){S.current=e;return}i(t=>[...t,{id:`user-${Date.now()}`,role:`user`,content:e,timestamp:new Date().toISOString()}]),y.current=``,b.current=[],x.current=!0,u(!0),T(JSON.stringify({type:`message`,content:e}))}},[T,l]),respondToApproval:(0,A.useCallback)((e,t,n)=>{if(T(JSON.stringify({type:`approval_response`,requestId:e,approved:t,data:n})),t&&n){let t=b.current.find(t=>t.type===`approval_request`&&t.requestId===e&&t.tool===`AskUserQuestion`);if(t){let e=t.input;e&&typeof e==`object`&&(e.answers=n)}i(e=>[...e])}f(null)},[T]),cancelStreaming:(0,A.useCallback)(()=>{if(!x.current)return;T(JSON.stringify({type:`cancel`}));let e=y.current,t=[...b.current];i(n=>{let r=n[n.length-1];return r?.role===`assistant`?[...n.slice(0,-1),{...r,id:`final-${Date.now()}`,content:e||r.content,events:t.length>0?t:r.events}]:n}),y.current=``,b.current=[],S.current=null,x.current=!1,u(!1),f(null)},[T]),refreshUsage:(0,A.useCallback)(()=>{n&&(v(!0),fetch(`${o(n)}/chat/usage?providerId=${t}&_t=${Date.now()}`,{headers:{Authorization:`Bearer ${a()}`}}).then(e=>e.json()).then(e=>{e.ok&&e.data&&g(t=>({...t,...e.data}))}).catch(()=>{}).finally(()=>v(!1)))},[n,t]),isConnected:p}}function j(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var M=j();function ue(e){M=e}var N={exec:()=>null};function P(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(F.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var de=(()=>{try{return!0}catch{return!1}})(),F={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},fe=/^(?:[ \t]*(?:\n|$))+/,pe=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,me=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,I=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,he=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,L=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,ge=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_e=P(ge).replace(/bull/g,L).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),ve=P(ge).replace(/bull/g,L).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),R=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ye=/^[^\n]+/,be=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,xe=P(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,be).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Se=P(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,L).getRegex(),z=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,Ce=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,we=P(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Ce).replace(`tag`,z).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Te=P(R).replace(`hr`,I).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,z).getRegex(),Ee={blockquote:P(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Te).getRegex(),code:pe,def:xe,fences:me,heading:he,hr:I,html:we,lheading:_e,list:Se,newline:fe,paragraph:Te,table:N,text:ye},De=P(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,I).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,z).getRegex(),Oe={...Ee,lheading:ve,table:De,paragraph:P(R).replace(`hr`,I).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,De).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,z).getRegex()},ke={...Ee,html:P(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Ce).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:N,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:P(R).replace(`hr`,I).replace(`heading`,` *#{1,6} *[^
2
+ ]`).replace(`lheading`,_e).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Ae=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,je=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Me=/^( {2,}|\\)\n(?!\s*$)/,Ne=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,B=/[\p{P}\p{S}]/u,Pe=/[\s\p{P}\p{S}]/u,Fe=/[^\s\p{P}\p{S}]/u,Ie=P(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Pe).getRegex(),Le=/(?!~)[\p{P}\p{S}]/u,Re=/(?!~)[\s\p{P}\p{S}]/u,ze=/(?:[^\s\p{P}\p{S}]|~)/u,Be=/(?![*_])[\p{P}\p{S}]/u,Ve=/(?![*_])[\s\p{P}\p{S}]/u,He=/(?:[^\s\p{P}\p{S}]|[*_])/u,Ue=P(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,de?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),We=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Ge=P(We,`u`).replace(/punct/g,B).getRegex(),Ke=P(We,`u`).replace(/punct/g,Le).getRegex(),qe=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,Je=P(qe,`gu`).replace(/notPunctSpace/g,Fe).replace(/punctSpace/g,Pe).replace(/punct/g,B).getRegex(),Ye=P(qe,`gu`).replace(/notPunctSpace/g,ze).replace(/punctSpace/g,Re).replace(/punct/g,Le).getRegex(),Xe=P(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Fe).replace(/punctSpace/g,Pe).replace(/punct/g,B).getRegex(),Ze=P(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,Be).getRegex(),Qe=P(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,He).replace(/punctSpace/g,Ve).replace(/punct/g,Be).getRegex(),$e=P(/\\(punct)/,`gu`).replace(/punct/g,B).getRegex(),et=P(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),tt=P(Ce).replace(`(?:-->|$)`,`-->`).getRegex(),nt=P(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,tt).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),V=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,rt=P(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,V).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),it=P(/^!?\[(label)\]\[(ref)\]/).replace(`label`,V).replace(`ref`,be).getRegex(),at=P(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,be).getRegex(),ot=P(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,it).replace(`nolink`,at).getRegex(),st=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ct={_backpedal:N,anyPunctuation:$e,autolink:et,blockSkip:Ue,br:Me,code:je,del:N,delLDelim:N,delRDelim:N,emStrongLDelim:Ge,emStrongRDelimAst:Je,emStrongRDelimUnd:Xe,escape:Ae,link:rt,nolink:at,punctuation:Ie,reflink:it,reflinkSearch:ot,tag:nt,text:Ne,url:N},lt={...ct,link:P(/^!?\[(label)\]\((.*?)\)/).replace(`label`,V).getRegex(),reflink:P(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,V).getRegex()},ut={...ct,emStrongRDelimAst:Ye,emStrongLDelim:Ke,delLDelim:Ze,delRDelim:Qe,url:P(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,st).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:P(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,st).getRegex()},dt={...ut,br:P(Me).replace(`{2,}`,`*`).getRegex(),text:P(ut.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},H={normal:Ee,gfm:Oe,pedantic:ke},U={normal:ct,gfm:ut,breaks:dt,pedantic:lt},ft={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},pt=e=>ft[e];function W(e,t){if(t){if(F.escapeTest.test(e))return e.replace(F.escapeReplace,pt)}else if(F.escapeTestNoEncode.test(e))return e.replace(F.escapeReplaceNoEncode,pt);return e}function mt(e){try{e=encodeURI(e).replace(F.percentDecode,`%`)}catch{return null}return e}function ht(e,t){let n=e.replace(F.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(F.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(F.slashPipe,`|`);return n}function G(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function gt(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function _t(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function vt(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function yt(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
3
+ `).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
4
+ `)}var bt=class{options;rules;lexer;constructor(e){this.options=e||M}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:G(e,`
5
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=yt(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=G(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:G(t[0],`
6
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=G(t[0],`
7
+ `).split(`
8
+ `),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o;for(o=0;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
9
+ `),c=s.replace(this.rules.other.blockquoteSetextReplace,`
10
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
11
+ ${s}`:s,r=r?`${r}
12
+ ${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=l,e.length===0)break;let u=i.at(-1);if(u?.type===`code`)break;if(u?.type===`blockquote`){let t=u,a=t.raw+`
13
+ `+e.join(`
14
+ `),o=this.blockquote(a);i[i.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,r=r.substring(0,r.length-t.text.length)+o.text;break}else if(u?.type===`list`){let t=u,a=t.raw+`
15
+ `+e.join(`
16
+ `),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
17
+ `);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=_t(t[2].split(`
18
+ `,1)[0],t[1].length),l=e.split(`
19
+ `,1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,s=c.trimStart()):u?d=t[1].length+1:(d=c.search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+`
20
+ `,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d),f=this.rules.other.blockquoteBeginRegex(d);for(;e;){let p=e.split(`
21
+ `,1)[0],m;if(l=p,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),m=l):m=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||f.test(l)||t.test(l)||n.test(l))break;if(m.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
22
+ `+m.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
23
+ `+l}u=!l.trim(),r+=p+`
24
+ `,e=e.substring(p.length+1),c=m.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,``),e.tokens[0]?.type===`text`||e.tokens[0]?.type===`paragraph`){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,``),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}}let t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let n={type:`checkbox`,raw:t[0]+` `,checked:t[0]!==`[ ]`};e.checked=n.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=n.raw+e.tokens[0].raw,e.tokens[0].text=n.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(n)):e.tokens.unshift({type:`paragraph`,raw:n.raw,text:n.raw,tokens:[n]}):e.tokens.unshift(n)}}if(!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:`html`,block:!0,raw:t[0],pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=ht(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
25
+ `):[],a={type:`table`,raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(ht(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:`heading`,raw:t[0],depth:t[2].charAt(0)===`=`?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
26
+ `?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=G(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=gt(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),vt(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return vt(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[2])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}else if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},K=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||M,this.options.tokenizer=this.options.tokenizer||new bt,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:F,block:H.normal,inline:U.normal};this.options.pedantic?(t.block=H.pedantic,t.inline=U.pedantic):this.options.gfm&&(t.block=H.gfm,this.options.breaks?t.inline=U.breaks:t.inline=U.gfm),this.tokenizer.rules=t}static get rules(){return{block:H,inline:U}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(F.carriageReturn,`
27
+ `),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(F.tabCharGlobal,` `).replace(F.spaceLine,``));e;){let r;if(this.options.extensions?.block?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);r.raw.length===1&&n!==void 0?n.raw+=`
28
+ `:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
29
+ `)?``:`
30
+ `)+r.raw,n.text+=`
31
+ `+r.text,this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
32
+ `)?``:`
33
+ `)+r.raw,n.text+=`
34
+ `+r.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},t.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let a=t.at(-1);n&&a?.type===`paragraph`?(a.raw+=(a.raw.endsWith(`
35
+ `)?``:`
36
+ `)+r.raw,a.text+=`
37
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
38
+ `)?``:`
39
+ `)+r.raw,n.text+=`
40
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)i=r[2]?r[2].length:0,n=n.slice(0,r.index+i)+`[`+`a`.repeat(r[0].length-i-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let a=!1,o=``;for(;e;){a||(o=``),a=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(i)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(o=r.raw.slice(-1)),a=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return t}},xt=class{options;parser;constructor(e){this.options=e||M}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(F.notSpaceStart)?.[0],i=e.replace(F.endingNewline,``)+`
41
+ `;return r?`<pre><code class="language-`+W(r)+`">`+(n?i:W(i,!0))+`</code></pre>
42
+ `:`<pre><code>`+(n?i:W(i,!0))+`</code></pre>
43
+ `}blockquote({tokens:e}){return`<blockquote>
44
+ ${this.parser.parse(e)}</blockquote>
45
+ `}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
46
+ `}hr(e){return`<hr>
47
+ `}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?`ol`:`ul`,a=t&&n!==1?` start="`+n+`"`:``;return`<`+i+a+`>
48
+ `+r+`</`+i+`>
49
+ `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
50
+ `}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox"> `}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
51
+ `}table(e){let t=``,n=``;for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r=``;for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n=``;for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&=`<tbody>${r}</tbody>`,`<table>
52
+ <thead>
53
+ `+t+`</thead>
54
+ `+r+`</table>
55
+ `}tablerow({text:e}){return`<tr>
56
+ ${e}</tr>
57
+ `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
58
+ `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${W(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=mt(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+W(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=mt(e);if(i===null)return W(n);e=i;let a=`<img src="${e}" alt="${W(n)}"`;return t&&(a+=` title="${W(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:W(e.text)}},St=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},q=class e{options;renderer;textRenderer;constructor(e){this.options=e||M,this.options.renderer=this.options.renderer||new xt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new St}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},J=class{options;block;constructor(e){this.options=e||M}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?K.lex:K.lexInline}provideParser(){return this.block?q.parse:q.parseInline}},Y=new class{defaults=j();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=q;Renderer=xt;TextRenderer=St;Lexer=K;Tokenizer=bt;Hooks=J;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new xt(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new bt(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new J;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];J.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&J.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return K.lex(e,t??this.defaults)}parser(e,t){return q.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer():e?K.lex:K.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser():e?q.parse:q.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer():e?K.lex:K.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser():e?q.parse:q.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
59
+ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+W(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function X(e,t){return Y.parse(e,t)}X.options=X.setOptions=function(e){return Y.setOptions(e),X.defaults=Y.defaults,ue(X.defaults),X},X.getDefaults=j,X.defaults=M,X.use=function(...e){return Y.use(...e),X.defaults=Y.defaults,ue(X.defaults),X},X.walkTokens=function(e,t){return Y.walkTokens(e,t)},X.parseInline=Y.parseInline,X.Parser=q,X.parser=q.parse,X.Renderer=xt,X.TextRenderer=St,X.Lexer=K,X.lexer=K.lex,X.Tokenizer=bt,X.Hooks=J,X.parse=X,X.options,X.setOptions,X.use,X.walkTokens,X.parseInline,q.parse,K.lex;var Z=n();function Ct({messages:e,messagesLoading:t,pendingApproval:n,onApprovalResponse:r,isStreaming:i,projectName:a}){let o=(0,A.useRef)(null),s=(0,A.useRef)(!0);return(0,A.useEffect)(()=>{let t=s.current?`instant`:`smooth`;o.current?.scrollIntoView({behavior:t}),s.current&&e.length>0&&(s.current=!1)},[e,n]),t?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,Z.jsx)(T,{className:`size-10 text-text-subtle animate-pulse`}),(0,Z.jsx)(`p`,{className:`text-sm`,children:`Loading messages...`})]}):e.length===0&&!i?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,Z.jsx)(T,{className:`size-10 text-text-subtle`}),(0,Z.jsx)(`p`,{className:`text-sm`,children:`Send a message to start the conversation`})]}):(0,Z.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[e.filter(e=>{let t=e.content&&e.content.trim().length>0,n=e.events&&e.events.length>0;return t||n}).map(e=>(0,Z.jsx)(wt,{message:e,isStreaming:i&&e.id.startsWith(`streaming-`),projectName:a},e.id)),n&&(n.tool===`AskUserQuestion`?(0,Z.jsx)(Ut,{approval:n,onRespond:r}):(0,Z.jsx)(Ht,{approval:n,onRespond:r})),i&&(0,Z.jsx)(It,{lastMessage:e[e.length-1]}),(0,Z.jsx)(`div`,{ref:o})]})}function wt({message:e,isStreaming:t,projectName:n}){return e.role===`user`?(0,Z.jsx)(At,{content:e.content,projectName:n}):e.role===`system`?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-red-500/10 border border-red-500/20 px-3 py-2 text-sm text-red-400`,children:[(0,Z.jsx)(p,{className:`size-4 shrink-0`}),(0,Z.jsx)(`p`,{children:e.content})]}):(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.events&&e.events.length>0?(0,Z.jsx)(Nt,{events:e.events,isStreaming:t}):e.content&&(0,Z.jsx)(`div`,{className:`text-sm text-text-primary`,children:(0,Z.jsx)(Lt,{content:e.content})})})}var Tt=new Set([`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`]);function Et(e){let t=e.match(/^\[Attached file: (.+?)\]\n\n?/);if(t)return{files:[t[1]],text:e.slice(t[0].length)};let n=e.match(/^\[Attached files:\n([\s\S]+?)\]\n\n?/);return n?{files:n[1].split(`
60
+ `).map(e=>e.trim()).filter(Boolean),text:e.slice(n[0].length)}:{files:[],text:e}}function Dt(e,t){let n=e.split(`/`).pop()??``;return`/api/project/${encodeURIComponent(t??`_`)}/chat/uploads/${encodeURIComponent(n)}`}function Ot(e){let t=e.lastIndexOf(`.`);return t===-1?!1:Tt.has(e.slice(t).toLowerCase())}function kt(e){return e.toLowerCase().endsWith(`.pdf`)}function At({content:e,projectName:t}){let{files:n,text:r}=(0,A.useMemo)(()=>Et(e),[e]);return(0,Z.jsx)(`div`,{className:`flex justify-end`,children:(0,Z.jsxs)(`div`,{className:`rounded-lg bg-primary/10 px-3 py-2 text-sm text-text-primary max-w-[85%] space-y-2`,children:[n.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:n.map((e,n)=>Ot(e)?(0,Z.jsx)(jt,{src:Dt(e,t),alt:e.split(`/`).pop()??`image`},n):kt(e)?(0,Z.jsx)(Mt,{src:Dt(e,t),filename:e.split(`/`).pop()??`document.pdf`,mimeType:`application/pdf`},n):(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border border-border bg-background/50 px-2 py-1 text-xs text-text-secondary`,children:[(0,Z.jsx)(C,{className:`size-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate max-w-40`,children:e.split(`/`).pop()})]},n))}),r&&(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap break-words`,children:r})]})})}function jt({src:e,alt:t}){let[n,r]=(0,A.useState)(null),[i,o]=(0,A.useState)(!1);return(0,A.useEffect)(()=>{let t,n=a();return fetch(e,{headers:n?{Authorization:`Bearer ${n}`}:{}}).then(e=>{if(!e.ok)throw Error(`Failed to load`);return e.blob()}).then(e=>{let n=URL.createObjectURL(e);t=n,r(n)}).catch(()=>o(!0)),()=>{t&&URL.revokeObjectURL(t)}},[e]),i?(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border border-border bg-background/50 px-2 py-1 text-xs text-text-secondary`,children:[(0,Z.jsx)(E,{className:`size-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate max-w-40`,children:t})]}):n?(0,Z.jsx)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,className:`block`,children:(0,Z.jsx)(`img`,{src:n,alt:t,className:`rounded-md max-h-48 max-w-full object-contain border border-border`})}):(0,Z.jsx)(`div`,{className:`rounded-md bg-surface border border-border h-24 w-32 animate-pulse`})}function Mt({src:e,filename:t,mimeType:n}){let[r,i]=(0,A.useState)(!1);return(0,Z.jsxs)(`button`,{type:`button`,onClick:(0,A.useCallback)(async()=>{i(!0);try{let t=a(),r=await fetch(e,{headers:t?{Authorization:`Bearer ${t}`}:{}});if(!r.ok)throw Error(`Failed to load`);let i=await r.blob(),o=URL.createObjectURL(new Blob([i],{type:n}));window.open(o,`_blank`),setTimeout(()=>URL.revokeObjectURL(o),6e4)}catch{window.open(e,`_blank`)}finally{i(!1)}},[e,n]),disabled:r,className:`flex items-center gap-1.5 rounded-md border border-border bg-background/50 px-2 py-1 text-xs text-text-secondary hover:bg-surface hover:text-text-primary transition-colors cursor-pointer disabled:opacity-50`,children:[(0,Z.jsx)(C,{className:`size-3.5 shrink-0 text-red-400`}),(0,Z.jsx)(`span`,{className:`truncate max-w-40`,children:t}),r&&(0,Z.jsx)(`span`,{className:`animate-spin text-[10px]`,children:`...`})]})}function Nt({events:e,isStreaming:t}){let n=[],r=``;for(let t=0;t<e.length;t++){let i=e[t];i.type===`text`?r+=i.content:i.type===`tool_use`?(r&&=(n.push({kind:`text`,content:r}),``),n.push({kind:`tool`,tool:i})):i.type===`tool_result`||(r&&=(n.push({kind:`text`,content:r}),``),n.push({kind:`tool`,tool:i}))}r&&n.push({kind:`text`,content:r});let i=e.filter(e=>e.type===`tool_result`);for(let e of i){let t=e.toolUseId;if(t){let r=n.find(e=>e.kind===`tool`&&e.tool.type===`tool_use`&&e.tool.toolUseId===t);if(r){r.result=e;continue}}let r=n.find(e=>e.kind===`tool`&&!e.result);r&&(r.result=e)}for(let e=0;e<n.length;e++){let r=n[e];r.kind===`tool`&&!r.result&&(r.completed=e<n.length-1||!t)}return(0,Z.jsx)(Z.Fragment,{children:n.map((e,r)=>{if(e.kind===`text`){let i=t&&r===n.length-1;return(0,Z.jsx)(`div`,{className:`text-sm text-text-primary`,children:(0,Z.jsx)(Pt,{content:e.content,animate:i})},`text-${r}`)}return(0,Z.jsx)(Rt,{tool:e.tool,result:e.result,completed:e.completed},`tool-${r}`)})})}function Pt({content:e,animate:t}){let[n,r]=(0,A.useState)(e),i=(0,A.useRef)(0),a=(0,A.useRef)(0);return(0,A.useEffect)(()=>{if(!t){r(e),i.current=e.length;return}let n=i.current;if(e.length<=n){r(e);return}let o=n,s=e.length,c=Math.max(3,Math.ceil((s-o)/30)),l=()=>{o=Math.min(o+c,s),r(e.slice(0,o)),o<s?a.current=requestAnimationFrame(l):i.current=s};return a.current=requestAnimationFrame(l),()=>cancelAnimationFrame(a.current)},[e,t]),(0,A.useEffect)(()=>{t||(r(e),i.current=e.length)},[t,e]),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Lt,{content:n}),t&&(0,Z.jsx)(Ft,{})]})}function Ft(){return(0,Z.jsx)(`span`,{className:`inline-block w-[2px] h-[1em] bg-accent ml-0.5 align-text-bottom animate-blink`})}function It({lastMessage:e}){if(!e||e.role!==`assistant`)return(0,Z.jsx)(`div`,{className:`flex items-center gap-2 text-text-subtle text-sm`,children:(0,Z.jsx)(`span`,{className:`animate-pulse`,children:`Thinking...`})});let t=e.events;if(t&&t.length>0){let e=t[t.length-1];if(e?.type===`tool_use`||e?.type===`tool_result`)return(0,Z.jsx)(`div`,{className:`flex items-center gap-2 text-text-subtle text-sm`,children:(0,Z.jsx)(`span`,{className:`animate-pulse`,children:`Thinking...`})})}return null}X.setOptions({gfm:!0,breaks:!0});function Lt({content:e}){return(0,Z.jsx)(`div`,{className:`markdown-content prose-sm`,dangerouslySetInnerHTML:{__html:(0,A.useMemo)(()=>{try{return X.parse(e)}catch{return e}},[e])}})}function Rt({tool:e,result:t,completed:n}){let[r,i]=(0,A.useState)(!1);if(e.type===`error`)return(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 rounded bg-red-500/10 border border-red-500/20 px-2 py-1.5 text-xs text-red-400`,children:[(0,Z.jsx)(p,{className:`size-3`}),(0,Z.jsx)(`span`,{children:e.message})]});let a=e.type===`approval_request`,o=e.type===`tool_use`?e.tool:a?e.tool??`Tool`:`Tool`,s=e.type===`tool_use`?e.input:a?e.input??{}:{},c=t?.type===`tool_result`,l=c&&!!t.isError,u=o===`AskUserQuestion`&&!!s?.answers;return(0,Z.jsxs)(`div`,{className:`rounded border border-border bg-background text-xs`,children:[(0,Z.jsxs)(`button`,{onClick:()=>i(!r),className:`flex items-center gap-2 px-2 py-1.5 w-full text-left hover:bg-surface transition-colors min-w-0`,children:[r?(0,Z.jsx)(x,{className:`size-3 shrink-0`}):(0,Z.jsx)(f,{className:`size-3 shrink-0`}),l?(0,Z.jsx)(ee,{className:`size-3 text-red-400 shrink-0`}):c||u||n?(0,Z.jsx)(S,{className:`size-3 text-green-400 shrink-0`}):(0,Z.jsx)(k,{className:`size-3 text-yellow-400 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate text-text-primary`,children:(0,Z.jsx)(zt,{name:o,input:s})})]}),r&&(0,Z.jsxs)(`div`,{className:`px-2 pb-2 space-y-1.5`,children:[(e.type===`tool_use`||a)&&(0,Z.jsx)(Bt,{name:o,input:s}),c&&(0,Z.jsx)(`pre`,{className:`overflow-x-auto text-text-subtle font-mono max-h-40 border-t border-border pt-1.5 whitespace-pre-wrap break-all`,children:t.output})]})]})}function zt({name:e,input:t}){let n=e=>String(e??``);switch(e){case`Read`:case`Write`:case`Edit`:return(0,Z.jsxs)(Z.Fragment,{children:[e,` `,(0,Z.jsx)(`span`,{className:`text-text-subtle`,children:Vt(n(t.file_path))})]});case`Bash`:return(0,Z.jsxs)(Z.Fragment,{children:[e,` `,(0,Z.jsx)(`span`,{className:`font-mono text-text-subtle`,children:Q(n(t.command),60)})]});case`Glob`:return(0,Z.jsxs)(Z.Fragment,{children:[e,` `,(0,Z.jsx)(`span`,{className:`font-mono text-text-subtle`,children:n(t.pattern)})]});case`Grep`:return(0,Z.jsxs)(Z.Fragment,{children:[e,` `,(0,Z.jsx)(`span`,{className:`font-mono text-text-subtle`,children:Q(n(t.pattern),40)})]});case`WebSearch`:return(0,Z.jsxs)(Z.Fragment,{children:[e,` `,(0,Z.jsx)(`span`,{className:`text-text-subtle`,children:Q(n(t.query),50)})]});case`WebFetch`:return(0,Z.jsxs)(Z.Fragment,{children:[e,` `,(0,Z.jsx)(`span`,{className:`text-text-subtle`,children:Q(n(t.url),50)})]});case`AskUserQuestion`:{let n=t.questions??[],r=!!t.answers;return(0,Z.jsxs)(Z.Fragment,{children:[e,` `,(0,Z.jsxs)(`span`,{className:`text-text-subtle`,children:[n.length,` question`,n.length===1?``:`s`,r?` ✓`:``]})]})}default:return(0,Z.jsx)(Z.Fragment,{children:e})}}function Bt({name:e,input:t}){let n=e=>String(e??``);switch(e){case`Bash`:return(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[!!t.description&&(0,Z.jsx)(`p`,{className:`text-text-subtle italic`,children:n(t.description)}),(0,Z.jsx)(`pre`,{className:`font-mono text-text-secondary overflow-x-auto whitespace-pre-wrap break-all`,children:n(t.command)})]});case`Read`:case`Write`:case`Edit`:return(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`font-mono text-text-secondary break-all`,children:n(t.file_path)}),e===`Edit`&&!!t.old_string&&(0,Z.jsx)(`div`,{className:`border-l-2 border-red-400/40 pl-2`,children:(0,Z.jsx)(`pre`,{className:`font-mono text-red-400/70 overflow-x-auto whitespace-pre-wrap`,children:Q(n(t.old_string),200)})}),e===`Edit`&&!!t.new_string&&(0,Z.jsx)(`div`,{className:`border-l-2 border-green-400/40 pl-2`,children:(0,Z.jsx)(`pre`,{className:`font-mono text-green-400/70 overflow-x-auto whitespace-pre-wrap`,children:Q(n(t.new_string),200)})}),e===`Write`&&!!t.content&&(0,Z.jsx)(`pre`,{className:`font-mono text-text-subtle overflow-x-auto max-h-32 whitespace-pre-wrap`,children:Q(n(t.content),300)})]});case`Glob`:return(0,Z.jsxs)(`p`,{className:`font-mono text-text-secondary`,children:[n(t.pattern),t.path?` in ${n(t.path)}`:``]});case`Grep`:return(0,Z.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Z.jsxs)(`p`,{className:`font-mono text-text-secondary`,children:[`/`,n(t.pattern),`/`]}),!!t.path&&(0,Z.jsxs)(`p`,{className:`text-text-subtle`,children:[`in `,n(t.path)]})]});case`AskUserQuestion`:{let e=t.questions??[],n=t.answers??{};return(0,Z.jsx)(`div`,{className:`space-y-2`,children:e.map((e,t)=>(0,Z.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Z.jsxs)(`p`,{className:`text-text-primary font-medium`,children:[e.header?`${e.header}: `:``,e.question]}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.options.map((t,r)=>(0,Z.jsx)(`span`,{className:`inline-block rounded px-1.5 py-0.5 text-xs border ${(n[e.question]??``).split(`, `).includes(t.label)?`border-accent bg-accent/20 text-text-primary`:`border-border text-text-subtle`}`,children:t.label},r))}),n[e.question]&&(0,Z.jsxs)(`p`,{className:`text-accent text-xs`,children:[`Answer: `,n[e.question]]})]},t))})}default:return(0,Z.jsx)(`pre`,{className:`overflow-x-auto text-text-secondary font-mono whitespace-pre-wrap break-all`,children:JSON.stringify(t,null,2)})}}function Vt(e){return e?e.split(`/`).pop()??e:``}function Q(e,t=50){return e?e.length>t?e.slice(0,t)+`…`:e:``}function Ht({approval:e,onRespond:t}){return(0,Z.jsxs)(`div`,{className:`rounded-lg border-2 border-yellow-500/40 bg-yellow-500/10 p-3 space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-yellow-400 text-sm font-medium`,children:[(0,Z.jsx)(re,{className:`size-4`}),(0,Z.jsx)(`span`,{children:`Tool Approval Required`})]}),(0,Z.jsx)(`div`,{className:`text-xs text-text-primary`,children:(0,Z.jsx)(`span`,{className:`font-medium`,children:e.tool})}),(0,Z.jsx)(`pre`,{className:`text-xs font-mono text-text-secondary overflow-x-auto bg-background rounded p-2 border border-border`,children:JSON.stringify(e.input,null,2)}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(`button`,{onClick:()=>t(e.requestId,!0),className:`px-4 py-1.5 rounded bg-green-600 text-white text-xs font-medium hover:bg-green-500 transition-colors`,children:`Allow`}),(0,Z.jsx)(`button`,{onClick:()=>t(e.requestId,!1),className:`px-4 py-1.5 rounded bg-red-600 text-white text-xs font-medium hover:bg-red-500 transition-colors`,children:`Deny`})]})]})}function Ut({approval:e,onRespond:t}){let n=e.input.questions??[],[r,i]=(0,A.useState)({}),[a,o]=(0,A.useState)({}),s=(e,t,n)=>{o(t=>({...t,[e]:!1})),i(r=>{if(!n)return{...r,[e]:t};let i=r[e]??``,a=i?i.split(`, `):[],o=a.indexOf(t);return o>=0?a.splice(o,1):a.push(t),{...r,[e]:a.join(`, `)}})},c=e=>{o(t=>({...t,[e]:!0})),i(t=>({...t,[e]:``}))},l=(e,t)=>{i(n=>({...n,[e]:t}))},u=n.every(e=>r[e.question]?.trim());return(0,Z.jsxs)(`div`,{className:`rounded-lg border-2 border-accent/40 bg-accent/5 p-3 space-y-3`,children:[n.map((e,t)=>(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(`p`,{className:`text-sm text-text-primary font-medium`,children:[e.header?`${e.header}: `:``,e.question]}),e.multiSelect&&(0,Z.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`Select multiple`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.options.map((t,n)=>(0,Z.jsxs)(`button`,{onClick:()=>s(e.question,t.label,e.multiSelect),className:`text-left rounded px-2.5 py-1.5 text-xs border transition-colors ${!a[e.question]&&(r[e.question]??``).split(`, `).includes(t.label)?`border-accent bg-accent/20 text-text-primary`:`border-border bg-background text-text-secondary hover:bg-surface-elevated`}`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:t.label}),t.description&&(0,Z.jsxs)(`span`,{className:`text-text-subtle ml-1.5`,children:[`— `,t.description]})]},n)),a[e.question]?(0,Z.jsx)(`input`,{type:`text`,autoFocus:!0,placeholder:`Type your answer...`,value:r[e.question]??``,onChange:t=>l(e.question,t.target.value),className:`rounded px-2.5 py-1.5 text-xs border border-accent bg-accent/10 text-text-primary outline-none placeholder:text-text-subtle`}):(0,Z.jsx)(`button`,{onClick:()=>c(e.question),className:`text-left rounded px-2.5 py-1.5 text-xs border border-dashed border-border text-text-subtle hover:bg-surface-elevated transition-colors`,children:`Other — type your own answer`})]})]},t)),(0,Z.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,Z.jsx)(`button`,{onClick:()=>t(e.requestId,!0,r),disabled:!u,className:`px-4 py-1.5 rounded bg-accent text-white text-xs font-medium hover:bg-accent/80 transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:`Submit`}),(0,Z.jsx)(`button`,{onClick:()=>t(e.requestId,!1),className:`px-4 py-1.5 rounded bg-surface-elevated text-text-secondary text-xs hover:bg-surface transition-colors`,children:`Skip`})]})]})}var Wt=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]),Gt=new Set([`application/pdf`]),Kt=[`text/`,`application/json`,`application/xml`,`application/javascript`,`application/typescript`,`application/x-yaml`,`application/toml`,`application/x-sh`],qt=new Set(`.ts,.tsx,.js,.jsx,.mjs,.cjs,.py,.rb,.go,.rs,.java,.kt,.swift,.c,.cpp,.h,.hpp,.cs,.json,.yaml,.yml,.toml,.xml,.md,.mdx,.txt,.csv,.tsv,.html,.css,.scss,.less,.sass,.sh,.bash,.zsh,.fish,.sql,.graphql,.gql,.env,.ini,.cfg,.conf,.dockerfile,.makefile,.vue,.svelte,.astro,.ipynb`.split(`,`));function Jt(e){return Wt.has(e.type)}function Yt(e){if(Wt.has(e.type)||Gt.has(e.type)||Kt.some(t=>e.type.startsWith(t)))return!0;let t=Xt(e.name);return!!(t&&qt.has(t))}function Xt(e){let t=e.lastIndexOf(`.`);return t===-1?``:e.slice(t).toLowerCase()}function Zt({attachments:e,onRemove:t}){return e.length===0?null:(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5 px-3 pt-2`,children:e.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border border-border bg-surface px-2 py-1 text-xs text-text-secondary max-w-48`,children:[e.previewUrl?(0,Z.jsx)(`img`,{src:e.previewUrl,alt:e.name,className:`size-5 rounded object-cover shrink-0`}):e.isImage?(0,Z.jsx)(E,{className:`size-3.5 shrink-0 text-text-subtle`}):(0,Z.jsx)(C,{className:`size-3.5 shrink-0 text-text-subtle`}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.name}),e.status===`uploading`?(0,Z.jsx)(i,{className:`size-3 shrink-0 animate-spin text-text-subtle`}):e.status===`error`?(0,Z.jsx)(`span`,{className:`text-red-500 shrink-0`,title:`Upload failed`,children:`!`}):null,(0,Z.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),className:`shrink-0 rounded-sm p-0.5 hover:bg-border/50 transition-colors`,"aria-label":`Remove ${e.name}`,children:(0,Z.jsx)(u,{className:`size-3`})})]},e.id))})}function Qt(e){let t=[];function n(e){for(let r of e)t.push(r),r.children&&n(r.children)}return n(e),t}function $t({items:e,filter:t,onSelect:n,onClose:r,visible:i}){let[a,o]=(0,A.useState)(0),s=(0,A.useRef)(null),c=(()=>{if(!t)return e.slice(0,50);let n=t.toLowerCase();return e.filter(e=>e.path.toLowerCase().includes(n)||e.name.toLowerCase().includes(n)).slice(0,50)})();(0,A.useEffect)(()=>{o(0)},[t]),(0,A.useEffect)(()=>{let e=s.current;e&&e.children[a]?.scrollIntoView({block:`nearest`})},[a]);let l=(0,A.useCallback)(e=>{if(!i||c.length===0)return!1;switch(e.key){case`ArrowUp`:return e.preventDefault(),o(e=>e>0?e-1:c.length-1),!0;case`ArrowDown`:return e.preventDefault(),o(e=>e<c.length-1?e+1:0),!0;case`Enter`:case`Tab`:return e.preventDefault(),c[a]&&n(c[a]),!0;case`Escape`:return e.preventDefault(),r(),!0}return!1},[i,c,a,n,r]);return(0,A.useEffect)(()=>{if(!i)return;let e=e=>{l(e)};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[i,l]),!i||c.length===0?null:(0,Z.jsx)(`div`,{className:`max-h-52 overflow-y-auto border-b border-border bg-surface`,children:(0,Z.jsx)(`div`,{ref:s,className:`py-1`,children:c.map((e,t)=>(0,Z.jsxs)(`button`,{className:`flex items-center gap-2 w-full px-3 py-1.5 text-left transition-colors ${t===a?`bg-primary/10 text-primary`:`hover:bg-surface-hover text-text-primary`}`,onMouseEnter:()=>o(t),onClick:()=>n(e),children:[(0,Z.jsx)(`span`,{className:`shrink-0`,children:e.type===`directory`?(0,Z.jsx)(h,{className:`size-4 text-amber-500`}):(0,Z.jsx)(b,{className:`size-4 text-blue-400`})}),(0,Z.jsx)(`span`,{className:`text-sm truncate`,children:e.path})]},e.path))})})}function en({onSend:e,isStreaming:t,onCancel:n,disabled:r,projectName:i,onSlashStateChange:c,onSlashItemsLoaded:l,slashSelected:u,onFileStateChange:f,onFileItemsLoaded:p,fileSelected:m,externalFiles:h}){let[g,_]=(0,A.useState)(``),[v,y]=(0,A.useState)([]),b=(0,A.useRef)(null),x=(0,A.useRef)(null),S=(0,A.useRef)([]),C=(0,A.useRef)([]);(0,A.useEffect)(()=>{if(!i){S.current=[],l?.([]);return}s.get(`${o(i)}/chat/slash-items`).then(e=>{S.current=e,l?.(e)}).catch(()=>{S.current=[],l?.([])})},[i]),(0,A.useEffect)(()=>{if(!i){C.current=[],p?.([]);return}s.get(`${o(i)}/files/tree?depth=5`).then(e=>{let t=Qt(e);C.current=t,p?.(t)}).catch(()=>{C.current=[],p?.([])})},[i]),(0,A.useEffect)(()=>{if(!u)return;let e=`/${u.name} `;_(e),c?.(!1,``),f?.(!1,``);let t=b.current;t&&(t.focus(),setTimeout(()=>{t.selectionStart=t.selectionEnd=e.length},0))},[u]),(0,A.useEffect)(()=>{if(!m)return;let e=b.current;if(!e)return;let t=e.selectionStart,n=g.slice(0,t),r=g.slice(t),i=n.match(/@(\S*)$/);if(i){let t=n.length-i[0].length;_(n.slice(0,t)+`@${m.path} `+r);let a=t+m.path.length+2;setTimeout(()=>{e.selectionStart=e.selectionEnd=a,e.focus()},0)}else{let t=g+`@${m.path} `;_(t),setTimeout(()=>{e.selectionStart=e.selectionEnd=t.length,e.focus()},0)}f?.(!1,``)},[m]),(0,A.useEffect)(()=>{!h||h.length===0||T(h)},[h]);let w=(0,A.useCallback)(async e=>{if(!i)return null;try{let t=new FormData;t.append(`files`,e);let n={},r=a();r&&(n.Authorization=`Bearer ${r}`);let s=await(await fetch(`${o(i)}/chat/upload`,{method:`POST`,headers:n,body:t})).json();return s.ok&&Array.isArray(s.data)&&s.data.length>0?s.data[0].path:null}catch{return null}},[i]),T=(0,A.useCallback)(e=>{for(let t of e){if(!Yt(t)){_(e=>e+(e.length>0&&!e.endsWith(` `)?` `:``)+t.name);continue}let e=d(),n=Jt(t),r=n?URL.createObjectURL(t):void 0,i={id:e,name:t.name,file:t,isImage:n,previewUrl:r,status:`uploading`};y(e=>[...e,i]),w(t).then(t=>{y(n=>n.map(n=>n.id===e?{...n,serverPath:t??void 0,status:t?`ready`:`error`}:n))})}b.current?.focus()},[w]),ee=(0,A.useCallback)(e=>{y(t=>{let n=t.find(t=>t.id===e);return n?.previewUrl&&URL.revokeObjectURL(n.previewUrl),t.filter(t=>t.id!==e)})},[]),E=(0,A.useCallback)(()=>{let t=g.trim(),n=v.filter(e=>e.status===`ready`);if(!(!t&&n.length===0)&&!r){c?.(!1,``),f?.(!1,``),e(t,n),_(``);for(let e of v)e.previewUrl&&URL.revokeObjectURL(e.previewUrl);y([]),b.current&&(b.current.style.height=`auto`)}},[g,v,r,e,c,f]),re=(0,A.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),E())},[E]),D=(0,A.useCallback)((e,t)=>{let n=e.match(/^\/(\S*)$/);if(n&&S.current.length>0){c?.(!0,n[1]??``),f?.(!1,``);return}let r=e.slice(0,t).match(/@(\S*)$/);if(r&&C.current.length>0){f?.(!0,r[1]??``),c?.(!1,``);return}c?.(!1,``),f?.(!1,``)},[c,f]),ie=(0,A.useCallback)(e=>{_(e),setTimeout(()=>{D(e,b.current?.selectionStart??e.length)},0)},[D]),k=(0,A.useCallback)(()=>{let e=b.current;e&&(e.style.height=`auto`,e.style.height=Math.min(e.scrollHeight,160)+`px`)},[]),ae=(0,A.useCallback)(e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t)if(e.kind===`file`){let t=e.getAsFile();t&&n.push(t)}n.length>0&&(e.preventDefault(),T(n))},[T]),oe=(0,A.useCallback)(e=>{e.preventDefault();let t=Array.from(e.dataTransfer.files);t.length>0&&T(t)},[T]),se=(0,A.useCallback)(e=>{e.preventDefault()},[]),ce=(0,A.useCallback)(()=>{x.current?.click()},[]),le=(0,A.useCallback)(e=>{let t=Array.from(e.target.files??[]);t.length>0&&T(t),e.target.value=``},[T]),j=g.trim().length>0||v.some(e=>e.status===`ready`),M=t&&!j;return(0,Z.jsxs)(`div`,{className:`border-t border-border bg-background`,children:[(0,Z.jsx)(Zt,{attachments:v,onRemove:ee}),(0,Z.jsxs)(`div`,{className:`flex items-end gap-2 p-3`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:ce,disabled:r,className:`flex items-center justify-center rounded-lg p-2 text-text-subtle hover:text-text-primary hover:bg-surface transition-colors shrink-0 disabled:opacity-50`,"aria-label":`Attach file`,children:(0,Z.jsx)(te,{className:`size-4`})}),(0,Z.jsx)(`input`,{ref:x,type:`file`,multiple:!0,className:`hidden`,onChange:le}),(0,Z.jsx)(`textarea`,{ref:b,value:g,onChange:e=>{ie(e.target.value),k()},onKeyDown:re,onPaste:ae,onDrop:oe,onDragOver:se,placeholder:t?`Send follow-up or press Stop...`:`Type / for commands, @ for files, or drop files...`,disabled:r,rows:1,className:`flex-1 resize-none rounded-lg border border-border bg-surface px-3 py-2 text-base md:text-sm text-text-primary placeholder:text-text-subtle focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-50 max-h-40`}),M?(0,Z.jsx)(`button`,{onClick:n,className:`flex items-center justify-center rounded-lg bg-red-600 p-2 text-white hover:bg-red-500 transition-colors shrink-0`,"aria-label":`Stop response`,children:(0,Z.jsx)(O,{className:`size-4`})}):(0,Z.jsx)(`button`,{onClick:E,disabled:r||!j,className:`flex items-center justify-center rounded-lg bg-primary p-2 text-white hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors shrink-0`,"aria-label":`Send message`,children:(0,Z.jsx)(ne,{className:`size-4`})})]})]})}function tn({currentSessionId:e,onSelectSession:t,onNewSession:n,projectName:r}){let[i,a]=(0,A.useState)([]),[c,u]=(0,A.useState)(!1),[d,f]=(0,A.useState)(!1),p=(0,A.useCallback)(async()=>{if(r){f(!0);try{a(await s.get(`${o(r)}/chat/sessions`))}catch{}finally{f(!1)}}},[r]);(0,A.useEffect)(()=>{p()},[p]),(0,A.useEffect)(()=>{c&&p()},[c,p]);let m=i.find(t=>t.id===e),h=async(e,t)=>{e.stopPropagation();try{if(!r)return;await s.del(`${o(r)}/chat/sessions/${t.id}?providerId=${t.providerId}`),a(e=>e.filter(e=>e.id!==t.id))}catch{}};return(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsxs)(`button`,{onClick:()=>u(!c),className:`flex items-center gap-1.5 text-sm text-text-secondary hover:text-text-primary transition-colors px-2 py-1 rounded hover:bg-surface-elevated`,children:[(0,Z.jsx)(_,{className:`size-3.5`}),(0,Z.jsx)(`span`,{className:`truncate max-w-[150px]`,children:m?.title??`Select chat`}),(0,Z.jsx)(x,{className:`size-3`})]}),c&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>u(!1)}),(0,Z.jsxs)(`div`,{className:`absolute bottom-full left-0 mb-1 z-50 w-64 rounded-lg border border-border bg-surface shadow-lg overflow-hidden`,children:[(0,Z.jsxs)(`button`,{onClick:()=>{n(),u(!1)},className:`flex items-center gap-2 w-full px-3 py-2 text-sm text-primary hover:bg-surface-elevated transition-colors border-b border-border`,children:[(0,Z.jsx)(v,{className:`size-4`}),(0,Z.jsx)(`span`,{children:`New Chat`})]}),(0,Z.jsxs)(`div`,{className:`max-h-60 overflow-y-auto`,children:[d&&(0,Z.jsx)(`p`,{className:`px-3 py-2 text-xs text-text-subtle animate-pulse`,children:`Loading sessions...`}),!d&&i.length===0&&(0,Z.jsx)(`p`,{className:`px-3 py-2 text-xs text-text-subtle`,children:`No sessions yet`}),i.map(n=>(0,Z.jsxs)(`div`,{onClick:()=>{t(n),u(!1)},className:`flex items-center justify-between px-3 py-2 text-sm cursor-pointer hover:bg-surface-elevated transition-colors ${n.id===e?`bg-surface-elevated text-text-primary`:`text-text-secondary`}`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`truncate text-xs font-medium`,children:n.title}),(0,Z.jsx)(`span`,{className:`text-xs text-text-subtle`,children:new Date(n.createdAt).toLocaleDateString()})]}),(0,Z.jsx)(`button`,{onClick:e=>h(e,n),className:`p-1 rounded hover:bg-red-500/20 text-text-subtle hover:text-red-400 transition-colors shrink-0`,"aria-label":`Delete session`,children:(0,Z.jsx)(l,{className:`size-3`})})]},n.id))]})]})]})]})}function nn({items:e,filter:t,onSelect:n,onClose:r,visible:i}){let[a,o]=(0,A.useState)(0),s=(0,A.useRef)(null),c=e.filter(e=>{let n=t.toLowerCase();return e.name.toLowerCase().includes(n)||e.description.toLowerCase().includes(n)});(0,A.useEffect)(()=>{o(0)},[t]),(0,A.useEffect)(()=>{let e=s.current;e&&e.children[a]?.scrollIntoView({block:`nearest`})},[a]);let l=(0,A.useCallback)(e=>{if(!i||c.length===0)return!1;switch(e.key){case`ArrowUp`:return e.preventDefault(),o(e=>e>0?e-1:c.length-1),!0;case`ArrowDown`:return e.preventDefault(),o(e=>e<c.length-1?e+1:0),!0;case`Enter`:case`Tab`:return e.preventDefault(),c[a]&&n(c[a]),!0;case`Escape`:return e.preventDefault(),r(),!0}return!1},[i,c,a,n,r]);return(0,A.useEffect)(()=>{if(!i)return;let e=e=>{l(e)};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[i,l]),!i||c.length===0?null:(0,Z.jsx)(`div`,{className:`max-h-52 overflow-y-auto border-b border-border bg-surface`,children:(0,Z.jsx)(`div`,{ref:s,className:`py-1`,children:c.map((e,t)=>(0,Z.jsxs)(`button`,{className:`flex items-start gap-3 w-full px-3 py-2 text-left transition-colors ${t===a?`bg-primary/10 text-primary`:`hover:bg-surface-hover text-text-primary`}`,onMouseEnter:()=>o(t),onClick:()=>n(e),children:[(0,Z.jsx)(`span`,{className:`shrink-0 mt-0.5`,children:e.type===`skill`?(0,Z.jsx)(D,{className:`size-4 text-amber-500`}):(0,Z.jsx)(m,{className:`size-4 text-blue-500`})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,Z.jsxs)(`span`,{className:`font-medium text-sm`,children:[`/`,e.name]}),e.argumentHint&&(0,Z.jsx)(`span`,{className:`text-xs text-text-subtle`,children:e.argumentHint}),(0,Z.jsx)(`span`,{className:`text-xs text-text-subtle capitalize ml-auto`,children:e.scope===`user`?`global`:e.type})]}),e.description&&(0,Z.jsx)(`p`,{className:`text-xs text-text-subtle mt-0.5 line-clamp-2`,children:e.description})]})]},`${e.type}-${e.name}`))})})}function rn(e){return e>=90?`text-red-500`:e>=70?`text-amber-500`:`text-green-500`}function an(e){return e>=90?`bg-red-500`:e>=70?`bg-amber-500`:`bg-green-500`}function on({usage:e,onClick:t}){let n=e.fiveHour==null?null:Math.round(e.fiveHour*100),r=e.sevenDay==null?null:Math.round(e.sevenDay*100),i=n==null?`--%`:`${n}%`,a=r==null?`--%`:`${r}%`;return(0,Z.jsxs)(`button`,{onClick:t,className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] font-medium tabular-nums transition-colors hover:bg-surface-hover ${n!=null||r!=null?rn(Math.max(n??0,r??0)):`text-text-subtle`}`,title:`Click for usage details`,children:[(0,Z.jsx)(w,{className:`size-3`}),(0,Z.jsxs)(`span`,{children:[`5h:`,i]}),(0,Z.jsx)(`span`,{className:`text-text-subtle`,children:`·`}),(0,Z.jsxs)(`span`,{children:[`Wk:`,a]})]})}function sn(e){if(!e)return null;let t=null;if(e.resetsInMinutes!=null)t=e.resetsInMinutes;else if(e.resetsInHours!=null)t=Math.round(e.resetsInHours*60);else if(e.resetsAt){let n=new Date(e.resetsAt).getTime()-Date.now();t=n>0?Math.ceil(n/6e4):0}if(t==null)return null;if(t<=0)return`now`;let n=Math.floor(t/1440),r=Math.floor(t%1440/60),i=t%60;return n>0?i>0?`${n}d ${r}h ${i}m`:r>0?`${n}d ${r}h`:`${n}d`:r>0?i>0?`${r}h ${i}m`:`${r}h`:`${i}m`}function cn(e){if(!e)return null;switch(e){case`ahead_of_pace`:return{text:`Ahead of pace`,color:`text-green-500`};case`behind_pace`:return{text:`Behind pace`,color:`text-amber-500`};case`on_pace`:return{text:`On pace`,color:`text-text-subtle`};default:return{text:e.replace(/_/g,` `),color:`text-text-subtle`}}}function $({label:e,bucket:t}){if(!t)return null;let n=Math.round(t.utilization*100),r=sn(t),i=cn(t.status);return(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-text-primary`,children:e}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i&&(0,Z.jsx)(`span`,{className:`text-[10px] ${i.color}`,children:i.text}),r&&(0,Z.jsxs)(`span`,{className:`text-[10px] text-text-subtle`,children:[`↻ `,r]})]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`flex-1 h-2 rounded-full bg-border overflow-hidden`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full transition-all ${an(n)}`,style:{width:`${Math.min(n,100)}%`}})}),(0,Z.jsxs)(`span`,{className:`text-xs font-medium tabular-nums w-10 text-right ${rn(n)}`,children:[n,`%`]})]})]})}function ln({usage:e,visible:t,onClose:n,onReload:r,loading:i}){if(!t)return null;let a=e.queryCostUsd!=null||e.totalCostUsd!=null,o=e.session||e.weekly||e.weeklyOpus||e.weeklySonnet;return(0,Z.jsxs)(`div`,{className:`border-b border-border bg-surface px-3 py-2.5 space-y-2.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-semibold text-text-primary`,children:`Usage Limits`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[r&&(0,Z.jsx)(`button`,{onClick:r,disabled:i,className:`text-xs text-text-subtle hover:text-text-primary px-1 disabled:opacity-50`,title:`Refresh usage data`,children:(0,Z.jsx)(c,{className:`size-3 ${i?`animate-spin`:``}`})}),(0,Z.jsx)(`button`,{onClick:n,className:`text-xs text-text-subtle hover:text-text-primary px-1`,children:`✕`})]})]}),o?(0,Z.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,Z.jsx)($,{label:`5-Hour Session`,bucket:e.session}),(0,Z.jsx)($,{label:`Weekly`,bucket:e.weekly}),(0,Z.jsx)($,{label:`Weekly (Opus)`,bucket:e.weeklyOpus}),(0,Z.jsx)($,{label:`Weekly (Sonnet)`,bucket:e.weeklySonnet})]}):(0,Z.jsxs)(`p`,{className:`text-xs text-text-subtle`,children:[`No data — run `,(0,Z.jsx)(`code`,{className:`bg-surface-elevated px-1 rounded`,children:`bun install`})]}),a&&(0,Z.jsxs)(`div`,{className:`border-t border-border pt-2 space-y-1`,children:[e.queryCostUsd!=null&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,Z.jsx)(`span`,{className:`text-text-subtle`,children:`Last query`}),(0,Z.jsxs)(`span`,{className:`text-text-primary font-medium tabular-nums`,children:[`$`,e.queryCostUsd.toFixed(4)]})]}),e.totalCostUsd!=null&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,Z.jsx)(`span`,{className:`text-text-subtle`,children:`Session total`}),(0,Z.jsxs)(`span`,{className:`text-text-primary font-medium tabular-nums`,children:[`$`,e.totalCostUsd.toFixed(4)]})]})]})]})}function un({metadata:e,tabId:t}){let[n,r]=(0,A.useState)(e?.sessionId??null),[i,a]=(0,A.useState)(e?.providerId??`claude-sdk`),[c,l]=(0,A.useState)([]),[u,d]=(0,A.useState)(!1),[f,p]=(0,A.useState)(``),[m,h]=(0,A.useState)(null),[_,v]=(0,A.useState)([]),[b,x]=(0,A.useState)(!1),[S,C]=(0,A.useState)(``),[w,T]=(0,A.useState)(null),[ee,E]=(0,A.useState)(!1),[te,ne]=(0,A.useState)(!1),[re,D]=(0,A.useState)(null),O=(0,A.useRef)(0),k=g(e=>e.activeProject),ae=y(e=>e.updateTab);(0,A.useEffect)(()=>{!t||!n||ae(t,{metadata:{...e,sessionId:n,providerId:i}})},[n,i]);let{messages:oe,messagesLoading:se,isStreaming:ce,pendingApproval:j,usageInfo:M,usageLoading:ue,sendMessage:N,respondToApproval:P,cancelStreaming:de,refreshUsage:F,isConnected:fe}=le(n,i,k?.name??``),pe=(0,A.useCallback)(()=>{let e=k?.name??null;y.getState().openTab({type:`chat`,title:`AI Chat`,metadata:{projectName:e},projectId:e,closable:!0})},[k?.name]),me=(0,A.useCallback)(e=>{r(e.id),a(e.providerId)},[]),I=(0,A.useCallback)((e,t)=>{if(t.length===0)return e;let n=t.filter(e=>e.serverPath).map(e=>e.serverPath).join(`
61
+ `);return n?(t.length===1?`[Attached file: ${n}]\n\n`:`[Attached files:\n${n}\n]\n\n`)+e:e},[]),he=(0,A.useCallback)(async(t,c=[])=>{let l=I(t,c);if(l.trim()){if(!n)try{let n=k?.name??e?.project??``,c=await s.post(`${o(n)}/chat/sessions`,{providerId:i,title:t.slice(0,50)});r(c.id),a(c.providerId),setTimeout(()=>{N(l)},500);return}catch(e){console.error(`Failed to create session:`,e);return}N(l)}},[n,i,e?.project,N,I,k?.name]),L=(0,A.useCallback)((e,t)=>{d(e),p(t)},[]),ge=(0,A.useCallback)(e=>{h(e),d(!1),p(``),setTimeout(()=>h(null),50)},[]),_e=(0,A.useCallback)(()=>{d(!1),p(``)},[]),ve=(0,A.useCallback)((e,t)=>{x(e),C(t)},[]),R=(0,A.useCallback)(e=>{T(e),x(!1),C(``),setTimeout(()=>T(null),50)},[]),ye=(0,A.useCallback)(()=>{x(!1),C(``)},[]);return(0,Z.jsxs)(`div`,{className:`flex flex-col h-full relative`,onDragEnter:(0,A.useCallback)(e=>{e.preventDefault(),O.current++,e.dataTransfer.types.includes(`Files`)&&ne(!0)},[]),onDragLeave:(0,A.useCallback)(e=>{e.preventDefault(),O.current--,O.current===0&&ne(!1)},[]),onDragOver:(0,A.useCallback)(e=>{e.preventDefault()},[]),onDrop:(0,A.useCallback)(e=>{e.preventDefault(),O.current=0,ne(!1);let t=Array.from(e.dataTransfer.files);t.length>0&&(D(t),setTimeout(()=>D(null),100))},[]),children:[te&&(0,Z.jsx)(`div`,{className:`absolute inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm border-2 border-dashed border-primary rounded-lg pointer-events-none`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-primary`,children:[(0,Z.jsx)(ie,{className:`size-8`}),(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:`Drop files to attach`})]})}),(0,Z.jsx)(Ct,{messages:oe,messagesLoading:se,pendingApproval:j,onApprovalResponse:P,isStreaming:ce,projectName:k?.name}),(0,Z.jsxs)(`div`,{className:`border-t border-border bg-background shrink-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 border-b border-border/50`,children:[(0,Z.jsx)(tn,{currentSessionId:n,onSelectSession:me,onNewSession:pe,projectName:k?.name}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(on,{usage:M,onClick:()=>E(e=>!e)}),fe&&(0,Z.jsx)(`span`,{className:`size-2 rounded-full bg-green-500`,title:`Connected`})]})]}),(0,Z.jsx)(ln,{usage:M,visible:ee,onClose:()=>E(!1),onReload:F,loading:ue}),(0,Z.jsx)(nn,{items:c,filter:f,onSelect:ge,onClose:_e,visible:u}),(0,Z.jsx)($t,{items:_,filter:S,onSelect:R,onClose:ye,visible:b}),(0,Z.jsx)(en,{onSend:he,isStreaming:ce,onCancel:de,projectName:k?.name,onSlashStateChange:L,onSlashItemsLoaded:l,slashSelected:m,onFileStateChange:ve,onFileItemsLoaded:v,fileSelected:w,externalFiles:re})]})]})}export{un as ChatTab};
@@ -1,2 +1,2 @@
1
- import{i as e,n as t,t as n}from"./jsx-runtime-BnxRlLMJ.js";import{t as r}from"./createLucideIcon-Dy1wlrF7.js";import{t as i}from"./external-link-WSiY-639.js";import{a,n as o,r as s,t as c}from"./api-client-Bnf9LAt4.js";import{u as l}from"./index-DGSLw2GE.js";import{$ as u,A as d,B as f,C as p,D as m,E as h,F as g,G as _,H as v,J as y,K as ee,L as te,M as b,N as x,O as S,P as C,Q as w,R as T,S as E,T as D,U as O,V as k,W as ne,X as A,Z as re,_ as ie,a as ae,b as oe,c as se,ct as ce,d as le,dt as ue,f as de,ft as fe,g as pe,gt as me,h as he,ht as j,i as ge,it as _e,j as ve,l as ye,lt as be,m as xe,mt as Se,n as Ce,nt as M,o as we,ot as Te,p as Ee,pt as De,q as Oe,r as ke,rt as Ae,s as je,st as N,t as Me,tt as P,u as Ne,ut as Pe,v as Fe,w as Ie,x as Le,y as Re,z as ze}from"./dist-CSp7ir0r.js";var Be=r(`file-exclamation-point`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),F=e(t());function Ve(){return Ve=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ve.apply(null,arguments)}function He(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Ue=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=Je(e.state,n.from);return r.line?Ge(e):r.block?qe(e):!1};function We(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var Ge=We(Qe,0),Ke=We(Ze,0),qe=We((e,t)=>Ze(e,t,Xe(t)),0);function Je(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var I=50;function Ye(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-I,r),o=e.sliceDoc(i,i+I),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=2*I?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+I),d=e.sliceDoc(i-I,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:/\s/.test(u.charAt(f+t.length))?1:0},close:{pos:i-p-n.length,margin:/\s/.test(d.charAt(m-1))?1:0}}:null}function Xe(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function Ze(e,t,n=t.selection.ranges){let r=n.map(e=>Je(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>Ye(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function Qe(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=Je(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}else if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var $e=A.define(),et=A.define(),tt=Ae.define(),nt=Ae.define({combine(e){return De(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),rt=ce.define({create(){return bt.empty},update(e,t){let n=t.state.facet(nt),r=t.annotation($e);if(r){let i=L.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?ut(o,o.length,n.minDepth,i):ht(o,t.startState.selection),new bt(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(et);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(Pe.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=L.fromTransaction(t),o=t.annotation(Pe.time),s=t.annotation(Pe.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new bt(e.done.map(L.fromJSON),e.undone.map(L.fromJSON))}});function it(e={}){return[rt,nt.of(e),S.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?ot:e.inputType==`historyRedo`?st:null;return n?(e.preventDefault(),n(t)):!1}})]}function at(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(rt,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var ot=at(0,!1),st=at(1,!1),ct=at(0,!0),lt=at(1,!0),L=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&w.fromJSON(t.changes),[],t.mapped&&re.fromJSON(t.mapped),t.startSelection&&P.fromJSON(t.startSelection),t.selectionsAfter.map(P.fromJSON))}static fromTransaction(t,n){let r=R;for(let e of t.startState.facet(tt)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,R)}static selection(t){return new e(void 0,R,void 0,void 0,t)}};function ut(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function dt(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function ft(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function pt(e,t){return e.length?t.length?e.concat(t):e:t}var R=[],mt=200;function ht(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-mt));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),ut(e,e.length-1,1e9,n.setSelAfter(r)))}else return[L.selection([t])]}function gt(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function _t(e,t){if(!e.length)return e;let n=e.length,r=R;for(;n;){let i=vt(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[L.selection(r)]:R}function vt(e,t,n){let r=pt(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):R,n);if(!e.changes)return L.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new L(i,N.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var yt=/^(input\.type|delete)($|\.)/,bt=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||yt.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,dt(s.changes,t.changes))||r==`input.type.compose`)?ut(o,o.length-1,i.minDepth,new L(t.changes.compose(s.changes),pt(N.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,R)):ut(o,o.length,i.minDepth,t),new e(o,R,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:R;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&ft(a[a.length-1],t)?this:new e(ht(this.done,t),this.undone,n,r)}addMapping(t){return new e(_t(this.done,t),_t(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:$e.of({side:e,rest:gt(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?R:r.slice(0,r.length-1);return i.mapped&&(n=_t(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:$e.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};bt.empty=new bt(R,R);var xt=[{key:`Mod-z`,run:ot,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:st,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:st,preventDefault:!0},{key:`Mod-u`,run:ct,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:lt,preventDefault:!0}];function z(e,t){return P.create(e.ranges.map(t),e.mainIndex)}function B(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function V({state:e,dispatch:t},n){let r=z(e.selection,n);return r.eq(e.selection,!0)?!1:(t(B(e,r)),!0)}function St(e,t){return P.cursor(t?e.to:e.from)}function Ct(e,t){return V(e,n=>n.empty?e.moveByChar(n,t):St(n,t))}function H(e){return e.textDirectionAt(e.state.selection.main.head)==m.LTR}var wt=e=>Ct(e,!H(e)),Tt=e=>Ct(e,H(e));function Et(e,t){return V(e,n=>n.empty?e.moveByGroup(n,t):St(n,t))}var Dt=e=>Et(e,!H(e)),Ot=e=>Et(e,H(e));typeof Intl<`u`&&Intl.Segmenter&&new Intl.Segmenter(void 0,{granularity:`word`});function kt(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function At(e,t,n){let r=Ie(e).resolveInner(t.head),i=n?D.closedBy:D.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;kt(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?E(e,r.from,1):E(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,P.cursor(s,n?-1:1)}var jt=e=>V(e,t=>At(e.state,t,!H(e))),Mt=e=>V(e,t=>At(e.state,t,H(e)));function Nt(e,t){return V(e,n=>{if(!n.empty)return St(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var Pt=e=>Nt(e,!1),Ft=e=>Nt(e,!0);function It(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(S.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function Lt(e,t){let n=It(e),{state:r}=e,i=z(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):St(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=S.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(B(r,i),{effects:a}),!0}var Rt=e=>Lt(e,!1),zt=e=>Lt(e,!0);function U(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=P.cursor(r.from+n))}return i}var Bt=e=>V(e,t=>U(e,t,!0)),Vt=e=>V(e,t=>U(e,t,!1)),Ht=e=>V(e,t=>U(e,t,!H(e))),Ut=e=>V(e,t=>U(e,t,H(e))),Wt=e=>V(e,t=>P.cursor(e.lineBlockAt(t.head).from,1)),Gt=e=>V(e,t=>P.cursor(e.lineBlockAt(t.head).to,-1));function Kt(e,t,n){let r=!1,i=z(e.selection,t=>{let i=E(e,t.head,-1)||E(e,t.head,1)||t.head>0&&E(e,t.head-1,1)||t.head<e.doc.length&&E(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?P.range(t.anchor,a):P.cursor(a)});return r?(t(B(e,i)),!0):!1}var qt=({state:e,dispatch:t})=>Kt(e,t,!1);function W(e,t){let n=z(e.state.selection,e=>{let n=t(e);return P.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(B(e.state,n)),!0)}function Jt(e,t){return W(e,n=>e.moveByChar(n,t))}var Yt=e=>Jt(e,!H(e)),Xt=e=>Jt(e,H(e));function Zt(e,t){return W(e,n=>e.moveByGroup(n,t))}var Qt=e=>Zt(e,!H(e)),$t=e=>Zt(e,H(e)),en=e=>W(e,t=>At(e.state,t,!H(e))),tn=e=>W(e,t=>At(e.state,t,H(e)));function nn(e,t){return W(e,n=>e.moveVertically(n,t))}var rn=e=>nn(e,!1),an=e=>nn(e,!0);function on(e,t){return W(e,n=>e.moveVertically(n,t,It(e).height))}var sn=e=>on(e,!1),cn=e=>on(e,!0),ln=e=>W(e,t=>U(e,t,!0)),un=e=>W(e,t=>U(e,t,!1)),dn=e=>W(e,t=>U(e,t,!H(e))),fn=e=>W(e,t=>U(e,t,H(e))),pn=e=>W(e,t=>P.cursor(e.lineBlockAt(t.head).from)),mn=e=>W(e,t=>P.cursor(e.lineBlockAt(t.head).to)),hn=({state:e,dispatch:t})=>(t(B(e,{anchor:0})),!0),gn=({state:e,dispatch:t})=>(t(B(e,{anchor:e.doc.length})),!0),_n=({state:e,dispatch:t})=>(t(B(e,{anchor:e.selection.main.anchor,head:0})),!0),vn=({state:e,dispatch:t})=>(t(B(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),yn=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),bn=({state:e,dispatch:t})=>{let n=zn(e).map(({from:t,to:n})=>P.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:P.create(n),userEvent:`select`})),!0},xn=({state:e,dispatch:t})=>{let n=z(e.selection,t=>{let n=Ie(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return P.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(B(e,n)),!0)};function Sn(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(B(n,P.create(i,i.length-1))),!0)}var Cn=e=>Sn(e,!1),wn=e=>Sn(e,!0),Tn=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=P.create([n.main]):n.main.empty||(r=P.create([P.cursor(n.main.head)])),r?(t(B(e,r)),!0):!1};function En(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=Dn(e,o,!1)):o>i&&(n=`delete.forward`,o=Dn(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=Dn(e,i,!1),a=Dn(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:P.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?S.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function Dn(e,t,n){if(e instanceof S)for(let r of e.state.facet(S.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var On=(e,t,n)=>En(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=Se(s,a.tabSize)%ie(a)||ie(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=j(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=j(o.text,c-o.from,!1,!1)+o.from);return c}),kn=e=>On(e,!1,!0),An=e=>On(e,!0,!1),jn=(e,t)=>En(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=j(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),Mn=e=>jn(e,!1),Nn=e=>jn(e,!0),Pn=e=>En(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Fn=e=>En(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),In=e=>En(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Ln=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:be.of([``,``])},range:P.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},Rn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:j(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:j(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:P.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function zn(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function Bn(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of zn(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(P.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(P.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:P.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var Vn=({state:e,dispatch:t})=>Bn(e,t,!1),Hn=({state:e,dispatch:t})=>Bn(e,t,!0);function Un(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of zn(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var Wn=({state:e,dispatch:t})=>Un(e,t,!1),Gn=({state:e,dispatch:t})=>Un(e,t,!0),Kn=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(zn(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=z(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function qn(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=Ie(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(D.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var Jn=Xn(!1),Yn=Xn(!0);function Xn(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&qn(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new de(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=Fe(s,r);for(c??=Se(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,oe(t,c)];return o&&l.push(oe(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:be.of(l)},range:P.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function Zn(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:P.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var Qn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new de(e,{overrideIndentation:e=>n[e]??-1}),i=Zn(e,(t,i,a)=>{let o=Fe(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=oe(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},$n=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Zn(e,(t,n)=>{n.push({from:t.from,insert:e.facet(Le)})}),{userEvent:`input.indent`})),!0),er=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Zn(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=Se(r,e.tabSize),a=0,o=oe(e,Math.max(0,i-ie(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),tr=e=>(e.setTabFocusMode(),!0),nr=[{key:`Ctrl-b`,run:wt,shift:Yt,preventDefault:!0},{key:`Ctrl-f`,run:Tt,shift:Xt},{key:`Ctrl-p`,run:Pt,shift:rn},{key:`Ctrl-n`,run:Ft,shift:an},{key:`Ctrl-a`,run:Wt,shift:pn},{key:`Ctrl-e`,run:Gt,shift:mn},{key:`Ctrl-d`,run:An},{key:`Ctrl-h`,run:kn},{key:`Ctrl-k`,run:Pn},{key:`Ctrl-Alt-h`,run:Mn},{key:`Ctrl-o`,run:Ln},{key:`Ctrl-t`,run:Rn},{key:`Ctrl-v`,run:zt}],rr=[{key:`ArrowLeft`,run:wt,shift:Yt,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Dt,shift:Qt,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:Ht,shift:dn,preventDefault:!0},{key:`ArrowRight`,run:Tt,shift:Xt,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Ot,shift:$t,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:Ut,shift:fn,preventDefault:!0},{key:`ArrowUp`,run:Pt,shift:rn,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:hn,shift:_n},{mac:`Ctrl-ArrowUp`,run:Rt,shift:sn},{key:`ArrowDown`,run:Ft,shift:an,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:gn,shift:vn},{mac:`Ctrl-ArrowDown`,run:zt,shift:cn},{key:`PageUp`,run:Rt,shift:sn},{key:`PageDown`,run:zt,shift:cn},{key:`Home`,run:Vt,shift:un,preventDefault:!0},{key:`Mod-Home`,run:hn,shift:_n},{key:`End`,run:Bt,shift:ln,preventDefault:!0},{key:`Mod-End`,run:gn,shift:vn},{key:`Enter`,run:Jn,shift:Jn},{key:`Mod-a`,run:yn},{key:`Backspace`,run:kn,shift:kn,preventDefault:!0},{key:`Delete`,run:An,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:Mn,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:Nn,preventDefault:!0},{mac:`Mod-Backspace`,run:Fn,preventDefault:!0},{mac:`Mod-Delete`,run:In,preventDefault:!0}].concat(nr.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),ir=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:jt,shift:en},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:Mt,shift:tn},{key:`Alt-ArrowUp`,run:Vn},{key:`Shift-Alt-ArrowUp`,run:Wn},{key:`Alt-ArrowDown`,run:Hn},{key:`Shift-Alt-ArrowDown`,run:Gn},{key:`Mod-Alt-ArrowUp`,run:Cn},{key:`Mod-Alt-ArrowDown`,run:wn},{key:`Escape`,run:Tn},{key:`Mod-Enter`,run:Yn},{key:`Alt-l`,mac:`Ctrl-l`,run:bn},{key:`Mod-i`,run:xn,preventDefault:!0},{key:`Mod-[`,run:er},{key:`Mod-]`,run:$n},{key:`Mod-Alt-\\`,run:Qn},{key:`Shift-Mod-k`,run:Kn},{key:`Shift-Mod-\\`,run:qt},{key:`Mod-/`,run:Ue},{key:`Alt-A`,run:Ke},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:tr}].concat(rr),ar={key:`Tab`,run:$n,shift:er},or=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,G=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(or(e)):or,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return ue(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=me(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=fe(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let a=r.charCodeAt(e),o=this.match(a,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}i==n&&e<t.length&&t.charCodeAt(e)==a&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],a=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,a=!0)),a||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<`u`&&(G.prototype[Symbol.iterator]=function(){return this});var sr={from:-1,to:-1,match:/.*/.exec(``)},cr=`gm`+(/x/.unicode==null?``:`u`),lr=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=sr,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new fr(e,t,n,r,i);this.re=new RegExp(t,cr+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(r).from,this.matchPos=mr(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=mr(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},ur=new WeakMap,dr=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=ur.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return ur.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),ur.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},fr=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=sr,this.matchPos=mr(e,r),this.re=new RegExp(t,cr+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=dr.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=mr(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=dr.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(lr.prototype[Symbol.iterator]=fr.prototype[Symbol.iterator]=function(){return this});function pr(e){try{return new RegExp(e,cr),!0}catch{return!1}}function mr(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var hr=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=ee(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=P.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,S.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},gr={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},_r=Ae.define({combine(e){return De(e,gr,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function vr(e){let t=[wr,Cr];return e&&t.push(_r.of(e)),t}var yr=h.mark({class:`cm-selectionMatch`}),br=h.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function xr(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=u.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=u.Word)}function Sr(e,t,n,r){return e(t.sliceDoc(n,n+1))==u.Word&&e(t.sliceDoc(r-1,r))==u.Word}var Cr=d.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(_r),{state:n}=e,r=n.selection;if(r.ranges.length>1)return h.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return h.none;let e=n.wordAt(i.head);if(!e)return h.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return h.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(xr(o,n,i.from,i.to)&&Sr(o,n,i.from,i.to)))return h.none}else if(a=n.sliceDoc(i.from,i.to),!a)return h.none}let s=[];for(let r of e.visibleRanges){let e=new G(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||xr(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(br.range(r,a)):(r>=i.to||a<=i.from)&&s.push(yr.range(r,a)),s.length>t.maxMatches))return h.none}}return h.set(s)}},{decorations:e=>e.decorations}),wr=S.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),Tr=({state:e,dispatch:t})=>{let{selection:n}=e,r=P.create(n.ranges.map(t=>e.wordAt(t.head)||P.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function Er(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new G(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new G(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var Dr=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return Tr({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=Er(e,r);return i?(t(e.update({selection:e.selection.addRange(P.range(i.from,i.to),!1),effects:S.scrollIntoView(i.to)})),!0):!1},K=Ae.define({combine(e){return De(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new ii(e),scrollToMatch:e=>S.scrollIntoView(e)})}}),Or=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||pr(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
1
+ import{i as e,n as t,t as n}from"./jsx-runtime-BnxRlLMJ.js";import{t as r}from"./createLucideIcon-Dy1wlrF7.js";import{t as i}from"./external-link-WSiY-639.js";import{a,n as o,r as s,t as c}from"./api-client-Bnf9LAt4.js";import{u as l}from"./index-BHEFCU01.js";import{$ as u,A as d,B as f,C as p,D as m,E as h,F as g,G as _,H as v,J as y,K as ee,L as te,M as b,N as x,O as S,P as C,Q as w,R as T,S as E,T as D,U as O,V as k,W as ne,X as A,Z as re,_ as ie,a as ae,b as oe,c as se,ct as ce,d as le,dt as ue,f as de,ft as fe,g as pe,gt as me,h as he,ht as j,i as ge,it as _e,j as ve,l as ye,lt as be,m as xe,mt as Se,n as Ce,nt as M,o as we,ot as Te,p as Ee,pt as De,q as Oe,r as ke,rt as Ae,s as je,st as N,t as Me,tt as P,u as Ne,ut as Pe,v as Fe,w as Ie,x as Le,y as Re,z as ze}from"./dist-CSp7ir0r.js";var Be=r(`file-exclamation-point`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),F=e(t());function Ve(){return Ve=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ve.apply(null,arguments)}function He(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Ue=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=Je(e.state,n.from);return r.line?Ge(e):r.block?qe(e):!1};function We(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var Ge=We(Qe,0),Ke=We(Ze,0),qe=We((e,t)=>Ze(e,t,Xe(t)),0);function Je(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var I=50;function Ye(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-I,r),o=e.sliceDoc(i,i+I),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=2*I?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+I),d=e.sliceDoc(i-I,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:/\s/.test(u.charAt(f+t.length))?1:0},close:{pos:i-p-n.length,margin:/\s/.test(d.charAt(m-1))?1:0}}:null}function Xe(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function Ze(e,t,n=t.selection.ranges){let r=n.map(e=>Je(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>Ye(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function Qe(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=Je(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}else if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var $e=A.define(),et=A.define(),tt=Ae.define(),nt=Ae.define({combine(e){return De(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),rt=ce.define({create(){return bt.empty},update(e,t){let n=t.state.facet(nt),r=t.annotation($e);if(r){let i=L.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?ut(o,o.length,n.minDepth,i):ht(o,t.startState.selection),new bt(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(et);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(Pe.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=L.fromTransaction(t),o=t.annotation(Pe.time),s=t.annotation(Pe.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new bt(e.done.map(L.fromJSON),e.undone.map(L.fromJSON))}});function it(e={}){return[rt,nt.of(e),S.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?ot:e.inputType==`historyRedo`?st:null;return n?(e.preventDefault(),n(t)):!1}})]}function at(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(rt,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var ot=at(0,!1),st=at(1,!1),ct=at(0,!0),lt=at(1,!0),L=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&w.fromJSON(t.changes),[],t.mapped&&re.fromJSON(t.mapped),t.startSelection&&P.fromJSON(t.startSelection),t.selectionsAfter.map(P.fromJSON))}static fromTransaction(t,n){let r=R;for(let e of t.startState.facet(tt)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,R)}static selection(t){return new e(void 0,R,void 0,void 0,t)}};function ut(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function dt(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function ft(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function pt(e,t){return e.length?t.length?e.concat(t):e:t}var R=[],mt=200;function ht(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-mt));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),ut(e,e.length-1,1e9,n.setSelAfter(r)))}else return[L.selection([t])]}function gt(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function _t(e,t){if(!e.length)return e;let n=e.length,r=R;for(;n;){let i=vt(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[L.selection(r)]:R}function vt(e,t,n){let r=pt(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):R,n);if(!e.changes)return L.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new L(i,N.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var yt=/^(input\.type|delete)($|\.)/,bt=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||yt.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,dt(s.changes,t.changes))||r==`input.type.compose`)?ut(o,o.length-1,i.minDepth,new L(t.changes.compose(s.changes),pt(N.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,R)):ut(o,o.length,i.minDepth,t),new e(o,R,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:R;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&ft(a[a.length-1],t)?this:new e(ht(this.done,t),this.undone,n,r)}addMapping(t){return new e(_t(this.done,t),_t(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:$e.of({side:e,rest:gt(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?R:r.slice(0,r.length-1);return i.mapped&&(n=_t(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:$e.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};bt.empty=new bt(R,R);var xt=[{key:`Mod-z`,run:ot,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:st,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:st,preventDefault:!0},{key:`Mod-u`,run:ct,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:lt,preventDefault:!0}];function z(e,t){return P.create(e.ranges.map(t),e.mainIndex)}function B(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function V({state:e,dispatch:t},n){let r=z(e.selection,n);return r.eq(e.selection,!0)?!1:(t(B(e,r)),!0)}function St(e,t){return P.cursor(t?e.to:e.from)}function Ct(e,t){return V(e,n=>n.empty?e.moveByChar(n,t):St(n,t))}function H(e){return e.textDirectionAt(e.state.selection.main.head)==m.LTR}var wt=e=>Ct(e,!H(e)),Tt=e=>Ct(e,H(e));function Et(e,t){return V(e,n=>n.empty?e.moveByGroup(n,t):St(n,t))}var Dt=e=>Et(e,!H(e)),Ot=e=>Et(e,H(e));typeof Intl<`u`&&Intl.Segmenter&&new Intl.Segmenter(void 0,{granularity:`word`});function kt(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function At(e,t,n){let r=Ie(e).resolveInner(t.head),i=n?D.closedBy:D.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;kt(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?E(e,r.from,1):E(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,P.cursor(s,n?-1:1)}var jt=e=>V(e,t=>At(e.state,t,!H(e))),Mt=e=>V(e,t=>At(e.state,t,H(e)));function Nt(e,t){return V(e,n=>{if(!n.empty)return St(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var Pt=e=>Nt(e,!1),Ft=e=>Nt(e,!0);function It(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(S.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function Lt(e,t){let n=It(e),{state:r}=e,i=z(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):St(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=S.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(B(r,i),{effects:a}),!0}var Rt=e=>Lt(e,!1),zt=e=>Lt(e,!0);function U(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=P.cursor(r.from+n))}return i}var Bt=e=>V(e,t=>U(e,t,!0)),Vt=e=>V(e,t=>U(e,t,!1)),Ht=e=>V(e,t=>U(e,t,!H(e))),Ut=e=>V(e,t=>U(e,t,H(e))),Wt=e=>V(e,t=>P.cursor(e.lineBlockAt(t.head).from,1)),Gt=e=>V(e,t=>P.cursor(e.lineBlockAt(t.head).to,-1));function Kt(e,t,n){let r=!1,i=z(e.selection,t=>{let i=E(e,t.head,-1)||E(e,t.head,1)||t.head>0&&E(e,t.head-1,1)||t.head<e.doc.length&&E(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?P.range(t.anchor,a):P.cursor(a)});return r?(t(B(e,i)),!0):!1}var qt=({state:e,dispatch:t})=>Kt(e,t,!1);function W(e,t){let n=z(e.state.selection,e=>{let n=t(e);return P.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(B(e.state,n)),!0)}function Jt(e,t){return W(e,n=>e.moveByChar(n,t))}var Yt=e=>Jt(e,!H(e)),Xt=e=>Jt(e,H(e));function Zt(e,t){return W(e,n=>e.moveByGroup(n,t))}var Qt=e=>Zt(e,!H(e)),$t=e=>Zt(e,H(e)),en=e=>W(e,t=>At(e.state,t,!H(e))),tn=e=>W(e,t=>At(e.state,t,H(e)));function nn(e,t){return W(e,n=>e.moveVertically(n,t))}var rn=e=>nn(e,!1),an=e=>nn(e,!0);function on(e,t){return W(e,n=>e.moveVertically(n,t,It(e).height))}var sn=e=>on(e,!1),cn=e=>on(e,!0),ln=e=>W(e,t=>U(e,t,!0)),un=e=>W(e,t=>U(e,t,!1)),dn=e=>W(e,t=>U(e,t,!H(e))),fn=e=>W(e,t=>U(e,t,H(e))),pn=e=>W(e,t=>P.cursor(e.lineBlockAt(t.head).from)),mn=e=>W(e,t=>P.cursor(e.lineBlockAt(t.head).to)),hn=({state:e,dispatch:t})=>(t(B(e,{anchor:0})),!0),gn=({state:e,dispatch:t})=>(t(B(e,{anchor:e.doc.length})),!0),_n=({state:e,dispatch:t})=>(t(B(e,{anchor:e.selection.main.anchor,head:0})),!0),vn=({state:e,dispatch:t})=>(t(B(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),yn=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),bn=({state:e,dispatch:t})=>{let n=zn(e).map(({from:t,to:n})=>P.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:P.create(n),userEvent:`select`})),!0},xn=({state:e,dispatch:t})=>{let n=z(e.selection,t=>{let n=Ie(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return P.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(B(e,n)),!0)};function Sn(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(B(n,P.create(i,i.length-1))),!0)}var Cn=e=>Sn(e,!1),wn=e=>Sn(e,!0),Tn=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=P.create([n.main]):n.main.empty||(r=P.create([P.cursor(n.main.head)])),r?(t(B(e,r)),!0):!1};function En(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=Dn(e,o,!1)):o>i&&(n=`delete.forward`,o=Dn(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=Dn(e,i,!1),a=Dn(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:P.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?S.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function Dn(e,t,n){if(e instanceof S)for(let r of e.state.facet(S.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var On=(e,t,n)=>En(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=Se(s,a.tabSize)%ie(a)||ie(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=j(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=j(o.text,c-o.from,!1,!1)+o.from);return c}),kn=e=>On(e,!1,!0),An=e=>On(e,!0,!1),jn=(e,t)=>En(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=j(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),Mn=e=>jn(e,!1),Nn=e=>jn(e,!0),Pn=e=>En(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Fn=e=>En(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),In=e=>En(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Ln=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:be.of([``,``])},range:P.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},Rn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:j(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:j(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:P.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function zn(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function Bn(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of zn(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(P.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(P.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:P.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var Vn=({state:e,dispatch:t})=>Bn(e,t,!1),Hn=({state:e,dispatch:t})=>Bn(e,t,!0);function Un(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of zn(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var Wn=({state:e,dispatch:t})=>Un(e,t,!1),Gn=({state:e,dispatch:t})=>Un(e,t,!0),Kn=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(zn(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=z(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function qn(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=Ie(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(D.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var Jn=Xn(!1),Yn=Xn(!0);function Xn(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&qn(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new de(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=Fe(s,r);for(c??=Se(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,oe(t,c)];return o&&l.push(oe(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:be.of(l)},range:P.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function Zn(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:P.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var Qn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new de(e,{overrideIndentation:e=>n[e]??-1}),i=Zn(e,(t,i,a)=>{let o=Fe(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=oe(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},$n=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Zn(e,(t,n)=>{n.push({from:t.from,insert:e.facet(Le)})}),{userEvent:`input.indent`})),!0),er=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Zn(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=Se(r,e.tabSize),a=0,o=oe(e,Math.max(0,i-ie(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),tr=e=>(e.setTabFocusMode(),!0),nr=[{key:`Ctrl-b`,run:wt,shift:Yt,preventDefault:!0},{key:`Ctrl-f`,run:Tt,shift:Xt},{key:`Ctrl-p`,run:Pt,shift:rn},{key:`Ctrl-n`,run:Ft,shift:an},{key:`Ctrl-a`,run:Wt,shift:pn},{key:`Ctrl-e`,run:Gt,shift:mn},{key:`Ctrl-d`,run:An},{key:`Ctrl-h`,run:kn},{key:`Ctrl-k`,run:Pn},{key:`Ctrl-Alt-h`,run:Mn},{key:`Ctrl-o`,run:Ln},{key:`Ctrl-t`,run:Rn},{key:`Ctrl-v`,run:zt}],rr=[{key:`ArrowLeft`,run:wt,shift:Yt,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Dt,shift:Qt,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:Ht,shift:dn,preventDefault:!0},{key:`ArrowRight`,run:Tt,shift:Xt,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Ot,shift:$t,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:Ut,shift:fn,preventDefault:!0},{key:`ArrowUp`,run:Pt,shift:rn,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:hn,shift:_n},{mac:`Ctrl-ArrowUp`,run:Rt,shift:sn},{key:`ArrowDown`,run:Ft,shift:an,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:gn,shift:vn},{mac:`Ctrl-ArrowDown`,run:zt,shift:cn},{key:`PageUp`,run:Rt,shift:sn},{key:`PageDown`,run:zt,shift:cn},{key:`Home`,run:Vt,shift:un,preventDefault:!0},{key:`Mod-Home`,run:hn,shift:_n},{key:`End`,run:Bt,shift:ln,preventDefault:!0},{key:`Mod-End`,run:gn,shift:vn},{key:`Enter`,run:Jn,shift:Jn},{key:`Mod-a`,run:yn},{key:`Backspace`,run:kn,shift:kn,preventDefault:!0},{key:`Delete`,run:An,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:Mn,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:Nn,preventDefault:!0},{mac:`Mod-Backspace`,run:Fn,preventDefault:!0},{mac:`Mod-Delete`,run:In,preventDefault:!0}].concat(nr.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),ir=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:jt,shift:en},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:Mt,shift:tn},{key:`Alt-ArrowUp`,run:Vn},{key:`Shift-Alt-ArrowUp`,run:Wn},{key:`Alt-ArrowDown`,run:Hn},{key:`Shift-Alt-ArrowDown`,run:Gn},{key:`Mod-Alt-ArrowUp`,run:Cn},{key:`Mod-Alt-ArrowDown`,run:wn},{key:`Escape`,run:Tn},{key:`Mod-Enter`,run:Yn},{key:`Alt-l`,mac:`Ctrl-l`,run:bn},{key:`Mod-i`,run:xn,preventDefault:!0},{key:`Mod-[`,run:er},{key:`Mod-]`,run:$n},{key:`Mod-Alt-\\`,run:Qn},{key:`Shift-Mod-k`,run:Kn},{key:`Shift-Mod-\\`,run:qt},{key:`Mod-/`,run:Ue},{key:`Alt-A`,run:Ke},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:tr}].concat(rr),ar={key:`Tab`,run:$n,shift:er},or=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,G=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(or(e)):or,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return ue(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=me(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=fe(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let a=r.charCodeAt(e),o=this.match(a,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}i==n&&e<t.length&&t.charCodeAt(e)==a&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],a=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,a=!0)),a||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<`u`&&(G.prototype[Symbol.iterator]=function(){return this});var sr={from:-1,to:-1,match:/.*/.exec(``)},cr=`gm`+(/x/.unicode==null?``:`u`),lr=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=sr,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new fr(e,t,n,r,i);this.re=new RegExp(t,cr+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(r).from,this.matchPos=mr(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=mr(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},ur=new WeakMap,dr=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=ur.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return ur.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),ur.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},fr=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=sr,this.matchPos=mr(e,r),this.re=new RegExp(t,cr+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=dr.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=mr(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=dr.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(lr.prototype[Symbol.iterator]=fr.prototype[Symbol.iterator]=function(){return this});function pr(e){try{return new RegExp(e,cr),!0}catch{return!1}}function mr(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var hr=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=ee(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=P.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,S.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},gr={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},_r=Ae.define({combine(e){return De(e,gr,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function vr(e){let t=[wr,Cr];return e&&t.push(_r.of(e)),t}var yr=h.mark({class:`cm-selectionMatch`}),br=h.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function xr(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=u.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=u.Word)}function Sr(e,t,n,r){return e(t.sliceDoc(n,n+1))==u.Word&&e(t.sliceDoc(r-1,r))==u.Word}var Cr=d.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(_r),{state:n}=e,r=n.selection;if(r.ranges.length>1)return h.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return h.none;let e=n.wordAt(i.head);if(!e)return h.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return h.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(xr(o,n,i.from,i.to)&&Sr(o,n,i.from,i.to)))return h.none}else if(a=n.sliceDoc(i.from,i.to),!a)return h.none}let s=[];for(let r of e.visibleRanges){let e=new G(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||xr(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(br.range(r,a)):(r>=i.to||a<=i.from)&&s.push(yr.range(r,a)),s.length>t.maxMatches))return h.none}}return h.set(s)}},{decorations:e=>e.decorations}),wr=S.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),Tr=({state:e,dispatch:t})=>{let{selection:n}=e,r=P.create(n.ranges.map(t=>e.wordAt(t.head)||P.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function Er(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new G(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new G(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var Dr=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return Tr({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=Er(e,r);return i?(t(e.update({selection:e.selection.addRange(P.range(i.from,i.to),!1),effects:S.scrollIntoView(i.to)})),!0):!1},K=Ae.define({combine(e){return De(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new ii(e),scrollToMatch:e=>S.scrollIntoView(e)})}}),Or=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||pr(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
2
2
  `:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Lr(this):new Mr(this)}getCursor(e,t=0,n){let r=e.doc?e:M.create({doc:e});return n??=r.doc.length,this.regexp?J(this,r,t,n):q(this,r,t,n)}},kr=class{constructor(e){this.spec=e}};function Ar(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function q(e,t,n,r){let i;return e.wholeWord&&(i=jr(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=Ar(e.test,t,i)),new G(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function jr(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(Pr(i,n-a))!=u.Word||t(Fr(i,n-a))!=u.Word)&&(t(Fr(i,r-a))!=u.Word||t(Pr(i,r-a))!=u.Word))}var Mr=class extends kr{constructor(e){super(e)}nextMatch(e,t,n){let r=q(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=q(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=q(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=q(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=q(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function Nr(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function J(e,t,n,r){let i;return e.wholeWord&&(i=Ir(t.charCategorizer(t.selection.main.head))),e.test&&(i=Nr(e.test,t,i)),new lr(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function Pr(e,t){return e.slice(j(e,t,!1),t)}function Fr(e,t){return e.slice(t,j(e,t))}function Ir(e){return(t,n,r)=>!r[0].length||(e(Pr(r.input,r.index))!=u.Word||e(Fr(r.input,r.index))!=u.Word)&&(e(Fr(r.input,r.index+r[0].length))!=u.Word||e(Pr(r.input,r.index+r[0].length))!=u.Word)}var Lr=class extends kr{nextMatch(e,t,n){let r=J(this.spec,e,n,e.doc.length).next();return r.done&&(r=J(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=J(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=J(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=J(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},Rr=N.define(),zr=N.define(),Y=ce.define({create(e){return new Br(Qr(e).create(),null)},update(e,t){for(let n of t.effects)n.is(Rr)?e=new Br(n.value.create(),e.panel):n.is(zr)&&(e=new Br(e.query,n.value?Zr:null));return e},provide:e=>Oe.from(e,e=>e.panel)}),Br=class{constructor(e,t){this.query=e,this.panel=t}},Vr=h.mark({class:`cm-searchMatch`}),Hr=h.mark({class:`cm-searchMatch cm-searchMatch-selected`}),Ur=d.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(Y))}update(e){let t=e.state.field(Y);(t!=e.startState.field(Y)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return h.none;let{view:n}=this,r=new Te;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?Hr:Vr)})}return r.finish()}},{decorations:e=>e.decorations});function Wr(e){return t=>{let n=t.state.field(Y,!1);return n&&n.query.spec.valid?e(t,n):ti(t)}}var Gr=Wr((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=P.single(r.from,r.to),a=e.state.facet(K);return e.dispatch({selection:i,effects:[si(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),ei(e),!0}),Kr=Wr((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=P.single(i.from,i.to),o=e.state.facet(K);return e.dispatch({selection:a,effects:[si(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),ei(e),!0}),qr=Wr((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:P.create(n.map(e=>P.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),Jr=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new G(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(P.range(t.value.from,t.value.to))}return t(e.update({selection:P.create(a,o),userEvent:`select.search.matches`})),!0},Yr=Wr((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),u.push(S.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`)));let d=e.state.changes(s);return o&&(c=P.single(o.from,o.to).map(d),u.push(si(e,o)),u.push(n.facet(K).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),Xr=Wr((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}});if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:S.announce.of(r),userEvent:`input.replace.all`}),!0});function Zr(e){return e.state.facet(K).createPanel(e)}function Qr(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(K);return new Or({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function $r(e){let t=g(e,Zr);return t&&t.dom.querySelector(`[main-field]`)}function ei(e){let t=$r(e);t&&t==e.root.activeElement&&t.select()}var ti=e=>{let t=e.state.field(Y,!1);if(t&&t.panel){let n=$r(e);if(n&&n!=e.root.activeElement){let r=Qr(e.state,t.query.spec);r.valid&&e.dispatch({effects:Rr.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[zr.of(!0),t?Rr.of(Qr(e.state,t.query.spec)):N.appendConfig.of(li)]});return!0},ni=e=>{let t=e.state.field(Y,!1);if(!t||!t.panel)return!1;let n=g(e,Zr);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:zr.of(!1)}),!0},ri=[{key:`Mod-f`,run:ti,scope:`editor search-panel`},{key:`F3`,run:Gr,shift:Kr,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:Gr,shift:Kr,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:ni,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:Jr},{key:`Mod-Alt-g`,run:hr},{key:`Mod-d`,run:Dr,preventDefault:!0}],ii=class{constructor(e){this.view=e;let t=this.query=e.state.field(Y).query.spec;this.commit=this.commit.bind(this),this.searchField=y(`input`,{value:t.search,placeholder:X(e,`Find`),"aria-label":X(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=y(`input`,{value:t.replace,placeholder:X(e,`Replace`),"aria-label":X(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=y(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=y(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=y(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return y(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=y(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>Gr(e),[X(e,`next`)]),n(`prev`,()=>Kr(e),[X(e,`previous`)]),n(`select`,()=>qr(e),[X(e,`all`)]),y(`label`,null,[this.caseField,X(e,`match case`)]),y(`label`,null,[this.reField,X(e,`regexp`)]),y(`label`,null,[this.wordField,X(e,`by word`)]),...e.state.readOnly?[]:[y(`br`),this.replaceField,n(`replace`,()=>Yr(e),[X(e,`replace`)]),n(`replaceAll`,()=>Xr(e),[X(e,`replace all`)])],y(`button`,{name:`close`,onclick:()=>ni(e),"aria-label":X(e,`close`),type:`button`},[`×`])])}commit(){let e=new Or({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Rr.of(e)}))}keydown(e){_(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Kr:Gr)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Yr(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(Rr)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(K).top}};function X(e,t){return e.state.phrase(t)}var ai=30,oi=/[\s\.,:;?!]/;function si(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-ai),o=Math.min(i,n+ai),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<ai;e++)if(!oi.test(s[e+1])&&oi.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-ai;e--)if(!oi.test(s[e-1])&&oi.test(s[e])){s=s.slice(0,e);break}}return S.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var ci=S.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),li=[Y,_e.low(Ur),ci],ui=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},di=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(Ci).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new Te,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=Pi(s);if(i)o.add(n,n,h.widget({widget:new Di(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,h.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let f=o.finish();return new e(f,n,Z(f))}};function Z(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(!r)r=new ui(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new ui(r.from,n,r.diagnostic)}),r}function fi(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(Ci).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(mi))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function pi(e,t){return e.field(Q,!1)?t:t.concat(N.appendConfig.of(Fi))}var mi=N.define(),hi=N.define(),gi=N.define(),Q=ce.define({create(){return new di(h.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=Z(n,e.selected.diagnostic,i)||Z(n,null,i)}!n.size&&i&&t.state.facet(Ci).autoPanel&&(i=null),e=new di(n,i,r)}for(let n of t.effects)if(n.is(mi)){let r=t.state.facet(Ci).autoPanel?n.value.length?ki.open:null:e.panel;e=di.init(n.value,r,t.state)}else n.is(hi)?e=new di(e.diagnostics,n.value?ki.open:null,e.selected):n.is(gi)&&(e=new di(e.diagnostics,e.panel,n.value));return e},provide:e=>[Oe.from(e,e=>e.panel),S.decorations.from(e,e=>e.diagnostics)]}),_i=h.mark({class:`cm-lintRange cm-lintRange-active`});function vi(e,t,n){let{diagnostics:r}=e.state.field(Q),i,a=-1,o=-1;r.between(t-(n<0?1:0),t+(n>0?1:0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet(Ci).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:e.state.doc.lineAt(a).to<o,create(){return{dom:yi(e,i)}}}:null}function yi(e,t){return y(`ul`,{class:`cm-tooltip-lint`},t.map(t=>Ei(e,t,!1)))}var bi=e=>{let t=e.state.field(Q,!1);(!t||!t.panel)&&e.dispatch({effects:pi(e.state,[hi.of(!0)])});let n=g(e,ki.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},xi=e=>{let t=e.state.field(Q,!1);return!t||!t.panel?!1:(e.dispatch({effects:hi.of(!1)}),!0)},Si=[{key:`Mod-Shift-m`,run:bi,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(Q,!1);if(!t)return!1;let n=e.state.selection.main,r=Z(t.diagnostics,null,n.to+1);return!r&&(r=Z(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],Ci=Ae.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...De(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:wi,tooltipFilter:wi,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function wi(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function Ti(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function Ei(e,t,n){let r=n?Ti(t.actions):[];return y(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},y(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=Z(e.state.field(Q).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),y(`u`,s.slice(c,c+1)),s.slice(c+1)];return y(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&y(`div`,{class:`cm-diagnosticSource`},t.source))}var Di=class extends ve{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return y(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},Oi=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=Ei(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},ki=class e{constructor(e){this.view=e,this.items=[];let t=t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)xi(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=Ti(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=Z(this.view.state.field(Q).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},n=e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)};this.list=y(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t,onclick:n}),this.dom=y(`div`,{class:`cm-panel-lint`},this.list,y(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>xi(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(Q).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Q),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new Oi(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new Oi(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=Z(this.view.state.field(Q).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:gi.of(t)})}static open(t){return new e(t)}};function Ai(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function ji(e){return Ai(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var Mi=S.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:ji(`#d11`)},".cm-lintRange-warning":{backgroundImage:ji(`orange`)},".cm-lintRange-info":{backgroundImage:ji(`#999`)},".cm-lintRange-hint":{backgroundImage:ji(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function Ni(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function Pi(e){let t=`hint`,n=1;for(let r of e){let e=Ni(r.severity);e>n&&(n=e,t=r.severity)}return t}var Fi=[Q,S.decorations.compute([Q],e=>{let{selected:t,panel:n}=e.field(Q);return!t||!n||t.from==t.to?h.none:h.set([_i.range(t.from,t.to)])}),f(vi,{hideOn:fi}),Mi],Ii=function(e){e===void 0&&(e={});var{crosshairCursor:t=!1}=e,n=[];e.closeBracketsKeymap!==!1&&(n=n.concat(Ne)),e.defaultKeymap!==!1&&(n=n.concat(ir)),e.searchKeymap!==!1&&(n=n.concat(ri)),e.historyKeymap!==!1&&(n=n.concat(xt)),e.foldKeymap!==!1&&(n=n.concat(pe)),e.completionKeymap!==!1&&(n=n.concat(le)),e.lintKeymap!==!1&&(n=n.concat(Si));var r=[];return e.lineNumbers!==!1&&r.push(v()),e.highlightActiveLineGutter!==!1&&r.push(T()),e.highlightSpecialChars!==!1&&r.push(ze()),e.history!==!1&&r.push(it()),e.foldGutter!==!1&&r.push(he()),e.drawSelection!==!1&&r.push(x()),e.dropCursor!==!1&&r.push(C()),e.allowMultipleSelections!==!1&&r.push(M.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&r.push(Re()),e.syntaxHighlighting!==!1&&r.push(p(xe,{fallback:!0})),e.bracketMatching!==!1&&r.push(Ee()),e.closeBrackets!==!1&&r.push(ye()),e.autocompletion!==!1&&r.push(se()),e.rectangularSelection!==!1&&r.push(ne()),t!==!1&&r.push(b()),e.highlightActiveLine!==!1&&r.push(te()),e.highlightSelectionMatches!==!1&&r.push(vr()),e.tabSize&&typeof e.tabSize==`number`&&r.push(Le.of(` `.repeat(e.tabSize))),r.concat([k.of(n.flat())]).filter(Boolean)},Li=S.theme({"&":{backgroundColor:`#fff`}},{dark:!1}),Ri=function(e){e===void 0&&(e={});var{indentWithTab:t=!0,editable:n=!0,readOnly:r=!1,theme:i=`light`,placeholder:a=``,basicSetup:o=!0}=e,s=[];switch(t&&s.unshift(k.of([ar])),o&&(typeof o==`boolean`?s.unshift(Ii()):s.unshift(Ii(o))),a&&s.unshift(O(a)),i){case`light`:s.push(Li);break;case`dark`:s.push(je);break;case`none`:break;default:s.push(i);break}return n===!1&&s.push(S.editable.of(!1)),r&&s.push(M.readOnly.of(!0)),[...s]},zi=e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(e=>!e.empty)}),Bi=class{constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(e=>{try{e()}catch(e){console.error(`TimeoutLatch callback error:`,e)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}},Vi=class{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}},Hi=null,Ui=()=>typeof window>`u`?new Vi:(Hi||=new Vi,Hi),Wi=A.define(),Gi=200,Ki=[];function qi(e){var{value:t,selection:n,onChange:r,onStatistics:i,onCreateEditor:a,onUpdate:o,extensions:s=Ki,autoFocus:c,theme:l=`light`,height:u=null,minHeight:d=null,maxHeight:f=null,width:p=null,minWidth:m=null,maxWidth:h=null,placeholder:g=``,editable:_=!0,readOnly:v=!1,indentWithTab:y=!0,basicSetup:ee=!0,root:te,initialState:b}=e,[x,C]=(0,F.useState)(),[w,T]=(0,F.useState)(),[E,D]=(0,F.useState)(),O=(0,F.useState)(()=>({current:null}))[0],k=(0,F.useState)(()=>({current:null}))[0],ne=S.theme({"&":{height:u,minHeight:d,maxHeight:f,width:p,minWidth:m,maxWidth:h},"& .cm-scroller":{height:`100% !important`}}),A=[S.updateListener.of(e=>{e.docChanged&&typeof r==`function`&&!e.transactions.some(e=>e.annotation(Wi))&&(O.current?O.current.reset():(O.current=new Bi(()=>{if(k.current){var e=k.current;k.current=null,e()}O.current=null},Gi),Ui().add(O.current)),r(e.state.doc.toString(),e)),i&&i(zi(e))}),ne,...Ri({theme:l,editable:_,readOnly:v,placeholder:g,indentWithTab:y,basicSetup:ee})];return o&&typeof o==`function`&&A.push(S.updateListener.of(o)),A=A.concat(s),(0,F.useLayoutEffect)(()=>{if(x&&!E){var e={doc:t,selection:n,extensions:A},r=b?M.fromJSON(b.json,e,b.fields):M.create(e);if(D(r),!w){var i=new S({state:r,parent:x,root:te});T(i),a&&a(i,r)}}return()=>{w&&(D(void 0),T(void 0))}},[x,E]),(0,F.useEffect)(()=>{e.container&&C(e.container)},[e.container]),(0,F.useEffect)(()=>()=>{w&&(w.destroy(),T(void 0)),O.current&&=(O.current.cancel(),null)},[w]),(0,F.useEffect)(()=>{c&&w&&w.focus()},[c,w]),(0,F.useEffect)(()=>{w&&w.dispatch({effects:N.reconfigure.of(A)})},[l,s,u,d,f,p,m,h,g,_,v,y,ee,r,o]),(0,F.useEffect)(()=>{if(t!==void 0){var e=w?w.state.doc.toString():``;if(w&&t!==e){var n=O.current&&!O.current.isDone,r=()=>{w&&t!==w.state.doc.toString()&&w.dispatch({changes:{from:0,to:w.state.doc.toString().length,insert:t||``},annotations:[Wi.of(!0)]})};n?k.current=r:r()}}},[t,w]),{state:E,setState:D,view:w,setView:T,container:x,setContainer:C}}var $=n(),Ji=[`className`,`value`,`selection`,`extensions`,`onChange`,`onStatistics`,`onCreateEditor`,`onUpdate`,`autoFocus`,`theme`,`height`,`minHeight`,`maxHeight`,`width`,`minWidth`,`maxWidth`,`basicSetup`,`placeholder`,`indentWithTab`,`editable`,`readOnly`,`root`,`initialState`],Yi=(0,F.forwardRef)((e,t)=>{var{className:n,value:r=``,selection:i,extensions:a=[],onChange:o,onStatistics:s,onCreateEditor:c,onUpdate:l,autoFocus:u,theme:d=`light`,height:f,minHeight:p,maxHeight:m,width:h,minWidth:g,maxWidth:_,basicSetup:v,placeholder:y,indentWithTab:ee,editable:te,readOnly:b,root:x,initialState:S}=e,C=He(e,Ji),w=(0,F.useRef)(null),{state:T,view:E,container:D,setContainer:O}=qi({root:x,value:r,autoFocus:u,theme:d,height:f,minHeight:p,maxHeight:m,width:h,minWidth:g,maxWidth:_,basicSetup:v,placeholder:y,indentWithTab:ee,editable:te,readOnly:b,selection:i,onChange:o,onStatistics:s,onCreateEditor:c,onUpdate:l,extensions:a,initialState:S});(0,F.useImperativeHandle)(t,()=>({editor:w.current,state:T,view:E}),[w,D,T,E]);var k=(0,F.useCallback)(e=>{w.current=e,O(e)},[O]);if(typeof r!=`string`)throw Error(`value must be typeof string but got `+typeof r);return(0,$.jsx)(`div`,Ve({ref:k,className:(typeof d==`string`?`cm-theme-`+d:`cm-theme`)+(n?` `+n:``)},C))});Yi.displayName=`CodeMirror`;var Xi=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`ico`]),Zi=`pdf`;function Qi(e){return e.split(`.`).pop()?.toLowerCase()??``}function $i(e){switch(Qi(e)){case`js`:case`jsx`:return we({jsx:!0});case`ts`:case`tsx`:return we({jsx:!0,typescript:!0});case`py`:return ae();case`html`:return ke();case`css`:case`scss`:return ge();case`json`:return Ce();case`md`:case`mdx`:return Me();default:return null}}function ea({metadata:e,tabId:t}){let n=e?.filePath,r=e?.projectName,[i,o]=(0,F.useState)(null),[u,d]=(0,F.useState)(`utf-8`),[f,p]=(0,F.useState)(!0),[m,h]=(0,F.useState)(null),[g,_]=(0,F.useState)(!1),v=(0,F.useRef)(null),y=(0,F.useRef)(``),{tabs:ee,updateTab:te}=l(),b=ee.find(e=>e.id===t),x=n?Qi(n):``,S=Xi.has(x),C=x===Zi;(0,F.useEffect)(()=>{if(!(!n||!r)){if(S||C){p(!1);return}return p(!0),h(null),c.get(`${s(r)}/files/read?path=${encodeURIComponent(n)}`).then(e=>{o(e.content),d(e.encoding),y.current=e.content,p(!1)}).catch(e=>{h(e instanceof Error?e.message:`Failed to load file`),p(!1)}),()=>{v.current&&clearTimeout(v.current)}}},[n,r,S,C]),(0,F.useEffect)(()=>{if(!b)return;let e=n?.split(`/`).pop()??`Untitled`,t=g?`${e} \u25CF`:e;b.title!==t&&te(b.id,{title:t})},[g]);let w=(0,F.useCallback)(async e=>{if(!(!n||!r))try{await c.put(`${s(r)}/files/write`,{path:n,content:e}),_(!1)}catch{}},[n,r]);function T(e){o(e),y.current=e,_(!0),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{w(y.current)},1e3)}if(!n||!r)return(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full text-text-secondary text-sm`,children:`No file selected.`});if(f)return(0,$.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-text-secondary`,children:[(0,$.jsx)(a,{className:`size-5 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm`,children:`Loading file...`})]});if(m)return(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full text-error text-sm`,children:m});if(S)return(0,$.jsx)(ta,{filePath:n,projectName:r});if(C)return(0,$.jsx)(na,{filePath:n,projectName:r});if(u===`base64`)return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,$.jsx)(Be,{className:`size-10 text-text-subtle`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`This file is a binary format and cannot be displayed.`}),(0,$.jsx)(`p`,{className:`text-xs text-text-subtle`,children:n})]});let E=[],D=$i(n);return D&&E.push(D),(0,$.jsx)(`div`,{className:`h-full w-full overflow-hidden`,children:(0,$.jsx)(Yi,{value:i??``,onChange:T,extensions:E,theme:je,height:`100%`,style:{height:`100%`,fontSize:`13px`,fontFamily:`var(--font-mono)`},basicSetup:{lineNumbers:!0,foldGutter:!0,autocompletion:!0,bracketMatching:!0,closeBrackets:!0,highlightActiveLine:!0,indentOnInput:!0}})})}function ta({filePath:e,projectName:t}){let[n,r]=(0,F.useState)(null),[i,c]=(0,F.useState)(!1);return(0,F.useEffect)(()=>{let n,i=`${s(t)}/files/raw?path=${encodeURIComponent(e)}`,a=o();return fetch(i,{headers:a?{Authorization:`Bearer ${a}`}:{}}).then(e=>{if(!e.ok)throw Error(`Failed`);return e.blob()}).then(e=>{let t=URL.createObjectURL(e);n=t,r(t)}).catch(()=>c(!0)),()=>{n&&URL.revokeObjectURL(n)}},[e,t]),i?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,$.jsx)(Be,{className:`size-10 text-text-subtle`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`Failed to load image.`})]}):n?(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full p-4 bg-surface overflow-auto`,children:(0,$.jsx)(`img`,{src:n,alt:e,className:`max-w-full max-h-full object-contain`})}):(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,$.jsx)(a,{className:`size-5 animate-spin text-text-subtle`})})}function na({filePath:e,projectName:t}){let[n,r]=(0,F.useState)(null),[c,l]=(0,F.useState)(!1);(0,F.useEffect)(()=>{let n,i=`${s(t)}/files/raw?path=${encodeURIComponent(e)}`,a=o();return fetch(i,{headers:a?{Authorization:`Bearer ${a}`}:{}}).then(e=>{if(!e.ok)throw Error(`Failed`);return e.blob()}).then(e=>{let t=URL.createObjectURL(new Blob([e],{type:`application/pdf`}));n=t,r(t)}).catch(()=>l(!0)),()=>{n&&URL.revokeObjectURL(n)}},[e,t]);let u=(0,F.useCallback)(()=>{n&&window.open(n,`_blank`)},[n]);return c?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,$.jsx)(Be,{className:`size-10 text-text-subtle`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`Failed to load PDF.`})]}):n?(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 border-b border-border bg-background shrink-0`,children:[(0,$.jsx)(`span`,{className:`text-xs text-text-secondary truncate`,children:e}),(0,$.jsxs)(`button`,{onClick:u,className:`flex items-center gap-1 text-xs text-text-secondary hover:text-text-primary transition-colors`,children:[(0,$.jsx)(i,{className:`size-3`}),`Open in new tab`]})]}),(0,$.jsx)(`iframe`,{src:n,title:e,className:`flex-1 w-full border-none`})]}):(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,$.jsx)(a,{className:`size-5 animate-spin text-text-subtle`})})}export{ea as CodeEditor};